Bug 1457249 - Factor out the function that converts transform into device space. r=kats
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 28 Apr 2018 18:08:15 +0900
changeset 472215 053966aefdb39c70801e332db20e508e0bc668b0
parent 472214 ac3a8c1f0776fa5db9507663b3b6ad987ee3b4dc
child 472216 ccef67dba02558dd7a3be26d339c9345efd3dfe6
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1457249
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457249 - Factor out the function that converts transform into device space. r=kats MozReview-Commit-ID: L7CDcSdIj4D
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -589,16 +589,42 @@ ServoAnimationValueToMatrix4x4(const Ref
                                                      transformOrigin);
 
   return nsDisplayTransform::GetResultingTransformMatrix(
     props, aTransformData.origin(),
     aTransformData.appUnitsPerDevPixel(),
     0, &aTransformData.bounds());
 }
 
+
+static Matrix4x4
+FrameTransformToTransformInDevice(const Matrix4x4& aFrameTransform,
+                                  Layer* aLayer,
+                                  const TransformData& aTransformData)
+{
+  Matrix4x4 transformInDevice = aFrameTransform;
+  // If our parent layer is a perspective layer, then the offset into reference
+  // frame coordinates is already on that layer. If not, then we need to ask
+  // for it to be added here.
+  if (!aLayer->GetParent() ||
+      !aLayer->GetParent()->GetTransformIsPerspective()) {
+    nsLayoutUtils::PostTranslate(transformInDevice, aTransformData.origin(),
+      aTransformData.appUnitsPerDevPixel(),
+      true);
+  }
+
+  if (ContainerLayer* c = aLayer->AsContainerLayer()) {
+    transformInDevice.PostScale(c->GetInheritedXScale(),
+                                c->GetInheritedYScale(),
+                                1);
+  }
+
+  return transformInDevice;
+}
+
 static void
 ApplyAnimatedValue(Layer* aLayer,
                    CompositorAnimationStorage* aStorage,
                    nsCSSPropertyID aProperty,
                    const AnimationData& aAnimationData,
                    const RefPtr<RawServoAnimationValue>& aValue)
 {
   if (!aValue) {
@@ -619,31 +645,20 @@ ApplyAnimatedValue(Layer* aLayer,
       break;
     }
     case eCSSProperty_transform: {
       const TransformData& transformData = aAnimationData.get_TransformData();
 
       Matrix4x4 frameTransform =
         ServoAnimationValueToMatrix4x4(aValue, transformData);
 
-      Matrix4x4 transform = frameTransform;
-
-      // If our parent layer is a perspective layer, then the offset into reference
-      // frame coordinates is already on that layer. If not, then we need to ask
-      // for it to be added here.
-      if (!aLayer->GetParent() ||
-          !aLayer->GetParent()->GetTransformIsPerspective()) {
-        nsLayoutUtils::PostTranslate(transform, transformData.origin(),
-                                     transformData.appUnitsPerDevPixel(),
-                                     true);
-      }
-
-      if (ContainerLayer* c = aLayer->AsContainerLayer()) {
-        transform.PostScale(c->GetInheritedXScale(), c->GetInheritedYScale(), 1);
-      }
+      Matrix4x4 transform =
+        FrameTransformToTransformInDevice(frameTransform,
+                                          aLayer,
+                                          transformData);
 
       layerCompositor->SetShadowBaseTransform(transform);
       layerCompositor->SetShadowTransformSetByAnimation(true);
       aStorage->SetAnimatedValue(aLayer->GetCompositorAnimationsId(),
                                  Move(transform), Move(frameTransform),
                                  transformData);
 
       layerCompositor->SetShadowOpacity(aLayer->GetOpacity());