Modified: trunk/Source/WebCore/ChangeLog (208595 => 208596)
--- trunk/Source/WebCore/ChangeLog 2016-11-11 18:54:08 UTC (rev 208595)
+++ trunk/Source/WebCore/ChangeLog 2016-11-11 18:54:21 UTC (rev 208596)
@@ -1,3 +1,17 @@
+2016-11-11 Megan Gardner <[email protected]>
+
+ [Cocoa] Support wide gamut for Drag Image UI
+ https://bugs.webkit.org/show_bug.cgi?id=164490
+
+ Reviewed by Tim Horton.
+
+ Fixed an error in the support define for wide gamut on Mac.
+
+ The testing infrastructure to test this does not exist, and will be landing in another patch.
+
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::extendedSRGBColorSpaceRef):
+
2016-11-11 Beth Dakin <[email protected]>
Get touch bar code building for open source builds
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (208595 => 208596)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2016-11-11 18:54:08 UTC (rev 208595)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2016-11-11 18:54:21 UTC (rev 208596)
@@ -97,7 +97,7 @@
CGColorSpaceRef extendedSRGBColorSpaceRef()
{
static CGColorSpaceRef extendedSRGBSpace;
-#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101200)
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
extendedSRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
#endif
// If there is no support for exteneded sRGB, fall back to sRGB.
Modified: trunk/Source/WebKit2/ChangeLog (208595 => 208596)
--- trunk/Source/WebKit2/ChangeLog 2016-11-11 18:54:08 UTC (rev 208595)
+++ trunk/Source/WebKit2/ChangeLog 2016-11-11 18:54:21 UTC (rev 208596)
@@ -1,3 +1,23 @@
+2016-11-11 Megan Gardner <[email protected]>
+
+ [Cocoa] Support wide gamut for Drag Image UI
+ https://bugs.webkit.org/show_bug.cgi?id=164490
+
+ Reviewed by Tim Horton.
+
+ Fixed an error in the gating for the new wide gamut support in ShareableBitmap.
+ We should always respect the flags straight out, and not make decisions later, it can lead to mismatched data and data storage.
+ Added support for wide gamut in createCGImage.
+
+ * Shared/cg/ShareableBitmapCG.cpp:
+ (WebKit::bitmapInfo):
+ (WebKit::colorSpace):
+ (WebKit::ShareableBitmap::createGraphicsContext):
+ (WebKit::ShareableBitmap::createCGImage):
+ * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+ (WebKit::convertImageToBitmap):
+ (WebKit::WebDragClient::startDrag):
+
2016-11-11 Beth Dakin <[email protected]>
Get touch bar code building for open source builds
Modified: trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp (208595 => 208596)
--- trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp 2016-11-11 18:54:08 UTC (rev 208595)
+++ trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp 2016-11-11 18:54:21 UTC (rev 208596)
@@ -39,7 +39,7 @@
static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags)
{
CGBitmapInfo info = 0;
- if ((flags & ShareableBitmap::SupportsExtendedColor) && screenSupportsExtendedColor()) {
+ if (flags & ShareableBitmap::SupportsExtendedColor) {
info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host;
if (flags & ShareableBitmap::SupportsAlpha)
@@ -58,19 +58,20 @@
return info;
}
+
+static CGColorSpaceRef colorSpace(ShareableBitmap::Flags flags)
+{
+ if (flags & ShareableBitmap::SupportsExtendedColor)
+ return extendedSRGBColorSpaceRef();
+ return sRGBColorSpaceRef();
+}
std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
{
ref(); // Balanced by deref in releaseBitmapContextData.
- CGColorSpaceRef colorSpace;
- if (m_flags & ShareableBitmap::SupportsExtendedColor)
- colorSpace = extendedSRGBColorSpaceRef();
- else
- colorSpace = sRGBColorSpaceRef();
+ RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), m_bytesPerPixel * 8 / 4, m_size.width() * m_bytesPerPixel, colorSpace(m_flags), bitmapInfo(m_flags), releaseBitmapContextData, this));
- 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));
-
ASSERT(bitmapContext.get());
// We want the origin to be in the top left corner so we flip the backing store context.
@@ -107,8 +108,7 @@
RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider) const
{
ASSERT_ARG(dataProvider, dataProvider);
- // FIXME: Make this use extended color, etc.
- 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));
+ RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), m_bytesPerPixel * 8 / 4, m_bytesPerPixel * 8, m_size.width() * m_bytesPerPixel, colorSpace(m_flags), bitmapInfo(m_flags), dataProvider, 0, false, kCGRenderingIntentDefault));
return image;
}
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (208595 => 208596)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2016-11-11 18:54:08 UTC (rev 208595)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2016-11-11 18:54:21 UTC (rev 208596)
@@ -39,6 +39,7 @@
#import <WebCore/FrameView.h>
#import <WebCore/GraphicsContext.h>
#import <WebCore/LegacyWebArchive.h>
+#import <WebCore/MainFrame.h>
#import <WebCore/WebCoreNSURLExtras.h>
#import <WebCore/Page.h>
#import <WebCore/RenderImage.h>
@@ -52,9 +53,12 @@
namespace WebKit {
-static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size)
+static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
{
- auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha);
+ ShareableBitmap::Flags flags = ShareableBitmap::SupportsAlpha;
+ if (screenSupportsExtendedColor(frame.mainFrame().view()))
+ flags |= ShareableBitmap::SupportsExtendedColor;
+ auto bitmap = ShareableBitmap::createShareable(size, flags);
if (!bitmap)
return nullptr;
@@ -73,7 +77,7 @@
void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, DataTransfer&, Frame& frame, bool linkDrag)
{
IntSize bitmapSize([image size]);
- RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize);
+ RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize, frame);
ShareableBitmap::Handle handle;
if (!bitmap || !bitmap->createHandle(handle))
return;