Changeset 96338 in webkit
- Timestamp:
- Sep 29, 2011 10:16:35 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96337 r96338 1 2011-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 1 18 2011-09-29 Iain Merrick <husky@google.com> 2 19 -
trunk/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
r95901 r96338 69 69 } 70 70 71 static bool encodePixels(const IntSize& inputSize, unsigned char* inputPixels, 72 bool premultiplied, Vector<unsigned char>* output) 71 static bool encodePixels(IntSize imageSize, unsigned char* inputPixels, bool premultiplied, Vector<unsigned char>* output) 73 72 { 74 IntSize imageSize(inputSize);75 73 imageSize.clampNegativeToZero(); 76 74 Vector<unsigned char> row; … … 102 100 unsigned char* pixels = inputPixels; 103 101 row.resize(imageSize.width() * sizeof(SkPMColor)); 102 const size_t pixelRowStride = imageSize.width() * 4; 104 103 for (int y = 0; y < imageSize.height(); ++y) { 105 104 if (premultiplied) { … … 108 107 } else 109 108 png_write_row(png, pixels); 110 pixels += imageSize.width() * 4;109 pixels += pixelRowStride; 111 110 } 112 111 … … 118 117 bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* output) 119 118 { 119 SkAutoLockPixels bitmapLock(bitmap); 120 120 121 if (bitmap.config() != SkBitmap::kARGB_8888_Config) 121 return false; // Only support ARGB 32 bppskia bitmaps.122 return false; // Only support 32 bit/pixel skia bitmaps. 122 123 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); 126 125 } 127 126 128 bool PNGImageEncoder::encode(const ImageData& bitmap, Vector<unsigned char>* output)127 bool PNGImageEncoder::encode(const ImageData& imageData, Vector<unsigned char>* output) 129 128 { 130 return encodePixels( bitmap.size(), bitmap.data()->data()->data(), false, output);129 return encodePixels(imageData.size(), imageData.data()->data()->data(), false, output); 131 130 } 132 131
Note: See TracChangeset
for help on using the changeset viewer.