Bug 1036119 - Have AsyncCompositionManager support layers which are both scrollable and fixed-position. r=Cwiiis
authorBotond Ballo <botond@mozilla.com>
Thu, 17 Jul 2014 16:08:33 -0400
changeset 217159 bd974f99638b2753fba77a5fbe39c4f31d60a8fb
parent 217158 30169511da157b6785dee963a0a2f37f8d37ccb8
child 217160 c50f8822c94ec38f3b94aeee7baa7041595c235c
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs1036119
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1036119 - Have AsyncCompositionManager support layers which are both scrollable and fixed-position. r=Cwiiis
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -136,18 +136,23 @@ GetBaseTransform2D(Layer* aLayer, Matrix
   return (aLayer->AsLayerComposite()->GetShadowTransformSetByAnimation() ?
           aLayer->GetLocalTransform() : aLayer->GetTransform()).Is2D(aTransform);
 }
 
 static void
 TranslateShadowLayer2D(Layer* aLayer,
                        const gfxPoint& aTranslation)
 {
+  // This layer might also be a scrollable layer and have an async transform.
+  // To make sure we don't clobber that, we start with the shadow transform.
+  // Any adjustments to the shadow transform made in this function in previous
+  // frames have been cleared in ClearAsyncTransforms(), so such adjustments
+  // will not compound over successive frames.
   Matrix layerTransform;
-  if (!GetBaseTransform2D(aLayer, &layerTransform)) {
+  if (!aLayer->GetLocalTransform().Is2D(&layerTransform)) {
     return;
   }
 
   // Apply the 2D translation to the layer transform.
   layerTransform._31 += aTranslation.x;
   layerTransform._32 += aTranslation.y;
 
   // The transform already takes the resolution scale into account.  Since we
@@ -889,31 +894,49 @@ AsyncCompositionManager::TransformScroll
   oldTransform.Scale(underZoomScale.width, underZoomScale.height, 1);
 
   // Make sure fixed position layers don't move away from their anchor points
   // when we're asynchronously panning or zooming
   AlignFixedAndStickyLayers(aLayer, aLayer, oldTransform,
                             aLayer->GetLocalTransform(), fixedLayerMargins);
 }
 
+void
+ClearAsyncTransforms(Layer* aLayer)
+{
+  if (!aLayer->AsLayerComposite()->GetShadowTransformSetByAnimation()) {
+    aLayer->AsLayerComposite()->SetShadowTransform(aLayer->GetBaseTransform());
+  }
+  for (Layer* child = aLayer->GetFirstChild();
+      child; child = child->GetNextSibling()) {
+    ClearAsyncTransforms(child);
+  }
+}
+
 bool
 AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
 {
   PROFILER_LABEL("AsyncCompositionManager", "TransformShadowTree",
     js::ProfileEntry::Category::GRAPHICS);
 
   Layer* root = mLayerManager->GetRoot();
   if (!root) {
     return false;
   }
 
   // NB: we must sample animations *before* sampling pan/zoom
   // transforms.
   bool wantNextFrame = SampleAnimations(root, aCurrentFrame);
 
+  // Clear any async transforms (not due to animations) set in previous frames.
+  // This is necessary because some things called by
+  // ApplyAsyncContentTransformToTree (in particular, TranslateShadowLayer2D),
+  // add to the shadow transform rather than overwriting it.
+  ClearAsyncTransforms(root);
+
   // FIXME/bug 775437: unify this interface with the ~native-fennec
   // derived code
   //
   // Attempt to apply an async content transform to any layer that has
   // an async pan zoom controller (which means that it is rendered
   // async using Gecko). If this fails, fall back to transforming the
   // primary scrollable layer.  "Failing" here means that we don't
   // find a frame that is async scrollable.  Note that the fallback