Optimize Region for single rectangle case
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 15:43:20 +0000 (15:43 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 15:43:20 +0000 (15:43 +0000)
commitdbe515808d575a38bef74c339675b266e8041af7
treee1781fa0be1fe1521ddb2e11440f44a9529e5266
parenteca375e3f572bad7d05ebf6cc2be4d287ba1cad8
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Region.cpp
Source/WebCore/platform/graphics/Region.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/UIProcess/win/WebView.cpp
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp