From 9559bab90f17063cd0d6d1db042b8c636ab4865d Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Tue, 11 Nov 2014 10:54:02 -0500 Subject: [PATCH] Bug 1091296 - When applying the APZ transform on a layer, make sure not to clobber any existing OMTA transform. r=mattwoodrow --HG-- extra : rebase_source : 9662fbdea917d63a1205660979cbb5c6f861ba02 --- .../composite/AsyncCompositionManager.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index a931f37df85..22bf15c8c46 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -544,7 +544,7 @@ SampleAPZAnimations(const LayerMetricsWrapper& aLayer, TimeStamp aSampleTime) } Matrix4x4 -AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer) +AdjustForClip(const Matrix4x4& asyncTransform, Layer* aLayer) { Matrix4x4 result = asyncTransform; @@ -559,9 +559,6 @@ AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer) result.ChangeBasis(shadowClipRect->x, shadowClipRect->y, 0); } } - - // Combine the async transform with the layer's CSS transform. - result = aLayer->GetTransform() * result; return result; } @@ -622,10 +619,12 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer) } if (hasAsyncTransform) { + // Apply the APZ transform on top of GetLocalTransform() here (rather than + // GetTransform()) in case the OMTA code in SampleAnimations already set a + // shadow transform; in that case we want to apply ours on top of that one + // rather than clobber it. SetShadowTransform(aLayer, - AdjustAndCombineWithCSSTransform(combinedAsyncTransform, aLayer)); - NS_ASSERTION(!aLayer->AsLayerComposite()->GetShadowTransformSetByAnimation(), - "overwriting animated transform!"); + aLayer->GetLocalTransform() * AdjustForClip(combinedAsyncTransform, aLayer)); const FrameMetrics& bottom = LayerMetricsWrapper::BottommostScrollableMetrics(aLayer); MOZ_ASSERT(bottom.IsScrollable()); // must be true because hasAsyncTransform is true @@ -638,15 +637,18 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer) oldTransform.PreScale(resolution.scale, resolution.scale, 1); // For the purpose of aligning fixed and sticky layers, we disregard - // the overscroll transform when computing the 'aCurrentTransformForRoot' - // parameter. This ensures that the overscroll transform is not unapplied, - // and therefore that the visual effect applies to fixed and sticky layers. - Matrix4x4 transformWithoutOverscroll = AdjustAndCombineWithCSSTransform( - combinedAsyncTransformWithoutOverscroll, aLayer); + // the overscroll transform as well as any OMTA transform when computing the + // 'aCurrentTransformForRoot' parameter. This ensures that the overscroll + // and OMTA transforms are not unapplied, and therefore that the visual + // effects apply to fixed and sticky layers. We do this by using + // GetTransform() as the base transform rather than GetLocalTransform(), + // which would include those factors. + Matrix4x4 transformWithoutOverscrollOrOmta = aLayer->GetTransform() * + AdjustForClip(combinedAsyncTransformWithoutOverscroll, aLayer); // Since fixed/sticky layers are relative to their nearest scrolling ancestor, // we use the ViewID from the bottommost scrollable metrics here. AlignFixedAndStickyLayers(aLayer, aLayer, bottom.GetScrollId(), oldTransform, - transformWithoutOverscroll, fixedLayerMargins); + transformWithoutOverscrollOrOmta, fixedLayerMargins); appliedTransform = true; }