Diff
Modified: trunk/Source/WebCore/ChangeLog (221067 => 221068)
--- trunk/Source/WebCore/ChangeLog 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/ChangeLog 2017-08-23 04:59:30 UTC (rev 221068)
@@ -1,3 +1,22 @@
+2017-08-22 Tim Horton <timothy_hor...@apple.com>
+
+ _WKThumbnailView should use the screen color space instead of sRGB
+ https://bugs.webkit.org/show_bug.cgi?id=175858
+ <rdar://problem/33925559>
+
+ Reviewed by Dean Jackson.
+
+ * platform/PlatformScreen.h:
+ * platform/ios/PlatformScreenIOS.mm:
+ (WebCore::screenColorSpace):
+ * platform/mac/PlatformScreenMac.mm:
+ (WebCore::screenColorSpace):
+ (WebCore::screenSupportsExtendedColor):
+ * platform/win/PlatformScreenWin.cpp:
+ (WebCore::screenColorSpace):
+ Add screenColorSpace, which returns the active color space for the
+ given Widget's screen. On Windows, just fall back to sRGB like we usually do.
+
2017-08-22 Ryosuke Niwa <rn...@webkit.org>
Consolidate the code to normalize MIME type in DataTransfer
Modified: trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (221067 => 221068)
--- trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -188,6 +188,8 @@
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: trunk/Source/WebCore/platform/PlatformScreen.h (221067 => 221068)
--- trunk/Source/WebCore/platform/PlatformScreen.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/platform/PlatformScreen.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -41,6 +41,10 @@
OBJC_CLASS UIScreen;
#endif
+#if USE(CG)
+typedef struct CGColorSpace *CGColorSpaceRef;
+#endif
+
namespace WebCore {
class FloatRect;
@@ -60,6 +64,10 @@
WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* = nullptr);
+#if USE(CG)
+WEBCORE_EXPORT CGColorSpaceRef screenColorSpace(Widget* = nullptr);
+#endif
+
#if PLATFORM(MAC)
NSScreen *screen(NSWindow *);
Modified: trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm (221067 => 221068)
--- trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -30,6 +30,7 @@
#import "FloatRect.h"
#import "FloatSize.h"
#import "FrameView.h"
+#import "GraphicsContextCG.h"
#import "HostWindow.h"
#import "IntRect.h"
#import "WAKWindow.h"
@@ -74,6 +75,11 @@
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: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (221067 => 221068)
--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -134,6 +134,11 @@
return firstScreen();
}
+CGColorSpaceRef screenColorSpace(Widget* widget)
+{
+ return screen(widget).colorSpace.CGColorSpace;
+}
+
bool screenSupportsExtendedColor(Widget* widget)
{
if (!widget)
@@ -142,7 +147,7 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
return [screen(widget) canRepresentDisplayGamut:NSDisplayGamutP3];
#else
- auto colorSpace = screen(widget).colorSpace.CGColorSpace;
+ auto colorSpace = screenColorSpace(widget);
auto iccData = adoptCF(CGColorSpaceCopyICCProfile(colorSpace));
auto profile = "" nullptr));
return profile && ColorSyncProfileIsWideGamut(profile.get());
Modified: trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp (221067 => 221068)
--- trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -30,6 +30,7 @@
#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
+#include "GraphicsContextCG.h"
#include "HostWindow.h"
#include "IntRect.h"
#include "NotImplemented.h"
@@ -100,6 +101,11 @@
return monitorInfo.rcWork;
}
+CGColorSpaceRef screenColorSpace(Widget*)
+{
+ return sRGBColorSpaceRef();
+}
+
bool screenSupportsExtendedColor(Widget*)
{
return false;
Modified: trunk/Source/WebKit/ChangeLog (221067 => 221068)
--- trunk/Source/WebKit/ChangeLog 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/ChangeLog 2017-08-23 04:59:30 UTC (rev 221068)
@@ -1,3 +1,122 @@
+2017-08-22 Tim Horton <timothy_hor...@apple.com>
+
+ _WKThumbnailView should use the screen color space instead of sRGB
+ https://bugs.webkit.org/show_bug.cgi?id=175858
+ <rdar://problem/33925559>
+
+ Reviewed by Dean Jackson.
+
+ Currently, _WKThumbnailView uses software snapshotting via
+ WebPage's takeSnapshot and friends, which always use sRGB.
+ However, it is immediately presented in display space, which
+ causes an expensive color conversion, which could have been avoided
+ if the snapshot was instead originally taken in display space.
+
+ To solve this, add:
+
+ - a mechanism allowing ShareableBitmap to be constructed with a
+ configuration, which can include a color space as well as the
+ existing flags (flipping SupportsAlpha to be IsOpaque instead
+ because most callers want alpha)
+
+ - a WebImage constructor allowing callers to pass a ShareableBitmap
+ configuration through
+
+ - a bit in SnapshotOptions for callers to indicate that they
+ want to snapshot in the display's color space (repurposed
+ from the ExtendedColor bit)
+
+ And then make use of that bit in _WKThumbnailView.
+
+ * Shared/API/c/WKSharedAPICast.h:
+ (WebKit::snapshotOptionsFromImageOptions):
+ Remove this incorrect conversion (WKImageOptions doesn't include
+ kWKSnapshotOptionsExtendedColor).
+
+ (WebKit::toSnapshotOptions):
+ Plumb kWKSnapshotOptionsExtendedColor to WebKit::SnapshotOptions
+ as the "UseScreenColorSpace". Leave the SPI name intact because
+ it has clients, but the difference isn't so huge that it will be
+ a problem.
+
+ * Shared/ImageOptions.h:
+ (WebKit::snapshotOptionsToImageOptions):
+ Remove ImageOptionsExtendedColor, and rename
+ SnapshotOptionsExtendedColor to SnapshotOptionsUseScreenColorSpace.
+
+ * Shared/ShareableBitmap.cpp:
+ (WebKit::ShareableBitmap::Handle::Handle):
+ (WebKit::ShareableBitmap::Handle::encode const):
+ (WebKit::ShareableBitmap::Handle::decode):
+ (WebKit::ShareableBitmap::Handle::clear):
+ (WebKit::ShareableBitmap::Configuration::encode const):
+ (WebKit::ShareableBitmap::Configuration::decode):
+ (WebKit::ShareableBitmap::create):
+ (WebKit::ShareableBitmap::createShareable):
+ (WebKit::ShareableBitmap::createHandle const):
+ (WebKit::ShareableBitmap::ShareableBitmap):
+ (WebKit::ShareableBitmap::calculateBytesPerPixel):
+ (WebKit::calculateBytesPerPixel): Deleted.
+ * Shared/ShareableBitmap.h:
+ (WebKit::ShareableBitmap::numBytesForSize):
+ (WebKit::ShareableBitmap::sizeInBytes const):
+ * Shared/cg/ShareableBitmapCG.cpp:
+ (WebKit::colorSpace):
+ (WebKit::bitmapInfo):
+ (WebKit::ShareableBitmap::calculateBytesPerPixel):
+ (WebKit::ShareableBitmap::createGraphicsContext):
+ (WebKit::ShareableBitmap::createCGImage const):
+ Remove ShareableBitmap's flags parameter, and replace it with
+ a configuration parameter. Configuration is a struct that currently
+ encompasses the newly-flipped IsOpaque bit and (on Cocoa platforms)
+ a platform colorspace object. Compute bytesPerPixel dynamically
+ based on the colorspace and whether it uses extended colors or not.
+
+ * Shared/WebImage.cpp:
+ (WebKit::WebImage::create):
+ * Shared/WebImage.h:
+ Pass ShareableBitmap::Configuration through to the ShareableBitmap
+ constructor, if provided.
+
+ * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+ (-[_WKThumbnailView requestSnapshot]):
+ Make use of the new bit, and use the screen's color space.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::snapshotOptionsToBitmapConfiguration):
+ (WebKit::WebPage::snapshotAtSize):
+ (WebKit::WebPage::snapshotNode):
+ If the snapshot option to use the display color space is set,
+ fill in the colorSpace field in the ShareableBitmap::Configuration
+ with the screen's color space.
+
+ (WebKit::WebPage::drawRectToImage):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::encodeImage):
+ * Shared/ContextMenuContextData.cpp:
+ (WebKit::ContextMenuContextData::ContextMenuContextData):
+ * Shared/mac/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
+ * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+ (WebKit::InjectedBundleRangeHandle::renderedImage):
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::snapshot):
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (WebKit::PDFPlugin::snapshot):
+ * WebProcess/Plugins/PluginProxy.cpp:
+ (WebKit::PluginProxy::geometryDidChange):
+ (WebKit::PluginProxy::updateBackingStore):
+ * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+ (WebKit::convertImageToBitmap):
+ (WebKit::convertCGImageToBitmap):
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::createSelectionSnapshot const):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getPositionInformation):
+ Adopt ShareableBitmap::Configuration. Since IsOpaque
+ defaults to false, all callers who previously constructed
+ ShareableBitmap with SupportsAlpha now don't have to do anything.
+
2017-08-20 Wenson Hsieh <wenson_hs...@apple.com>
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div
Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (221067 => 221068)
--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -930,9 +930,6 @@
if (wkImageOptions & kWKImageOptionsShareable)
snapshotOptions |= SnapshotOptionsShareable;
-
- if (wkImageOptions & kWKSnapshotOptionsExtendedColor)
- snapshotOptions |= SnapshotOptionsExtendedColor;
return snapshotOptions;
}
@@ -955,6 +952,8 @@
snapshotOptions |= SnapshotOptionsForceWhiteText;
if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
snapshotOptions |= SnapshotOptionsPrinting;
+ if (wkSnapshotOptions & kWKSnapshotOptionsExtendedColor)
+ snapshotOptions |= SnapshotOptionsUseScreenColorSpace;
return snapshotOptions;
}
Modified: trunk/Source/WebKit/Shared/ContextMenuContextData.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/ContextMenuContextData.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/ContextMenuContextData.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -64,8 +64,8 @@
if (!image)
return;
- // FIXME: figure out the rounding startegy for ShareableBitmap.
- m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
+ // FIXME: figure out the rounding strategy for ShareableBitmap.
+ m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), { });
m_controlledImage->createGraphicsContext()->drawImage(*image, IntPoint());
#endif
}
Modified: trunk/Source/WebKit/Shared/ImageOptions.h (221067 => 221068)
--- trunk/Source/WebKit/Shared/ImageOptions.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/ImageOptions.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -30,7 +30,6 @@
enum ImageOptions {
ImageOptionsShareable = 1 << 0,
- ImageOptionsExtendedColor = 1 << 1,
};
enum {
@@ -42,11 +41,10 @@
SnapshotOptionsForceBlackText = 1 << 6,
SnapshotOptionsForceWhiteText = 1 << 7,
SnapshotOptionsPrinting = 1 << 8,
- SnapshotOptionsExtendedColor = 1 << 9,
+ SnapshotOptionsUseScreenColorSpace = 1 << 9,
};
typedef uint32_t SnapshotOptions;
-
inline ImageOptions snapshotOptionsToImageOptions(SnapshotOptions snapshotOptions)
{
unsigned imageOptions = 0;
@@ -53,10 +51,6 @@
if (snapshotOptions & SnapshotOptionsShareable)
imageOptions |= ImageOptionsShareable;
-
- if (snapshotOptions & SnapshotOptionsExtendedColor)
- imageOptions |= ImageOptionsExtendedColor;
-
return static_cast<ImageOptions>(imageOptions);
}
Modified: trunk/Source/WebKit/Shared/ShareableBitmap.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/ShareableBitmap.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/ShareableBitmap.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -33,16 +33,8 @@
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)
{
}
@@ -50,7 +42,7 @@
{
encoder << m_handle;
encoder << m_size;
- encoder << m_flags;
+ encoder << m_configuration;
}
bool ShareableBitmap::Handle::decode(IPC::Decoder& decoder, Handle& handle)
@@ -59,9 +51,8 @@
return false;
if (!decoder.decode(handle.m_size))
return false;
- if (!decoder.decode(handle.m_flags))
+ if (!decoder.decode(handle.m_configuration))
return false;
- handle.m_bytesPerPixel = calculateBytesPerPixel(handle.m_flags);
return true;
}
@@ -69,14 +60,31 @@
{
m_handle.clear();
m_size = IntSize();
- m_flags = Flag::NoFlags;
- m_bytesPerPixel = calculateBytesPerPixel(m_flags);
+ m_configuration = { };
}
-RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags)
+void ShareableBitmap::Configuration::encode(IPC::Encoder& encoder) const
{
- unsigned bytesPerPixel = calculateBytesPerPixel(flags);
- auto numBytes = numBytesForSize(size, bytesPerPixel);
+ 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));
if (numBytes.hasOverflowed())
return nullptr;
@@ -84,13 +92,12 @@
if (!tryFastMalloc(numBytes.unsafeGet()).getValue(data))
return nullptr;
- return adoptRef(new ShareableBitmap(size, flags, data));
+ return adoptRef(new ShareableBitmap(size, configuration, data));
}
-RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags)
+RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Configuration configuration)
{
- unsigned bytesPerPixel = calculateBytesPerPixel(flags);
- auto numBytes = numBytesForSize(size, bytesPerPixel);
+ auto numBytes = numBytesForSize(size, calculateBytesPerPixel(configuration));
if (numBytes.hasOverflowed())
return nullptr;
@@ -98,15 +105,14 @@
if (!sharedMemory)
return nullptr;
- return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
+ return adoptRef(new ShareableBitmap(size, configuration, sharedMemory));
}
-RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
+RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Configuration configuration, RefPtr<SharedMemory> sharedMemory)
{
ASSERT(sharedMemory);
- unsigned bytesPerPixel = calculateBytesPerPixel(flags);
- auto numBytes = numBytesForSize(size, bytesPerPixel);
+ auto numBytes = numBytesForSize(size, calculateBytesPerPixel(configuration));
if (numBytes.hasOverflowed())
return nullptr;
if (sharedMemory->size() < numBytes.unsafeGet()) {
@@ -114,7 +120,7 @@
return nullptr;
}
- return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
+ return adoptRef(new ShareableBitmap(size, configuration, sharedMemory));
}
RefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle, SharedMemory::Protection protection)
@@ -124,7 +130,7 @@
if (!sharedMemory)
return nullptr;
- return create(handle.m_size, handle.m_flags, WTFMove(sharedMemory));
+ return create(handle.m_size, handle.m_configuration, WTFMove(sharedMemory));
}
bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection) const
@@ -134,26 +140,23 @@
if (!m_sharedMemory->createHandle(handle.m_handle, protection))
return false;
handle.m_size = m_size;
- handle.m_flags = m_flags;
- handle.m_bytesPerPixel = m_bytesPerPixel;
+ handle.m_configuration = m_configuration;
return true;
}
-ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, void* data)
+ShareableBitmap::ShareableBitmap(const IntSize& size, Configuration configuration, void* data)
: m_size(size)
- , m_flags(flags)
+ , m_configuration(configuration)
, m_data(data)
{
- m_bytesPerPixel = calculateBytesPerPixel(flags);
}
-ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
+ShareableBitmap::ShareableBitmap(const IntSize& size, Configuration configuration, RefPtr<SharedMemory> sharedMemory)
: m_size(size)
- , m_flags(flags)
+ , m_configuration(configuration)
, m_sharedMemory(sharedMemory)
- , m_data(0)
+ , m_data(nullptr)
{
- m_bytesPerPixel = calculateBytesPerPixel(flags);
}
ShareableBitmap::~ShareableBitmap()
@@ -171,4 +174,11 @@
return m_data;
}
+#if !USE(CG)
+unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration&)
+{
+ return 4;
+}
+#endif
+
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/ShareableBitmap.h (221067 => 221068)
--- trunk/Source/WebKit/Shared/ShareableBitmap.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/ShareableBitmap.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -32,6 +32,7 @@
#include <wtf/RefPtr.h>
#if USE(CG)
+#include "ColorSpaceData.h"
#include <wtf/RetainPtr.h>
#endif
@@ -40,8 +41,8 @@
#endif
namespace WebCore {
- class Image;
- class GraphicsContext;
+class Image;
+class GraphicsContext;
}
namespace WebKit {
@@ -48,12 +49,15 @@
class ShareableBitmap : public RefCounted<ShareableBitmap> {
public:
- enum Flag {
- NoFlags = 0,
- SupportsAlpha = 1 << 0,
- SupportsExtendedColor = 1 << 1,
+ struct Configuration {
+ bool isOpaque { false };
+#if PLATFORM(COCOA)
+ ColorSpaceData colorSpace;
+#endif
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Configuration&);
};
- typedef unsigned Flags;
class Handle {
WTF_MAKE_NONCOPYABLE(Handle);
@@ -72,18 +76,17 @@
mutable SharedMemory::Handle m_handle;
WebCore::IntSize m_size;
- Flags m_flags;
- unsigned m_bytesPerPixel;
+ Configuration m_configuration;
};
// Create a shareable bitmap that uses malloced memory.
- static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags);
+ static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Configuration);
// Create a shareable bitmap whose backing memory can be shared with another process.
- static RefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags);
+ static RefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Configuration);
// Create a shareable bitmap from an already existing shared memory block.
- static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
+ static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Configuration, RefPtr<SharedMemory>);
// Create a shareable bitmap from a handle.
static RefPtr<ShareableBitmap> create(const Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite);
@@ -123,8 +126,8 @@
#endif
private:
- ShareableBitmap(const WebCore::IntSize&, Flags, void*);
- ShareableBitmap(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
+ ShareableBitmap(const WebCore::IntSize&, Configuration, void*);
+ ShareableBitmap(const WebCore::IntSize&, Configuration, RefPtr<SharedMemory>);
#if USE(CAIRO)
static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize&);
@@ -147,12 +150,13 @@
#if USE(CAIRO)
size_t sizeInBytes() const { return numBytesForSize(m_size).unsafeGet(); }
#else
- size_t sizeInBytes() const { return numBytesForSize(m_size, m_bytesPerPixel).unsafeGet(); }
+ size_t sizeInBytes() const { return numBytesForSize(m_size, calculateBytesPerPixel(m_configuration)).unsafeGet(); }
#endif
-
+
+ static unsigned calculateBytesPerPixel(const Configuration&);
+
WebCore::IntSize m_size;
- Flags m_flags;
- unsigned m_bytesPerPixel;
+ Configuration m_configuration;
// If the shareable bitmap is backed by shared memory, this points to the shared memory object.
RefPtr<SharedMemory> m_sharedMemory;
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -1119,7 +1119,7 @@
static void encodeImage(Encoder& encoder, Image& image)
{
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
bitmap->createGraphicsContext()->drawImage(image, IntPoint());
ShareableBitmap::Handle handle;
Modified: trunk/Source/WebKit/Shared/WebImage.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/WebImage.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/WebImage.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -26,8 +26,6 @@
#include "config.h"
#include "WebImage.h"
-#include "ShareableBitmap.h"
-
using namespace WebCore;
namespace WebKit {
@@ -34,17 +32,18 @@
RefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
{
- int sharableOptions = ShareableBitmap::SupportsAlpha;
-
- if (options & ImageOptionsExtendedColor)
- sharableOptions |= ShareableBitmap::SupportsExtendedColor;
+ return WebImage::create(size, options, { });
+}
+
+RefPtr<WebImage> WebImage::create(const WebCore::IntSize& size, ImageOptions options, const ShareableBitmap::Configuration& bitmapConfiguration)
+{
if (options & ImageOptionsShareable) {
- auto bitmap = ShareableBitmap::createShareable(size, sharableOptions);
+ auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
if (!bitmap)
return nullptr;
return WebImage::create(bitmap.releaseNonNull());
}
- auto bitmap = ShareableBitmap::create(size, sharableOptions);
+ auto bitmap = ShareableBitmap::create(size, bitmapConfiguration);
if (!bitmap)
return nullptr;
return WebImage::create(bitmap.releaseNonNull());
Modified: trunk/Source/WebKit/Shared/WebImage.h (221067 => 221068)
--- trunk/Source/WebKit/Shared/WebImage.h 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/WebImage.h 2017-08-23 04:59:30 UTC (rev 221068)
@@ -27,6 +27,7 @@
#include "APIObject.h"
#include "ImageOptions.h"
+#include "ShareableBitmap.h"
#include <wtf/Ref.h>
namespace WebCore {
@@ -35,13 +36,12 @@
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: trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -29,6 +29,7 @@
#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"
@@ -35,43 +36,56 @@
using namespace WebCore;
namespace WebKit {
+
+static CGColorSpaceRef colorSpace(const ShareableBitmap::Configuration& configuration)
+{
+ return configuration.colorSpace.cgColorSpace.get() ?: sRGBColorSpaceRef();
+}
-static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags)
+static bool wantsExtendedRange(const ShareableBitmap::Configuration& configuration)
{
+#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 (flags & ShareableBitmap::SupportsExtendedColor) {
+ if (wantsExtendedRange(configuration)) {
info |= kCGBitmapFloatComponents | kCGBitmapByteOrder16Host;
-
- if (flags & ShareableBitmap::SupportsAlpha)
+
+ if (configuration.isOpaque)
+ info |= kCGImageAlphaNoneSkipLast;
+ else
info |= kCGImageAlphaPremultipliedLast;
- else
- info |= kCGImageAlphaNoneSkipLast;
-
} else {
info |= kCGBitmapByteOrder32Host;
-
- if (flags & ShareableBitmap::SupportsAlpha)
+
+ if (configuration.isOpaque)
+ info |= kCGImageAlphaNoneSkipFirst;
+ else
info |= kCGImageAlphaPremultipliedFirst;
- else
- info |= kCGImageAlphaNoneSkipFirst;
}
-
+
return info;
}
-
-static CGColorSpaceRef colorSpace(ShareableBitmap::Flags flags)
+
+unsigned ShareableBitmap::calculateBytesPerPixel(const Configuration& configuration)
{
- if (flags & ShareableBitmap::SupportsExtendedColor)
- return extendedSRGBColorSpaceRef();
- return sRGBColorSpaceRef();
+ return wantsExtendedRange(configuration) ? 8 : 4;
}
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.
@@ -108,7 +122,8 @@
RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider) const
{
ASSERT_ARG(dataProvider, dataProvider);
- 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));
+ 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));
return image;
}
Modified: trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp (221067 => 221068)
--- trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -42,7 +42,7 @@
static void encodeImage(Encoder& encoder, Image& image)
{
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
bitmap->createGraphicsContext()->drawImage(image, IntPoint());
ShareableBitmap::Handle handle;
Modified: trunk/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm (221067 => 221068)
--- trunk/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/Shared/mac/RemoteLayerBackingStore.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -212,8 +212,11 @@
ASSERT(!m_acceleratesDrawing);
std::swap(m_frontBuffer, m_backBuffer);
- if (!m_frontBuffer.bitmap)
- m_frontBuffer.bitmap = ShareableBitmap::createShareable(expandedScaledSize, m_isOpaque ? ShareableBitmap::NoFlags : ShareableBitmap::SupportsAlpha);
+ if (!m_frontBuffer.bitmap) {
+ ShareableBitmap::Configuration bitmapConfiguration;
+ bitmapConfiguration.isOpaque = m_isOpaque;
+ m_frontBuffer.bitmap = ShareableBitmap::createShareable(expandedScaledSize, bitmapConfiguration);
+ }
}
bool RemoteLayerBackingStore::display()
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm (221067 => 221068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -92,7 +92,7 @@
RetainPtr<_WKThumbnailView> thumbnailView = self;
IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize() - IntSize(0, _webPageProxy->topContentInset()));
- SnapshotOptions options = SnapshotOptionsInViewCoordinates;
+ SnapshotOptions options = SnapshotOptionsInViewCoordinates | SnapshotOptionsUseScreenColorSpace;
IntSize bitmapSize = snapshotRect.size();
bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -130,7 +130,7 @@
IntSize backingStoreSize = paintRect.size();
backingStoreSize.scale(scaleFactor);
- RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, { });
if (!backingStore)
return nullptr;
Modified: trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -754,7 +754,7 @@
IntSize backingStoreSize = m_pluginSize;
backingStoreSize.scale(contentsScaleFactor());
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, { });
auto context = bitmap->createGraphicsContext();
// FIXME: We should really call applyDeviceScaleFactor instead of scale, but that ends up calling into WKSI
Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -1246,7 +1246,7 @@
IntSize backingStoreSize = size();
backingStoreSize.scale(contentsScaleFactor);
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, { });
auto context = bitmap->createGraphicsContext();
context->scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
Modified: trunk/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/Plugins/PluginProxy.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -270,7 +270,7 @@
if (updateBackingStore()) {
// Create a new plug-in backing store.
- m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), ShareableBitmap::SupportsAlpha);
+ m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), { });
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, ShareableBitmap::SupportsAlpha);
+ m_backingStore = ShareableBitmap::create(backingStoreSize, { });
return !!m_backingStore;
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -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, ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, { });
auto graphicsContext = bitmap->createGraphicsContext();
graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), *graphicsContext);
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -41,7 +41,7 @@
#import <WebCore/Frame.h>
#import <WebCore/FrameDestructionObserver.h>
#import <WebCore/FrameView.h>
-#import <WebCore/GraphicsContext.h>
+#import <WebCore/GraphicsContextCG.h>
#import <WebCore/LegacyWebArchive.h>
#import <WebCore/MainFrame.h>
#import <WebCore/NotImplemented.h>
@@ -67,12 +67,9 @@
static RefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size, Frame& frame)
{
- 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);
+ ShareableBitmap::Configuration bitmapConfiguration;
+ bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
+ auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
if (!bitmap)
return nullptr;
@@ -195,7 +192,9 @@
static RefPtr<ShareableBitmap> convertCGImageToBitmap(CGImageRef image, const IntSize& size, Frame& frame)
{
- auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha | ShareableBitmap::SupportsExtendedColor);
+ ShareableBitmap::Configuration bitmapConfiguration;
+ bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(frame.mainFrame().view());
+ auto bitmap = ShareableBitmap::createShareable(size, bitmapConfiguration);
if (!bitmap)
return nullptr;
Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -416,7 +416,7 @@
IntSize bitmapSize = bounds.size();
float deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
bitmapSize.scale(deviceScaleFactor);
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, { });
if (!bitmap)
return;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -824,7 +824,7 @@
if (!snapshot)
return nullptr;
- auto sharedSnapshot = ShareableBitmap::createShareable(snapshot->internalSize(), ShareableBitmap::SupportsAlpha);
+ auto sharedSnapshot = ShareableBitmap::createShareable(snapshot->internalSize(), { });
if (!sharedSnapshot)
return nullptr;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2017-08-23 04:59:30 UTC (rev 221068)
@@ -1988,6 +1988,16 @@
}
}
+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();
@@ -1998,7 +2008,9 @@
if (!frameView)
return nullptr;
- auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
+ auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options), snapshotOptionsToBitmapConfiguration(options, *this));
+ if (!snapshot)
+ return nullptr;
auto graphicsContext = snapshot->bitmap().createGraphicsContext();
paintSnapshotAtSize(rect, bitmapSize, options, *coreFrame, *frameView, *graphicsContext);
@@ -2065,8 +2077,9 @@
snapshotSize = IntSize(snapshotSize.width() * scaleFactor, maximumHeight);
}
- auto snapshot = WebImage::create(snapshotSize, snapshotOptionsToImageOptions(options));
-
+ auto snapshot = WebImage::create(snapshotSize, snapshotOptionsToImageOptions(options), snapshotOptionsToBitmapConfiguration(options, *this));
+ if (!snapshot)
+ return nullptr;
auto graphicsContext = snapshot->bitmap().createGraphicsContext();
if (!(options & SnapshotOptionsExcludeDeviceScaleFactor)) {
@@ -4438,7 +4451,7 @@
ASSERT(coreFrame->document()->printing());
#endif
- auto bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
+ auto bitmap = ShareableBitmap::createShareable(imageSize, { });
if (!bitmap) {
ASSERT_NOT_REACHED();
return;
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (221067 => 221068)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2017-08-23 04:54:59 UTC (rev 221067)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2017-08-23 04:59:30 UTC (rev 221068)
@@ -2526,9 +2526,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::Flags flags = ShareableBitmap::SupportsAlpha;
- flags |= screenSupportsExtendedColor() ? ShareableBitmap::SupportsExtendedColor : 0;
- if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), flags)) {
+ ShareableBitmap::Configuration bitmapConfiguration;
+ bitmapConfiguration.colorSpace.cgColorSpace = screenColorSpace(m_page->mainFrame().view());
+ if (RefPtr<ShareableBitmap> sharedBitmap = ShareableBitmap::createShareable(IntSize(bitmapSize), bitmapConfiguration)) {
auto graphicsContext = sharedBitmap->createGraphicsContext();
graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()));
info.image = sharedBitmap;