Bug 1340005 - Part 4: Retrieve transform list from AnimationValue. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 25 Sep 2017 14:25:43 +0800
changeset 688117 6ba6dfa9f2293f92ecc1431efa67cce1a4c25d3f
parent 688116 b43c82ffe651880e52322b7dcdc50cc0752baeb6
child 688118 ebe3f98312ec91bb5a0052c72376237e134382db
push id86669
push userhikezoe@mozilla.com
push dateSat, 28 Oct 2017 10:13:18 +0000
reviewersbirtles
bugs1340005
milestone58.0a1
Bug 1340005 - Part 4: Retrieve transform list from AnimationValue. r=birtles MozReview-Commit-ID: 82NAOBV2rEl
gfx/layers/AnimationHelper.cpp
gfx/layers/composite/AsyncCompositionManager.cpp
layout/painting/nsDisplayList.h
layout/style/StyleAnimationValue.cpp
layout/style/StyleAnimationValue.h
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -582,23 +582,23 @@ AnimationHelper::SampleAnimations(Compos
     // Store the AnimatedValue
     Animation& animation = animations->LastElement();
     switch (animation.property()) {
       case eCSSProperty_opacity: {
         aStorage->SetAnimatedValue(iter.Key(), animationValue.GetOpacity());
         break;
       }
       case eCSSProperty_transform: {
-        // TODO: Convert AnimationValue into css shared list.
-        nsCSSValueSharedList* list = animationValue.mGecko.GetCSSValueSharedListValue();
+        RefPtr<const nsCSSValueSharedList> list =
+          animationValue.GetTransformList();
         const TransformData& transformData = animation.data().get_TransformData();
         nsPoint origin = transformData.origin();
         // we expect all our transform data to arrive in device pixels
         gfx::Point3D transformOrigin = transformData.transformOrigin();
-        nsDisplayTransform::FrameTransformProperties props(list,
+        nsDisplayTransform::FrameTransformProperties props(Move(list),
                                                            transformOrigin);
 
         gfx::Matrix4x4 transform =
           nsDisplayTransform::GetResultingTransformMatrix(props, origin,
                                                           transformData.appUnitsPerDevPixel(),
                                                           0, &transformData.bounds());
         gfx::Matrix4x4 frameTransform = transform;
         // If the parent has perspective transform, then the offset into reference
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -592,27 +592,22 @@ ApplyAnimatedValue(Layer* aLayer,
       layerCompositor->SetShadowOpacity(aValue.GetOpacity());
       layerCompositor->SetShadowOpacitySetByAnimation(true);
       aStorage->SetAnimatedValue(aLayer->GetCompositorAnimationsId(),
                                  aValue.GetOpacity());
 
       break;
     }
     case eCSSProperty_transform: {
-      MOZ_ASSERT(aValue.mGecko.GetUnit() == StyleAnimationValue::eUnit_Transform,
-                 "The unit of interpolated value for transform should be "
-                 "transform");
-      // TODO: Convert AnimationValue into css shared list.
-      nsCSSValueSharedList* list = aValue.mGecko.GetCSSValueSharedListValue();
-
+      RefPtr<const nsCSSValueSharedList> list = aValue.GetTransformList();
       const TransformData& transformData = aAnimationData.get_TransformData();
       nsPoint origin = transformData.origin();
       // we expect all our transform data to arrive in device pixels
       Point3D transformOrigin = transformData.transformOrigin();
-      nsDisplayTransform::FrameTransformProperties props(list,
+      nsDisplayTransform::FrameTransformProperties props(Move(list),
                                                          transformOrigin);
 
       Matrix4x4 transform =
         nsDisplayTransform::GetResultingTransformMatrix(props, origin,
                                                         transformData.appUnitsPerDevPixel(),
                                                         0, &transformData.bounds());
       Matrix4x4 frameTransform = transform;
 
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -5864,25 +5864,26 @@ public:
                                        float aAppUnitsPerPixel,
                                        Matrix4x4& aOutMatrix);
 
   struct FrameTransformProperties
   {
     FrameTransformProperties(const nsIFrame* aFrame,
                              float aAppUnitsPerPixel,
                              const nsRect* aBoundsOverride);
-    FrameTransformProperties(nsCSSValueSharedList* aTransformList,
+    FrameTransformProperties(RefPtr<const nsCSSValueSharedList>&&
+                               aTransformList,
                              const Point3D& aToTransformOrigin)
       : mFrame(nullptr)
-      , mTransformList(aTransformList)
+      , mTransformList(mozilla::Move(aTransformList))
       , mToTransformOrigin(aToTransformOrigin)
     {}
 
     const nsIFrame* mFrame;
-    RefPtr<nsCSSValueSharedList> mTransformList;
+    const RefPtr<const nsCSSValueSharedList> mTransformList;
     const Point3D mToTransformOrigin;
   };
 
   /**
    * Given a frame with the -moz-transform property or an SVG transform,
    * returns the transformation matrix for that frame.
    *
    * @param aFrame The frame to get the matrix from.
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -5355,16 +5355,33 @@ AnimationValue::GetOpacity() const
 {
   MOZ_ASSERT(!mServo != mGecko.IsNull());
   MOZ_ASSERT(mServo || mGecko.GetUnit() == StyleAnimationValue::eUnit_Float,
              "Should have the correct unit on Gecko backend");
   return mServo ? Servo_AnimationValue_GetOpacity(mServo)
                 : mGecko.GetFloatValue();
 }
 
+already_AddRefed<const nsCSSValueSharedList>
+AnimationValue::GetTransformList() const
+{
+  MOZ_ASSERT(!mServo != mGecko.IsNull());
+  MOZ_ASSERT(mServo || mGecko.GetUnit() == StyleAnimationValue::eUnit_Transform,
+             "The unit of interpolated value for transform should be "
+             "transform on Gecko backend");
+
+  RefPtr<nsCSSValueSharedList> transform;
+  if (mServo) {
+    Servo_AnimationValue_GetTransform(mServo, &transform);
+  } else {
+    transform = mGecko.GetCSSValueSharedListValue();
+  }
+  return transform.forget();
+}
+
 gfxSize
 AnimationValue::GetScaleValue(const nsIFrame* aFrame) const
 {
   MOZ_ASSERT(!mServo != mGecko.IsNull());
   if (mServo) {
     RefPtr<nsCSSValueSharedList> list;
     Servo_AnimationValue_GetTransform(mServo, &list);
     return nsStyleTransformMatrix::GetScaleValue(list, aFrame);
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -606,17 +606,20 @@ struct AnimationValue
 
   bool operator==(const AnimationValue& aOther) const;
   bool operator!=(const AnimationValue& aOther) const;
 
   bool IsNull() const { return mGecko.IsNull() && !mServo; }
 
   float GetOpacity() const;
 
-  // Returns the scale for mGecko or mServo, which are calculated with
+  // Return the transform list as a RefPtr.
+  already_AddRefed<const nsCSSValueSharedList> GetTransformList() const;
+
+  // Return the scale for mGecko or mServo, which are calculated with
   // reference to aFrame.
   gfxSize GetScaleValue(const nsIFrame* aFrame) const;
 
   // Uncompute this AnimationValue and then serialize it.
   void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
                                nsAString& aString) const;
 
   // Check if |*this| and |aToValue| can be interpolated.