Title: [229804] trunk/Source/WebCore
Revision
229804
Author
[email protected]
Date
2018-03-21 07:16:22 -0700 (Wed, 21 Mar 2018)

Log Message

[CoordGraphics] Track dirty rects that need update in CoordinatedGraphicsLayer
https://bugs.webkit.org/show_bug.cgi?id=175376

Reviewed by Carlos Garcia Campos.

Follow the GraphicsLayerCA class and track rectangles in need of display
in a Vector object. In case the whole layer needs updating, it's marked
separately, and further rects are ignored.

During layer flush, all the rects are used to invalidate the backing
store, or a single layer-sized rect is used in case the whole layer has
to be updated. We can also bail early from updateContentBuffers() if
there are no dirty rects recorded and there's no pending visible rect
adjustment.

At the end of updateContentBuffers() we now test for an existing
previous backing store before inquiring the backing store if the visible
area is already covered, enabling deletion of this backing store.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplayInRect):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229803 => 229804)


--- trunk/Source/WebCore/ChangeLog	2018-03-21 12:37:03 UTC (rev 229803)
+++ trunk/Source/WebCore/ChangeLog	2018-03-21 14:16:22 UTC (rev 229804)
@@ -1,3 +1,30 @@
+2018-03-21  Zan Dobersek  <[email protected]>
+
+        [CoordGraphics] Track dirty rects that need update in CoordinatedGraphicsLayer
+        https://bugs.webkit.org/show_bug.cgi?id=175376
+
+        Reviewed by Carlos Garcia Campos.
+
+        Follow the GraphicsLayerCA class and track rectangles in need of display
+        in a Vector object. In case the whole layer needs updating, it's marked
+        separately, and further rects are ignored.
+
+        During layer flush, all the rects are used to invalidate the backing
+        store, or a single layer-sized rect is used in case the whole layer has
+        to be updated. We can also bail early from updateContentBuffers() if
+        there are no dirty rects recorded and there's no pending visible rect
+        adjustment.
+
+        At the end of updateContentBuffers() we now test for an existing
+        previous backing store before inquiring the backing store if the visible
+        area is already covered, enabling deletion of this backing store.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setNeedsDisplay):
+        (WebCore::CoordinatedGraphicsLayer::setNeedsDisplayInRect):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2018-03-21  Carlos Alberto Lopez Perez  <[email protected]>
 
         [WPE] Build failure with ENABLE_VIDEO=OFF when GStreamer is not available

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (229803 => 229804)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2018-03-21 12:37:03 UTC (rev 229803)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2018-03-21 14:16:22 UTC (rev 229804)
@@ -534,16 +534,40 @@
 
 void CoordinatedGraphicsLayer::setNeedsDisplay()
 {
-    setNeedsDisplayInRect(FloatRect(FloatPoint(), size()));
+    if (!drawsContent() || !contentsAreVisible() || m_size.isEmpty() || m_needsDisplay.completeLayer)
+        return;
+
+    m_needsDisplay.completeLayer = true;
+    m_needsDisplay.rects.clear();
+
+    didChangeLayerState();
+    addRepaintRect({ { }, m_size });
 }
 
-void CoordinatedGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect, ShouldClipToLayer)
+void CoordinatedGraphicsLayer::setNeedsDisplayInRect(const FloatRect& initialRect, ShouldClipToLayer shouldClip)
 {
-    if (m_mainBackingStore)
-        m_mainBackingStore->invalidate(enclosingIntRect(rect));
+    if (!drawsContent() || !contentsAreVisible() || m_size.isEmpty() || m_needsDisplay.completeLayer)
+        return;
 
+    auto rect = initialRect;
+    if (shouldClip == ClipToLayer)
+        rect.intersect({ { }, m_size });
+
+    if (rect.isEmpty())
+        return;
+
+    auto& rects = m_needsDisplay.rects;
+    bool alreadyRecorded = std::any_of(rects.begin(), rects.end(),
+        [&](auto& dirtyRect) { return dirtyRect.contains(rect); });
+    if (alreadyRecorded)
+        return;
+
+    if (rects.size() < 32)
+        rects.append(rect);
+    else
+        rects[0].unite(rect);
+
     didChangeLayerState();
-
     addRepaintRect(rect);
 }
 
@@ -923,6 +947,18 @@
         m_pendingVisibleRectAdjustment = true;
     }
 
+    if (!m_pendingVisibleRectAdjustment && !m_needsDisplay.completeLayer && m_needsDisplay.rects.isEmpty())
+        return;
+
+    if (!m_needsDisplay.completeLayer) {
+        for (auto& rect : m_needsDisplay.rects)
+            m_mainBackingStore->invalidate(IntRect { rect });
+    } else
+        m_mainBackingStore->invalidate({ { }, IntSize { m_size } });
+
+    m_needsDisplay.completeLayer = false;
+    m_needsDisplay.rects.clear();
+
     if (m_pendingVisibleRectAdjustment) {
         m_pendingVisibleRectAdjustment = false;
         m_mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height()));
@@ -968,7 +1004,7 @@
     // The previous backing store is kept around to avoid flickering between
     // removing the existing tiles and painting the new ones. The first time
     // the visibleRect is full painted we remove the previous backing store.
-    if (m_mainBackingStore->visibleAreaIsCovered())
+    if (m_previousBackingStore && m_mainBackingStore->visibleAreaIsCovered())
         m_previousBackingStore = nullptr;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (229803 => 229804)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2018-03-21 12:37:03 UTC (rev 229803)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2018-03-21 14:16:22 UTC (rev 229804)
@@ -216,6 +216,11 @@
     std::unique_ptr<TiledBackingStore> m_mainBackingStore;
     std::unique_ptr<TiledBackingStore> m_previousBackingStore;
 
+    struct {
+        bool completeLayer { false };
+        Vector<FloatRect, 32> rects;
+    } m_needsDisplay;
+
     RefPtr<Image> m_compositedImage;
     NativeImagePtr m_compositedNativeImagePtr;
     RefPtr<CoordinatedImageBacking> m_coordinatedImageBacking;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to