Commit 3271ebe2 authored by zimmermann@webkit.org's avatar zimmermann@webkit.org
Browse files

2011-02-15 Nikolas Zimmermann <nzimmermann@rim.com>

        Reviewed by Dirk Schulze.

        Pixel tests differences on 10.6.6 32bit vs. 64bit
        https://bugs.webkit.org/show_bug.cgi?id=54474

        When generating a SVG pixel test baseline with a vanilla 10.6.6 installation on a 32bit machine (Core Duo MBP)
        and comparing the run with a software-identical 64bit machine (Core 2 Duo MBP), there are about 250 differences.

        These fall in two categories:
        a) 1px differences in text AA, or when drawing circles (all _below_ a tolerance of 0.01). Only visible in the subtracted difference image.
           The reason is probably CGFloat being typedefed to double on 64bit machines, and float on 32bit machines.
           AffineTransform stores doubles, so on 32bit machines we loose precision from AffineTransform -> CGAffineTransform.

        b) Failures >0.1% (text origin/scale is slightly different, user-visible).
           Caused by several sources of numerical instabilities within the SVG rendering code.

           -> SVGPreserveAspectRatio::getCTM() computes an AffineTransform using doubles as input parameters, but floats are passed (like everywhere else in SVG).
              This method is used to compute the viewBox AffineTransform, that affects the rendering of every content in the document. RenderSVGRoot concats
              this transformation matrix to the GraphicsContext CTM, resulting in a source of numerical imprecision.

           -> SVGInlineTextBox::paintTextWithShadows() calculates a scaling factor for text, to scale up the specified font size, to the actual on-screen size.
              SVGInlineTextBox uses the scaled Font object, to draw in an unscaled context, that gets scaled up again afterwards.
              context->scale(1 / scalingFactor); scaledFont.drawText(); context->scale(scalingFactor);

              To remove the scale from the current GraphicsContext CTM, "context->scale(FloatSize(1 / scalingFactor, ...)" is used. As AffineTransform stores
              doubles internally, it's likely that "context->scale(FloatSize(1 / ctm.a(), .." doesn't give you a matrix with a=1, but something close to 1.
              Using "context->concatCTM(AffineTransform().scale(1 / ctm.a(), ..." could be used as workaround, to preserve double precision.
              Fixing that brings us down to just a few pixel tests that differ between 32 & 64bit. There is still numerical imprecision, as floating-point
              number representations aren't always precise. Unfortunately CoreGraphics doesn't provide a public way to just set a CTM, it only allows to concat them.
              Fortunately CGContextSetCTM() is available, as private method, that allows me to switch the context CTM to any arbitary CGAffineTransform.

              -> Add GraphicsContext::setCTM(const AffineTransform&) and implement it for all platforms (each explicitely exposes a 'setCTM' concept, except CG)
                 Use CGContextSetCTM() for CG, which appears to be present since at least 10.4, Cairo is using it for the same purpose since some years!

              -> Instead of scaling the GraphicsContext before drawing text, grab the current CTM using context->getCTM(), scale it by '1 / scalingFactor'
                 normalize the transform (look for values close to 0/1 using float precision, and round!), and assign it using context->setCTM(normalizedTransform).
                 After drawing, just switch back to the preserved original CTM, both operations need GraphicsContext::setCTM.
                 This fixes all pixel test differences between 32/64 bit machines that fall into category b).
                 The use of GraphicsContext::setCTM() allows to switch between arbitary context transformations _without_ inducing accumulated rounding imprecision.

        These combined patches fix the pixel test baseline changes.

        Updated existing Snow Leopard pixel test baseline with a 32bit machine, passes here with tolerance 0.
        The 64bit machine passes the baseline with tolerance 0.01.

        * platform/graphics/GraphicsContext.h: Add setCTM(const AffineTransform&) method.
        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContext::setCTM): Implement setCTM.
        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
        (WebCore::GraphicsContextPlatformPrivate::setCTM): Ditto.
        * platform/graphics/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
        (WebCore::GraphicsContextPlatformPrivate::setCTM): Ditto.
        * platform/graphics/chromium/GLES2Canvas.cpp:
        (WebCore::GLES2Canvas::setCTM): Ditto.
        * platform/graphics/chromium/GLES2Canvas.h:
        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * platform/graphics/openvg/GraphicsContextOpenVG.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * platform/graphics/qt/GraphicsContextQt.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * platform/graphics/skia/GraphicsContextSkia.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * platform/graphics/win/GraphicsContextWin.cpp:
        (WebCore::GraphicsContextPlatformPrivate::setCTM): Ditto.
        * platform/graphics/wince/GraphicsContextWinCE.cpp:
        (WebCore::GraphicsContextPlatformPrivate::concatCTM):
        (WebCore::GraphicsContextPlatformPrivate::setCTM): Ditto.
        (WebCore::GraphicsContext::setCTM):
        * platform/graphics/wx/GraphicsContextWx.cpp:
        (WebCore::GraphicsContext::setCTM): Ditto.
        * rendering/svg/SVGInlineTextBox.cpp: Use setCTM() to switch to a scale-free AffineTransform, and also to switch back to the original CTM after rendering text.
        (WebCore::normalizeTransform):
        (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
        (WebCore::SVGInlineTextBox::paintTextWithShadows):
        * svg/SVGPreserveAspectRatio.cpp: s/double/float/.
        (WebCore::SVGPreserveAspectRatio::getCTM):
        * svg/SVGPreserveAspectRatio.h:
        * svg/SVGSVGElement.cpp: Simplify viewport() code, avoid using doubles.
        (WebCore::SVGSVGElement::viewport):

2011-02-16  Nikolas Zimmermann  <nzimmermann@rim.com>

        Reviewed by Dirk Schulze.

        Pixel tests differences on 10.6.6 32bit vs. 64bit
        https://bugs.webkit.org/show_bug.cgi?id=54474

        Update SnowLeopard SVG pixel test baseline, generated on a 32bit machine, where it passes with tolerance 0.
        This is the first chunk of several commits, as one commit is too huge for SVN.

        It should pass on modern 64bit machines as well, using tolerance 0.01.

        * platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-08-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-08-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-26-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-26-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-30-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-30-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-33-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-33-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-34-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-34-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-36-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-36-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-40-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-40-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-44-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-44-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-82-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-82-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-84-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-84-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-color-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/filters-color-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/filters-comptran-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/filters-example-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-offset-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/filters-offset-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/interact-order-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/interact-order-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/interact-order-02-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/interact-order-02-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/linking-a-05-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/linking-a-05-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/painting-marker-03-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-04-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-04-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-05-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-05-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-06-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-06-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-07-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-07-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-08-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-08-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-15-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-15-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-07-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-07-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-08-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-11-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-11-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/render-groups-03-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/render-groups-03-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/shapes-circle-01-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/shapes-circle-01-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/shapes-ellipse-01-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/shapes-ellipse-01-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/struct-frag-02-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/struct-frag-02-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/struct-frag-02-t-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/struct-frag-03-t-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/struct-image-02-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/struct-image-02-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/text-path-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/text-path-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/text-text-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/text-text-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/types-basicDOM-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/types-basicDOM-01-b-expected.png:
        * platform/mac/svg/batik/masking/maskRegions-expected.txt:
        * platform/mac/svg/custom/circular-marker-reference-1-expected.txt:
        * platform/mac/svg/custom/circular-marker-reference-2-expected.txt:
        * platform/mac/svg/custom/circular-marker-reference-3-expected.txt:
        * platform/mac/svg/custom/circular-marker-reference-4-expected.txt:
        * platform/mac/svg/custom/non-circular-marker-reference-expected.txt:
        * platform/mac/svg/custom/non-scaling-stroke-markers-expected.txt:
        * platform/mac/svg/custom/stroked-pattern-expected.txt:
        * platform/mac/svg/custom/text-rotated-gradient-expected.txt:
        * platform/mac/svg/custom/use-detach-expected.txt:
        * platform/mac/svg/hixie/links/001-expected.txt:
        * platform/mac/svg/hixie/viewbox/preserveAspectRatio/001-expected.txt:
        * platform/mac/svg/text/small-fonts-2-expected.txt:
        * platform/mac/svg/zoom/page/zoom-mask-with-percentages-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2b3335c3
9b8322f16fbac58cd96cfbaa86ba3448
\ No newline at end of file
50ba6364f5eb7f13a4ae79e1bf5418f6
\ No newline at end of file
a9ad1b7c6c59408a4425526f0fc294cf
\ No newline at end of file
493403d498431375781ba9f67a9db1dc
\ No newline at end of file
f5a39f3b65691ec451c9f8f4ab71e68c
\ No newline at end of file
4ba41669ffd74f93642a5433203d35e3
\ No newline at end of file
8a0e6ebaf7df926c4ced5bd4746722e5
\ No newline at end of file
bb27c75e661494ff7dc72547da4976a4
\ No newline at end of file
......@@ -6,7 +6,7 @@ layer at (0,0) size 480x360
RenderSVGResourceMarker {marker} [id="marker1"] [markerUnits=strokeWidth] [ref at (50,50)] [angle=0.00]
RenderSVGPath {rect} at (0,0) size 5x5 [fill={[type=SOLID] [color=#4169E1]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
RenderSVGResourceMarker {marker} [id="marker2"] [markerUnits=strokeWidth] [ref at (100,100)] [angle=0.00]
RenderSVGPath {rect} at (0,0) size 15x15 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=200.00] [height=200.00]
RenderSVGPath {rect} at (0,0) size 16x16 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=200.00] [height=200.00]
RenderSVGText {text} at (153,10) size 174x23 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 174x23
chunk 1 (middle anchor) text run 1 at (153.00,28.00) startOffset 0 endOffset 22 width 174.00: "'marker' property test"
......
f230a78d6d42b7941627181872914bc6
\ No newline at end of file
f1999ea9afbf58710963da2a93720191
\ No newline at end of file
e9177365dcbb0228d2eb1775f584e5c7
\ No newline at end of file
f20c37c7faa109bd40699246da0be99f
\ No newline at end of file
f403062ff2a2eb0f8b4069210cbf4555
\ No newline at end of file
55a7a8a6cffe6efa2b951acc3d4c28de
\ No newline at end of file
91f1b3d81ce954bf78c65dfe4ec18c96
\ No newline at end of file
66419365aea07c87c30b7f8942380277
\ No newline at end of file
c0bb8f75bf6bfa6607a2c8d5ae92f1ba
\ No newline at end of file
413b6e0124b5e185f65195059a5b9cce
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment