Bug 985470 - Replace the Moz2D Matrix().Translate() calls with Matrix::Translation() for better perf. r=mattwoodrow
authorJonathan Watt <jwatt@jwatt.org>
Sat, 22 Mar 2014 07:56:11 +0800
changeset 174829 2cbac6fa8499f089d46092a6fd47d119fb1dbcfb
parent 174828 87e39d7d851a17756c396a4d2ad69c186b472a61
child 174853 2cc3ef8513ce443a88aabf4642f954ed95030bb6
push id41372
push userjwatt@jwatt.org
push dateFri, 21 Mar 2014 23:57:16 +0000
treeherdermozilla-inbound@2cbac6fa8499 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs985470
milestone31.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 985470 - Replace the Moz2D Matrix().Translate() calls with Matrix::Translation() for better perf. r=mattwoodrow
gfx/2d/FilterNodeSoftware.cpp
gfx/layers/Layers.cpp
gfx/src/FilterSupport.cpp
layout/svg/nsSVGImageFrame.cpp
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -1103,18 +1103,18 @@ FilterNodeTransformSoftware::Render(cons
 
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_TRANSFORM_IN, srcRect, NEED_COLOR_CHANNELS);
 
   if (!input) {
     return nullptr;
   }
 
-  Matrix transform = Matrix().Translate(srcRect.x, srcRect.y) * mMatrix *
-                     Matrix().Translate(-aRect.x, -aRect.y);
+  Matrix transform = Matrix::Translation(srcRect.x, srcRect.y) * mMatrix *
+                     Matrix::Translation(-aRect.x, -aRect.y);
   if (transform.IsIdentity() && srcRect.Size() == aRect.Size()) {
     return input;
   }
 
   RefPtr<DrawTarget> dt =
     Factory::CreateDrawTarget(BackendType::CAIRO, aRect.Size(), input->GetFormat());
   if (!dt) {
     return nullptr;
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -495,26 +495,26 @@ Layer::SnapTransformTranslation(const Ma
 
   Matrix matrix2D;
   Matrix4x4 result;
   if (mManager->IsSnappingEffectiveTransforms() &&
       aTransform.Is2D(&matrix2D) &&
       !matrix2D.HasNonTranslation() &&
       matrix2D.HasNonIntegerTranslation()) {
     IntPoint snappedTranslation = RoundedToInt(matrix2D.GetTranslation());
-    Matrix snappedMatrix = Matrix().Translate(snappedTranslation.x,
-                                              snappedTranslation.y);
+    Matrix snappedMatrix = Matrix::Translation(snappedTranslation.x,
+                                               snappedTranslation.y);
     result = Matrix4x4::From2D(snappedMatrix);
     if (aResidualTransform) {
       // set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
       // (I.e., appying snappedMatrix after aResidualTransform gives the
       // ideal transform.)
       *aResidualTransform =
-        Matrix().Translate(matrix2D._31 - snappedTranslation.x,
-                           matrix2D._32 - snappedTranslation.y);
+        Matrix::Translation(matrix2D._31 - snappedTranslation.x,
+                            matrix2D._32 - snappedTranslation.y);
     }
   } else {
     result = aTransform;
   }
   return result;
 }
 
 Matrix4x4
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -153,17 +153,17 @@ namespace FilterWrappers {
     filter->SetInput(IN_CROP_IN, aInputFilter);
     return filter;
   }
 
   static TemporaryRef<FilterNode>
   Offset(DrawTarget* aDT, FilterNode* aInputFilter, const IntPoint& aOffset)
   {
     RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::TRANSFORM);
-    filter->SetAttribute(ATT_TRANSFORM_MATRIX, Matrix().Translate(aOffset.x, aOffset.y));
+    filter->SetAttribute(ATT_TRANSFORM_MATRIX, Matrix::Translation(aOffset.x, aOffset.y));
     filter->SetInput(IN_TRANSFORM_IN, aInputFilter);
     return filter;
   }
 
   static TemporaryRef<FilterNode>
   GaussianBlur(DrawTarget* aDT, FilterNode* aInputFilter, const Size& aStdDeviation)
   {
     float stdX = float(std::min(aStdDeviation.width, kMaxStdDeviation));
@@ -194,17 +194,17 @@ namespace FilterWrappers {
   }
 
   static TemporaryRef<FilterNode>
   ForSurface(DrawTarget* aDT, SourceSurface* aSurface,
              const IntPoint& aSurfacePosition)
   {
     RefPtr<FilterNode> filter = aDT->CreateFilter(FilterType::TRANSFORM);
     filter->SetAttribute(ATT_TRANSFORM_MATRIX,
-      Matrix().Translate(aSurfacePosition.x, aSurfacePosition.y));
+      Matrix::Translation(aSurfacePosition.x, aSurfacePosition.y));
     filter->SetInput(IN_TRANSFORM_IN, aSurface);
     return filter;
   }
 
   static TemporaryRef<FilterNode>
   ToAlpha(DrawTarget* aDT, FilterNode* aInput)
   {
     float zero = 0.0f;
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -234,33 +234,33 @@ nsSVGImageFrame::GetRasterImageTransform
   element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
   Matrix viewBoxTM =
     SVGContentUtils::GetViewBoxTransform(width, height,
                                          0, 0, aNativeWidth, aNativeHeight,
                                          element->mPreserveAspectRatio);
 
   return viewBoxTM *
-         gfx::Matrix().Translate(x, y) *
+         gfx::Matrix::Translation(x, y) *
          gfx::ToMatrix(GetCanvasTM(aFor, aTransformRoot));
 }
 
 gfx::Matrix
 nsSVGImageFrame::GetVectorImageTransform(uint32_t aFor,
                                          nsIFrame* aTransformRoot)
 {
   float x, y, width, height;
   SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
   element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
   // No viewBoxTM needed here -- our height/width overrides any concept of
   // "native size" that the SVG image has, and it will handle viewBox and
   // preserveAspectRatio on its own once we give it a region to draw into.
 
-  return gfx::Matrix().Translate(x, y) *
+  return gfx::Matrix::Translation(x, y) *
          gfx::ToMatrix(GetCanvasTM(aFor, aTransformRoot));
 }
 
 bool
 nsSVGImageFrame::TransformContextForPainting(gfxContext* aGfxContext,
                                              nsIFrame* aTransformRoot)
 {
   gfx::Matrix imageTransform;