Chromium Code Reviews| Index: Source/platform/image-encoders/skia/PNGImageEncoder.cpp |
| diff --git a/Source/platform/image-encoders/skia/PNGImageEncoder.cpp b/Source/platform/image-encoders/skia/PNGImageEncoder.cpp |
| index 4b1d818a9edcc19845da32ba9994e3061b489c48..c7951d43de5a4d2b704f5e26a0cde6c4c8d0f7a2 100644 |
| --- a/Source/platform/image-encoders/skia/PNGImageEncoder.cpp |
| +++ b/Source/platform/image-encoders/skia/PNGImageEncoder.cpp |
| @@ -68,7 +68,7 @@ static void preMultipliedBGRAtoRGBA(const void* pixels, int pixelCount, unsigned |
| } |
| } |
| -static bool encodePixels(IntSize imageSize, unsigned char* inputPixels, bool premultiplied, Vector<unsigned char>* output) |
| +static bool encodePixels(IntSize imageSize, const unsigned char* inputPixels, bool premultiplied, Vector<unsigned char>* output) |
|
haraken
2015/01/06 12:08:44
Why do you add const and then do const_cast?
Noel Gordon
2015/01/06 13:54:56
To workaround libpng, which doesn't use const in i
|
| { |
| imageSize.clampNegativeToZero(); |
| Vector<unsigned char> row; |
| @@ -97,7 +97,7 @@ static bool encodePixels(IntSize imageSize, unsigned char* inputPixels, bool pre |
| 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0); |
| png_write_info(png, info); |
| - unsigned char* pixels = inputPixels; |
| + unsigned char* pixels = const_cast<unsigned char*>(inputPixels); |
| row.resize(imageSize.width() * sizeof(SkPMColor)); |
| const size_t pixelRowStride = imageSize.width() * 4; |
| for (int y = 0; y < imageSize.height(); ++y) { |
| @@ -126,7 +126,7 @@ bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* outp |
| bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, Vector<unsigned char>* output) |
| { |
| - return encodePixels(imageData.size(), imageData.data(), false, output); |
| + return encodePixels(IntSize(imageData.width(), imageData.height()), imageData.bytes(), false, output); |
| } |
| } // namespace blink |