Title: [246988] releases/WebKitGTK/webkit-2.24/Source
Revision
246988
Author
carlo...@webkit.org
Date
2019-07-01 02:22:16 -0700 (Mon, 01 Jul 2019)

Log Message

Merge r246963 - [WPE][GTK] Content disappearing when using CSS transforms
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):

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog	2019-07-01 09:22:16 UTC (rev 246988)
@@ -1,3 +1,38 @@
+2019-07-01  Miguel Gomez  <mago...@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-07  Philippe Normand  <pnorm...@igalia.com>
 
         [GStreamer] videorate issues with v4l2src

Added: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h (0 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h	2019-07-01 09:22:16 UTC (rev 246988)
@@ -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)

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2019-07-01 09:22:16 UTC (rev 246988)
@@ -34,6 +34,7 @@
 #include "FloatPoint3D.h"
 #include "FloatRect.h"
 #include "FloatSize.h"
+#include "NicosiaAnimatedBackingStoreClient.h"
 #include "TextureMapperAnimation.h"
 #include "TransformationMatrix.h"
 #include <wtf/Function.h>
@@ -110,6 +111,7 @@
                     bool contentLayerChanged : 1;
                     bool backingStoreChanged : 1;
                     bool imageBackingChanged : 1;
+                    bool animatedBackingStoreClientChanged : 1;
                     bool repaintCounterChanged : 1;
                     bool debugBorderChanged : 1;
                 };
@@ -162,6 +164,7 @@
         RefPtr<ContentLayer> contentLayer;
         RefPtr<BackingStore> backingStore;
         RefPtr<ImageBacking> imageBacking;
+        RefPtr<AnimatedBackingStoreClient> animatedBackingStoreClient;
 
         struct RepaintCounter {
             unsigned count { 0 };
@@ -240,6 +243,8 @@
             staging.contentLayer = pending.contentLayer;
         if (pending.delta.imageBackingChanged)
             staging.imageBacking = pending.imageBacking;
+        if (pending.delta.animatedBackingStoreClientChanged)
+            staging.animatedBackingStoreClient = pending.animatedBackingStoreClient;
 
         pending.delta = { };
 

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2019-07-01 09:22:16 UTC (rev 246988)
@@ -239,6 +239,19 @@
     }
 }
 
+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 @@
         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(),

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2019-07-01 09:22:16 UTC (rev 246988)
@@ -44,6 +44,7 @@
     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 @@
     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(); }

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2019-07-01 09:22:16 UTC (rev 246988)
@@ -78,6 +78,28 @@
             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 @@
     // 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 @@
     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 @@
     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;
 }
 

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2019-07-01 09:22:16 UTC (rev 246988)
@@ -27,6 +27,10 @@
 #include "TextureMapperBackingStore.h"
 #include <wtf/WeakPtr.h>
 
+#if USE(COORDINATED_GRAPHICS)
+#include "NicosiaAnimatedBackingStoreClient.h"
+#endif
+
 namespace WebCore {
 
 class GraphicsLayer;
@@ -88,6 +92,9 @@
     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 @@
     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;
 };
 

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2019-07-01 09:22:16 UTC (rev 246988)
@@ -149,6 +149,8 @@
     }
     ASSERT(!m_nicosia.imageBacking);
     ASSERT(!m_nicosia.backingStore);
+    if (m_animatedBackingStoreHost)
+        m_animatedBackingStoreHost->layerWillBeDestroyed();
     willBeDestroyed();
 }
 
@@ -631,6 +633,86 @@
 #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 @@
         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 @@
                     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 @@
     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 @@
     return enclosingIntRect(rect);
 }
 
+void CoordinatedGraphicsLayer::requestBackingStoreUpdate()
+{
+    setNeedsVisibleRectAdjustment();
+    notifyFlushRequired();
+}
+
 void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
 {
     if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer()))
@@ -914,6 +1004,11 @@
         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.

Modified: releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2019-07-01 09:22:16 UTC (rev 246988)
@@ -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 @@
 
     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;
 
@@ -199,7 +224,10 @@
         RefPtr<Nicosia::BackingStore> backingStore;
         RefPtr<Nicosia::ContentLayer> contentLayer;
         RefPtr<Nicosia::ImageBacking> imageBacking;
+        RefPtr<Nicosia::AnimatedBackingStoreClient> animatedBackingStoreClient;
     } m_nicosia;
+
+    RefPtr<AnimatedBackingStoreHost> m_animatedBackingStoreHost;
 };
 
 } // namespace WebCore

Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/ChangeLog	2019-07-01 09:22:16 UTC (rev 246988)
@@ -1,3 +1,15 @@
+2019-07-01  Miguel Gomez  <mago...@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-20  Alexander Mikhaylenko  <exalm7...@gmail.com>
 
         [GTK] The Previous/Next gesture should handle RTL

Modified: releases/WebKitGTK/webkit-2.24/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp (246987 => 246988)


--- releases/WebKitGTK/webkit-2.24/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp	2019-07-01 09:22:09 UTC (rev 246987)
+++ releases/WebKitGTK/webkit-2.24/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp	2019-07-01 09:22:16 UTC (rev 246988)
@@ -356,6 +356,11 @@
                                 { std::ref(layer), std::ref(impl), impl.takeUpdate() });
                         } else
                             layer.setContentsLayer(nullptr);
+
+                        if (layerState.animatedBackingStoreClient)
+                            layer.setAnimatedBackingStoreClient(layerState.animatedBackingStoreClient.get());
+                        else
+                            layer.setAnimatedBackingStoreClient(nullptr);
                     });
             }
         });
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to