Bug 1340005 - Part 4: Retrieve transform list from AnimationValue. draft
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 25 Sep 2017 14:25:43 +0800
changeset 687789 f8345ee25f6b61cbc2c51d9558d7ce37220f1c79
parent 687788 26c8e2d8e61eaa5b486c992c525bc63389424804
child 687790 51351e4877f110d86c4e2eb7e37cc3ada8f96f8f
push id86604
push userbmo:boris.chiou@gmail.com
push dateFri, 27 Oct 2017 19:27:11 +0000
bugs1340005
milestone58.0a1
Bug 1340005 - Part 4: Retrieve transform list from AnimationValue. 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
@@ -5843,25 +5843,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
@@ -605,17 +605,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.