<!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>[170925] 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/170925">170925</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-07-09 12:31:33 -0700 (Wed, 09 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use IOSurface ViewSnapshots everywhere on Mac, remove JPEG encoding path
https://bugs.webkit.org/show_bug.cgi?id=134773

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView _takeViewSnapshot]):
* UIProcess/mac/ViewSnapshotStore.h:
* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::ViewSnapshotStore::ViewSnapshotStore):
(WebKit::ViewSnapshotStore::~ViewSnapshotStore):
(WebKit::ViewSnapshotStore::recordSnapshot):
(WebKit::ViewSnapshot::clearImage):
(WebKit::ViewSnapshot::asLayerContents):
(WebKit::createIOSurfaceFromImage): Deleted.
(WebKit::compressImageAsJPEG): Deleted.
(WebKit::ViewSnapshotStore::reduceSnapshotMemoryCost): Deleted.
(WebKit::ViewSnapshotStore::didCompressSnapshot): Deleted.
Remove all ViewSnapshot(Store) code related to JPEG-encoded snapshots.
Remove the &quot;image&quot; member on ViewSnapshot; Mac will always start out with an IOSurface instead.
Adopt WebCore::IOSurface::createFromImage to make that happen.
Add a comment noting that if a snapshot comes back empty, we should throw it away completely.

* WebCore.exp.in:
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::createFromImage):
Move make-an-IOSurface-from-a-CGImageRef into WebCore::IOSurface.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoreh">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoremm">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebCore/ChangeLog        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-07-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Use IOSurface ViewSnapshots everywhere on Mac, remove JPEG encoding path
+        https://bugs.webkit.org/show_bug.cgi?id=134773
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (IOSurface::createFromImage):
+        Move make-an-IOSurface-from-a-CGImageRef into WebCore::IOSurface.
+
</ins><span class="cx"> 2014-07-09  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement Editor::fontAttributesForSelectionStart() or iOS.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -1479,6 +1479,7 @@
</span><span class="cx"> __ZN7WebCore9HTMLNames9styleAttrE
</span><span class="cx"> __ZN7WebCore9HTMLNames9titleAttrE
</span><span class="cx"> __ZN7WebCore9HTMLNames9valueAttrE
</span><ins>+__ZN7WebCore9IOSurface15createFromImageEP7CGImage
</ins><span class="cx"> __ZN7WebCore9InlineBox14adjustPositionEff
</span><span class="cx"> __ZN7WebCore9InlineBox14dirtyLineBoxesEv
</span><span class="cx"> __ZN7WebCore9InlineBox14selectionStateEv
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx">     static PassRefPtr&lt;IOSurface&gt; create(IntSize, ColorSpace);
</span><span class="cx">     static PassRefPtr&lt;IOSurface&gt; createFromMachPort(mach_port_t, ColorSpace);
</span><span class="cx">     static PassRefPtr&lt;IOSurface&gt; createFromSurface(IOSurfaceRef, ColorSpace);
</span><ins>+    static PassRefPtr&lt;IOSurface&gt; createFromImage(CGImageRef);
</ins><span class="cx"> 
</span><span class="cx">     static IntSize maximumSize();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -70,6 +70,19 @@
</span><span class="cx">     return adoptRef(new IOSurface(surface, colorSpace));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;IOSurface&gt; IOSurface::createFromImage(CGImageRef image)
+{
+    size_t width = CGImageGetWidth(image);
+    size_t height = CGImageGetHeight(image);
+
+    RefPtr&lt;IOSurface&gt; surface = IOSurface::create(IntSize(width, height), ColorSpaceDeviceRGB);
+    auto surfaceContext = surface-&gt;ensurePlatformContext();
+    CGContextDrawImage(surfaceContext, CGRectMake(0, 0, width, height), image);
+    CGContextFlush(surfaceContext);
+
+    return surface.release();
+}
+
</ins><span class="cx"> IOSurface::IOSurface(IntSize size, ColorSpace colorSpace)
</span><span class="cx">     : m_colorSpace(colorSpace)
</span><span class="cx">     , m_size(size)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-07-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Use IOSurface ViewSnapshots everywhere on Mac, remove JPEG encoding path
+        https://bugs.webkit.org/show_bug.cgi?id=134773
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _takeViewSnapshot]):
+        * UIProcess/mac/ViewSnapshotStore.h:
+        * UIProcess/mac/ViewSnapshotStore.mm:
+        (WebKit::ViewSnapshotStore::ViewSnapshotStore):
+        (WebKit::ViewSnapshotStore::~ViewSnapshotStore):
+        (WebKit::ViewSnapshotStore::recordSnapshot):
+        (WebKit::ViewSnapshot::clearImage):
+        (WebKit::ViewSnapshot::asLayerContents):
+        (WebKit::createIOSurfaceFromImage): Deleted.
+        (WebKit::compressImageAsJPEG): Deleted.
+        (WebKit::ViewSnapshotStore::reduceSnapshotMemoryCost): Deleted.
+        (WebKit::ViewSnapshotStore::didCompressSnapshot): Deleted.
+        Remove all ViewSnapshot(Store) code related to JPEG-encoded snapshots.
+        Remove the &quot;image&quot; member on ViewSnapshot; Mac will always start out with an IOSurface instead.
+        Adopt WebCore::IOSurface::createFromImage to make that happen.
+        Add a comment noting that if a snapshot comes back empty, we should throw it away completely.
+
</ins><span class="cx"> 2014-07-09  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RemoteLayerBackingStore::ensureBackingStore should ensure that the entire backing store gets redrawn
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -3141,7 +3141,8 @@
</span><span class="cx"> 
</span><span class="cx">     auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
</span><span class="cx"> 
</span><del>-    snapshot.image = croppedSnapshotImage.get();
</del><ins>+    snapshot.surface = IOSurface::createFromImage(croppedSnapshotImage.get());
+    snapshot.surface-&gt;setIsVolatile(true);
</ins><span class="cx"> 
</span><span class="cx">     IntSize imageSize(CGImageGetWidth(croppedSnapshotImage.get()), CGImageGetHeight(croppedSnapshotImage.get()));
</span><span class="cx">     snapshot.size = imageSize;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -37,17 +37,10 @@
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS CAContext;
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
-#define USE_JPEG_VIEW_SNAPSHOTS false
</del><ins>+#if PLATFORM(MAC)
</ins><span class="cx"> #define USE_IOSURFACE_VIEW_SNAPSHOTS true
</span><span class="cx"> #define USE_RENDER_SERVER_VIEW_SNAPSHOTS false
</span><del>-#elif PLATFORM(MAC)
-// Mountain Lion and before do not support IOSurface purgeability.
-#define USE_JPEG_VIEW_SNAPSHOTS true
-#define USE_IOSURFACE_VIEW_SNAPSHOTS false
-#define USE_RENDER_SERVER_VIEW_SNAPSHOTS false
</del><span class="cx"> #else
</span><del>-#define USE_JPEG_VIEW_SNAPSHOTS false
</del><span class="cx"> #define USE_IOSURFACE_VIEW_SNAPSHOTS false
</span><span class="cx"> #define USE_RENDER_SERVER_VIEW_SNAPSHOTS true
</span><span class="cx"> #endif
</span><span class="lines">@@ -58,9 +51,8 @@
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> 
</span><span class="cx"> struct ViewSnapshot {
</span><del>-#if USE_JPEG_VIEW_SNAPSHOTS || USE_IOSURFACE_VIEW_SNAPSHOTS
</del><ins>+#if USE_IOSURFACE_VIEW_SNAPSHOTS
</ins><span class="cx">     RefPtr&lt;WebCore::IOSurface&gt; surface;
</span><del>-    RetainPtr&lt;CGImageRef&gt; image;
</del><span class="cx"> #endif
</span><span class="cx"> #if USE_RENDER_SERVER_VIEW_SNAPSHOTS
</span><span class="cx">     uint32_t slotID = 0;
</span><span class="lines">@@ -101,13 +93,7 @@
</span><span class="cx"> private:
</span><span class="cx">     void pruneSnapshots(WebPageProxy&amp;);
</span><span class="cx">     void removeSnapshotImage(ViewSnapshot&amp;);
</span><del>-    void reduceSnapshotMemoryCost(const String&amp; uuid);
</del><span class="cx"> 
</span><del>-#if USE_JPEG_VIEW_SNAPSHOTS
-    void didCompressSnapshot(const String&amp; uuid, RetainPtr&lt;CGImageRef&gt; newImage, size_t newImageSize);
-    dispatch_queue_t m_compressionQueue;
-#endif
-
</del><span class="cx">     HashMap&lt;String, ViewSnapshot&gt; m_snapshotMap;
</span><span class="cx"> 
</span><span class="cx">     bool m_enabled;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (170924 => 170925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-07-09 19:11:47 UTC (rev 170924)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-07-09 19:31:33 UTC (rev 170925)
</span><span class="lines">@@ -40,8 +40,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><span class="cx"> static const size_t maximumSnapshotCacheSize = 400 * (1024 * 1024);
</span><del>-#elif USE_JPEG_VIEW_SNAPSHOTS || USE_RENDER_SERVER_VIEW_SNAPSHOTS
-// Because non-IOSurface snapshots are not purgeable, we should keep fewer around.
</del><ins>+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+// Because render server snapshots are not purgeable, we should keep fewer around.
</ins><span class="cx"> static const size_t maximumSnapshotCacheSize = 50 * (1024 * 1024);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -51,16 +51,10 @@
</span><span class="cx">     : m_enabled(true)
</span><span class="cx">     , m_snapshotCacheSize(0)
</span><span class="cx"> {
</span><del>-#if USE_JPEG_VIEW_SNAPSHOTS
-    m_compressionQueue = dispatch_queue_create(&quot;com.apple.WebKit.ViewSnapshotStore.CompressionQueue&quot;, nullptr);
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ViewSnapshotStore::~ViewSnapshotStore()
</span><span class="cx"> {
</span><del>-#if USE_JPEG_VIEW_SNAPSHOTS
-    dispatch_release(m_compressionQueue);
-#endif
</del><span class="cx">     discardSnapshots();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -185,8 +179,6 @@
</span><span class="cx"> 
</span><span class="cx">     m_snapshotMap.add(item-&gt;snapshotUUID(), snapshot);
</span><span class="cx">     m_snapshotCacheSize += snapshot.imageSizeInBytes;
</span><del>-
-    reduceSnapshotMemoryCost(item-&gt;snapshotUUID());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ViewSnapshotStore::getSnapshot(WebBackForwardListItem* item, ViewSnapshot&amp; snapshot)
</span><span class="lines">@@ -207,84 +199,6 @@
</span><span class="cx">         removeSnapshotImage(snapshot);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE_IOSURFACE_VIEW_SNAPSHOTS
-static RefPtr&lt;IOSurface&gt; createIOSurfaceFromImage(CGImageRef image)
-{
-    size_t width = CGImageGetWidth(image);
-    size_t height = CGImageGetHeight(image);
-
-    RefPtr&lt;IOSurface&gt; surface = IOSurface::create(IntSize(width, height), ColorSpaceDeviceRGB);
-    RetainPtr&lt;CGContextRef&gt; surfaceContext = surface-&gt;ensurePlatformContext();
-    CGContextDrawImage(surfaceContext.get(), CGRectMake(0, 0, width, height), image);
-    CGContextFlush(surfaceContext.get());
-
-    surface-&gt;setIsVolatile(true);
-
-    return surface;
-}
-#endif
-
-#if USE_JPEG_VIEW_SNAPSHOTS
-static std::pair&lt;RetainPtr&lt;CGImageRef&gt;, size_t&gt; compressImageAsJPEG(CGImageRef image)
-{
-    RetainPtr&lt;NSData&gt; compressedData = adoptNS([[NSMutableData alloc] init]);
-    RetainPtr&lt;CGImageDestinationRef&gt; destination = adoptCF(CGImageDestinationCreateWithData((CFMutableDataRef)compressedData.get(), kUTTypeJPEG, 1, 0));
-
-    RetainPtr&lt;NSDictionary&gt; options = @{
-        (NSString*)kCGImageDestinationLossyCompressionQuality: @0.9
-    };
-
-    CGImageDestinationAddImage(destination.get(), image, (CFDictionaryRef)options.get());
-    CGImageDestinationFinalize(destination.get());
-
-    RetainPtr&lt;CGImageSourceRef&gt; imageSourceRef = adoptCF(CGImageSourceCreateWithData((CFDataRef)compressedData.get(), 0));
-    RetainPtr&lt;CGImageRef&gt; compressedSnapshot = adoptCF(CGImageSourceCreateImageAtIndex(imageSourceRef.get(), 0, 0));
-    
-    return std::make_pair(compressedSnapshot, [compressedData length]);
-}
-#endif
-
-void ViewSnapshotStore::reduceSnapshotMemoryCost(const String&amp; uuid)
-{
-    const auto&amp; snapshotIterator = m_snapshotMap.find(uuid);
-    if (snapshotIterator == m_snapshotMap.end())
-        return;
-    ViewSnapshot&amp; snapshot = snapshotIterator-&gt;value;
-    if (!snapshot.hasImage())
-        return;
-
-#if USE_IOSURFACE_VIEW_SNAPSHOTS
-    snapshot.surface = createIOSurfaceFromImage(snapshot.image.get());
-    snapshot.image = nullptr;
-#elif USE_JPEG_VIEW_SNAPSHOTS
-    RetainPtr&lt;CGImageRef&gt; originalImage = snapshot.image.get();
-    dispatch_async(m_compressionQueue, [uuid, originalImage] {
-        auto imageAndBytes = compressImageAsJPEG(originalImage.get());
-        dispatch_async(dispatch_get_main_queue(), [uuid, imageAndBytes] {
-            ViewSnapshotStore::shared().didCompressSnapshot(uuid, imageAndBytes.first, imageAndBytes.second);
-        });
-    });
-#endif
-}
-
-#if USE_JPEG_VIEW_SNAPSHOTS
-void ViewSnapshotStore::didCompressSnapshot(const String&amp; uuid, RetainPtr&lt;CGImageRef&gt; newImage, size_t newImageSize)
-{
-    const auto&amp; snapshotIterator = m_snapshotMap.find(uuid);
-    if (snapshotIterator == m_snapshotMap.end())
-        return;
-    ViewSnapshot&amp; snapshot = snapshotIterator-&gt;value;
-
-    size_t originalImageSize = snapshot.imageSizeInBytes;
-    if (!newImage || newImageSize &gt; originalImageSize)
-        return;
-    snapshot.image = newImage;
-    snapshot.imageSizeInBytes = newImageSize;
-    m_snapshotCacheSize += newImageSize;
-    m_snapshotCacheSize -= originalImageSize;
-}
-#endif
-
</del><span class="cx"> bool ViewSnapshot::hasImage() const
</span><span class="cx"> {
</span><span class="cx">     return imageSizeInBytes;
</span><span class="lines">@@ -294,11 +208,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><span class="cx">     surface = nullptr;
</span><del>-#endif
-#if USE_IOSURFACE_VIEW_SNAPSHOTS || USE_JPEG_VIEW_SNAPSHOTS
-    image = nullptr;
-#endif
-#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
</del><ins>+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
</ins><span class="cx">     if (slotID)
</span><span class="cx">         [ViewSnapshotStore::snapshottingContext() deleteSlot:slotID];
</span><span class="cx">     slotID = 0;
</span><span class="lines">@@ -309,17 +219,15 @@
</span><span class="cx"> id ViewSnapshot::asLayerContents()
</span><span class="cx"> {
</span><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><del>-    if (surface) {
-        if (surface-&gt;setIsVolatile(false) != IOSurface::SurfaceState::Valid)
-            return nullptr;
</del><ins>+    if (!surface)
+        return nullptr;
</ins><span class="cx"> 
</span><del>-        return (id)surface-&gt;surface();
-    }
-#endif
-#if USE_IOSURFACE_VIEW_SNAPSHOTS || USE_JPEG_VIEW_SNAPSHOTS
-    return (id)image.get();
-#endif
-#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
</del><ins>+    // FIXME: This should destroy the surface and inform the ViewSnapshotStore to reduce m_snapshotCacheSize.
+    if (surface-&gt;setIsVolatile(false) != IOSurface::SurfaceState::Valid)
+        return nullptr;
+
+    return (id)surface-&gt;surface();
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
</ins><span class="cx">     return [CAContext objectForSlot:slotID];
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>