Changeset 102782 in webkit


Ignore:
Timestamp:
Dec 14, 2011 8:37:19 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-14
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-14
Reviewed by Stephen White.

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102777 r102782  
     12011-12-14  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-14  Csaba Osztrogonác  <ossy@webkit.org>
    213
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r102767 r102782  
    27612761//
    27622762
     2763// This test expects that putImageData followed by getImageData at the same location
     2764// will return the exact same pixel values. However, the spec allows some fuzziness
     2765// due to conversion to/from premultiplied-alpha. When we do the conversions on the
     2766// GPU we may be off by one in r, g, and/or b.
     2767BUGWK73952 GPU : canvas/philip/tests/2d.imageData.put.unchanged.html = TEXT
     2768
    27632769// Will need windows and linux baselines
    27642770
  • trunk/Source/WebCore/ChangeLog

    r102780 r102782  
     12011-12-14  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-14  Mary Wu  <mary.wu@torchmobile.com.cn>
    216
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

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