Bug 1043859 - Fix the code to remove the async transform from scrollbar layers that are descendants of their content. r=botond a=bajaj
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 01 Oct 2014 17:49:31 -0400
changeset 225481 4596fc5abb411bdef98f1a99aa98adfa14dc95f4
parent 225480 398ee670cb58976f855a9be125cd6ebb9b4d9cd8
child 225482 34dd5b90c0d91b01af28f22e358d612b58e28a71
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond, bajaj
bugs1043859
milestone34.0a2
Bug 1043859 - Fix the code to remove the async transform from scrollbar layers that are descendants of their content. r=botond a=bajaj
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -730,25 +730,35 @@ ApplyAsyncTransformToScrollbarForContent
   Matrix4x4 transform = scrollbarTransform * aScrollbar->GetTransform();
 
   if (aScrollbarIsDescendant) {
     // If the scrollbar layer is a child of the content it is a scrollbar for, then we
     // need to do an extra untransform to cancel out the transient async transform on
     // the content. This is needed because otherwise that transient async transform is
     // part of the effective transform of this scrollbar, and the scrollbar will jitter
     // as the content scrolls.
-    transientTransform.Invert();
-    transform = transform * transientTransform;
+    // Since the async transform is applied on top of the content's regular
+    // transform, we need to make sure to unapply the async transform in the
+    // same coordinate space. This requires applying the content transform and
+    // then unapplying it after unapplying the async transform.
+    Matrix4x4 asyncUntransform = (asyncTransform * apzc->GetOverscrollTransform());
+    asyncUntransform.Invert();
+    Matrix4x4 contentTransform = aContent.GetTransform();
+    Matrix4x4 contentUntransform = contentTransform;
+    contentUntransform.Invert();
+
+    Matrix4x4 compensation = contentTransform * asyncUntransform * contentUntransform;
+    transform = transform * compensation;
 
     // We also need to make a corresponding change on the clip rect of all the
     // layers on the ancestor chain from the scrollbar layer up to but not
     // including the layer with the async transform. Otherwise the scrollbar
     // shifts but gets clipped and so appears to flicker.
     for (Layer* ancestor = aScrollbar; ancestor != aContent.GetLayer(); ancestor = ancestor->GetParent()) {
-      TransformClipRect(ancestor, transientTransform);
+      TransformClipRect(ancestor, compensation);
     }
   }
 
   // GetTransform already takes the pre- and post-scale into account.  Since we
   // will apply the pre- and post-scale again when computing the effective
   // transform, we must apply the inverses here.
   if (ContainerLayer* container = aScrollbar->AsContainerLayer()) {
     transform.Scale(1.0f/container->GetPreXScale(),