Changeset 102244 in webkit


Ignore:
Timestamp:
Dec 7, 2011 10:08:25 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: [CHROMIUM/SKIA] Handle put[Un/Pre]multipliedImageData conversions in Skia rather than ImageBuffer
https://bugs.webkit.org/show_bug.cgi?id=73953

Patch by Brian Salomon <bsalomon@google.com> on 2011-12-07
Reviewed by Stephen White.

Tested by existing canvas2d layout tests.

  • platform/graphics/skia/ImageBufferSkia.cpp:

(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):

LayoutTests: [CHROMIUM] Make canvas/philip/tests/2d.imageData.put.unchanged.html be expected to fail
on the GPU due to slight difference in alpha-premul computation.

https://bugs.webkit.org/show_bug.cgi?id=73953

Patch by Brian Salomon <bsalomon@google.com> on 2011-12-07
Reviewed by Stephen White.

  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102236 r102244  
     12011-12-07  Brian Salomon  <bsalomon@google.com>
     2
     3        [CHROMIUM] Make canvas/philip/tests/2d.imageData.put.unchanged.html be expected to fail
     4        on the GPU due to slight difference in alpha-premul computation.
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=73953
     7
     8        Reviewed by Stephen White.
     9
     10        * platform/chromium/test_expectations.txt:
     11
    1122011-12-07  Balazs Kelemen  <kbalazs@webkit.org>
    213
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r102229 r102244  
    26542654//
    26552655
     2656// This test expects that putImageData followed by getImageData at the same location
     2657// will return the exact same pixel values. However, the spec allows some fuzziness
     2658// due to conversion to/from premultiplied-alpha. When we do the conversions on the
     2659// GPU we may be off by one in r, g, and/or b.
     2660BUGWK73952 GPU : canvas/philip/tests/2d.imageData.put.unchanged.html = TEXT
     2661
    26562662// Will need windows and linux baselines
    26572663
  • trunk/Source/WebCore/ChangeLog

    r102243 r102244  
     12011-12-07  Brian Salomon  <bsalomon@google.com>
     2
     3        [CHROMIUM/SKIA] Handle put[Un/Pre]multipliedImageData conversions in Skia rather than ImageBuffer
     4        https://bugs.webkit.org/show_bug.cgi?id=73953
     5
     6        Reviewed by Stephen White.
     7
     8        Tested by existing canvas2d layout tests.
     9
     10        * platform/graphics/skia/ImageBufferSkia.cpp:
     11        (WebCore::putImageData):
     12        (WebCore::ImageBuffer::putUnmultipliedImageData):
     13        (WebCore::ImageBuffer::putPremultipliedImageData):
     14
    1152011-12-07  Andreas Kling  <kling@webkit.org>
    216
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r102088 r102244  
    293293template <Multiply multiplied>
    294294void putImageData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint,
    295                   SkDevice* dstDevice, const IntSize& size)
     295                  SkCanvas* canvas, const IntSize& size)
    296296{
    297297    ASSERT(sourceRect.width() > 0);
     
    322322
    323323    unsigned srcBytesPerRow = 4 * sourceSize.width();
    324 
    325     SkBitmap deviceBitmap = dstDevice->accessBitmap(true);
    326 
    327     // If the device's bitmap doesn't have pixels we will make a temp and call writePixels on the device.
    328     bool temporaryBitmap = !!deviceBitmap.getTexture();
    329     SkBitmap destBitmap;
    330 
    331     if (temporaryBitmap) {
    332         destBitmap.setConfig(SkBitmap::kARGB_8888_Config, numColumns, numRows, srcBytesPerRow);
    333         if (!destBitmap.allocPixels())
    334             CRASH();
    335     } else
    336         deviceBitmap.extractSubset(&destBitmap, SkIRect::MakeXYWH(destX, destY, numColumns, numRows));
    337 
    338     // Whether we made a temporary or not destBitmap is always configured to be written at 0,0
    339     SkAutoLockPixels destAutoLock(destBitmap);
    340     const unsigned char* srcRow = source->data() + originY * srcBytesPerRow + originX * 4;
    341     for (int y = 0; y < numRows; ++y) {
    342         SkPMColor* destRow = destBitmap.getAddr32(0, y);
    343         for (int x = 0; x < numColumns; ++x) {
    344             const unsigned char* srcPixel = &srcRow[x * 4];
    345             if (multiplied == Unmultiplied) {
    346                 unsigned char alpha = srcPixel[3];
    347                 unsigned char r = SkMulDiv255Ceiling(srcPixel[0], alpha);
    348                 unsigned char g = SkMulDiv255Ceiling(srcPixel[1], alpha);
    349                 unsigned char b = SkMulDiv255Ceiling(srcPixel[2], alpha);
    350                 destRow[x] = SkPackARGB32(alpha, r, g, b);
    351             } else
    352                 destRow[x] = SkPackARGB32NoCheck(srcPixel[3], srcPixel[0], srcPixel[1], srcPixel[2]);
    353         }
    354         srcRow += srcBytesPerRow;
    355     }
    356 
    357     // If we used a temporary then write it to the device
    358     if (temporaryBitmap)
    359         dstDevice->writePixels(destBitmap, destX, destY);
     324    SkBitmap srcBitmap;
     325    srcBitmap.setConfig(SkBitmap::kARGB_8888_Config, numColumns, numRows, srcBytesPerRow);
     326    srcBitmap.setPixels(source->data() + originY * srcBytesPerRow + originX * 4);
     327
     328    SkCanvas::Config8888 config8888;
     329    if (multiplied == Premultiplied)
     330        config8888 = SkCanvas::kRGBA_Premul_Config8888;
     331    else
     332        config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
     333
     334    canvas->writePixels(srcBitmap, destX, destY, config8888);
    360335}
    361336
    362337void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
    363338{
    364     putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas()->getDevice(), m_size);
     339    putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas(), m_size);
    365340}
    366341
    367342void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
    368343{
    369     putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas()->getDevice(), m_size);
     344    putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas(), m_size);
    370345}
    371346
Note: See TracChangeset for help on using the changeset viewer.