Changeset 50408 in webkit


Ignore:
Timestamp:
Nov 2, 2009 7:27:16 AM (14 years ago)
Author:
senorblanco@chromium.org
Message:

This is the WebKit-side change needed to fix canvas.getImageData() for
Chromium. The unpremultiply code in Skia assumes that unpremultiplied
values should be rounded, while CG does not. In addition, the fixed
point inversion used by Skia introduces slight inaccuracies that make
us fail this test. This change brings Chromium in line with
the CG path.
https://bugs.webkit.org/show_bug.cgi?id=30825

Reviewed by Dmitry Titov.

Covered by LayoutTests/fast/canvas/canvas-getImageData.html

  • platform/graphics/skia/ImageBufferSkia.cpp:

(WebCore::getImageData):

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50407 r50408  
     12009-10-27  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by Dmitry Titov.
     4
     5        This is the WebKit-side change needed to fix canvas.getImageData() for
     6        Chromium.  The unpremultiply code in Skia assumes that unpremultiplied
     7        values should be rounded, while CG does not.  In addition, the fixed
     8        point inversion used by Skia introduces slight inaccuracies that make
     9        us fail this test.  This change brings Chromium in line with
     10        the CG path.
     11        https://bugs.webkit.org/show_bug.cgi?id=30825
     12
     13        Covered by LayoutTests/fast/canvas/canvas-getImageData.html
     14
     15        * platform/graphics/skia/ImageBufferSkia.cpp:
     16        (WebCore::getImageData):
     17
    1182009-11-01  Kelly Norton  <knorton@google.com>
    219
  • trunk/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r47996 r50408  
    165165            unsigned char* destPixel = &destRow[x * 4];
    166166            if (multiplied == Unmultiplied) {
    167                 SkColor color = SkPMColorToColor(srcRow[x]);
    168                 destPixel[0] = SkColorGetR(color);
    169                 destPixel[1] = SkColorGetG(color);
    170                 destPixel[2] = SkColorGetB(color);
    171                 destPixel[3] = SkColorGetA(color);
     167                SkColor color = srcRow[x];
     168                unsigned a = SkColorGetA(color);
     169                destPixel[0] = a ? SkColorGetR(color) * 255 / a : 0;
     170                destPixel[1] = a ? SkColorGetG(color) * 255 / a : 0;
     171                destPixel[2] = a ? SkColorGetB(color) * 255 / a : 0;
     172                destPixel[3] = a;
    172173            } else {
    173174                // Input and output are both pre-multiplied, we just need to re-arrange the
Note: See TracChangeset for help on using the changeset viewer.