Changeset 96609 in webkit
- Timestamp:
- Oct 4, 2011 10:49:46 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96607 r96609 1 2011-10-04 Cary Clark <caryclark@google.com> 2 3 Apply color profile found to decoded bitmap (Skia on Mac) 4 https://bugs.webkit.org/show_bug.cgi?id=69144 5 This fixes http://code.google.com/p/chromium/issues/detail?id=97830 6 7 Reviewed by Stephen White. 8 9 No new tests. This platform is not enabled. 10 11 * platform/image-decoders/ImageDecoder.h: 12 Add color profile slot to Skia variation. 13 14 * platform/image-decoders/skia/ImageDecoderSkia.cpp: 15 (WebCore::resolveColorSpace): 16 Adjust the bitmap in place to use the supplied color space. 17 18 (WebCore::createColorSpace): 19 Create a CGColorSpace from a color profile. 20 21 (WebCore::ImageFrame::setColorProfile): 22 Save the image's color profile until the image is complete. 23 24 (WebCore::ImageFrame::setStatus): 25 Apply the color profile, if any, to the image. 26 1 27 2011-10-04 Leandro Pereira <leandro@profusion.mobi> 2 28 -
trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h
r93792 r96609 189 189 #if USE(SKIA) 190 190 NativeImageSkia m_bitmap; 191 #if PLATFORM(CHROMIUM) && OS(DARWIN) 192 ColorProfile m_colorProfile; 193 #endif 191 194 #elif PLATFORM(QT) 192 195 mutable QPixmap m_pixmap; -
trunk/Source/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
r95901 r96609 29 29 30 30 #include "NotImplemented.h" 31 32 #if PLATFORM(CHROMIUM) && OS(DARWIN) 33 #include "GraphicsContextCG.h" 34 #include "SkCGUtils.h" 35 #endif 31 36 32 37 namespace WebCore { … … 111 116 } 112 117 118 #if PLATFORM(CHROMIUM) && OS(DARWIN) 119 static void resolveColorSpace(const SkBitmap& bitmap, CGColorSpaceRef colorSpace) 120 { 121 int width = bitmap.width(); 122 int height = bitmap.height(); 123 CGImageRef srcImage = SkCreateCGImageRefWithColorspace(bitmap, colorSpace); 124 SkAutoLockPixels lock(bitmap); 125 void* pixels = bitmap.getPixels(); 126 RetainPtr<CGContextRef> cgBitmap(AdoptCF, CGBitmapContextCreate(pixels, width, height, 8, width * 4, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst)); 127 if (!cgBitmap) 128 return; 129 CGContextSetBlendMode(cgBitmap.get(), kCGBlendModeCopy); 130 CGRect bounds = { {0, 0}, {width, height} }; 131 CGContextDrawImage(cgBitmap.get(), bounds, srcImage); 132 } 133 134 static CGColorSpaceRef createColorSpace(const ColorProfile& colorProfile) 135 { 136 RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(colorProfile.data()), colorProfile.size())); 137 #ifndef TARGETING_LEOPARD 138 return CGColorSpaceCreateWithICCProfile(data.get()); 139 #else 140 RetainPtr<CGDataProviderRef> profileDataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get())); 141 CGFloat ranges[] = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0}; 142 return CGColorSpaceCreateICCBased(3, ranges, profileDataProvider.get(), deviceRGBColorSpaceRef()); 143 #endif 144 } 145 #endif 146 113 147 void ImageFrame::setColorProfile(const ColorProfile& colorProfile) 114 148 { 149 #if PLATFORM(CHROMIUM) && OS(DARWIN) 150 m_colorProfile = colorProfile; 151 #else 115 152 notImplemented(); 153 #endif 116 154 } 117 155 … … 119 157 { 120 158 m_status = status; 121 if (m_status == FrameComplete) 159 if (m_status == FrameComplete) { 122 160 m_bitmap.setDataComplete(); // Tell the bitmap it's done. 161 #if PLATFORM(CHROMIUM) && OS(DARWIN) 162 if (m_colorProfile.isEmpty()) 163 return; 164 RetainPtr<CGColorSpaceRef> cgColorSpace(AdoptCF, createColorSpace(m_colorProfile)); 165 resolveColorSpace(m_bitmap.bitmap(), cgColorSpace.get()); 166 #endif 167 } 123 168 } 124 169
Note: See TracChangeset
for help on using the changeset viewer.