Title: [184274] trunk/Source/WebCore
Revision
184274
Author
[email protected]
Date
2015-05-12 23:47:21 -0700 (Tue, 12 May 2015)

Log Message

Reduce TransformationMatrix copies in MatrixTransformOperation, Matrix3DTransformOperation
https://bugs.webkit.org/show_bug.cgi?id=144797

Reviewed by Darin Adler.

Using std::swap() on TransformationMatrix objects which don't
provide move constructors will result in copies.

Instead, use a helper function in both MatrixTransformOperation
and Matrix3DTransformOperation that calls TransformationMatrix::blend()
and returns the new Matrix(3D)TransformOperation object, and call it
with fromT and toT arguments switched when blending to identity.

* platform/graphics/transforms/Matrix3DTransformOperation.cpp:
(WebCore::createOperation):
(WebCore::Matrix3DTransformOperation::blend):
* platform/graphics/transforms/Matrix3DTransformOperation.h: No need
to copy the m_matrix member, it won't change when passed to
TransformationMatrix::multiply().
* platform/graphics/transforms/MatrixTransformOperation.cpp:
(WebCore::createOperation):
(WebCore::MatrixTransformOperation::blend):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (184273 => 184274)


--- trunk/Source/WebCore/ChangeLog	2015-05-13 06:18:22 UTC (rev 184273)
+++ trunk/Source/WebCore/ChangeLog	2015-05-13 06:47:21 UTC (rev 184274)
@@ -1,3 +1,28 @@
+2015-05-12  Zan Dobersek  <[email protected]>
+
+        Reduce TransformationMatrix copies in MatrixTransformOperation, Matrix3DTransformOperation
+        https://bugs.webkit.org/show_bug.cgi?id=144797
+
+        Reviewed by Darin Adler.
+
+        Using std::swap() on TransformationMatrix objects which don't
+        provide move constructors will result in copies.
+
+        Instead, use a helper function in both MatrixTransformOperation
+        and Matrix3DTransformOperation that calls TransformationMatrix::blend()
+        and returns the new Matrix(3D)TransformOperation object, and call it
+        with fromT and toT arguments switched when blending to identity.
+
+        * platform/graphics/transforms/Matrix3DTransformOperation.cpp:
+        (WebCore::createOperation):
+        (WebCore::Matrix3DTransformOperation::blend):
+        * platform/graphics/transforms/Matrix3DTransformOperation.h: No need
+        to copy the m_matrix member, it won't change when passed to
+        TransformationMatrix::multiply().
+        * platform/graphics/transforms/MatrixTransformOperation.cpp:
+        (WebCore::createOperation):
+        (WebCore::MatrixTransformOperation::blend):
+
 2015-05-12  Carlos Garcia Campos  <[email protected]>
 
         [EGL][X11] XPixmap created in GLContextEGL::createPixmapContext() is leaked

Modified: trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp (184273 => 184274)


--- trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp	2015-05-13 06:18:22 UTC (rev 184273)
+++ trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp	2015-05-13 06:47:21 UTC (rev 184274)
@@ -35,6 +35,12 @@
     return isSameType(other) && m_matrix == downcast<Matrix3DTransformOperation>(other).m_matrix;
 }
 
+static Ref<TransformOperation> createOperation(TransformationMatrix& to, TransformationMatrix& from, double progress)
+{
+    to.blend(from, progress);
+    return Matrix3DTransformOperation::create(to);
+}
+
 Ref<TransformOperation> Matrix3DTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
 {
     if (from && !from->isSameType(*this))
@@ -50,10 +56,8 @@
     apply(toT, size);
 
     if (blendToIdentity)
-        std::swap(fromT, toT);
-
-    toT.blend(fromT, progress);
-    return Matrix3DTransformOperation::create(toT);
+        return createOperation(fromT, toT, progress);
+    return createOperation(toT, fromT, progress);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h (184273 => 184274)


--- trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2015-05-13 06:18:22 UTC (rev 184273)
+++ trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2015-05-13 06:47:21 UTC (rev 184274)
@@ -56,7 +56,7 @@
 
     virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override
     {
-        transform.multiply(TransformationMatrix(m_matrix));
+        transform.multiply(m_matrix);
         return false;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp (184273 => 184274)


--- trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp	2015-05-13 06:18:22 UTC (rev 184273)
+++ trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp	2015-05-13 06:47:21 UTC (rev 184274)
@@ -34,6 +34,12 @@
     return m_a == m.m_a && m_b == m.m_b && m_c == m.m_c && m_d == m.m_d && m_e == m.m_e && m_f == m.m_f;
 }
 
+static Ref<TransformOperation> createOperation(TransformationMatrix& to, TransformationMatrix& from, double progress)
+{
+    to.blend(from, progress);
+    return MatrixTransformOperation::create(to);
+}
+
 Ref<TransformOperation> MatrixTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
 {
     if (from && !from->isSameType(*this))
@@ -46,12 +52,10 @@
         const MatrixTransformOperation& m = downcast<MatrixTransformOperation>(*from);
         fromT.setMatrix(m.m_a, m.m_b, m.m_c, m.m_d, m.m_e, m.m_f);
     }
-    
+
     if (blendToIdentity)
-        std::swap(fromT, toT);
-
-    toT.blend(fromT, progress);
-    return MatrixTransformOperation::create(toT.a(), toT.b(), toT.c(), toT.d(), toT.e(), toT.f());
+        return createOperation(fromT, toT, progress);
+    return createOperation(toT, fromT, progress);
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to