⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242995 in webkit


Ignore:
Timestamp:
Mar 15, 2019, 8:43:20 AM (7 years ago)
Author:
Antti Koivisto
Message:

Optimize Region for single rectangle case
https://bugs.webkit.org/show_bug.cgi?id=195743

Reviewed by Simon Fraser.

Source/WebCore:

Instrumentation shows vast majority of Region objects consist of a single rectangle. However it always allocates
the large Shape data structure. This makes it unsuitable to use as a member in any popular objects.

This patch optimizes the single rectangle case by using only the bounds rectangle to describe it.
Shape is allocated on demand. This makes it safe to use Region as a data member where a rectangle is the common case.

The patch also modernizes Region encoding/decoding support.

  • platform/graphics/Region.cpp:

(WebCore::Region::Region):
(WebCore::Region::~Region):
(WebCore::Region::operator=):
(WebCore::Region::rects const):
(WebCore::Region::contains const):
(WebCore::Region::intersects const):
(WebCore::Region::Shape::Shape):
(WebCore::Region::Shape::appendSpan):
(WebCore::Region::dump const):
(WebCore::Region::intersect):
(WebCore::Region::unite):
(WebCore::Region::subtract):
(WebCore::Region::translate):
(WebCore::Region::setShape):
(WebCore::Region::Shape::isValid const): Deleted.
(WebCore::Region::Shape::swap): Deleted.
(WebCore::Region::updateBoundsFromShape): Deleted.

Remove some now unused function.

  • platform/graphics/Region.h:

(WebCore::Region::isRect const):
(WebCore::Region::gridSize const):
(WebCore::Region::copyShape const):
(WebCore::operator==):
(WebCore::Region::Span::encode const):
(WebCore::Region::Span::decode):
(WebCore::Region::Shape::encode const):
(WebCore::Region::Shape::decode):
(WebCore::Region::encode const):
(WebCore::Region::decode):

This is now part of type.

(WebCore::Region::isValid const): Deleted.
(WebCore::Region::Span::Span): Deleted.
(WebCore::Region::shapeSegments const): Deleted.
(WebCore::Region::shapeSpans const): Deleted.
(WebCore::Region::setShapeSegments): Deleted.
(WebCore::Region::setShapeSpans): Deleted.
(WebCore::Region::Shape::segments const): Deleted.
(WebCore::Region::Shape::spans const): Deleted.
(WebCore::Region::Shape::setSegments): Deleted.
(WebCore::Region::Shape::setSpans): Deleted.

No need to expose these for encoding anymore.

Source/WebKit:

  • Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<EventTrackingRegions>::decode):
(IPC::ArgumentCoder<Region::Span>::encode): Deleted.
(IPC::ArgumentCoder<Region::Span>::decode): Deleted.
(IPC::ArgumentCoder<Region>::encode): Deleted.
(IPC::ArgumentCoder<Region>::decode): Deleted.

  • Shared/WebCoreArgumentCoders.h:
Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242992 r242995  
     12019-03-15  Antti Koivisto  <antti@apple.com>
     2
     3        Optimize Region for single rectangle case
     4        https://bugs.webkit.org/show_bug.cgi?id=195743
     5
     6        Reviewed by Simon Fraser.
     7
     8        Instrumentation shows vast majority of Region objects consist of a single rectangle. However it always allocates
     9        the large Shape data structure. This makes it unsuitable to use as a member in any popular objects.
     10
     11        This patch optimizes the single rectangle case by using only the bounds rectangle to describe it.
     12        Shape is allocated on demand. This makes it safe to use Region as a data member where a rectangle is the common case.
     13
     14        The patch also modernizes Region encoding/decoding support.
     15
     16        * platform/graphics/Region.cpp:
     17        (WebCore::Region::Region):
     18        (WebCore::Region::~Region):
     19        (WebCore::Region::operator=):
     20        (WebCore::Region::rects const):
     21        (WebCore::Region::contains const):
     22        (WebCore::Region::intersects const):
     23        (WebCore::Region::Shape::Shape):
     24        (WebCore::Region::Shape::appendSpan):
     25        (WebCore::Region::dump const):
     26        (WebCore::Region::intersect):
     27        (WebCore::Region::unite):
     28        (WebCore::Region::subtract):
     29        (WebCore::Region::translate):
     30        (WebCore::Region::setShape):
     31        (WebCore::Region::Shape::isValid const): Deleted.
     32        (WebCore::Region::Shape::swap): Deleted.
     33        (WebCore::Region::updateBoundsFromShape): Deleted.
     34
     35        Remove some now unused function.
     36
     37        * platform/graphics/Region.h:
     38        (WebCore::Region::isRect const):
     39        (WebCore::Region::gridSize const):
     40        (WebCore::Region::copyShape const):
     41        (WebCore::operator==):
     42        (WebCore::Region::Span::encode const):
     43        (WebCore::Region::Span::decode):
     44        (WebCore::Region::Shape::encode const):
     45        (WebCore::Region::Shape::decode):
     46        (WebCore::Region::encode const):
     47        (WebCore::Region::decode):
     48
     49        This is now part of type.
     50
     51        (WebCore::Region::isValid const): Deleted.
     52        (WebCore::Region::Span::Span): Deleted.
     53        (WebCore::Region::shapeSegments const): Deleted.
     54        (WebCore::Region::shapeSpans const): Deleted.
     55        (WebCore::Region::setShapeSegments): Deleted.
     56        (WebCore::Region::setShapeSpans): Deleted.
     57        (WebCore::Region::Shape::segments const): Deleted.
     58        (WebCore::Region::Shape::spans const): Deleted.
     59        (WebCore::Region::Shape::setSegments): Deleted.
     60        (WebCore::Region::Shape::setSpans): Deleted.
     61
     62        No need to expose these for encoding anymore.
     63
    1642019-03-15  Devin Rousso  <drousso@apple.com>
    265
  • trunk/Source/WebCore/platform/graphics/Region.cpp

    r163509 r242995  
    4343Region::Region(const IntRect& rect)
    4444    : m_bounds(rect)
    45     , m_shape(rect)
    46 {
    47 }
    48 
    49 Vector<IntRect> Region::rects() const
    50 {
    51     Vector<IntRect> rects;
    52 
    53     for (Shape::SpanIterator span = m_shape.spans_begin(), end = m_shape.spans_end(); span != end && span + 1 != end; ++span) {
     45{
     46}
     47
     48Region::Region(const Region& other)
     49    : m_bounds(other.m_bounds)
     50    , m_shape(other.copyShape())
     51{
     52}
     53
     54Region::Region(Region&& other)
     55    : m_bounds(WTFMove(other.m_bounds))
     56    , m_shape(WTFMove(other.m_shape))
     57{
     58}
     59
     60Region::~Region()
     61{
     62}
     63
     64Region& Region::operator=(const Region& other)
     65{
     66    m_bounds = other.m_bounds;
     67    m_shape = other.copyShape();
     68    return *this;
     69}
     70
     71Region& Region::operator=(Region&& other)
     72{
     73    m_bounds = WTFMove(other.m_bounds);
     74    m_shape = WTFMove(other.m_shape);
     75    return *this;
     76}
     77
     78Vector<IntRect, 1> Region::rects() const
     79{
     80    Vector<IntRect, 1> rects;
     81
     82    if (!m_shape) {
     83        if (!m_bounds.isEmpty())
     84            rects.uncheckedAppend(m_bounds);
     85        return rects;
     86    }
     87
     88    for (Shape::SpanIterator span = m_shape->spans_begin(), end = m_shape->spans_end(); span != end && span + 1 != end; ++span) {
    5489        int y = span->y;
    5590        int height = (span + 1)->y - y;
    5691
    57         for (Shape::SegmentIterator segment = m_shape.segments_begin(span), end = m_shape.segments_end(span); segment != end && segment + 1 != end; segment += 2) {
     92        for (Shape::SegmentIterator segment = m_shape->segments_begin(span), end = m_shape->segments_end(span); segment != end && segment + 1 != end; segment += 2) {
    5893            int x = *segment;
    5994            int width = *(segment + 1) - x;
     
    71106        return false;
    72107
    73     return Shape::compareShapes<Shape::CompareContainsOperation>(m_shape, region.m_shape);
     108    if (!m_shape)
     109        return true;
     110
     111    return Shape::compareShapes<Shape::CompareContainsOperation>(*m_shape, region.m_shape ? *region.m_shape : Shape(region.m_bounds));
    74112}
    75113
     
    79117        return false;
    80118
    81     for (Shape::SpanIterator span = m_shape.spans_begin(), end = m_shape.spans_end(); span != end && span + 1 != end; ++span) {
     119    if (!m_shape)
     120        return true;
     121
     122    for (Shape::SpanIterator span = m_shape->spans_begin(), end = m_shape->spans_end(); span != end && span + 1 != end; ++span) {
    82123        int y = span->y;
    83124        int maxY = (span + 1)->y;
     
    88129            continue;
    89130
    90         for (Shape::SegmentIterator segment = m_shape.segments_begin(span), end = m_shape.segments_end(span); segment != end && segment + 1 != end; segment += 2) {
     131        for (Shape::SegmentIterator segment = m_shape->segments_begin(span), end = m_shape->segments_end(span); segment != end && segment + 1 != end; segment += 2) {
    91132            int x = *segment;
    92133            int maxX = *(segment + 1);
     
    107148        return false;
    108149
    109     return Shape::compareShapes<Shape::CompareIntersectsOperation>(m_shape, region.m_shape);
    110 }
    111 
    112 unsigned Region::totalArea() const
    113 {
    114     Vector<IntRect> rects = this->rects();
    115     size_t size = rects.size();
    116     unsigned totalArea = 0;
    117 
    118     for (size_t i = 0; i < size; ++i) {
    119         IntRect rect = rects[i];
     150    if (!m_shape && !region.m_shape)
     151        return true;
     152
     153    return Shape::compareShapes<Shape::CompareIntersectsOperation>(m_shape ? *m_shape : m_bounds, region.m_shape ? *region.m_shape : region.m_bounds);
     154}
     155
     156uint64_t Region::totalArea() const
     157{
     158    uint64_t totalArea = 0;
     159
     160    for (auto& rect : rects())
    120161        totalArea += (rect.width() * rect.height());
    121     }
    122162
    123163    return totalArea;
     
    222262};
    223263
    224 Region::Shape::Shape()
    225 {
    226 }
    227 
    228264Region::Shape::Shape(const IntRect& rect)
    229 {
    230     appendSpan(rect.y());
    231     appendSegment(rect.x());
    232     appendSegment(rect.maxX());
    233     appendSpan(rect.maxY());
     265    : m_segments({ rect.x(), rect.maxX() })
     266    , m_spans({ { rect.y(), 0 }, { rect.maxY(), 2 } })
     267{
    234268}
    235269
    236270void Region::Shape::appendSpan(int y)
    237271{
    238     m_spans.append(Span(y, m_segments.size()));
     272    m_spans.append({ y, m_segments.size() });
    239273}
    240274
     
    331365}
    332366#endif
    333 
    334 bool Region::Shape::isValid() const
    335 {
    336     for (auto span = spans_begin(), end = spans_end(); span != end && span + 1 != end; ++span) {
    337         int y = span->y;
    338         int height = (span + 1)->y - y;
    339        
    340         if (height < 0)
    341             return false;
    342 
    343         for (auto segment = segments_begin(span), end = segments_end(span); segment != end && segment + 1 != end; segment += 2) {
    344             int x = *segment;
    345             int width = *(segment + 1) - x;
    346            
    347             if (width < 0)
    348                 return false;
    349         }
    350     }
    351 
    352     return true;
    353 }
    354367
    355368IntRect Region::Shape::bounds() const
     
    396409    for (size_t i = 0; i < m_spans.size(); ++i)
    397410        m_spans[i].y += offset.height();
    398 }
    399 
    400 void Region::Shape::swap(Shape& other)
    401 {
    402     m_segments.swap(other.m_segments);
    403     m_spans.swap(other.m_spans);
    404411}
    405412
     
    568575    printf("Bounds: (%d, %d, %d, %d)\n",
    569576           m_bounds.x(), m_bounds.y(), m_bounds.width(), m_bounds.height());
    570     m_shape.dump();
     577    if (m_shape)
     578        m_shape->dump();
    571579}
    572580#endif
    573581
    574 void Region::updateBoundsFromShape()
    575 {
    576     m_bounds = m_shape.bounds();
    577 }
    578 
    579582void Region::intersect(const Region& region)
    580583{
     
    582585        return;
    583586    if (!m_bounds.intersects(region.m_bounds)) {
    584         m_shape = Shape();
     587        m_shape = nullptr;
    585588        m_bounds = IntRect();
    586589        return;
    587590    }
    588 
    589     Shape intersectedShape = Shape::intersectShapes(m_shape, region.m_shape);
    590 
    591     m_shape.swap(intersectedShape);
    592     m_bounds = m_shape.bounds();
     591    if (!m_shape && !region.m_shape) {
     592        m_bounds = intersection(m_bounds, region.m_bounds);
     593        return;
     594    }
     595
     596    setShape(Shape::intersectShapes(m_shape ? *m_shape : m_bounds, region.m_shape ? *region.m_shape : region.m_bounds));
    593597}
    594598
     
    597601    if (region.isEmpty())
    598602        return;
    599     if (isRect() && m_bounds.contains(region.m_bounds))
    600         return;
     603    if (isEmpty()) {
     604        m_bounds = region.m_bounds;
     605        m_shape = region.copyShape();
     606        return;
     607    }
    601608    if (region.isRect() && region.m_bounds.contains(m_bounds)) {
    602         m_shape = region.m_shape;
    603609        m_bounds = region.m_bounds;
    604         return;
    605     }
    606     // FIXME: We may want another way to construct a Region without doing this test when we expect it to be false.
    607     if (!isRect() && contains(region))
    608         return;
    609 
    610     Shape unitedShape = Shape::unionShapes(m_shape, region.m_shape);
    611 
    612     m_shape.swap(unitedShape);
    613     m_bounds.unite(region.m_bounds);
     610        m_shape = nullptr;
     611        return;
     612    }
     613    if (contains(region))
     614        return;
     615
     616    setShape(Shape::unionShapes(m_shape ? *m_shape : m_bounds, region.m_shape ? *region.m_shape : region.m_bounds));
    614617}
    615618
    616619void Region::subtract(const Region& region)
    617620{
    618     if (m_bounds.isEmpty())
     621    if (isEmpty())
    619622        return;
    620623    if (region.isEmpty())
     
    623626        return;
    624627
    625     Shape subtractedShape = Shape::subtractShapes(m_shape, region.m_shape);
    626 
    627     m_shape.swap(subtractedShape);
    628     m_bounds = m_shape.bounds();
     628    setShape(Shape::subtractShapes(m_shape ? *m_shape : m_bounds, region.m_shape ? *region.m_shape : region.m_bounds));
    629629}
    630630
     
    632632{
    633633    m_bounds.move(offset);
    634     m_shape.translate(offset);
    635 }
     634    if (m_shape)
     635        m_shape->translate(offset);
     636}
     637
     638void Region::setShape(Shape&& shape)
     639{
     640    m_bounds = shape.bounds();
     641
     642    if (shape.isRect()) {
     643        m_shape = nullptr;
     644        return;
     645    }
     646
     647    if (!m_shape)
     648        m_shape = std::make_unique<Shape>(WTFMove(shape));
     649    else
     650        *m_shape = WTFMove(shape);
     651}
     652
    636653
    637654} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/Region.h

    r242794 r242995  
    2828
    2929#include "IntRect.h"
     30#include <wtf/Optional.h>
     31#include <wtf/PointerComparison.h>
    3032#include <wtf/Vector.h>
    3133
     
    3941    WEBCORE_EXPORT Region(const IntRect&);
    4042
     43    WEBCORE_EXPORT Region(const Region&);
     44    WEBCORE_EXPORT Region(Region&&);
     45
     46    WEBCORE_EXPORT ~Region();
     47
     48    WEBCORE_EXPORT Region& operator=(const Region&);
     49    WEBCORE_EXPORT Region& operator=(Region&&);
     50
    4151    IntRect bounds() const { return m_bounds; }
    4252    bool isEmpty() const { return m_bounds.isEmpty(); }
    43     bool isRect() const { return m_shape.isRect(); }
    44 
    45     WEBCORE_EXPORT Vector<IntRect> rects() const;
     53    bool isRect() const { return !m_shape; }
     54
     55    WEBCORE_EXPORT Vector<IntRect, 1> rects() const;
    4656
    4757    WEBCORE_EXPORT void unite(const Region&);
     
    5969    WEBCORE_EXPORT bool intersects(const Region&) const;
    6070
    61     WEBCORE_EXPORT unsigned totalArea() const;
    62 
    63     unsigned gridSize() const { return m_shape.gridSize(); }
     71    WEBCORE_EXPORT uint64_t totalArea() const;
     72
     73    unsigned gridSize() const { return m_shape ? m_shape->gridSize() : 0; }
    6474
    6575#ifndef NDEBUG
     
    6777#endif
    6878
    69     bool isValid() const { return m_shape.isValid(); }
    70 
    71     // This is internal to Region, but exposed just for encoding.
    72     // FIXME: figure out a better way to encode WebCore classes.
     79    template<class Encoder> void encode(Encoder&) const;
     80    template<class Decoder> static Optional<Region> decode(Decoder&);
     81    // FIXME: Remove legacy decode.
     82    template<class Decoder> static bool decode(Decoder&, Region&);
     83
     84private:
    7385    struct Span {
    74         Span()
    75             : y(0)
    76             , segmentIndex(0)
    77         {
    78         }
    79 
    80         Span(int y, size_t segmentIndex)
    81             : y(y)
    82             , segmentIndex(segmentIndex)
    83         {
    84         }
    85 
    86         int y;
    87         size_t segmentIndex;
     86        int y { 0 };
     87        size_t segmentIndex { 0 };
     88
     89        template<class Encoder> void encode(Encoder&) const;
     90        template<class Decoder> static Optional<Span> decode(Decoder&);
    8891    };
    89 
    90     // For encoding/decoding only.
    91     const Vector<int, 32>& shapeSegments() const { return m_shape.segments(); }
    92     const Vector<Span, 16>& shapeSpans() const { return m_shape.spans(); }
    93 
    94     void setShapeSegments(const Vector<int>& segments) { m_shape.setSegments(segments); }
    95     void setShapeSpans(const Vector<Span>& spans) { m_shape.setSpans(spans); }
    96     WEBCORE_EXPORT void updateBoundsFromShape();
    97 
    98 private:
    9992
    10093    class Shape {
    10194    public:
    102         Shape();
     95        Shape() = default;
    10396        Shape(const IntRect&);
    10497
     
    121114
    122115        WEBCORE_EXPORT void translate(const IntSize&);
    123         void swap(Shape&);
    124116
    125117        struct CompareContainsOperation;
     
    128120        template<typename CompareOperation>
    129121        static bool compareShapes(const Shape& shape1, const Shape& shape2);
    130        
    131         WEBCORE_EXPORT bool isValid() const;
    132 
    133         // For encoding/decoding only.
    134         const Vector<int, 32>& segments() const { return m_segments; }
    135         const Vector<Span, 16>& spans() const { return m_spans; }
    136 
    137         void setSegments(const Vector<int>& segments) { m_segments = segments; }
    138         void setSpans(const Vector<Span>& spans) { m_spans = spans; }
     122
     123        template<class Encoder> void encode(Encoder&) const;
     124        template<class Decoder> static Optional<Shape> decode(Decoder&);
    139125
    140126#ifndef NDEBUG
     
    163149    };
    164150
     151    std::unique_ptr<Shape> copyShape() const { return m_shape ? std::make_unique<Shape>(*m_shape) : nullptr; }
     152    void setShape(Shape&&);
     153
    165154    IntRect m_bounds;
    166     Shape m_shape;
     155    std::unique_ptr<Shape> m_shape;
    167156
    168157    friend bool operator==(const Region&, const Region&);
    169158    friend bool operator==(const Shape&, const Shape&);
    170159    friend bool operator==(const Span&, const Span&);
     160    friend bool operator!=(const Span&, const Span&);
    171161};
    172162
     
    178168    return result;
    179169}
    180    
     170
    181171static inline Region subtract(const Region& a, const Region& b)
    182172{
     
    197187inline bool operator==(const Region& a, const Region& b)
    198188{
    199     return a.m_bounds == b.m_bounds && a.m_shape == b.m_shape;
     189    return a.m_bounds == b.m_bounds && arePointingToEqualData(a.m_shape, b.m_shape);
    200190}
    201191inline bool operator!=(const Region& a, const Region& b)
     
    213203    return a.y == b.y && a.segmentIndex == b.segmentIndex;
    214204}
     205
    215206inline bool operator!=(const Region::Span& a, const Region::Span& b)
    216207{
     
    218209}
    219210
     211template<class Encoder>
     212void Region::Span::encode(Encoder& encoder) const
     213{
     214    encoder << y << static_cast<uint64_t>(segmentIndex);
     215}
     216
     217template<class Decoder>
     218Optional<Region::Span> Region::Span::decode(Decoder& decoder)
     219{
     220    Optional<int> y;
     221    decoder >> y;
     222    if (!y)
     223        return { };
     224
     225    Optional<uint64_t> segmentIndex;
     226    decoder >> segmentIndex;
     227    if (!segmentIndex)
     228        return { };
     229
     230    return { { *y, *segmentIndex } };
     231}
     232
     233template<class Encoder>
     234void Region::Shape::encode(Encoder& encoder) const
     235{
     236    encoder << m_segments;
     237    encoder << m_spans;
     238}
     239
     240template<class Decoder>
     241Optional<Region::Shape> Region::Shape::decode(Decoder& decoder)
     242{
     243    Optional<Vector<int>> segments;
     244    decoder >> segments;
     245    if (!segments)
     246        return WTF::nullopt;
     247
     248    Optional<Vector<Region::Span>> spans;
     249    decoder >> spans;
     250    if (!spans)
     251        return WTF::nullopt;
     252
     253    Shape shape;
     254    shape.m_segments = WTFMove(*segments);
     255    shape.m_spans = WTFMove(*spans);
     256
     257    return { shape };
     258}
     259
     260template<class Encoder>
     261void Region::encode(Encoder& encoder) const
     262{
     263    encoder << m_bounds;
     264    bool hasShape = !!m_shape;
     265    encoder << hasShape;
     266    if (hasShape)
     267        encoder << *m_shape;
     268}
     269
     270template<class Decoder>
     271Optional<Region> Region::decode(Decoder& decoder)
     272{
     273    Optional<IntRect> bounds;
     274    decoder >> bounds;
     275    if (!bounds)
     276        return WTF::nullopt;
     277
     278    Optional<bool> hasShape;
     279    decoder >> hasShape;
     280    if (!hasShape)
     281        return WTF::nullopt;
     282
     283    Region region = { *bounds };
     284
     285    if (*hasShape) {
     286        Optional<Shape> shape;
     287        decoder >> shape;
     288        if (!shape)
     289            return WTF::nullopt;
     290        region.m_shape = std::make_unique<Shape>(WTFMove(*shape));
     291    }
     292
     293    return { region };
     294}
     295
     296template<class Decoder>
     297bool Region::decode(Decoder& decoder, Region& region)
     298{
     299    Optional<Region> decodedRegion;
     300    decoder >> decodedRegion;
     301    if (!decodedRegion)
     302        return false;
     303    region = WTFMove(*decodedRegion);
     304    return true;
     305}
     306
    220307} // namespace WebCore
    221308
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r241120 r242995  
    336336
    337337    nonOverlapRegion.translate(options.offset);
    338     Vector<IntRect> rects = nonOverlapRegion.rects();
     338    auto rects = nonOverlapRegion.rects();
    339339
    340340    for (auto& rect : rects) {
  • trunk/Source/WebKit/ChangeLog

    r242987 r242995  
     12019-03-15  Antti Koivisto  <antti@apple.com>
     2
     3        Optimize Region for single rectangle case
     4        https://bugs.webkit.org/show_bug.cgi?id=195743
     5
     6        Reviewed by Simon Fraser.
     7
     8        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
     9        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     10        * Shared/WebCoreArgumentCoders.cpp:
     11        (IPC::ArgumentCoder<EventTrackingRegions>::decode):
     12        (IPC::ArgumentCoder<Region::Span>::encode): Deleted.
     13        (IPC::ArgumentCoder<Region::Span>::decode): Deleted.
     14        (IPC::ArgumentCoder<Region>::encode): Deleted.
     15        (IPC::ArgumentCoder<Region>::decode): Deleted.
     16        * Shared/WebCoreArgumentCoders.h:
     17
    1182019-03-14  Per Arne Vollan  <pvollan@apple.com>
    219
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm

    r240918 r242995  
    299299    WebCore::IntRect dirtyBounds = m_dirtyRegion.bounds();
    300300
    301     Vector<WebCore::IntRect> dirtyRects = m_dirtyRegion.rects();
     301    auto dirtyRects = m_dirtyRegion.rects();
    302302    if (dirtyRects.size() > WebCore::PlatformCALayer::webLayerMaxRectsToPaint || m_dirtyRegion.totalArea() > WebCore::PlatformCALayer::webLayerWastedSpaceThreshold * dirtyBounds.width() * dirtyBounds.height()) {
    303303        dirtyRects.clear();
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm

    r242794 r242995  
    516516            return false;
    517517        if (hasEventRegion) {
    518             auto eventRegion = std::make_unique<WebCore::Region>();
    519             if (!decoder.decode(*eventRegion))
     518            Optional<WebCore::Region> eventRegion;
     519            decoder >> eventRegion;
     520            if (!eventRegion)
    520521                return false;
    521             result.eventRegion = WTFMove(eventRegion);
     522            result.eventRegion = std::make_unique<Region>(WTFMove(*eventRegion));
    522523        }
    523524    }
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r242913 r242995  
    368368bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions)
    369369{
    370     Region asynchronousDispatchRegion;
    371     if (!decoder.decode(asynchronousDispatchRegion))
     370    Optional<Region> asynchronousDispatchRegion;
     371    decoder >> asynchronousDispatchRegion;
     372    if (!asynchronousDispatchRegion)
    372373        return false;
    373374    HashMap<String, Region> eventSpecificSynchronousDispatchRegions;
     
    379380        return false;
    380381#endif
    381     eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion);
     382    eventTrackingRegions.asynchronousDispatchRegion = WTFMove(*asynchronousDispatchRegion);
    382383    eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions);
    383384#if ENABLE(POINTER_EVENTS)
     
    903904}
    904905
    905 template<> struct ArgumentCoder<Region::Span> {
    906     static void encode(Encoder&, const Region::Span&);
    907     static Optional<Region::Span> decode(Decoder&);
    908 };
    909 
    910 void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span)
    911 {
    912     encoder << span.y;
    913     encoder << (uint64_t)span.segmentIndex;
    914 }
    915 
    916 Optional<Region::Span> ArgumentCoder<Region::Span>::decode(Decoder& decoder)
    917 {
    918     Region::Span span;
    919     if (!decoder.decode(span.y))
    920         return WTF::nullopt;
    921    
    922     uint64_t segmentIndex;
    923     if (!decoder.decode(segmentIndex))
    924         return WTF::nullopt;
    925    
    926     span.segmentIndex = segmentIndex;
    927     return WTFMove(span);
    928 }
    929 
    930 void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region)
    931 {
    932     encoder.encode(region.shapeSegments());
    933     encoder.encode(region.shapeSpans());
    934 }
    935 
    936 bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region)
    937 {
    938     Vector<int> segments;
    939     if (!decoder.decode(segments))
    940         return false;
    941 
    942     Vector<Region::Span> spans;
    943     if (!decoder.decode(spans))
    944         return false;
    945    
    946     region.setShapeSegments(segments);
    947     region.setShapeSpans(spans);
    948     region.updateBoundsFromShape();
    949    
    950     if (!region.isValid())
    951         return false;
    952 
    953     return true;
    954 }
    955 
    956 Optional<Region> ArgumentCoder<Region>::decode(Decoder& decoder)
    957 {
    958     Region region;
    959     if (!decode(decoder, region))
    960         return WTF::nullopt;
    961 
    962     return region;
    963 }
    964 
    965906void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length)
    966907{
     
    972913    return SimpleArgumentCoder<Length>::decode(decoder, length);
    973914}
    974 
    975915
    976916void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes)
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r242913 r242995  
    325325};
    326326
    327 template<> struct ArgumentCoder<WebCore::Region> {
    328     static void encode(Encoder&, const WebCore::Region&);
    329     static bool decode(Decoder&, WebCore::Region&);
    330     static Optional<WebCore::Region> decode(Decoder&);
    331 };
    332 
    333327template<> struct ArgumentCoder<WebCore::Length> {
    334328    static void encode(Encoder&, const WebCore::Length&);
  • trunk/Source/WebKit/UIProcess/win/WebView.cpp

    r242592 r242995  
    475475        cairo_surface_destroy(surface);
    476476
    477         Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
     477        auto unpaintedRects = unpaintedRegion.rects();
    478478        for (auto& rect : unpaintedRects)
    479479            drawPageBackground(hdc, m_page.get(), rect);
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp

    r242714 r242995  
    677677}
    678678
    679 static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& rects)
     679static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect, 1>& rects)
    680680{
    681681    const size_t rectThreshold = 10;
     
    729729        return;
    730730
    731     Vector<IntRect> rects = m_dirtyRegion.rects();
     731    auto rects = m_dirtyRegion.rects();
    732732    if (shouldPaintBoundsRect(bounds, rects)) {
    733733        rects.clear();
Note: See TracChangeset for help on using the changeset viewer.