summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/image-decoders/png
diff options
context:
space:
mode:
authorRussell Brenner <russellbrenner@google.com>2010-11-18 17:33:13 -0800
committerRussell Brenner <russellbrenner@google.com>2010-12-02 13:47:21 -0800
commit6b70adc33054f8aee8c54d0f460458a9df11b8a5 (patch)
tree103a13998c33944d6ab3b8318c509a037e639460 /WebCore/platform/image-decoders/png
parentbdf4ebc8e70b2d221b6ee7a65660918ecb1d33aa (diff)
downloadexternal_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.zip
external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.gz
external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.bz2
Merge WebKit at r72274: Initial merge by git.
Change-Id: Ie51f0b4a16da82942bd516dce59cfb79ebbe25fb
Diffstat (limited to 'WebCore/platform/image-decoders/png')
-rw-r--r--WebCore/platform/image-decoders/png/PNGImageDecoder.cpp15
-rw-r--r--WebCore/platform/image-decoders/png/PNGImageDecoder.h2
2 files changed, 8 insertions, 9 deletions
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
index e4f7a0c..8b81896 100644
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -169,8 +169,8 @@ private:
unsigned m_currentBufferSize;
};
-PNGImageDecoder::PNGImageDecoder(bool premultiplyAlpha)
- : ImageDecoder(premultiplyAlpha)
+PNGImageDecoder::PNGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+ : ImageDecoder(premultiplyAlpha, ignoreGammaAndColorProfile)
, m_doNothingOnFailure(false)
{
}
@@ -296,7 +296,7 @@ void PNGImageDecoder::headerAvailable()
// Deal with gamma and keep it under our control.
double gamma;
- if (png_get_gAMA(png, info, &gamma)) {
+ if (!m_ignoreGammaAndColorProfile && png_get_gAMA(png, info, &gamma)) {
if ((gamma <= 0.0) || (gamma > cMaxGamma)) {
gamma = cInverseGamma;
png_set_gAMA(png, info, gamma);
@@ -395,16 +395,15 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
// Check that the row is within the image bounds. LibPNG may supply an extra row.
if (destY < 0 || destY >= scaledSize().height())
return;
- bool sawAlpha = buffer.hasAlpha();
+ bool nonTrivialAlpha = false;
for (int x = 0; x < width; ++x) {
png_bytep pixel = row + (m_scaled ? m_scaledColumns[x] : x) * colorChannels;
unsigned alpha = hasAlpha ? pixel[3] : 255;
buffer.setRGBA(x, destY, pixel[0], pixel[1], pixel[2], alpha);
- if (!sawAlpha && alpha < 255) {
- sawAlpha = true;
- buffer.setHasAlpha(true);
- }
+ nonTrivialAlpha |= alpha < 255;
}
+ if (nonTrivialAlpha && !buffer.hasAlpha())
+ buffer.setHasAlpha(nonTrivialAlpha);
}
void PNGImageDecoder::pngComplete()
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.h b/WebCore/platform/image-decoders/png/PNGImageDecoder.h
index 763b88f..68b0c1f 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);
+ PNGImageDecoder(bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
virtual ~PNGImageDecoder();
// ImageDecoder