<!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>[166682] 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/166682">166682</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-04-02 17:33:02 -0700 (Wed, 02 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Pool IOSurfaces to help with allocation cost
https://bugs.webkit.org/show_bug.cgi?id=131096
<rdar://problem/15373942>
Reviewed by Simon Fraser.
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/Timer.h:
(WebCore::TimerBase::startRepeating): Add a std::chrono startRepeating.
* platform/graphics/cg/IOSurfacePool.h: Added.
(WebCore::IOSurfacePool::CachedSurfaceDetails::CachedSurfaceDetails):
(WebCore::IOSurfacePool::CachedSurfaceDetails::resetLastUseTime):
* platform/graphics/cg/ImageBufferBackingStoreCache.cpp: Removed.
* platform/graphics/cg/ImageBufferBackingStoreCache.h: Removed.
* platform/graphics/cg/IOSurfacePool.cpp: Added.
(WebCore::IOSurfacePool::IOSurfacePool):
(WebCore::IOSurfacePool::sharedPool):
(WebCore::surfaceMatchesParameters):
(WebCore::IOSurfacePool::willAddSurface):
(WebCore::IOSurfacePool::didRemoveSurface):
(WebCore::IOSurfacePool::didUseSurfaceOfSize):
(WebCore::IOSurfacePool::takeSurface):
(WebCore::IOSurfacePool::addSurface):
(WebCore::IOSurfacePool::insertSurfaceIntoPool):
(WebCore::IOSurfacePool::setPoolSize):
(WebCore::IOSurfacePool::tryEvictInUseSurface):
(WebCore::IOSurfacePool::tryEvictOldestCachedSurface):
(WebCore::IOSurfacePool::evict):
(WebCore::IOSurfacePool::collectInUseSurfaces):
(WebCore::IOSurfacePool::markOlderSurfacesPurgeable):
(WebCore::IOSurfacePool::collectionTimerFired):
(WebCore::IOSurfacePool::scheduleCollectionTimer):
(WebCore::IOSurfacePool::discardAllSurfaces):
(WebCore::IOSurfacePool::showPoolStatistics):
Add a pool of IOSurfaces. It behaves as such:
- Keeps up to 64MB of surfaces.
- Keeps unused and in-use surfaces (but never gets more than 1/2 full with the latter)
- Marks surfaces purgeable after they've been unused for 2 seconds.
- Tries to move surfaces from the in-use pool to the unused pool every 500ms.
- Evicts in an LRU-ish fashion, interleaving eviction of the oldest
surfaces and the in-use surfaces (since in-use surfaces are not immediately
useful for the pool, but they are desirous because they were recently used).
- Throws everything away under memory pressure.
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::create):
Try to grab a surface from the IOSurfacePool.
* platform/ios/MemoryPressureHandlerIOS.mm:
(WebCore::MemoryPressureHandler::platformReleaseMemory):
* platform/mac/MemoryPressureHandlerMac.mm:
(WebCore::MemoryPressureHandler::install):
(WebCore::MemoryPressureHandler::platformReleaseMemory):
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::platformReleaseMemory):
Fix some includes, and throw away all surfaces when we're under memory pressure.
* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::~RemoteLayerBackingStore):
(WebKit::RemoteLayerBackingStore::clearBackingStore):
(WebKit::RemoteLayerBackingStore::display):
When RemoteLayerBackingStore discards a layer, throw it into the pool.
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
Disable the pool in the UI process.</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="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlercpp">trunk/Source/WebCore/platform/MemoryPressureHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformTimerh">trunk/Source/WebCore/platform/Timer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosMemoryPressureHandlerIOSmm">trunk/Source/WebCore/platform/ios/MemoryPressureHandlerIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacMemoryPressureHandlerMacmm">trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacRemoteLayerTreeDrawingAreaProxymm">trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCachecpp">trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCacheh">trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/ChangeLog        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -1,3 +1,66 @@
</span><ins>+2014-04-02 Tim Horton <timothy_horton@apple.com>
+
+ Pool IOSurfaces to help with allocation cost
+ https://bugs.webkit.org/show_bug.cgi?id=131096
+ <rdar://problem/15373942>
+
+ Reviewed by Simon Fraser.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * platform/Timer.h:
+ (WebCore::TimerBase::startRepeating): Add a std::chrono startRepeating.
+
+ * platform/graphics/cg/IOSurfacePool.h: Added.
+ (WebCore::IOSurfacePool::CachedSurfaceDetails::CachedSurfaceDetails):
+ (WebCore::IOSurfacePool::CachedSurfaceDetails::resetLastUseTime):
+ * platform/graphics/cg/ImageBufferBackingStoreCache.cpp: Removed.
+ * platform/graphics/cg/ImageBufferBackingStoreCache.h: Removed.
+ * platform/graphics/cg/IOSurfacePool.cpp: Added.
+ (WebCore::IOSurfacePool::IOSurfacePool):
+ (WebCore::IOSurfacePool::sharedPool):
+ (WebCore::surfaceMatchesParameters):
+ (WebCore::IOSurfacePool::willAddSurface):
+ (WebCore::IOSurfacePool::didRemoveSurface):
+ (WebCore::IOSurfacePool::didUseSurfaceOfSize):
+ (WebCore::IOSurfacePool::takeSurface):
+ (WebCore::IOSurfacePool::addSurface):
+ (WebCore::IOSurfacePool::insertSurfaceIntoPool):
+ (WebCore::IOSurfacePool::setPoolSize):
+ (WebCore::IOSurfacePool::tryEvictInUseSurface):
+ (WebCore::IOSurfacePool::tryEvictOldestCachedSurface):
+ (WebCore::IOSurfacePool::evict):
+ (WebCore::IOSurfacePool::collectInUseSurfaces):
+ (WebCore::IOSurfacePool::markOlderSurfacesPurgeable):
+ (WebCore::IOSurfacePool::collectionTimerFired):
+ (WebCore::IOSurfacePool::scheduleCollectionTimer):
+ (WebCore::IOSurfacePool::discardAllSurfaces):
+ (WebCore::IOSurfacePool::showPoolStatistics):
+ Add a pool of IOSurfaces. It behaves as such:
+
+ - Keeps up to 64MB of surfaces.
+ - Keeps unused and in-use surfaces (but never gets more than 1/2 full with the latter)
+ - Marks surfaces purgeable after they've been unused for 2 seconds.
+ - Tries to move surfaces from the in-use pool to the unused pool every 500ms.
+ - Evicts in an LRU-ish fashion, interleaving eviction of the oldest
+ surfaces and the in-use surfaces (since in-use surfaces are not immediately
+ useful for the pool, but they are desirous because they were recently used).
+ - Throws everything away under memory pressure.
+
+ * platform/graphics/cocoa/IOSurface.mm:
+ (IOSurface::create):
+ Try to grab a surface from the IOSurfacePool.
+
+ * platform/ios/MemoryPressureHandlerIOS.mm:
+ (WebCore::MemoryPressureHandler::platformReleaseMemory):
+ * platform/mac/MemoryPressureHandlerMac.mm:
+ (WebCore::MemoryPressureHandler::install):
+ (WebCore::MemoryPressureHandler::platformReleaseMemory):
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::platformReleaseMemory):
+ Fix some includes, and throw away all surfaces when we're under memory pressure.
+
</ins><span class="cx"> 2014-04-02 Stephanie Lewis <slewis@apple.com>
</span><span class="cx">
</span><span class="cx"> Roll out http://trac.webkit.org/changeset/166144
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -3077,6 +3077,9 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><ins>+__ZN7WebCore13IOSurfacePool10addSurfaceEPNS_9IOSurfaceE
+__ZN7WebCore13IOSurfacePool10sharedPoolEv
+__ZN7WebCore13IOSurfacePool11setPoolSizeEm
</ins><span class="cx"> __ZN7WebCore9IOSurface11createImageEv
</span><span class="cx"> __ZN7WebCore9IOSurface14setIsPurgeableEb
</span><span class="cx"> __ZN7WebCore9IOSurface18createFromMachPortEjNS_10ColorSpaceE
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -913,8 +913,8 @@
</span><span class="cx">                 1C11CCC80AA6093700DADB20 /* DOMHTMLElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85DF2EEB0AA387CB00AD64C5 /* DOMHTMLElement.h */; };
</span><span class="cx">                 1C18DA58181AF6A500C4EF22 /* TextPainter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */; };
</span><span class="cx">                 1C18DA59181AF6A500C4EF22 /* TextPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C18DA57181AF6A500C4EF22 /* TextPainter.h */; };
</span><del>-                1C21E57C183ED1FF001C289D /* ImageBufferBackingStoreCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C21E57A183ED1FF001C289D /* ImageBufferBackingStoreCache.cpp */; };
-                1C21E57D183ED1FF001C289D /* ImageBufferBackingStoreCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* ImageBufferBackingStoreCache.h */; };
</del><ins>+                1C21E57C183ED1FF001C289D /* IOSurfacePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */; };
+                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
</span><span class="cx">                 1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
</span><span class="cx">                 1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7773,8 +7773,8 @@
</span><span class="cx">                 1AFE11980CBFFCC4003017FA /* JSSQLResultSetRowList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLResultSetRowList.h; sourceTree = "<group>"; };
</span><span class="cx">                 1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPainter.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1C18DA57181AF6A500C4EF22 /* TextPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPainter.h; sourceTree = "<group>"; };
</span><del>-                1C21E57A183ED1FF001C289D /* ImageBufferBackingStoreCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferBackingStoreCache.cpp; sourceTree = "<group>"; };
-                1C21E57B183ED1FF001C289D /* ImageBufferBackingStoreCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBufferBackingStoreCache.h; sourceTree = "<group>"; };
</del><ins>+                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOSurfacePool.cpp; path = ../cg/IOSurfacePool.cpp; sourceTree = "<group>"; };
+                1C21E57B183ED1FF001C289D /* IOSurfacePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOSurfacePool.h; path = ../cg/IOSurfacePool.h; sourceTree = "<group>"; };
</ins><span class="cx">                 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1C4C8EFF0AD85D87009475CE /* DeleteButtonController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteButtonController.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
</span><span class="lines">@@ -19933,8 +19933,6 @@
</span><span class="cx">                                 B2ED97700B1F55CE00257D0F /* GraphicsContextCG.cpp */,
</span><span class="cx">                                 934907E3125BBBC8007F23A0 /* GraphicsContextCG.h */,
</span><span class="cx">                                 A80D67070E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h */,
</span><del>-                                1C21E57A183ED1FF001C289D /* ImageBufferBackingStoreCache.cpp */,
-                                1C21E57B183ED1FF001C289D /* ImageBufferBackingStoreCache.h */,
</del><span class="cx">                                 B2A10B930B3818D700099AA4 /* ImageBufferCG.cpp */,
</span><span class="cx">                                 2292B27B1356669400CF11EF /* ImageBufferDataCG.cpp */,
</span><span class="cx">                                 22BD9F80135364FE009BD102 /* ImageBufferDataCG.h */,
</span><span class="lines">@@ -20320,6 +20318,8 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
</span><span class="cx">                                 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
</span><ins>+                                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */,
+                                1C21E57B183ED1FF001C289D /* IOSurfacePool.h */,
</ins><span class="cx">                                 B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
</span><span class="cx">                         );
</span><span class="cx">                         path = cocoa;
</span><span class="lines">@@ -24144,7 +24144,7 @@
</span><span class="cx">                                 8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */,
</span><span class="cx">                                 B27535700B053814002CE64F /* Image.h in Headers */,
</span><span class="cx">                                 B2A10B920B3818BD00099AA4 /* ImageBuffer.h in Headers */,
</span><del>-                                1C21E57D183ED1FF001C289D /* ImageBufferBackingStoreCache.h in Headers */,
</del><ins>+                                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
</ins><span class="cx">                                 22BD9F7F1353625C009BD102 /* ImageBufferData.h in Headers */,
</span><span class="cx">                                 22BD9F81135364FE009BD102 /* ImageBufferDataCG.h in Headers */,
</span><span class="cx">                                 510192D618B6B9B7007FC7A1 /* ImageControlsRootElement.h in Headers */,
</span><span class="lines">@@ -27544,7 +27544,7 @@
</span><span class="cx">                                 C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */,
</span><span class="cx">                                 B275356F0B053814002CE64F /* Image.cpp in Sources */,
</span><span class="cx">                                 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */,
</span><del>-                                1C21E57C183ED1FF001C289D /* ImageBufferBackingStoreCache.cpp in Sources */,
</del><ins>+                                1C21E57C183ED1FF001C289D /* IOSurfacePool.cpp in Sources */,
</ins><span class="cx">                                 B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */,
</span><span class="cx">                                 2292B27C1356669400CF11EF /* ImageBufferDataCG.cpp in Sources */,
</span><span class="cx">                                 B275355E0B053814002CE64F /* ImageCG.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -96,13 +96,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(MAC)
</span><del>-
</del><span class="cx"> void MemoryPressureHandler::install() { }
</span><span class="cx"> void MemoryPressureHandler::uninstall() { }
</span><span class="cx"> void MemoryPressureHandler::holdOff(unsigned) { }
</span><span class="cx"> void MemoryPressureHandler::respondToMemoryPressure() { }
</span><ins>+#endif
+
+#if !PLATFORM(COCOA)
</ins><span class="cx"> void MemoryPressureHandler::platformReleaseMemory(bool) { }
</span><del>-
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformTimerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Timer.h (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Timer.h        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/Timer.h        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> void start(double nextFireInterval, double repeatInterval);
</span><span class="cx">
</span><span class="cx"> void startRepeating(double repeatInterval) { start(repeatInterval, repeatInterval); }
</span><ins>+ void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(repeatInterval.count() * 0.001); }
</ins><span class="cx"> void startOneShot(double interval) { start(interval, 0); }
</span><span class="cx"> void startOneShot(std::chrono::milliseconds interval) { startOneShot(interval.count() * 0.001); }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgIOSurfacePoolcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (0 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -0,0 +1,357 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IOSurfacePool.h"
+
+#if USE(IOSURFACE)
+
+#include "GraphicsContextCG.h"
+#include "IOSurface.h"
+#include <CoreGraphics/CoreGraphics.h>
+#include <chrono>
+#include <wtf/NeverDestroyed.h>
+
+const std::chrono::milliseconds collectionInterval = 500_ms;
+const std::chrono::seconds surfaceAgeBeforeMarkingPurgeable = 2_s;
+const size_t defaultMaximumBytesCached = 1024 * 1024 * 64;
+
+// We'll never allow more than 1/2 of the cache to be filled with in-use surfaces, because
+// they can't be immediately returned when requested (but will be freed up in the future).
+const size_t maximumInUseBytes = defaultMaximumBytesCached / 2;
+
+#define ENABLE_IOSURFACE_POOL_STATISTICS false
+#if ENABLE_IOSURFACE_POOL_STATISTICS
+#define DUMP_POOL_STATISTICS() do { showPoolStatistics(); } while (0);
+#else
+#define DUMP_POOL_STATISTICS() ((void)0)
+#endif
+
+namespace WebCore {
+
+IOSurfacePool::IOSurfacePool()
+ : m_collectionTimer(this, &IOSurfacePool::collectionTimerFired)
+ , m_bytesCached(0)
+ , m_inUseBytesCached(0)
+ , m_maximumBytesCached(defaultMaximumBytesCached)
+{
+}
+
+IOSurfacePool& IOSurfacePool::sharedPool()
+{
+ static NeverDestroyed<IOSurfacePool> pool;
+ return pool;
+}
+
+static bool surfaceMatchesParameters(IOSurface& surface, const IntSize& requestedSize, ColorSpace colorSpace)
+{
+ IntSize surfaceSize = surface.size();
+ if (colorSpace != surface.colorSpace())
+ return false;
+ if (surfaceSize != requestedSize)
+ return false;
+ return true;
+}
+
+void IOSurfacePool::willAddSurface(IOSurface* surface, bool inUse)
+{
+ CachedSurfaceDetails& details = m_surfaceDetails.add(surface, CachedSurfaceDetails()).iterator->value;
+ details.resetLastUseTime();
+
+ surface->clearGraphicsContext();
+
+ size_t surfaceBytes = surface->totalBytes();
+ m_bytesCached += surfaceBytes;
+ if (inUse)
+ m_inUseBytesCached += surfaceBytes;
+ evict(surface->totalBytes());
+}
+
+void IOSurfacePool::didRemoveSurface(IOSurface* surface, bool inUse)
+{
+ size_t surfaceBytes = surface->totalBytes();
+ m_bytesCached -= surfaceBytes;
+ if (inUse)
+ m_inUseBytesCached -= surfaceBytes;
+
+ m_surfaceDetails.remove(surface);
+}
+
+void IOSurfacePool::didUseSurfaceOfSize(IntSize size)
+{
+ m_sizesInPruneOrder.remove(m_sizesInPruneOrder.reverseFind(size));
+ m_sizesInPruneOrder.append(size);
+}
+
+PassRefPtr<IOSurface> IOSurfacePool::takeSurface(IntSize size, ColorSpace colorSpace)
+{
+ CachedSurfaceMap::iterator mapIter = m_cachedSurfaces.find(size);
+
+ if (mapIter == m_cachedSurfaces.end()) {
+ DUMP_POOL_STATISTICS();
+ return nullptr;
+ }
+
+ for (auto surfaceIter = mapIter->value.begin(); surfaceIter != mapIter->value.end(); ++surfaceIter) {
+ if (!surfaceMatchesParameters(*surfaceIter->get(), size, colorSpace))
+ continue;
+
+ RefPtr<IOSurface> surface = surfaceIter->get();
+ mapIter->value.remove(surfaceIter);
+
+ didUseSurfaceOfSize(size);
+
+ if (mapIter->value.isEmpty()) {
+ m_cachedSurfaces.remove(mapIter);
+ m_sizesInPruneOrder.removeLast();
+ }
+
+ didRemoveSurface(surface.get(), false);
+
+ surface->setIsPurgeable(false);
+
+ DUMP_POOL_STATISTICS();
+ return surface.release();
+ }
+
+ // Some of the in-use surfaces may no longer actually be in-use, but we haven't moved them over yet.
+ for (auto surfaceIter = m_inUseSurfaces.begin(); surfaceIter != m_inUseSurfaces.end(); ++surfaceIter) {
+ if (!surfaceMatchesParameters(*surfaceIter->get(), size, colorSpace))
+ continue;
+ if (surfaceIter->get()->isInUse())
+ continue;
+
+ RefPtr<IOSurface> surface = surfaceIter->get();
+ m_inUseSurfaces.remove(surfaceIter);
+ didRemoveSurface(surface.get(), true);
+
+ surface->setIsPurgeable(false);
+
+ DUMP_POOL_STATISTICS();
+ return surface.release();
+ }
+
+ DUMP_POOL_STATISTICS();
+ return nullptr;
+}
+
+void IOSurfacePool::addSurface(IOSurface* surface)
+{
+ if (surface->totalBytes() > m_maximumBytesCached)
+ return;
+
+ bool surfaceIsInUse = surface->isInUse();
+
+ willAddSurface(surface, surfaceIsInUse);
+
+ if (surfaceIsInUse) {
+ m_inUseSurfaces.prepend(surface);
+ scheduleCollectionTimer();
+ DUMP_POOL_STATISTICS();
+ return;
+ }
+
+ insertSurfaceIntoPool(surface);
+ DUMP_POOL_STATISTICS();
+}
+
+void IOSurfacePool::insertSurfaceIntoPool(IOSurface* surface)
+{
+ auto insertedTuple = m_cachedSurfaces.add(surface->size(), CachedSurfaceQueue());
+ insertedTuple.iterator->value.prepend(surface);
+ if (!insertedTuple.isNewEntry)
+ m_sizesInPruneOrder.remove(m_sizesInPruneOrder.reverseFind(surface->size()));
+ m_sizesInPruneOrder.append(surface->size());
+
+ scheduleCollectionTimer();
+}
+
+void IOSurfacePool::setPoolSize(size_t poolSizeInBytes)
+{
+ m_maximumBytesCached = poolSizeInBytes;
+ evict(0);
+}
+
+void IOSurfacePool::tryEvictInUseSurface()
+{
+ if (m_inUseSurfaces.isEmpty())
+ return;
+
+ RefPtr<IOSurface> surface = m_inUseSurfaces.takeLast();
+ didRemoveSurface(surface.get(), true);
+}
+
+void IOSurfacePool::tryEvictOldestCachedSurface()
+{
+ if (m_cachedSurfaces.isEmpty())
+ return;
+
+ if (m_sizesInPruneOrder.isEmpty())
+ return;
+
+ CachedSurfaceMap::iterator surfaceQueueIter = m_cachedSurfaces.find(m_sizesInPruneOrder.first());
+ ASSERT(!surfaceQueueIter->value.isEmpty());
+ RefPtr<IOSurface> surface = surfaceQueueIter->value.takeLast();
+ didRemoveSurface(surface.get(), false);
+
+ if (surfaceQueueIter->value.isEmpty()) {
+ m_cachedSurfaces.remove(surfaceQueueIter);
+ m_sizesInPruneOrder.remove(0);
+ }
+}
+
+void IOSurfacePool::evict(size_t additionalSize)
+{
+ // FIXME: Perhaps purgeable surfaces should count less against the cap?
+ // We don't want to end up with a ton of empty (purged) surfaces, though, as that would defeat the purpose of the pool.
+ size_t targetSize = m_maximumBytesCached - additionalSize;
+
+ // Interleave eviction of old cached surfaces and more recent in-use surfaces.
+ // In-use surfaces are more recently used, but less useful in the pool, as they aren't
+ // immediately available when requested.
+ while (m_bytesCached > targetSize) {
+ tryEvictOldestCachedSurface();
+
+ if (m_inUseBytesCached > maximumInUseBytes)
+ tryEvictInUseSurface();
+ }
+
+ while (m_inUseBytesCached > maximumInUseBytes)
+ tryEvictInUseSurface();
+}
+
+void IOSurfacePool::collectInUseSurfaces()
+{
+ CachedSurfaceQueue newInUseSurfaces;
+ for (CachedSurfaceQueue::iterator surfaceIter = m_inUseSurfaces.begin(); surfaceIter != m_inUseSurfaces.end(); ++surfaceIter) {
+ IOSurface* surface = surfaceIter->get();
+ if (surface->isInUse()) {
+ newInUseSurfaces.append(*surfaceIter);
+ continue;
+ }
+
+ m_inUseBytesCached -= surface->totalBytes();
+ insertSurfaceIntoPool(surface);
+ }
+
+ m_inUseSurfaces = newInUseSurfaces;
+}
+
+bool IOSurfacePool::markOlderSurfacesPurgeable()
+{
+ bool markedAllSurfaces = true;
+ auto markTime = std::chrono::steady_clock::now();
+
+ for (auto& surfaceAndDetails : m_surfaceDetails) {
+ if (surfaceAndDetails.value.hasMarkedPurgeable)
+ continue;
+
+ if (markTime - surfaceAndDetails.value.lastUseTime < surfaceAgeBeforeMarkingPurgeable) {
+ markedAllSurfaces = false;
+ continue;
+ }
+
+ surfaceAndDetails.key->setIsPurgeable(true);
+ surfaceAndDetails.value.hasMarkedPurgeable = true;
+ }
+
+ return markedAllSurfaces;
+}
+
+void IOSurfacePool::collectionTimerFired(Timer<IOSurfacePool>&)
+{
+ collectInUseSurfaces();
+ bool markedAllSurfaces = markOlderSurfacesPurgeable();
+
+ if (!m_inUseSurfaces.size() && markedAllSurfaces)
+ m_collectionTimer.stop();
+
+ DUMP_POOL_STATISTICS();
+}
+
+void IOSurfacePool::scheduleCollectionTimer()
+{
+ if (!m_collectionTimer.isActive())
+ m_collectionTimer.startRepeating(collectionInterval);
+}
+
+void IOSurfacePool::discardAllSurfaces()
+{
+ m_bytesCached = 0;
+ m_inUseBytesCached = 0;
+ m_surfaceDetails.clear();
+ m_cachedSurfaces.clear();
+ m_inUseSurfaces.clear();
+ m_sizesInPruneOrder.clear();
+ m_collectionTimer.stop();
+}
+
+void IOSurfacePool::showPoolStatistics()
+{
+#if ENABLE_IOSURFACE_POOL_STATISTICS
+ WTFLogAlways("IOSurfacePool Statistics\n");
+ unsigned totalSurfaces = 0;
+ size_t totalSize = 0;
+ size_t totalPurgeableSize = 0;
+
+ for (const auto& keyAndSurfaces : m_cachedSurfaces) {
+ ASSERT(!keyAndSurfaces.value.isEmpty());
+ size_t queueSize = 0;
+ size_t queuePurgeableSize = 0;
+ for (const auto& surface : keyAndSurfaces.value) {
+ size_t surfaceBytes = surface->totalBytes();
+
+ totalSurfaces++;
+ queueSize += surfaceBytes;
+
+ if (surface->isPurgeable())
+ queuePurgeableSize += surfaceBytes;
+ }
+
+ totalSize += queueSize;
+ totalPurgeableSize += queuePurgeableSize;
+
+ WTFLogAlways(" %d x %d: %zu surfaces for %zd KB (%zd KB purgeable)", keyAndSurfaces.key.width(), keyAndSurfaces.key.height(), keyAndSurfaces.value.size(), queueSize / 1024, queuePurgeableSize / 1024);
+ }
+
+ size_t inUseSize = 0;
+ for (const auto& surface : m_inUseSurfaces) {
+ totalSurfaces++;
+ inUseSize += surface->totalBytes();
+ }
+
+ totalSize += inUseSize;
+ WTFLogAlways(" IN USE: %zu surfaces for %zd KB", m_inUseSurfaces.size(), inUseSize / 1024);
+
+ // FIXME: Should move consistency checks elsewhere, and always perform them in debug builds.
+ ASSERT(m_bytesCached == totalSize);
+ ASSERT(m_bytesCached <= m_maximumBytesCached);
+
+ WTFLogAlways(" TOTAL: %d surfaces for %zd KB (%zd KB purgeable)\n", totalSurfaces, totalSize / 1024, totalPurgeableSize / 1024);
+#endif
+}
+
+}
+#endif // USE(IOSURFACE)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgIOSurfacePoolh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (0 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IOSurfacePool_h
+#define IOSurfacePool_h
+
+#include "ColorSpace.h"
+#include "IntSize.h"
+#include "IntSizeHash.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/RetainPtr.h>
+
+#if USE(IOSURFACE)
+
+namespace WebCore {
+
+class IOSurface;
+
+class IOSurfacePool {
+ WTF_MAKE_NONCOPYABLE(IOSurfacePool);
+ WTF_MAKE_FAST_ALLOCATED;
+ friend class NeverDestroyed<IOSurfacePool>;
+
+public:
+ static IOSurfacePool& sharedPool();
+
+ PassRefPtr<IOSurface> takeSurface(IntSize size, ColorSpace colorSpace);
+ void addSurface(IOSurface*);
+
+ void discardAllSurfaces();
+
+ void setPoolSize(size_t);
+
+ void showPoolStatistics();
+
+private:
+ IOSurfacePool();
+
+ struct CachedSurfaceDetails {
+ CachedSurfaceDetails()
+ : hasMarkedPurgeable(false)
+ { }
+
+ void resetLastUseTime() { lastUseTime = std::chrono::steady_clock::now(); }
+
+ std::chrono::steady_clock::time_point lastUseTime;
+ bool hasMarkedPurgeable;
+ };
+
+ typedef Deque<RefPtr<IOSurface>> CachedSurfaceQueue;
+ typedef HashMap<IntSize, CachedSurfaceQueue> CachedSurfaceMap;
+ typedef HashMap<IOSurface*, CachedSurfaceDetails> CachedSurfaceDetailsMap;
+
+ void willAddSurface(IOSurface*, bool inUse);
+ void didRemoveSurface(IOSurface*, bool inUse);
+ void didUseSurfaceOfSize(IntSize);
+
+ void insertSurfaceIntoPool(IOSurface*);
+
+ void evict(size_t additionalSize);
+ void tryEvictInUseSurface();
+ void tryEvictOldestCachedSurface();
+
+ void scheduleCollectionTimer();
+ void collectionTimerFired(Timer<IOSurfacePool>&);
+ void collectInUseSurfaces();
+ bool markOlderSurfacesPurgeable();
+
+ Timer<IOSurfacePool> m_collectionTimer;
+ CachedSurfaceMap m_cachedSurfaces;
+ CachedSurfaceQueue m_inUseSurfaces;
+ CachedSurfaceDetailsMap m_surfaceDetails;
+ Vector<IntSize> m_sizesInPruneOrder;
+
+ size_t m_bytesCached;
+ size_t m_inUseBytesCached;
+ size_t m_maximumBytesCached;
+};
+
+}
+#endif // USE(IOSURFACE)
+
+#endif // IOSurfacePool_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCachecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -1,227 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBufferBackingStoreCache.h"
-
-#if USE(IOSURFACE_CANVAS_BACKING_STORE)
-#include <CoreGraphics/CoreGraphics.h>
-#include <IOSurface/IOSurface.h>
-
-static const double purgeInterval = 5;
-
-namespace WebCore {
-
-// FIXME: Adopt WebCore::IOSurface.
-static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
-{
- unsigned pixelFormat = 'BGRA';
- unsigned bytesPerElement = 4;
- int width = size.width();
- int height = size.height();
-
- unsigned long bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, size.width() * bytesPerElement);
- if (!bytesPerRow)
- return 0;
-
- unsigned long allocSize = IOSurfaceAlignProperty(kIOSurfaceAllocSize, size.height() * bytesPerRow);
- if (!allocSize)
- return 0;
-
- const int kNumCreationParameters = 6;
- const void* keys[kNumCreationParameters];
- const void* values[kNumCreationParameters];
- keys[0] = kIOSurfaceWidth;
- values[0] = CFNumberCreate(0, kCFNumberIntType, &width);
- keys[1] = kIOSurfaceHeight;
- values[1] = CFNumberCreate(0, kCFNumberIntType, &height);
- keys[2] = kIOSurfacePixelFormat;
- values[2] = CFNumberCreate(0, kCFNumberIntType, &pixelFormat);
- keys[3] = kIOSurfaceBytesPerElement;
- values[3] = CFNumberCreate(0, kCFNumberIntType, &bytesPerElement);
- keys[4] = kIOSurfaceBytesPerRow;
- values[4] = CFNumberCreate(0, kCFNumberLongType, &bytesPerRow);
- keys[5] = kIOSurfaceAllocSize;
- values[5] = CFNumberCreate(0, kCFNumberLongType, &allocSize);
-
- RetainPtr<CFDictionaryRef> dict = adoptCF(CFDictionaryCreate(0, keys, values, kNumCreationParameters, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- for (unsigned i = 0; i < kNumCreationParameters; i++)
- CFRelease(values[i]);
-
- return adoptCF(IOSurfaceCreate(dict.get()));
-}
-
-ImageBufferBackingStoreCache::ImageBufferBackingStoreCache()
- : m_purgeTimer(this, &ImageBufferBackingStoreCache::timerFired, purgeInterval)
- , m_pixelsCached(0)
- {
- }
-
-ImageBufferBackingStoreCache& ImageBufferBackingStoreCache::get()
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(ImageBufferBackingStoreCache, cache, ());
- return cache;
-}
-
-bool ImageBufferBackingStoreCache::isAcceptableSurface(const IOSurfaceAndContextWithCreationParams& info, const IntSize& requestedSize, CGColorSpaceRef colorSpace, bool needExactSize) const
-{
- IOSurfaceRef surface = info.surface.get();
- IntSize actualSize(IOSurfaceGetWidth(surface), IOSurfaceGetHeight(surface));
- if (!CFEqual(info.colorSpace.get(), colorSpace))
- return false;
- if (needExactSize && actualSize != requestedSize)
- return false;
- if (actualSize.width() < requestedSize.width() || actualSize.height() < requestedSize.height())
- return false;
- return true;
-}
-
-void ImageBufferBackingStoreCache::insertIntoCache(IOSurfaceAndContextWithCreationParams&& info)
-{
- IOSurfaceRef surface = info.surface.get();
- IntSize surfaceSize(IOSurfaceGetWidth(surface), IOSurfaceGetHeight(surface));
-
- auto toAdd = new IOSurfaceAndContextWithCreationParams(info);
- auto insertedTuple = m_cachedSurfaces.add(convertSizeToKey(surfaceSize), InfoLinkedList());
- insertedTuple.iterator->value.append(toAdd);
-
- m_pixelsCached += surfaceSize.area();
-}
-
-auto ImageBufferBackingStoreCache::takeFromCache(CachedSurfaceMap::iterator iter, IOSurfaceAndContextWithCreationParams* info) -> IOSurfaceAndContextWithCreationParams
-{
- ASSERT(info);
- ASSERT(iter != m_cachedSurfaces.end());
-
- IOSurfaceRef surface = info->surface.get();
- m_pixelsCached -= IOSurfaceGetWidth(surface) * IOSurfaceGetHeight(surface);
-
- iter->value.remove(info);
- if (iter->value.isEmpty())
- m_cachedSurfaces.remove(iter);
- IOSurfaceAndContextWithCreationParams result = std::move(*info);
- delete info;
- return result;
-}
-
-bool ImageBufferBackingStoreCache::tryTakeFromCache(const IntSize& size, CGColorSpaceRef colorSpace, bool needExactSize, IOSurfaceAndContextWithCreationParams& outInfo)
-{
- CachedSurfaceMap::iterator i = m_cachedSurfaces.find(convertSizeToKey(size));
- if (i == m_cachedSurfaces.end())
- return nullptr;
- InfoLinkedList& ll = i->value;
- for (auto info = ll.head(); info; info = info->next()) {
- if (isAcceptableSurface(*info, size, colorSpace, needExactSize)) {
- outInfo = takeFromCache(i, info);
- return true;
- }
- }
- return false;
-}
-
-ImageBufferBackingStoreCache::IOSurfaceAndContext ImageBufferBackingStoreCache::getOrAllocate(IntSize size, CGColorSpaceRef colorSpace, bool needExactSize)
-{
- IOSurfaceAndContextWithCreationParams foundInfo;
- if (tryTakeFromCache(size, colorSpace, needExactSize, foundInfo)) {
- IOSurfaceRef surface = foundInfo.surface.get();
- CGContextRef context = foundInfo.context.get();
- CGContextSaveGState(context);
- auto activeInserted = m_activeSurfaces.add(surface, std::move(foundInfo));
- ASSERT(activeInserted.isNewEntry);
- return activeInserted.iterator->value;
- }
-
- RetainPtr<IOSurfaceRef> surface = createIOSurface(size);
- if (!surface.get())
- return IOSurfaceAndContext();
-
- RetainPtr<CGContextRef> context = adoptCF(wkIOSurfaceContextCreate(surface.get(), size.width(), size.height(), colorSpace));
- if (!context.get())
- return IOSurfaceAndContext();
- CGContextSaveGState(context.get());
-
- auto insertedTuple = m_activeSurfaces.add(surface, IOSurfaceAndContextWithCreationParams(surface.get(), context.get(), colorSpace));
- ASSERT(insertedTuple.isNewEntry);
-
- return insertedTuple.iterator->value;
-}
-
-void ImageBufferBackingStoreCache::deallocate(IOSurfaceRef surface)
-{
- ActiveSurfaceMap::iterator lookup = m_activeSurfaces.find(surface);
- ASSERT(lookup != m_activeSurfaces.end());
-
- auto info = std::move(lookup->value);
- m_activeSurfaces.remove(lookup);
-
- IOSurfaceRef ioSurface = info.surface.get();
- CGContextRef context = info.context.get();
- IntSize surfaceSize(IOSurfaceGetWidth(ioSurface), IOSurfaceGetHeight(ioSurface));
- int surfaceArea = surfaceSize.area();
-
- static const int kMaxPixelsCached = 1024 * 1024 * 64; // 256MB
- if (surfaceArea > kMaxPixelsCached)
- return;
-
- // Evict
- auto bucket = m_cachedSurfaces.find(convertSizeToKey(surfaceSize));
- if (bucket != m_cachedSurfaces.end()) {
- for (int itemsInBucket = bucket->value.size();
- itemsInBucket > 0 && m_pixelsCached + surfaceArea > kMaxPixelsCached;
- --itemsInBucket)
- takeFromCache(bucket, bucket->value.head());
- }
- while (m_pixelsCached + surfaceArea > kMaxPixelsCached) {
- CachedSurfaceMap::iterator iter = m_cachedSurfaces.begin();
- takeFromCache(iter, iter->value.head());
- }
-
- CGContextRestoreGState(context);
- // Clear opportunistically so CG has more time to carry it out.
- CGContextClearRect(context, CGRectMake(0, 0, surfaceSize.width(), surfaceSize.height()));
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- CGContextFlush(context);
-#endif
-
- insertIntoCache(std::move(info));
-
- schedulePurgeTimer();
-}
-
-void ImageBufferBackingStoreCache::timerFired(DeferrableOneShotTimer<ImageBufferBackingStoreCache>&)
-{
- while (!m_cachedSurfaces.isEmpty()) {
- CachedSurfaceMap::iterator iter = m_cachedSurfaces.begin();
- takeFromCache(iter, iter->value.head());
- }
-}
-
-void ImageBufferBackingStoreCache::schedulePurgeTimer()
-{
- m_purgeTimer.restart();
-}
-
-}
-#endif // IOSURFACE_CANVAS_BACKING_STORE
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCacheh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.h (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.h        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.h        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -1,112 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferBackingStoreCache_h
-#define ImageBufferBackingStoreCache_h
-
-#include "ImageBuffer.h"
-
-#include "Timer.h"
-
-#include <wtf/DoublyLinkedList.h>
-#include <wtf/HashMap.h>
-
-#if USE(IOSURFACE_CANVAS_BACKING_STORE)
-
-namespace WebCore {
-
-class ImageBufferBackingStoreCache {
- WTF_MAKE_NONCOPYABLE(ImageBufferBackingStoreCache); WTF_MAKE_FAST_ALLOCATED;
-
-public:
- static ImageBufferBackingStoreCache& get();
-
- struct IOSurfaceAndContext {
- IOSurfaceAndContext()
- {
- }
-
- IOSurfaceAndContext(IOSurfaceRef surface, CGContextRef context)
- : surface(surface)
- , context(context)
- {
- }
-
- RetainPtr<IOSurfaceRef> surface;
- RetainPtr<CGContextRef> context;
- };
-
- IOSurfaceAndContext getOrAllocate(IntSize, CGColorSpaceRef, bool needExactSize);
- void deallocate(IOSurfaceRef);
-
-private:
- ImageBufferBackingStoreCache();
-
- struct IOSurfaceAndContextWithCreationParams : public IOSurfaceAndContext, public DoublyLinkedListNode<IOSurfaceAndContextWithCreationParams> {
- IOSurfaceAndContextWithCreationParams()
- {
- }
-
- IOSurfaceAndContextWithCreationParams(IOSurfaceRef surface, CGContextRef context, CGColorSpaceRef colorSpace)
- : IOSurfaceAndContext(surface, context)
- , colorSpace(colorSpace)
- {
- }
-
- IOSurfaceAndContextWithCreationParams* m_prev;
- IOSurfaceAndContextWithCreationParams* m_next;
- RetainPtr<CGColorSpaceRef> colorSpace;
- };
- typedef HashMap<RetainPtr<IOSurfaceRef>, IOSurfaceAndContextWithCreationParams> ActiveSurfaceMap;
- typedef std::pair<int, int> CachedSurfaceKey;
- typedef DoublyLinkedList<IOSurfaceAndContextWithCreationParams> InfoLinkedList;
- typedef HashMap<CachedSurfaceKey, InfoLinkedList> CachedSurfaceMap;
-
- static CachedSurfaceKey convertSizeToKey(const IntSize& size)
- {
- return std::make_pair(WTF::roundUpToMultipleOf(8, size.width()), WTF::roundUpToMultipleOf(8, size.height()));
- }
-
- IOSurfaceAndContextWithCreationParams takeFromCache(CachedSurfaceMap::iterator, IOSurfaceAndContextWithCreationParams*);
- void insertIntoCache(IOSurfaceAndContextWithCreationParams&&);
-
- // If we find an acceptable surface, this function removes it from the cache as
- // well as placing it in the out parameter.
- bool tryTakeFromCache(const IntSize&, CGColorSpaceRef, bool needExactSize, IOSurfaceAndContextWithCreationParams& outInfo);
- bool isAcceptableSurface(const IOSurfaceAndContextWithCreationParams&, const IntSize&, CGColorSpaceRef, bool needExactSize) const;
-
- void timerFired(DeferrableOneShotTimer<ImageBufferBackingStoreCache>&);
- void schedulePurgeTimer();
-
- DeferrableOneShotTimer<ImageBufferBackingStoreCache> m_purgeTimer;
- ActiveSurfaceMap m_activeSurfaces;
- CachedSurfaceMap m_cachedSurfaces;
- int m_pixelsCached;
-};
-
-}
-#endif // IOSURFACE_CANVAS_BACKING_STORE
-
-#endif // ImageBufferBackingStoreCache_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx">
</span><span class="cx"> #import "GraphicsContextCG.h"
</span><ins>+#import "IOSurfacePool.h"
</ins><span class="cx"> #import <IOSurface/IOSurface.h>
</span><span class="cx"> #import <wtf/Assertions.h>
</span><span class="cx">
</span><span class="lines">@@ -53,6 +54,8 @@
</span><span class="cx">
</span><span class="cx"> PassRefPtr<IOSurface> IOSurface::create(IntSize size, ColorSpace colorSpace)
</span><span class="cx"> {
</span><ins>+ if (RefPtr<IOSurface> cachedSurface = IOSurfacePool::sharedPool().takeSurface(size, colorSpace))
+ return cachedSurface.release();
</ins><span class="cx"> return adoptRef(new IOSurface(size, colorSpace));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosMemoryPressureHandlerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/MemoryPressureHandlerIOS.mm (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/MemoryPressureHandlerIOS.mm        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/ios/MemoryPressureHandlerIOS.mm        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "MemoryPressureHandler.h"
</span><span class="cx">
</span><ins>+#import "IOSurfacePool.h"
</ins><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "SystemMemory.h"
</span><span class="cx"> #import "WebCoreThread.h"
</span><span class="lines">@@ -104,4 +105,9 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MemoryPressureHandler::platformReleaseMemory(bool)
+{
+ IOSurfacePool::sharedPool().discardAllSurfaces();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacMemoryPressureHandlerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -26,18 +26,17 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "MemoryPressureHandler.h"
</span><span class="cx">
</span><del>-#import <WebCore/LayerPool.h>
-#import <wtf/CurrentTime.h>
-#import <malloc/malloc.h>
</del><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">
</span><del>-#if !PLATFORM(IOS)
</del><ins>+#import "IOSurfacePool.h"
+#import "LayerPool.h"
</ins><span class="cx"> #import "WebCoreSystemInterface.h"
</span><ins>+#import <malloc/malloc.h>
</ins><span class="cx"> #import <notify.h>
</span><del>-#endif
</del><ins>+#import <wtf/CurrentTime.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-#if !PLATFORM(IOS)
</del><span class="cx"> static dispatch_source_t _cache_event_source = 0;
</span><span class="cx"> static dispatch_source_t _timer_event_source = 0;
</span><span class="cx"> static int _notifyToken;
</span><span class="lines">@@ -57,7 +56,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> dispatch_async(dispatch_get_main_queue(), ^{
</span><del>-#if !PLATFORM(IOS) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
</del><ins>+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
</ins><span class="cx"> _cache_event_source = wkCreateMemoryStatusPressureCriticalDispatchOnMainQueue();
</span><span class="cx"> #else
</span><span class="cx"> _cache_event_source = wkCreateVMPressureDispatchOnMainQueue();
</span><span class="lines">@@ -138,8 +137,9 @@
</span><span class="cx"> void MemoryPressureHandler::platformReleaseMemory(bool)
</span><span class="cx"> {
</span><span class="cx"> LayerPool::sharedPool()->drain();
</span><ins>+ IOSurfacePool::sharedPool().discardAllSurfaces();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+} // namespace WebCore
+
</ins><span class="cx"> #endif // !PLATFORM(IOS)
</span><del>-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-04-02 Tim Horton <timothy_horton@apple.com>
+
+ Pool IOSurfaces to help with allocation cost
+ https://bugs.webkit.org/show_bug.cgi?id=131096
+ <rdar://problem/15373942>
+
+ Reviewed by Simon Fraser.
+
+ * Shared/mac/RemoteLayerBackingStore.h:
+ * Shared/mac/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::~RemoteLayerBackingStore):
+ (WebKit::RemoteLayerBackingStore::clearBackingStore):
+ (WebKit::RemoteLayerBackingStore::display):
+ When RemoteLayerBackingStore discards a layer, throw it into the pool.
+
+ * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+ (WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
+ Disable the pool in the UI process.
+
</ins><span class="cx"> 2014-04-02 Alice Barraclough <alice.barraclough@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix a typo causing TestWebKitAPI to timeout when testing Find.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx"> RemoteLayerBackingStore();
</span><ins>+ ~RemoteLayerBackingStore();
</ins><span class="cx">
</span><span class="cx"> void ensureBackingStore(PlatformCALayerRemote*, WebCore::IntSize, float scale, bool acceleratesDrawing, bool isOpaque);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><span class="cx"> #import <WebCore/GraphicsContextCG.h>
</span><span class="cx"> #import <WebCore/IOSurface.h>
</span><ins>+#import <WebCore/IOSurfacePool.h>
</ins><span class="cx"> #import <WebCore/WebLayer.h>
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="lines">@@ -58,6 +59,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RemoteLayerBackingStore::~RemoteLayerBackingStore()
+{
+ clearBackingStore();
+}
+
</ins><span class="cx"> void RemoteLayerBackingStore::ensureBackingStore(PlatformCALayerRemote* layer, IntSize size, float scale, bool acceleratesDrawing, bool isOpaque)
</span><span class="cx"> {
</span><span class="cx"> if (m_layer == layer && m_size == size && m_scale == scale && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
</span><span class="lines">@@ -75,6 +81,11 @@
</span><span class="cx"> void RemoteLayerBackingStore::clearBackingStore()
</span><span class="cx"> {
</span><span class="cx"> #if USE(IOSURFACE)
</span><ins>+ if (m_frontSurface)
+ IOSurfacePool::sharedPool().addSurface(m_frontSurface.get());
+ if (m_backSurface)
+ IOSurfacePool::sharedPool().addSurface(m_backSurface.get());
+
</ins><span class="cx"> m_frontSurface = nullptr;
</span><span class="cx"> m_backSurface = nullptr;
</span><span class="cx"> #endif
</span><span class="lines">@@ -188,6 +199,8 @@
</span><span class="cx">
</span><span class="cx"> if (!m_frontSurface || m_frontSurface->isInUse()) {
</span><span class="cx"> // FIXME: Instead of discarding it, put the unusable in-use surface into a pool for future use.
</span><ins>+ if (m_frontSurface)
+ IOSurfacePool::sharedPool().addSurface(m_frontSurface.get());
</ins><span class="cx"> m_frontSurface = IOSurface::create(expandedScaledSize, ColorSpaceDeviceRGB);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacRemoteLayerTreeDrawingAreaProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm (166681 => 166682)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm        2014-04-03 00:07:03 UTC (rev 166681)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm        2014-04-03 00:33:02 UTC (rev 166682)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import "RemoteScrollingCoordinatorProxy.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><ins>+#import <WebCore/IOSurfacePool.h>
</ins><span class="cx"> #import <WebCore/WebCoreCALayerExtras.h>
</span><span class="cx">
</span><span class="cx"> static const CFIndex CoreAnimationCommitRunLoopOrder = 2000000;
</span><span class="lines">@@ -46,6 +47,10 @@
</span><span class="cx"> , m_remoteLayerTreeHost(*this)
</span><span class="cx"> , m_isWaitingForDidUpdateGeometry(false)
</span><span class="cx"> {
</span><ins>+ // We don't want to pool surfaces in the UI process.
+ // FIXME: We should do this somewhere else.
+ IOSurfacePool::sharedPool().setPoolSize(0);
+
</ins><span class="cx"> m_webPageProxy->process().addMessageReceiver(Messages::RemoteLayerTreeDrawingAreaProxy::messageReceiverName(), m_webPageProxy->pageID(), *this);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>