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
4c1ccbb2a4834c7f93d54c560c94d572
\ No newline at end of file
bddc47361d7fc52e555c4276a576bba4
\ No newline at end of file
4692e4d5afbb39d3c3a9aca87637d78e
\ No newline at end of file
935f0e9783cfba75e798b234970bdb8a
\ No newline at end of file
a0a7bf8259036c4e298cfc52a014a8b2
\ No newline at end of file
29d7770dd8d70a902b617477ecb53300
\ No newline at end of file
39fd26e32fcc087e420df11177d7252c
\ No newline at end of file
45737540f1a7621affc456d04634d6d8
\ No newline at end of file
5f8d224e61b54e4173251a764b4cbe30
\ No newline at end of file
8cf5bab4cebb61066d7038bf00a64e8f
\ No newline at end of file
5f037fb7b6af7046f09e038876c74ebc
\ No newline at end of file
8e4237bc24421dc6d6be2053a053bb9c
\ No newline at end of file
768913439f02a555922edf129acf9763
\ No newline at end of file
c9a9b035ff61968c3b113ad55ec81cda
\ No newline at end of file
81d57048340e7f8738ce0beb9cd0f5e6
\ No newline at end of file
b9070d213878c5ea8db8f8af5a51adeb
\ No newline at end of file
b80f72d19ea321dc449023d2782f9103
\ No newline at end of file
547abe3b3fc577e8610a8d9271e7915e
\ No newline at end of file
78769a0c46494976e3b4ddbd55490dea
\ No newline at end of file
342fa23abc3cac350287e1d999e700f8
\ 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