[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
abarth at webkit.org
abarth at webkit.org
Wed Dec 22 15:21:16 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 6e06aa035926cc19aebd72feaa59d98b022e7bfa
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Nov 1 22:33:44 2010 +0000
2010-10-31 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
[Chromium] Add ICC support for PNG on Mac
https://bugs.webkit.org/show_bug.cgi?id=48170
This just pipes the ICC profile from libpng to CoreGraphics. This
patch would have been a lot prettier on Snow Leopard, but we have to
use a somewhat ugly API to get this to work on Leopard.
This is covered by about infinite tests.
* platform/image-decoders/ImageDecoder.cpp:
(WebCore::RGBA32Buffer::setColorProfile):
* platform/image-decoders/ImageDecoder.h:
* platform/image-decoders/cg/ImageDecoderCG.cpp:
(WebCore::RGBA32Buffer::asNewNativeImage):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::headerAvailable):
(WebCore::PNGImageDecoder::rowAvailable):
* platform/image-decoders/qt/RGBA32BufferQt.cpp:
(WebCore::RGBA32Buffer::setColorProfile):
* platform/image-decoders/skia/ImageDecoderSkia.cpp:
(WebCore::RGBA32Buffer::setColorProfile):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c8b2f3d..38d61ea 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-10-31 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ [Chromium] Add ICC support for PNG on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=48170
+
+ This just pipes the ICC profile from libpng to CoreGraphics. This
+ patch would have been a lot prettier on Snow Leopard, but we have to
+ use a somewhat ugly API to get this to work on Leopard.
+
+ This is covered by about infinite tests.
+
+ * platform/image-decoders/ImageDecoder.cpp:
+ (WebCore::RGBA32Buffer::setColorProfile):
+ * platform/image-decoders/ImageDecoder.h:
+ * platform/image-decoders/cg/ImageDecoderCG.cpp:
+ (WebCore::RGBA32Buffer::asNewNativeImage):
+ * platform/image-decoders/png/PNGImageDecoder.cpp:
+ (WebCore::PNGImageDecoder::headerAvailable):
+ (WebCore::PNGImageDecoder::rowAvailable):
+ * platform/image-decoders/qt/RGBA32BufferQt.cpp:
+ (WebCore::RGBA32Buffer::setColorProfile):
+ * platform/image-decoders/skia/ImageDecoderSkia.cpp:
+ (WebCore::RGBA32Buffer::setColorProfile):
+
2010-11-01 David Hyatt <hyatt at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebCore/platform/image-decoders/ImageDecoder.cpp b/WebCore/platform/image-decoders/ImageDecoder.cpp
index 9ffbbf5..a4aa630 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/ImageDecoder.cpp
@@ -189,6 +189,11 @@ void RGBA32Buffer::setHasAlpha(bool alpha)
m_hasAlpha = alpha;
}
+void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile)
+{
+ m_colorProfile = colorProfile;
+}
+
void RGBA32Buffer::setStatus(FrameStatus status)
{
m_status = status;
diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h
index b07c72b..995b240 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/WebCore/platform/image-decoders/ImageDecoder.h
@@ -46,6 +46,9 @@
namespace WebCore {
+ // FIXME: Do we want better encapsulation?
+ typedef Vector<char> ColorProfile;
+
// The RGBA32Buffer object represents the decoded image data in RGBA32
// format. This buffer is what all decoders write a single frame into.
// Frames are then instantiated for drawing by being handed this buffer.
@@ -125,6 +128,7 @@ namespace WebCore {
bool premultiplyAlpha() const { return m_premultiplyAlpha; }
void setHasAlpha(bool alpha);
+ void setColorProfile(const ColorProfile&);
void setRect(const IntRect& r) { m_rect = r; }
void setStatus(FrameStatus status);
void setDuration(unsigned duration) { m_duration = duration; }
@@ -192,6 +196,7 @@ namespace WebCore {
// same as ImageDecoder::m_size.
bool m_hasAlpha; // Whether or not any of the pixels in the buffer
// have transparency.
+ ColorProfile m_colorProfile;
#endif
IntRect m_rect; // The rect of the original specified frame within
// the overall buffer. This will always just be
@@ -344,6 +349,7 @@ namespace WebCore {
RefPtr<SharedBuffer> m_data; // The encoded data.
Vector<RGBA32Buffer> m_frameBufferCache;
+ ColorProfile m_colorProfile;
bool m_scaled;
Vector<int> m_scaledColumns;
Vector<int> m_scaledRows;
diff --git a/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
index 2fac7da..ce6e27c 100644
--- a/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
+++ b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
@@ -64,15 +64,30 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
return true;
}
+static CGColorSpaceRef createColorSpace(const ColorProfile& colorProfile)
+{
+ if (colorProfile.isEmpty())
+ return CGColorSpaceCreateDeviceRGB();
+
+ RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(colorProfile.data()), colorProfile.size()));
+#if !defined(TARGETING_TIGER) && !defined(TARGETING_LEOPARD)
+ return CGColorSpaceCreateWithICCProfile(data.get());
+#else
+ RetainPtr<CGColorSpaceRef> deviceColorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGDataProviderRef> profileDataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));
+ CGFloat ranges[] = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0};
+ return CGColorSpaceCreateICCBased(3, ranges, profileDataProvider.get(), deviceColorSpace.get());
+#endif
+}
+
NativeImagePtr RGBA32Buffer::asNewNativeImage() const
{
- // FIXME: Figure out the right color space.
- DEFINE_STATIC_LOCAL(RetainPtr<CGColorSpaceRef>, deviceColorSpace, (AdoptCF, CGColorSpaceCreateDeviceRGB()));
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, createColorSpace(m_colorProfile));
RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(m_backingStore.get()));
CGImageAlphaInfo alphaInfo = m_premultiplyAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaFirst;
- return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), deviceColorSpace.get(),
+ return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), colorSpace.get(),
alphaInfo | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault);
}
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
index 940e4c4..39040ed 100644
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -220,6 +220,23 @@ bool PNGImageDecoder::setFailed()
return ImageDecoder::setFailed();
}
+static ColorProfile readColorProfile(png_structp png, png_infop info)
+{
+#ifdef PNG_iCCP_SUPPORTED
+ char* profileName;
+ int compressionType;
+ char* profile;
+ png_uint_32 profileLength;
+ png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength);
+ if (profile) {
+ ColorProfile colorProfile;
+ colorProfile.append(profile, profileLength);
+ return colorProfile;
+ }
+#endif
+ return ColorProfile();
+}
+
void PNGImageDecoder::headerAvailable()
{
png_structp png = m_reader->pngPtr();
@@ -249,6 +266,8 @@ void PNGImageDecoder::headerAvailable()
int bitDepth, colorType, interlaceType, compressionType, filterType, channels;
png_get_IHDR(png, info, &width, &height, &bitDepth, &colorType, &interlaceType, &compressionType, &filterType);
+ m_colorProfile = readColorProfile(png, info);
+
// The options we set here match what Mozilla does.
// Expand to ensure we use 24-bit for RGB and 32-bit for RGBA.
@@ -311,6 +330,7 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
}
buffer.setStatus(RGBA32Buffer::FramePartial);
buffer.setHasAlpha(false);
+ buffer.setColorProfile(m_colorProfile);
// For PNGs, the frame always fills the entire image.
buffer.setRect(IntRect(IntPoint(), size()));
diff --git a/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp b/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
index a782373..998234f 100644
--- a/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
+++ b/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
@@ -28,6 +28,8 @@
#include "config.h"
#include "ImageDecoder.h"
+#include "NotImplemented.h"
+
#include <QPixmap>
#include <stdio.h>
@@ -124,6 +126,11 @@ void RGBA32Buffer::setHasAlpha(bool alpha)
m_hasAlpha = alpha;
}
+void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile)
+{
+ notImplemented();
+}
+
void RGBA32Buffer::setStatus(FrameStatus status)
{
m_status = status;
diff --git a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
index 3f435e4..94d6e82 100644
--- a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
+++ b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
@@ -27,6 +27,8 @@
#include "config.h"
#include "ImageDecoder.h"
+#include "NotImplemented.h"
+
namespace WebCore {
RGBA32Buffer::RGBA32Buffer()
@@ -109,6 +111,11 @@ void RGBA32Buffer::setHasAlpha(bool alpha)
m_bitmap.setIsOpaque(!alpha);
}
+void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile)
+{
+ notImplemented();
+}
+
void RGBA32Buffer::setStatus(FrameStatus status)
{
m_status = status;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list