| Index: Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| diff --git a/Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| index 7974b79a7ee2dd3a4fbb4c7579bab8dad2315872..cc2b43bda198021fc04cc63296919b11c8df7e47 100644
|
| --- a/Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| +++ b/Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
|
| @@ -637,31 +637,7 @@ bool JPEGImageDecoder::setFailed()
|
| return ImageDecoder::setFailed();
|
| }
|
|
|
| -template <J_COLOR_SPACE colorSpace> void setPixel(ImageFrame& buffer, ImageFrame::PixelData* pixel, JSAMPARRAY samples, int column)
|
| -{
|
| - JSAMPLE* jsample = *samples + column * (colorSpace == JCS_RGB ? 3 : 4);
|
| -
|
| - switch (colorSpace) {
|
| - case JCS_RGB:
|
| - buffer.setRGBA(pixel, jsample[0], jsample[1], jsample[2], 0xFF);
|
| - break;
|
| - case JCS_CMYK:
|
| - // Source is 'Inverted CMYK', output is RGB.
|
| - // See: http://www.easyrgb.com/math.php?MATH=M12#text12
|
| - // Or: http://www.ilkeratalay.com/colorspacesfaq.php#rgb
|
| - // From CMYK to CMY:
|
| - // X = X * (1 - K ) + K [for X = C, M, or Y]
|
| - // Thus, from Inverted CMYK to CMY is:
|
| - // X = (1-iX) * (1 - (1-iK)) + (1-iK) => 1 - iX*iK
|
| - // From CMY (0..1) to RGB (0..1):
|
| - // R = 1 - C => 1 - (1 - iC*iK) => iC*iK [G and B similar]
|
| - unsigned k = jsample[3];
|
| - buffer.setRGBA(pixel, jsample[0] * k / 255, jsample[1] * k / 255, jsample[2] * k / 255, 0xFF);
|
| - break;
|
| - }
|
| -}
|
| -
|
| -template <J_COLOR_SPACE colorSpace> bool outputRows(JPEGImageReader* reader, ImageFrame& buffer)
|
| +static bool outputRows(JPEGImageReader* reader, ImageFrame& buffer, J_COLOR_SPACE colorSpace)
|
| {
|
| JSAMPARRAY samples = reader->samples();
|
| jpeg_decompress_struct* info = reader->info();
|
| @@ -678,9 +654,13 @@ template <J_COLOR_SPACE colorSpace> bool outputRows(JPEGImageReader* reader, Ima
|
| if (reader->colorTransform() && colorSpace == JCS_RGB)
|
| qcms_transform_data(reader->colorTransform(), *samples, *samples, width);
|
| #endif
|
| - ImageFrame::PixelData* pixel = buffer.getAddr(0, y);
|
| - for (int x = 0; x < width; ++pixel, ++x)
|
| - setPixel<colorSpace>(buffer, pixel, samples, x);
|
| + unsigned const char* row = *samples;
|
| + if (colorSpace == JCS_RGB)
|
| + buffer.fillRowFromRGBSource(y, row);
|
| + else if (colorSpace == JCS_CMYK)
|
| + buffer.fillRowFromInvertedCMYK(y, row);
|
| + else
|
| + ASSERT_NOT_REACHED();
|
| }
|
|
|
| return true;
|
| @@ -722,16 +702,7 @@ bool JPEGImageDecoder::outputScanlines()
|
| }
|
| #endif
|
|
|
| - switch (info->out_color_space) {
|
| - case JCS_RGB:
|
| - return outputRows<JCS_RGB>(m_reader.get(), buffer);
|
| - case JCS_CMYK:
|
| - return outputRows<JCS_CMYK>(m_reader.get(), buffer);
|
| - default:
|
| - ASSERT_NOT_REACHED();
|
| - }
|
| -
|
| - return setFailed();
|
| + return outputRows(m_reader.get(), buffer, info->out_color_space);
|
| }
|
|
|
| void JPEGImageDecoder::jpegComplete()
|
|
|