diff options
Diffstat (limited to 'WebCore/platform/image-decoders')
14 files changed, 41 insertions, 35 deletions
diff --git a/WebCore/platform/image-decoders/ImageDecoder.cpp b/WebCore/platform/image-decoders/ImageDecoder.cpp index 49c2a61..cc23b2a 100644 --- a/WebCore/platform/image-decoders/ImageDecoder.cpp +++ b/WebCore/platform/image-decoders/ImageDecoder.cpp @@ -53,11 +53,15 @@ static unsigned copyFromSharedBuffer(char* buffer, unsigned bufferLength, const return bytesExtracted; } +<<<<<<< HEAD #if !OS(ANDROID) // This method requires BMPImageDecoder, PNGImageDecoder, ICOImageDecoder and // JPEGDecoder, which aren't used on Android, and which don't all compile. // TODO: Find a better fix. ImageDecoder* ImageDecoder::create(const SharedBuffer& data, bool premultiplyAlpha, bool ignoreGammaAndColorProfile) +======= +ImageDecoder* ImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) +>>>>>>> webkit.org at r74534 (trunk) { // We need at least 4 bytes to figure out what kind of image we're dealing // with. @@ -69,15 +73,15 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data, bool premultiplyAlp // GIFs begin with GIF8(7 or 9). if (strncmp(contents, "GIF8", 4) == 0) - return new GIFImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new GIFImageDecoder(alphaOption, gammaAndColorProfileOption); // Test for PNG. if (!memcmp(contents, "\x89\x50\x4E\x47", 4)) - return new PNGImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new PNGImageDecoder(alphaOption, gammaAndColorProfileOption); // JPEG if (!memcmp(contents, "\xFF\xD8\xFF", 3)) - return new JPEGImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption); #if USE(WEBP) if (!memcmp(contents, "RIFF", 4)) { @@ -87,19 +91,19 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data, bool premultiplyAlp unsigned length = copyFromSharedBuffer(header, webpExtraMarker, data, webpExtraMarkeroffset); if (length >= webpExtraMarker) { if (!memcmp(header, "WEBPVP", webpExtraMarker)) - return new WEBPImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption); } } #endif // BMP if (strncmp(contents, "BM", 2) == 0) - return new BMPImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new BMPImageDecoder(alphaOption, gammaAndColorProfileOption); // ICOs always begin with a 2-byte 0 followed by a 2-byte 1. // CURs begin with 2-byte 0 followed by 2-byte 2. if (!memcmp(contents, "\x00\x00\x01\x00", 4) || !memcmp(contents, "\x00\x00\x02\x00", 4)) - return new ICOImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile); + return new ICOImageDecoder(alphaOption, gammaAndColorProfileOption); // Give up. We don't know what the heck this is. return 0; diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h index ceb8f9b..c3d73c0 100644 --- a/WebCore/platform/image-decoders/ImageDecoder.h +++ b/WebCore/platform/image-decoders/ImageDecoder.h @@ -233,10 +233,10 @@ namespace WebCore { // m_maxNumPixels. (Not supported by all image decoders yet) class ImageDecoder : public Noncopyable { public: - ImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) + ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) : m_scaled(false) - , m_premultiplyAlpha(premultiplyAlpha) - , m_ignoreGammaAndColorProfile(ignoreGammaAndColorProfile) + , m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied) + , m_ignoreGammaAndColorProfile(gammaAndColorProfileOption == ImageSource::GammaAndColorProfileIgnored) , m_sizeAvailable(false) , m_maxNumPixels(-1) , m_isAllDataReceived(false) @@ -249,7 +249,7 @@ namespace WebCore { // Factory function to create an ImageDecoder. Ports that subclass // ImageDecoder can provide their own implementation of this to avoid // needing to write a dedicated setData() implementation. - static ImageDecoder* create(const SharedBuffer& data, bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + static ImageDecoder* create(const SharedBuffer& data, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); // The the filename extension usually associated with an undecoded image // of this type. diff --git a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp index 219a1e2..220a1ed 100644 --- a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp +++ b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp @@ -40,8 +40,9 @@ namespace WebCore { // don't pack). static const size_t sizeOfFileHeader = 14; -BMPImageDecoder::BMPImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +BMPImageDecoder::BMPImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) , m_decodedOffset(0) { } diff --git a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h index 695fab4..5f4ed82 100644 --- a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h +++ b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h @@ -39,7 +39,7 @@ namespace WebCore { // This class decodes the BMP image format. class BMPImageDecoder : public ImageDecoder { public: - BMPImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + BMPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); // ImageDecoder virtual String filenameExtension() const { return "bmp"; } diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp index dfdf35e..e92f264 100644 --- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp +++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp @@ -29,8 +29,9 @@ namespace WebCore { -GIFImageDecoder::GIFImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +GIFImageDecoder::GIFImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) , m_alreadyScannedThisDataForFrameCount(true) , m_repetitionCount(cAnimationLoopOnce) , m_readOffset(0) diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h index 5b4ca10..64240d4 100644 --- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h +++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h @@ -36,7 +36,7 @@ namespace WebCore { // This class decodes the GIF image format. class GIFImageDecoder : public ImageDecoder { public: - GIFImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + GIFImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); virtual ~GIFImageDecoder(); enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery }; diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp index b07cf92..92a7dcf 100644 --- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp +++ b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp @@ -44,8 +44,9 @@ namespace WebCore { static const size_t sizeOfDirectory = 6; static const size_t sizeOfDirEntry = 16; -ICOImageDecoder::ICOImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +ICOImageDecoder::ICOImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) , m_decodedOffset(0) { } @@ -201,7 +202,9 @@ bool ICOImageDecoder::decodeAtIndex(size_t index) } if (!m_pngDecoders[index]) { - m_pngDecoders[index].set(new PNGImageDecoder(m_premultiplyAlpha, m_ignoreGammaAndColorProfile)); + m_pngDecoders[index].set( + new PNGImageDecoder(m_premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied, + m_ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied)); setDataForPNGDecoderAtIndex(index); } // Fail if the size the PNGImageDecoder calculated does not match the size diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h b/WebCore/platform/image-decoders/ico/ICOImageDecoder.h index dc631f4..c2af6a3 100644 --- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h +++ b/WebCore/platform/image-decoders/ico/ICOImageDecoder.h @@ -40,7 +40,7 @@ namespace WebCore { // This class decodes the ICO and CUR image formats. class ICOImageDecoder : public ImageDecoder { public: - ICOImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + ICOImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); virtual ~ICOImageDecoder(); // ImageDecoder diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp index 855ba24..632d428 100644 --- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp +++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp @@ -222,12 +222,6 @@ public: // jpeglib cannot convert these to rgb, but it can convert ycck // to cmyk. m_info.out_color_space = JCS_CMYK; - - // Same as with grayscale images, we convert CMYK images to RGBA - // ones. When we keep the color profiles of these CMYK images, - // CoreGraphics will convert their colors again. So, we discard - // their color profiles to prevent color corruption. - m_decoder->setIgnoreGammaAndColorProfile(true); break; default: return m_decoder->setFailed(); @@ -404,8 +398,9 @@ void term_source(j_decompress_ptr jd) src->decoder->decoder()->jpegComplete(); } -JPEGImageDecoder::JPEGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +JPEGImageDecoder::JPEGImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) { } diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h index a60b387..63f29ab 100644 --- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h +++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h @@ -37,7 +37,7 @@ namespace WebCore { // This class decodes the JPEG image format. class JPEGImageDecoder : public ImageDecoder { public: - JPEGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + JPEGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); virtual ~JPEGImageDecoder(); // ImageDecoder diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp index 794a474..3fe4d3c 100644 --- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp +++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp @@ -169,8 +169,9 @@ private: unsigned m_currentBufferSize; }; -PNGImageDecoder::PNGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +PNGImageDecoder::PNGImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) , m_doNothingOnFailure(false) { } diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.h b/WebCore/platform/image-decoders/png/PNGImageDecoder.h index 68b0c1f..1e8902f 100644 --- a/WebCore/platform/image-decoders/png/PNGImageDecoder.h +++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.h @@ -36,7 +36,7 @@ namespace WebCore { // This class decodes the PNG image format. class PNGImageDecoder : public ImageDecoder { public: - PNGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + PNGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); virtual ~PNGImageDecoder(); // ImageDecoder diff --git a/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp b/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp index 0fc0bd5..a988d9c 100644 --- a/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp +++ b/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp @@ -35,8 +35,9 @@ namespace WebCore { -WEBPImageDecoder::WEBPImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile) - : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile) +WEBPImageDecoder::WEBPImageDecoder(ImageSource::AlphaOption alphaOption, + ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption) + : ImageDecoder(alphaOption, gammaAndColorProfileOption) { } diff --git a/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h b/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h index 57b1dae..6cf8870 100644 --- a/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h +++ b/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h @@ -37,7 +37,7 @@ namespace WebCore { class WEBPImageDecoder : public ImageDecoder { public: - WEBPImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile); + WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption); virtual ~WEBPImageDecoder(); virtual String filenameExtension() const { return "vp8"; } virtual bool isSizeAvailable(); |