[WPE][GTK] Content disappearing when using CSS transforms
authormagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2019 08:01:19 +0000 (08:01 +0000)
committermagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2019 08:01:19 +0000 (08:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181757

Reviewed by Žan Doberšek.

Source/WebCore:

During each layer flush, create an AnimatedBackingStoreClient instance for each layer that
has a backingStore and is to be animated, and send that client to the appropriate
TextureMapperLayer on the compositor thread. During each frame rendering, the client will
use the future layer position (currently 50ms in the future) to check whether new tiles are
required to keep the animation ongoing, and notify the appropriate CoordinatedGraphicsLayer so
it can perform a layer flush and provide new tiles.

* platform/TextureMapper.cmake:
* platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h: Added.
* platform/graphics/nicosia/NicosiaPlatformLayer.h:
(Nicosia::CompositionLayer::flushState):
* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::TextureMapperAnimation::applyKeepingInternalState):
(WebCore::TextureMapperAnimations::applyKeepingInternalState):
* platform/graphics/texmap/TextureMapperAnimation.h:
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeTransformsRecursive):
(WebCore::TextureMapperLayer::setAnimatedBackingStoreClient):
(WebCore::TextureMapperLayer::syncAnimations):
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer):
(WebCore::clampToContentsRectIfRectIsInfinite):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::requestBackingStoreUpdate):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Source/WebKit:

Set the appropriate AnimatedBackingStoreClient to the TextureMapperLayers when required.

* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::updateSceneState):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/TextureMapper.cmake
Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h [new file with mode: 0644]
Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp

index ca4d9ad..5dedf5c 100644 (file)
@@ -1,3 +1,38 @@
+2019-07-01  Miguel Gomez  <magomez@igalia.com>
+
+        [WPE][GTK] Content disappearing when using CSS transforms
+        https://bugs.webkit.org/show_bug.cgi?id=181757
+
+        Reviewed by Žan Doberšek.
+
+        During each layer flush, create an AnimatedBackingStoreClient instance for each layer that
+        has a backingStore and is to be animated, and send that client to the appropriate
+        TextureMapperLayer on the compositor thread. During each frame rendering, the client will
+        use the future layer position (currently 50ms in the future) to check whether new tiles are
+        required to keep the animation ongoing, and notify the appropriate CoordinatedGraphicsLayer so
+        it can perform a layer flush and provide new tiles.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h: Added.
+        * platform/graphics/nicosia/NicosiaPlatformLayer.h:
+        (Nicosia::CompositionLayer::flushState):
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::TextureMapperAnimation::applyKeepingInternalState):
+        (WebCore::TextureMapperAnimations::applyKeepingInternalState):
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computeTransformsRecursive):
+        (WebCore::TextureMapperLayer::setAnimatedBackingStoreClient):
+        (WebCore::TextureMapperLayer::syncAnimations):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer):
+        (WebCore::clampToContentsRectIfRectIsInfinite):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        (WebCore::CoordinatedGraphicsLayer::requestBackingStoreUpdate):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2019-06-30  Antti Koivisto  <antti@apple.com>
 
         Use separate variables for moving and stationary scrolling relationships in RemoteLayerTreeNode
index 9198e20..ce9ab96 100644 (file)
@@ -97,6 +97,7 @@ if (USE_COORDINATED_GRAPHICS)
         page/scrolling/nicosia/ScrollingTreeFixedNode.h
         page/scrolling/nicosia/ScrollingTreeStickyNode.h
 
+        platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h
         platform/graphics/nicosia/NicosiaBuffer.h
         platform/graphics/nicosia/NicosiaPaintingEngine.h
         platform/graphics/nicosia/NicosiaPlatformLayer.h
diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h b/Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h
new file mode 100644 (file)
index 0000000..21de15e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 Metrological Group B.V.
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WebCore {
+class TransformationMatrix;
+}
+
+namespace Nicosia {
+
+class AnimatedBackingStoreClient : public ThreadSafeRefCounted<AnimatedBackingStoreClient> {
+public:
+    virtual ~AnimatedBackingStoreClient() = default;
+    virtual void requestBackingStoreUpdateIfNeeded(const WebCore::TransformationMatrix&) = 0;
+};
+
+} // namespace Nicosia
+
+#endif // USE(COORDINATED_GRAPHICS)
index a3bf287..11c6059 100644 (file)
@@ -34,6 +34,7 @@
 #include "FloatPoint3D.h"
 #include "FloatRect.h"
 #include "FloatSize.h"
+#include "NicosiaAnimatedBackingStoreClient.h"
 #include "NicosiaSceneIntegration.h"
 #include "TextureMapperAnimation.h"
 #include "TransformationMatrix.h"
@@ -126,6 +127,7 @@ public:
                     bool contentLayerChanged : 1;
                     bool backingStoreChanged : 1;
                     bool imageBackingChanged : 1;
+                    bool animatedBackingStoreClientChanged : 1;
                     bool repaintCounterChanged : 1;
                     bool debugBorderChanged : 1;
                 };
@@ -178,6 +180,7 @@ public:
         RefPtr<ContentLayer> contentLayer;
         RefPtr<BackingStore> backingStore;
         RefPtr<ImageBacking> imageBacking;
+        RefPtr<AnimatedBackingStoreClient> animatedBackingStoreClient;
 
         struct RepaintCounter {
             unsigned count { 0 };
@@ -256,6 +259,8 @@ public:
             staging.contentLayer = pending.contentLayer;
         if (pending.delta.imageBackingChanged)
             staging.imageBacking = pending.imageBacking;
+        if (pending.delta.animatedBackingStoreClientChanged)
+            staging.animatedBackingStoreClient = pending.animatedBackingStoreClient;
 
         pending.delta = { };
 
index 01a2742..dd0b8df 100644 (file)
@@ -239,6 +239,19 @@ void TextureMapperAnimation::apply(ApplicationResult& applicationResults, Monoto
     }
 }
 
+void TextureMapperAnimation::applyKeepingInternalState(ApplicationResult& applicationResults, MonotonicTime time)
+{
+    MonotonicTime oldLastRefreshedTime = m_lastRefreshedTime;
+    Seconds oldTotalRunningTime = m_totalRunningTime;
+    AnimationState oldState = m_state;
+
+    apply(applicationResults, time);
+
+    m_lastRefreshedTime = oldLastRefreshedTime;
+    m_totalRunningTime = oldTotalRunningTime;
+    m_state = oldState;
+}
+
 void TextureMapperAnimation::pause(Seconds time)
 {
     m_state = AnimationState::Paused;
@@ -338,6 +351,12 @@ void TextureMapperAnimations::apply(TextureMapperAnimation::ApplicationResult& a
         animation.apply(applicationResults, time);
 }
 
+void TextureMapperAnimations::applyKeepingInternalState(TextureMapperAnimation::ApplicationResult& applicationResults, MonotonicTime time)
+{
+    for (auto& animation : m_animations)
+        animation.applyKeepingInternalState(applicationResults, time);
+}
+
 bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const
 {
     return std::any_of(m_animations.begin(), m_animations.end(),
index 3fa913d..2fa86a4 100644 (file)
@@ -44,6 +44,7 @@ public:
     WEBCORE_EXPORT TextureMapperAnimation(const TextureMapperAnimation&);
 
     void apply(ApplicationResult&, MonotonicTime);
+    void applyKeepingInternalState(ApplicationResult&, MonotonicTime);
     void pause(Seconds);
     void resume();
     bool isActive() const;
@@ -81,6 +82,7 @@ public:
     void resume();
 
     void apply(TextureMapperAnimation::ApplicationResult&, MonotonicTime);
+    void applyKeepingInternalState(TextureMapperAnimation::ApplicationResult&, MonotonicTime);
 
     bool isEmpty() const { return m_animations.isEmpty(); }
     size_t size() const { return m_animations.size(); }
index 5e9c56b..3428c67 100644 (file)
@@ -78,6 +78,28 @@ void TextureMapperLayer::computeTransformsRecursive()
             m_layerTransforms.combinedForChildren = m_layerTransforms.combinedForChildren.to2dTransform();
         m_layerTransforms.combinedForChildren.multiply(m_state.childrenTransform);
         m_layerTransforms.combinedForChildren.translate3d(-originX, -originY, -m_state.anchorPoint.z());
+
+#if USE(COORDINATED_GRAPHICS)
+        // Compute transforms for the future as well.
+        TransformationMatrix futureParentTransform;
+        if (m_parent)
+            futureParentTransform = m_parent->m_layerTransforms.futureCombinedForChildren;
+        else if (m_effectTarget)
+            futureParentTransform = m_effectTarget->m_layerTransforms.futureCombined;
+
+        m_layerTransforms.futureCombined = futureParentTransform;
+        m_layerTransforms.futureCombined
+            .translate3d(originX + m_state.pos.x(), originY + m_state.pos.y(), m_state.anchorPoint.z())
+            .multiply(m_layerTransforms.futureLocalTransform);
+
+        m_layerTransforms.futureCombinedForChildren = m_layerTransforms.futureCombined;
+        m_layerTransforms.futureCombined.translate3d(-originX, -originY, -m_state.anchorPoint.z());
+
+        if (!m_state.preserves3D)
+            m_layerTransforms.futureCombinedForChildren = m_layerTransforms.futureCombinedForChildren.to2dTransform();
+        m_layerTransforms.futureCombinedForChildren.multiply(m_state.childrenTransform);
+        m_layerTransforms.futureCombinedForChildren.translate3d(-originX, -originY, -m_state.anchorPoint.z());
+#endif
     }
 
     m_state.visible = m_state.backfaceVisibility || !m_layerTransforms.combined.isBackFaceVisible();
@@ -97,6 +119,11 @@ void TextureMapperLayer::computeTransformsRecursive()
     // Reorder children if needed on the way back up.
     if (m_state.preserves3D)
         sortByZOrder(m_children);
+
+#if USE(COORDINATED_GRAPHICS)
+    if (m_backingStore && m_animatedBackingStoreClient)
+        m_animatedBackingStoreClient->requestBackingStoreUpdateIfNeeded(m_layerTransforms.futureCombined);
+#endif
 }
 
 void TextureMapperLayer::paint()
@@ -623,6 +650,13 @@ void TextureMapperLayer::setBackingStore(TextureMapperBackingStore* backingStore
     m_backingStore = backingStore;
 }
 
+#if USE(COORDINATED_GRAPHICS)
+void TextureMapperLayer::setAnimatedBackingStoreClient(Nicosia::AnimatedBackingStoreClient* client)
+{
+    m_animatedBackingStoreClient = client;
+}
+#endif
+
 bool TextureMapperLayer::descendantsOrSelfHaveRunningAnimations() const
 {
     if (m_animations.hasRunningAnimations())
@@ -651,6 +685,13 @@ bool TextureMapperLayer::syncAnimations(MonotonicTime time)
     m_currentOpacity = applicationResults.opacity.valueOr(m_state.opacity);
     m_currentFilters = applicationResults.filters.valueOr(m_state.filters);
 
+#if USE(COORDINATED_GRAPHICS)
+    // Calculate localTransform 50ms in the future.
+    TextureMapperAnimation::ApplicationResult futureApplicationResults;
+    m_animations.applyKeepingInternalState(futureApplicationResults, time + 50_ms);
+    m_layerTransforms.futureLocalTransform = futureApplicationResults.transform.valueOr(m_layerTransforms.localTransform);
+#endif
+
     return applicationResults.hasRunningAnimations;
 }
 
index ea259ba..50b24aa 100644 (file)
 #include "TextureMapperBackingStore.h"
 #include <wtf/WeakPtr.h>
 
+#if USE(COORDINATED_GRAPHICS)
+#include "NicosiaAnimatedBackingStoreClient.h"
+#endif
+
 namespace WebCore {
 
 class GraphicsLayer;
@@ -88,6 +92,9 @@ public:
     void setContentsLayer(TextureMapperPlatformLayer*);
     void setAnimations(const TextureMapperAnimations&);
     void setBackingStore(TextureMapperBackingStore*);
+#if USE(COORDINATED_GRAPHICS)
+    void setAnimatedBackingStoreClient(Nicosia::AnimatedBackingStoreClient*);
+#endif
 
     bool applyAnimationsRecursively(MonotonicTime);
     bool syncAnimations(MonotonicTime);
@@ -197,12 +204,19 @@ private:
     TextureMapper* m_textureMapper { nullptr };
     TextureMapperAnimations m_animations;
     uint32_t m_id { 0 };
+#if USE(COORDINATED_GRAPHICS)
+    RefPtr<Nicosia::AnimatedBackingStoreClient> m_animatedBackingStoreClient;
+#endif
 
     struct {
         TransformationMatrix localTransform;
-
         TransformationMatrix combined;
         TransformationMatrix combinedForChildren;
+#if USE(COORDINATED_GRAPHICS)
+        TransformationMatrix futureLocalTransform;
+        TransformationMatrix futureCombined;
+        TransformationMatrix futureCombinedForChildren;
+#endif
     } m_layerTransforms;
 };
 
index a95382c..0b051a9 100644 (file)
@@ -149,6 +149,8 @@ CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer()
     }
     ASSERT(!m_nicosia.imageBacking);
     ASSERT(!m_nicosia.backingStore);
+    if (m_animatedBackingStoreHost)
+        m_animatedBackingStoreHost->layerWillBeDestroyed();
     willBeDestroyed();
 }
 
@@ -631,6 +633,86 @@ void CoordinatedGraphicsLayer::updatePlatformLayer()
 #endif
 }
 
+static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const FloatSize& contentsSize)
+{
+    if (rect.width() >= LayoutUnit::nearlyMax() || rect.width() <= LayoutUnit::nearlyMin()) {
+        rect.setX(0);
+        rect.setWidth(contentsSize.width());
+    }
+
+    if (rect.height() >= LayoutUnit::nearlyMax() || rect.height() <= LayoutUnit::nearlyMin()) {
+        rect.setY(0);
+        rect.setHeight(contentsSize.height());
+    }
+}
+
+class CoordinatedAnimatedBackingStoreClient final : public Nicosia::AnimatedBackingStoreClient {
+public:
+    static Ref<CoordinatedAnimatedBackingStoreClient> create(RefPtr<CoordinatedGraphicsLayer::AnimatedBackingStoreHost>&& host, const FloatRect& visibleRect, const FloatRect& coverRect, const FloatSize& size, float contentsScale)
+    {
+        return adoptRef(*new CoordinatedAnimatedBackingStoreClient(WTFMove(host), visibleRect, coverRect, size, contentsScale));
+    }
+
+    ~CoordinatedAnimatedBackingStoreClient() = default;
+
+    void setCoverRect(const IntRect& rect) { m_coverRect = rect; }
+    void requestBackingStoreUpdateIfNeeded(const TransformationMatrix& transform) final
+    {
+        ASSERT(!isMainThread());
+
+        // Calculate the contents rectangle of the layer in backingStore coordinates.
+        FloatRect contentsRect = { { 0, 0 }, m_size };
+        contentsRect.scale(m_contentsScale);
+
+        // If the area covered by tiles (the coverRect, already in backingStore coordinates) covers the whole
+        // layer contents then we don't need to do anything.
+        if (m_coverRect.contains(contentsRect))
+            return;
+
+        // Non-invertible layers are not visible.
+        if (!transform.isInvertible())
+            return;
+
+        // Calculate the inverse of the layer transformation. The inverse transform will have the inverse of the
+        // scaleFactor applied, so we need to scale it back.
+        TransformationMatrix inverse = transform.inverse().valueOr(TransformationMatrix()).scale(m_contentsScale);
+
+        // Apply the inverse transform to the visible rectangle, so we have the visible rectangle in layer coordinates.
+        FloatRect rect = inverse.clampedBoundsOfProjectedQuad(FloatQuad(m_visibleRect));
+        clampToContentsRectIfRectIsInfinite(rect, m_size);
+        FloatRect transformedVisibleRect = enclosingIntRect(rect);
+
+        // Convert the calculated visible rectangle to backingStore coordinates.
+        transformedVisibleRect.scale(m_contentsScale);
+
+        // Restrict the calculated visible rect to the contents rectangle of the layer.
+        transformedVisibleRect.intersect(contentsRect);
+
+        // If the coverRect doesn't contain the calculated visible rectangle we need to request a backingStore
+        // update to render more tiles.
+        if (!m_coverRect.contains(transformedVisibleRect)) {
+            callOnMainThread([protectedHost = m_host.copyRef()]() {
+                protectedHost->requestBackingStoreUpdate();
+            });
+        }
+    }
+
+private:
+    CoordinatedAnimatedBackingStoreClient(RefPtr<CoordinatedGraphicsLayer::AnimatedBackingStoreHost>&& host, const FloatRect& visibleRect, const FloatRect& coverRect, const FloatSize& size, float contentsScale)
+        : m_host(WTFMove(host))
+        , m_visibleRect(visibleRect)
+        , m_coverRect(coverRect)
+        , m_size(size)
+        , m_contentsScale(contentsScale)
+    { }
+
+    RefPtr<CoordinatedGraphicsLayer::AnimatedBackingStoreHost> m_host;
+    FloatRect m_visibleRect;
+    FloatRect m_coverRect;
+    FloatSize m_size;
+    float m_contentsScale;
+};
+
 void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
 {
     // Whether it kicked or not, we don't need this timer running anymore.
@@ -666,6 +748,19 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
         m_nicosia.delta.backingStoreChanged = true;
     }
 
+    if (hasActiveTransformAnimation && m_nicosia.backingStore) {
+        // The layer has a backingStore and a transformation animation. This means that we need to add an
+        // AnimatedBackingStoreClient to check whether we need to update the backingStore due to the animation.
+        // At this point we don't know the area covered by tiles available, so we just pass an empty rectangle
+        // for that. The call to updateContentBuffers will calculate the tile coverage and set the appropriate
+        // rectangle to the client.
+        if (!m_animatedBackingStoreHost)
+            m_animatedBackingStoreHost = AnimatedBackingStoreHost::create(*this);
+        m_nicosia.animatedBackingStoreClient = CoordinatedAnimatedBackingStoreClient::create(m_animatedBackingStoreHost.copyRef(), m_coordinator->visibleContentsRect(), { }, m_size, effectiveContentsScale());
+    }
+    // Each layer flush changes the AnimatedBackingStoreClient, being it null or a real one.
+    m_nicosia.delta.animatedBackingStoreClientChanged = true;
+
     // Determine image backing presence according to the composited image source.
     if (m_compositedNativeImagePtr) {
         ASSERT(m_compositedImage);
@@ -787,6 +882,8 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
                     state.contentLayer = m_nicosia.contentLayer;
                 if (localDelta.imageBackingChanged)
                     state.imageBacking = m_nicosia.imageBacking;
+                if (localDelta.animatedBackingStoreClientChanged)
+                    state.animatedBackingStoreClient = m_nicosia.animatedBackingStoreClient;
             });
         m_nicosia.performLayerSync = !!m_nicosia.delta.value;
         m_nicosia.delta = { };
@@ -817,19 +914,6 @@ float CoordinatedGraphicsLayer::effectiveContentsScale()
     return selfOrAncestorHaveNonAffineTransforms() ? 1 : deviceScaleFactor() * pageScaleFactor();
 }
 
-static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const FloatSize& contentsSize)
-{
-    if (rect.width() >= LayoutUnit::nearlyMax() || rect.width() <= LayoutUnit::nearlyMin()) {
-        rect.setX(0);
-        rect.setWidth(contentsSize.width());
-    }
-
-    if (rect.height() >= LayoutUnit::nearlyMax() || rect.height() <= LayoutUnit::nearlyMin()) {
-        rect.setY(0);
-        rect.setHeight(contentsSize.height());
-    }
-}
-
 IntRect CoordinatedGraphicsLayer::transformedVisibleRect()
 {
     // Non-invertible layers are not visible.
@@ -845,6 +929,12 @@ IntRect CoordinatedGraphicsLayer::transformedVisibleRect()
     return enclosingIntRect(rect);
 }
 
+void CoordinatedGraphicsLayer::requestBackingStoreUpdate()
+{
+    setNeedsVisibleRectAdjustment();
+    notifyFlushRequired();
+}
+
 void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
 {
     if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer()))
@@ -914,6 +1004,11 @@ void CoordinatedGraphicsLayer::updateContentBuffers()
         layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, m_size.width(), m_size.height()));
     }
 
+    if (m_nicosia.animatedBackingStoreClient) {
+        // Determine the coverRect and set it to the client.
+        downcast<CoordinatedAnimatedBackingStoreClient>(m_nicosia.animatedBackingStoreClient.get())->setCoverRect(layerState.mainBackingStore->coverRect());
+    }
+
     ASSERT(m_coordinator && m_coordinator->isFlushingLayerChanges());
 
     // With all the affected tiles created and/or invalidated, we can finally paint them.
index b5177de..e6c5866 100644 (file)
@@ -29,6 +29,7 @@
 #include "GraphicsLayerTransform.h"
 #include "Image.h"
 #include "IntSize.h"
+#include "NicosiaAnimatedBackingStoreClient.h"
 #include "NicosiaBuffer.h"
 #include "NicosiaPlatformLayer.h"
 #include "TextureMapperAnimation.h"
@@ -124,6 +125,30 @@ public:
 
     const RefPtr<Nicosia::CompositionLayer>& compositionLayer() const;
 
+    class AnimatedBackingStoreHost : public ThreadSafeRefCounted<AnimatedBackingStoreHost> {
+    public:
+        static Ref<AnimatedBackingStoreHost> create(CoordinatedGraphicsLayer& layer)
+        {
+            return adoptRef(*new AnimatedBackingStoreHost(layer));
+        }
+
+        void requestBackingStoreUpdate()
+        {
+            if (m_layer)
+                m_layer->requestBackingStoreUpdate();
+        }
+
+        void layerWillBeDestroyed() { m_layer = nullptr; }
+    private:
+        explicit AnimatedBackingStoreHost(CoordinatedGraphicsLayer& layer)
+            : m_layer(&layer)
+        { }
+
+        CoordinatedGraphicsLayer* m_layer;
+    };
+
+    void requestBackingStoreUpdate();
+
 private:
     bool isCoordinatedGraphicsLayer() const override;
 
@@ -198,7 +223,10 @@ private:
         RefPtr<Nicosia::BackingStore> backingStore;
         RefPtr<Nicosia::ContentLayer> contentLayer;
         RefPtr<Nicosia::ImageBacking> imageBacking;
+        RefPtr<Nicosia::AnimatedBackingStoreClient> animatedBackingStoreClient;
     } m_nicosia;
+
+    RefPtr<AnimatedBackingStoreHost> m_animatedBackingStoreHost;
 };
 
 } // namespace WebCore
index af019eb..6d374fe 100644 (file)
@@ -1,3 +1,15 @@
+2019-07-01  Miguel Gomez  <magomez@igalia.com>
+
+        [WPE][GTK] Content disappearing when using CSS transforms
+        https://bugs.webkit.org/show_bug.cgi?id=181757
+
+        Reviewed by Žan Doberšek.
+
+        Set the appropriate AnimatedBackingStoreClient to the TextureMapperLayers when required.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::updateSceneState):
+
 2019-06-30  Antti Koivisto  <antti@apple.com>
 
         Use separate variables for moving and stationary scrolling relationships in RemoteLayerTreeNode
index eb6af98..18dc2fb 100644 (file)
@@ -356,6 +356,11 @@ void CoordinatedGraphicsScene::updateSceneState()
                                 { std::ref(layer), std::ref(impl), impl.takeUpdate() });
                         } else
                             layer.setContentsLayer(nullptr);
+
+                        if (layerState.animatedBackingStoreClient)
+                            layer.setAnimatedBackingStoreClient(layerState.animatedBackingStoreClient.get());
+                        else
+                            layer.setAnimatedBackingStoreClient(nullptr);
                     });
             }
         });