Source/WebCore/ChangeLog

 12016-11-07 Megan Gardner <megan_gardner@apple.com>
 2
 3 Support wide gamut for Drag Image UI
 4 https://bugs.webkit.org/show_bug.cgi?id=164490
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added a new kind of NSImage from Bitmap that does not copy.
 9 Fixed a few errors for wide gamut support on mac.
 10 Updated a few depricated constants.
 11
 12 This is volitile UI, which does not currently have a structure to test with.
 13
 14 * platform/graphics/BitmapImage.h:
 15 * platform/graphics/Image.h:
 16 (WebCore::Image::snapshotNSImageDirect):
 17 * platform/graphics/cg/GraphicsContextCG.cpp:
 18 (WebCore::extendedSRGBColorSpaceRef):
 19 * platform/graphics/mac/ImageMac.mm:
 20 (WebCore::BitmapImage::snapshotNSImageDirect):
 21 * platform/mac/DragImageMac.mm:
 22 (WebCore::createDragImageFromImage):
 23
1242016-10-31 Dave Hyatt <hyatt@apple.com>
225
326 [CSS Parser] Support unprefixed cross-fade
208147

Source/WebCore/platform/graphics/BitmapImage.h

@@public:
9898#if USE(APPKIT)
9999 NSImage *nsImage() override;
100100 RetainPtr<NSImage> snapshotNSImage() override;
 101 RetainPtr<NSImage> snapshotNSImageDirect() override;
101102#endif
102103
103104#if PLATFORM(COCOA)
208147

Source/WebCore/platform/graphics/Image.h

@@public:
147147#if USE(APPKIT)
148148 virtual NSImage *nsImage() { return nullptr; }
149149 virtual RetainPtr<NSImage> snapshotNSImage() { return nullptr; }
 150 virtual RetainPtr<NSImage> snapshotNSImageDirect() { return nullptr; }
150151#endif
151152
152153#if PLATFORM(COCOA)
208147

Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

@@CGColorSpaceRef sRGBColorSpaceRef()
9797CGColorSpaceRef extendedSRGBColorSpaceRef()
9898{
9999 static CGColorSpaceRef extendedSRGBSpace;
100 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101200)
 100#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
101101 extendedSRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
102102#endif
103103 // If there is no support for exteneded sRGB, fall back to sRGB.
208147

Source/WebCore/platform/graphics/mac/ImageMac.mm

@@RetainPtr<NSImage> BitmapImage::snapshot
136136
137137 return adoptNS([[NSImage alloc] initWithData:(NSData*)data.get()]);
138138}
 139
 140RetainPtr<NSImage> BitmapImage::snapshotNSImageDirect()
 141{
 142 auto nativeImage = this->nativeImageForCurrentFrame();
 143 if (!nativeImage)
 144 return nullptr;
 145
 146 return adoptNS([[NSImage alloc] initWithCGImage:nativeImage.get() size:NSZeroSize]);
 147}
139148#endif
140149
141150}
208147

Source/WebCore/platform/mac/DragImageMac.mm

@@RetainPtr<NSImage> createDragImageFromIm
119119 [cocoaTransform.get() setTransformStruct:*(NSAffineTransformStruct*)&transform];
120120 [cocoaTransform.get() concat];
121121
122 #pragma clang diagnostic push
123 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
124  [image->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositeSourceOver fraction:1.0];
125 #pragma clang diagnostic pop
 122 [image->snapshotNSImage() drawInRect:destRect fromRect:NSMakeRect(0, 0, size.width(), size.height()) operation:NSCompositingOperationSourceOver fraction:1.0];
 123
126124 [rotatedDragImage.get() unlockFocus];
127125
128126 return rotatedDragImage;
129127 }
130128 }
131129
132  auto dragImage = image->snapshotNSImage();
 130 auto dragImage = image->snapshotNSImageDirect();
133131 [dragImage.get() setSize:(NSSize)size];
134132 return dragImage;
135133}
208147

Source/WebKit2/ChangeLog

 12016-11-07 Megan Gardner <megan_gardner@apple.com>
 2
 3 Support wide gamut for Drag Image UI
 4 https://bugs.webkit.org/show_bug.cgi?id=164490
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Fixed a few errors with the new wide gamut support in SharableBitmap.
 9 Added support for wide gamut when in the create Image path.
 10 Updated a few depricated constants.
 11
 12 * Shared/cg/ShareableBitmapCG.cpp:
 13 (WebKit::bitmapInfo):
 14 (WebKit::colorSpaceType):
 15 (WebKit::ShareableBitmap::createGraphicsContext):
 16 (WebKit::ShareableBitmap::createCGImage):
 17 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
 18 (WebKit::convertImageToBitmap):
 19 (WebKit::WebDragClient::startDrag):
 20
1212016-11-05 Carlos Garcia Campos <cgarcia@igalia.com>
222
323 [SOUP] Layout test http/tests/misc/authentication-redirect-3/authentication-sent-to-redirect-same-origin-with-location-credentials.html fails
208422

Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp

@@namespace WebKit {
3939static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags)
4040{
4141 CGBitmapInfo info = 0;
42  if ((flags & ShareableBitmap::SupportsExtendedColor) && screenSupportsExtendedColor()) {
 42 if (flags & ShareableBitmap::SupportsExtendedColor) {
4343 info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host;
4444
4545 if (flags & ShareableBitmap::SupportsAlpha)

@@static CGBitmapInfo bitmapInfo(Shareable
5858
5959 return info;
6060}
61 
62 std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
63 {
64  ref(); // Balanced by deref in releaseBitmapContextData.
6561
 62static CGColorSpaceRef colorSpaceType(ShareableBitmap::Flags flags)
 63{
6664 CGColorSpaceRef colorSpace;
67  if (m_flags & ShareableBitmap::SupportsExtendedColor)
 65
 66 if (flags & ShareableBitmap::SupportsExtendedColor)
6867 colorSpace = extendedSRGBColorSpaceRef();
6968 else
7069 colorSpace = sRGBColorSpaceRef();
 70 return colorSpace;
 71}
 72
 73std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
 74{
 75 ref(); // Balanced by deref in releaseBitmapContextData.
 76
 77 CGColorSpaceRef colorSpace = colorSpaceType(m_flags);
7178
7279 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));
7380

@@RetainPtr<CGImageRef> ShareableBitmap::m
107114RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider) const
108115{
109116 ASSERT_ARG(dataProvider, dataProvider);
110  // FIXME: Make this use extended color, etc.
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));
 117 CGColorSpaceRef colorSpace = colorSpaceType(m_flags);
 118 RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), m_bytesPerPixel * 8 / 4, m_bytesPerPixel * 8, m_size.width() * m_bytesPerPixel, colorSpace, bitmapInfo(m_flags), dataProvider, 0, false, kCGRenderingIntentDefault));
112119 return image;
113120}
114121
208147

Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

3939#import <WebCore/FrameView.h>
4040#import <WebCore/GraphicsContext.h>
4141#import <WebCore/LegacyWebArchive.h>
 42#import <WebCore/MainFrame.h>
4243#import <WebCore/WebCoreNSURLExtras.h>
4344#import <WebCore/Page.h>
4445#import <WebCore/RenderImage.h>

@@using namespace WebKit;
5253
5354namespace WebKit {
5455
55 static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size)
 56static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
5657{
57  auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha);
 58 ShareableBitmap::Flags flags = ShareableBitmap::SupportsAlpha;
 59 flags |= screenSupportsExtendedColor(frame.mainFrame().view()) ? ShareableBitmap::SupportsExtendedColor : 0;
 60 auto bitmap = ShareableBitmap::createShareable(size, flags);
5861 if (!bitmap)
5962 return nullptr;
6063

@@static PassRefPtr<ShareableBitmap> conve
6366 RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
6467
6568 [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]];
66 #pragma clang diagnostic push
67 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
68  [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil];
69 #pragma clang diagnostic pop
 69
 70 [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];
7071
7172 [NSGraphicsContext setCurrentContext:savedContext.get()];
7273

@@static PassRefPtr<ShareableBitmap> conve
7677void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, DataTransfer&, Frame& frame, bool linkDrag)
7778{
7879 IntSize bitmapSize([image size]);
79  RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize);
 80 RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize, frame);
8081 ShareableBitmap::Handle handle;
8182 if (!bitmap || !bitmap->createHandle(handle))
8283 return;
208147