From 41be7768d192fd1221b0aebbf34a3e6a3c591589 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Sat, 28 Apr 2018 18:09:27 +0900 Subject: [PATCH] Bug 1457249 - Use actually calculated value for the assertion that checks animation value is unchanged when we decided to skip calculation for the animation on debug build. r=kats Before this change, the value which was set by SetShadowBaseTransform() has been used for the assertion, but it is possible that the value is changed by APZ. And it's hard to tell whether the value has been changed by APZ or not and it's hard to *reverse-calculate* the differences in the past APZ at the moment we want to do the assert. So after this patch, on debug build we don't actually skip the calculation for unchanged animations and use the newly calculated value for the assertion. MozReview-Commit-ID: 8fCcvvbUMHe --HG-- extra : rebase_source : 0ff5e7100ad33a690bb0edd02af2b00c749afbbe --- gfx/layers/AnimationHelper.cpp | 23 +++++++++++++++++++ .../composite/AsyncCompositionManager.cpp | 14 +++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp index fda9500a27d8..45cca831fb7b 100644 --- a/gfx/layers/AnimationHelper.cpp +++ b/gfx/layers/AnimationHelper.cpp @@ -156,6 +156,14 @@ AnimationHelper::SampleAnimationForEachNode( MOZ_ASSERT(!aAnimations.IsEmpty(), "Should be called with animations"); bool hasInEffectAnimations = false; +#ifdef DEBUG + // In cases where this function returns a SampleResult::Skipped, we actually + // do populate aAnimationValue in debug mode, so that we can MOZ_ASSERT at the + // call site that the value that would have been computed matches the stored + // value that we end up using. This flag is used to ensure we populate + // aAnimationValue in this scenario. + bool shouldBeSkipped = false; +#endif // Process in order, since later aAnimations override earlier ones. for (size_t i = 0, iEnd = aAnimations.Length(); i < iEnd; ++i) { Animation& animation = aAnimations[i]; @@ -204,7 +212,11 @@ AnimationHelper::SampleAnimationForEachNode( iterCompositeOperation, animData.mProgressOnLastCompose, animData.mCurrentIterationOnLastCompose)) { +#ifdef DEBUG + shouldBeSkipped = true; +#else return SampleResult::Skipped; +#endif } uint32_t segmentIndex = 0; @@ -236,7 +248,11 @@ AnimationHelper::SampleAnimationForEachNode( animData.mSegmentIndexOnLastCompose == segmentIndex && !animData.mPortionInSegmentOnLastCompose.IsNull() && animData.mPortionInSegmentOnLastCompose.Value() == portion) { +#ifdef DEBUG + shouldBeSkipped = true; +#else return SampleResult::Skipped; +#endif } AnimationPropertySegment animSegment; @@ -260,6 +276,13 @@ AnimationHelper::SampleAnimationForEachNode( iterCompositeOperation, portion, computedTiming.mCurrentIteration).Consume(); + +#ifdef DEBUG + if (shouldBeSkipped) { + return SampleResult::Skipped; + } +#endif + hasInEffectAnimations = true; animData.mProgressOnLastCompose = computedTiming.mProgress; animData.mCurrentIterationOnLastCompose = computedTiming.mCurrentIteration; diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 88ee69944a36..c54f2d304250 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -713,17 +713,27 @@ SampleAnimations(Layer* aLayer, MOZ_ASSERT( layer->AsHostLayer()->GetShadowOpacitySetByAnimation()); MOZ_ASSERT(FuzzyEqualsMultiplicative( - layer->AsHostLayer()->GetShadowOpacity(), + Servo_AnimationValue_GetOpacity(animationValue), *(aStorage->GetAnimationOpacity(layer->GetCompositorAnimationsId())))); break; case eCSSProperty_transform: { MOZ_ASSERT( layer->AsHostLayer()->GetShadowTransformSetByAnimation()); + AnimatedValue* transform = aStorage->GetAnimatedValue(layer->GetCompositorAnimationsId()); + + const TransformData& transformData = + animations[0].data().get_TransformData(); + Matrix4x4 frameTransform = + ServoAnimationValueToMatrix4x4(animationValue, transformData); + Matrix4x4 transformInDevice = + FrameTransformToTransformInDevice(frameTransform, + layer, + transformData); MOZ_ASSERT( transform->mTransform.mTransformInDevSpace.FuzzyEqualsMultiplicative( - (layer->AsHostLayer()->GetShadowBaseTransform()))); + transformInDevice)); break; } default: