[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

krit at webkit.org krit at webkit.org
Fri Feb 26 22:16:12 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 1553eac8a13039d994ba83de8e6d0f8fc9a71967
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 9 20:46:59 2010 +0000

    2010-02-09  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            More optimization for AffineTransform with SVG
            https://bugs.webkit.org/show_bug.cgi?id=34774
    
            Some optimizations to safe unnecessary summations and multiplications.
            Optimize AffineTransform to handle an identity or translation matrix
            more efficient.
            Added translationRight to avoid multiplications of matrices as much as
            possible.
    
            No tests added, no change of functionality.
    
            * platform/graphics/transforms/AffineTransform.cpp:
            (WebCore::AffineTransform::inverse):
            (WebCore::AffineTransform::translate):
            (WebCore::AffineTransform::translateRight):
            * platform/graphics/transforms/AffineTransform.h:
            * rendering/RenderForeignObject.cpp:
            (WebCore::RenderForeignObject::translationForAttributes):
            (WebCore::RenderForeignObject::localToParentTransform):
            * rendering/RenderForeignObject.h:
            * rendering/RenderSVGRoot.cpp:
            (WebCore::RenderSVGRoot::localToBorderBoxTransform):
            (WebCore::RenderSVGRoot::localToRepaintContainerTransform):
            (WebCore::RenderSVGRoot::localToParentTransform):
            * rendering/RenderSVGViewportContainer.cpp:
            (WebCore::RenderSVGViewportContainer::localToParentTransform):
            * rendering/SVGRootInlineBox.cpp:
            (WebCore::applyTextLengthCorrectionToTextChunk):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54564 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 889acfa..3cfc586 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,39 @@
 
         Reviewed by Nikolas Zimmermann.
 
+        More optimization for AffineTransform with SVG
+        https://bugs.webkit.org/show_bug.cgi?id=34774
+
+        Some optimizations to safe unnecessary summations and multiplications.
+        Optimize AffineTransform to handle an identity or translation matrix
+        more efficient.
+        Added translationRight to avoid multiplications of matrices as much as
+        possible.
+
+        No tests added, no change of functionality.   
+
+        * platform/graphics/transforms/AffineTransform.cpp:
+        (WebCore::AffineTransform::inverse):
+        (WebCore::AffineTransform::translate):
+        (WebCore::AffineTransform::translateRight):
+        * platform/graphics/transforms/AffineTransform.h:
+        * rendering/RenderForeignObject.cpp:
+        (WebCore::RenderForeignObject::translationForAttributes):
+        (WebCore::RenderForeignObject::localToParentTransform):
+        * rendering/RenderForeignObject.h:
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::localToBorderBoxTransform):
+        (WebCore::RenderSVGRoot::localToRepaintContainerTransform):
+        (WebCore::RenderSVGRoot::localToParentTransform):
+        * rendering/RenderSVGViewportContainer.cpp:
+        (WebCore::RenderSVGViewportContainer::localToParentTransform):
+        * rendering/SVGRootInlineBox.cpp:
+        (WebCore::applyTextLengthCorrectionToTextChunk):
+
+2010-02-09  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
         SVG patterns with some scale patternTransform are not displayed correctly for small elements
         https://bugs.webkit.org/show_bug.cgi?id=25484
 
diff --git a/WebCore/platform/graphics/transforms/AffineTransform.cpp b/WebCore/platform/graphics/transforms/AffineTransform.cpp
index 183bff5..d6688d2 100644
--- a/WebCore/platform/graphics/transforms/AffineTransform.cpp
+++ b/WebCore/platform/graphics/transforms/AffineTransform.cpp
@@ -136,6 +136,12 @@ AffineTransform AffineTransform::inverse() const
         return AffineTransform();
 
     AffineTransform result;
+    if (isIdentityOrTranslation()) {
+        result.m_transform[4] = -m_transform[4];
+        result.m_transform[5] = -m_transform[5];
+        return result;
+    }
+
     result.m_transform[0] = m_transform[3] / determinant;
     result.m_transform[1] = -m_transform[1] / determinant;
     result.m_transform[2] = -m_transform[2] / determinant;
@@ -194,13 +200,28 @@ AffineTransform& AffineTransform::scale(double sx, double sy)
     return *this;
 }
 
+// *this = *this * translation
 AffineTransform& AffineTransform::translate(double tx, double ty)
 {
+    if (isIdentityOrTranslation()) {
+        m_transform[4] += tx;
+        m_transform[5] += ty;
+        return *this;
+    }
+        
     m_transform[4] += tx * m_transform[0] + ty * m_transform[2];
     m_transform[5] += tx * m_transform[1] + ty * m_transform[3];
     return *this;
 }
 
+// *this = translation * *this
+AffineTransform& AffineTransform::translateRight(double tx, double ty)
+{
+    m_transform[4] += tx;
+    m_transform[5] += ty;
+    return *this;
+}
+
 AffineTransform& AffineTransform::scaleNonUniform(double sx, double sy)
 {
     return scale(sx, sy);
diff --git a/WebCore/platform/graphics/transforms/AffineTransform.h b/WebCore/platform/graphics/transforms/AffineTransform.h
index 30d712d..00631c2 100644
--- a/WebCore/platform/graphics/transforms/AffineTransform.h
+++ b/WebCore/platform/graphics/transforms/AffineTransform.h
@@ -100,6 +100,7 @@ public:
     AffineTransform& rotate(double d);
     AffineTransform& rotateFromVector(double x, double y);
     AffineTransform& translate(double tx, double ty);
+    AffineTransform& translateRight(double tx, double ty);
     AffineTransform& shear(double sx, double sy);
     AffineTransform& flipX();
     AffineTransform& flipY();
diff --git a/WebCore/rendering/RenderForeignObject.cpp b/WebCore/rendering/RenderForeignObject.cpp
index d7532b1..5bb4439 100644
--- a/WebCore/rendering/RenderForeignObject.cpp
+++ b/WebCore/rendering/RenderForeignObject.cpp
@@ -38,10 +38,10 @@ RenderForeignObject::RenderForeignObject(SVGForeignObjectElement* node)
 {
 }
 
-AffineTransform RenderForeignObject::translationForAttributes() const
+FloatPoint RenderForeignObject::translationForAttributes() const
 {
     SVGForeignObjectElement* foreign = static_cast<SVGForeignObjectElement*>(node());
-    return AffineTransform().translate(foreign->x().value(foreign), foreign->y().value(foreign));
+    return FloatPoint(foreign->x().value(foreign), foreign->y().value(foreign));
 }
 
 void RenderForeignObject::paint(PaintInfo& paintInfo, int, int)
@@ -90,7 +90,8 @@ void RenderForeignObject::computeRectForRepaint(RenderBoxModelObject* repaintCon
 
 const AffineTransform& RenderForeignObject::localToParentTransform() const
 {
-    m_localToParentTransform = localTransform() * translationForAttributes();
+    FloatPoint attributeTranslation(translationForAttributes());
+    m_localToParentTransform = localTransform().translateRight(attributeTranslation.x(), attributeTranslation.y());
     return m_localToParentTransform;
 }
 
diff --git a/WebCore/rendering/RenderForeignObject.h b/WebCore/rendering/RenderForeignObject.h
index 17057b5..f32069c 100644
--- a/WebCore/rendering/RenderForeignObject.h
+++ b/WebCore/rendering/RenderForeignObject.h
@@ -24,6 +24,7 @@
 #if ENABLE(SVG) && ENABLE(SVG_FOREIGN_OBJECT)
 
 #include "AffineTransform.h"
+#include "FloatPoint.h"
 #include "RenderSVGBlock.h"
 
 namespace WebCore {
@@ -55,7 +56,7 @@ public:
     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const;
 
  private:
-    AffineTransform translationForAttributes() const;
+    FloatPoint translationForAttributes() const;
 
     virtual AffineTransform localTransform() const { return m_localTransform; }
 
diff --git a/WebCore/rendering/RenderSVGRoot.cpp b/WebCore/rendering/RenderSVGRoot.cpp
index 78499b1..74172fc 100644
--- a/WebCore/rendering/RenderSVGRoot.cpp
+++ b/WebCore/rendering/RenderSVGRoot.cpp
@@ -192,11 +192,10 @@ void RenderSVGRoot::calcViewport()
 // relative to our borderBox origin.  This method gives us exactly that.
 AffineTransform RenderSVGRoot::localToBorderBoxTransform() const
 {
-    AffineTransform ctm;
     IntSize borderAndPadding = borderOriginToContentBox();
-    ctm.translate(borderAndPadding.width(), borderAndPadding.height());
     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
-    ctm.scale(svg->currentScale());
+    float scale = svg->currentScale();
+    AffineTransform ctm(scale, 0, 0, scale, borderAndPadding.width(), borderAndPadding.height());
     ctm.translate(svg->currentTranslate().x(), svg->currentTranslate().y());
     return svg->viewBoxToViewTransform(width(), height()) * ctm;
 }
@@ -213,19 +212,18 @@ IntSize RenderSVGRoot::borderOriginToContentBox() const
 
 AffineTransform RenderSVGRoot::localToRepaintContainerTransform(const IntPoint& parentOriginInContainer) const
 {
-    AffineTransform parentToContainer;
-    parentToContainer.translate(parentOriginInContainer.x(), parentOriginInContainer.y());
-    return localToParentTransform() * parentToContainer;
+    AffineTransform parentToContainer(localToParentTransform());
+    return parentToContainer.translateRight(parentOriginInContainer.x(), parentOriginInContainer.y());
 }
 
 const AffineTransform& RenderSVGRoot::localToParentTransform() const
 {
     IntSize parentToBorderBoxOffset = parentOriginToBorderBox();
 
-    AffineTransform borderBoxOriginToParentOrigin;
-    borderBoxOriginToParentOrigin.translate(parentToBorderBoxOffset.width(), parentToBorderBoxOffset.height());
+    AffineTransform borderBoxOriginToParentOrigin(localToBorderBoxTransform());
+    borderBoxOriginToParentOrigin.translateRight(parentToBorderBoxOffset.width(), parentToBorderBoxOffset.height());
 
-    m_localToParentTransform = localToBorderBoxTransform() * borderBoxOriginToParentOrigin;
+    m_localToParentTransform = borderBoxOriginToParentOrigin;
     return m_localToParentTransform;
 }
 
diff --git a/WebCore/rendering/RenderSVGViewportContainer.cpp b/WebCore/rendering/RenderSVGViewportContainer.cpp
index 441faa5..103d9d2 100644
--- a/WebCore/rendering/RenderSVGViewportContainer.cpp
+++ b/WebCore/rendering/RenderSVGViewportContainer.cpp
@@ -107,9 +107,8 @@ AffineTransform RenderSVGViewportContainer::viewportTransform() const
 
 const AffineTransform& RenderSVGViewportContainer::localToParentTransform() const
 {
-    AffineTransform viewportTranslation;
-    viewportTranslation.translate(m_viewport.x(), m_viewport.y());
-    m_localToParentTransform = viewportTransform() * viewportTranslation;
+    AffineTransform viewportTranslation(viewportTransform());
+    m_localToParentTransform = viewportTranslation.translateRight(m_viewport.x(), m_viewport.y());
     return m_localToParentTransform;
     // If this class were ever given a localTransform(), then the above would read:
     // return viewportTransform() * localTransform() * viewportTranslation;
diff --git a/WebCore/rendering/SVGRootInlineBox.cpp b/WebCore/rendering/SVGRootInlineBox.cpp
index 3f21e64..d0dd4a8 100644
--- a/WebCore/rendering/SVGRootInlineBox.cpp
+++ b/WebCore/rendering/SVGRootInlineBox.cpp
@@ -933,9 +933,8 @@ static void applyTextLengthCorrectionToTextChunk(SVGTextChunk& chunk)
         SVGChar& firstChar = *(chunk.start);
 
         // Assure we apply the chunk scaling in the right origin
-        AffineTransform newChunkCtm;
-        newChunkCtm.translate(firstChar.x, firstChar.y);
-        newChunkCtm = chunk.ctm * newChunkCtm;
+        AffineTransform newChunkCtm(chunk.ctm);
+        newChunkCtm.translateRight(firstChar.x, firstChar.y);
         newChunkCtm.translate(-firstChar.x, -firstChar.y);
 
         chunk.ctm = newChunkCtm;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list