• zimmermann@webkit.org's avatar
    2011-02-15 Nikolas Zimmermann <nzimmermann@rim.com> · 3271ebe2
    zimmermann@webkit.org authored
            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
    3271ebe2
animate-elem-08-t-expected.checksum 32 Bytes