<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202927] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202927">202927</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-07 12:32:33 -0700 (Thu, 07 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>&lt;img&gt; with a wide gamut PDF does not display using a wide gamut color space
https://bugs.webkit.org/show_bug.cgi?id=158983
&lt;rdar://problem/25720247&gt;

Patch by Antoine Quint &lt;graouts@apple.com&gt; on 2016-07-07
Reviewed by Dean Jackson.

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/BitmapImage.cpp:
(WebCore::BitmapImage::drawPattern):
* 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:]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGradientImagecpp">trunk/Source/WebCore/platform/graphics/GradientImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBuffercpp">trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBufferh">trunk/Source/WebCore/platform/graphics/ImageBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsNamedImageGeneratedImagecpp">trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp">trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgIOSurfacePoolcpp">trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgIOSurfacePoolh">trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacThemeMacmm">trunk/Source/WebCore/platform/mac/ThemeMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformspicgCoreGraphicsSPIh">trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemeMacmm">trunk/Source/WebCore/rendering/RenderThemeMac.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGRenderingContextcpp">trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCoresvggraphicsSVGImagecpp">trunk/Source/WebCore/svg/graphics/SVGImage.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/ChangeLog        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2016-07-07  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        &lt;img&gt; with a wide gamut PDF does not display using a wide gamut color space
+        https://bugs.webkit.org/show_bug.cgi?id=158983
+        &lt;rdar://problem/25720247&gt;
+
+        Reviewed by Dean Jackson.
+
+        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/BitmapImage.cpp:
+        (WebCore::BitmapImage::drawPattern):
+        * 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):
+
</ins><span class="cx"> 2016-07-07  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         All fullscreen videos should be able the control the controls manager
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -2466,7 +2466,7 @@
</span><span class="cx">             fontProxy.drawBidiText(*c, textRun, location + offset, FontCascade::UseFallbackIfFontNotReady);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        auto maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), *c);
</del><ins>+        auto maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), ColorSpaceSRGB, *c);
</ins><span class="cx">         if (!maskImage)
</span><span class="cx">             return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -606,7 +606,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (!m_cachedImage) {
</span><del>-        auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ctxt);
</del><ins>+        auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ColorSpaceSRGB, ctxt);
</ins><span class="cx">         if (!buffer)
</span><span class="cx">             return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGradientImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GradientImage.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GradientImage.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/GradientImage.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">     unsigned generatorHash = m_gradient-&gt;hash();
</span><span class="cx"> 
</span><span class="cx">     if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !m_cachedImageBuffer-&gt;isCompatibleWithContext(destContext)) {
</span><del>-        m_cachedImageBuffer = ImageBuffer::createCompatibleBuffer(adjustedSize, destContext, m_gradient-&gt;hasAlpha());
</del><ins>+        m_cachedImageBuffer = ImageBuffer::createCompatibleBuffer(adjustedSize, ColorSpaceSRGB, destContext);
</ins><span class="cx">         if (!m_cachedImageBuffer)
</span><span class="cx">             return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, const GraphicsContext&amp; context, bool hasAlpha)
</del><ins>+std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, ColorSpace colorSpace, const GraphicsContext&amp; context)
</ins><span class="cx"> {
</span><span class="cx">     if (size.isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -171,7 +171,7 @@
</span><span class="cx"> 
</span><span class="cx">     IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
</span><span class="cx"> 
</span><del>-    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceSRGB, context, hasAlpha);
</del><ins>+    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, colorSpace, context);
</ins><span class="cx">     if (!buffer)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">     return buffer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext&amp; context, bool)
</del><ins>+std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext&amp; context)
</ins><span class="cx"> {
</span><span class="cx">     return create(size, context.renderingMode(), resolutionScale, colorSpace);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -80,8 +80,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Create an image buffer compatible with the context, with suitable resolution for drawing into the buffer and then into this context.
</span><del>-    static std::unique_ptr&lt;ImageBuffer&gt; createCompatibleBuffer(const FloatSize&amp;, const GraphicsContext&amp;, bool hasAlpha = true);
-    static std::unique_ptr&lt;ImageBuffer&gt; createCompatibleBuffer(const FloatSize&amp;, float resolutionScale, ColorSpace, const GraphicsContext&amp;, bool hasAlpha);
</del><ins>+    static std::unique_ptr&lt;ImageBuffer&gt; createCompatibleBuffer(const FloatSize&amp;, const GraphicsContext&amp;);
+    static std::unique_ptr&lt;ImageBuffer&gt; createCompatibleBuffer(const FloatSize&amp;, ColorSpace, const GraphicsContext&amp;);
+    static std::unique_ptr&lt;ImageBuffer&gt; createCompatibleBuffer(const FloatSize&amp;, float resolutionScale, ColorSpace, const GraphicsContext&amp;);
</ins><span class="cx"> 
</span><span class="cx">     static IntSize compatibleBufferSize(const FloatSize&amp;, const GraphicsContext&amp;);
</span><span class="cx">     bool isCompatibleWithContext(const GraphicsContext&amp;) const;
</span><span class="lines">@@ -172,6 +173,9 @@
</span><span class="cx">     // This constructor will place its success into the given out-variable
</span><span class="cx">     // so that create() knows when it should return failure.
</span><span class="cx">     WEBCORE_EXPORT ImageBuffer(const FloatSize&amp;, float resolutionScale, ColorSpace, RenderingMode, bool&amp; success);
</span><ins>+#if USE(CG)
+    ImageBuffer(const FloatSize&amp;, float resolutionScale, CGColorSpaceRef, RenderingMode, bool&amp; success);
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNamedImageGeneratedImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> void NamedImageGeneratedImage::drawPattern(GraphicsContext&amp; context, const FloatRect&amp; srcRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator compositeOp, const FloatRect&amp; dstRect, BlendMode blendMode)
</span><span class="cx"> {
</span><span class="cx"> #if USE(NEW_THEME)
</span><del>-    auto imageBuffer = ImageBuffer::createCompatibleBuffer(size(), context, true);
</del><ins>+    auto imageBuffer = ImageBuffer::createCompatibleBuffer(size(), context);
</ins><span class="cx">     if (!imageBuffer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -232,6 +232,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, const GraphicsContext&amp; context)
+{
+    return createCompatibleBuffer(size, ColorSpaceSRGB, context);
+}
+
</ins><span class="cx"> GraphicsContext&amp; ImageBuffer::context() const
</span><span class="cx"> {
</span><span class="cx">     return *m_data.m_context;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgIOSurfacePoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     return pool;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool surfaceMatchesParameters(IOSurface&amp; surface, IntSize requestedSize, ColorSpace colorSpace, IOSurface::Format format)
</del><ins>+static bool surfaceMatchesParameters(IOSurface&amp; surface, IntSize requestedSize, CGColorSpaceRef colorSpace, IOSurface::Format format)
</ins><span class="cx"> {
</span><span class="cx">     if (format != surface.format())
</span><span class="cx">         return false;
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">     m_sizesInPruneOrder.append(size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;IOSurface&gt; IOSurfacePool::takeSurface(IntSize size, ColorSpace colorSpace, IOSurface::Format format)
</del><ins>+std::unique_ptr&lt;IOSurface&gt; IOSurfacePool::takeSurface(IntSize size, CGColorSpaceRef colorSpace, IOSurface::Format format)
</ins><span class="cx"> {
</span><span class="cx">     CachedSurfaceMap::iterator mapIter = m_cachedSurfaces.find(size);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgIOSurfacePoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx"> 
</span><del>-#include &quot;ColorSpace.h&quot;
</del><span class="cx"> #include &quot;IOSurface.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><span class="cx"> #include &quot;IntSizeHash.h&quot;
</span><span class="lines">@@ -48,7 +47,7 @@
</span><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT static IOSurfacePool&amp; sharedPool();
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;IOSurface&gt; takeSurface(IntSize, ColorSpace, IOSurface::Format);
</del><ins>+    std::unique_ptr&lt;IOSurface&gt; takeSurface(IntSize, CGColorSpaceRef, IOSurface::Format);
</ins><span class="cx">     WEBCORE_EXPORT void addSurface(std::unique_ptr&lt;IOSurface&gt;);
</span><span class="cx"> 
</span><span class="cx">     void discardAllSurfaces();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -70,7 +70,32 @@
</span><span class="cx">     return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ImageBuffer::ImageBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool&amp; success)
</del><ins>+std::unique_ptr&lt;ImageBuffer&gt; ImageBuffer::createCompatibleBuffer(const FloatSize&amp; size, const GraphicsContext&amp; context)
+{
+    if (size.isEmpty())
+        return nullptr;
+
+    IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
+    float resolutionScale = context.scaleFactor().width();
+    RetainPtr&lt;CGColorSpaceRef&gt; colorSpace;
+#if PLATFORM(COCOA)
+    colorSpace = adoptCF(CGContextCopyDeviceColorSpace(context.platformContext()));
+#else
+    colorSpace = sRGBColorSpaceRef();
+#endif
+    RenderingMode renderingMode = context.renderingMode();
+    bool success = false;
+    std::unique_ptr&lt;ImageBuffer&gt; buffer(new ImageBuffer(scaledSize, resolutionScale, colorSpace.get(), renderingMode, success));
+
+    if (!success)
+        return nullptr;
+
+    // Set up a corresponding scale factor on the graphics context.
+    buffer-&gt;context().scale(FloatSize(scaledSize.width() / size.width(), scaledSize.height() / size.height()));
+    return buffer;
+}
+
+ImageBuffer::ImageBuffer(const FloatSize&amp; size, float resolutionScale, CGColorSpaceRef colorSpace, RenderingMode renderingMode, bool&amp; success)
</ins><span class="cx">     : m_logicalSize(size)
</span><span class="cx">     , m_resolutionScale(resolutionScale)
</span><span class="cx"> {
</span><span class="lines">@@ -108,13 +133,13 @@
</span><span class="cx">     ASSERT(renderingMode == Unaccelerated);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    m_data.colorSpace = cachedCGColorSpace(imageColorSpace);
</del><ins>+    m_data.colorSpace = colorSpace;
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CGContextRef&gt; cgContext;
</span><span class="cx">     if (accelerateRendering) {
</span><span class="cx"> #if USE(IOSURFACE_CANVAS_BACKING_STORE)
</span><span class="cx">         FloatSize userBounds = sizeForDestinationSize(FloatSize(width.unsafeGet(), height.unsafeGet()));
</span><del>-        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), imageColorSpace);
</del><ins>+        m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
</ins><span class="cx">         cgContext = m_data.surface-&gt;ensurePlatformContext();
</span><span class="cx">         if (cgContext)
</span><span class="cx">             CGContextClearRect(cgContext.get(), FloatRect(FloatPoint(), userBounds));
</span><span class="lines">@@ -151,6 +176,11 @@
</span><span class="cx">     success = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ImageBuffer::ImageBuffer(const FloatSize&amp; size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool&amp; success)
+    : ImageBuffer(size, resolutionScale, cachedCGColorSpace(imageColorSpace), renderingMode, success)
+{
+}
+
</ins><span class="cx"> ImageBuffer::~ImageBuffer()
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -45,10 +45,10 @@
</span><span class="cx">         RGB10A8,
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; create(IntSize, ColorSpace, Format = Format::RGBA);
-    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; create(IntSize, IntSize contextSize, ColorSpace, Format = Format::RGBA);
-    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; createFromSendRight(const MachSendRight&amp;, ColorSpace);
-    static std::unique_ptr&lt;IOSurface&gt; createFromSurface(IOSurfaceRef, ColorSpace);
</del><ins>+    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; create(IntSize, CGColorSpaceRef, Format = Format::RGBA);
+    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; create(IntSize, IntSize contextSize, CGColorSpaceRef, Format = Format::RGBA);
+    WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; createFromSendRight(const MachSendRight&amp;, CGColorSpaceRef);
+    static std::unique_ptr&lt;IOSurface&gt; createFromSurface(IOSurfaceRef, CGColorSpaceRef);
</ins><span class="cx">     WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; createFromImage(CGImageRef);
</span><span class="cx">     
</span><span class="cx">     static std::unique_ptr&lt;IOSurface&gt; createFromImageBuffer(std::unique_ptr&lt;ImageBuffer&gt;);
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx">     IntSize size() const { return m_size; }
</span><span class="cx">     size_t totalBytes() const { return m_totalBytes; }
</span><del>-    ColorSpace colorSpace() const { return m_colorSpace; }
</del><ins>+    CGColorSpaceRef colorSpace() const { return m_colorSpace.get(); }
</ins><span class="cx">     WEBCORE_EXPORT Format format() const;
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT bool isInUse() const;
</span><span class="lines">@@ -100,15 +100,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    IOSurface(IntSize, ColorSpace, Format);
-    IOSurface(IntSize, IntSize contextSize, ColorSpace, Format);
-    IOSurface(IOSurfaceRef, ColorSpace);
</del><ins>+    IOSurface(IntSize, CGColorSpaceRef, Format);
+    IOSurface(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
+    IOSurface(IOSurfaceRef, CGColorSpaceRef);
</ins><span class="cx"> 
</span><del>-    static std::unique_ptr&lt;IOSurface&gt; surfaceFromPool(IntSize, IntSize contextSize, ColorSpace, Format);
</del><ins>+    static std::unique_ptr&lt;IOSurface&gt; surfaceFromPool(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
</ins><span class="cx">     IntSize contextSize() const { return m_contextSize; }
</span><span class="cx">     void setContextSize(IntSize);
</span><span class="cx"> 
</span><del>-    ColorSpace m_colorSpace;
</del><ins>+    RetainPtr&lt;CGColorSpaceRef&gt; m_colorSpace;
</ins><span class="cx">     IntSize m_size;
</span><span class="cx">     IntSize m_contextSize;
</span><span class="cx">     size_t m_totalBytes;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-inline std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
</del><ins>+inline std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
</ins><span class="cx"> {
</span><span class="cx">     auto cachedSurface = IOSurfacePool::sharedPool().takeSurface(size, colorSpace, pixelFormat);
</span><span class="cx">     if (!cachedSurface)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">     return cachedSurface;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::create(IntSize size, ColorSpace colorSpace, Format pixelFormat)
</del><ins>+std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::create(IntSize size, CGColorSpaceRef colorSpace, Format pixelFormat)
</ins><span class="cx"> {
</span><span class="cx">     if (auto cachedSurface = surfaceFromPool(size, size, colorSpace, pixelFormat))
</span><span class="cx">         return cachedSurface;
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     return std::unique_ptr&lt;IOSurface&gt;(new IOSurface(size, colorSpace, pixelFormat));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::create(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
</del><ins>+std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::create(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
</ins><span class="cx"> {
</span><span class="cx">     if (auto cachedSurface = surfaceFromPool(size, contextSize, colorSpace, pixelFormat))
</span><span class="cx">         return cachedSurface;
</span><span class="lines">@@ -70,13 +70,13 @@
</span><span class="cx">     return std::unique_ptr&lt;IOSurface&gt;(new IOSurface(size, contextSize, colorSpace, pixelFormat));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::createFromSendRight(const MachSendRight&amp; sendRight, ColorSpace colorSpace)
</del><ins>+std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::createFromSendRight(const MachSendRight&amp; sendRight, CGColorSpaceRef colorSpace)
</ins><span class="cx"> {
</span><span class="cx">     auto surface = adoptCF(IOSurfaceLookupFromMachPort(sendRight.sendRight()));
</span><span class="cx">     return IOSurface::createFromSurface(surface.get(), colorSpace);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::createFromSurface(IOSurfaceRef surface, ColorSpace colorSpace)
</del><ins>+std::unique_ptr&lt;WebCore::IOSurface&gt; WebCore::IOSurface::createFromSurface(IOSurfaceRef surface, CGColorSpaceRef colorSpace)
</ins><span class="cx"> {
</span><span class="cx">     return std::unique_ptr&lt;IOSurface&gt;(new IOSurface(surface, colorSpace));
</span><span class="cx"> }
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx">     size_t width = CGImageGetWidth(image);
</span><span class="cx">     size_t height = CGImageGetHeight(image);
</span><span class="cx"> 
</span><del>-    auto surface = IOSurface::create(IntSize(width, height), ColorSpaceSRGB);
</del><ins>+    auto surface = IOSurface::create(IntSize(width, height), sRGBColorSpaceRef());
</ins><span class="cx">     auto surfaceContext = surface-&gt;ensurePlatformContext();
</span><span class="cx">     CGContextDrawImage(surfaceContext, CGRectMake(0, 0, width, height), image);
</span><span class="cx">     CGContextFlush(surfaceContext);
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebCore::IOSurface::IOSurface(IntSize size, ColorSpace colorSpace, Format format)
</del><ins>+WebCore::IOSurface::IOSurface(IntSize size, CGColorSpaceRef colorSpace, Format format)
</ins><span class="cx">     : m_colorSpace(colorSpace)
</span><span class="cx">     , m_size(size)
</span><span class="cx">     , m_contextSize(size)
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx">         NSLog(@&quot;Surface creation failed for options %@&quot;, options);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, ColorSpace colorSpace, Format pixelFormat)
</del><ins>+WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
</ins><span class="cx">     : IOSurface(size, colorSpace, pixelFormat)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(contextSize.width() &lt;= size.width());
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx">     m_contextSize = contextSize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebCore::IOSurface::IOSurface(IOSurfaceRef surface, ColorSpace colorSpace)
</del><ins>+WebCore::IOSurface::IOSurface(IOSurfaceRef surface, CGColorSpaceRef colorSpace)
</ins><span class="cx">     : m_colorSpace(colorSpace)
</span><span class="cx">     , m_surface(surface)
</span><span class="cx"> {
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_contextSize.width(), m_contextSize.height(), bitsPerComponent, bitsPerPixel, cachedCGColorSpace(m_colorSpace), bitmapInfo));
</del><ins>+    m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_contextSize.width(), m_contextSize.height(), bitsPerComponent, bitsPerPixel, m_colorSpace.get(), bitmapInfo));
</ins><span class="cx"> 
</span><span class="cx">     return m_cgContext.get();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ThemeMac.mm        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -679,7 +679,7 @@
</span><span class="cx">     bool needsRepaint = false;
</span><span class="cx">     if (useImageBuffer) {
</span><span class="cx">         NSRect imageBufferDrawRect = NSRect(FloatRect(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth, rect.width(), rect.height()));
</span><del>-        auto imageBuffer = ImageBuffer::createCompatibleBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context, false);
</del><ins>+        auto imageBuffer = ImageBuffer::createCompatibleBuffer(rect.size() + 2 * FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth), deviceScaleFactor, ColorSpaceSRGB, context);
</ins><span class="cx">         if (!imageBuffer)
</span><span class="cx">             return needsRepaint;
</span><span class="cx">         {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicgCoreGraphicsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -188,6 +188,7 @@
</span><span class="cx"> CGSRegionEnumeratorObj CGSRegionEnumerator(CGRegionRef);
</span><span class="cx"> CGRect* CGSNextRect(const CGSRegionEnumeratorObj);
</span><span class="cx"> CGError CGSReleaseRegionEnumerator(const CGSRegionEnumeratorObj);
</span><ins>+CGColorSpaceRef CGContextCopyDeviceColorSpace(CGContextRef);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -756,7 +756,7 @@
</span><span class="cx">         maskRect.intersect(snappedIntRect(paintInfo.rect));
</span><span class="cx"> 
</span><span class="cx">         // Now create the mask.
</span><del>-        maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), context);
</del><ins>+        maskImage = ImageBuffer::createCompatibleBuffer(maskRect.size(), ColorSpaceSRGB, context);
</ins><span class="cx">         if (!maskImage)
</span><span class="cx">             return;
</span><span class="cx">         paintMaskForTextFillBox(maskImage.get(), maskRect, box, scrolledPaintRect);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -1144,7 +1144,7 @@
</span><span class="cx">     trackInfo.reserved = 0;
</span><span class="cx">     trackInfo.filler1 = 0;
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;ImageBuffer&gt; imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpaceSRGB, paintInfo.context(), true);
</del><ins>+    std::unique_ptr&lt;ImageBuffer&gt; imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpaceSRGB, paintInfo.context());
</ins><span class="cx">     if (!imageBuffer)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -351,7 +351,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Create a new buffer and paint the foreground into it.
</span><span class="cx">     if (!imageBuffer) {
</span><del>-        if ((imageBuffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(boundingBox.size()), m_paintInfo-&gt;context(), true))) {
</del><ins>+        if ((imageBuffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(boundingBox.size()), ColorSpaceSRGB, m_paintInfo-&gt;context()))) {
</ins><span class="cx">             GraphicsContext&amp; bufferedRenderingContext = imageBuffer-&gt;context();
</span><span class="cx">             bufferedRenderingContext.translate(-boundingBox.x(), -boundingBox.y());
</span><span class="cx">             PaintInfo bufferedInfo(*m_paintInfo);
</span></span></pre></div>
<a id="trunkSourceWebCoresvggraphicsSVGImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx">     FloatRect imageBufferSize = zoomedContainerRect;
</span><span class="cx">     imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;ImageBuffer&gt; buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context, true);
</del><ins>+    std::unique_ptr&lt;ImageBuffer&gt; buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context);
</ins><span class="cx">     if (!buffer) // Failed to allocate buffer.
</span><span class="cx">         return;
</span><span class="cx">     drawForContainer(buffer-&gt;context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, CompositeSourceOver, BlendModeNormal);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebKit2/ChangeLog        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-07-07  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        &lt;img&gt; with a wide gamut PDF does not display using a wide gamut color space
+        https://bugs.webkit.org/show_bug.cgi?id=158983
+        &lt;rdar://problem/25720247&gt;
+
+        Reviewed by Dean Jackson.
+
+        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:]):
+
</ins><span class="cx"> 2016-07-07  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Memory corruption destroying PaymentCoordinator
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">         MachSendRight sendRight;
</span><span class="cx">         if (!decoder.decode(sendRight))
</span><span class="cx">             return false;
</span><del>-        result.m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(sendRight, ColorSpaceSRGB);
</del><ins>+        result.m_frontBuffer.surface = WebCore::IOSurface::createFromSendRight(sendRight, sRGBColorSpaceRef());
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="lines">@@ -210,7 +210,7 @@
</span><span class="cx">         std::swap(m_frontBuffer, m_backBuffer);
</span><span class="cx"> 
</span><span class="cx">         if (!m_frontBuffer.surface)
</span><del>-            m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, ColorSpaceSRGB, bufferFormat(m_isOpaque));
</del><ins>+            m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, sRGBColorSpaceRef(), bufferFormat(m_isOpaque));
</ins><span class="cx"> 
</span><span class="cx">         setBufferVolatility(BufferType::Front, false);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (202926 => 202927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-07-07 19:03:27 UTC (rev 202926)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-07-07 19:32:33 UTC (rev 202927)
</span><span class="lines">@@ -82,6 +82,7 @@
</span><span class="cx"> #import &quot;_WKRemoteObjectRegistryInternal.h&quot;
</span><span class="cx"> #import &quot;_WKSessionStateInternal.h&quot;
</span><span class="cx"> #import &quot;_WKVisitedLinkStoreInternal.h&quot;
</span><ins>+#import &lt;WebCore/GraphicsContextCG.h&gt;
</ins><span class="cx"> #import &lt;WebCore/IOSurface.h&gt;
</span><span class="cx"> #import &lt;WebCore/JSDOMBinding.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSTextFinderSPI.h&gt;
</span><span class="lines">@@ -1391,7 +1392,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx">     WebCore::IOSurface::Format snapshotFormat = WebCore::screenSupportsExtendedColor() ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGBA;
</span><del>-    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::ColorSpaceSRGB, snapshotFormat);
</del><ins>+    auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::sRGBColorSpaceRef(), snapshotFormat);
</ins><span class="cx">     CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast&lt;uint64_t&gt;(self.layer), surface-&gt;surface(), 0, 0, &amp;transform);
</span><span class="cx"> 
</span><span class="cx">     WebCore::IOSurface::Format compressedFormat = WebCore::IOSurface::Format::YUV422;
</span><span class="lines">@@ -4228,7 +4229,7 @@
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx">     // If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
</span><span class="cx">     if (CADisplay *display = self.window.screen._display) {
</span><del>-        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::ColorSpaceSRGB);
</del><ins>+        auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::sRGBColorSpaceRef());
</ins><span class="cx">         CGFloat imageScaleInViewCoordinates = imageWidth / rectInViewCoordinates.size.width;
</span><span class="cx">         CATransform3D transform = CATransform3DMakeScale(imageScaleInViewCoordinates, imageScaleInViewCoordinates, 1);
</span><span class="cx">         transform = CATransform3DTranslate(transform, -rectInViewCoordinates.origin.x, -rectInViewCoordinates.origin.y, 0);
</span></span></pre>
</div>
</div>

</body>
</html>