Changeset 208596 in webkit


Ignore:
Timestamp:
Nov 11, 2016 10:54:21 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[Cocoa] Support wide gamut for Drag Image UI
https://bugs.webkit.org/show_bug.cgi?id=164490

Patch by Megan Gardner <Megan Gardner> on 2016-11-11
Reviewed by Tim Horton.

Source/WebCore:

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):

Source/WebKit2:

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):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r208595 r208596  
     12016-11-11  Megan Gardner  <megan_gardner@apple.com>
     2
     3        [Cocoa] Support wide gamut for Drag Image UI
     4        https://bugs.webkit.org/show_bug.cgi?id=164490
     5
     6        Reviewed by Tim Horton.
     7
     8        Fixed an error in the support define for wide gamut on Mac.
     9
     10        The testing infrastructure to test this does not exist, and will be landing in another patch.
     11
     12        * platform/graphics/cg/GraphicsContextCG.cpp:
     13        (WebCore::extendedSRGBColorSpaceRef):
     14
    1152016-11-11  Beth Dakin  <bdakin@apple.com>
    216
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r208460 r208596  
    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
  • trunk/Source/WebKit2/ChangeLog

    r208595 r208596  
     12016-11-11  Megan Gardner  <megan_gardner@apple.com>
     2
     3        [Cocoa] Support wide gamut for Drag Image UI
     4        https://bugs.webkit.org/show_bug.cgi?id=164490
     5
     6        Reviewed by Tim Horton.
     7
     8        Fixed an error in the gating for the new wide gamut support in ShareableBitmap.
     9        We should always respect the flags straight out, and not make decisions later, it can lead to mismatched data and data storage.
     10        Added support for wide gamut in createCGImage.
     11
     12        * Shared/cg/ShareableBitmapCG.cpp:
     13        (WebKit::bitmapInfo):
     14        (WebKit::colorSpace):
     15        (WebKit::ShareableBitmap::createGraphicsContext):
     16        (WebKit::ShareableBitmap::createCGImage):
     17        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
     18        (WebKit::convertImageToBitmap):
     19        (WebKit::WebDragClient::startDrag):
     20
    1212016-11-11  Beth Dakin  <bdakin@apple.com>
    222
  • trunk/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp

    r208020 r208596  
    4040{
    4141    CGBitmapInfo info = 0;
    42     if ((flags & ShareableBitmap::SupportsExtendedColor) && screenSupportsExtendedColor()) {
     42    if (flags & ShareableBitmap::SupportsExtendedColor) {
    4343        info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host;
    4444       
     
    5959    return info;
    6060}
     61   
     62static CGColorSpaceRef colorSpace(ShareableBitmap::Flags flags)
     63{
     64    if (flags & ShareableBitmap::SupportsExtendedColor)
     65        return extendedSRGBColorSpaceRef();
     66    return sRGBColorSpaceRef();
     67}
    6168
    6269std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
     
    6471    ref(); // Balanced by deref in releaseBitmapContextData.
    6572   
    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    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));
    7374   
    7475    ASSERT(bitmapContext.get());
     
    108109{
    109110    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));
     111    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));
    112112    return image;
    113113}
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

    r208455 r208596  
    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>
     
    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    if (screenSupportsExtendedColor(frame.mainFrame().view()))
     60        flags |= ShareableBitmap::SupportsExtendedColor;
     61    auto bitmap = ShareableBitmap::createShareable(size, flags);
    5862    if (!bitmap)
    5963        return nullptr;
     
    7478{
    7579    IntSize bitmapSize([image size]);
    76     RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize);
     80    RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get(), bitmapSize, frame);
    7781    ShareableBitmap::Handle handle;
    7882    if (!bitmap || !bitmap->createHandle(handle))
Note: See TracChangeset for help on using the changeset viewer.