Changeset 208020 in webkit
- Timestamp:
- Oct 27, 2016 5:50:53 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208019 r208020 1 2016-10-27 Megan Gardner <megan_gardner@apple.com> 2 3 Add support for wide gamut for ShareableBitmap for image popovers 4 https://bugs.webkit.org/show_bug.cgi?id=164001 5 6 Reviewed by Simon Fraser. 7 8 Add a function to return a CGColorSpaceRef for extended sRGB. 9 10 This is currently untestable, so no tests added. 11 12 * platform/graphics/cg/GraphicsContextCG.cpp: 13 (WebCore::extendedSRGBColorSpaceRef): 14 1 15 2016-10-25 Brent Fulgham <bfulgham@apple.com> 2 16 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r207366 r208020 93 93 #endif // PLATFORM(WIN) 94 94 return sRGBSpace; 95 } 96 97 CGColorSpaceRef extendedSRGBColorSpaceRef() 98 { 99 static CGColorSpaceRef extendedSRGBSpace; 100 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101200) 101 extendedSRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB); 102 #endif 103 // If there is no support for exteneded sRGB, fall back to sRGB. 104 if (!extendedSRGBSpace) 105 extendedSRGBSpace = sRGBColorSpaceRef(); 106 return extendedSRGBSpace; 95 107 } 96 108 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
r207366 r208020 35 35 CGColorSpaceRef deviceRGBColorSpaceRef(); 36 36 WEBCORE_EXPORT CGColorSpaceRef sRGBColorSpaceRef(); 37 WEBCORE_EXPORT CGColorSpaceRef extendedSRGBColorSpaceRef(); 37 38 WEBCORE_EXPORT CGColorSpaceRef displayP3ColorSpaceRef(); 38 39 CGColorSpaceRef linearRGBColorSpaceRef(); -
trunk/Source/WebKit2/ChangeLog
r208014 r208020 1 2016-10-27 Megan Gardner <megan_gardner@apple.com> 2 3 Add support for wide gamut for ShareableBitmap for image popovers 4 https://bugs.webkit.org/show_bug.cgi?id=164001 5 6 Reviewed by Simon Fraser. 7 8 Added suppport for wide gamut in ShareableBitmap. SharableBitmaps now know the size of their pixels, 9 and that data is passed back and forth between the processes. The callers of SharedBitmap will determine 10 if their image should support wide gamut, but ShareableBitmap will override a set flag on a device that 11 is incapbable of supporting a wide gamut image. 12 This makes it possible to show wide gamut images in image popovers on iOS. 13 This is currently untestable, so no tests added. 14 15 * Platform/IPC/Decoder.cpp: 16 (IPC::Decoder::decode): 17 * Platform/IPC/Decoder.h: 18 * Platform/IPC/Encoder.cpp: 19 (IPC::Encoder::encode): 20 * Platform/IPC/Encoder.h: 21 * Shared/ShareableBitmap.cpp: 22 (WebKit::bytesPerPixel): 23 (WebKit::ShareableBitmap::Handle::encode): 24 (WebKit::ShareableBitmap::Handle::decode): 25 (WebKit::ShareableBitmap::Handle::clear): 26 (WebKit::ShareableBitmap::create): 27 (WebKit::ShareableBitmap::createShareable): 28 (WebKit::ShareableBitmap::createHandle): 29 (WebKit::ShareableBitmap::ShareableBitmap): 30 * Shared/ShareableBitmap.h: 31 (WebKit::ShareableBitmap::numBytesForSize): 32 (WebKit::ShareableBitmap::sizeInBytes): 33 * Shared/cg/ShareableBitmapCG.cpp: 34 (WebKit::bitmapInfo): 35 (WebKit::ShareableBitmap::createGraphicsContext): 36 (WebKit::ShareableBitmap::createCGImage): 37 * WebProcess/WebPage/ios/WebPageIOS.mm: 38 (WebKit::WebPage::getPositionInformation): 39 1 40 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 41 -
trunk/Source/WebKit2/Shared/ShareableBitmap.cpp
r207708 r208020 34 34 35 35 namespace WebKit { 36 37 static unsigned calculateBytesPerPixel(ShareableBitmap::Flags flags) 38 { 39 if (flags & ShareableBitmap::SupportsExtendedColor) 40 return 8; // for extended color, we are using half-float representations 41 return 4; 42 } 36 43 37 44 ShareableBitmap::Handle::Handle() … … 55 62 if (!decoder.decode(handle.m_flags)) 56 63 return false; 64 handle.m_bytesPerPixel = calculateBytesPerPixel(handle.m_flags); 57 65 return true; 58 66 } … … 63 71 m_size = IntSize(); 64 72 m_flags = Flag::NoFlags; 73 m_bytesPerPixel = calculateBytesPerPixel(m_flags); 65 74 } 66 75 67 76 RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags) 68 77 { 69 auto numBytes = numBytesForSize(size); 78 unsigned bytesPerPixel = calculateBytesPerPixel(flags); 79 auto numBytes = numBytesForSize(size, bytesPerPixel); 70 80 if (numBytes.hasOverflowed()) 71 81 return nullptr; … … 80 90 RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags) 81 91 { 82 auto numBytes = numBytesForSize(size); 92 unsigned bytesPerPixel = calculateBytesPerPixel(flags); 93 auto numBytes = numBytesForSize(size, bytesPerPixel); 83 94 if (numBytes.hasOverflowed()) 84 95 return nullptr; … … 95 106 ASSERT(sharedMemory); 96 107 97 auto numBytes = numBytesForSize(size); 108 unsigned bytesPerPixel = calculateBytesPerPixel(flags); 109 auto numBytes = numBytesForSize(size, bytesPerPixel); 98 110 if (numBytes.hasOverflowed()) 99 111 return nullptr; … … 102 114 return nullptr; 103 115 } 104 116 105 117 return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); 106 118 } … … 124 136 handle.m_size = m_size; 125 137 handle.m_flags = m_flags; 138 handle.m_bytesPerPixel = m_bytesPerPixel; 126 139 return true; 127 140 } … … 132 145 , m_data(data) 133 146 { 147 m_bytesPerPixel = calculateBytesPerPixel(flags); 134 148 } 135 149 … … 140 154 , m_data(0) 141 155 { 156 m_bytesPerPixel = calculateBytesPerPixel(flags); 142 157 } 143 158 -
trunk/Source/WebKit2/Shared/ShareableBitmap.h
r207708 r208020 52 52 NoFlags = 0, 53 53 SupportsAlpha = 1 << 0, 54 SupportsExtendedColor = 1 << 1, 54 55 }; 55 56 typedef unsigned Flags; … … 73 74 WebCore::IntSize m_size; 74 75 Flags m_flags; 76 unsigned m_bytesPerPixel; 75 77 }; 76 78 … … 127 129 #if USE(CAIRO) 128 130 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize&); 131 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return numBytesForSize(size); } 129 132 #else 130 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size ) { return size.area<RecordOverflow>() * 4; }133 static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return size.area<RecordOverflow>() * bytesPerPixel; } 131 134 #endif 132 135 … … 142 145 143 146 void* data() const; 147 #if USE(CAIRO) 144 148 size_t sizeInBytes() const { return numBytesForSize(m_size).unsafeGet(); } 145 149 #else 150 size_t sizeInBytes() const { return numBytesForSize(m_size, m_bytesPerPixel).unsafeGet(); } 151 #endif 152 146 153 WebCore::IntSize m_size; 147 154 Flags m_flags; 155 unsigned m_bytesPerPixel; 148 156 149 157 // If the shareable bitmap is backed by shared memory, this points to the shared memory object. -
trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp
r198655 r208020 29 29 #include <WebCore/BitmapImage.h> 30 30 #include <WebCore/GraphicsContextCG.h> 31 #include <WebCore/PlatformScreen.h> 31 32 #include <wtf/RetainPtr.h> 32 33 #include "CGUtilities.h" … … 38 39 static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags) 39 40 { 40 CGBitmapInfo info = kCGBitmapByteOrder32Host; 41 if (flags & ShareableBitmap::SupportsAlpha) 42 info |= kCGImageAlphaPremultipliedFirst; 43 else 44 info |= kCGImageAlphaNoneSkipFirst; 45 41 CGBitmapInfo info = 0; 42 if ((flags & ShareableBitmap::SupportsExtendedColor) && screenSupportsExtendedColor()) { 43 info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host; 44 45 if (flags & ShareableBitmap::SupportsAlpha) 46 info |= kCGImageAlphaPremultipliedLast; 47 else 48 info |= kCGImageAlphaNoneSkipLast; 49 50 } else { 51 info |= kCGBitmapByteOrder32Host; 52 53 if (flags & ShareableBitmap::SupportsAlpha) 54 info |= kCGImageAlphaPremultipliedFirst; 55 else 56 info |= kCGImageAlphaNoneSkipFirst; 57 } 58 46 59 return info; 47 60 } … … 50 63 { 51 64 ref(); // Balanced by deref in releaseBitmapContextData. 52 RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), 53 m_size.width(), m_size.height(), 8, m_size.width() * 4, sRGBColorSpaceRef(), 54 bitmapInfo(m_flags), releaseBitmapContextData, this)); 65 66 CGColorSpaceRef colorSpace; 67 if (m_flags & ShareableBitmap::SupportsExtendedColor) 68 colorSpace = extendedSRGBColorSpaceRef(); 69 else 70 colorSpace = sRGBColorSpaceRef(); 71 72 RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), m_bytesPerPixel * 8 / 4, m_size.width() * m_bytesPerPixel, colorSpace, bitmapInfo(m_flags), releaseBitmapContextData, this)); 73 74 ASSERT(bitmapContext.get()); 55 75 56 76 // We want the origin to be in the top left corner so we flip the backing store context. … … 88 108 { 89 109 ASSERT_ARG(dataProvider, dataProvider); 90 110 // FIXME: Make this use extended color, etc. 91 111 RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), 8, 32, m_size.width() * 4, sRGBColorSpaceRef(), bitmapInfo(m_flags), dataProvider, 0, false, kCGRenderingIntentDefault)); 92 112 return image; -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r206626 r208020 2358 2358 FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size(); 2359 2359 FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size(); 2360 if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), ShareableBitmap::SupportsAlpha)) { 2360 // FIXME: Only select ExtendedColor on images known to need wide gamut 2361 ShareableBitmap::Flags flags = ShareableBitmap::SupportsAlpha; 2362 flags |= screenSupportsExtendedColor() ? ShareableBitmap::SupportsExtendedColor : 0; 2363 if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), flags)) { 2361 2364 auto graphicsContext = sharedBitmap->createGraphicsContext(); 2362 2365 graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()));
Note: See TracChangeset
for help on using the changeset viewer.