Changeset 96338 in webkit


Ignore:
Timestamp:
Sep 29, 2011 10:16:35 AM (13 years ago)
Author:
noel.gordon@gmail.com
Message:

[chromium skia] PNGImageEncoder: hoist constants out of the encoding loop
https://bugs.webkit.org/show_bug.cgi?id=68988

Reviewed by Kenneth Russell.

No new tests. Covered by existing canvas 2d and 3d tests.
canvas/philip/tests/toDataURL.png.*.html
fast/canvas/toDataURL-alpha.html
fast/canvas/webgl/premultiplyalpha-test.html

  • platform/image-encoders/skia/PNGImageEncoder.cpp:

(WebCore::encodePixels): Move constant out of the encoding loop.
(WebCore::PNGImageEncoder::encode): Consistency & style: call encodePixels()
just like we do in the JPEG encoder.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96337 r96338  
     12011-09-29  Noel Gordon  <noel.gordon@gmail.com>
     2
     3        [chromium skia] PNGImageEncoder: hoist constants out of the encoding loop
     4        https://bugs.webkit.org/show_bug.cgi?id=68988
     5
     6        Reviewed by Kenneth Russell.
     7
     8        No new tests.  Covered by existing canvas 2d and 3d tests.
     9        canvas/philip/tests/toDataURL.png.*.html
     10        fast/canvas/toDataURL-alpha.html
     11        fast/canvas/webgl/premultiplyalpha-test.html
     12
     13        * platform/image-encoders/skia/PNGImageEncoder.cpp:
     14        (WebCore::encodePixels):  Move constant out of the encoding loop.
     15        (WebCore::PNGImageEncoder::encode):  Consistency & style: call encodePixels()
     16        just like we do in the JPEG encoder.
     17
    1182011-09-29  Iain Merrick  <husky@google.com>
    219
  • trunk/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp

    r95901 r96338  
    6969}
    7070
    71 static bool encodePixels(const IntSize& inputSize, unsigned char* inputPixels,
    72                          bool premultiplied, Vector<unsigned char>* output)
     71static bool encodePixels(IntSize imageSize, unsigned char* inputPixels, bool premultiplied, Vector<unsigned char>* output)
    7372{
    74     IntSize imageSize(inputSize);
    7573    imageSize.clampNegativeToZero();
    7674    Vector<unsigned char> row;
     
    102100    unsigned char* pixels = inputPixels;
    103101    row.resize(imageSize.width() * sizeof(SkPMColor));
     102    const size_t pixelRowStride = imageSize.width() * 4;
    104103    for (int y = 0; y < imageSize.height(); ++y) {
    105104        if (premultiplied) {
     
    108107        } else
    109108            png_write_row(png, pixels);
    110         pixels += imageSize.width() * 4;
     109        pixels += pixelRowStride;
    111110    }
    112111
     
    118117bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* output)
    119118{
     119    SkAutoLockPixels bitmapLock(bitmap);
     120
    120121    if (bitmap.config() != SkBitmap::kARGB_8888_Config)
    121         return false; // Only support ARGB 32 bpp skia bitmaps.
     122        return false; // Only support 32 bit/pixel skia bitmaps.
    122123
    123     SkAutoLockPixels bitmapLock(bitmap);
    124     IntSize imageSize(bitmap.width(), bitmap.height());
    125     return encodePixels(imageSize, static_cast<unsigned char*>(bitmap.getPixels()), true, output);
     124    return encodePixels(IntSize(bitmap.width(), bitmap.height()), static_cast<unsigned char*>(bitmap.getPixels()), true, output);
    126125}
    127126
    128 bool PNGImageEncoder::encode(const ImageData& bitmap, Vector<unsigned char>* output)
     127bool PNGImageEncoder::encode(const ImageData& imageData, Vector<unsigned char>* output)
    129128{
    130     return encodePixels(bitmap.size(), bitmap.data()->data()->data(), false, output);
     129    return encodePixels(imageData.size(), imageData.data()->data()->data(), false, output);
    131130}
    132131
Note: See TracChangeset for help on using the changeset viewer.