Title: [210543] trunk/Source/WebCore
Revision
210543
Author
zandober...@gmail.com
Date
2017-01-10 04:32:17 -0800 (Tue, 10 Jan 2017)

Log Message

[CoordinatedGraphics] TextureMapperPlatformLayerProxy is constantly getting activated
https://bugs.webkit.org/show_bug.cgi?id=166856

Reviewed by Michael Catanzaro.

When CoordinatedGraphicsLayer::setContentsNeedsDisplay() is called, currently with
the threaded CoordinatedGraphics mode the platform layer is marked for synchronizing.
This means that at flush-time this layer swaps the buffer of the wrapped platform
layer and updates the layer state to indicate that the underlying
TextureMapperPlatformLayerProxy object has to be activated on the composition thread.

This current logic results in the TextureMapperPlatformLayerProxy object being
reactivated for every display request that arrives via setContentsNeedsDisplay().
This is pretty wasteful since this activation heap-allocates a RunLoop::Timer object
which internally also locks up the GLib main context to attach a new source, and
that's only after the source on the previous RunLoop::Timer was detached before
that RunLoop::Timer was destroyed.

To avoid this, CoordinatedGraphicsLayer::setContentsNeedsDisplay() sets a new flag,
m_shouldUpdatePlatformLayer. During flush, this flag is checked in
CoordinatedGraphicsLayer::updatePlatformLayer(), with the buffer swap performed in
case it's set. CoordinatedGraphicsLayer::syncPlatformLayer() now only sets the
platform layer proxy object for that layer's state.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
(WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::syncPlatformLayer):
(WebCore::CoordinatedGraphicsLayer::updatePlatformLayer):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (210542 => 210543)


--- trunk/Source/WebCore/ChangeLog	2017-01-10 12:29:36 UTC (rev 210542)
+++ trunk/Source/WebCore/ChangeLog	2017-01-10 12:32:17 UTC (rev 210543)
@@ -1,5 +1,39 @@
 2017-01-10  Zan Dobersek  <zdober...@igalia.com>
 
+        [CoordinatedGraphics] TextureMapperPlatformLayerProxy is constantly getting activated
+        https://bugs.webkit.org/show_bug.cgi?id=166856
+
+        Reviewed by Michael Catanzaro.
+
+        When CoordinatedGraphicsLayer::setContentsNeedsDisplay() is called, currently with
+        the threaded CoordinatedGraphics mode the platform layer is marked for synchronizing.
+        This means that at flush-time this layer swaps the buffer of the wrapped platform
+        layer and updates the layer state to indicate that the underlying
+        TextureMapperPlatformLayerProxy object has to be activated on the composition thread.
+
+        This current logic results in the TextureMapperPlatformLayerProxy object being
+        reactivated for every display request that arrives via setContentsNeedsDisplay().
+        This is pretty wasteful since this activation heap-allocates a RunLoop::Timer object
+        which internally also locks up the GLib main context to attach a new source, and
+        that's only after the source on the previous RunLoop::Timer was detached before
+        that RunLoop::Timer was destroyed.
+
+        To avoid this, CoordinatedGraphicsLayer::setContentsNeedsDisplay() sets a new flag,
+        m_shouldUpdatePlatformLayer. During flush, this flag is checked in
+        CoordinatedGraphicsLayer::updatePlatformLayer(), with the buffer swap performed in
+        case it's set. CoordinatedGraphicsLayer::syncPlatformLayer() now only sets the
+        platform layer proxy object for that layer's state.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
+        (WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay):
+        (WebCore::CoordinatedGraphicsLayer::syncPlatformLayer):
+        (WebCore::CoordinatedGraphicsLayer::updatePlatformLayer):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
+2017-01-10  Zan Dobersek  <zdober...@igalia.com>
+
         [TexMap] Use WTF::Function in TextureMapperPlatformLayerProxy
         https://bugs.webkit.org/show_bug.cgi?id=166853
 

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


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2017-01-10 12:29:36 UTC (rev 210542)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2017-01-10 12:32:17 UTC (rev 210543)
@@ -126,6 +126,7 @@
 #endif
 #if USE(COORDINATED_GRAPHICS_THREADED)
     , m_shouldSyncPlatformLayer(false)
+    , m_shouldUpdatePlatformLayer(false)
 #endif
     , m_coordinator(0)
     , m_compositedNativeImagePtr(0)
@@ -383,7 +384,7 @@
         m_pendingPlatformLayerOperation |= SyncPlatformLayer;
 #elif USE(COORDINATED_GRAPHICS_THREADED)
     if (m_platformLayer)
-        m_shouldSyncPlatformLayer = true;
+        m_shouldUpdatePlatformLayer = true;
 #endif
 
     notifyFlushRequired();
@@ -744,13 +745,23 @@
 
     m_shouldSyncPlatformLayer = false;
     m_layerState.platformLayerChanged = true;
-    if (m_platformLayer) {
-        m_platformLayer->swapBuffersIfNeeded();
+    if (m_platformLayer)
         m_layerState.platformLayerProxy = m_platformLayer->proxy();
-    }
 #endif
 }
 
+void CoordinatedGraphicsLayer::updatePlatformLayer()
+{
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    if (!m_shouldUpdatePlatformLayer)
+        return;
+
+    m_shouldUpdatePlatformLayer = false;
+    if (m_platformLayer)
+        m_platformLayer->swapBuffersIfNeeded();
+#endif
+}
+
 #if USE(GRAPHICS_SURFACE)
 void CoordinatedGraphicsLayer::destroyPlatformLayerIfNeeded()
 {
@@ -801,6 +812,7 @@
     syncChildren();
     syncFilters();
     syncPlatformLayer();
+    updatePlatformLayer();
 
     // Only unset m_movingVisibleRect after we have updated the visible rect after the animation stopped.
     if (!hasActiveTransformAnimation)

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


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2017-01-10 12:29:36 UTC (rev 210542)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2017-01-10 12:32:17 UTC (rev 210543)
@@ -165,6 +165,7 @@
     void createPlatformLayerIfNeeded();
 #endif
     void syncPlatformLayer();
+    void updatePlatformLayer();
 #if USE(COORDINATED_GRAPHICS_THREADED)
     void platformLayerWillBeDestroyed() override;
     void setPlatformLayerNeedsDisplay() override;
@@ -237,6 +238,7 @@
 #endif
 #if USE(COORDINATED_GRAPHICS_THREADED)
     bool m_shouldSyncPlatformLayer : 1;
+    bool m_shouldUpdatePlatformLayer : 1;
 #endif
 
     CoordinatedGraphicsLayerClient* m_coordinator;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to