Changeset 242995 in webkit
- Timestamp:
- Mar 15, 2019, 8:43:20 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/graphics/Region.cpp (modified) (13 diffs)
-
WebCore/platform/graphics/Region.h (modified) (11 diffs)
-
WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (modified) (1 diff)
-
WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm (modified) (1 diff)
-
WebKit/Shared/WebCoreArgumentCoders.cpp (modified) (4 diffs)
-
WebKit/Shared/WebCoreArgumentCoders.h (modified) (1 diff)
-
WebKit/UIProcess/win/WebView.cpp (modified) (1 diff)
-
WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242992 r242995 1 2019-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 1 64 2019-03-15 Devin Rousso <drousso@apple.com> 2 65 -
trunk/Source/WebCore/platform/graphics/Region.cpp
r163509 r242995 43 43 Region::Region(const IntRect& rect) 44 44 : 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 48 Region::Region(const Region& other) 49 : m_bounds(other.m_bounds) 50 , m_shape(other.copyShape()) 51 { 52 } 53 54 Region::Region(Region&& other) 55 : m_bounds(WTFMove(other.m_bounds)) 56 , m_shape(WTFMove(other.m_shape)) 57 { 58 } 59 60 Region::~Region() 61 { 62 } 63 64 Region& Region::operator=(const Region& other) 65 { 66 m_bounds = other.m_bounds; 67 m_shape = other.copyShape(); 68 return *this; 69 } 70 71 Region& Region::operator=(Region&& other) 72 { 73 m_bounds = WTFMove(other.m_bounds); 74 m_shape = WTFMove(other.m_shape); 75 return *this; 76 } 77 78 Vector<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) { 54 89 int y = span->y; 55 90 int height = (span + 1)->y - y; 56 91 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) { 58 93 int x = *segment; 59 94 int width = *(segment + 1) - x; … … 71 106 return false; 72 107 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)); 74 112 } 75 113 … … 79 117 return false; 80 118 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) { 82 123 int y = span->y; 83 124 int maxY = (span + 1)->y; … … 88 129 continue; 89 130 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) { 91 132 int x = *segment; 92 133 int maxX = *(segment + 1); … … 107 148 return false; 108 149 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 156 uint64_t Region::totalArea() const 157 { 158 uint64_t totalArea = 0; 159 160 for (auto& rect : rects()) 120 161 totalArea += (rect.width() * rect.height()); 121 }122 162 123 163 return totalArea; … … 222 262 }; 223 263 224 Region::Shape::Shape()225 {226 }227 228 264 Region::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 { 234 268 } 235 269 236 270 void Region::Shape::appendSpan(int y) 237 271 { 238 m_spans.append( Span(y, m_segments.size()));272 m_spans.append({ y, m_segments.size() }); 239 273 } 240 274 … … 331 365 } 332 366 #endif 333 334 bool Region::Shape::isValid() const335 {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 }354 367 355 368 IntRect Region::Shape::bounds() const … … 396 409 for (size_t i = 0; i < m_spans.size(); ++i) 397 410 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);404 411 } 405 412 … … 568 575 printf("Bounds: (%d, %d, %d, %d)\n", 569 576 m_bounds.x(), m_bounds.y(), m_bounds.width(), m_bounds.height()); 570 m_shape.dump(); 577 if (m_shape) 578 m_shape->dump(); 571 579 } 572 580 #endif 573 581 574 void Region::updateBoundsFromShape()575 {576 m_bounds = m_shape.bounds();577 }578 579 582 void Region::intersect(const Region& region) 580 583 { … … 582 585 return; 583 586 if (!m_bounds.intersects(region.m_bounds)) { 584 m_shape = Shape();587 m_shape = nullptr; 585 588 m_bounds = IntRect(); 586 589 return; 587 590 } 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)); 593 597 } 594 598 … … 597 601 if (region.isEmpty()) 598 602 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 } 601 608 if (region.isRect() && region.m_bounds.contains(m_bounds)) { 602 m_shape = region.m_shape;603 609 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)); 614 617 } 615 618 616 619 void Region::subtract(const Region& region) 617 620 { 618 if ( m_bounds.isEmpty())621 if (isEmpty()) 619 622 return; 620 623 if (region.isEmpty()) … … 623 626 return; 624 627 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)); 629 629 } 630 630 … … 632 632 { 633 633 m_bounds.move(offset); 634 m_shape.translate(offset); 635 } 634 if (m_shape) 635 m_shape->translate(offset); 636 } 637 638 void 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 636 653 637 654 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/Region.h
r242794 r242995 28 28 29 29 #include "IntRect.h" 30 #include <wtf/Optional.h> 31 #include <wtf/PointerComparison.h> 30 32 #include <wtf/Vector.h> 31 33 … … 39 41 WEBCORE_EXPORT Region(const IntRect&); 40 42 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 41 51 IntRect bounds() const { return m_bounds; } 42 52 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; 46 56 47 57 WEBCORE_EXPORT void unite(const Region&); … … 59 69 WEBCORE_EXPORT bool intersects(const Region&) const; 60 70 61 WEBCORE_EXPORT u nsignedtotalArea() 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; } 64 74 65 75 #ifndef NDEBUG … … 67 77 #endif 68 78 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 84 private: 73 85 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&); 88 91 }; 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:99 92 100 93 class Shape { 101 94 public: 102 Shape() ;95 Shape() = default; 103 96 Shape(const IntRect&); 104 97 … … 121 114 122 115 WEBCORE_EXPORT void translate(const IntSize&); 123 void swap(Shape&);124 116 125 117 struct CompareContainsOperation; … … 128 120 template<typename CompareOperation> 129 121 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&); 139 125 140 126 #ifndef NDEBUG … … 163 149 }; 164 150 151 std::unique_ptr<Shape> copyShape() const { return m_shape ? std::make_unique<Shape>(*m_shape) : nullptr; } 152 void setShape(Shape&&); 153 165 154 IntRect m_bounds; 166 Shapem_shape;155 std::unique_ptr<Shape> m_shape; 167 156 168 157 friend bool operator==(const Region&, const Region&); 169 158 friend bool operator==(const Shape&, const Shape&); 170 159 friend bool operator==(const Span&, const Span&); 160 friend bool operator!=(const Span&, const Span&); 171 161 }; 172 162 … … 178 168 return result; 179 169 } 180 170 181 171 static inline Region subtract(const Region& a, const Region& b) 182 172 { … … 197 187 inline bool operator==(const Region& a, const Region& b) 198 188 { 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); 200 190 } 201 191 inline bool operator!=(const Region& a, const Region& b) … … 213 203 return a.y == b.y && a.segmentIndex == b.segmentIndex; 214 204 } 205 215 206 inline bool operator!=(const Region::Span& a, const Region::Span& b) 216 207 { … … 218 209 } 219 210 211 template<class Encoder> 212 void Region::Span::encode(Encoder& encoder) const 213 { 214 encoder << y << static_cast<uint64_t>(segmentIndex); 215 } 216 217 template<class Decoder> 218 Optional<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 233 template<class Encoder> 234 void Region::Shape::encode(Encoder& encoder) const 235 { 236 encoder << m_segments; 237 encoder << m_spans; 238 } 239 240 template<class Decoder> 241 Optional<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 260 template<class Encoder> 261 void 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 270 template<class Decoder> 271 Optional<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 296 template<class Decoder> 297 bool 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 220 307 } // namespace WebCore 221 308 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r241120 r242995 336 336 337 337 nonOverlapRegion.translate(options.offset); 338 Vector<IntRect>rects = nonOverlapRegion.rects();338 auto rects = nonOverlapRegion.rects(); 339 339 340 340 for (auto& rect : rects) { -
trunk/Source/WebKit/ChangeLog
r242987 r242995 1 2019-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 1 18 2019-03-14 Per Arne Vollan <pvollan@apple.com> 2 19 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
r240918 r242995 299 299 WebCore::IntRect dirtyBounds = m_dirtyRegion.bounds(); 300 300 301 Vector<WebCore::IntRect>dirtyRects = m_dirtyRegion.rects();301 auto dirtyRects = m_dirtyRegion.rects(); 302 302 if (dirtyRects.size() > WebCore::PlatformCALayer::webLayerMaxRectsToPaint || m_dirtyRegion.totalArea() > WebCore::PlatformCALayer::webLayerWastedSpaceThreshold * dirtyBounds.width() * dirtyBounds.height()) { 303 303 dirtyRects.clear(); -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
r242794 r242995 516 516 return false; 517 517 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) 520 521 return false; 521 result.eventRegion = WTFMove(eventRegion);522 result.eventRegion = std::make_unique<Region>(WTFMove(*eventRegion)); 522 523 } 523 524 } -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r242913 r242995 368 368 bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions) 369 369 { 370 Region asynchronousDispatchRegion; 371 if (!decoder.decode(asynchronousDispatchRegion)) 370 Optional<Region> asynchronousDispatchRegion; 371 decoder >> asynchronousDispatchRegion; 372 if (!asynchronousDispatchRegion) 372 373 return false; 373 374 HashMap<String, Region> eventSpecificSynchronousDispatchRegions; … … 379 380 return false; 380 381 #endif 381 eventTrackingRegions.asynchronousDispatchRegion = WTFMove( asynchronousDispatchRegion);382 eventTrackingRegions.asynchronousDispatchRegion = WTFMove(*asynchronousDispatchRegion); 382 383 eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions); 383 384 #if ENABLE(POINTER_EVENTS) … … 903 904 } 904 905 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 965 906 void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length) 966 907 { … … 972 913 return SimpleArgumentCoder<Length>::decode(decoder, length); 973 914 } 974 975 915 976 916 void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes) -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r242913 r242995 325 325 }; 326 326 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 333 327 template<> struct ArgumentCoder<WebCore::Length> { 334 328 static void encode(Encoder&, const WebCore::Length&); -
trunk/Source/WebKit/UIProcess/win/WebView.cpp
r242592 r242995 475 475 cairo_surface_destroy(surface); 476 476 477 Vector<IntRect>unpaintedRects = unpaintedRegion.rects();477 auto unpaintedRects = unpaintedRegion.rects(); 478 478 for (auto& rect : unpaintedRects) 479 479 drawPageBackground(hdc, m_page.get(), rect); -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
r242714 r242995 677 677 } 678 678 679 static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect >& rects)679 static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect, 1>& rects) 680 680 { 681 681 const size_t rectThreshold = 10; … … 729 729 return; 730 730 731 Vector<IntRect>rects = m_dirtyRegion.rects();731 auto rects = m_dirtyRegion.rects(); 732 732 if (shouldPaintBoundsRect(bounds, rects)) { 733 733 rects.clear();
Note:
See TracChangeset
for help on using the changeset viewer.