[CoordGraphics] Avoid painting backing stores for zero-opacity layers
authormagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 09:31:14 +0000 (09:31 +0000)
committermagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 09:31:14 +0000 (09:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184143

Reviewed by Žan Doberšek.

Source/WebCore:

Skip generating backing stores for layers that have zero opacity and do
not animate the opacity value. In the current CoordinatedGraphics system
this can end up saving loads of memory on Web content that deploys a
large number of such elements.

Based on a previous patch from Žan Doberšek.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::shouldHaveBackingStore const):

Source/WebKit:

Do not check whether a backingStore is required by a layer inside CoordinatedGraphicsScene. This
decision is made by the appropriate CoordinatedGraphicsLayer and propagated to the scene by
sending a valid or null Nicosia::BackingStore instance through the state.

* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::updateBackingStore):
(WebKit::layerShouldHaveBackingStore): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251837 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp

index 40bbf91..0432aeb 100644 (file)
@@ -1,3 +1,20 @@
+2019-10-31  Miguel Gomez  <magomez@igalia.com>
+
+        [CoordGraphics] Avoid painting backing stores for zero-opacity layers
+        https://bugs.webkit.org/show_bug.cgi?id=184143
+
+        Reviewed by Žan Doberšek.
+
+        Skip generating backing stores for layers that have zero opacity and do
+        not animate the opacity value. In the current CoordinatedGraphics system
+        this can end up saving loads of memory on Web content that deploys a
+        large number of such elements.
+
+        Based on a previous patch from Žan Doberšek.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::shouldHaveBackingStore const):
+
 2019-10-29  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WPE] ImageDecoders: use SharedBuffer::DataSegment instead of SharedBuffer
index f067e64..2e643b5 100644 (file)
@@ -1239,7 +1239,8 @@ void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
 
 bool CoordinatedGraphicsLayer::shouldHaveBackingStore() const
 {
-    return drawsContent() && contentsAreVisible() && !m_size.isEmpty();
+    return drawsContent() && contentsAreVisible() && !m_size.isEmpty()
+        && (!!opacity() || m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity));
 }
 
 bool CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation() const
index 0fcd3da..31d70cd 100644 (file)
@@ -1,3 +1,18 @@
+2019-10-31  Miguel Gomez  <magomez@igalia.com>
+
+        [CoordGraphics] Avoid painting backing stores for zero-opacity layers
+        https://bugs.webkit.org/show_bug.cgi?id=184143
+
+        Reviewed by Žan Doberšek.
+
+        Do not check whether a backingStore is required by a layer inside CoordinatedGraphicsScene. This
+        decision is made by the appropriate CoordinatedGraphicsLayer and propagated to the scene by
+        sending a valid or null Nicosia::BackingStore instance through the state.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::updateBackingStore):
+        (WebKit::layerShouldHaveBackingStore): Deleted.
+
 2019-10-30  Peng Liu  <peng.liu6@apple.com>
 
         [Picture-in-Picture Web API] Enable the support for iOS
index 61af2c0..335828c 100644 (file)
 namespace WebKit {
 using namespace WebCore;
 
-static bool layerShouldHaveBackingStore(TextureMapperLayer* layer)
-{
-    return layer->drawsContent() && layer->contentsAreVisible() && !layer->size().isEmpty();
-}
-
 CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient* client)
     : m_client(client)
 {
@@ -135,12 +130,6 @@ void updateBackingStore(TextureMapperLayer& layer,
     Nicosia::BackingStoreTextureMapperImpl::CompositionState& compositionState,
     const Nicosia::BackingStoreTextureMapperImpl::TileUpdate& update)
 {
-    if (!layerShouldHaveBackingStore(&layer)) {
-        layer.setBackingStore(nullptr);
-        compositionState.backingStore = nullptr;
-        return;
-    }
-
     if (!compositionState.backingStore)
         compositionState.backingStore = CoordinatedBackingStore::create();
     auto& backingStore = *compositionState.backingStore;