<!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>[194025] 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/194025">194025</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-12-13 21:27:45 -0800 (Sun, 13 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
https://bugs.webkit.org/show_bug.cgi?id=150988
&lt;rdar://problem/18993594&gt;

Reviewed by Darin Adler.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawConsumingImageBuffer):
* platform/graphics/GraphicsContext.h:
* platform/graphics/ImageBuffer.h:
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::createBitmapImageAfterScalingIfNeeded):
(WebCore::ImageBuffer::copyImage):
(WebCore::ImageBuffer::sinkIntoImage):
(WebCore::ImageBuffer::sinkIntoNativeImage):
(WebCore::ImageBuffer::drawConsuming):
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::createFromImageBuffer):
(IOSurface::sinkIntoImage):
Add sinkIntoImage, sinkIntoNativeImage, and drawConsuming to ImageBuffer,
which all consume the ImageBuffer and allow us to tell the system to
make a CGImage that references the IOSurface, which is in many cases
more efficient than making an image with a &quot;copy&quot; of the IOSurface.
(The copy is done lazily, but we often hit a corner case that causes
it to happen unnecessarily.)

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
* page/TextIndicator.cpp:
(WebCore::takeSnapshot):
* platform/DragImage.cpp:
(WebCore::createDragImageFromSnapshot):
* platform/graphics/filters/FETile.cpp:
(WebCore::FETile::platformApplySoftware):
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::currentFrameImage):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintProgressBar):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildPattern):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::drawPatternForContainer):
Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::imageForCurrentSharingServicePickerItem):
Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createSelectionSnapshot):
Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlElementscpp">trunk/Source/WebCore/html/shadow/MediaControlElements.cpp</a></li>
<li><a href="#trunkSourceWebCorepageTextIndicatorcpp">trunk/Source/WebCore/page/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformDragImagecpp">trunk/Source/WebCore/platform/DragImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBufferh">trunk/Source/WebCore/platform/graphics/ImageBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp">trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp</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="#trunkSourceWebCoreplatformgraphicsfiltersFETilecpp">trunk/Source/WebCore/platform/graphics/filters/FETile.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacThemeMacmm">trunk/Source/WebCore/platform/mac/ThemeMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourcemm">trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm</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="#trunkSourceWebCorerenderingsvgRenderSVGResourcePatterncpp">trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp</a></li>
<li><a href="#trunkSourceWebCoresvggraphicsSVGImagecpp">trunk/Source/WebCore/svg/graphics/SVGImage.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebContextMenuClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebFramecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/ChangeLog        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2015-12-13  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+        https://bugs.webkit.org/show_bug.cgi?id=150988
+        &lt;rdar://problem/18993594&gt;
+
+        Reviewed by Darin Adler.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawConsumingImageBuffer):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::createBitmapImageAfterScalingIfNeeded):
+        (WebCore::ImageBuffer::copyImage):
+        (WebCore::ImageBuffer::sinkIntoImage):
+        (WebCore::ImageBuffer::sinkIntoNativeImage):
+        (WebCore::ImageBuffer::drawConsuming):
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (IOSurface::createFromImageBuffer):
+        (IOSurface::sinkIntoImage):
+        Add sinkIntoImage, sinkIntoNativeImage, and drawConsuming to ImageBuffer,
+        which all consume the ImageBuffer and allow us to tell the system to
+        make a CGImage that references the IOSurface, which is in many cases
+        more efficient than making an image with a &quot;copy&quot; of the IOSurface.
+        (The copy is done lazily, but we often hit a corner case that causes
+        it to happen unnecessarily.)
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
+        * page/TextIndicator.cpp:
+        (WebCore::takeSnapshot):
+        * platform/DragImage.cpp:
+        (WebCore::createDragImageFromSnapshot):
+        * platform/graphics/filters/FETile.cpp:
+        (WebCore::FETile::platformApplySoftware):
+        * platform/mac/ThemeMac.mm:
+        (WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::currentFrameImage):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintProgressBar):
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::buildPattern):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::drawPatternForContainer):
+        Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
</ins><span class="cx"> 2015-12-13  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CachedScript could have a copy-free path for all-ASCII scripts.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlElementscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -1374,7 +1374,7 @@
</span><span class="cx"> 
</span><span class="cx">     layer-&gt;paint(buffer-&gt;context(), paintingRect, LayoutSize(), PaintBehaviorFlattenCompositingLayers, nullptr, RenderLayer::PaintLayerPaintingCompositingAllPhases);
</span><span class="cx"> 
</span><del>-    return buffer-&gt;copyImage();
</del><ins>+    return ImageBuffer::sinkIntoImage(WTF::move(buffer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged(const IntRect&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCorepageTextIndicatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/TextIndicator.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/TextIndicator.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/page/TextIndicator.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx">     if (!buffer)
</span><span class="cx">         return nullptr;
</span><span class="cx">     scaleFactor = buffer-&gt;resolutionScale();
</span><del>-    return buffer-&gt;copyImage(CopyBackingStore, Unscaled);
</del><ins>+    return ImageBuffer::sinkIntoImage(WTF::move(buffer), Unscaled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool takeSnapshots(TextIndicatorData&amp; data, Frame&amp; frame, IntRect snapshotRect)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDragImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DragImage.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DragImage.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/DragImage.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(node);
</span><span class="cx"> #endif
</span><del>-    RefPtr&lt;Image&gt; image = snapshot-&gt;copyImage(ImageBuffer::fastCopyImageMode(), Unscaled);
</del><ins>+    RefPtr&lt;Image&gt; image = ImageBuffer::sinkIntoImage(WTF::move(snapshot), Unscaled);
</ins><span class="cx">     if (!image)
</span><span class="cx">         return nullptr;
</span><span class="cx">     return createDragImageFromImage(image.get(), orientation);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -443,6 +443,33 @@
</span><span class="cx">     image.draw(*this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_useLowQualityScale);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt; image, const FloatPoint&amp; destination, const ImagePaintingOptions&amp; imagePaintingOptions)
+{
+    if (!image)
+        return;
+    IntSize imageLogicalSize = image-&gt;logicalSize();
+    drawConsumingImageBuffer(WTF::move(image), FloatRect(destination, imageLogicalSize), FloatRect(FloatPoint(), imageLogicalSize), imagePaintingOptions);
+}
+
+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt; image, const FloatRect&amp; destination, const ImagePaintingOptions&amp; imagePaintingOptions)
+{
+    if (!image)
+        return;
+    IntSize imageLogicalSize = image-&gt;logicalSize();
+    drawConsumingImageBuffer(WTF::move(image), destination, FloatRect(FloatPoint(), FloatSize(imageLogicalSize)), imagePaintingOptions);
+}
+
+void GraphicsContext::drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt; image, const FloatRect&amp; destination, const FloatRect&amp; source, const ImagePaintingOptions&amp; imagePaintingOptions)
+{
+    if (paintingDisabled() || !image)
+        return;
+    
+    // FIXME (49002): Should be InterpolationLow
+    InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_useLowQualityScale ? InterpolationNone : imageInterpolationQuality());
+
+    ImageBuffer::drawConsuming(WTF::move(image), *this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_useLowQualityScale);
+}
+
</ins><span class="cx"> void GraphicsContext::clip(const IntRect&amp; rect)
</span><span class="cx"> {
</span><span class="cx">     clip(FloatRect(rect));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -315,6 +315,10 @@
</span><span class="cx"> 
</span><span class="cx">     void drawPattern(Image&amp;, const FloatRect&amp; srcRect, const AffineTransform&amp;, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator, const FloatRect&amp; destRect, BlendMode = BlendModeNormal);
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT void drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt;, const FloatPoint&amp; destination, const ImagePaintingOptions&amp; = ImagePaintingOptions());
+    void drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt;, const FloatRect&amp; destination, const ImagePaintingOptions&amp; = ImagePaintingOptions());
+    void drawConsumingImageBuffer(std::unique_ptr&lt;ImageBuffer&gt;, const FloatRect&amp; destination, const FloatRect&amp; source, const ImagePaintingOptions&amp; = ImagePaintingOptions());
+
</ins><span class="cx">     WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
</span><span class="cx">     InterpolationQuality imageInterpolationQuality() const { return m_state.imageInterpolationQuality; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> 
</span><span class="cx"> class ImageBuffer {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
</span><ins>+    friend class IOSurface;
</ins><span class="cx"> public:
</span><span class="cx">     // Will return a null pointer on allocation failure.
</span><span class="cx">     static std::unique_ptr&lt;ImageBuffer&gt; create(const FloatSize&amp; size, RenderingMode renderingMode, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceSRGB)
</span><span class="lines">@@ -91,6 +92,7 @@
</span><span class="cx">     WEBCORE_EXPORT GraphicsContext&amp; context() const;
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT RefPtr&lt;Image&gt; copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavior = Scaled) const;
</span><ins>+    WEBCORE_EXPORT static RefPtr&lt;Image&gt; sinkIntoImage(std::unique_ptr&lt;ImageBuffer&gt;, ScaleBehavior = Scaled);
</ins><span class="cx">     // Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
</span><span class="cx">     // or return CopyBackingStore if it doesn't.  
</span><span class="cx">     static BackingStoreCopy fastCopyImageMode();
</span><span class="lines">@@ -130,6 +132,7 @@
</span><span class="cx">     // The returned image might be larger than the internalSize(). If you want the smaller
</span><span class="cx">     // image, crop the result.
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
</span><ins>+    static RetainPtr&lt;CGImageRef&gt; sinkIntoNativeImage(std::unique_ptr&lt;ImageBuffer&gt;);
</ins><span class="cx">     void flushContext() const;
</span><span class="cx"> #endif
</span><span class="cx">     void clip(GraphicsContext&amp;, const FloatRect&amp;) const;
</span><span class="lines">@@ -137,6 +140,8 @@
</span><span class="cx">     void draw(GraphicsContext&amp;, const FloatRect&amp; destRect, const FloatRect&amp; srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
</span><span class="cx">     void drawPattern(GraphicsContext&amp;, const FloatRect&amp; srcRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator, const FloatRect&amp; destRect, BlendMode = BlendModeNormal);
</span><span class="cx"> 
</span><ins>+    static void drawConsuming(std::unique_ptr&lt;ImageBuffer&gt;, GraphicsContext&amp;, const FloatRect&amp; destRect, const FloatRect&amp; srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
+
</ins><span class="cx">     inline void genericConvertToLuminanceMask();
</span><span class="cx"> 
</span><span class="cx">     friend class GraphicsContext;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoImageBufferCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -195,6 +195,11 @@
</span><span class="cx">     return *m_data.m_context;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;Image&gt; ImageBuffer::sinkIntoImage(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, ScaleBehavior scaleBehavior)
+{
+    return imageBuffer-&gt;copyImage(DontCopyBackingStore, scaleBehavior);
+}
+
</ins><span class="cx"> RefPtr&lt;Image&gt; ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
</span><span class="cx"> {
</span><span class="cx">     if (copyBehavior == CopyBackingStore)
</span><span class="lines">@@ -214,6 +219,11 @@
</span><span class="cx">     context.platformContext()-&gt;pushImageMask(m_data.m_surface.get(), maskRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ImageBuffer::drawConsuming(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
+{
+    imageBuffer-&gt;draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+}
+
</ins><span class="cx"> void ImageBuffer::draw(GraphicsContext&amp; destinationContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect,
</span><span class="cx">     CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/text/Base64.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><ins>+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> #include &quot;WebCoreSystemInterface.h&quot;
</span><span class="cx"> #endif
</span><span class="lines">@@ -177,18 +178,15 @@
</span><span class="cx">     return image;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;Image&gt; ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
</del><ins>+static RefPtr&lt;Image&gt; createBitmapImageAfterScalingIfNeeded(RetainPtr&lt;CGImageRef&gt;&amp;&amp; image, IntSize internalSize, IntSize logicalSize, IntSize backingStoreSize, float resolutionScale, ScaleBehavior scaleBehavior)
</ins><span class="cx"> {
</span><del>-    RetainPtr&lt;CGImageRef&gt; image;
-    if (m_resolutionScale == 1 || scaleBehavior == Unscaled) {
-        image = copyNativeImage(copyBehavior);
-        image = createCroppedImageIfNecessary(image.get(), internalSize());
-    } else {
-        image = copyNativeImage(DontCopyBackingStore);
-        RetainPtr&lt;CGContextRef&gt; context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
</del><ins>+    if (resolutionScale == 1 || scaleBehavior == Unscaled)
+        image = createCroppedImageIfNecessary(image.get(), internalSize);
+    else {
+        RetainPtr&lt;CGContextRef&gt; context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
</ins><span class="cx">         CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
</span><del>-        CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize()));
-        FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize(), m_data.backingStoreSize, internalSize());
</del><ins>+        CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
+        FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize, backingStoreSize, internalSize);
</ins><span class="cx">         CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
</span><span class="cx">         image = adoptCF(CGBitmapContextCreateImage(context.get()));
</span><span class="cx">     }
</span><span class="lines">@@ -199,11 +197,44 @@
</span><span class="cx">     return BitmapImage::create(image.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;Image&gt; ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
+{
+    RetainPtr&lt;CGImageRef&gt; image;
+    if (m_resolutionScale == 1 || scaleBehavior == Unscaled)
+        image = copyNativeImage(copyBehavior);
+    else
+        image = copyNativeImage(DontCopyBackingStore);
+
+    return createBitmapImageAfterScalingIfNeeded(WTF::move(image), internalSize(), logicalSize(), m_data.backingStoreSize, m_resolutionScale, scaleBehavior);
+}
+
+RefPtr&lt;Image&gt; ImageBuffer::sinkIntoImage(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, ScaleBehavior scaleBehavior)
+{
+    IntSize internalSize = imageBuffer-&gt;internalSize();
+    IntSize logicalSize = imageBuffer-&gt;logicalSize();
+    IntSize backingStoreSize = imageBuffer-&gt;m_data.backingStoreSize;
+    float resolutionScale = imageBuffer-&gt;m_resolutionScale;
+
+    return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTF::move(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, scaleBehavior);
+}
+
</ins><span class="cx"> BackingStoreCopy ImageBuffer::fastCopyImageMode()
</span><span class="cx"> {
</span><span class="cx">     return DontCopyBackingStore;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RetainPtr&lt;CGImageRef&gt; ImageBuffer::sinkIntoNativeImage(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer)
+{
+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+    if (!imageBuffer-&gt;m_data.surface)
+        return imageBuffer-&gt;copyNativeImage(DontCopyBackingStore);
+
+    return IOSurface::sinkIntoImage(IOSurface::createFromImageBuffer(WTF::move(imageBuffer)));
+#else
+    return imageBuffer-&gt;copyNativeImage(DontCopyBackingStore);
+#endif
+}
+
</ins><span class="cx"> RetainPtr&lt;CGImageRef&gt; ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; image;
</span><span class="lines">@@ -228,6 +259,29 @@
</span><span class="cx">     return image;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ImageBuffer::drawConsuming(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer, GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
+{
+#if USE(IOSURFACE_CANVAS_BACKING_STORE)
+    if (!imageBuffer-&gt;m_data.surface) {
+        imageBuffer-&gt;draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+        return;
+    }
+    
+    ASSERT(destContext.isAcceleratedContext());
+    
+    float resolutionScale = imageBuffer-&gt;m_resolutionScale;
+    IntSize backingStoreSize = imageBuffer-&gt;m_data.backingStoreSize;
+
+    RetainPtr&lt;CGImageRef&gt; image = IOSurface::sinkIntoImage(IOSurface::createFromImageBuffer(WTF::move(imageBuffer)));
+    
+    FloatRect adjustedSrcRect = srcRect;
+    adjustedSrcRect.scale(resolutionScale, resolutionScale);
+    destContext.drawNativeImage(image.get(), backingStoreSize, destRect, adjustedSrcRect, op, blendMode);
+#else
+    imageBuffer-&gt;draw(destContext, destRect, srcRect, op, blendMode, useLowQualityScale);
+#endif
+}
+
</ins><span class="cx"> void ImageBuffer::draw(GraphicsContext&amp; destContext, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode, bool)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; image;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -50,6 +50,8 @@
</span><span class="cx">     WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; createFromSendRight(const MachSendRight&amp;, ColorSpace);
</span><span class="cx">     static std::unique_ptr&lt;IOSurface&gt; createFromSurface(IOSurfaceRef, ColorSpace);
</span><span class="cx">     WEBCORE_EXPORT static std::unique_ptr&lt;IOSurface&gt; createFromImage(CGImageRef);
</span><ins>+    
+    static std::unique_ptr&lt;IOSurface&gt; createFromImageBuffer(std::unique_ptr&lt;ImageBuffer&gt;);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static void moveToPool(std::unique_ptr&lt;IOSurface&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -60,6 +62,7 @@
</span><span class="cx">     // Any images created from a surface need to be released before releasing
</span><span class="cx">     // the surface, or an expensive GPU readback can result.
</span><span class="cx">     WEBCORE_EXPORT RetainPtr&lt;CGImageRef&gt; createImage();
</span><ins>+    static RetainPtr&lt;CGImageRef&gt; sinkIntoImage(std::unique_ptr&lt;IOSurface&gt;);
</ins><span class="cx"> 
</span><span class="cx">     IOSurfaceRef surface() const { return m_surface.get(); }
</span><span class="cx">     WEBCORE_EXPORT GraphicsContext&amp; ensureGraphicsContext();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -31,12 +31,15 @@
</span><span class="cx"> #import &quot;GraphicsContextCG.h&quot;
</span><span class="cx"> #import &quot;IOSurfacePool.h&quot;
</span><span class="cx"> #import &quot;IOSurfaceSPI.h&quot;
</span><ins>+#import &quot;ImageBuffer.h&quot;
+#import &quot;ImageBufferDataCG.h&quot;
</ins><span class="cx"> #import &quot;MachSendRight.h&quot;
</span><span class="cx"> #import &lt;wtf/Assertions.h&gt;
</span><span class="cx"> 
</span><span class="cx"> extern &quot;C&quot; {
</span><span class="cx"> CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
</span><span class="cx"> CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
</span><ins>+CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -98,6 +101,11 @@
</span><span class="cx">     IOSurfacePool::sharedPool().addSurface(WTF::move(surface));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;IOSurface&gt; IOSurface::createFromImageBuffer(std::unique_ptr&lt;ImageBuffer&gt; imageBuffer)
+{
+    return WTF::move(imageBuffer-&gt;m_data.surface);
+}
+
</ins><span class="cx"> IOSurface::IOSurface(IntSize size, ColorSpace colorSpace, Format format)
</span><span class="cx">     : m_colorSpace(colorSpace)
</span><span class="cx">     , m_size(size)
</span><span class="lines">@@ -244,6 +252,15 @@
</span><span class="cx">     return adoptCF(CGIOSurfaceContextCreateImage(ensurePlatformContext()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RetainPtr&lt;CGImageRef&gt; IOSurface::sinkIntoImage(std::unique_ptr&lt;IOSurface&gt; surface)
+{
+#if (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 100000) || (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101100)
+    return adoptCF(CGIOSurfaceContextCreateImageReference(surface-&gt;ensurePlatformContext()));
+#else
+    return surface-&gt;createImage();
+#endif
+}
+
</ins><span class="cx"> void IOSurface::setContextSize(IntSize contextSize)
</span><span class="cx"> {
</span><span class="cx">     if (contextSize == m_contextSize)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFETilecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FETile.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     tileImageContext.translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
</span><span class="cx">     tileImageContext.drawImageBuffer(*inBuffer, in-&gt;absolutePaintRect().location());
</span><span class="cx"> 
</span><del>-    auto tileImageCopy = tileImage-&gt;copyImage(CopyBackingStore);
</del><ins>+    auto tileImageCopy = ImageBuffer::sinkIntoImage(WTF::move(tileImage));
</ins><span class="cx">     if (!tileImageCopy)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ThemeMac.mm        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -692,7 +692,7 @@
</span><span class="cx">             LocalCurrentGraphicsContext localContext(imageBuffer-&gt;context());
</span><span class="cx">             needsRepaint = drawCellOrFocusRingIntoRectWithView(cell, imageBufferDrawRect, view, drawButtonCell, drawFocusRing);
</span><span class="cx">         }
</span><del>-        context.drawImageBuffer(*imageBuffer, rect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
</del><ins>+        context.drawConsumingImageBuffer(WTF::move(imageBuffer), rect.location() - FloatSize(buttonFocusRectOutlineWidth, buttonFocusRectOutlineWidth));
</ins><span class="cx">         return needsRepaint;
</span><span class="cx">     }
</span><span class="cx">     if (drawButtonCell)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx"> 
</span><span class="cx">     paintCurrentFrameInContext(imageBuffer-&gt;context(), imageRect);
</span><span class="cx"> 
</span><del>-    return imageBuffer-&gt;copyImage();
</del><ins>+    return ImageBuffer::sinkIntoImage(WTF::move(imageBuffer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RetainPtr&lt;CGImageRef&gt; AVVideoCaptureSource::currentFrameCGImage()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -840,7 +840,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (maskImage &amp;&amp; bgLayer-&gt;clip() == TextFillBox) {
</span><del>-        context.drawImageBuffer(*maskImage, maskRect, CompositeDestinationIn);
</del><ins>+        context.drawConsumingImageBuffer(WTF::move(maskImage), maskRect, CompositeDestinationIn);
</ins><span class="cx">         context.endTransparencyLayer();
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeMac.mm        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -1156,7 +1156,7 @@
</span><span class="cx">         paintInfo.context().scale(FloatSize(-1, 1));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    paintInfo.context().drawImageBuffer(*imageBuffer, inflatedRect.location());
</del><ins>+    paintInfo.context().drawConsumingImageBuffer(WTF::move(imageBuffer), inflatedRect.location());
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGResourcePatterncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -113,7 +113,9 @@
</span><span class="cx">     if (!tileImage)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Image&gt; copiedImage = tileImage-&gt;copyImage(CopyBackingStore);
</del><ins>+    const IntSize tileImageSize = tileImage-&gt;logicalSize();
+
+    RefPtr&lt;Image&gt; copiedImage = ImageBuffer::sinkIntoImage(WTF::move(tileImage));
</ins><span class="cx">     if (!copiedImage)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="lines">@@ -122,7 +124,7 @@
</span><span class="cx">     patternData-&gt;pattern = Pattern::create(copiedImage, true, true);
</span><span class="cx"> 
</span><span class="cx">     // Compute pattern space transformation.
</span><del>-    const IntSize tileImageSize = tileImage-&gt;logicalSize();
</del><ins>+
</ins><span class="cx">     patternData-&gt;transform.translate(tileBoundaries.x(), tileBoundaries.y());
</span><span class="cx">     patternData-&gt;transform.scale(tileBoundaries.width() / tileImageSize.width(), tileBoundaries.height() / tileImageSize.height());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoresvggraphicsSVGImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -208,7 +208,7 @@
</span><span class="cx">     if (context.drawLuminanceMask())
</span><span class="cx">         buffer-&gt;convertToLuminanceMask();
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Image&gt; image = buffer-&gt;copyImage(DontCopyBackingStore, Unscaled);
</del><ins>+    RefPtr&lt;Image&gt; image = ImageBuffer::sinkIntoImage(WTF::move(buffer), Unscaled);
</ins><span class="cx">     if (!image)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit/mac/ChangeLog        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-12-13  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+        https://bugs.webkit.org/show_bug.cgi?id=150988
+        &lt;rdar://problem/18993594&gt;
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebContextMenuClient.mm:
+        (WebContextMenuClient::imageForCurrentSharingServicePickerItem):
+        Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
</ins><span class="cx"> 2015-12-11  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] Add a setting to allow the mock media capture devices to be enabled and disabled
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebContextMenuClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -220,7 +220,7 @@
</span><span class="cx">     frameView-&gt;frame().selection().setSelection(oldSelection);
</span><span class="cx">     frameView-&gt;setPaintBehavior(oldPaintBehavior);
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Image&gt; image = buffer-&gt;copyImage(DontCopyBackingStore);
</del><ins>+    RefPtr&lt;Image&gt; image = ImageBuffer::sinkIntoImage(WTF::move(buffer));
</ins><span class="cx">     if (!image)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-12-13  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Adopt CGIOSurfaceContextCreateImageReference to avoid unnecessary readback
+        https://bugs.webkit.org/show_bug.cgi?id=150988
+        &lt;rdar://problem/18993594&gt;
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::createSelectionSnapshot):
+        Adopt sinkIntoImage and drawConsumingImageBuffer in a few places.
+
</ins><span class="cx"> 2015-12-13  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Another fix after r194018.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (194024 => 194025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2015-12-14 04:30:37 UTC (rev 194024)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2015-12-14 05:27:45 UTC (rev 194025)
</span><span class="lines">@@ -826,7 +826,7 @@
</span><span class="cx">     auto graphicsContext = sharedSnapshot-&gt;createGraphicsContext();
</span><span class="cx">     float deviceScaleFactor = coreFrame()-&gt;page()-&gt;deviceScaleFactor();
</span><span class="cx">     graphicsContext-&gt;scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
</span><del>-    graphicsContext-&gt;drawImageBuffer(*snapshot, FloatPoint());
</del><ins>+    graphicsContext-&gt;drawConsumingImageBuffer(WTF::move(snapshot), FloatPoint());
</ins><span class="cx"> 
</span><span class="cx">     return sharedSnapshot.release();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>