Title: [221391] tags/Safari-605.1.4/Source
Revision
221391
Author
[email protected]
Date
2017-08-30 12:10:22 -0700 (Wed, 30 Aug 2017)

Log Message

Revert r221068. rdar://problem/33925559

Modified Paths

Diff

Modified: tags/Safari-605.1.4/Source/WebCore/ChangeLog (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/ChangeLog	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/ChangeLog	2017-08-30 19:10:22 UTC (rev 221391)
@@ -1,5 +1,9 @@
 2017-08-30  Jason Marcell  <[email protected]>
 
+        Revert r221068. rdar://problem/33925559
+
+2017-08-30  Jason Marcell  <[email protected]>
+
         Revert r221088. rdar://problem/33925559
 
 2017-08-29  Wenson Hsieh  <[email protected]>

Modified: tags/Safari-605.1.4/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -188,8 +188,6 @@
 void CGContextSetFontAntialiasingStyle(CGContextRef, CGFontAntialiasingStyle);
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || PLATFORM(IOS)
-bool CGColorSpaceUsesExtendedRange(CGColorSpaceRef);
-
 typedef struct CGPDFAnnotation *CGPDFAnnotationRef;
 typedef bool (^CGPDFAnnotationDrawCallbackType)(CGContextRef context, CGPDFPageRef page, CGPDFAnnotationRef annotation);
 void CGContextDrawPDFPageWithAnnotations(CGContextRef, CGPDFPageRef, CGPDFAnnotationDrawCallbackType);

Modified: tags/Safari-605.1.4/Source/WebCore/platform/PlatformScreen.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/platform/PlatformScreen.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/platform/PlatformScreen.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -41,10 +41,6 @@
 OBJC_CLASS UIScreen;
 #endif
 
-#if USE(CG)
-typedef struct CGColorSpace *CGColorSpaceRef;
-#endif
-
 namespace WebCore {
 
 class FloatRect;
@@ -64,10 +60,6 @@
 
 WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* = nullptr);
 
-#if USE(CG)
-WEBCORE_EXPORT CGColorSpaceRef screenColorSpace(Widget* = nullptr);
-#endif
-
 #if PLATFORM(MAC)
 
 NSScreen *screen(NSWindow *);

Modified: tags/Safari-605.1.4/Source/WebCore/platform/ios/PlatformScreenIOS.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/platform/ios/PlatformScreenIOS.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/platform/ios/PlatformScreenIOS.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -30,7 +30,6 @@
 #import "FloatRect.h"
 #import "FloatSize.h"
 #import "FrameView.h"
-#import "GraphicsContextCG.h"
 #import "HostWindow.h"
 #import "IntRect.h"
 #import "WAKWindow.h"
@@ -75,11 +74,6 @@
     return MGGetBoolAnswer(kMGQHasExtendedColorDisplay);
 }
 
-CGColorSpaceRef screenColorSpace(Widget* widget)
-{
-    return screenSupportsExtendedColor(widget) ? extendedSRGBColorSpaceRef() : sRGBColorSpaceRef();
-}
-
 // These functions scale between screen and page coordinates because _javascript_/DOM operations
 // assume that the screen and the page share the same coordinate system.
 FloatRect screenRect(Widget* widget)

Modified: tags/Safari-605.1.4/Source/WebCore/platform/mac/PlatformScreenMac.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/platform/mac/PlatformScreenMac.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/platform/mac/PlatformScreenMac.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -134,11 +134,6 @@
     return firstScreen();
 }
 
-CGColorSpaceRef screenColorSpace(Widget* widget)
-{
-    return screen(widget).colorSpace.CGColorSpace;
-}
-
 bool screenSupportsExtendedColor(Widget* widget)
 {
     if (!widget)
@@ -147,7 +142,7 @@
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     return [screen(widget) canRepresentDisplayGamut:NSDisplayGamutP3];
 #else
-    auto colorSpace = screenColorSpace(widget);
+    auto colorSpace = screen(widget).colorSpace.CGColorSpace;
     auto iccData = adoptCF(CGColorSpaceCopyICCProfile(colorSpace));
     auto profile = "" nullptr));
     return profile && ColorSyncProfileIsWideGamut(profile.get());

Modified: tags/Safari-605.1.4/Source/WebCore/platform/win/PlatformScreenWin.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebCore/platform/win/PlatformScreenWin.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebCore/platform/win/PlatformScreenWin.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -30,7 +30,6 @@
 #include "FloatRect.h"
 #include "Frame.h"
 #include "FrameView.h"
-#include "GraphicsContextCG.h"
 #include "HostWindow.h"
 #include "IntRect.h"
 #include "NotImplemented.h"
@@ -101,11 +100,6 @@
     return monitorInfo.rcWork;
 }
 
-CGColorSpaceRef screenColorSpace(Widget*)
-{
-    return sRGBColorSpaceRef();
-}
-
 bool screenSupportsExtendedColor(Widget*)
 {
     return false;

Modified: tags/Safari-605.1.4/Source/WebKit/ChangeLog (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/ChangeLog	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/ChangeLog	2017-08-30 19:10:22 UTC (rev 221391)
@@ -1,5 +1,9 @@
 2017-08-30  Jason Marcell  <[email protected]>
 
+        Revert r221068. rdar://problem/33925559
+
+2017-08-30  Jason Marcell  <[email protected]>
+
         Revert r221149. rdar://problem/34029673
 
 2017-08-29  Carlos Garcia Campos  <[email protected]>

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/API/c/WKSharedAPICast.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/API/c/WKSharedAPICast.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/API/c/WKSharedAPICast.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -930,6 +930,9 @@
 
     if (wkImageOptions & kWKImageOptionsShareable)
         snapshotOptions |= SnapshotOptionsShareable;
+
+    if (wkImageOptions & kWKSnapshotOptionsExtendedColor)
+        snapshotOptions |= SnapshotOptionsExtendedColor;
     
     return snapshotOptions;
 }
@@ -952,8 +955,6 @@
         snapshotOptions |= SnapshotOptionsForceWhiteText;
     if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
         snapshotOptions |= SnapshotOptionsPrinting;
-    if (wkSnapshotOptions & kWKSnapshotOptionsExtendedColor)
-        snapshotOptions |= SnapshotOptionsUseScreenColorSpace;
 
     return snapshotOptions;
 }

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/ContextMenuContextData.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/ContextMenuContextData.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/ContextMenuContextData.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -64,8 +64,8 @@
     if (!image)
         return;
 
-    // FIXME: figure out the rounding strategy for ShareableBitmap.
-    m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), { });
+    // FIXME: figure out the rounding startegy for ShareableBitmap.
+    m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
     m_controlledImage->createGraphicsContext()->drawImage(*image, IntPoint());
 #endif
 }

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/ImageOptions.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/ImageOptions.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/ImageOptions.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -30,6 +30,7 @@
 
 enum ImageOptions {
     ImageOptionsShareable = 1 << 0,
+    ImageOptionsExtendedColor = 1 << 1,
 };
 
 enum {
@@ -41,10 +42,11 @@
     SnapshotOptionsForceBlackText = 1 << 6,
     SnapshotOptionsForceWhiteText = 1 << 7,
     SnapshotOptionsPrinting = 1 << 8,
-    SnapshotOptionsUseScreenColorSpace = 1 << 9,
+    SnapshotOptionsExtendedColor = 1 << 9,
 };
 typedef uint32_t SnapshotOptions;
 
+
 inline ImageOptions snapshotOptionsToImageOptions(SnapshotOptions snapshotOptions)
 {
     unsigned imageOptions = 0;
@@ -51,6 +53,10 @@
 
     if (snapshotOptions & SnapshotOptionsShareable)
         imageOptions |= ImageOptionsShareable;
+    
+    if (snapshotOptions & SnapshotOptionsExtendedColor)
+        imageOptions |= ImageOptionsExtendedColor;
+    
 
     return static_cast<ImageOptions>(imageOptions);
 }

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -33,8 +33,16 @@
 using namespace WebCore;
 
 namespace WebKit {
+    
+static unsigned calculateBytesPerPixel(ShareableBitmap::Flags flags)
+{
+    if (flags & ShareableBitmap::SupportsExtendedColor)
+        return 8; // for extended color, we are using half-float representations
+    return 4;
+}
 
 ShareableBitmap::Handle::Handle()
+    : m_flags(0)
 {
 }
 
@@ -42,7 +50,7 @@
 {
     encoder << m_handle;
     encoder << m_size;
-    encoder << m_configuration;
+    encoder << m_flags;
 }
 
 bool ShareableBitmap::Handle::decode(IPC::Decoder& decoder, Handle& handle)
@@ -51,8 +59,9 @@
         return false;
     if (!decoder.decode(handle.m_size))
         return false;
-    if (!decoder.decode(handle.m_configuration))
+    if (!decoder.decode(handle.m_flags))
         return false;
+    handle.m_bytesPerPixel = calculateBytesPerPixel(handle.m_flags);
     return true;
 }
 
@@ -60,31 +69,14 @@
 {
     m_handle.clear();
     m_size = IntSize();
-    m_configuration = { };
+    m_flags = Flag::NoFlags;
+    m_bytesPerPixel = calculateBytesPerPixel(m_flags);
 }
 
-void ShareableBitmap::Configuration::encode(IPC::Encoder& encoder) const
+RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags)
 {
-    encoder << isOpaque;
-#if PLATFORM(COCOA)
-    encoder << colorSpace;
-#endif
-}
-
-bool ShareableBitmap::Configuration::decode(IPC::Decoder& decoder, Configuration& configuration)
-{
-    if (!decoder.decode(configuration.isOpaque))
-        return false;
-#if PLATFORM(COCOA)
-    if (!decoder.decode(configuration.colorSpace))
-        return false;
-#endif
-    return true;
-}
-
-RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Configuration configuration)
-{
-    auto numBytes = numBytesForSize(size, calculateBytesPerPixel(configuration));
+    unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+    auto numBytes = numBytesForSize(size, bytesPerPixel);
     if (numBytes.hasOverflowed())
         return nullptr;
 
@@ -92,12 +84,13 @@
     if (!tryFastMalloc(numBytes.unsafeGet()).getValue(data))
         return nullptr;
 
-    return adoptRef(new ShareableBitmap(size, configuration, data));
+    return adoptRef(new ShareableBitmap(size, flags, data));
 }
 
-RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Configuration configuration)
+RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags)
 {
-    auto numBytes = numBytesForSize(size, calculateBytesPerPixel(configuration));
+    unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+    auto numBytes = numBytesForSize(size, bytesPerPixel);
     if (numBytes.hasOverflowed())
         return nullptr;
 
@@ -105,14 +98,15 @@
     if (!sharedMemory)
         return nullptr;
 
-    return adoptRef(new ShareableBitmap(size, configuration, sharedMemory));
+    return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
 }
 
-RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Configuration configuration, RefPtr<SharedMemory> sharedMemory)
+RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
 {
     ASSERT(sharedMemory);
 
-    auto numBytes = numBytesForSize(size, calculateBytesPerPixel(configuration));
+    unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+    auto numBytes = numBytesForSize(size, bytesPerPixel);
     if (numBytes.hasOverflowed())
         return nullptr;
     if (sharedMemory->size() < numBytes.unsafeGet()) {
@@ -120,7 +114,7 @@
         return nullptr;
     }
     
-    return adoptRef(new ShareableBitmap(size, configuration, sharedMemory));
+    return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
 }
 
 RefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle, SharedMemory::Protection protection)
@@ -130,7 +124,7 @@
     if (!sharedMemory)
         return nullptr;
 
-    return create(handle.m_size, handle.m_configuration, WTFMove(sharedMemory));
+    return create(handle.m_size, handle.m_flags, WTFMove(sharedMemory));
 }
 
 bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection) const
@@ -140,23 +134,26 @@
     if (!m_sharedMemory->createHandle(handle.m_handle, protection))
         return false;
     handle.m_size = m_size;
-    handle.m_configuration = m_configuration;
+    handle.m_flags = m_flags;
+    handle.m_bytesPerPixel = m_bytesPerPixel;
     return true;
 }
 
-ShareableBitmap::ShareableBitmap(const IntSize& size, Configuration configuration, void* data)
+ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, void* data)
     : m_size(size)
-    , m_configuration(configuration)
+    , m_flags(flags)
     , m_data(data)
 {
+    m_bytesPerPixel = calculateBytesPerPixel(flags);
 }
 
-ShareableBitmap::ShareableBitmap(const IntSize& size, Configuration configuration, RefPtr<SharedMemory> sharedMemory)
+ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
     : m_size(size)
-    , m_configuration(configuration)
+    , m_flags(flags)
     , m_sharedMemory(sharedMemory)
-    , m_data(nullptr)
+    , m_data(0)
 {
+    m_bytesPerPixel = calculateBytesPerPixel(flags);
 }
 
 ShareableBitmap::~ShareableBitmap()
@@ -174,11 +171,4 @@
     return m_data;
 }
 
-#if !USE(CG)
-unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration&)
-{
-    return 4;
-}
-#endif
-
 } // namespace WebKit

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/ShareableBitmap.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -32,7 +32,6 @@
 #include <wtf/RefPtr.h>
 
 #if USE(CG)
-#include "ColorSpaceData.h"
 #include <wtf/RetainPtr.h>
 #endif
 
@@ -41,8 +40,8 @@
 #endif
 
 namespace WebCore {
-class Image;
-class GraphicsContext;
+    class Image;
+    class GraphicsContext;
 }
 
 namespace WebKit {
@@ -49,15 +48,12 @@
     
 class ShareableBitmap : public RefCounted<ShareableBitmap> {
 public:
-    struct Configuration {
-        bool isOpaque { false };
-#if PLATFORM(COCOA)
-        ColorSpaceData colorSpace;
-#endif
-
-        void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, Configuration&);
+    enum Flag {
+        NoFlags = 0,
+        SupportsAlpha = 1 << 0,
+        SupportsExtendedColor = 1 << 1,
     };
+    typedef unsigned Flags;
 
     class Handle {
         WTF_MAKE_NONCOPYABLE(Handle);
@@ -76,17 +72,18 @@
 
         mutable SharedMemory::Handle m_handle;
         WebCore::IntSize m_size;
-        Configuration m_configuration;
+        Flags m_flags;
+        unsigned m_bytesPerPixel;
     };
 
     // Create a shareable bitmap that uses malloced memory.
-    static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Configuration);
+    static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags);
 
     // Create a shareable bitmap whose backing memory can be shared with another process.
-    static RefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Configuration);
+    static RefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags);
 
     // Create a shareable bitmap from an already existing shared memory block.
-    static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Configuration, RefPtr<SharedMemory>);
+    static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
 
     // Create a shareable bitmap from a handle.
     static RefPtr<ShareableBitmap> create(const Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite);
@@ -126,8 +123,8 @@
 #endif
 
 private:
-    ShareableBitmap(const WebCore::IntSize&, Configuration, void*);
-    ShareableBitmap(const WebCore::IntSize&, Configuration, RefPtr<SharedMemory>);
+    ShareableBitmap(const WebCore::IntSize&, Flags, void*);
+    ShareableBitmap(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
 
 #if USE(CAIRO)
     static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize&);
@@ -150,13 +147,12 @@
 #if USE(CAIRO)
     size_t sizeInBytes() const { return numBytesForSize(m_size).unsafeGet(); }
 #else
-    size_t sizeInBytes() const { return numBytesForSize(m_size, calculateBytesPerPixel(m_configuration)).unsafeGet(); }
+    size_t sizeInBytes() const { return numBytesForSize(m_size, m_bytesPerPixel).unsafeGet(); }
 #endif
-
-    static unsigned calculateBytesPerPixel(const Configuration&);
-
+    
     WebCore::IntSize m_size;
-    Configuration m_configuration;
+    Flags m_flags;
+    unsigned m_bytesPerPixel;
 
     // If the shareable bitmap is backed by shared memory, this points to the shared memory object.
     RefPtr<SharedMemory> m_sharedMemory;

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -1055,7 +1055,7 @@
 
 static void encodeImage(Encoder& encoder, Image& image)
 {
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
     bitmap->createGraphicsContext()->drawImage(image, IntPoint());
 
     ShareableBitmap::Handle handle;

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebImage.h"
 
+#include "ShareableBitmap.h"
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -32,18 +34,17 @@
 
 RefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
 {
-    return WebImage::create(size, options, { });
-}
-
-RefPtr<WebImage> WebImage::create(const WebCore::IntSize& size, ImageOptions options, const ShareableBitmap::Configuration& bitmapConfiguration)
-{
+    int sharableOptions = ShareableBitmap::SupportsAlpha;
+    
+    if (options & ImageOptionsExtendedColor)
+        sharableOptions |= ShareableBitmap::SupportsExtendedColor;
     if (options & ImageOptionsShareable) {
-        auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
+        auto bitmap = ShareableBitmap::createShareable(size, sharableOptions);
         if (!bitmap)
             return nullptr;
         return WebImage::create(bitmap.releaseNonNull());
     }
-    auto bitmap = ShareableBitmap::create(size, bitmapConfiguration);
+    auto bitmap = ShareableBitmap::create(size, sharableOptions);
     if (!bitmap)
         return nullptr;
     return WebImage::create(bitmap.releaseNonNull());

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.h (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.h	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/WebImage.h	2017-08-30 19:10:22 UTC (rev 221391)
@@ -27,7 +27,6 @@
 
 #include "APIObject.h"
 #include "ImageOptions.h"
-#include "ShareableBitmap.h"
 #include <wtf/Ref.h>
 
 namespace WebCore {
@@ -36,12 +35,13 @@
 
 namespace WebKit {
 
+class ShareableBitmap;
+
 // WebImage - An image type suitable for vending to an API.
 
 class WebImage : public API::ObjectImpl<API::Object::Type::Image> {
 public:
     static RefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
-    static RefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions, const ShareableBitmap::Configuration&);
     static Ref<WebImage> create(Ref<ShareableBitmap>&&);
     ~WebImage();
     

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -29,7 +29,6 @@
 #include <WebCore/BitmapImage.h>
 #include <WebCore/GraphicsContextCG.h>
 #include <WebCore/PlatformScreen.h>
-#include <pal/spi/cg/CoreGraphicsSPI.h>
 #include <wtf/RetainPtr.h>
 #include "CGUtilities.h"
 
@@ -36,56 +35,43 @@
 using namespace WebCore;
 
 namespace WebKit {
-    
-static CGColorSpaceRef colorSpace(const ShareableBitmap::Configuration& configuration)
-{
-    return configuration.colorSpace.cgColorSpace.get() ?: sRGBColorSpaceRef();
-}
 
-static bool wantsExtendedRange(const ShareableBitmap::Configuration& configuration)
+static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags)
 {
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || PLATFORM(IOS)
-    return CGColorSpaceUsesExtendedRange(colorSpace(configuration));
-#else
-    UNUSED_PARAM(configuration);
-    return false;
-#endif
-}
-
-static CGBitmapInfo bitmapInfo(const ShareableBitmap::Configuration& configuration)
-{
     CGBitmapInfo info = 0;
-    if (wantsExtendedRange(configuration)) {
+    if (flags & ShareableBitmap::SupportsExtendedColor) {
         info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host;
-
-        if (configuration.isOpaque)
+        
+        if (flags & ShareableBitmap::SupportsAlpha)
+            info |= kCGImageAlphaPremultipliedLast;
+        else
             info |= kCGImageAlphaNoneSkipLast;
-        else
-            info |= kCGImageAlphaPremultipliedLast;
+        
     } else {
         info |= kCGBitmapByteOrder32Host;
-
-        if (configuration.isOpaque)
+        
+        if (flags & ShareableBitmap::SupportsAlpha)
+            info |= kCGImageAlphaPremultipliedFirst;
+        else
             info |= kCGImageAlphaNoneSkipFirst;
-        else
-            info |= kCGImageAlphaPremultipliedFirst;
     }
-
+    
     return info;
 }
-
-unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration& configuration)
+    
+static CGColorSpaceRef colorSpace(ShareableBitmap::Flags flags)
 {
-    return wantsExtendedRange(configuration) ? 8 : 4;
+    if (flags & ShareableBitmap::SupportsExtendedColor)
+        return extendedSRGBColorSpaceRef();
+    return sRGBColorSpaceRef();
 }
 
 std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
 {
     ref(); // Balanced by deref in releaseBitmapContextData.
-
-    unsigned bytesPerPixel = calculateBytesPerPixel(m_configuration);
-    RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, m_size.width() * bytesPerPixel, colorSpace(m_configuration), bitmapInfo(m_configuration), releaseBitmapContextData, this));
     
+    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));
+    
     ASSERT(bitmapContext.get());
 
     // We want the origin to be in the top left corner so we flip the backing store context.
@@ -122,8 +108,7 @@
 RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider) const
 {
     ASSERT_ARG(dataProvider, dataProvider);
-    unsigned bytesPerPixel = calculateBytesPerPixel(m_configuration);
-    RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), bytesPerPixel * 8 / 4, bytesPerPixel * 8, m_size.width() * bytesPerPixel, colorSpace(m_configuration), bitmapInfo(m_configuration), 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: tags/Safari-605.1.4/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -42,7 +42,7 @@
 
 static void encodeImage(Encoder& encoder, Image& image)
 {
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
     bitmap->createGraphicsContext()->drawImage(image, IntPoint());
 
     ShareableBitmap::Handle handle;

Modified: tags/Safari-605.1.4/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -212,11 +212,8 @@
     ASSERT(!m_acceleratesDrawing);
     std::swap(m_frontBuffer, m_backBuffer);
 
-    if (!m_frontBuffer.bitmap) {
-        ShareableBitmap::Configuration bitmapConfiguration;
-        bitmapConfiguration.isOpaque = m_isOpaque;
-        m_frontBuffer.bitmap = ShareableBitmap::createShareable(expandedScaledSize, bitmapConfiguration);
-    }
+    if (!m_frontBuffer.bitmap)
+        m_frontBuffer.bitmap = ShareableBitmap::createShareable(expandedScaledSize, m_isOpaque ? ShareableBitmap::NoFlags : ShareableBitmap::SupportsAlpha);
 }
 
 bool RemoteLayerBackingStore::display()

Modified: tags/Safari-605.1.4/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -92,7 +92,7 @@
 
     RetainPtr<_WKThumbnailView> thumbnailView = self;
     IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize() - IntSize(0, _webPageProxy->topContentInset()));
-    SnapshotOptions options = SnapshotOptionsInViewCoordinates | SnapshotOptionsUseScreenColorSpace;
+    SnapshotOptions options = SnapshotOptionsInViewCoordinates;
     IntSize bitmapSize = snapshotRect.size();
     bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -130,7 +130,7 @@
     IntSize backingStoreSize = paintRect.size();
     backingStoreSize.scale(scaleFactor);
 
-    RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, { });
+    RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
     if (!backingStore)
         return nullptr;
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -754,7 +754,7 @@
     IntSize backingStoreSize = m_pluginSize;
     backingStoreSize.scale(contentsScaleFactor());
 
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
     auto context = bitmap->createGraphicsContext();
 
     // FIXME: We should really call applyDeviceScaleFactor instead of scale, but that ends up calling into WKSI

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -1246,7 +1246,7 @@
     IntSize backingStoreSize = size();
     backingStoreSize.scale(contentsScaleFactor);
 
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
     auto context = bitmap->createGraphicsContext();
 
     context->scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -270,7 +270,7 @@
 
     if (updateBackingStore()) {
         // Create a new plug-in backing store.
-        m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), { });
+        m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), ShareableBitmap::SupportsAlpha);
         if (!m_pluginBackingStore)
             return;
 
@@ -613,7 +613,7 @@
         m_backingStore = nullptr; // Give malloc a chance to recycle our backing store.
     }
 
-    m_backingStore = ShareableBitmap::create(backingStoreSize, { });
+    m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha);
     return !!m_backingStore;
 }
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -49,7 +49,7 @@
         return nullptr;
 
     IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
     auto graphicsContext = bitmap->createGraphicsContext();
 
     graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), *graphicsContext);

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -41,7 +41,7 @@
 #import <WebCore/Frame.h>
 #import <WebCore/FrameDestructionObserver.h>
 #import <WebCore/FrameView.h>
-#import <WebCore/GraphicsContextCG.h>
+#import <WebCore/GraphicsContext.h>
 #import <WebCore/LegacyWebArchive.h>
 #import <WebCore/MainFrame.h>
 #import <WebCore/NotImplemented.h>
@@ -67,9 +67,12 @@
 
 static RefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
 {
-    ShareableBitmap::Configuration bitmapConfiguration;
-    bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
-    auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
+    ShareableBitmap::Flags flags = ShareableBitmap::SupportsAlpha;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    if (screenSupportsExtendedColor(frame.mainFrame().view()))
+        flags |= ShareableBitmap::SupportsExtendedColor;
+#endif
+    auto bitmap = ShareableBitmap::createShareable(size, flags);
     if (!bitmap)
         return nullptr;
 
@@ -192,9 +195,7 @@
 
 static RefPtr<ShareableBitmap> convertCGImageToBitmap(CGImageRef image, const IntSize& size, Frame& frame)
 {
-    ShareableBitmap::Configuration bitmapConfiguration;
-    bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
-    auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
+    auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha | ShareableBitmap::SupportsExtendedColor);
     if (!bitmap)
         return nullptr;
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -417,7 +417,7 @@
     IntSize bitmapSize = bounds.size();
     float deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
     bitmapSize.scale(deviceScaleFactor);
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, { });
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
     if (!bitmap)
         return;
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebFrame.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebFrame.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -824,7 +824,7 @@
     if (!snapshot)
         return nullptr;
 
-    auto sharedSnapshot = ShareableBitmap::createShareable(snapshot->internalSize(), { });
+    auto sharedSnapshot = ShareableBitmap::createShareable(snapshot->internalSize(), ShareableBitmap::SupportsAlpha);
     if (!sharedSnapshot)
         return nullptr;
 

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebPage.cpp (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-30 19:10:22 UTC (rev 221391)
@@ -1988,16 +1988,6 @@
     }
 }
 
-static ShareableBitmap::Configuration snapshotOptionsToBitmapConfiguration(SnapshotOptions options, WebPage& page)
-{
-    ShareableBitmap::Configuration configuration;
-#if USE(CG)
-    if (options & SnapshotOptionsUseScreenColorSpace)
-        configuration.colorSpace.cgColorSpace = screenColorSpace(page.corePage()->mainFrame().view());
-#endif
-    return configuration;
-}
-
 RefPtr<WebImage> WebPage::snapshotAtSize(const IntRect& rect, const IntSize& bitmapSize, SnapshotOptions options)
 {
     Frame* coreFrame = m_mainFrame->coreFrame();
@@ -2008,9 +1998,7 @@
     if (!frameView)
         return nullptr;
 
-    auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options), snapshotOptionsToBitmapConfiguration(options, *this));
-    if (!snapshot)
-        return nullptr;
+    auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
     auto graphicsContext = snapshot->bitmap().createGraphicsContext();
 
     paintSnapshotAtSize(rect, bitmapSize, options, *coreFrame, *frameView, *graphicsContext);
@@ -2077,9 +2065,8 @@
         snapshotSize = IntSize(snapshotSize.width() * scaleFactor, maximumHeight);
     }
 
-    auto snapshot = WebImage::create(snapshotSize, snapshotOptionsToImageOptions(options), snapshotOptionsToBitmapConfiguration(options, *this));
-    if (!snapshot)
-        return nullptr;
+    auto snapshot = WebImage::create(snapshotSize, snapshotOptionsToImageOptions(options));
+
     auto graphicsContext = snapshot->bitmap().createGraphicsContext();
 
     if (!(options & SnapshotOptionsExcludeDeviceScaleFactor)) {
@@ -4452,7 +4439,7 @@
         ASSERT(coreFrame->document()->printing());
 #endif
 
-        auto bitmap = ShareableBitmap::createShareable(imageSize, { });
+        auto bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
         if (!bitmap) {
             ASSERT_NOT_REACHED();
             return;

Modified: tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (221390 => 221391)


--- tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-08-30 19:10:14 UTC (rev 221390)
+++ tags/Safari-605.1.4/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-08-30 19:10:22 UTC (rev 221391)
@@ -2519,9 +2519,9 @@
                                     FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size();
                                     FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size();
                                     // FIXME: Only select ExtendedColor on images known to need wide gamut
-                                    ShareableBitmap::Configuration bitmapConfiguration;
-                                    bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(m_page->mainFrame().view());
-                                    if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), bitmapConfiguration)) {
+                                    ShareableBitmap::Flags flags = ShareableBitmap::SupportsAlpha;
+                                    flags |= screenSupportsExtendedColor() ? ShareableBitmap::SupportsExtendedColor : 0;
+                                    if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), flags)) {
                                         auto graphicsContext = sharedBitmap->createGraphicsContext();
                                         graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()));
                                         info.image = sharedBitmap;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to