[WK2][Qt] REGRESSION: Pages with transform animations sometimes omit some of the...
authornoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 23:40:41 +0000 (23:40 +0000)
committernoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 23:40:41 +0000 (23:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76886

Reviewed by Kenneth Rohde Christiansen.

We now render the whole layer if it or one if its ancestors has an active transform
animations. It's possible to optimize further in the future, but not currently necessary.
Also, we make sure that when a WebGraphicsLayer's property that affects transformation is
changed, all its descandants layers are marked as modified so that we re-adjust their
visible rect in the next pass.

* WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
(WebCore::WebGraphicsLayer::notifyChangeRecursively):
(WebCore):
(WebCore::WebGraphicsLayer::setPosition):
(WebCore::WebGraphicsLayer::setAnchorPoint):
(WebCore::WebGraphicsLayer::setSize):
(WebCore::WebGraphicsLayer::setTransform):
(WebCore::WebGraphicsLayer::setChildrenTransform):
(WebCore::WebGraphicsLayer::setPreserves3D):
(WebCore::WebGraphicsLayer::setMasksToBounds):
(WebCore::WebGraphicsLayer::addAnimation):
(WebCore::WebGraphicsLayer::removeAnimation):
(WebCore::WebGraphicsLayer::tiledBackingStoreVisibleRect):
(WebCore::WebGraphicsLayer::selfOrAncestorHasActiveTransformAnimations):
* WebProcess/WebCoreSupport/WebGraphicsLayer.h:
(WebGraphicsLayer):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h

index 092634a..17f5433 100644 (file)
@@ -1,3 +1,33 @@
+2012-01-25  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
+        [WK2][Qt] REGRESSION: Pages with transform animations sometimes omit some of the layers since r105413
+        https://bugs.webkit.org/show_bug.cgi?id=76886
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        We now render the whole layer if it or one if its ancestors has an active transform
+        animations. It's possible to optimize further in the future, but not currently necessary.
+        Also, we make sure that when a WebGraphicsLayer's property that affects transformation is
+        changed, all its descandants layers are marked as modified so that we re-adjust their
+        visible rect in the next pass.
+
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::WebGraphicsLayer::notifyChangeRecursively):
+        (WebCore):
+        (WebCore::WebGraphicsLayer::setPosition):
+        (WebCore::WebGraphicsLayer::setAnchorPoint):
+        (WebCore::WebGraphicsLayer::setSize):
+        (WebCore::WebGraphicsLayer::setTransform):
+        (WebCore::WebGraphicsLayer::setChildrenTransform):
+        (WebCore::WebGraphicsLayer::setPreserves3D):
+        (WebCore::WebGraphicsLayer::setMasksToBounds):
+        (WebCore::WebGraphicsLayer::addAnimation):
+        (WebCore::WebGraphicsLayer::removeAnimation):
+        (WebCore::WebGraphicsLayer::tiledBackingStoreVisibleRect):
+        (WebCore::WebGraphicsLayer::selfOrAncestorHasActiveTransformAnimations):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+        (WebGraphicsLayer):
+
 2012-01-25  Hajime Morita  <morrita@google.com>
 
         ENABLE_SHADOW_DOM should be available via build-webkit --shadow-dom
index 37d7b44..74c2431 100644 (file)
@@ -69,6 +69,15 @@ void WebGraphicsLayer::notifyChange()
         client()->notifySyncRequired(this);
 }
 
+void WebGraphicsLayer::notifyChangeRecursively()
+{
+    notifyChange();
+    for (size_t i = 0; i < children().size(); ++i)
+        toWebGraphicsLayer(children()[i])->notifyChangeRecursively();
+    if (replicaLayer())
+        toWebGraphicsLayer(replicaLayer())->notifyChange();
+}
+
 WebGraphicsLayer::WebGraphicsLayer(GraphicsLayerClient* client)
     : GraphicsLayer(client)
     , m_maskTarget(0)
@@ -173,7 +182,7 @@ void WebGraphicsLayer::setPosition(const FloatPoint& p)
         return;
 
     GraphicsLayer::setPosition(p);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
@@ -182,7 +191,7 @@ void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
         return;
 
     GraphicsLayer::setAnchorPoint(p);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setSize(const FloatSize& size)
@@ -194,7 +203,7 @@ void WebGraphicsLayer::setSize(const FloatSize& size)
     setNeedsDisplay();
     if (maskLayer())
         maskLayer()->setSize(size);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setTransform(const TransformationMatrix& t)
@@ -203,7 +212,7 @@ void WebGraphicsLayer::setTransform(const TransformationMatrix& t)
         return;
 
     GraphicsLayer::setTransform(t);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t)
@@ -212,7 +221,7 @@ void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t)
         return;
 
     GraphicsLayer::setChildrenTransform(t);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setPreserves3D(bool b)
@@ -221,7 +230,7 @@ void WebGraphicsLayer::setPreserves3D(bool b)
         return;
 
     GraphicsLayer::setPreserves3D(b);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setMasksToBounds(bool b)
@@ -229,7 +238,7 @@ void WebGraphicsLayer::setMasksToBounds(bool b)
     if (masksToBounds() == b)
         return;
     GraphicsLayer::setMasksToBounds(b);
-    notifyChange();
+    notifyChangeRecursively();
 }
 
 void WebGraphicsLayer::setDrawsContent(bool b)
@@ -296,9 +305,11 @@ bool WebGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const In
     webAnimation.animation = Animation::create(anim);
     webAnimation.startTime = timeOffset;
     m_layerInfo.animations.append(webAnimation);
+    if (valueList.property() == AnimatedPropertyWebkitTransform)
+        m_transformAnimations.add(keyframesName);
 
     m_hasPendingAnimations = true;
-    notifyChange();
+    notifyChangeRecursively();
 
     return true;
 }
@@ -319,6 +330,7 @@ void WebGraphicsLayer::removeAnimation(const String& animationName)
     webAnimation.name = animationName;
     webAnimation.operation = WebLayerAnimation::RemoveAnimation;
     m_layerInfo.animations.append(webAnimation);
+    m_transformAnimations.remove(animationName);
     notifyChange();
 }
 
@@ -535,6 +547,11 @@ IntRect WebGraphicsLayer::tiledBackingStoreContentsRect()
 
 IntRect WebGraphicsLayer::tiledBackingStoreVisibleRect()
 {
+    // If this layer is part of an active transform animation, the visible rect might change,
+    // so we rather render the whole layer until some better optimization is available.
+    if (selfOrAncestorHasActiveTransformAnimations())
+        return tiledBackingStoreContentsRect();
+
     // Non-invertible layers are not visible.
     if (!m_layerTransform.combined().isInvertible())
         return IntRect();
@@ -699,5 +716,16 @@ void WebGraphicsLayer::initFactory()
     GraphicsLayer::setGraphicsLayerFactory(createWebGraphicsLayer);
 }
 
+bool WebGraphicsLayer::selfOrAncestorHasActiveTransformAnimations() const
+{
+    if (!m_transformAnimations.isEmpty())
+        return true;
+
+    if (parent())
+        return toWebGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimations();
+
+    return false;
+}
+
 }
 #endif
index 3c579fd..0b50763 100644 (file)
@@ -35,6 +35,7 @@
 #include "WebLayerTreeInfo.h"
 #include "WebProcess.h"
 #include <WebCore/RunLoop.h>
+#include <wtf/text/StringHash.h>
 
 #if USE(ACCELERATED_COMPOSITING)
 
@@ -152,6 +153,10 @@ private:
     bool m_inUpdateMode : 2;
 
     void notifyChange();
+    void notifyChangeRecursively();
+    HashSet<String> m_transformAnimations;
+
+    bool selfOrAncestorHasActiveTransformAnimations() const;
 
 #if USE(TILED_BACKING_STORE)
     void computeTransformedVisibleRect();