Bug 1091296 - Remove the redundant code for clearing async transforms per frame of composition. r=mattwoodrow
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 11 Nov 2014 10:53:57 -0500
changeset 226446 357845594db431485453b0fd0a63337b8dd901f5
parent 226445 b9ebaad549c3e1b00ac976f42389597b4a159842
child 226447 6fd76ef0601f05a26e5672a5a8a797761f78d84e
push id53
push userdglastonbury@mozilla.com
push dateWed, 12 Nov 2014 02:04:58 +0000
reviewersmattwoodrow
bugs1091296
milestone36.0a1
Bug 1091296 - Remove the redundant code for clearing async transforms per frame of composition. r=mattwoodrow We already reset the shadow transform to the layer transform in SetShadowProperties() before compositing every frame, so this is redundant.
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -174,19 +174,20 @@ SetShadowTransform(Layer* aLayer, Matrix
 
 static void
 TranslateShadowLayer2D(Layer* aLayer,
                        const gfxPoint& aTranslation,
                        bool aAdjustClipRect)
 {
   // 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.
+  // (i.e. GetLocalTransform() instead of GetTransform()).
+  // Note that the shadow transform is reset on every frame of composition so
+  // we don't have to worry about the adjustments compounding over successive
+  // frames.
   Matrix layerTransform;
   if (!aLayer->GetLocalTransform().Is2D(&layerTransform)) {
     return;
   }
 
   // Apply the 2D translation to the layer transform.
   layerTransform._31 += aTranslation.x;
   layerTransform._32 += aTranslation.y;
@@ -934,50 +935,32 @@ AsyncCompositionManager::TransformScroll
   oldTransform.PreScale(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, metrics.GetScrollId(), 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;
   }
 
-
+  // First, compute and set the shadow transforms from OMT animations.
   // 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