Title: [202867] trunk/Source
Revision
202867
Author
[email protected]
Date
2016-07-06 11:46:51 -0700 (Wed, 06 Jul 2016)

Log Message

<img> with a wide gamut PDF does not display using a wide gamut color space
https://bugs.webkit.org/show_bug.cgi?id=158983
<rdar://problem/25720247>

Patch by Antoine Quint <[email protected]> on 2016-07-06
Reviewed by Tim Horton.

Source/WebCore:

Calls to ImageBuffer::createCompatibleBuffer() that do not provide an explicit
color space will now infer the color space from the provided graphics context
on platforms using CG. The method signature that takes in a GraphicsContext
without a color space is now split into a CG-specified implementation and a
Cairo one to avoid having diverging platform code in ImageBuffer.cpp.

Some call sites need to provide an explicit color space still, so we add a new
ImageBuffer::createCompatibleBuffer() that allows for that while inferring
sizing and scaling from a GraphicsContext.

All signatures of ImageBuffer::createCompatibleBuffer() are losing the
hasAlpha parameter which was always ignored. All call sites that were using
hasAlpha have been updated.

In addition, we make all the IOSurface and IOSurfacePool code, which is
CG-specific, use the plaform-specific type CGColorSpaceRef instead of ColorSpace
so that we may pick up on the color space copied over from the graphics context
in the CG-specific implementation of ImageBuffer::createCompatibleBuffer().

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal):
* platform/graphics/GradientImage.cpp:
(WebCore::GradientImage::drawPattern):
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
* platform/graphics/ImageBuffer.h:
* platform/graphics/NamedImageGeneratedImage.cpp:
(WebCore::NamedImageGeneratedImage::drawPattern):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::surfaceMatchesParameters):
(WebCore::IOSurfacePool::takeSurface):
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::createCompatibleBuffer):
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::surfaceFromPool):
(WebCore::IOSurface::create):
(WebCore::IOSurface::createFromSendRight):
(WebCore::IOSurface::createFromSurface):
(WebCore::IOSurface::createFromImage):
(WebCore::IOSurface::IOSurface):
(WebCore::IOSurface::ensurePlatformContext):
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
* platform/spi/cg/CoreGraphicsSPI.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintProgressBar):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::bufferForeground):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::drawPatternForContainer):

Source/WebKit2:

ColorSpace parameters have been replaced with CGColorSpaceRef parameters for IOSurface.

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::decode):
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _takeViewSnapshot]):
(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202866 => 202867)


--- trunk/Source/WebCore/ChangeLog	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/ChangeLog	2016-07-06 18:46:51 UTC (rev 202867)
@@ -1,3 +1,69 @@
+2016-07-06  Antoine Quint  <[email protected]>
+
+        <img> with a wide gamut PDF does not display using a wide gamut color space
+        https://bugs.webkit.org/show_bug.cgi?id=158983
+        <rdar://problem/25720247>
+
+        Reviewed by Tim Horton.
+
+        Calls to ImageBuffer::createCompatibleBuffer() that do not provide an explicit
+        color space will now infer the color space from the provided graphics context
+        on platforms using CG. The method signature that takes in a GraphicsContext
+        without a color space is now split into a CG-specified implementation and a
+        Cairo one to avoid having diverging platform code in ImageBuffer.cpp.
+
+        Some call sites need to provide an explicit color space still, so we add a new
+        ImageBuffer::createCompatibleBuffer() that allows for that while inferring
+        sizing and scaling from a GraphicsContext.
+        
+        All signatures of ImageBuffer::createCompatibleBuffer() are losing the
+        hasAlpha parameter which was always ignored. All call sites that were using
+        hasAlpha have been updated.
+
+        In addition, we make all the IOSurface and IOSurfacePool code, which is
+        CG-specific, use the plaform-specific type CGColorSpaceRef instead of ColorSpace
+        so that we may pick up on the color space copied over from the graphics context
+        in the CG-specific implementation of ImageBuffer::createCompatibleBuffer().
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+        * platform/graphics/GradientImage.cpp:
+        (WebCore::GradientImage::drawPattern):
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/NamedImageGeneratedImage.cpp:
+        (WebCore::NamedImageGeneratedImage::drawPattern):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::surfaceMatchesParameters):
+        (WebCore::IOSurfacePool::takeSurface):
+        * platform/graphics/cg/IOSurfacePool.h:
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::createCompatibleBuffer):
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (WebCore::IOSurface::surfaceFromPool):
+        (WebCore::IOSurface::create):
+        (WebCore::IOSurface::createFromSendRight):
+        (WebCore::IOSurface::createFromSurface):
+        (WebCore::IOSurface::createFromImage):
+        (WebCore::IOSurface::IOSurface):
+        (WebCore::IOSurface::ensurePlatformContext):
+        * platform/mac/ThemeMac.mm:
+        (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
+        * platform/spi/cg/CoreGraphicsSPI.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintProgressBar):
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::bufferForeground):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::drawPatternForContainer):
+
 2016-07-06  Tim Horton  <[email protected]>
 
         Long spin editing text at top of message containing Reader version of web page with many GIFs

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (202866 => 202867)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -2457,7 +2457,7 @@
             fontProxy.drawBidiText(*c, textRun, location + offset, FontCascade::UseFallbackIfFontNotReady);
         }
 
-        auto maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), *c);
+        auto maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), ColorSpaceSRGB, *c);
         if (!maskImage)
             return;
 

Modified: trunk/Source/WebCore/platform/graphics/GradientImage.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/GradientImage.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/GradientImage.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -75,7 +75,7 @@
     unsigned generatorHash = m_gradient->hash();
 
     if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !m_cachedImageBuffer->isCompatibleWithContext(destContext)) {
-        m_cachedImageBuffer = ImageBuffer::createCompatibleBuffer(adjustedSize, destContext, m_gradient->hasAlpha());
+        m_cachedImageBuffer = ImageBuffer::createCompatibleBuffer(adjustedSize, ColorSpaceSRGB, destContext);
         if (!m_cachedImageBuffer)
             return;
 

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -164,7 +164,7 @@
 }
 #endif
 
-std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context, bool hasAlpha)
+std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, ColorSpace colorSpace, const GraphicsContext& context)
 {
     if (size.isEmpty())
         return nullptr;
@@ -171,7 +171,7 @@
 
     IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
 
-    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceSRGB, context, hasAlpha);
+    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, colorSpace, context);
     if (!buffer)
         return nullptr;
 
@@ -180,7 +180,7 @@
     return buffer;
 }
 
-std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext& context, bool)
+std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext& context)
 {
     return create(size, context.renderingMode(), resolutionScale, colorSpace);
 }

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2016-07-06 18:46:51 UTC (rev 202867)
@@ -80,8 +80,9 @@
     }
 
     // Create an image buffer compatible with the context, with suitable resolution for drawing into the buffer and then into this context.
-    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, const GraphicsContext&, bool hasAlpha = true);
-    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&, bool hasAlpha);
+    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, const GraphicsContext&);
+    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, ColorSpace, const GraphicsContext&);
+    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&);
 
     static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
     bool isCompatibleWithContext(const GraphicsContext&) const;
@@ -172,6 +173,9 @@
     // This constructor will place its success into the given out-variable
     // so that create() knows when it should return failure.
     WEBCORE_EXPORT ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);
+#if USE(CG)
+    ImageBuffer(const FloatSize&, float resolutionScale, CGColorSpaceRef, RenderingMode, bool& success);
+#endif
 };
 
 #if USE(CG)

Modified: trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -64,7 +64,7 @@
 void NamedImageGeneratedImage::drawPattern(GraphicsContext& context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
 #if USE(NEW_THEME)
-    auto imageBuffer = ImageBuffer::createCompatibleBuffer(size(), context, true);
+    auto imageBuffer = ImageBuffer::createCompatibleBuffer(size(), context);
     if (!imageBuffer)
         return;
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -232,6 +232,11 @@
 {
 }
 
+std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
+{
+    return createCompatibleBuffer(size, ColorSpaceSRGB, context);
+}
+
 GraphicsContext& ImageBuffer::context() const
 {
     return *m_data.m_context;

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -64,7 +64,7 @@
     return pool;
 }
 
-static bool surfaceMatchesParameters(IOSurface& surface, IntSize requestedSize, ColorSpace colorSpace, IOSurface::Format format)
+static bool surfaceMatchesParameters(IOSurface& surface, IntSize requestedSize, CGColorSpaceRef colorSpace, IOSurface::Format format)
 {
     if (format != surface.format())
         return false;
@@ -107,7 +107,7 @@
     m_sizesInPruneOrder.append(size);
 }
 
-std::unique_ptr<IOSurface> IOSurfacePool::takeSurface(IntSize size, ColorSpace colorSpace, IOSurface::Format format)
+std::unique_ptr<IOSurface> IOSurfacePool::takeSurface(IntSize size, CGColorSpaceRef colorSpace, IOSurface::Format format)
 {
     CachedSurfaceMap::iterator mapIter = m_cachedSurfaces.find(size);
 

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2016-07-06 18:46:51 UTC (rev 202867)
@@ -28,7 +28,6 @@
 
 #if USE(IOSURFACE)
 
-#include "ColorSpace.h"
 #include "IOSurface.h"
 #include "IntSize.h"
 #include "IntSizeHash.h"
@@ -48,7 +47,7 @@
 public:
     WEBCORE_EXPORT static IOSurfacePool& sharedPool();
 
-    std::unique_ptr<IOSurface> takeSurface(IntSize, ColorSpace, IOSurface::Format);
+    std::unique_ptr<IOSurface> takeSurface(IntSize, CGColorSpaceRef, IOSurface::Format);
     WEBCORE_EXPORT void addSurface(std::unique_ptr<IOSurface>);
 
     void discardAllSurfaces();

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -70,7 +70,32 @@
     return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
 }
 
-ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool& success)
+std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
+{
+    if (size.isEmpty())
+        return nullptr;
+
+    IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
+    float resolutionScale = context.scaleFactor().width();
+    RetainPtr<CGColorSpaceRef> colorSpace;
+#if PLATFORM(COCOA)
+    colorSpace = adoptCF(CGContextCopyDeviceColorSpace(context.platformContext()));
+#else
+    colorSpace = sRGBColorSpaceRef();
+#endif
+    RenderingMode renderingMode = context.renderingMode();
+    bool success = false;
+    std::unique_ptr<ImageBuffer> buffer(new ImageBuffer(scaledSize, resolutionScale, colorSpace.get(), renderingMode, success));
+
+    if (!success)
+        return nullptr;
+
+    // Set up a corresponding scale factor on the graphics context.
+    buffer->context().scale(FloatSize(scaledSize.width() / size.width(), scaledSize.height() / size.height()));
+    return buffer;
+}
+
+ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, CGColorSpaceRef colorSpace, RenderingMode renderingMode, bool& success)
     : m_logicalSize(size)
     , m_resolutionScale(resolutionScale)
 {
@@ -108,13 +133,13 @@
     ASSERT(renderingMode == Unaccelerated);
 #endif
 
-    m_data.colorSpace = cachedCGColorSpace(imageColorSpace);
+    m_data.colorSpace = colorSpace;
 
     RetainPtr<CGContextRef> cgContext;
     if (accelerateRendering) {
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
         FloatSize userBounds = sizeForDestinationSize(FloatSize(width.unsafeGet(), height.unsafeGet()));
-        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), imageColorSpace);
+        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
         cgContext = m_data.surface->ensurePlatformContext();
         if (cgContext)
             CGContextClearRect(cgContext.get(), FloatRect(FloatPoint(), userBounds));
@@ -151,6 +176,11 @@
     success = true;
 }
 
+ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool& success)
+    : ImageBuffer(size, resolutionScale, cachedCGColorSpace(imageColorSpace), renderingMode, success)
+{
+}
+
 ImageBuffer::~ImageBuffer()
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h	2016-07-06 18:46:51 UTC (rev 202867)
@@ -45,10 +45,10 @@
         RGB10A8,
     };
 
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, ColorSpace, Format = Format::RGBA);
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, IntSize contextSize, ColorSpace, Format = Format::RGBA);
-    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const MachSendRight&, ColorSpace);
-    static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, ColorSpace);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, CGColorSpaceRef, Format = Format::RGBA);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> create(IntSize, IntSize contextSize, CGColorSpaceRef, Format = Format::RGBA);
+    WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromSendRight(const MachSendRight&, CGColorSpaceRef);
+    static std::unique_ptr<IOSurface> createFromSurface(IOSurfaceRef, CGColorSpaceRef);
     WEBCORE_EXPORT static std::unique_ptr<IOSurface> createFromImage(CGImageRef);
     
     static std::unique_ptr<IOSurface> createFromImageBuffer(std::unique_ptr<ImageBuffer>);
@@ -85,7 +85,7 @@
 
     IntSize size() const { return m_size; }
     size_t totalBytes() const { return m_totalBytes; }
-    ColorSpace colorSpace() const { return m_colorSpace; }
+    CGColorSpaceRef colorSpace() const { return m_colorSpace.get(); }
     WEBCORE_EXPORT Format format() const;
 
     WEBCORE_EXPORT bool isInUse() const;
@@ -100,15 +100,15 @@
 #endif
 
 private:
-    IOSurface(IntSize, ColorSpace, Format);
-    IOSurface(IntSize, IntSize contextSize, ColorSpace, Format);
-    IOSurface(IOSurfaceRef, ColorSpace);
+    IOSurface(IntSize, CGColorSpaceRef, Format);
+    IOSurface(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
+    IOSurface(IOSurfaceRef, CGColorSpaceRef);
 
-    static std::unique_ptr<IOSurface> surfaceFromPool(IntSize, IntSize contextSize, ColorSpace, Format);
+    static std::unique_ptr<IOSurface> surfaceFromPool(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
     IntSize contextSize() const { return m_contextSize; }
     void setContextSize(IntSize);
 
-    ColorSpace m_colorSpace;
+    RetainPtr<CGColorSpaceRef> m_colorSpace;
     IntSize m_size;
     IntSize m_contextSize;
     size_t m_totalBytes;

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (202866 => 202867)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-07-06 18:46:51 UTC (rev 202867)
@@ -45,7 +45,7 @@
 
 using namespace WebCore;
 
-inline std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
+inline std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
 {
     auto cachedSurface = IOSurfacePool::sharedPool().takeSurface(size, colorSpace, pixelFormat);
     if (!cachedSurface)
@@ -55,7 +55,7 @@
     return cachedSurface;
 }
 
-std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, ColorSpace colorSpace, Format pixelFormat)
+std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, CGColorSpaceRef colorSpace, Format pixelFormat)
 {
     if (auto cachedSurface = surfaceFromPool(size, size, colorSpace, pixelFormat))
         return cachedSurface;
@@ -63,7 +63,7 @@
     return std::unique_ptr<IOSurface>(new IOSurface(size, colorSpace, pixelFormat));
 }
 
-std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
+std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
 {
     if (auto cachedSurface = surfaceFromPool(size, contextSize, colorSpace, pixelFormat))
         return cachedSurface;
@@ -70,13 +70,13 @@
     return std::unique_ptr<IOSurface>(new IOSurface(size, contextSize, colorSpace, pixelFormat));
 }
 
-std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSendRight(const MachSendRight& sendRight, ColorSpace colorSpace)
+std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSendRight(const MachSendRight& sendRight, CGColorSpaceRef colorSpace)
 {
     auto surface = adoptCF(IOSurfaceLookupFromMachPort(sendRight.sendRight()));
     return IOSurface::createFromSurface(surface.get(), colorSpace);
 }
 
-std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSurface(IOSurfaceRef surface, ColorSpace colorSpace)
+std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSurface(IOSurfaceRef surface, CGColorSpaceRef colorSpace)
 {
     return std::unique_ptr<IOSurface>(new IOSurface(surface, colorSpace));
 }
@@ -89,7 +89,7 @@
     size_t width = CGImageGetWidth(image);
     size_t height = CGImageGetHeight(image);
 
-    auto surface = IOSurface::create(IntSize(width, height), ColorSpaceSRGB);
+    auto surface = IOSurface::create(IntSize(width, height), sRGBColorSpaceRef());
     auto surfaceContext = surface->ensurePlatformContext();
     CGContextDrawImage(surfaceContext, CGRectMake(0, 0, width, height), image);
     CGContextFlush(surfaceContext);
@@ -179,7 +179,7 @@
 
 }
 
-WebCore::IOSurface::IOSurface(IntSize size, ColorSpace colorSpace, Format format)
+WebCore::IOSurface::IOSurface(IntSize size, CGColorSpaceRef colorSpace, Format format)
     : m_colorSpace(colorSpace)
     , m_size(size)
     , m_contextSize(size)
@@ -207,7 +207,7 @@
         NSLog(@"Surface creation failed for options %@", options);
 }
 
-WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
+WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
     : IOSurface(size, colorSpace, pixelFormat)
 {
     ASSERT(contextSize.width() <= size.width());
@@ -215,7 +215,7 @@
     m_contextSize = contextSize;
 }
 
-WebCore::IOSurface::IOSurface(IOSurfaceRef surface, ColorSpace colorSpace)
+WebCore::IOSurface::IOSurface(IOSurfaceRef surface, CGColorSpaceRef colorSpace)
     : m_colorSpace(colorSpace)
     , m_surface(surface)
 {
@@ -297,7 +297,7 @@
         break;
     }
     
-    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_contextSize.width(), m_contextSize.height(), bitsPerComponent, bitsPerPixel, cachedCGColorSpace(m_colorSpace), bitmapInfo));
+    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_contextSize.width(), m_contextSize.height(), bitsPerComponent, bitsPerPixel, m_colorSpace.get(), bitmapInfo));
 
     return m_cgContext.get();
 }

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (202866 => 202867)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2016-07-06 18:46:51 UTC (rev 202867)
@@ -679,7 +679,7 @@
     bool needsRepaint = false;
     if (useImageBuffer) {
         NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height()));
-        auto imageBuffer = ImageBuffer::createCompatibleBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context, false);
+        auto imageBuffer = ImageBuffer::createCompatibleBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context);
         if (!imageBuffer)
             return needsRepaint;
         {

Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (202866 => 202867)


--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h	2016-07-06 18:46:51 UTC (rev 202867)
@@ -188,6 +188,7 @@
 CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
 CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
 CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
+CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef);
 #endif
 
 #if PLATFORM(WIN)

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (202866 => 202867)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -756,7 +756,7 @@
         maskRect.intersect(snappedIntRect(paintInfo.rect));
 
         // Now create the mask.
-        maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), context);
+        maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), ColorSpaceSRGB, context);
         if (!maskImage)
             return;
         paintMaskForTextFillBox(maskImage.get(), maskRect, box, scrolledPaintRect);

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (202866 => 202867)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2016-07-06 18:46:51 UTC (rev 202867)
@@ -1144,7 +1144,7 @@
     trackInfo.reserved = 0;
     trackInfo.filler1 = 0;
 
-    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpaceSRGB, paintInfo.context(), true);
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpaceSRGB, paintInfo.context());
     if (!imageBuffer)
         return true;
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (202866 => 202867)


--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -351,7 +351,7 @@
 
     // Create a new buffer and paint the foreground into it.
     if (!imageBuffer) {
-        if ((imageBuffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(boundingBox.size()), m_paintInfo->context(), true))) {
+        if ((imageBuffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(boundingBox.size()), ColorSpaceSRGB, m_paintInfo->context()))) {
             GraphicsContext& bufferedRenderingContext = imageBuffer->context();
             bufferedRenderingContext.translate(-boundingBox.x(), -boundingBox.y());
             PaintInfo bufferedInfo(*m_paintInfo);

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (202866 => 202867)


--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2016-07-06 18:46:51 UTC (rev 202867)
@@ -219,7 +219,7 @@
     FloatRect imageBufferSize = zoomedContainerRect;
     imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
 
-    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context, true);
+    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context);
     if (!buffer) // Failed to allocate buffer.
         return;
     drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, CompositeSourceOver, BlendModeNormal);

Modified: trunk/Source/WebKit2/ChangeLog (202866 => 202867)


--- trunk/Source/WebKit2/ChangeLog	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-06 18:46:51 UTC (rev 202867)
@@ -1,3 +1,20 @@
+2016-07-06  Antoine Quint  <[email protected]>
+
+        <img> with a wide gamut PDF does not display using a wide gamut color space
+        https://bugs.webkit.org/show_bug.cgi?id=158983
+        <rdar://problem/25720247>
+
+        Reviewed by Tim Horton.
+
+        ColorSpace parameters have been replaced with CGColorSpaceRef parameters for IOSurface.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::decode):
+        (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _takeViewSnapshot]):
+        (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
+
 2016-07-06  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r202725.

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (202866 => 202867)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm	2016-07-06 18:46:51 UTC (rev 202867)
@@ -150,7 +150,7 @@
         MachSendRight sendRight;
         if (!decoder.decode(sendRight))
             return false;
-        result.m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(sendRight, ColorSpaceSRGB);
+        result.m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(sendRight, sRGBColorSpaceRef());
         return true;
     }
 #endif
@@ -210,7 +210,7 @@
         std::swap(m_frontBuffer, m_backBuffer);
 
         if (!m_frontBuffer.surface)
-            m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, ColorSpaceSRGB, bufferFormat(m_isOpaque));
+            m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, sRGBColorSpaceRef(), bufferFormat(m_isOpaque));
 
         setBufferVolatility(BufferType::Front, false);
         return;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (202866 => 202867)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-07-06 18:23:38 UTC (rev 202866)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-07-06 18:46:51 UTC (rev 202867)
@@ -82,6 +82,7 @@
 #import "_WKRemoteObjectRegistryInternal.h"
 #import "_WKSessionStateInternal.h"
 #import "_WKVisitedLinkStoreInternal.h"
+#import <WebCore/GraphicsContextCG.h>
 #import <WebCore/IOSurface.h>
 #import <WebCore/JSDOMBinding.h>
 #import <WebCore/NSTextFinderSPI.h>
@@ -1391,7 +1392,7 @@
 
 #if USE(IOSURFACE)
     WebCore::IOSurface::Format snapshotFormat = WebCore::screenSupportsExtendedColor() ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGBA;
-    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::ColorSpaceSRGB, snapshotFormat);
+    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::sRGBColorSpaceRef(), snapshotFormat);
     CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast<uint64_t>(self.layer), surface->surface(), 0, 0, &transform);
 
     WebCore::IOSurface::Format compressedFormat = WebCore::IOSurface::Format::YUV422;
@@ -4228,7 +4229,7 @@
 #if USE(IOSURFACE)
     // If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
     if (CADisplay *display = self.window.screen._display) {
-        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::ColorSpaceSRGB);
+        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::sRGBColorSpaceRef());
         CGFloat imageScaleInViewCoordinates = imageWidth / rectInViewCoordinates.size.width;
         CATransform3D transform = CATransform3DMakeScale(imageScaleInViewCoordinates, imageScaleInViewCoordinates, 1);
         transform = CATransform3DTranslate(transform, -rectInViewCoordinates.origin.x, -rectInViewCoordinates.origin.y, 0);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to