Title: [121343] trunk/Source/WebCore
Revision
121343
Author
r...@google.com
Date
2012-06-27 08:06:24 -0700 (Wed, 27 Jun 2012)

Log Message

Cleanup scaling code in text-decorations for SVG InlineText. Use scale() instead of getCTM/normalizeTransform/setCTM
to use more standard pattern for scaling, and to allow for these operations to be recorded and played back later
(potentially with a different starting matrix). This effectively reverts change# 78704.
https://bugs.webkit.org/show_bug.cgi?id=89888

Reviewed by Nikolas Zimmermann.

No new tests. Current layouttests exercise this code path.

* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintDecorationWithStyle):
(WebCore::SVGInlineTextBox::paintTextWithShadows):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121342 => 121343)


--- trunk/Source/WebCore/ChangeLog	2012-06-27 14:55:13 UTC (rev 121342)
+++ trunk/Source/WebCore/ChangeLog	2012-06-27 15:06:24 UTC (rev 121343)
@@ -1,3 +1,18 @@
+2012-06-27  Mike Reed  <r...@google.com>
+
+        Cleanup scaling code in text-decorations for SVG InlineText. Use scale() instead of getCTM/normalizeTransform/setCTM
+        to use more standard pattern for scaling, and to allow for these operations to be recorded and played back later
+        (potentially with a different starting matrix). This effectively reverts change# 78704.
+        https://bugs.webkit.org/show_bug.cgi?id=89888
+
+        Reviewed by Nikolas Zimmermann.
+
+        No new tests. Current layouttests exercise this code path.
+
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
+        (WebCore::SVGInlineTextBox::paintTextWithShadows):
+
 2012-06-27  Oswald Buddenhagen  <oswald.buddenha...@nokia.com>
 
         [Qt] Remove redundant NDEBUG definition

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (121342 => 121343)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2012-06-27 14:55:13 UTC (rev 121342)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2012-06-27 15:06:24 UTC (rev 121343)
@@ -547,29 +547,6 @@
     }
 }
 
-static inline void normalizeTransform(AffineTransform& transform)
-{
-    // Obtain consistent numerical results for the AffineTransform on both 32/64bit platforms.
-    // Tested with SnowLeopard on Core Duo vs. Core 2 Duo.
-    static const float s_floatEpsilon = std::numeric_limits<float>::epsilon();
-
-    if (fabs(transform.a() - 1) <= s_floatEpsilon)
-        transform.setA(1);
-    else if (fabs(transform.a() + 1) <= s_floatEpsilon)
-        transform.setA(-1);
-
-    if (fabs(transform.d() - 1) <= s_floatEpsilon)
-        transform.setD(1);
-    else if (fabs(transform.d() + 1) <= s_floatEpsilon)
-        transform.setD(-1);
-
-    if (fabs(transform.e()) <= s_floatEpsilon)
-        transform.setE(0);
-
-    if (fabs(transform.f()) <= s_floatEpsilon)
-        transform.setF(0);
-}
-
 void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, ETextDecoration decoration, const SVGTextFragment& fragment, RenderObject* decorationRenderer)
 {
     ASSERT(!m_paintingResource);
@@ -597,12 +574,7 @@
     if (scalingFactor != 1) {
         width *= scalingFactor;
         decorationOrigin.scale(scalingFactor, scalingFactor);
-
-        AffineTransform newTransform = context->getCTM();
-        newTransform.scale(1 / scalingFactor);
-        normalizeTransform(newTransform);
-
-        context->setCTM(newTransform);
+        context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
     }
 
     decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetForDecoration(decoration, scaledFontMetrics, thickness));
@@ -643,21 +615,12 @@
         if (shadow)
             extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */);
 
-        AffineTransform originalTransform;
-        if (scalingFactor != 1) {
-            originalTransform = context->getCTM();
+        context->save();
+        context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
 
-            AffineTransform newTransform = originalTransform;
-            newTransform.scale(1 / scalingFactor);
-            normalizeTransform(newTransform);
-
-            context->setCTM(newTransform);
-        }
-
         scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition);
 
-        if (scalingFactor != 1)
-            context->setCTM(originalTransform);
+        context->restore();
 
         restoreGraphicsContextAfterTextPainting(context, textRun);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to