Changeset 71065 in webkit
- Timestamp:
- Nov 1, 2010 3:33:44 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71055 r71065 1 2010-10-31 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 [Chromium] Add ICC support for PNG on Mac 6 https://bugs.webkit.org/show_bug.cgi?id=48170 7 8 This just pipes the ICC profile from libpng to CoreGraphics. This 9 patch would have been a lot prettier on Snow Leopard, but we have to 10 use a somewhat ugly API to get this to work on Leopard. 11 12 This is covered by about infinite tests. 13 14 * platform/image-decoders/ImageDecoder.cpp: 15 (WebCore::RGBA32Buffer::setColorProfile): 16 * platform/image-decoders/ImageDecoder.h: 17 * platform/image-decoders/cg/ImageDecoderCG.cpp: 18 (WebCore::RGBA32Buffer::asNewNativeImage): 19 * platform/image-decoders/png/PNGImageDecoder.cpp: 20 (WebCore::PNGImageDecoder::headerAvailable): 21 (WebCore::PNGImageDecoder::rowAvailable): 22 * platform/image-decoders/qt/RGBA32BufferQt.cpp: 23 (WebCore::RGBA32Buffer::setColorProfile): 24 * platform/image-decoders/skia/ImageDecoderSkia.cpp: 25 (WebCore::RGBA32Buffer::setColorProfile): 26 1 27 2010-11-01 David Hyatt <hyatt@apple.com> 2 28 -
trunk/WebCore/platform/image-decoders/ImageDecoder.cpp
r70846 r71065 188 188 { 189 189 m_hasAlpha = alpha; 190 } 191 192 void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile) 193 { 194 m_colorProfile = colorProfile; 190 195 } 191 196 -
trunk/WebCore/platform/image-decoders/ImageDecoder.h
r70846 r71065 47 47 namespace WebCore { 48 48 49 // FIXME: Do we want better encapsulation? 50 typedef Vector<char> ColorProfile; 51 49 52 // The RGBA32Buffer object represents the decoded image data in RGBA32 50 53 // format. This buffer is what all decoders write a single frame into. … … 126 129 127 130 void setHasAlpha(bool alpha); 131 void setColorProfile(const ColorProfile&); 128 132 void setRect(const IntRect& r) { m_rect = r; } 129 133 void setStatus(FrameStatus status); … … 193 197 bool m_hasAlpha; // Whether or not any of the pixels in the buffer 194 198 // have transparency. 199 ColorProfile m_colorProfile; 195 200 #endif 196 201 IntRect m_rect; // The rect of the original specified frame within … … 345 350 RefPtr<SharedBuffer> m_data; // The encoded data. 346 351 Vector<RGBA32Buffer> m_frameBufferCache; 352 ColorProfile m_colorProfile; 347 353 bool m_scaled; 348 354 Vector<int> m_scaledColumns; -
trunk/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
r70846 r71065 65 65 } 66 66 67 static CGColorSpaceRef createColorSpace(const ColorProfile& colorProfile) 68 { 69 if (colorProfile.isEmpty()) 70 return CGColorSpaceCreateDeviceRGB(); 71 72 RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(colorProfile.data()), colorProfile.size())); 73 #if !defined(TARGETING_TIGER) && !defined(TARGETING_LEOPARD) 74 return CGColorSpaceCreateWithICCProfile(data.get()); 75 #else 76 RetainPtr<CGColorSpaceRef> deviceColorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); 77 RetainPtr<CGDataProviderRef> profileDataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get())); 78 CGFloat ranges[] = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0}; 79 return CGColorSpaceCreateICCBased(3, ranges, profileDataProvider.get(), deviceColorSpace.get()); 80 #endif 81 } 82 67 83 NativeImagePtr RGBA32Buffer::asNewNativeImage() const 68 84 { 69 // FIXME: Figure out the right color space. 70 DEFINE_STATIC_LOCAL(RetainPtr<CGColorSpaceRef>, deviceColorSpace, (AdoptCF, CGColorSpaceCreateDeviceRGB())); 85 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, createColorSpace(m_colorProfile)); 71 86 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(m_backingStore.get())); 72 87 73 88 CGImageAlphaInfo alphaInfo = m_premultiplyAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaFirst; 74 89 75 return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), deviceColorSpace.get(),90 return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), colorSpace.get(), 76 91 alphaInfo | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault); 77 92 } -
trunk/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
r66039 r71065 221 221 } 222 222 223 static ColorProfile readColorProfile(png_structp png, png_infop info) 224 { 225 #ifdef PNG_iCCP_SUPPORTED 226 char* profileName; 227 int compressionType; 228 char* profile; 229 png_uint_32 profileLength; 230 png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength); 231 if (profile) { 232 ColorProfile colorProfile; 233 colorProfile.append(profile, profileLength); 234 return colorProfile; 235 } 236 #endif 237 return ColorProfile(); 238 } 239 223 240 void PNGImageDecoder::headerAvailable() 224 241 { … … 250 267 png_get_IHDR(png, info, &width, &height, &bitDepth, &colorType, &interlaceType, &compressionType, &filterType); 251 268 269 m_colorProfile = readColorProfile(png, info); 270 252 271 // The options we set here match what Mozilla does. 253 272 … … 312 331 buffer.setStatus(RGBA32Buffer::FramePartial); 313 332 buffer.setHasAlpha(false); 333 buffer.setColorProfile(m_colorProfile); 314 334 315 335 // For PNGs, the frame always fills the entire image. -
trunk/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
r68446 r71065 28 28 #include "config.h" 29 29 #include "ImageDecoder.h" 30 31 #include "NotImplemented.h" 30 32 31 33 #include <QPixmap> … … 125 127 } 126 128 129 void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile) 130 { 131 notImplemented(); 132 } 133 127 134 void RGBA32Buffer::setStatus(FrameStatus status) 128 135 { -
trunk/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
r68446 r71065 27 27 #include "config.h" 28 28 #include "ImageDecoder.h" 29 30 #include "NotImplemented.h" 29 31 30 32 namespace WebCore { … … 110 112 } 111 113 114 void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile) 115 { 116 notImplemented(); 117 } 118 112 119 void RGBA32Buffer::setStatus(FrameStatus status) 113 120 {
Note: See TracChangeset
for help on using the changeset viewer.