<!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>[166529] 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/166529">166529</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-03-31 14:18:23 -0700 (Mon, 31 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Rename TileCache to LegacyTileCache
https://bugs.webkit.org/show_bug.cgi?id=130986
Reviewed by Simon Fraser.
../WebCore:
Rename iOS WebKit1 tile cache classes to reflect its status.
This also frees some good type names.
TileCache -> LegacyTileCache
TileGrid -> LegacyTileGrid
TileGridTile -> LegacyTileGridTile
etc.
../WebKit/mac:
* WebView/WebView.mm:
(+[WebView drainLayerPool]):
(+[WebView _setTileCacheLayerPoolCapacity:]):</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="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewh">trunk/Source/WebCore/platform/ScrollView.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosScrollViewIOSmm">trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformioswakWAKWindowh">trunk/Source/WebCore/platform/ios/wak/WAKWindow.h</a></li>
<li><a href="#trunkSourceWebCoreplatformioswakWAKWindowmm">trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileCacheh">trunk/Source/WebCore/platform/ios/LegacyTileCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileCachemm">trunk/Source/WebCore/platform/ios/LegacyTileCache.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridh">trunk/Source/WebCore/platform/ios/LegacyTileGrid.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridmm">trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridTileh">trunk/Source/WebCore/platform/ios/LegacyTileGridTile.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridTilemm">trunk/Source/WebCore/platform/ios/LegacyTileGridTile.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayerh">trunk/Source/WebCore/platform/ios/LegacyTileLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayermm">trunk/Source/WebCore/platform/ios/LegacyTileLayer.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayerPoolh">trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayerPoolmm">trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformiosTileCacheh">trunk/Source/WebCore/platform/ios/TileCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileCachemm">trunk/Source/WebCore/platform/ios/TileCache.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileGridh">trunk/Source/WebCore/platform/ios/TileGrid.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileGridmm">trunk/Source/WebCore/platform/ios/TileGrid.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileGridTileh">trunk/Source/WebCore/platform/ios/TileGridTile.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileGridTilemm">trunk/Source/WebCore/platform/ios/TileGridTile.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileLayerh">trunk/Source/WebCore/platform/ios/TileLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileLayermm">trunk/Source/WebCore/platform/ios/TileLayer.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileLayerPoolh">trunk/Source/WebCore/platform/ios/TileLayerPool.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileLayerPoolmm">trunk/Source/WebCore/platform/ios/TileLayerPool.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/ChangeLog        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-03-31 Antti Koivisto <antti@apple.com>
+
+ Rename TileCache to LegacyTileCache
+ https://bugs.webkit.org/show_bug.cgi?id=130986
+
+ Reviewed by Simon Fraser.
+
+ Rename iOS WebKit1 tile cache classes to reflect its status.
+ This also frees some good type names.
+
+ TileCache -> LegacyTileCache
+ TileGrid -> LegacyTileGrid
+ TileGridTile -> LegacyTileGridTile
+ etc.
+
</ins><span class="cx"> 2014-03-31 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Small adjustments to WebCore::IOSurface
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -2482,6 +2482,8 @@
</span><span class="cx"> __ZN7WebCore15GraphicsContext22setEmojiDrawingEnabledEb
</span><span class="cx"> __ZN7WebCore15GraphicsContext23setIsAcceleratedContextEb
</span><span class="cx"> __ZN7WebCore15GraphicsContextC1EP9CGContextb
</span><ins>+__ZN7WebCore15LegacyTileCache14drainLayerPoolEv
+__ZN7WebCore15LegacyTileCache20setLayerPoolCapacityEj
</ins><span class="cx"> __ZN7WebCore15QuickLookHandle10nsResponseEv
</span><span class="cx"> __ZN7WebCore15QuickLookHandle14didReceiveDataEPK8__CFData
</span><span class="cx"> __ZN7WebCore15QuickLookHandle16didFinishLoadingEv
</span><span class="lines">@@ -2636,8 +2638,6 @@
</span><span class="cx"> __ZN7WebCore9FrameView35setUseCustomFixedPositionLayoutRectEb
</span><span class="cx"> __ZN7WebCore9FrameView36scheduleLayerFlushAllowingThrottlingEv
</span><span class="cx"> __ZN7WebCore9PageGroup17removeVisitedLinkERKNS_3URLE
</span><del>-__ZN7WebCore9TileCache14drainLayerPoolEv
-__ZN7WebCore9TileCache20setLayerPoolCapacityEj
</del><span class="cx"> __ZNK7WebCore10FloatPointcv7CGPointEv
</span><span class="cx"> __ZNK7WebCore10ScrollView21unobscuredContentRectENS_14ScrollableArea36VisibleContentRectIncludesScrollbarsE
</span><span class="cx"> __ZNK7WebCore14DocumentLoader16responseMIMETypeEv
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -5975,8 +5975,8 @@
</span><span class="cx">                 E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */; };
</span><span class="cx">                 E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
</span><span class="cx">                 E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                E424A39E1330DF0100CF6DC9 /* TileGridTile.h in Headers */ = {isa = PBXBuildFile; fileRef = E424A39D1330DF0100CF6DC9 /* TileGridTile.h */; };
-                E424A3A01330DF1E00CF6DC9 /* TileGridTile.mm in Sources */ = {isa = PBXBuildFile; fileRef = E424A39F1330DF1E00CF6DC9 /* TileGridTile.mm */; };
</del><ins>+                E424A39E1330DF0100CF6DC9 /* LegacyTileGridTile.h in Headers */ = {isa = PBXBuildFile; fileRef = E424A39D1330DF0100CF6DC9 /* LegacyTileGridTile.h */; };
+                E424A3A01330DF1E00CF6DC9 /* LegacyTileGridTile.mm in Sources */ = {isa = PBXBuildFile; fileRef = E424A39F1330DF1E00CF6DC9 /* LegacyTileGridTile.mm */; };
</ins><span class="cx">                 E425A49A18292B840020CFCF /* CollectionIndexCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E425A49918292B840020CFCF /* CollectionIndexCache.h */; };
</span><span class="cx">                 E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */; };
</span><span class="lines">@@ -6057,10 +6057,10 @@
</span><span class="cx">                 E4AFD00E0DAF335500F5F55C /* SMILTimeContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFD0080DAF335400F5F55C /* SMILTimeContainer.h */; };
</span><span class="cx">                 E4AFD00F0DAF335500F5F55C /* SVGSMILElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4AFD0090DAF335400F5F55C /* SVGSMILElement.cpp */; };
</span><span class="cx">                 E4AFD0100DAF335500F5F55C /* SVGSMILElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFD00A0DAF335400F5F55C /* SVGSMILElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                E4B65A58132FA8E70070E7BE /* TileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B65A57132FA8E70070E7BE /* TileGrid.h */; };
-                E4B65A5A132FAAF90070E7BE /* TileGrid.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4B65A59132FAAF90070E7BE /* TileGrid.mm */; };
-                E4B65A5C132FACB00070E7BE /* TileLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B65A5B132FACB00070E7BE /* TileLayer.h */; };
-                E4B65A5E132FADB60070E7BE /* TileLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4B65A5D132FADB60070E7BE /* TileLayer.mm */; };
</del><ins>+                E4B65A58132FA8E70070E7BE /* LegacyTileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B65A57132FA8E70070E7BE /* LegacyTileGrid.h */; };
+                E4B65A5A132FAAF90070E7BE /* LegacyTileGrid.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4B65A59132FAAF90070E7BE /* LegacyTileGrid.mm */; };
+                E4B65A5C132FACB00070E7BE /* LegacyTileLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B65A5B132FACB00070E7BE /* LegacyTileLayer.h */; };
+                E4B65A5E132FADB60070E7BE /* LegacyTileLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4B65A5D132FADB60070E7BE /* LegacyTileLayer.mm */; };
</ins><span class="cx">                 E4BBED0E14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4BBED0C14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp */; };
</span><span class="cx">                 E4BBED0F14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = E4BBED0D14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h */; };
</span><span class="cx">                 E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4BBED4A14FCDBA1003F0B98 /* StyleRule.cpp */; };
</span><span class="lines">@@ -6069,8 +6069,8 @@
</span><span class="cx">                 E4C1789B0EE6903800824D69 /* CSSSelectorList.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C178960EE6903800824D69 /* CSSSelectorList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C279560CF9741900E97B98 /* RenderMedia.cpp */; };
</span><span class="cx">                 E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; };
</span><del>-                E4C3B1FA0F0E4161009693F6 /* TileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* TileCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
-                E4C3B1FC0F0E4170009693F6 /* TileCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4C3B1FB0F0E4170009693F6 /* TileCache.mm */; };
</del><ins>+                E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                E4C3B1FC0F0E4170009693F6 /* LegacyTileCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4C3B1FB0F0E4170009693F6 /* LegacyTileCache.mm */; };
</ins><span class="cx">                 E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A0D1802343100A17F6D /* TextPaintStyle.h */; };
</span><span class="cx">                 E4C91A101802343900A17F6D /* TextPaintStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */; };
</span><span class="cx">                 E4C91A16180999F100A17F6D /* RenderTextLineBoxes.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -6086,8 +6086,8 @@
</span><span class="cx">                 E4D988B617BFEB210084FB88 /* TextNodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */; };
</span><span class="cx">                 E4DEAA1717A93DC3000E0430 /* StyleResolveTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */; };
</span><span class="cx">                 E4DEAA1817A93DC3000E0430 /* StyleResolveTree.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                E4E39AFB1330EFA8003AB274 /* TileLayerPool.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E39AFA1330EFA8003AB274 /* TileLayerPool.h */; };
-                E4E39AFD1330EFC6003AB274 /* TileLayerPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4E39AFC1330EFC5003AB274 /* TileLayerPool.mm */; };
</del><ins>+                E4E39AFB1330EFA8003AB274 /* LegacyTileLayerPool.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */; };
+                E4E39AFD1330EFC6003AB274 /* LegacyTileLayerPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */; };
</ins><span class="cx">                 E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */; };
</span><span class="cx">                 E4E9B11B18145692003ACCDF /* SimpleLineLayoutFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */; };
</span><span class="cx">                 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
</span><span class="lines">@@ -13365,8 +13365,8 @@
</span><span class="cx">                 E406F3FB1198307D009D59D6 /* ColorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E41EA038119836DB00710BC5 /* CSSPropertyNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertyNames.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E41EA0391198374900710BC5 /* CSSValueKeywords.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValueKeywords.cpp; sourceTree = "<group>"; };
</span><del>-                E424A39D1330DF0100CF6DC9 /* TileGridTile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGridTile.h; path = ios/TileGridTile.h; sourceTree = "<group>"; };
-                E424A39F1330DF1E00CF6DC9 /* TileGridTile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileGridTile.mm; path = ios/TileGridTile.mm; sourceTree = "<group>"; };
</del><ins>+                E424A39D1330DF0100CF6DC9 /* LegacyTileGridTile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileGridTile.h; path = ios/LegacyTileGridTile.h; sourceTree = "<group>"; };
+                E424A39F1330DF1E00CF6DC9 /* LegacyTileGridTile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LegacyTileGridTile.mm; path = ios/LegacyTileGridTile.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 E425A49918292B840020CFCF /* CollectionIndexCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionIndexCache.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadPriority.h; sourceTree = "<group>"; };
</span><span class="cx">                 E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeTraversal.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -13456,10 +13456,10 @@
</span><span class="cx">                 E4B423800CBFB73C00AF2ECE /* JSHTMLMediaElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLMediaElement.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4B423850CBFB73C00AF2ECE /* JSProgressEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSProgressEvent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4B423860CBFB73C00AF2ECE /* JSProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSProgressEvent.h; sourceTree = "<group>"; };
</span><del>-                E4B65A57132FA8E70070E7BE /* TileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGrid.h; path = ios/TileGrid.h; sourceTree = "<group>"; };
-                E4B65A59132FAAF90070E7BE /* TileGrid.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileGrid.mm; path = ios/TileGrid.mm; sourceTree = "<group>"; };
-                E4B65A5B132FACB00070E7BE /* TileLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileLayer.h; path = ios/TileLayer.h; sourceTree = "<group>"; };
-                E4B65A5D132FADB60070E7BE /* TileLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileLayer.mm; path = ios/TileLayer.mm; sourceTree = "<group>"; };
</del><ins>+                E4B65A57132FA8E70070E7BE /* LegacyTileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileGrid.h; path = ios/LegacyTileGrid.h; sourceTree = "<group>"; };
+                E4B65A59132FAAF90070E7BE /* LegacyTileGrid.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LegacyTileGrid.mm; path = ios/LegacyTileGrid.mm; sourceTree = "<group>"; };
+                E4B65A5B132FACB00070E7BE /* LegacyTileLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileLayer.h; path = ios/LegacyTileLayer.h; sourceTree = "<group>"; };
+                E4B65A5D132FADB60070E7BE /* LegacyTileLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LegacyTileLayer.mm; path = ios/LegacyTileLayer.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 E4BBED0C14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertySetCSSStyleDeclaration.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4BBED0D14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertySetCSSStyleDeclaration.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4BBED4A14FCDBA1003F0B98 /* StyleRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRule.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -13468,8 +13468,8 @@
</span><span class="cx">                 E4C178960EE6903800824D69 /* CSSSelectorList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSSelectorList.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4C279560CF9741900E97B98 /* RenderMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMedia.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4C279570CF9741900E97B98 /* RenderMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMedia.h; sourceTree = "<group>"; };
</span><del>-                E4C3B1F90F0E4161009693F6 /* TileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileCache.h; path = ios/TileCache.h; sourceTree = "<group>"; };
-                E4C3B1FB0F0E4170009693F6 /* TileCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileCache.mm; path = ios/TileCache.mm; sourceTree = "<group>"; };
</del><ins>+                E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileCache.h; path = ios/LegacyTileCache.h; sourceTree = "<group>"; };
+                E4C3B1FB0F0E4170009693F6 /* LegacyTileCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LegacyTileCache.mm; path = ios/LegacyTileCache.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 E4C91A0D1802343100A17F6D /* TextPaintStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPaintStyle.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPaintStyle.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextLineBoxes.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -13485,8 +13485,8 @@
</span><span class="cx">                 E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextNodeTraversal.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleResolveTree.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolveTree.h; sourceTree = "<group>"; };
</span><del>-                E4E39AFA1330EFA8003AB274 /* TileLayerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileLayerPool.h; path = ios/TileLayerPool.h; sourceTree = "<group>"; };
-                E4E39AFC1330EFC5003AB274 /* TileLayerPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileLayerPool.mm; path = ios/TileLayerPool.mm; sourceTree = "<group>"; };
</del><ins>+                E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileLayerPool.h; path = ios/LegacyTileLayerPool.h; sourceTree = "<group>"; };
+                E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LegacyTileLayerPool.mm; path = ios/LegacyTileLayerPool.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutResolver.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutFunctions.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -18140,18 +18140,18 @@
</span><span class="cx">                                 E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */,
</span><span class="cx">                                 44C9919D0F3D210E00586670 /* ThemeIOS.h */,
</span><span class="cx">                                 44C9919E0F3D210E00586670 /* ThemeIOS.mm */,
</span><del>-                                E4C3B1F90F0E4161009693F6 /* TileCache.h */,
-                                E4C3B1FB0F0E4170009693F6 /* TileCache.mm */,
</del><ins>+                                E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */,
+                                E4C3B1FB0F0E4170009693F6 /* LegacyTileCache.mm */,
</ins><span class="cx">                                 1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */,
</span><span class="cx">                                 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */,
</span><del>-                                E4B65A57132FA8E70070E7BE /* TileGrid.h */,
-                                E4B65A59132FAAF90070E7BE /* TileGrid.mm */,
-                                E424A39D1330DF0100CF6DC9 /* TileGridTile.h */,
-                                E424A39F1330DF1E00CF6DC9 /* TileGridTile.mm */,
-                                E4B65A5B132FACB00070E7BE /* TileLayer.h */,
-                                E4B65A5D132FADB60070E7BE /* TileLayer.mm */,
-                                E4E39AFA1330EFA8003AB274 /* TileLayerPool.h */,
-                                E4E39AFC1330EFC5003AB274 /* TileLayerPool.mm */,
</del><ins>+                                E4B65A57132FA8E70070E7BE /* LegacyTileGrid.h */,
+                                E4B65A59132FAAF90070E7BE /* LegacyTileGrid.mm */,
+                                E424A39D1330DF0100CF6DC9 /* LegacyTileGridTile.h */,
+                                E424A39F1330DF1E00CF6DC9 /* LegacyTileGridTile.mm */,
+                                E4B65A5B132FACB00070E7BE /* LegacyTileLayer.h */,
+                                E4B65A5D132FADB60070E7BE /* LegacyTileLayer.mm */,
+                                E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */,
+                                E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */,
</ins><span class="cx">                                 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */,
</span><span class="cx">                                 31403798124BEA7F00AF40E4 /* WebCoreMotionManager.mm */,
</span><span class="cx">                                 44C3CFE71556BE5D00013609 /* WebCoreSystemInterfaceIOS.h */,
</span><span class="lines">@@ -25955,14 +25955,14 @@
</span><span class="cx">                                 0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */,
</span><span class="cx">                                 E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */,
</span><span class="cx">                                 185BCF290F3279CE000EA262 /* ThreadTimers.h in Headers */,
</span><del>-                                E4C3B1FA0F0E4161009693F6 /* TileCache.h in Headers */,
</del><ins>+                                E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */,
</ins><span class="cx">                                 1AA7160B149BC4DB0016EC19 /* TileController.h in Headers */,
</span><span class="cx">                                 1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */,
</span><span class="cx">                                 1AF89A421518FDEA00E547B5 /* TiledBacking.h in Headers */,
</span><del>-                                E4B65A58132FA8E70070E7BE /* TileGrid.h in Headers */,
-                                E424A39E1330DF0100CF6DC9 /* TileGridTile.h in Headers */,
-                                E4B65A5C132FACB00070E7BE /* TileLayer.h in Headers */,
-                                E4E39AFB1330EFA8003AB274 /* TileLayerPool.h in Headers */,
</del><ins>+                                E4B65A58132FA8E70070E7BE /* LegacyTileGrid.h in Headers */,
+                                E424A39E1330DF0100CF6DC9 /* LegacyTileGridTile.h in Headers */,
+                                E4B65A5C132FACB00070E7BE /* LegacyTileLayer.h in Headers */,
+                                E4E39AFB1330EFA8003AB274 /* LegacyTileLayerPool.h in Headers */,
</ins><span class="cx">                                 498770F31242C535002226BA /* TilingData.h in Headers */,
</span><span class="cx">                                 F55B3DDC1251F12D003EF269 /* TimeInputType.h in Headers */,
</span><span class="cx">                                 7553CFE8108F473F00EA281E /* TimelineRecordFactory.h in Headers */,
</span><span class="lines">@@ -29207,13 +29207,13 @@
</span><span class="cx">                                 0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */,
</span><span class="cx">                                 E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */,
</span><span class="cx">                                 185BCF280F3279CE000EA262 /* ThreadTimers.cpp in Sources */,
</span><del>-                                E4C3B1FC0F0E4170009693F6 /* TileCache.mm in Sources */,
</del><ins>+                                E4C3B1FC0F0E4170009693F6 /* LegacyTileCache.mm in Sources */,
</ins><span class="cx">                                 1AA7160A149BC4DB0016EC19 /* TileController.mm in Sources */,
</span><span class="cx">                                 1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */,
</span><del>-                                E4B65A5A132FAAF90070E7BE /* TileGrid.mm in Sources */,
-                                E424A3A01330DF1E00CF6DC9 /* TileGridTile.mm in Sources */,
-                                E4B65A5E132FADB60070E7BE /* TileLayer.mm in Sources */,
-                                E4E39AFD1330EFC6003AB274 /* TileLayerPool.mm in Sources */,
</del><ins>+                                E4B65A5A132FAAF90070E7BE /* LegacyTileGrid.mm in Sources */,
+                                E424A3A01330DF1E00CF6DC9 /* LegacyTileGridTile.mm in Sources */,
+                                E4B65A5E132FADB60070E7BE /* LegacyTileLayer.mm in Sources */,
+                                E4E39AFD1330EFC6003AB274 /* LegacyTileLayerPool.mm in Sources */,
</ins><span class="cx">                                 498770F21242C535002226BA /* TilingData.cpp in Sources */,
</span><span class="cx">                                 F55B3DDB1251F12D003EF269 /* TimeInputType.cpp in Sources */,
</span><span class="cx">                                 7553CFE9108F473F00EA281E /* TimelineRecordFactory.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -95,11 +95,11 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #include "DocumentLoader.h"
</span><ins>+#include "LegacyTileCache.h"
</ins><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "MemoryCache.h"
</span><span class="cx"> #include "MemoryPressureHandler.h"
</span><span class="cx"> #include "SystemMemory.h"
</span><del>-#include "TileCache.h"
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="lines">@@ -378,8 +378,8 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> // To avoid flashes of white, disable tile updates immediately when view is cleared at the beginning of a page load.
</span><span class="cx"> // Tiling will be re-enabled from UIKit via [WAKWindow setTilingMode:] when we have content to draw.
</span><del>- if (TileCache* tileCache = this->tileCache())
- tileCache->setTilingMode(TileCache::Disabled);
</del><ins>+ if (LegacyTileCache* tileCache = legacyTileCache())
+ tileCache->setTilingMode(LegacyTileCache::Disabled);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -860,7 +860,7 @@
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- if (TileCache* tileCache = this->tileCache())
</del><ins>+ if (LegacyTileCache* tileCache = legacyTileCache())
</ins><span class="cx"> tileCache->doPendingRepaints();
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -2243,7 +2243,7 @@
</span><span class="cx"> if (renderView && renderView->layer()->backing())
</span><span class="cx"> renderView->layer()->backing()->adjustTiledBackingCoverage();
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- if (TileCache* tileCache = this->tileCache())
</del><ins>+ if (LegacyTileCache* tileCache = legacyTileCache())
</ins><span class="cx"> tileCache->setSpeculativeTileCreationEnabled(m_speculativeTilingEnabled);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ScrollView.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -60,8 +60,8 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class HostWindow;
</span><ins>+class LegacyTileCache;
</ins><span class="cx"> class Scrollbar;
</span><del>-class TileCache;
</del><span class="cx">
</span><span class="cx"> class ScrollView : public Widget, public ScrollableArea {
</span><span class="cx"> public:
</span><span class="lines">@@ -190,7 +190,7 @@
</span><span class="cx"> FloatRect computeCoverageRect(double horizontalMargin, double verticalMargin) const;
</span><span class="cx">
</span><span class="cx"> void setActualScrollPosition(const IntPoint&);
</span><del>- TileCache* tileCache();
</del><ins>+ LegacyTileCache* legacyTileCache();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // visibleContentRect().size() is computed from unscaledUnobscuredVisibleContentSize() divided by the value of visibleContentScaleFactor.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileCachehfromrev166453trunkSourceWebCoreplatformiosTileCacheh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileCache.h (from rev 166453, trunk/Source/WebCore/platform/ios/TileCache.h) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileCache.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileCache.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,218 @@
</span><ins>+/*
+ * Copyright (C) 2009 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 LegacyTileCache_h
+#define LegacyTileCache_h
+
+#if PLATFORM(IOS)
+
+#include "Color.h"
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "Timer.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/Vector.h>
+
+#ifdef __OBJC__
+@class CALayer;
+@class LegacyTileCacheTombstone;
+@class LegacyTileLayer;
+@class WAKWindow;
+#else
+class CALayer;
+class LegacyTileCacheTombstone;
+class LegacyTileLayer;
+class WAKWindow;
+#endif
+
+namespace WebCore {
+
+class LegacyTileGrid;
+
+class LegacyTileCache {
+ WTF_MAKE_NONCOPYABLE(LegacyTileCache);
+public:
+ LegacyTileCache(WAKWindow*);
+ ~LegacyTileCache();
+
+ CGFloat screenScale() const;
+
+ void setNeedsDisplay();
+ void setNeedsDisplayInRect(const IntRect&);
+
+ void layoutTiles();
+ void layoutTilesNow();
+ void layoutTilesNowForRect(const IntRect&);
+ void removeAllNonVisibleTiles();
+ void removeAllTiles();
+ void removeForegroundTiles();
+
+ // If 'contentReplacementImage' is not NULL, drawLayer() draws
+ // contentReplacementImage instead of the page content. We assume the
+ // image is to be drawn at the origin and scaled to match device pixels.
+ void setContentReplacementImage(RetainPtr<CGImageRef>);
+ RetainPtr<CGImageRef> contentReplacementImage() const;
+
+ void setTileBordersVisible(bool);
+ bool tileBordersVisible() const { return m_tileBordersVisible; }
+
+ void setTilePaintCountersVisible(bool);
+ bool tilePaintCountersVisible() const { return m_tilePaintCountersVisible; }
+
+ void setAcceleratedDrawingEnabled(bool enabled) { m_acceleratedDrawingEnabled = enabled; }
+ bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
+
+ void setKeepsZoomedOutTiles(bool);
+ bool keepsZoomedOutTiles() const { return m_keepsZoomedOutTiles; }
+
+ void setZoomedOutScale(float);
+ float zoomedOutScale() const;
+
+ void setCurrentScale(float);
+ float currentScale() const;
+
+ bool tilesOpaque() const;
+ void setTilesOpaque(bool);
+
+ enum TilingMode {
+ Normal,
+ Minimal,
+ Panning,
+ Zooming,
+ Disabled,
+ ScrollToTop
+ };
+ TilingMode tilingMode() const { return m_tilingMode; }
+ void setTilingMode(TilingMode);
+
+ typedef enum {
+ TilingDirectionUp,
+ TilingDirectionDown,
+ TilingDirectionLeft,
+ TilingDirectionRight,
+ } TilingDirection;
+ void setTilingDirection(TilingDirection);
+ TilingDirection tilingDirection() const;
+
+ bool hasPendingDraw() const;
+
+ void hostLayerSizeChanged();
+
+ static void setLayerPoolCapacity(unsigned);
+ static void drainLayerPool();
+
+ // Logging
+ void dumpTiles();
+
+ // Internal
+ void doLayoutTiles();
+ void drawLayer(LegacyTileLayer*, CGContextRef);
+ void prepareToDraw();
+ void finishedCreatingTiles(bool didCreateTiles, bool createMore);
+ FloatRect visibleRectInLayer(CALayer *) const;
+ CALayer* hostLayer() const;
+ unsigned tileCapacityForGrid(LegacyTileGrid*);
+ Color colorForGridTileBorder(LegacyTileGrid*) const;
+
+ void doPendingRepaints();
+
+ bool isSpeculativeTileCreationEnabled() const { return m_isSpeculativeTileCreationEnabled; }
+ void setSpeculativeTileCreationEnabled(bool);
+
+ enum SynchronousTileCreationMode { CoverVisibleOnly, CoverSpeculative };
+
+private:
+ LegacyTileGrid* activeTileGrid() const;
+ LegacyTileGrid* inactiveTileGrid() const;
+
+ void updateTilingMode();
+ bool isTileInvalidationSuspended() const;
+ bool isTileCreationSuspended() const;
+ void flushSavedDisplayRects();
+ void invalidateTiles(const IntRect& dirtyRect);
+ void setZoomedOutScaleInternal(float);
+ void commitScaleChange();
+ void bringActiveTileGridToFront();
+ void adjustTileGridTransforms();
+ void removeAllNonVisibleTilesInternal();
+ void createTilesInActiveGrid(SynchronousTileCreationMode);
+ void scheduleLayerFlushForPendingRepaint();
+
+ void tileCreationTimerFired(Timer<LegacyTileCache>*);
+
+ void drawReplacementImage(LegacyTileLayer*, CGContextRef, CGImageRef);
+ void drawWindowContent(LegacyTileLayer*, CGContextRef, CGRect dirtyRect);
+
+ WAKWindow* m_window;
+
+ RetainPtr<CGImageRef> m_contentReplacementImage;
+
+ bool m_keepsZoomedOutTiles;
+
+ bool m_hasPendingLayoutTiles;
+ bool m_hasPendingUpdateTilingMode;
+ // Ensure there are no async calls on a dead tile cache.
+ RetainPtr<LegacyTileCacheTombstone> m_tombstone;
+
+ TilingMode m_tilingMode;
+ TilingDirection m_tilingDirection;
+
+ IntSize m_tileSize;
+ bool m_tilesOpaque;
+
+ bool m_tileBordersVisible;
+ bool m_tilePaintCountersVisible;
+ bool m_acceleratedDrawingEnabled;
+ bool m_isSpeculativeTileCreationEnabled;
+
+ bool m_didCallWillStartScrollingOrZooming;
+ OwnPtr<LegacyTileGrid> m_zoomedOutTileGrid;
+ OwnPtr<LegacyTileGrid> m_zoomedInTileGrid;
+
+ Timer<LegacyTileCache> m_tileCreationTimer;
+
+ Vector<IntRect> m_savedDisplayRects;
+
+ float m_currentScale;
+
+ float m_pendingScale;
+ float m_pendingZoomedOutScale;
+
+ mutable Mutex m_tileMutex;
+ mutable Mutex m_savedDisplayRectMutex;
+ mutable Mutex m_contentReplacementImageMutex;
+};
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
+
+#endif // TileCache_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileCachemmfromrev166453trunkSourceWebCoreplatformiosTileCachemm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileCache.mm (from rev 166453, trunk/Source/WebCore/platform/ios/TileCache.mm) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileCache.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileCache.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,822 @@
</span><ins>+/*
+ * Copyright (C) 2009 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 "LegacyTileCache.h"
+
+#if PLATFORM(IOS)
+
+#include "LegacyTileGrid.h"
+#include "LegacyTileGridTile.h"
+#include "LegacyTileLayer.h"
+#include "LegacyTileLayerPool.h"
+#include "Logging.h"
+#include "MemoryPressureHandler.h"
+#include "SystemMemory.h"
+#include "WAKWindow.h"
+#include "WKGraphics.h"
+#include "WebCoreSystemInterface.h"
+#include "WebCoreThreadRun.h"
+#include <QuartzCore/QuartzCore.h>
+#include <QuartzCore/QuartzCorePrivate.h>
+#include <wtf/CurrentTime.h>
+
+@interface WAKView (WebViewExtras)
+- (void)_dispatchTileDidDraw:(CALayer*)tile;
+- (void)_willStartScrollingOrZooming;
+- (void)_didFinishScrollingOrZooming;
+- (void)_dispatchTileDidDraw;
+- (void)_scheduleLayerFlushForPendingTileCacheRepaint;
+@end
+
+@interface LegacyTileCacheTombstone : NSObject {
+ BOOL dead;
+}
+@property(getter=isDead) BOOL dead;
+
+@end
+
+@implementation LegacyTileCacheTombstone
+
+@synthesize dead;
+
+@end
+
+namespace WebCore {
+
+LegacyTileCache::LegacyTileCache(WAKWindow* window)
+ : m_window(window)
+ , m_keepsZoomedOutTiles(false)
+ , m_hasPendingLayoutTiles(false)
+ , m_hasPendingUpdateTilingMode(false)
+ , m_tombstone(adoptNS([[LegacyTileCacheTombstone alloc] init]))
+ , m_tilingMode(Normal)
+ , m_tilingDirection(TilingDirectionDown)
+ , m_tileSize(512, 512)
+ , m_tilesOpaque(true)
+ , m_tileBordersVisible(false)
+ , m_tilePaintCountersVisible(false)
+ , m_acceleratedDrawingEnabled(false)
+ , m_isSpeculativeTileCreationEnabled(true)
+ , m_didCallWillStartScrollingOrZooming(false)
+ , m_zoomedOutTileGrid(PassOwnPtr<LegacyTileGrid>())
+ , m_zoomedInTileGrid(PassOwnPtr<LegacyTileGrid>())
+ , m_tileCreationTimer(this, &LegacyTileCache::tileCreationTimerFired)
+ , m_currentScale(1.f)
+ , m_pendingScale(0)
+ , m_pendingZoomedOutScale(0)
+{
+ m_zoomedOutTileGrid = LegacyTileGrid::create(this, m_tileSize);
+ [hostLayer() insertSublayer:m_zoomedOutTileGrid->tileHostLayer() atIndex:0];
+ hostLayerSizeChanged();
+}
+
+LegacyTileCache::~LegacyTileCache()
+{
+ [m_tombstone.get() setDead:true];
+}
+
+CGFloat LegacyTileCache::screenScale() const
+{
+ return [m_window screenScale];
+}
+
+CALayer* LegacyTileCache::hostLayer() const
+{
+ return [m_window hostLayer];
+}
+
+FloatRect LegacyTileCache::visibleRectInLayer(CALayer *layer) const
+{
+ return [layer convertRect:[m_window extendedVisibleRect] fromLayer:hostLayer()];
+}
+
+bool LegacyTileCache::tilesOpaque() const
+{
+ return m_tilesOpaque;
+}
+
+LegacyTileGrid* LegacyTileCache::activeTileGrid() const
+{
+ if (!m_keepsZoomedOutTiles)
+ return m_zoomedOutTileGrid.get();
+ if (m_tilingMode == Zooming)
+ return m_zoomedOutTileGrid.get();
+ if (m_zoomedInTileGrid && m_currentScale == m_zoomedInTileGrid->scale())
+ return m_zoomedInTileGrid.get();
+ return m_zoomedOutTileGrid.get();
+}
+
+LegacyTileGrid* LegacyTileCache::inactiveTileGrid() const
+{
+ return activeTileGrid() == m_zoomedOutTileGrid ? m_zoomedInTileGrid.get() : m_zoomedOutTileGrid.get();
+}
+
+void LegacyTileCache::setTilesOpaque(bool opaque)
+{
+ if (m_tilesOpaque == opaque)
+ return;
+
+ MutexLocker locker(m_tileMutex);
+
+ m_tilesOpaque = opaque;
+ m_zoomedOutTileGrid->updateTileOpacity();
+ if (m_zoomedInTileGrid)
+ m_zoomedInTileGrid->updateTileOpacity();
+}
+
+void LegacyTileCache::doLayoutTiles()
+{
+ if (isTileCreationSuspended())
+ return;
+
+ MutexLocker locker(m_tileMutex);
+ LegacyTileGrid* activeGrid = activeTileGrid();
+ // Even though we aren't actually creating tiles in the inactive grid, we
+ // still need to drop invalid tiles in response to a layout.
+ // See <rdar://problem/9839867>.
+ if (LegacyTileGrid* inactiveGrid = inactiveTileGrid())
+ inactiveGrid->dropInvalidTiles();
+ if (activeGrid->checkDoSingleTileLayout())
+ return;
+ createTilesInActiveGrid(CoverVisibleOnly);
+}
+
+void LegacyTileCache::hostLayerSizeChanged()
+{
+ m_zoomedOutTileGrid->updateHostLayerSize();
+ if (m_zoomedInTileGrid)
+ m_zoomedInTileGrid->updateHostLayerSize();
+}
+
+void LegacyTileCache::setKeepsZoomedOutTiles(bool keep)
+{
+ m_keepsZoomedOutTiles = keep;
+}
+
+void LegacyTileCache::setCurrentScale(float scale)
+{
+ ASSERT(scale > 0);
+
+ if (currentScale() == scale) {
+ m_pendingScale = 0;
+ return;
+ }
+ m_pendingScale = scale;
+ if (m_tilingMode == Disabled)
+ return;
+ commitScaleChange();
+
+ if (!keepsZoomedOutTiles() && !isTileInvalidationSuspended()) {
+ // Tile invalidation is normally suspended during zooming by UIKit but some applications
+ // using custom scrollviews may zoom without triggering the callbacks. Invalidate the tiles explicitly.
+ MutexLocker locker(m_tileMutex);
+ activeTileGrid()->dropAllTiles();
+ activeTileGrid()->createTiles(CoverVisibleOnly);
+ }
+}
+
+void LegacyTileCache::setZoomedOutScale(float scale)
+{
+ ASSERT(scale > 0);
+
+ if (zoomedOutScale() == scale) {
+ m_pendingZoomedOutScale = 0;
+ return;
+ }
+ m_pendingZoomedOutScale = scale;
+ if (m_tilingMode == Disabled)
+ return;
+ commitScaleChange();
+}
+
+void LegacyTileCache::commitScaleChange()
+{
+ ASSERT(m_pendingZoomedOutScale || m_pendingScale);
+ ASSERT(m_tilingMode != Disabled);
+
+ MutexLocker locker(m_tileMutex);
+
+ if (m_pendingZoomedOutScale) {
+ m_zoomedOutTileGrid->setScale(m_pendingZoomedOutScale);
+ m_pendingZoomedOutScale = 0;
+ }
+
+ if (!m_keepsZoomedOutTiles) {
+ ASSERT(activeTileGrid() == m_zoomedOutTileGrid);
+ if (m_pendingScale) {
+ m_currentScale = m_pendingScale;
+ m_zoomedOutTileGrid->setScale(m_currentScale);
+ }
+ m_pendingScale = 0;
+ return;
+ }
+
+ if (m_pendingScale) {
+ m_currentScale = m_pendingScale;
+ m_pendingScale = 0;
+ }
+
+ if (m_currentScale != m_zoomedOutTileGrid->scale()) {
+ if (!m_zoomedInTileGrid) {
+ m_zoomedInTileGrid = LegacyTileGrid::create(this, m_tileSize);
+ [hostLayer() addSublayer:m_zoomedInTileGrid->tileHostLayer()];
+ hostLayerSizeChanged();
+ }
+ m_zoomedInTileGrid->setScale(m_currentScale);
+ }
+
+ // Keep the current ordering during zooming.
+ if (m_tilingMode != Zooming)
+ bringActiveTileGridToFront();
+
+ adjustTileGridTransforms();
+ layoutTiles();
+}
+
+void LegacyTileCache::bringActiveTileGridToFront()
+{
+ LegacyTileGrid* activeGrid = activeTileGrid();
+ LegacyTileGrid* otherGrid = inactiveTileGrid();
+ if (!otherGrid)
+ return;
+ CALayer* frontLayer = activeGrid->tileHostLayer();
+ CALayer* otherLayer = otherGrid->tileHostLayer();
+ [hostLayer() insertSublayer:frontLayer above:otherLayer];
+}
+
+void LegacyTileCache::adjustTileGridTransforms()
+{
+ CALayer* zoomedOutHostLayer = m_zoomedOutTileGrid->tileHostLayer();
+ float transformScale = currentScale() / zoomedOutScale();
+ [zoomedOutHostLayer setTransform:CATransform3DMakeScale(transformScale, transformScale, 1.0f)];
+ m_zoomedOutTileGrid->updateHostLayerSize();
+}
+
+void LegacyTileCache::layoutTiles()
+{
+ if (m_hasPendingLayoutTiles)
+ return;
+ m_hasPendingLayoutTiles = true;
+
+ LegacyTileCacheTombstone *tombstone = m_tombstone.get();
+ WebThreadRun(^{
+ if ([tombstone isDead])
+ return;
+ m_hasPendingLayoutTiles = false;
+ doLayoutTiles();
+ });
+}
+
+void LegacyTileCache::layoutTilesNow()
+{
+ ASSERT(WebThreadIsLockedOrDisabled());
+
+ // layoutTilesNow() is called after a zoom, while the tile mode is still set to Zooming.
+ // If we checked for isTileCreationSuspended here, that would cause <rdar://problem/8434112> (Page flashes after zooming in/out).
+ if (m_tilingMode == Disabled)
+ return;
+
+ // FIXME: layoutTilesNow should be called after state has been set to non-zooming and the active grid is the final one.
+ // Fix this in UIKit side (perhaps also getting rid of this call) and remove this code afterwards.
+ // <rdar://problem/9672993>
+ TilingMode savedTilingMode = m_tilingMode;
+ if (m_tilingMode == Zooming)
+ m_tilingMode = Minimal;
+
+ MutexLocker locker(m_tileMutex);
+ LegacyTileGrid* activeGrid = activeTileGrid();
+ if (activeGrid->checkDoSingleTileLayout()) {
+ m_tilingMode = savedTilingMode;
+ return;
+ }
+ createTilesInActiveGrid(CoverVisibleOnly);
+ m_tilingMode = savedTilingMode;
+}
+
+void LegacyTileCache::layoutTilesNowForRect(const IntRect& rect)
+{
+ ASSERT(WebThreadIsLockedOrDisabled());
+ MutexLocker locker(m_tileMutex);
+
+ activeTileGrid()->addTilesCoveringRect(rect);
+}
+
+void LegacyTileCache::removeAllNonVisibleTiles()
+{
+ MutexLocker locker(m_tileMutex);
+ removeAllNonVisibleTilesInternal();
+}
+
+void LegacyTileCache::removeAllNonVisibleTilesInternal()
+{
+ LegacyTileGrid* activeGrid = activeTileGrid();
+ if (keepsZoomedOutTiles() && activeGrid == m_zoomedInTileGrid && activeGrid->hasTiles())
+ m_zoomedOutTileGrid->dropAllTiles();
+
+ IntRect activeTileBounds = activeGrid->bounds();
+ if (activeTileBounds.width() <= m_tileSize.width() && activeTileBounds.height() <= m_tileSize.height()) {
+ // If the view is smaller than a tile, keep the tile even if it is not visible.
+ activeGrid->dropTilesOutsideRect(activeTileBounds);
+ return;
+ }
+
+ activeGrid->dropTilesOutsideRect(activeGrid->visibleRect());
+}
+
+void LegacyTileCache::removeAllTiles()
+{
+ MutexLocker locker(m_tileMutex);
+ m_zoomedOutTileGrid->dropAllTiles();
+ if (m_zoomedInTileGrid)
+ m_zoomedInTileGrid->dropAllTiles();
+}
+
+void LegacyTileCache::removeForegroundTiles()
+{
+ MutexLocker locker(m_tileMutex);
+ if (!keepsZoomedOutTiles())
+ m_zoomedOutTileGrid->dropAllTiles();
+ if (m_zoomedInTileGrid)
+ m_zoomedInTileGrid->dropAllTiles();
+}
+
+void LegacyTileCache::setContentReplacementImage(RetainPtr<CGImageRef> contentReplacementImage)
+{
+ MutexLocker locker(m_contentReplacementImageMutex);
+ m_contentReplacementImage = contentReplacementImage;
+}
+
+RetainPtr<CGImageRef> LegacyTileCache::contentReplacementImage() const
+{
+ MutexLocker locker(m_contentReplacementImageMutex);
+ return m_contentReplacementImage;
+}
+
+void LegacyTileCache::setTileBordersVisible(bool flag)
+{
+ if (flag == m_tileBordersVisible)
+ return;
+
+ m_tileBordersVisible = flag;
+ m_zoomedOutTileGrid->updateTileBorderVisibility();
+ if (m_zoomedInTileGrid)
+ m_zoomedInTileGrid->updateTileBorderVisibility();
+}
+
+void LegacyTileCache::setTilePaintCountersVisible(bool flag)
+{
+ m_tilePaintCountersVisible = flag;
+ // The numbers will show up the next time the tiles paint.
+}
+
+void LegacyTileCache::finishedCreatingTiles(bool didCreateTiles, bool createMore)
+{
+ // We need to ensure that all tiles are showing the same version of the content.
+ if (didCreateTiles && !m_savedDisplayRects.isEmpty())
+ flushSavedDisplayRects();
+
+ if (keepsZoomedOutTiles()) {
+ if (m_zoomedInTileGrid && activeTileGrid() == m_zoomedOutTileGrid && m_tilingMode != Zooming && m_zoomedInTileGrid->hasTiles()) {
+ // This CA transaction will cover the screen with top level tiles.
+ // We can remove zoomed-in tiles without flashing.
+ m_zoomedInTileGrid->dropAllTiles();
+ } else if (activeTileGrid() == m_zoomedInTileGrid) {
+ // Pass the minimum possible distance to consider all tiles, even visible ones.
+ m_zoomedOutTileGrid->dropDistantTiles(0, std::numeric_limits<double>::min());
+ }
+ }
+
+ // Keep creating tiles until the whole coverRect is covered.
+ if (createMore)
+ m_tileCreationTimer.startOneShot(0);
+}
+
+void LegacyTileCache::tileCreationTimerFired(Timer<LegacyTileCache>*)
+{
+ if (isTileCreationSuspended())
+ return;
+ MutexLocker locker(m_tileMutex);
+ createTilesInActiveGrid(CoverSpeculative);
+}
+
+void LegacyTileCache::createTilesInActiveGrid(SynchronousTileCreationMode mode)
+{
+ if (memoryPressureHandler().hasReceivedMemoryPressure()) {
+ LOG(MemoryPressure, "Under memory pressure at: %s", __PRETTY_FUNCTION__);
+ removeAllNonVisibleTilesInternal();
+ }
+ activeTileGrid()->createTiles(mode);
+}
+
+unsigned LegacyTileCache::tileCapacityForGrid(LegacyTileGrid* grid)
+{
+ static unsigned capacity;
+ if (!capacity) {
+ size_t totalMemory = systemTotalMemory();
+ totalMemory /= 1024 * 1024;
+ if (totalMemory >= 1024)
+ capacity = 128 * 1024 * 1024;
+ else if (totalMemory >= 512)
+ capacity = 64 * 1024 * 1024;
+ else
+ capacity = 32 * 1024 * 1024;
+ }
+
+ int gridCapacity;
+
+ int memoryLevel = systemMemoryLevel();
+ if (memoryLevel < 15)
+ gridCapacity = capacity / 4;
+ else if (memoryLevel < 20)
+ gridCapacity = capacity / 2;
+ else if (memoryLevel < 30)
+ gridCapacity = capacity * 3 / 4;
+ else
+ gridCapacity = capacity;
+
+ if (keepsZoomedOutTiles() && grid == m_zoomedOutTileGrid) {
+ if (activeTileGrid() == m_zoomedOutTileGrid)
+ return gridCapacity;
+ return gridCapacity / 4;
+ }
+ return gridCapacity * 3 / 4;
+}
+
+Color LegacyTileCache::colorForGridTileBorder(LegacyTileGrid* grid) const
+{
+ if (grid == m_zoomedOutTileGrid)
+ return Color(.3f, .0f, 0.4f, 0.5f);
+
+ return Color(.0f, .0f, 0.4f, 0.5f);
+}
+
+static bool shouldRepaintInPieces(const CGRect& dirtyRect, CGSRegionObj dirtyRegion, CGFloat contentsScale)
+{
+ // Estimate whether or not we should use the unioned rect or the individual rects.
+ // We do this by computing the percentage of "wasted space" in the union. If that wasted space
+ // is too large, then we will do individual rect painting instead.
+ float singlePixels = 0;
+ unsigned rectCount = 0;
+
+ CGSRegionEnumeratorObj enumerator = CGSRegionEnumerator(dirtyRegion);
+ CGRect *subRect;
+ while ((subRect = CGSNextRect(enumerator))) {
+ ++rectCount;
+ singlePixels += subRect->size.width * subRect->size.height;
+ }
+ singlePixels /= (contentsScale * contentsScale);
+ CGSReleaseRegionEnumerator(enumerator);
+
+ const unsigned cRectThreshold = 10;
+ if (rectCount < 2 || rectCount > cRectThreshold)
+ return false;
+
+ const float cWastedSpaceThreshold = 0.50f;
+ float unionPixels = dirtyRect.size.width * dirtyRect.size.height;
+ float wastedSpace = 1.f - (singlePixels / unionPixels);
+ return wastedSpace > cWastedSpaceThreshold;
+}
+
+void LegacyTileCache::drawReplacementImage(LegacyTileLayer* layer, CGContextRef context, CGImageRef image)
+{
+ CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+ CGContextFillRect(context, CGContextGetClipBoundingBox(context));
+
+ CGFloat contentsScale = [layer contentsScale];
+ CGContextScaleCTM(context, 1 / contentsScale, -1 / contentsScale);
+ CGRect imageRect = CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image));
+ CGContextTranslateCTM(context, 0, -imageRect.size.height);
+ CGContextDrawImage(context, imageRect, image);
+}
+
+void LegacyTileCache::drawWindowContent(LegacyTileLayer* layer, CGContextRef context, CGRect dirtyRect)
+{
+ CGRect frame = [layer frame];
+ WKFontAntialiasingStateSaver fontAntialiasingState(context, [m_window useOrientationDependentFontAntialiasing] && [layer isOpaque]);
+ fontAntialiasingState.setup([WAKWindow hasLandscapeOrientation]);
+
+ CGSRegionObj drawRegion = (CGSRegionObj)[layer regionBeingDrawn];
+ CGFloat contentsScale = [layer contentsScale];
+ if (drawRegion && shouldRepaintInPieces(dirtyRect, drawRegion, contentsScale)) {
+ // Use fine grained repaint rectangles to minimize the amount of painted pixels.
+ CGSRegionEnumeratorObj enumerator = CGSRegionEnumerator(drawRegion);
+ CGRect *subRect;
+ while ((subRect = CGSNextRect(enumerator))) {
+ CGRect adjustedSubRect = *subRect;
+ adjustedSubRect.origin.x /= contentsScale;
+ adjustedSubRect.origin.y = frame.size.height - (adjustedSubRect.origin.y + adjustedSubRect.size.height) / contentsScale;
+ adjustedSubRect.size.width /= contentsScale;
+ adjustedSubRect.size.height /= contentsScale;
+
+ CGRect subRectInSuper = [hostLayer() convertRect:adjustedSubRect fromLayer:layer];
+ [m_window displayRect:subRectInSuper];
+ }
+ CGSReleaseRegionEnumerator(enumerator);
+ } else {
+ // Simple repaint
+ CGRect dirtyRectInSuper = [hostLayer() convertRect:dirtyRect fromLayer:layer];
+ [m_window displayRect:dirtyRectInSuper];
+ }
+
+ fontAntialiasingState.restore();
+}
+
+void LegacyTileCache::drawLayer(LegacyTileLayer* layer, CGContextRef context)
+{
+ // The web lock unlock observer runs after CA commit observer.
+ if (!WebThreadIsLockedOrDisabled()) {
+ LOG_ERROR("Drawing without holding the web thread lock");
+ ASSERT_NOT_REACHED();
+ }
+
+ WKSetCurrentGraphicsContext(context);
+
+ CGRect dirtyRect = CGContextGetClipBoundingBox(context);
+ CGRect frame = [layer frame];
+ CGContextTranslateCTM(context, -frame.origin.x, -frame.origin.y);
+ CGRect scaledFrame = [hostLayer() convertRect:[layer bounds] fromLayer:layer];
+ CGContextScaleCTM(context, frame.size.width / scaledFrame.size.width, frame.size.height / scaledFrame.size.height);
+
+ if (RetainPtr<CGImage> contentReplacementImage = this->contentReplacementImage())
+ drawReplacementImage(layer, context, contentReplacementImage.get());
+ else
+ drawWindowContent(layer, context, dirtyRect);
+
+ ++layer.paintCount;
+ if (m_tilePaintCountersVisible) {
+ char text[16];
+ snprintf(text, sizeof(text), "%d", layer.paintCount);
+
+ CGContextSaveGState(context);
+
+ CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
+ CGContextSetFillColorWithColor(context, cachedCGColor(colorForGridTileBorder([layer tileGrid]), ColorSpaceDeviceRGB));
+
+ CGRect labelBounds = [layer bounds];
+ labelBounds.size.width = 10 + 12 * strlen(text);
+ labelBounds.size.height = 25;
+ CGContextFillRect(context, labelBounds);
+
+ if (acceleratedDrawingEnabled())
+ CGContextSetRGBFillColor(context, 1, 0, 0, 0.4f);
+ else
+ CGContextSetRGBFillColor(context, 1, 1, 1, 0.6f);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextSelectFont(context, "Helvetica", 25, kCGEncodingMacRoman);
+ CGContextShowTextAtPoint(context, labelBounds.origin.x + 3, labelBounds.origin.y + 20, text, strlen(text));
+#pragma clang diagnostic pop
+
+ CGContextRestoreGState(context);
+ }
+
+ WAKView* view = [m_window contentView];
+ [view performSelector:@selector(_dispatchTileDidDraw:) withObject:layer afterDelay:0.0];
+}
+
+void LegacyTileCache::setNeedsDisplay()
+{
+ setNeedsDisplayInRect(IntRect(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()));
+}
+
+void LegacyTileCache::scheduleLayerFlushForPendingRepaint()
+{
+ WAKView* view = [m_window contentView];
+ [view _scheduleLayerFlushForPendingTileCacheRepaint];
+}
+
+void LegacyTileCache::setNeedsDisplayInRect(const IntRect& dirtyRect)
+{
+ MutexLocker locker(m_savedDisplayRectMutex);
+ bool addedFirstRect = m_savedDisplayRects.isEmpty();
+ m_savedDisplayRects.append(dirtyRect);
+ if (!addedFirstRect)
+ return;
+ // Compositing layer flush will call back to doPendingRepaints(). The flush may be throttled and not happen immediately.
+ scheduleLayerFlushForPendingRepaint();
+}
+
+void LegacyTileCache::invalidateTiles(const IntRect& dirtyRect)
+{
+ ASSERT(!m_tileMutex.tryLock());
+
+ LegacyTileGrid* activeGrid = activeTileGrid();
+ if (!keepsZoomedOutTiles()) {
+ activeGrid->invalidateTiles(dirtyRect);
+ return;
+ }
+ FloatRect scaledRect = dirtyRect;
+ scaledRect.scale(zoomedOutScale() / currentScale());
+ IntRect zoomedOutDirtyRect = enclosingIntRect(scaledRect);
+ if (activeGrid == m_zoomedOutTileGrid) {
+ bool dummy;
+ IntRect coverRect = m_zoomedOutTileGrid->calculateCoverRect(m_zoomedOutTileGrid->visibleRect(), dummy);
+ // Instead of repainting a tile outside the cover rect, just remove it.
+ m_zoomedOutTileGrid->dropTilesBetweenRects(zoomedOutDirtyRect, coverRect);
+ m_zoomedOutTileGrid->invalidateTiles(zoomedOutDirtyRect);
+ // We need to invalidate zoomed in tiles as well while zooming, since
+ // we could switch back to the zoomed in grid without dropping its
+ // tiles. See <rdar://problem/9946759>.
+ if (m_tilingMode == Zooming && m_zoomedInTileGrid)
+ m_zoomedInTileGrid->invalidateTiles(dirtyRect);
+ return;
+ }
+ if (!m_zoomedInTileGrid->hasTiles()) {
+ // If no tiles have been created yet for the zoomed in grid, we can't drop the zoomed out tiles.
+ m_zoomedOutTileGrid->invalidateTiles(zoomedOutDirtyRect);
+ return;
+ }
+ m_zoomedOutTileGrid->dropTilesIntersectingRect(zoomedOutDirtyRect);
+ m_zoomedInTileGrid->invalidateTiles(dirtyRect);
+}
+
+bool LegacyTileCache::isTileCreationSuspended() const
+{
+ return (!keepsZoomedOutTiles() && m_tilingMode == Zooming) || m_tilingMode == Disabled;
+}
+
+bool LegacyTileCache::isTileInvalidationSuspended() const
+{
+ return m_tilingMode == Zooming || m_tilingMode == Panning || m_tilingMode == ScrollToTop || m_tilingMode == Disabled;
+}
+
+void LegacyTileCache::updateTilingMode()
+{
+ ASSERT(WebThreadIsCurrent() || !WebThreadIsEnabled());
+
+ WAKView* view = [m_window contentView];
+
+ if (m_tilingMode == Zooming || m_tilingMode == Panning || m_tilingMode == ScrollToTop) {
+ if (!m_didCallWillStartScrollingOrZooming) {
+ [view _willStartScrollingOrZooming];
+ m_didCallWillStartScrollingOrZooming = true;
+ }
+ } else {
+ if (m_didCallWillStartScrollingOrZooming) {
+ [view _didFinishScrollingOrZooming];
+ m_didCallWillStartScrollingOrZooming = false;
+ }
+ if (m_tilingMode == Disabled)
+ return;
+
+ MutexLocker locker(m_tileMutex);
+ createTilesInActiveGrid(CoverVisibleOnly);
+
+ if (!m_savedDisplayRects.isEmpty())
+ scheduleLayerFlushForPendingRepaint();
+ }
+}
+
+void LegacyTileCache::setTilingMode(TilingMode tilingMode)
+{
+ if (tilingMode == m_tilingMode)
+ return;
+ bool wasZooming = (m_tilingMode == Zooming);
+ m_tilingMode = tilingMode;
+
+ if ((m_pendingZoomedOutScale || m_pendingScale) && m_tilingMode != Disabled)
+ commitScaleChange();
+ else if (wasZooming) {
+ MutexLocker locker(m_tileMutex);
+ bringActiveTileGridToFront();
+ }
+
+ if (m_hasPendingUpdateTilingMode)
+ return;
+ m_hasPendingUpdateTilingMode = true;
+
+ LegacyTileCacheTombstone *tombstone = m_tombstone.get();
+ WebThreadRun(^{
+ if ([tombstone isDead])
+ return;
+ m_hasPendingUpdateTilingMode = false;
+ updateTilingMode();
+ });
+}
+
+void LegacyTileCache::setTilingDirection(TilingDirection tilingDirection)
+{
+ m_tilingDirection = tilingDirection;
+}
+
+LegacyTileCache::TilingDirection LegacyTileCache::tilingDirection() const
+{
+ return m_tilingDirection;
+}
+
+float LegacyTileCache::zoomedOutScale() const
+{
+ return m_zoomedOutTileGrid->scale();
+}
+
+float LegacyTileCache::currentScale() const
+{
+ return m_currentScale;
+}
+
+void LegacyTileCache::doPendingRepaints()
+{
+ if (m_savedDisplayRects.isEmpty())
+ return;
+ if (isTileInvalidationSuspended())
+ return;
+ MutexLocker locker(m_tileMutex);
+ flushSavedDisplayRects();
+}
+
+void LegacyTileCache::flushSavedDisplayRects()
+{
+ ASSERT(!m_tileMutex.tryLock());
+ ASSERT(!m_savedDisplayRects.isEmpty());
+
+ Vector<IntRect> rects;
+ {
+ MutexLocker locker(m_savedDisplayRectMutex);
+ m_savedDisplayRects.swap(rects);
+ }
+ size_t size = rects.size();
+ for (size_t n = 0; n < size; ++n)
+ invalidateTiles(rects[n]);
+}
+
+void LegacyTileCache::setSpeculativeTileCreationEnabled(bool enabled)
+{
+ if (m_isSpeculativeTileCreationEnabled == enabled)
+ return;
+ m_isSpeculativeTileCreationEnabled = enabled;
+ if (m_isSpeculativeTileCreationEnabled)
+ m_tileCreationTimer.startOneShot(0);
+}
+
+bool LegacyTileCache::hasPendingDraw() const
+{
+ return !m_savedDisplayRects.isEmpty();
+}
+
+void LegacyTileCache::prepareToDraw()
+{
+ // This will trigger document relayout if needed.
+ [[m_window contentView] viewWillDraw];
+
+ if (!m_savedDisplayRects.isEmpty()) {
+ MutexLocker locker(m_tileMutex);
+ flushSavedDisplayRects();
+ }
+}
+
+void LegacyTileCache::setLayerPoolCapacity(unsigned capacity)
+{
+ LegacyTileLayerPool::sharedPool()->setCapacity(capacity);
+}
+
+void LegacyTileCache::drainLayerPool()
+{
+ LegacyTileLayerPool::sharedPool()->drain();
+}
+
+void LegacyTileCache::dumpTiles()
+{
+ NSLog(@"=================");
+ NSLog(@"ZOOMED OUT");
+ if (m_zoomedOutTileGrid == activeTileGrid())
+ NSLog(@"<ACTIVE>");
+ m_zoomedOutTileGrid->dumpTiles();
+ NSLog(@"=================");
+ if (m_zoomedInTileGrid) {
+ NSLog(@"ZOOMED IN");
+ if (m_zoomedInTileGrid == activeTileGrid())
+ NSLog(@"<ACTIVE>");
+ m_zoomedInTileGrid->dumpTiles();
+ NSLog(@"=================");
+ }
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridhfromrev166453trunkSourceWebCoreplatformiosTileGridh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileGrid.h (from rev 166453, trunk/Source/WebCore/platform/ios/TileGrid.h) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGrid.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGrid.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,143 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 LegacyTileGrid_h
+#define LegacyTileGrid_h
+
+#if PLATFORM(IOS)
+
+#include "IntPoint.h"
+#include "IntPointHash.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "LegacyTileCache.h"
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+
+#define LOG_TILING 0
+
+@class CALayer;
+
+namespace WebCore {
+
+class LegacyTileGridTile;
+
+class LegacyTileGrid {
+ WTF_MAKE_NONCOPYABLE(LegacyTileGrid);
+public:
+ typedef IntPoint TileIndex;
+
+ static PassOwnPtr<LegacyTileGrid> create(LegacyTileCache* cache, const IntSize& tileSize) { return adoptPtr(new LegacyTileGrid(cache, tileSize)); }
+
+ ~LegacyTileGrid();
+
+ LegacyTileCache* tileCache() const { return m_tileCache; }
+
+ CALayer *tileHostLayer() const;
+ IntRect bounds() const;
+ unsigned tileCount() const;
+
+ float scale() const { return m_scale; }
+ void setScale(float scale) { m_scale = scale; }
+
+ IntRect visibleRect() const;
+
+ void createTiles(LegacyTileCache::SynchronousTileCreationMode);
+
+ void dropAllTiles();
+ void dropInvalidTiles();
+ void dropTilesOutsideRect(const IntRect&);
+ void dropTilesIntersectingRect(const IntRect&);
+ // Drops tiles that intersect dropRect but do not intersect keepRect.
+ void dropTilesBetweenRects(const IntRect& dropRect, const IntRect& keepRect);
+ bool dropDistantTiles(unsigned tilesNeeded, double shortestDistance);
+
+ void addTilesCoveringRect(const IntRect&);
+
+ bool tilesCover(const IntRect&) const;
+ void centerTileGridOrigin(const IntRect& visibleRect);
+ void invalidateTiles(const IntRect& dirtyRect);
+
+ void updateTileOpacity();
+ void updateTileBorderVisibility();
+ void updateHostLayerSize();
+ bool checkDoSingleTileLayout();
+
+ bool hasTiles() const { return !m_tiles.isEmpty(); }
+
+ IntRect calculateCoverRect(const IntRect& visibleRect, bool& centerGrid);
+
+ // Logging
+ void dumpTiles();
+
+private:
+ double tileDistance2(const IntRect& visibleRect, const IntRect& tileRect) const;
+ unsigned tileByteSize() const;
+
+ void addTileForIndex(const TileIndex&);
+
+ PassRefPtr<LegacyTileGridTile> tileForIndex(const TileIndex&) const;
+ IntRect tileRectForIndex(const TileIndex&) const;
+ PassRefPtr<LegacyTileGridTile> tileForPoint(const IntPoint&) const;
+ TileIndex tileIndexForPoint(const IntPoint&) const;
+
+ IntRect adjustCoverRectForPageBounds(const IntRect&) const;
+ bool shouldUseMinimalTileCoverage() const;
+
+private:
+ LegacyTileGrid(LegacyTileCache*, const IntSize&);
+
+ LegacyTileCache* m_tileCache;
+ RetainPtr<CALayer> m_tileHostLayer;
+
+ IntPoint m_origin;
+ IntSize m_tileSize;
+
+ float m_scale;
+
+ typedef HashMap<TileIndex, RefPtr<LegacyTileGridTile>> TileMap;
+ TileMap m_tiles;
+
+ IntRect m_validBounds;
+};
+
+static inline IntPoint topLeft(const IntRect& rect)
+{
+ return rect.location();
+}
+
+static inline IntPoint bottomRight(const IntRect& rect)
+{
+ return IntPoint(rect.maxX() - 1, rect.maxY() - 1);
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
+#endif // TileGrid_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridmmfromrev166453trunkSourceWebCoreplatformiosTileGridmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm (from rev 166453, trunk/Source/WebCore/platform/ios/TileGrid.mm) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,567 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 "LegacyTileGrid.h"
+
+#if PLATFORM(IOS)
+
+#include "MemoryPressureHandler.h"
+#include "SystemMemory.h"
+#include "LegacyTileGridTile.h"
+#include "LegacyTileLayer.h"
+#include "LegacyTileLayerPool.h"
+#include "WAKWindow.h"
+#include <CoreGraphics/CoreGraphicsPrivate.h>
+#include <QuartzCore/QuartzCore.h>
+#include <QuartzCore/QuartzCorePrivate.h>
+#include <algorithm>
+#include <functional>
+
+namespace WebCore {
+
+LegacyTileGrid::LegacyTileGrid(LegacyTileCache* tileCache, const IntSize& tileSize)
+ : m_tileCache(tileCache)
+ , m_tileHostLayer(adoptNS([[LegacyTileHostLayer alloc] initWithTileGrid:this]))
+ , m_tileSize(tileSize)
+ , m_scale(1)
+ , m_validBounds(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max())
+{
+}
+
+LegacyTileGrid::~LegacyTileGrid()
+{
+ [m_tileHostLayer removeFromSuperlayer];
+}
+
+IntRect LegacyTileGrid::visibleRect() const
+{
+ IntRect visibleRect = enclosingIntRect(m_tileCache->visibleRectInLayer(m_tileHostLayer.get()));
+
+ // When fast scrolling to the top, move the visible rect there immediately so we have tiles when the scrolling completes.
+ if (m_tileCache->tilingMode() == LegacyTileCache::ScrollToTop)
+ visibleRect.setY(0);
+
+ return visibleRect;
+}
+
+void LegacyTileGrid::dropAllTiles()
+{
+ m_tiles.clear();
+}
+
+void LegacyTileGrid::dropTilesIntersectingRect(const IntRect& dropRect)
+{
+ dropTilesBetweenRects(dropRect, IntRect());
+}
+
+void LegacyTileGrid::dropTilesOutsideRect(const IntRect& keepRect)
+{
+ dropTilesBetweenRects(IntRect(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()), keepRect);
+}
+
+void LegacyTileGrid::dropTilesBetweenRects(const IntRect& dropRect, const IntRect& keepRect)
+{
+ Vector<TileIndex> toRemove;
+ for (const auto& tile : m_tiles) {
+ const TileIndex& index = tile.key;
+ IntRect tileRect = tile.value->rect();
+ if (tileRect.intersects(dropRect) && !tileRect.intersects(keepRect))
+ toRemove.append(index);
+ }
+ unsigned removeCount = toRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ m_tiles.remove(toRemove[n]);
+}
+
+unsigned LegacyTileGrid::tileByteSize() const
+{
+ IntSize tilePixelSize = m_tileSize;
+ tilePixelSize.scale(m_tileCache->screenScale());
+ return LegacyTileLayerPool::bytesBackingLayerWithPixelSize(tilePixelSize);
+}
+
+template <typename T>
+static bool isFartherAway(const std::pair<double, T>& a, const std::pair<double, T>& b)
+{
+ return a.first > b.first;
+}
+
+bool LegacyTileGrid::dropDistantTiles(unsigned tilesNeeded, double shortestDistance)
+{
+ unsigned bytesPerTile = tileByteSize();
+ unsigned bytesNeeded = tilesNeeded * bytesPerTile;
+ unsigned bytesUsed = tileCount() * bytesPerTile;
+ unsigned maximumBytes = m_tileCache->tileCapacityForGrid(this);
+
+ int bytesToReclaim = int(bytesUsed) - (int(maximumBytes) - bytesNeeded);
+ if (bytesToReclaim <= 0)
+ return true;
+
+ unsigned tilesToRemoveCount = bytesToReclaim / bytesPerTile;
+
+ IntRect visibleRect = this->visibleRect();
+ Vector<std::pair<double, TileIndex>> toRemove;
+ for (const auto& tile : m_tiles) {
+ const TileIndex& index = tile.key;
+ const IntRect& tileRect = tile.value->rect();
+ double distance = tileDistance2(visibleRect, tileRect);
+ if (distance <= shortestDistance)
+ continue;
+ toRemove.append(std::make_pair(distance, index));
+ std::push_heap(toRemove.begin(), toRemove.end(), std::ptr_fun(isFartherAway<TileIndex>));
+ if (toRemove.size() > tilesToRemoveCount) {
+ std::pop_heap(toRemove.begin(), toRemove.end(), std::ptr_fun(isFartherAway<TileIndex>));
+ toRemove.removeLast();
+ }
+ }
+ size_t removeCount = toRemove.size();
+ for (size_t n = 0; n < removeCount; ++n)
+ m_tiles.remove(toRemove[n].second);
+
+ if (!shortestDistance)
+ return true;
+
+ return tileCount() * bytesPerTile + bytesNeeded <= maximumBytes;
+}
+
+void LegacyTileGrid::addTilesCoveringRect(const IntRect& rectToCover)
+{
+ // We never draw anything outside of our bounds.
+ IntRect rect(rectToCover);
+ rect.intersect(bounds());
+ if (rect.isEmpty())
+ return;
+
+ TileIndex topLeftIndex = tileIndexForPoint(topLeft(rect));
+ TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(rect));
+ for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
+ for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
+ TileIndex index(xIndex, yIndex);
+ if (!tileForIndex(index))
+ addTileForIndex(index);
+ }
+ }
+}
+
+void LegacyTileGrid::addTileForIndex(const TileIndex& index)
+{
+ m_tiles.set(index, LegacyTileGridTile::create(this, tileRectForIndex(index)));
+}
+
+CALayer* LegacyTileGrid::tileHostLayer() const
+{
+ return m_tileHostLayer.get();
+}
+
+IntRect LegacyTileGrid::bounds() const
+{
+ return IntRect(IntPoint(), IntSize([tileHostLayer() size]));
+}
+
+PassRefPtr<LegacyTileGridTile> LegacyTileGrid::tileForIndex(const TileIndex& index) const
+{
+ return m_tiles.get(index);
+}
+
+IntRect LegacyTileGrid::tileRectForIndex(const TileIndex& index) const
+{
+ IntRect rect(index.x() * m_tileSize.width() - (m_origin.x() ? m_tileSize.width() - m_origin.x() : 0),
+ index.y() * m_tileSize.height() - (m_origin.y() ? m_tileSize.height() - m_origin.y() : 0),
+ m_tileSize.width(),
+ m_tileSize.height());
+ rect.intersect(bounds());
+ return rect;
+}
+
+LegacyTileGrid::TileIndex LegacyTileGrid::tileIndexForPoint(const IntPoint& point) const
+{
+ ASSERT(m_origin.x() < m_tileSize.width());
+ ASSERT(m_origin.y() < m_tileSize.height());
+ int x = (point.x() + (m_origin.x() ? m_tileSize.width() - m_origin.x() : 0)) / m_tileSize.width();
+ int y = (point.y() + (m_origin.y() ? m_tileSize.height() - m_origin.y() : 0)) / m_tileSize.height();
+ return TileIndex(std::max(x, 0), std::max(y, 0));
+}
+
+void LegacyTileGrid::centerTileGridOrigin(const IntRect& visibleRect)
+{
+ if (visibleRect.isEmpty())
+ return;
+
+ unsigned minimumHorizontalTiles = 1 + (visibleRect.width() - 1) / m_tileSize.width();
+ unsigned minimumVerticalTiles = 1 + (visibleRect.height() - 1) / m_tileSize.height();
+ TileIndex currentTopLeftIndex = tileIndexForPoint(topLeft(visibleRect));
+ TileIndex currentBottomRightIndex = tileIndexForPoint(bottomRight(visibleRect));
+ unsigned currentHorizontalTiles = currentBottomRightIndex.x() - currentTopLeftIndex.x() + 1;
+ unsigned currentVerticalTiles = currentBottomRightIndex.y() - currentTopLeftIndex.y() + 1;
+
+ // If we have tiles already, only center if we would get benefits from both directions (as we need to throw out existing tiles).
+ if (tileCount() && (currentHorizontalTiles == minimumHorizontalTiles || currentVerticalTiles == minimumVerticalTiles))
+ return;
+
+ IntPoint newOrigin(0, 0);
+ IntSize size = bounds().size();
+ if (size.width() > m_tileSize.width()) {
+ newOrigin.setX((visibleRect.x() - (minimumHorizontalTiles * m_tileSize.width() - visibleRect.width()) / 2) % m_tileSize.width());
+ if (newOrigin.x() < 0)
+ newOrigin.setX(0);
+ }
+ if (size.height() > m_tileSize.height()) {
+ newOrigin.setY((visibleRect.y() - (minimumVerticalTiles * m_tileSize.height() - visibleRect.height()) / 2) % m_tileSize.height());
+ if (newOrigin.y() < 0)
+ newOrigin.setY(0);
+ }
+
+ // Drop all existing tiles if the origin moved.
+ if (newOrigin == m_origin)
+ return;
+ m_tiles.clear();
+ m_origin = newOrigin;
+}
+
+PassRefPtr<LegacyTileGridTile> LegacyTileGrid::tileForPoint(const IntPoint& point) const
+{
+ return tileForIndex(tileIndexForPoint(point));
+}
+
+bool LegacyTileGrid::tilesCover(const IntRect& rect) const
+{
+ return tileForPoint(rect.location()) && tileForPoint(IntPoint(rect.maxX() - 1, rect.y())) &&
+ tileForPoint(IntPoint(rect.x(), rect.maxY() - 1)) && tileForPoint(IntPoint(rect.maxX() - 1, rect.maxY() - 1));
+}
+
+void LegacyTileGrid::updateTileOpacity()
+{
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it)
+ [it->value->tileLayer() setOpaque:m_tileCache->tilesOpaque()];
+}
+
+void LegacyTileGrid::updateTileBorderVisibility()
+{
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it)
+ it->value->showBorder(m_tileCache->tileBordersVisible());
+}
+
+unsigned LegacyTileGrid::tileCount() const
+{
+ return m_tiles.size();
+}
+
+bool LegacyTileGrid::checkDoSingleTileLayout()
+{
+ IntSize size = bounds().size();
+ if (size.width() > m_tileSize.width() || size.height() > m_tileSize.height())
+ return false;
+
+ if (m_origin != IntPoint(0, 0)) {
+ m_tiles.clear();
+ m_origin = IntPoint(0, 0);
+ }
+
+ dropInvalidTiles();
+
+ if (size.isEmpty()) {
+ ASSERT(!m_tiles.get(TileIndex(0, 0)));
+ return true;
+ }
+
+ TileIndex originIndex(0, 0);
+ if (!m_tiles.get(originIndex))
+ m_tiles.set(originIndex, LegacyTileGridTile::create(this, tileRectForIndex(originIndex)));
+
+ return true;
+}
+
+void LegacyTileGrid::updateHostLayerSize()
+{
+ CALayer* hostLayer = m_tileCache->hostLayer();
+ CGRect tileHostBounds = [hostLayer convertRect:[hostLayer bounds] toLayer:tileHostLayer()];
+ CGSize transformedSize;
+ transformedSize.width = CGRound(tileHostBounds.size.width);
+ transformedSize.height = CGRound(tileHostBounds.size.height);
+
+ CGRect bounds = [tileHostLayer() bounds];
+ if (CGSizeEqualToSize(bounds.size, transformedSize))
+ return;
+ bounds.size = transformedSize;
+ [tileHostLayer() setBounds:bounds];
+}
+
+void LegacyTileGrid::dropInvalidTiles()
+{
+ IntRect bounds = this->bounds();
+ IntRect dropBounds = intersection(m_validBounds, bounds);
+ Vector<TileIndex> toRemove;
+ for (const auto& tile : m_tiles) {
+ const TileIndex& index = tile.key;
+ const IntRect& tileRect = tile.value->rect();
+ IntRect expectedTileRect = tileRectForIndex(index);
+ if (expectedTileRect != tileRect || !dropBounds.contains(tileRect))
+ toRemove.append(index);
+ }
+ unsigned removeCount = toRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ m_tiles.remove(toRemove[n]);
+
+ m_validBounds = bounds;
+}
+
+void LegacyTileGrid::invalidateTiles(const IntRect& dirtyRect)
+{
+ if (!hasTiles())
+ return;
+
+ IntRect bounds = this->bounds();
+ if (intersection(bounds, m_validBounds) != m_validBounds) {
+ // The bounds have got smaller. Everything outside will also be considered invalid and will be dropped by dropInvalidTiles().
+ // Due to dirtyRect being limited to current bounds the tiles that are temporarily outside might miss invalidation
+ // completely othwerwise.
+ m_validBounds = bounds;
+ }
+
+ Vector<TileIndex> invalidatedTiles;
+
+ if (dirtyRect.width() > m_tileSize.width() * 4 || dirtyRect.height() > m_tileSize.height() * 4) {
+ // For large invalidates, iterate over live tiles.
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ LegacyTileGridTile* tile = it->value.get();
+ if (!tile->rect().intersects(dirtyRect))
+ continue;
+ tile->invalidateRect(dirtyRect);
+ invalidatedTiles.append(it->key);
+ }
+ } else {
+ TileIndex topLeftIndex = tileIndexForPoint(topLeft(dirtyRect));
+ TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(dirtyRect));
+ for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
+ for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
+ TileIndex index(xIndex, yIndex);
+ RefPtr<LegacyTileGridTile> tile = tileForIndex(index);
+ if (!tile)
+ continue;
+ if (!tile->rect().intersects(dirtyRect))
+ continue;
+ tile->invalidateRect(dirtyRect);
+ invalidatedTiles.append(index);
+ }
+ }
+ }
+ if (invalidatedTiles.isEmpty())
+ return;
+ // When using minimal coverage, drop speculative tiles instead of updating them.
+ if (!shouldUseMinimalTileCoverage())
+ return;
+ if (m_tileCache->tilingMode() != LegacyTileCache::Minimal && m_tileCache->tilingMode() != LegacyTileCache::Normal)
+ return;
+ IntRect visibleRect = this->visibleRect();
+ unsigned count = invalidatedTiles.size();
+ for (unsigned i = 0; i < count; ++i) {
+ RefPtr<LegacyTileGridTile> tile = tileForIndex(invalidatedTiles[i]);
+ if (!tile->rect().intersects(visibleRect))
+ m_tiles.remove(invalidatedTiles[i]);
+ }
+}
+
+bool LegacyTileGrid::shouldUseMinimalTileCoverage() const
+{
+ return m_tileCache->tilingMode() == LegacyTileCache::Minimal
+ || !m_tileCache->isSpeculativeTileCreationEnabled()
+ || memoryPressureHandler().hasReceivedMemoryPressure();
+}
+
+IntRect LegacyTileGrid::adjustCoverRectForPageBounds(const IntRect& rect) const
+{
+ // Adjust the rect so that it stays within the bounds and keeps the pixel size.
+ IntRect bounds = this->bounds();
+ IntRect adjustedRect = rect;
+ adjustedRect.move(rect.x() < bounds.x() ? bounds.x() - rect.x() : 0,
+ rect.y() < bounds.y() ? bounds.y() - rect.y() : 0);
+ adjustedRect.move(rect.maxX() > bounds.maxX() ? bounds.maxX() - rect.maxX() : 0,
+ rect.maxY() > bounds.maxY() ? bounds.maxY() - rect.maxY() : 0);
+ adjustedRect = intersection(bounds, adjustedRect);
+ if (adjustedRect == rect || adjustedRect.isEmpty() || shouldUseMinimalTileCoverage())
+ return adjustedRect;
+ int pixels = adjustedRect.width() * adjustedRect.height();
+ if (adjustedRect.width() != rect.width())
+ adjustedRect.inflateY((pixels / adjustedRect.width() - adjustedRect.height()) / 2);
+ else if (adjustedRect.height() != rect.height())
+ adjustedRect.inflateX((pixels / adjustedRect.height() - adjustedRect.width()) / 2);
+ return intersection(adjustedRect, bounds);
+}
+
+IntRect LegacyTileGrid::calculateCoverRect(const IntRect& visibleRect, bool& centerGrid)
+{
+ // Use minimum coverRect if we are under memory pressure.
+ if (shouldUseMinimalTileCoverage()) {
+ centerGrid = true;
+ return visibleRect;
+ }
+ IntRect coverRect = visibleRect;
+ centerGrid = false;
+ coverRect.inflateX(visibleRect.width() / 2);
+ coverRect.inflateY(visibleRect.height());
+ return adjustCoverRectForPageBounds(coverRect);
+}
+
+double LegacyTileGrid::tileDistance2(const IntRect& visibleRect, const IntRect& tileRect) const
+{
+ // The "distance" calculated here is used to pick which tile to cache next. The idea is to create those
+ // closest to the current viewport first so the user is more likely to see already rendered content we she
+ // scrolls. The calculation is weighted to prefer vertical and downward direction.
+ if (visibleRect.intersects(tileRect))
+ return 0;
+ IntPoint visibleCenter = visibleRect.location() + IntSize(visibleRect.width() / 2, visibleRect.height() / 2);
+ IntPoint tileCenter = tileRect.location() + IntSize(tileRect.width() / 2, tileRect.height() / 2);
+
+ double horizontalBias = 1.0;
+ double leftwardBias = 1.0;
+ double rightwardBias = 1.0;
+
+ double verticalBias = 1.0;
+ double upwardBias = 1.0;
+ double downwardBias = 1.0;
+
+ const double tilingBiasVeryLikely = 0.8;
+ const double tilingBiasLikely = 0.9;
+
+ switch (m_tileCache->tilingDirection()) {
+ case LegacyTileCache::TilingDirectionUp:
+ verticalBias = tilingBiasVeryLikely;
+ upwardBias = tilingBiasLikely;
+ break;
+ case LegacyTileCache::TilingDirectionDown:
+ verticalBias = tilingBiasVeryLikely;
+ downwardBias = tilingBiasLikely;
+ break;
+ case LegacyTileCache::TilingDirectionLeft:
+ horizontalBias = tilingBiasVeryLikely;
+ leftwardBias = tilingBiasLikely;
+ break;
+ case LegacyTileCache::TilingDirectionRight:
+ horizontalBias = tilingBiasVeryLikely;
+ rightwardBias = tilingBiasLikely;
+ break;
+ }
+
+ double xScale = horizontalBias * visibleRect.height() / visibleRect.width() * (tileCenter.x() >= visibleCenter.x() ? rightwardBias : leftwardBias);
+ double yScale = verticalBias * visibleRect.width() / visibleRect.height() * (tileCenter.y() >= visibleCenter.y() ? downwardBias : upwardBias);
+
+ double xDistance = xScale * (tileCenter.x() - visibleCenter.x());
+ double yDistance = yScale * (tileCenter.y() - visibleCenter.y());
+
+ double distance2 = xDistance * xDistance + yDistance * yDistance;
+ return distance2;
+}
+
+void LegacyTileGrid::createTiles(LegacyTileCache::SynchronousTileCreationMode creationMode)
+{
+ IntRect visibleRect = this->visibleRect();
+ if (visibleRect.isEmpty())
+ return;
+
+ // Drop tiles that are wrong size or outside the frame (because the frame has been resized).
+ dropInvalidTiles();
+
+ bool centerGrid;
+ IntRect coverRect = calculateCoverRect(visibleRect, centerGrid);
+
+ // If tile size is bigger than the view, centering minimizes the painting needed to cover the screen.
+ // This is especially useful after zooming
+ centerGrid = centerGrid || !tileCount();
+ if (centerGrid)
+ centerTileGridOrigin(visibleRect);
+
+ double shortestDistance = std::numeric_limits<double>::infinity();
+ double coveredDistance = 0;
+ Vector<LegacyTileGrid::TileIndex> tilesToCreate;
+ unsigned pendingTileCount = 0;
+
+ LegacyTileGrid::TileIndex topLeftIndex = tileIndexForPoint(topLeft(coverRect));
+ LegacyTileGrid::TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(coverRect));
+ for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
+ for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
+ LegacyTileGrid::TileIndex index(xIndex, yIndex);
+ // Currently visible tiles have distance of 0 and get all created in the same transaction.
+ double distance = tileDistance2(visibleRect, tileRectForIndex(index));
+ if (distance > coveredDistance)
+ coveredDistance = distance;
+ if (tileForIndex(index))
+ continue;
+ ++pendingTileCount;
+ if (distance > shortestDistance)
+ continue;
+ if (distance < shortestDistance) {
+ tilesToCreate.clear();
+ shortestDistance = distance;
+ }
+ tilesToCreate.append(index);
+ }
+ }
+
+ size_t tilesToCreateCount = tilesToCreate.size();
+
+ // Tile creation timer will invoke this function again in CoverSpeculative mode.
+ bool candidateTilesAreSpeculative = shortestDistance > 0;
+ if (creationMode == LegacyTileCache::CoverVisibleOnly && candidateTilesAreSpeculative)
+ tilesToCreateCount = 0;
+
+ // Even if we don't create any tiles, we should still drop distant tiles
+ // in case coverRect got smaller.
+ double keepDistance = std::min(shortestDistance, coveredDistance);
+ if (!dropDistantTiles(tilesToCreateCount, keepDistance))
+ return;
+
+ ASSERT(pendingTileCount >= tilesToCreateCount);
+ if (!pendingTileCount)
+ return;
+
+ for (size_t n = 0; n < tilesToCreateCount; ++n)
+ addTileForIndex(tilesToCreate[n]);
+
+ bool didCreateTiles = !!tilesToCreateCount;
+ bool createMoreTiles = pendingTileCount > tilesToCreateCount;
+ m_tileCache->finishedCreatingTiles(didCreateTiles, createMoreTiles);
+}
+
+void LegacyTileGrid::dumpTiles()
+{
+ IntRect visibleRect = this->visibleRect();
+ NSLog(@"transformed visibleRect = [%6d %6d %6d %6d]", visibleRect.x(), visibleRect.y(), visibleRect.width(), visibleRect.height());
+ unsigned i = 0;
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ TileIndex& index = it->key;
+ IntRect tileRect = it->value->rect();
+ NSLog(@"#%-3d (%3d %3d) - [%6d %6d %6d %6d]%@", ++i, index.x(), index.y(), tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height(), tileRect.intersects(visibleRect) ? @" *" : @"");
+ NSLog(@" %@", [it->value->tileLayer() contents]);
+ }
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridTilehfromrev166453trunkSourceWebCoreplatformiosTileGridTileh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileGridTile.h (from rev 166453, trunk/Source/WebCore/platform/ios/TileGridTile.h) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGridTile.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGridTile.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 LegacyTileGridTile_h
+#define LegacyTileGridTile_h
+
+#if PLATFORM(IOS)
+
+#include "IntRect.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+@class LegacyTileLayer;
+
+namespace WebCore {
+
+class LegacyTileGrid;
+
+// Refcount the tiles so they work nicely in vector and we know when to remove the tile layer from the parent.
+class LegacyTileGridTile : public RefCounted<LegacyTileGridTile> {
+public:
+ static PassRefPtr<LegacyTileGridTile> create(LegacyTileGrid* grid, const IntRect& rect) { return adoptRef<LegacyTileGridTile>(new LegacyTileGridTile(grid, rect)); }
+ ~LegacyTileGridTile();
+
+ LegacyTileLayer* tileLayer() const { return m_tileLayer.get(); }
+ void invalidateRect(const IntRect& rectInSurface);
+ IntRect rect() const { return m_rect; }
+ void setRect(const IntRect& tileRect);
+ void showBorder(bool);
+
+private:
+ LegacyTileGridTile(LegacyTileGrid*, const IntRect&);
+
+ LegacyTileGrid* m_tileGrid;
+ RetainPtr<LegacyTileLayer> m_tileLayer;
+ IntRect m_rect;
+};
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
+#endif // LegacyTileGridTile_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridTilemmfromrev166453trunkSourceWebCoreplatformiosTileGridTilemm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileGridTile.mm (from rev 166453, trunk/Source/WebCore/platform/ios/TileGridTile.mm) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGridTile.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGridTile.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,131 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 "LegacyTileGridTile.h"
+
+#if PLATFORM(IOS)
+
+#include "Color.h"
+#include "LegacyTileCache.h"
+#include "LegacyTileGrid.h"
+#include "LegacyTileLayer.h"
+#include "LegacyTileLayerPool.h"
+#include "WAKWindow.h"
+#include <QuartzCore/QuartzCore.h>
+#include <QuartzCore/QuartzCorePrivate.h>
+#include <algorithm>
+#include <functional>
+
+namespace WebCore {
+
+#if LOG_TILING
+static int totalTileCount;
+#endif
+
+LegacyTileGridTile::LegacyTileGridTile(LegacyTileGrid* tileGrid, const IntRect& tileRect)
+ : m_tileGrid(tileGrid)
+ , m_rect(tileRect)
+{
+ ASSERT(!tileRect.isEmpty());
+ IntSize pixelSize(m_rect.size());
+ const CGFloat screenScale = m_tileGrid->tileCache()->screenScale();
+ pixelSize.scale(screenScale);
+ m_tileLayer = LegacyTileLayerPool::sharedPool()->takeLayerWithSize(pixelSize);
+ if (!m_tileLayer) {
+#if LOG_TILING
+ NSLog(@"unable to reuse layer with size %d x %d, creating one", pixelSize.width(), pixelSize.height());
+#endif
+ m_tileLayer = adoptNS([[LegacyTileLayer alloc] init]);
+ }
+ LegacyTileLayer* layer = m_tileLayer.get();
+ [layer setTileGrid:tileGrid];
+ [layer setOpaque:m_tileGrid->tileCache()->tilesOpaque()];
+ [layer setEdgeAntialiasingMask:0];
+ [layer setNeedsLayoutOnGeometryChange:NO];
+ [layer setContentsScale:screenScale];
+ [layer setAcceleratesDrawing:m_tileGrid->tileCache()->acceleratedDrawingEnabled()];
+
+ // Host layer may have other sublayers. Keep the tile layers at the beginning of the array
+ // so they are painted behind everything else.
+ [tileGrid->tileHostLayer() insertSublayer:layer atIndex:tileGrid->tileCount()];
+ [layer setFrame:m_rect];
+ invalidateRect(m_rect);
+ showBorder(m_tileGrid->tileCache()->tileBordersVisible());
+
+#if LOG_TILING
+ ++totalTileCount;
+ NSLog(@"new Tile (%d,%d) %d %d, count %d", tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height(), totalTileCount);
+#endif
+}
+
+LegacyTileGridTile::~LegacyTileGridTile()
+{
+ [tileLayer() setTileGrid:0];
+ [tileLayer() removeFromSuperlayer];
+ LegacyTileLayerPool::sharedPool()->addLayer(tileLayer());
+#if LOG_TILING
+ --totalTileCount;
+ NSLog(@"delete Tile (%d,%d) %d %d, count %d", m_rect.x(), m_rect.y(), m_rect.width(), m_rect.height(), totalTileCount);
+#endif
+}
+
+void LegacyTileGridTile::invalidateRect(const IntRect& windowDirtyRect)
+{
+ IntRect dirtyRect = intersection(windowDirtyRect, m_rect);
+ if (dirtyRect.isEmpty())
+ return;
+ dirtyRect.move(IntPoint() - m_rect.location());
+ [tileLayer() setNeedsDisplayInRect:dirtyRect];
+
+ if (m_tileGrid->tileCache()->tilePaintCountersVisible())
+ [tileLayer() setNeedsDisplayInRect:CGRectMake(0, 0, 46, 25)];
+}
+
+void LegacyTileGridTile::setRect(const IntRect& tileRect)
+{
+ if (m_rect == tileRect)
+ return;
+ m_rect = tileRect;
+ LegacyTileLayer* layer = m_tileLayer.get();
+ [layer setFrame:m_rect];
+ [layer setNeedsDisplay];
+}
+
+void LegacyTileGridTile::showBorder(bool flag)
+{
+ LegacyTileLayer* layer = m_tileLayer.get();
+ if (flag) {
+ [layer setBorderColor:cachedCGColor(m_tileGrid->tileCache()->colorForGridTileBorder(m_tileGrid), ColorSpaceDeviceRGB)];
+ [layer setBorderWidth:0.5f];
+ } else {
+ [layer setBorderColor:nil];
+ [layer setBorderWidth:0];
+ }
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayerhfromrev166453trunkSourceWebCoreplatformiosTileLayerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileLayer.h (from rev 166453, trunk/Source/WebCore/platform/ios/TileLayer.h) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayer.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayer.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 LegacyTileLayer_h
+#define LegacyTileLayer_h
+
+#if PLATFORM(IOS)
+
+#include <QuartzCore/CALayer.h>
+
+namespace WebCore {
+class LegacyTileGrid;
+};
+
+@interface LegacyTileLayer : CALayer {
+ WebCore::LegacyTileGrid* _tileGrid;
+ unsigned _paintCount;
+}
+@property (nonatomic) unsigned paintCount;
+@property (nonatomic) WebCore::LegacyTileGrid* tileGrid;
++ (LegacyTileLayer *)layerBeingPainted;
+@end
+
+@interface LegacyTileHostLayer : CALayer {
+ WebCore::LegacyTileGrid* _tileGrid;
+}
+- (id)initWithTileGrid:(WebCore::LegacyTileGrid*)tileGrid;
+@end
+
+#endif // PLATFORM(IOS)
+#endif // TileLayer_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayermmfromrev166453trunkSourceWebCoreplatformiosTileLayermm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileLayer.mm (from rev 166453, trunk/Source/WebCore/platform/ios/TileLayer.mm) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayer.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayer.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,103 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 "LegacyTileLayer.h"
+
+#if PLATFORM(IOS)
+
+#include "LegacyTileCache.h"
+#include "LegacyTileGrid.h"
+#include "WebCoreThread.h"
+
+@implementation LegacyTileHostLayer
+- (id)initWithTileGrid:(WebCore::LegacyTileGrid*)tileGrid
+{
+ self = [super init];
+ if (!self)
+ return nil;
+ _tileGrid = tileGrid;
+ [self setAnchorPoint:CGPointZero];
+ return self;
+}
+
+- (id<CAAction>)actionForKey:(NSString *)key
+{
+ UNUSED_PARAM(key);
+ // Disable all default actions
+ return nil;
+}
+
+- (void)renderInContext:(CGContextRef)context
+{
+ if (pthread_main_np())
+ WebThreadLock();
+ _tileGrid->tileCache()->doLayoutTiles();
+ [super renderInContext:context];
+}
+@end
+
+@implementation LegacyTileLayer
+@synthesize paintCount = _paintCount;
+@synthesize tileGrid = _tileGrid;
+
+static LegacyTileLayer *layerBeingPainted;
+
+- (void)setNeedsDisplayInRect:(CGRect)rect
+{
+ [self setNeedsLayout];
+ [super setNeedsDisplayInRect:rect];
+}
+
+- (void)layoutSublayers
+{
+ if (pthread_main_np())
+ WebThreadLock();
+ // This may trigger WebKit layout and generate more repaint rects.
+ if (_tileGrid)
+ _tileGrid->tileCache()->prepareToDraw();
+}
+
+- (void)drawInContext:(CGContextRef)context
+{
+ if (_tileGrid)
+ _tileGrid->tileCache()->drawLayer(self, context);
+}
+
+- (id<CAAction>)actionForKey:(NSString *)key
+{
+ UNUSED_PARAM(key);
+ // Disable all default actions
+ return nil;
+}
+
++ (LegacyTileLayer *)layerBeingPainted
+{
+ return layerBeingPainted;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayerPoolhfromrev166453trunkSourceWebCoreplatformiosTileLayerPoolh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.h (from rev 166453, trunk/Source/WebCore/platform/ios/TileLayerPool.h) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.h         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 LegacyTileLayerPool_h
+#define LegacyTileLayerPool_h
+
+#if PLATFORM(IOS)
+
+#include "IntSize.h"
+#include "IntSizeHash.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/Vector.h>
+
+@class LegacyTileLayer;
+
+namespace WebCore {
+
+class LegacyTileLayerPool {
+ WTF_MAKE_NONCOPYABLE(LegacyTileLayerPool);
+public:
+ static LegacyTileLayerPool* sharedPool();
+
+ void addLayer(const RetainPtr<LegacyTileLayer>&);
+ RetainPtr<LegacyTileLayer> takeLayerWithSize(const IntSize&);
+
+ // The maximum size of all queued layers in bytes.
+ unsigned capacity() const { return m_capacity; }
+ void setCapacity(unsigned);
+ void drain();
+
+ unsigned decayedCapacity() const;
+
+ static unsigned bytesBackingLayerWithPixelSize(const IntSize&);
+
+private:
+ LegacyTileLayerPool();
+
+ typedef Deque<RetainPtr<LegacyTileLayer> > LayerList;
+
+ bool canReuseLayerWithSize(const IntSize& size) const { return m_capacity && !size.isEmpty(); }
+ void schedulePrune();
+ void prune();
+ typedef enum { LeaveUnchanged, MarkAsUsed } AccessType;
+ LayerList& listOfLayersWithSize(const IntSize&, AccessType = LeaveUnchanged);
+
+ HashMap<IntSize, LayerList> m_reuseLists;
+ // Ordered by recent use. The last size is the most recently used.
+ Vector<IntSize> m_sizesInPruneOrder;
+ unsigned m_totalBytes;
+ unsigned m_capacity;
+ Mutex m_layerPoolMutex;
+
+ double m_lastAddTime;
+ bool m_needsPrune;
+
+ friend NeverDestroyed<LegacyTileLayerPool>;
+};
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
+#endif // TileLayerPool_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayerPoolmmfromrev166453trunkSourceWebCoreplatformiosTileLayerPoolmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm (from rev 166453, trunk/Source/WebCore/platform/ios/TileLayerPool.mm) (0 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm         (rev 0)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -0,0 +1,174 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 "LegacyTileLayerPool.h"
+
+#if PLATFORM(IOS)
+
+#include "LegacyTileLayer.h"
+#include "LegacyTileGrid.h"
+#include "Logging.h"
+#include "MemoryPressureHandler.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+static const double capacityDecayTime = 5;
+
+LegacyTileLayerPool::LegacyTileLayerPool()
+ : m_totalBytes(0)
+ , m_capacity(0)
+ , m_lastAddTime(0)
+ , m_needsPrune(false)
+{
+}
+
+LegacyTileLayerPool* LegacyTileLayerPool::sharedPool()
+{
+ static NeverDestroyed<LegacyTileLayerPool> sharedPool;
+ return &sharedPool.get();
+}
+
+unsigned LegacyTileLayerPool::bytesBackingLayerWithPixelSize(const IntSize& size)
+{
+ return size.width() * size.height() * 4;
+}
+
+LegacyTileLayerPool::LayerList& LegacyTileLayerPool::listOfLayersWithSize(const IntSize& size, AccessType accessType)
+{
+ ASSERT(!m_layerPoolMutex.tryLock());
+ HashMap<IntSize, LayerList>::iterator it = m_reuseLists.find(size);
+ if (it == m_reuseLists.end()) {
+ it = m_reuseLists.add(size, LayerList()).iterator;
+ m_sizesInPruneOrder.append(size);
+ } else if (accessType == MarkAsUsed) {
+ m_sizesInPruneOrder.remove(m_sizesInPruneOrder.reverseFind(size));
+ m_sizesInPruneOrder.append(size);
+ }
+ return it->value;
+}
+
+void LegacyTileLayerPool::addLayer(const RetainPtr<LegacyTileLayer>& layer)
+{
+ IntSize layerSize([layer.get() frame].size);
+ layerSize.scale([layer.get() contentsScale]);
+ if (!canReuseLayerWithSize(layerSize))
+ return;
+
+ if (memoryPressureHandler().hasReceivedMemoryPressure()) {
+ LOG(MemoryPressure, "Under memory pressure: %s, totalBytes: %d", __PRETTY_FUNCTION__, m_totalBytes);
+ return;
+ }
+
+ MutexLocker locker(m_layerPoolMutex);
+ listOfLayersWithSize(layerSize).prepend(layer);
+ m_totalBytes += bytesBackingLayerWithPixelSize(layerSize);
+
+ m_lastAddTime = currentTime();
+ schedulePrune();
+}
+
+RetainPtr<LegacyTileLayer> LegacyTileLayerPool::takeLayerWithSize(const IntSize& size)
+{
+ if (!canReuseLayerWithSize(size))
+ return nil;
+ MutexLocker locker(m_layerPoolMutex);
+ LayerList& reuseList = listOfLayersWithSize(size, MarkAsUsed);
+ if (reuseList.isEmpty())
+ return nil;
+ m_totalBytes -= bytesBackingLayerWithPixelSize(size);
+ return reuseList.takeFirst();
+}
+
+void LegacyTileLayerPool::setCapacity(unsigned capacity)
+{
+ MutexLocker reuseLocker(m_layerPoolMutex);
+ if (capacity < m_capacity)
+ schedulePrune();
+ m_capacity = capacity;
+}
+
+unsigned LegacyTileLayerPool::decayedCapacity() const
+{
+ // Decay to one quarter over capacityDecayTime
+ double timeSinceLastAdd = currentTime() - m_lastAddTime;
+ if (timeSinceLastAdd > capacityDecayTime)
+ return m_capacity / 4;
+ float decayProgess = float(timeSinceLastAdd / capacityDecayTime);
+ return m_capacity / 4 + m_capacity * 3 / 4 * (1.f - decayProgess);
+}
+
+void LegacyTileLayerPool::schedulePrune()
+{
+ ASSERT(!m_layerPoolMutex.tryLock());
+ if (m_needsPrune)
+ return;
+ m_needsPrune = true;
+ dispatch_time_t nextPruneTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
+ dispatch_after(nextPruneTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ prune();
+ });
+}
+
+void LegacyTileLayerPool::prune()
+{
+ MutexLocker locker(m_layerPoolMutex);
+ ASSERT(m_needsPrune);
+ m_needsPrune = false;
+ unsigned shrinkTo = decayedCapacity();
+ while (m_totalBytes > shrinkTo) {
+ ASSERT(!m_sizesInPruneOrder.isEmpty());
+ IntSize sizeToDrop = m_sizesInPruneOrder.first();
+ LayerList& oldestReuseList = m_reuseLists.find(sizeToDrop)->value;
+ if (oldestReuseList.isEmpty()) {
+ m_reuseLists.remove(sizeToDrop);
+ m_sizesInPruneOrder.remove(0);
+ continue;
+ }
+#if LOG_TILING
+ NSLog(@"dropping layer of size %d x %d", sizeToDrop.width(), sizeToDrop.height());
+#endif
+ m_totalBytes -= bytesBackingLayerWithPixelSize(sizeToDrop);
+ // The last element in the list is the oldest, hence most likely not to
+ // still have a backing store.
+ oldestReuseList.removeLast();
+ }
+ if (currentTime() - m_lastAddTime <= capacityDecayTime)
+ schedulePrune();
+}
+
+void LegacyTileLayerPool::drain()
+{
+ MutexLocker reuseLocker(m_layerPoolMutex);
+ m_reuseLists.clear();
+ m_sizesInPruneOrder.clear();
+ m_totalBytes = 0;
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosScrollViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx"> return IntSize();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-TileCache* ScrollView::tileCache()
</del><ins>+LegacyTileCache* ScrollView::legacyTileCache()
</ins><span class="cx"> {
</span><span class="cx"> // Make tile cache pointer available via the main frame only. Tile cache interaction should be managed by
</span><span class="cx"> // the main frame and this avoids having to add parent checks to all call sites.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileCacheh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileCache.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileCache.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileCache.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,218 +0,0 @@
</span><del>-/*
- * Copyright (C) 2009 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 TileCache_h
-#define TileCache_h
-
-#if PLATFORM(IOS)
-
-#include "Color.h"
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "IntSize.h"
-#include "Timer.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
-
-#ifdef __OBJC__
-@class CALayer;
-@class TileCacheTombstone;
-@class TileLayer;
-@class WAKWindow;
-#else
-class CALayer;
-class TileCacheTombstone;
-class TileLayer;
-class WAKWindow;
-#endif
-
-namespace WebCore {
-
-class TileGrid;
-
-class TileCache {
- WTF_MAKE_NONCOPYABLE(TileCache);
-public:
- TileCache(WAKWindow*);
- ~TileCache();
-
- CGFloat screenScale() const;
-
- void setNeedsDisplay();
- void setNeedsDisplayInRect(const IntRect&);
-
- void layoutTiles();
- void layoutTilesNow();
- void layoutTilesNowForRect(const IntRect&);
- void removeAllNonVisibleTiles();
- void removeAllTiles();
- void removeForegroundTiles();
-
- // If 'contentReplacementImage' is not NULL, drawLayer() draws
- // contentReplacementImage instead of the page content. We assume the
- // image is to be drawn at the origin and scaled to match device pixels.
- void setContentReplacementImage(RetainPtr<CGImageRef>);
- RetainPtr<CGImageRef> contentReplacementImage() const;
-
- void setTileBordersVisible(bool);
- bool tileBordersVisible() const { return m_tileBordersVisible; }
-
- void setTilePaintCountersVisible(bool);
- bool tilePaintCountersVisible() const { return m_tilePaintCountersVisible; }
-
- void setAcceleratedDrawingEnabled(bool enabled) { m_acceleratedDrawingEnabled = enabled; }
- bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
-
- void setKeepsZoomedOutTiles(bool);
- bool keepsZoomedOutTiles() const { return m_keepsZoomedOutTiles; }
-
- void setZoomedOutScale(float);
- float zoomedOutScale() const;
-
- void setCurrentScale(float);
- float currentScale() const;
-
- bool tilesOpaque() const;
- void setTilesOpaque(bool);
-
- enum TilingMode {
- Normal,
- Minimal,
- Panning,
- Zooming,
- Disabled,
- ScrollToTop
- };
- TilingMode tilingMode() const { return m_tilingMode; }
- void setTilingMode(TilingMode);
-
- typedef enum {
- TilingDirectionUp,
- TilingDirectionDown,
- TilingDirectionLeft,
- TilingDirectionRight,
- } TilingDirection;
- void setTilingDirection(TilingDirection);
- TilingDirection tilingDirection() const;
-
- bool hasPendingDraw() const;
-
- void hostLayerSizeChanged();
-
- static void setLayerPoolCapacity(unsigned);
- static void drainLayerPool();
-
- // Logging
- void dumpTiles();
-
- // Internal
- void doLayoutTiles();
- void drawLayer(TileLayer*, CGContextRef);
- void prepareToDraw();
- void finishedCreatingTiles(bool didCreateTiles, bool createMore);
- FloatRect visibleRectInLayer(CALayer *) const;
- CALayer* hostLayer() const;
- unsigned tileCapacityForGrid(TileGrid*);
- Color colorForGridTileBorder(TileGrid*) const;
-
- void doPendingRepaints();
-
- bool isSpeculativeTileCreationEnabled() const { return m_isSpeculativeTileCreationEnabled; }
- void setSpeculativeTileCreationEnabled(bool);
-
- enum SynchronousTileCreationMode { CoverVisibleOnly, CoverSpeculative };
-
-private:
- TileGrid* activeTileGrid() const;
- TileGrid* inactiveTileGrid() const;
-
- void updateTilingMode();
- bool isTileInvalidationSuspended() const;
- bool isTileCreationSuspended() const;
- void flushSavedDisplayRects();
- void invalidateTiles(const IntRect& dirtyRect);
- void setZoomedOutScaleInternal(float);
- void commitScaleChange();
- void bringActiveTileGridToFront();
- void adjustTileGridTransforms();
- void removeAllNonVisibleTilesInternal();
- void createTilesInActiveGrid(SynchronousTileCreationMode);
- void scheduleLayerFlushForPendingRepaint();
-
- void tileCreationTimerFired(Timer<TileCache>*);
-
- void drawReplacementImage(TileLayer*, CGContextRef, CGImageRef);
- void drawWindowContent(TileLayer*, CGContextRef, CGRect dirtyRect);
-
- WAKWindow* m_window;
-
- RetainPtr<CGImageRef> m_contentReplacementImage;
-
- bool m_keepsZoomedOutTiles;
-
- bool m_hasPendingLayoutTiles;
- bool m_hasPendingUpdateTilingMode;
- // Ensure there are no async calls on a dead tile cache.
- RetainPtr<TileCacheTombstone> m_tombstone;
-
- TilingMode m_tilingMode;
- TilingDirection m_tilingDirection;
-
- IntSize m_tileSize;
- bool m_tilesOpaque;
-
- bool m_tileBordersVisible;
- bool m_tilePaintCountersVisible;
- bool m_acceleratedDrawingEnabled;
- bool m_isSpeculativeTileCreationEnabled;
-
- bool m_didCallWillStartScrollingOrZooming;
- OwnPtr<TileGrid> m_zoomedOutTileGrid;
- OwnPtr<TileGrid> m_zoomedInTileGrid;
-
- Timer<TileCache> m_tileCreationTimer;
-
- Vector<IntRect> m_savedDisplayRects;
-
- float m_currentScale;
-
- float m_pendingScale;
- float m_pendingZoomedOutScale;
-
- mutable Mutex m_tileMutex;
- mutable Mutex m_savedDisplayRectMutex;
- mutable Mutex m_contentReplacementImageMutex;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
-
-#endif // TileCache_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileCachemm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileCache.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileCache.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileCache.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,822 +0,0 @@
</span><del>-/*
- * Copyright (C) 2009 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 "TileCache.h"
-
-#if PLATFORM(IOS)
-
-#include "Logging.h"
-#include "MemoryPressureHandler.h"
-#include "SystemMemory.h"
-#include "TileGrid.h"
-#include "TileGridTile.h"
-#include "TileLayer.h"
-#include "TileLayerPool.h"
-#include "WAKWindow.h"
-#include "WKGraphics.h"
-#include "WebCoreSystemInterface.h"
-#include "WebCoreThreadRun.h"
-#include <QuartzCore/QuartzCore.h>
-#include <QuartzCore/QuartzCorePrivate.h>
-#include <wtf/CurrentTime.h>
-
-@interface WAKView (WebViewExtras)
-- (void)_dispatchTileDidDraw:(CALayer*)tile;
-- (void)_willStartScrollingOrZooming;
-- (void)_didFinishScrollingOrZooming;
-- (void)_dispatchTileDidDraw;
-- (void)_scheduleLayerFlushForPendingTileCacheRepaint;
-@end
-
-@interface TileCacheTombstone : NSObject {
- BOOL dead;
-}
-@property(getter=isDead) BOOL dead;
-
-@end
-
-@implementation TileCacheTombstone
-
-@synthesize dead;
-
-@end
-
-namespace WebCore {
-
-TileCache::TileCache(WAKWindow* window)
- : m_window(window)
- , m_keepsZoomedOutTiles(false)
- , m_hasPendingLayoutTiles(false)
- , m_hasPendingUpdateTilingMode(false)
- , m_tombstone(adoptNS([[TileCacheTombstone alloc] init]))
- , m_tilingMode(Normal)
- , m_tilingDirection(TilingDirectionDown)
- , m_tileSize(512, 512)
- , m_tilesOpaque(true)
- , m_tileBordersVisible(false)
- , m_tilePaintCountersVisible(false)
- , m_acceleratedDrawingEnabled(false)
- , m_isSpeculativeTileCreationEnabled(true)
- , m_didCallWillStartScrollingOrZooming(false)
- , m_zoomedOutTileGrid(PassOwnPtr<TileGrid>())
- , m_zoomedInTileGrid(PassOwnPtr<TileGrid>())
- , m_tileCreationTimer(this, &TileCache::tileCreationTimerFired)
- , m_currentScale(1.f)
- , m_pendingScale(0)
- , m_pendingZoomedOutScale(0)
-{
- m_zoomedOutTileGrid = TileGrid::create(this, m_tileSize);
- [hostLayer() insertSublayer:m_zoomedOutTileGrid->tileHostLayer() atIndex:0];
- hostLayerSizeChanged();
-}
-
-TileCache::~TileCache()
-{
- [m_tombstone.get() setDead:true];
-}
-
-CGFloat TileCache::screenScale() const
-{
- return [m_window screenScale];
-}
-
-CALayer* TileCache::hostLayer() const
-{
- return [m_window hostLayer];
-}
-
-FloatRect TileCache::visibleRectInLayer(CALayer *layer) const
-{
- return [layer convertRect:[m_window extendedVisibleRect] fromLayer:hostLayer()];
-}
-
-bool TileCache::tilesOpaque() const
-{
- return m_tilesOpaque;
-}
-
-TileGrid* TileCache::activeTileGrid() const
-{
- if (!m_keepsZoomedOutTiles)
- return m_zoomedOutTileGrid.get();
- if (m_tilingMode == Zooming)
- return m_zoomedOutTileGrid.get();
- if (m_zoomedInTileGrid && m_currentScale == m_zoomedInTileGrid->scale())
- return m_zoomedInTileGrid.get();
- return m_zoomedOutTileGrid.get();
-}
-
-TileGrid* TileCache::inactiveTileGrid() const
-{
- return activeTileGrid() == m_zoomedOutTileGrid ? m_zoomedInTileGrid.get() : m_zoomedOutTileGrid.get();
-}
-
-void TileCache::setTilesOpaque(bool opaque)
-{
- if (m_tilesOpaque == opaque)
- return;
-
- MutexLocker locker(m_tileMutex);
-
- m_tilesOpaque = opaque;
- m_zoomedOutTileGrid->updateTileOpacity();
- if (m_zoomedInTileGrid)
- m_zoomedInTileGrid->updateTileOpacity();
-}
-
-void TileCache::doLayoutTiles()
-{
- if (isTileCreationSuspended())
- return;
-
- MutexLocker locker(m_tileMutex);
- TileGrid* activeGrid = activeTileGrid();
- // Even though we aren't actually creating tiles in the inactive grid, we
- // still need to drop invalid tiles in response to a layout.
- // See <rdar://problem/9839867>.
- if (TileGrid* inactiveGrid = inactiveTileGrid())
- inactiveGrid->dropInvalidTiles();
- if (activeGrid->checkDoSingleTileLayout())
- return;
- createTilesInActiveGrid(CoverVisibleOnly);
-}
-
-void TileCache::hostLayerSizeChanged()
-{
- m_zoomedOutTileGrid->updateHostLayerSize();
- if (m_zoomedInTileGrid)
- m_zoomedInTileGrid->updateHostLayerSize();
-}
-
-void TileCache::setKeepsZoomedOutTiles(bool keep)
-{
- m_keepsZoomedOutTiles = keep;
-}
-
-void TileCache::setCurrentScale(float scale)
-{
- ASSERT(scale > 0);
-
- if (currentScale() == scale) {
- m_pendingScale = 0;
- return;
- }
- m_pendingScale = scale;
- if (m_tilingMode == Disabled)
- return;
- commitScaleChange();
-
- if (!keepsZoomedOutTiles() && !isTileInvalidationSuspended()) {
- // Tile invalidation is normally suspended during zooming by UIKit but some applications
- // using custom scrollviews may zoom without triggering the callbacks. Invalidate the tiles explicitly.
- MutexLocker locker(m_tileMutex);
- activeTileGrid()->dropAllTiles();
- activeTileGrid()->createTiles(CoverVisibleOnly);
- }
-}
-
-void TileCache::setZoomedOutScale(float scale)
-{
- ASSERT(scale > 0);
-
- if (zoomedOutScale() == scale) {
- m_pendingZoomedOutScale = 0;
- return;
- }
- m_pendingZoomedOutScale = scale;
- if (m_tilingMode == Disabled)
- return;
- commitScaleChange();
-}
-
-void TileCache::commitScaleChange()
-{
- ASSERT(m_pendingZoomedOutScale || m_pendingScale);
- ASSERT(m_tilingMode != Disabled);
-
- MutexLocker locker(m_tileMutex);
-
- if (m_pendingZoomedOutScale) {
- m_zoomedOutTileGrid->setScale(m_pendingZoomedOutScale);
- m_pendingZoomedOutScale = 0;
- }
-
- if (!m_keepsZoomedOutTiles) {
- ASSERT(activeTileGrid() == m_zoomedOutTileGrid);
- if (m_pendingScale) {
- m_currentScale = m_pendingScale;
- m_zoomedOutTileGrid->setScale(m_currentScale);
- }
- m_pendingScale = 0;
- return;
- }
-
- if (m_pendingScale) {
- m_currentScale = m_pendingScale;
- m_pendingScale = 0;
- }
-
- if (m_currentScale != m_zoomedOutTileGrid->scale()) {
- if (!m_zoomedInTileGrid) {
- m_zoomedInTileGrid = TileGrid::create(this, m_tileSize);
- [hostLayer() addSublayer:m_zoomedInTileGrid->tileHostLayer()];
- hostLayerSizeChanged();
- }
- m_zoomedInTileGrid->setScale(m_currentScale);
- }
-
- // Keep the current ordering during zooming.
- if (m_tilingMode != Zooming)
- bringActiveTileGridToFront();
-
- adjustTileGridTransforms();
- layoutTiles();
-}
-
-void TileCache::bringActiveTileGridToFront()
-{
- TileGrid* activeGrid = activeTileGrid();
- TileGrid* otherGrid = inactiveTileGrid();
- if (!otherGrid)
- return;
- CALayer* frontLayer = activeGrid->tileHostLayer();
- CALayer* otherLayer = otherGrid->tileHostLayer();
- [hostLayer() insertSublayer:frontLayer above:otherLayer];
-}
-
-void TileCache::adjustTileGridTransforms()
-{
- CALayer* zoomedOutHostLayer = m_zoomedOutTileGrid->tileHostLayer();
- float transformScale = currentScale() / zoomedOutScale();
- [zoomedOutHostLayer setTransform:CATransform3DMakeScale(transformScale, transformScale, 1.0f)];
- m_zoomedOutTileGrid->updateHostLayerSize();
-}
-
-void TileCache::layoutTiles()
-{
- if (m_hasPendingLayoutTiles)
- return;
- m_hasPendingLayoutTiles = true;
-
- TileCacheTombstone *tombstone = m_tombstone.get();
- WebThreadRun(^{
- if ([tombstone isDead])
- return;
- m_hasPendingLayoutTiles = false;
- doLayoutTiles();
- });
-}
-
-void TileCache::layoutTilesNow()
-{
- ASSERT(WebThreadIsLockedOrDisabled());
-
- // layoutTilesNow() is called after a zoom, while the tile mode is still set to Zooming.
- // If we checked for isTileCreationSuspended here, that would cause <rdar://problem/8434112> (Page flashes after zooming in/out).
- if (m_tilingMode == Disabled)
- return;
-
- // FIXME: layoutTilesNow should be called after state has been set to non-zooming and the active grid is the final one.
- // Fix this in UIKit side (perhaps also getting rid of this call) and remove this code afterwards.
- // <rdar://problem/9672993>
- TilingMode savedTilingMode = m_tilingMode;
- if (m_tilingMode == Zooming)
- m_tilingMode = Minimal;
-
- MutexLocker locker(m_tileMutex);
- TileGrid* activeGrid = activeTileGrid();
- if (activeGrid->checkDoSingleTileLayout()) {
- m_tilingMode = savedTilingMode;
- return;
- }
- createTilesInActiveGrid(CoverVisibleOnly);
- m_tilingMode = savedTilingMode;
-}
-
-void TileCache::layoutTilesNowForRect(const IntRect& rect)
-{
- ASSERT(WebThreadIsLockedOrDisabled());
- MutexLocker locker(m_tileMutex);
-
- activeTileGrid()->addTilesCoveringRect(rect);
-}
-
-void TileCache::removeAllNonVisibleTiles()
-{
- MutexLocker locker(m_tileMutex);
- removeAllNonVisibleTilesInternal();
-}
-
-void TileCache::removeAllNonVisibleTilesInternal()
-{
- TileGrid* activeGrid = activeTileGrid();
- if (keepsZoomedOutTiles() && activeGrid == m_zoomedInTileGrid && activeGrid->hasTiles())
- m_zoomedOutTileGrid->dropAllTiles();
-
- IntRect activeTileBounds = activeGrid->bounds();
- if (activeTileBounds.width() <= m_tileSize.width() && activeTileBounds.height() <= m_tileSize.height()) {
- // If the view is smaller than a tile, keep the tile even if it is not visible.
- activeGrid->dropTilesOutsideRect(activeTileBounds);
- return;
- }
-
- activeGrid->dropTilesOutsideRect(activeGrid->visibleRect());
-}
-
-void TileCache::removeAllTiles()
-{
- MutexLocker locker(m_tileMutex);
- m_zoomedOutTileGrid->dropAllTiles();
- if (m_zoomedInTileGrid)
- m_zoomedInTileGrid->dropAllTiles();
-}
-
-void TileCache::removeForegroundTiles()
-{
- MutexLocker locker(m_tileMutex);
- if (!keepsZoomedOutTiles())
- m_zoomedOutTileGrid->dropAllTiles();
- if (m_zoomedInTileGrid)
- m_zoomedInTileGrid->dropAllTiles();
-}
-
-void TileCache::setContentReplacementImage(RetainPtr<CGImageRef> contentReplacementImage)
-{
- MutexLocker locker(m_contentReplacementImageMutex);
- m_contentReplacementImage = contentReplacementImage;
-}
-
-RetainPtr<CGImageRef> TileCache::contentReplacementImage() const
-{
- MutexLocker locker(m_contentReplacementImageMutex);
- return m_contentReplacementImage;
-}
-
-void TileCache::setTileBordersVisible(bool flag)
-{
- if (flag == m_tileBordersVisible)
- return;
-
- m_tileBordersVisible = flag;
- m_zoomedOutTileGrid->updateTileBorderVisibility();
- if (m_zoomedInTileGrid)
- m_zoomedInTileGrid->updateTileBorderVisibility();
-}
-
-void TileCache::setTilePaintCountersVisible(bool flag)
-{
- m_tilePaintCountersVisible = flag;
- // The numbers will show up the next time the tiles paint.
-}
-
-void TileCache::finishedCreatingTiles(bool didCreateTiles, bool createMore)
-{
- // We need to ensure that all tiles are showing the same version of the content.
- if (didCreateTiles && !m_savedDisplayRects.isEmpty())
- flushSavedDisplayRects();
-
- if (keepsZoomedOutTiles()) {
- if (m_zoomedInTileGrid && activeTileGrid() == m_zoomedOutTileGrid && m_tilingMode != Zooming && m_zoomedInTileGrid->hasTiles()) {
- // This CA transaction will cover the screen with top level tiles.
- // We can remove zoomed-in tiles without flashing.
- m_zoomedInTileGrid->dropAllTiles();
- } else if (activeTileGrid() == m_zoomedInTileGrid) {
- // Pass the minimum possible distance to consider all tiles, even visible ones.
- m_zoomedOutTileGrid->dropDistantTiles(0, std::numeric_limits<double>::min());
- }
- }
-
- // Keep creating tiles until the whole coverRect is covered.
- if (createMore)
- m_tileCreationTimer.startOneShot(0);
-}
-
-void TileCache::tileCreationTimerFired(Timer<TileCache>*)
-{
- if (isTileCreationSuspended())
- return;
- MutexLocker locker(m_tileMutex);
- createTilesInActiveGrid(CoverSpeculative);
-}
-
-void TileCache::createTilesInActiveGrid(SynchronousTileCreationMode mode)
-{
- if (memoryPressureHandler().hasReceivedMemoryPressure()) {
- LOG(MemoryPressure, "Under memory pressure at: %s", __PRETTY_FUNCTION__);
- removeAllNonVisibleTilesInternal();
- }
- activeTileGrid()->createTiles(mode);
-}
-
-unsigned TileCache::tileCapacityForGrid(TileGrid* grid)
-{
- static unsigned capacity;
- if (!capacity) {
- size_t totalMemory = systemTotalMemory();
- totalMemory /= 1024 * 1024;
- if (totalMemory >= 1024)
- capacity = 128 * 1024 * 1024;
- else if (totalMemory >= 512)
- capacity = 64 * 1024 * 1024;
- else
- capacity = 32 * 1024 * 1024;
- }
-
- int gridCapacity;
-
- int memoryLevel = systemMemoryLevel();
- if (memoryLevel < 15)
- gridCapacity = capacity / 4;
- else if (memoryLevel < 20)
- gridCapacity = capacity / 2;
- else if (memoryLevel < 30)
- gridCapacity = capacity * 3 / 4;
- else
- gridCapacity = capacity;
-
- if (keepsZoomedOutTiles() && grid == m_zoomedOutTileGrid) {
- if (activeTileGrid() == m_zoomedOutTileGrid)
- return gridCapacity;
- return gridCapacity / 4;
- }
- return gridCapacity * 3 / 4;
-}
-
-Color TileCache::colorForGridTileBorder(TileGrid* grid) const
-{
- if (grid == m_zoomedOutTileGrid)
- return Color(.3f, .0f, 0.4f, 0.5f);
-
- return Color(.0f, .0f, 0.4f, 0.5f);
-}
-
-static bool shouldRepaintInPieces(const CGRect& dirtyRect, CGSRegionObj dirtyRegion, CGFloat contentsScale)
-{
- // Estimate whether or not we should use the unioned rect or the individual rects.
- // We do this by computing the percentage of "wasted space" in the union. If that wasted space
- // is too large, then we will do individual rect painting instead.
- float singlePixels = 0;
- unsigned rectCount = 0;
-
- CGSRegionEnumeratorObj enumerator = CGSRegionEnumerator(dirtyRegion);
- CGRect *subRect;
- while ((subRect = CGSNextRect(enumerator))) {
- ++rectCount;
- singlePixels += subRect->size.width * subRect->size.height;
- }
- singlePixels /= (contentsScale * contentsScale);
- CGSReleaseRegionEnumerator(enumerator);
-
- const unsigned cRectThreshold = 10;
- if (rectCount < 2 || rectCount > cRectThreshold)
- return false;
-
- const float cWastedSpaceThreshold = 0.50f;
- float unionPixels = dirtyRect.size.width * dirtyRect.size.height;
- float wastedSpace = 1.f - (singlePixels / unionPixels);
- return wastedSpace > cWastedSpaceThreshold;
-}
-
-void TileCache::drawReplacementImage(TileLayer* layer, CGContextRef context, CGImageRef image)
-{
- CGContextSetRGBFillColor(context, 1, 1, 1, 1);
- CGContextFillRect(context, CGContextGetClipBoundingBox(context));
-
- CGFloat contentsScale = [layer contentsScale];
- CGContextScaleCTM(context, 1 / contentsScale, -1 / contentsScale);
- CGRect imageRect = CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image));
- CGContextTranslateCTM(context, 0, -imageRect.size.height);
- CGContextDrawImage(context, imageRect, image);
-}
-
-void TileCache::drawWindowContent(TileLayer* layer, CGContextRef context, CGRect dirtyRect)
-{
- CGRect frame = [layer frame];
- WKFontAntialiasingStateSaver fontAntialiasingState(context, [m_window useOrientationDependentFontAntialiasing] && [layer isOpaque]);
- fontAntialiasingState.setup([WAKWindow hasLandscapeOrientation]);
-
- CGSRegionObj drawRegion = (CGSRegionObj)[layer regionBeingDrawn];
- CGFloat contentsScale = [layer contentsScale];
- if (drawRegion && shouldRepaintInPieces(dirtyRect, drawRegion, contentsScale)) {
- // Use fine grained repaint rectangles to minimize the amount of painted pixels.
- CGSRegionEnumeratorObj enumerator = CGSRegionEnumerator(drawRegion);
- CGRect *subRect;
- while ((subRect = CGSNextRect(enumerator))) {
- CGRect adjustedSubRect = *subRect;
- adjustedSubRect.origin.x /= contentsScale;
- adjustedSubRect.origin.y = frame.size.height - (adjustedSubRect.origin.y + adjustedSubRect.size.height) / contentsScale;
- adjustedSubRect.size.width /= contentsScale;
- adjustedSubRect.size.height /= contentsScale;
-
- CGRect subRectInSuper = [hostLayer() convertRect:adjustedSubRect fromLayer:layer];
- [m_window displayRect:subRectInSuper];
- }
- CGSReleaseRegionEnumerator(enumerator);
- } else {
- // Simple repaint
- CGRect dirtyRectInSuper = [hostLayer() convertRect:dirtyRect fromLayer:layer];
- [m_window displayRect:dirtyRectInSuper];
- }
-
- fontAntialiasingState.restore();
-}
-
-void TileCache::drawLayer(TileLayer* layer, CGContextRef context)
-{
- // The web lock unlock observer runs after CA commit observer.
- if (!WebThreadIsLockedOrDisabled()) {
- LOG_ERROR("Drawing without holding the web thread lock");
- ASSERT_NOT_REACHED();
- }
-
- WKSetCurrentGraphicsContext(context);
-
- CGRect dirtyRect = CGContextGetClipBoundingBox(context);
- CGRect frame = [layer frame];
- CGContextTranslateCTM(context, -frame.origin.x, -frame.origin.y);
- CGRect scaledFrame = [hostLayer() convertRect:[layer bounds] fromLayer:layer];
- CGContextScaleCTM(context, frame.size.width / scaledFrame.size.width, frame.size.height / scaledFrame.size.height);
-
- if (RetainPtr<CGImage> contentReplacementImage = this->contentReplacementImage())
- drawReplacementImage(layer, context, contentReplacementImage.get());
- else
- drawWindowContent(layer, context, dirtyRect);
-
- ++layer.paintCount;
- if (m_tilePaintCountersVisible) {
- char text[16];
- snprintf(text, sizeof(text), "%d", layer.paintCount);
-
- CGContextSaveGState(context);
-
- CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
- CGContextSetFillColorWithColor(context, cachedCGColor(colorForGridTileBorder([layer tileGrid]), ColorSpaceDeviceRGB));
-
- CGRect labelBounds = [layer bounds];
- labelBounds.size.width = 10 + 12 * strlen(text);
- labelBounds.size.height = 25;
- CGContextFillRect(context, labelBounds);
-
- if (acceleratedDrawingEnabled())
- CGContextSetRGBFillColor(context, 1, 0, 0, 0.4f);
- else
- CGContextSetRGBFillColor(context, 1, 1, 1, 0.6f);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextSelectFont(context, "Helvetica", 25, kCGEncodingMacRoman);
- CGContextShowTextAtPoint(context, labelBounds.origin.x + 3, labelBounds.origin.y + 20, text, strlen(text));
-#pragma clang diagnostic pop
-
- CGContextRestoreGState(context);
- }
-
- WAKView* view = [m_window contentView];
- [view performSelector:@selector(_dispatchTileDidDraw:) withObject:layer afterDelay:0.0];
-}
-
-void TileCache::setNeedsDisplay()
-{
- setNeedsDisplayInRect(IntRect(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()));
-}
-
-void TileCache::scheduleLayerFlushForPendingRepaint()
-{
- WAKView* view = [m_window contentView];
- [view _scheduleLayerFlushForPendingTileCacheRepaint];
-}
-
-void TileCache::setNeedsDisplayInRect(const IntRect& dirtyRect)
-{
- MutexLocker locker(m_savedDisplayRectMutex);
- bool addedFirstRect = m_savedDisplayRects.isEmpty();
- m_savedDisplayRects.append(dirtyRect);
- if (!addedFirstRect)
- return;
- // Compositing layer flush will call back to doPendingRepaints(). The flush may be throttled and not happen immediately.
- scheduleLayerFlushForPendingRepaint();
-}
-
-void TileCache::invalidateTiles(const IntRect& dirtyRect)
-{
- ASSERT(!m_tileMutex.tryLock());
-
- TileGrid* activeGrid = activeTileGrid();
- if (!keepsZoomedOutTiles()) {
- activeGrid->invalidateTiles(dirtyRect);
- return;
- }
- FloatRect scaledRect = dirtyRect;
- scaledRect.scale(zoomedOutScale() / currentScale());
- IntRect zoomedOutDirtyRect = enclosingIntRect(scaledRect);
- if (activeGrid == m_zoomedOutTileGrid) {
- bool dummy;
- IntRect coverRect = m_zoomedOutTileGrid->calculateCoverRect(m_zoomedOutTileGrid->visibleRect(), dummy);
- // Instead of repainting a tile outside the cover rect, just remove it.
- m_zoomedOutTileGrid->dropTilesBetweenRects(zoomedOutDirtyRect, coverRect);
- m_zoomedOutTileGrid->invalidateTiles(zoomedOutDirtyRect);
- // We need to invalidate zoomed in tiles as well while zooming, since
- // we could switch back to the zoomed in grid without dropping its
- // tiles. See <rdar://problem/9946759>.
- if (m_tilingMode == Zooming && m_zoomedInTileGrid)
- m_zoomedInTileGrid->invalidateTiles(dirtyRect);
- return;
- }
- if (!m_zoomedInTileGrid->hasTiles()) {
- // If no tiles have been created yet for the zoomed in grid, we can't drop the zoomed out tiles.
- m_zoomedOutTileGrid->invalidateTiles(zoomedOutDirtyRect);
- return;
- }
- m_zoomedOutTileGrid->dropTilesIntersectingRect(zoomedOutDirtyRect);
- m_zoomedInTileGrid->invalidateTiles(dirtyRect);
-}
-
-bool TileCache::isTileCreationSuspended() const
-{
- return (!keepsZoomedOutTiles() && m_tilingMode == Zooming) || m_tilingMode == Disabled;
-}
-
-bool TileCache::isTileInvalidationSuspended() const
-{
- return m_tilingMode == Zooming || m_tilingMode == Panning || m_tilingMode == ScrollToTop || m_tilingMode == Disabled;
-}
-
-void TileCache::updateTilingMode()
-{
- ASSERT(WebThreadIsCurrent() || !WebThreadIsEnabled());
-
- WAKView* view = [m_window contentView];
-
- if (m_tilingMode == Zooming || m_tilingMode == Panning || m_tilingMode == ScrollToTop) {
- if (!m_didCallWillStartScrollingOrZooming) {
- [view _willStartScrollingOrZooming];
- m_didCallWillStartScrollingOrZooming = true;
- }
- } else {
- if (m_didCallWillStartScrollingOrZooming) {
- [view _didFinishScrollingOrZooming];
- m_didCallWillStartScrollingOrZooming = false;
- }
- if (m_tilingMode == Disabled)
- return;
-
- MutexLocker locker(m_tileMutex);
- createTilesInActiveGrid(CoverVisibleOnly);
-
- if (!m_savedDisplayRects.isEmpty())
- scheduleLayerFlushForPendingRepaint();
- }
-}
-
-void TileCache::setTilingMode(TilingMode tilingMode)
-{
- if (tilingMode == m_tilingMode)
- return;
- bool wasZooming = (m_tilingMode == Zooming);
- m_tilingMode = tilingMode;
-
- if ((m_pendingZoomedOutScale || m_pendingScale) && m_tilingMode != Disabled)
- commitScaleChange();
- else if (wasZooming) {
- MutexLocker locker(m_tileMutex);
- bringActiveTileGridToFront();
- }
-
- if (m_hasPendingUpdateTilingMode)
- return;
- m_hasPendingUpdateTilingMode = true;
-
- TileCacheTombstone *tombstone = m_tombstone.get();
- WebThreadRun(^{
- if ([tombstone isDead])
- return;
- m_hasPendingUpdateTilingMode = false;
- updateTilingMode();
- });
-}
-
-void TileCache::setTilingDirection(TilingDirection tilingDirection)
-{
- m_tilingDirection = tilingDirection;
-}
-
-TileCache::TilingDirection TileCache::tilingDirection() const
-{
- return m_tilingDirection;
-}
-
-float TileCache::zoomedOutScale() const
-{
- return m_zoomedOutTileGrid->scale();
-}
-
-float TileCache::currentScale() const
-{
- return m_currentScale;
-}
-
-void TileCache::doPendingRepaints()
-{
- if (m_savedDisplayRects.isEmpty())
- return;
- if (isTileInvalidationSuspended())
- return;
- MutexLocker locker(m_tileMutex);
- flushSavedDisplayRects();
-}
-
-void TileCache::flushSavedDisplayRects()
-{
- ASSERT(!m_tileMutex.tryLock());
- ASSERT(!m_savedDisplayRects.isEmpty());
-
- Vector<IntRect> rects;
- {
- MutexLocker locker(m_savedDisplayRectMutex);
- m_savedDisplayRects.swap(rects);
- }
- size_t size = rects.size();
- for (size_t n = 0; n < size; ++n)
- invalidateTiles(rects[n]);
-}
-
-void TileCache::setSpeculativeTileCreationEnabled(bool enabled)
-{
- if (m_isSpeculativeTileCreationEnabled == enabled)
- return;
- m_isSpeculativeTileCreationEnabled = enabled;
- if (m_isSpeculativeTileCreationEnabled)
- m_tileCreationTimer.startOneShot(0);
-}
-
-bool TileCache::hasPendingDraw() const
-{
- return !m_savedDisplayRects.isEmpty();
-}
-
-void TileCache::prepareToDraw()
-{
- // This will trigger document relayout if needed.
- [[m_window contentView] viewWillDraw];
-
- if (!m_savedDisplayRects.isEmpty()) {
- MutexLocker locker(m_tileMutex);
- flushSavedDisplayRects();
- }
-}
-
-void TileCache::setLayerPoolCapacity(unsigned capacity)
-{
- TileLayerPool::sharedPool()->setCapacity(capacity);
-}
-
-void TileCache::drainLayerPool()
-{
- TileLayerPool::sharedPool()->drain();
-}
-
-void TileCache::dumpTiles()
-{
- NSLog(@"=================");
- NSLog(@"ZOOMED OUT");
- if (m_zoomedOutTileGrid == activeTileGrid())
- NSLog(@"<ACTIVE>");
- m_zoomedOutTileGrid->dumpTiles();
- NSLog(@"=================");
- if (m_zoomedInTileGrid) {
- NSLog(@"ZOOMED IN");
- if (m_zoomedInTileGrid == activeTileGrid())
- NSLog(@"<ACTIVE>");
- m_zoomedInTileGrid->dumpTiles();
- NSLog(@"=================");
- }
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileGridh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileGrid.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileGrid.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileGrid.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,143 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 TileGrid_h
-#define TileGrid_h
-
-#if PLATFORM(IOS)
-
-#include "IntPoint.h"
-#include "IntPointHash.h"
-#include "IntRect.h"
-#include "IntSize.h"
-#include "TileCache.h"
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RetainPtr.h>
-
-#define LOG_TILING 0
-
-@class CALayer;
-
-namespace WebCore {
-
-class TileGridTile;
-
-class TileGrid {
- WTF_MAKE_NONCOPYABLE(TileGrid);
-public:
- typedef IntPoint TileIndex;
-
- static PassOwnPtr<TileGrid> create(TileCache* cache, const IntSize& tileSize) { return adoptPtr(new TileGrid(cache, tileSize)); }
-
- ~TileGrid();
-
- TileCache* tileCache() const { return m_tileCache; }
-
- CALayer *tileHostLayer() const;
- IntRect bounds() const;
- unsigned tileCount() const;
-
- float scale() const { return m_scale; }
- void setScale(float scale) { m_scale = scale; }
-
- IntRect visibleRect() const;
-
- void createTiles(TileCache::SynchronousTileCreationMode);
-
- void dropAllTiles();
- void dropInvalidTiles();
- void dropTilesOutsideRect(const IntRect&);
- void dropTilesIntersectingRect(const IntRect&);
- // Drops tiles that intersect dropRect but do not intersect keepRect.
- void dropTilesBetweenRects(const IntRect& dropRect, const IntRect& keepRect);
- bool dropDistantTiles(unsigned tilesNeeded, double shortestDistance);
-
- void addTilesCoveringRect(const IntRect&);
-
- bool tilesCover(const IntRect&) const;
- void centerTileGridOrigin(const IntRect& visibleRect);
- void invalidateTiles(const IntRect& dirtyRect);
-
- void updateTileOpacity();
- void updateTileBorderVisibility();
- void updateHostLayerSize();
- bool checkDoSingleTileLayout();
-
- bool hasTiles() const { return !m_tiles.isEmpty(); }
-
- IntRect calculateCoverRect(const IntRect& visibleRect, bool& centerGrid);
-
- // Logging
- void dumpTiles();
-
-private:
- double tileDistance2(const IntRect& visibleRect, const IntRect& tileRect) const;
- unsigned tileByteSize() const;
-
- void addTileForIndex(const TileIndex&);
-
- PassRefPtr<TileGridTile> tileForIndex(const TileIndex&) const;
- IntRect tileRectForIndex(const TileIndex&) const;
- PassRefPtr<TileGridTile> tileForPoint(const IntPoint&) const;
- TileIndex tileIndexForPoint(const IntPoint&) const;
-
- IntRect adjustCoverRectForPageBounds(const IntRect&) const;
- bool shouldUseMinimalTileCoverage() const;
-
-private:
- TileGrid(TileCache*, const IntSize&);
-
- TileCache* m_tileCache;
- RetainPtr<CALayer> m_tileHostLayer;
-
- IntPoint m_origin;
- IntSize m_tileSize;
-
- float m_scale;
-
- typedef HashMap<TileIndex, RefPtr<TileGridTile>> TileMap;
- TileMap m_tiles;
-
- IntRect m_validBounds;
-};
-
-static inline IntPoint topLeft(const IntRect& rect)
-{
- return rect.location();
-}
-
-static inline IntPoint bottomRight(const IntRect& rect)
-{
- return IntPoint(rect.maxX() - 1, rect.maxY() - 1);
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
-#endif // TileGrid_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileGridmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileGrid.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileGrid.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileGrid.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,567 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 "TileGrid.h"
-
-#if PLATFORM(IOS)
-
-#include "MemoryPressureHandler.h"
-#include "SystemMemory.h"
-#include "TileGridTile.h"
-#include "TileLayer.h"
-#include "TileLayerPool.h"
-#include "WAKWindow.h"
-#include <CoreGraphics/CoreGraphicsPrivate.h>
-#include <QuartzCore/QuartzCore.h>
-#include <QuartzCore/QuartzCorePrivate.h>
-#include <algorithm>
-#include <functional>
-
-namespace WebCore {
-
-TileGrid::TileGrid(TileCache* tileCache, const IntSize& tileSize)
- : m_tileCache(tileCache)
- , m_tileHostLayer(adoptNS([[TileHostLayer alloc] initWithTileGrid:this]))
- , m_tileSize(tileSize)
- , m_scale(1)
- , m_validBounds(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max())
-{
-}
-
-TileGrid::~TileGrid()
-{
- [m_tileHostLayer removeFromSuperlayer];
-}
-
-IntRect TileGrid::visibleRect() const
-{
- IntRect visibleRect = enclosingIntRect(m_tileCache->visibleRectInLayer(m_tileHostLayer.get()));
-
- // When fast scrolling to the top, move the visible rect there immediately so we have tiles when the scrolling completes.
- if (m_tileCache->tilingMode() == TileCache::ScrollToTop)
- visibleRect.setY(0);
-
- return visibleRect;
-}
-
-void TileGrid::dropAllTiles()
-{
- m_tiles.clear();
-}
-
-void TileGrid::dropTilesIntersectingRect(const IntRect& dropRect)
-{
- dropTilesBetweenRects(dropRect, IntRect());
-}
-
-void TileGrid::dropTilesOutsideRect(const IntRect& keepRect)
-{
- dropTilesBetweenRects(IntRect(0, 0, std::numeric_limits<int>::max(), std::numeric_limits<int>::max()), keepRect);
-}
-
-void TileGrid::dropTilesBetweenRects(const IntRect& dropRect, const IntRect& keepRect)
-{
- Vector<TileIndex> toRemove;
- for (const auto& tile : m_tiles) {
- const TileIndex& index = tile.key;
- IntRect tileRect = tile.value->rect();
- if (tileRect.intersects(dropRect) && !tileRect.intersects(keepRect))
- toRemove.append(index);
- }
- unsigned removeCount = toRemove.size();
- for (unsigned n = 0; n < removeCount; ++n)
- m_tiles.remove(toRemove[n]);
-}
-
-unsigned TileGrid::tileByteSize() const
-{
- IntSize tilePixelSize = m_tileSize;
- tilePixelSize.scale(m_tileCache->screenScale());
- return TileLayerPool::bytesBackingLayerWithPixelSize(tilePixelSize);
-}
-
-template <typename T>
-static bool isFartherAway(const std::pair<double, T>& a, const std::pair<double, T>& b)
-{
- return a.first > b.first;
-}
-
-bool TileGrid::dropDistantTiles(unsigned tilesNeeded, double shortestDistance)
-{
- unsigned bytesPerTile = tileByteSize();
- unsigned bytesNeeded = tilesNeeded * bytesPerTile;
- unsigned bytesUsed = tileCount() * bytesPerTile;
- unsigned maximumBytes = m_tileCache->tileCapacityForGrid(this);
-
- int bytesToReclaim = int(bytesUsed) - (int(maximumBytes) - bytesNeeded);
- if (bytesToReclaim <= 0)
- return true;
-
- unsigned tilesToRemoveCount = bytesToReclaim / bytesPerTile;
-
- IntRect visibleRect = this->visibleRect();
- Vector<std::pair<double, TileIndex>> toRemove;
- for (const auto& tile : m_tiles) {
- const TileIndex& index = tile.key;
- const IntRect& tileRect = tile.value->rect();
- double distance = tileDistance2(visibleRect, tileRect);
- if (distance <= shortestDistance)
- continue;
- toRemove.append(std::make_pair(distance, index));
- std::push_heap(toRemove.begin(), toRemove.end(), std::ptr_fun(isFartherAway<TileIndex>));
- if (toRemove.size() > tilesToRemoveCount) {
- std::pop_heap(toRemove.begin(), toRemove.end(), std::ptr_fun(isFartherAway<TileIndex>));
- toRemove.removeLast();
- }
- }
- size_t removeCount = toRemove.size();
- for (size_t n = 0; n < removeCount; ++n)
- m_tiles.remove(toRemove[n].second);
-
- if (!shortestDistance)
- return true;
-
- return tileCount() * bytesPerTile + bytesNeeded <= maximumBytes;
-}
-
-void TileGrid::addTilesCoveringRect(const IntRect& rectToCover)
-{
- // We never draw anything outside of our bounds.
- IntRect rect(rectToCover);
- rect.intersect(bounds());
- if (rect.isEmpty())
- return;
-
- TileIndex topLeftIndex = tileIndexForPoint(topLeft(rect));
- TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(rect));
- for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
- for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
- TileIndex index(xIndex, yIndex);
- if (!tileForIndex(index))
- addTileForIndex(index);
- }
- }
-}
-
-void TileGrid::addTileForIndex(const TileIndex& index)
-{
- m_tiles.set(index, TileGridTile::create(this, tileRectForIndex(index)));
-}
-
-CALayer* TileGrid::tileHostLayer() const
-{
- return m_tileHostLayer.get();
-}
-
-IntRect TileGrid::bounds() const
-{
- return IntRect(IntPoint(), IntSize([tileHostLayer() size]));
-}
-
-PassRefPtr<TileGridTile> TileGrid::tileForIndex(const TileIndex& index) const
-{
- return m_tiles.get(index);
-}
-
-IntRect TileGrid::tileRectForIndex(const TileIndex& index) const
-{
- IntRect rect(index.x() * m_tileSize.width() - (m_origin.x() ? m_tileSize.width() - m_origin.x() : 0),
- index.y() * m_tileSize.height() - (m_origin.y() ? m_tileSize.height() - m_origin.y() : 0),
- m_tileSize.width(),
- m_tileSize.height());
- rect.intersect(bounds());
- return rect;
-}
-
-TileGrid::TileIndex TileGrid::tileIndexForPoint(const IntPoint& point) const
-{
- ASSERT(m_origin.x() < m_tileSize.width());
- ASSERT(m_origin.y() < m_tileSize.height());
- int x = (point.x() + (m_origin.x() ? m_tileSize.width() - m_origin.x() : 0)) / m_tileSize.width();
- int y = (point.y() + (m_origin.y() ? m_tileSize.height() - m_origin.y() : 0)) / m_tileSize.height();
- return TileIndex(std::max(x, 0), std::max(y, 0));
-}
-
-void TileGrid::centerTileGridOrigin(const IntRect& visibleRect)
-{
- if (visibleRect.isEmpty())
- return;
-
- unsigned minimumHorizontalTiles = 1 + (visibleRect.width() - 1) / m_tileSize.width();
- unsigned minimumVerticalTiles = 1 + (visibleRect.height() - 1) / m_tileSize.height();
- TileIndex currentTopLeftIndex = tileIndexForPoint(topLeft(visibleRect));
- TileIndex currentBottomRightIndex = tileIndexForPoint(bottomRight(visibleRect));
- unsigned currentHorizontalTiles = currentBottomRightIndex.x() - currentTopLeftIndex.x() + 1;
- unsigned currentVerticalTiles = currentBottomRightIndex.y() - currentTopLeftIndex.y() + 1;
-
- // If we have tiles already, only center if we would get benefits from both directions (as we need to throw out existing tiles).
- if (tileCount() && (currentHorizontalTiles == minimumHorizontalTiles || currentVerticalTiles == minimumVerticalTiles))
- return;
-
- IntPoint newOrigin(0, 0);
- IntSize size = bounds().size();
- if (size.width() > m_tileSize.width()) {
- newOrigin.setX((visibleRect.x() - (minimumHorizontalTiles * m_tileSize.width() - visibleRect.width()) / 2) % m_tileSize.width());
- if (newOrigin.x() < 0)
- newOrigin.setX(0);
- }
- if (size.height() > m_tileSize.height()) {
- newOrigin.setY((visibleRect.y() - (minimumVerticalTiles * m_tileSize.height() - visibleRect.height()) / 2) % m_tileSize.height());
- if (newOrigin.y() < 0)
- newOrigin.setY(0);
- }
-
- // Drop all existing tiles if the origin moved.
- if (newOrigin == m_origin)
- return;
- m_tiles.clear();
- m_origin = newOrigin;
-}
-
-PassRefPtr<TileGridTile> TileGrid::tileForPoint(const IntPoint& point) const
-{
- return tileForIndex(tileIndexForPoint(point));
-}
-
-bool TileGrid::tilesCover(const IntRect& rect) const
-{
- return tileForPoint(rect.location()) && tileForPoint(IntPoint(rect.maxX() - 1, rect.y())) &&
- tileForPoint(IntPoint(rect.x(), rect.maxY() - 1)) && tileForPoint(IntPoint(rect.maxX() - 1, rect.maxY() - 1));
-}
-
-void TileGrid::updateTileOpacity()
-{
- TileMap::iterator end = m_tiles.end();
- for (TileMap::iterator it = m_tiles.begin(); it != end; ++it)
- [it->value->tileLayer() setOpaque:m_tileCache->tilesOpaque()];
-}
-
-void TileGrid::updateTileBorderVisibility()
-{
- TileMap::iterator end = m_tiles.end();
- for (TileMap::iterator it = m_tiles.begin(); it != end; ++it)
- it->value->showBorder(m_tileCache->tileBordersVisible());
-}
-
-unsigned TileGrid::tileCount() const
-{
- return m_tiles.size();
-}
-
-bool TileGrid::checkDoSingleTileLayout()
-{
- IntSize size = bounds().size();
- if (size.width() > m_tileSize.width() || size.height() > m_tileSize.height())
- return false;
-
- if (m_origin != IntPoint(0, 0)) {
- m_tiles.clear();
- m_origin = IntPoint(0, 0);
- }
-
- dropInvalidTiles();
-
- if (size.isEmpty()) {
- ASSERT(!m_tiles.get(TileIndex(0, 0)));
- return true;
- }
-
- TileIndex originIndex(0, 0);
- if (!m_tiles.get(originIndex))
- m_tiles.set(originIndex, TileGridTile::create(this, tileRectForIndex(originIndex)));
-
- return true;
-}
-
-void TileGrid::updateHostLayerSize()
-{
- CALayer* hostLayer = m_tileCache->hostLayer();
- CGRect tileHostBounds = [hostLayer convertRect:[hostLayer bounds] toLayer:tileHostLayer()];
- CGSize transformedSize;
- transformedSize.width = CGRound(tileHostBounds.size.width);
- transformedSize.height = CGRound(tileHostBounds.size.height);
-
- CGRect bounds = [tileHostLayer() bounds];
- if (CGSizeEqualToSize(bounds.size, transformedSize))
- return;
- bounds.size = transformedSize;
- [tileHostLayer() setBounds:bounds];
-}
-
-void TileGrid::dropInvalidTiles()
-{
- IntRect bounds = this->bounds();
- IntRect dropBounds = intersection(m_validBounds, bounds);
- Vector<TileIndex> toRemove;
- for (const auto& tile : m_tiles) {
- const TileIndex& index = tile.key;
- const IntRect& tileRect = tile.value->rect();
- IntRect expectedTileRect = tileRectForIndex(index);
- if (expectedTileRect != tileRect || !dropBounds.contains(tileRect))
- toRemove.append(index);
- }
- unsigned removeCount = toRemove.size();
- for (unsigned n = 0; n < removeCount; ++n)
- m_tiles.remove(toRemove[n]);
-
- m_validBounds = bounds;
-}
-
-void TileGrid::invalidateTiles(const IntRect& dirtyRect)
-{
- if (!hasTiles())
- return;
-
- IntRect bounds = this->bounds();
- if (intersection(bounds, m_validBounds) != m_validBounds) {
- // The bounds have got smaller. Everything outside will also be considered invalid and will be dropped by dropInvalidTiles().
- // Due to dirtyRect being limited to current bounds the tiles that are temporarily outside might miss invalidation
- // completely othwerwise.
- m_validBounds = bounds;
- }
-
- Vector<TileIndex> invalidatedTiles;
-
- if (dirtyRect.width() > m_tileSize.width() * 4 || dirtyRect.height() > m_tileSize.height() * 4) {
- // For large invalidates, iterate over live tiles.
- TileMap::iterator end = m_tiles.end();
- for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
- TileGridTile* tile = it->value.get();
- if (!tile->rect().intersects(dirtyRect))
- continue;
- tile->invalidateRect(dirtyRect);
- invalidatedTiles.append(it->key);
- }
- } else {
- TileIndex topLeftIndex = tileIndexForPoint(topLeft(dirtyRect));
- TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(dirtyRect));
- for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
- for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
- TileIndex index(xIndex, yIndex);
- RefPtr<TileGridTile> tile = tileForIndex(index);
- if (!tile)
- continue;
- if (!tile->rect().intersects(dirtyRect))
- continue;
- tile->invalidateRect(dirtyRect);
- invalidatedTiles.append(index);
- }
- }
- }
- if (invalidatedTiles.isEmpty())
- return;
- // When using minimal coverage, drop speculative tiles instead of updating them.
- if (!shouldUseMinimalTileCoverage())
- return;
- if (m_tileCache->tilingMode() != TileCache::Minimal && m_tileCache->tilingMode() != TileCache::Normal)
- return;
- IntRect visibleRect = this->visibleRect();
- unsigned count = invalidatedTiles.size();
- for (unsigned i = 0; i < count; ++i) {
- RefPtr<TileGridTile> tile = tileForIndex(invalidatedTiles[i]);
- if (!tile->rect().intersects(visibleRect))
- m_tiles.remove(invalidatedTiles[i]);
- }
-}
-
-bool TileGrid::shouldUseMinimalTileCoverage() const
-{
- return m_tileCache->tilingMode() == TileCache::Minimal
- || !m_tileCache->isSpeculativeTileCreationEnabled()
- || memoryPressureHandler().hasReceivedMemoryPressure();
-}
-
-IntRect TileGrid::adjustCoverRectForPageBounds(const IntRect& rect) const
-{
- // Adjust the rect so that it stays within the bounds and keeps the pixel size.
- IntRect bounds = this->bounds();
- IntRect adjustedRect = rect;
- adjustedRect.move(rect.x() < bounds.x() ? bounds.x() - rect.x() : 0,
- rect.y() < bounds.y() ? bounds.y() - rect.y() : 0);
- adjustedRect.move(rect.maxX() > bounds.maxX() ? bounds.maxX() - rect.maxX() : 0,
- rect.maxY() > bounds.maxY() ? bounds.maxY() - rect.maxY() : 0);
- adjustedRect = intersection(bounds, adjustedRect);
- if (adjustedRect == rect || adjustedRect.isEmpty() || shouldUseMinimalTileCoverage())
- return adjustedRect;
- int pixels = adjustedRect.width() * adjustedRect.height();
- if (adjustedRect.width() != rect.width())
- adjustedRect.inflateY((pixels / adjustedRect.width() - adjustedRect.height()) / 2);
- else if (adjustedRect.height() != rect.height())
- adjustedRect.inflateX((pixels / adjustedRect.height() - adjustedRect.width()) / 2);
- return intersection(adjustedRect, bounds);
-}
-
-IntRect TileGrid::calculateCoverRect(const IntRect& visibleRect, bool& centerGrid)
-{
- // Use minimum coverRect if we are under memory pressure.
- if (shouldUseMinimalTileCoverage()) {
- centerGrid = true;
- return visibleRect;
- }
- IntRect coverRect = visibleRect;
- centerGrid = false;
- coverRect.inflateX(visibleRect.width() / 2);
- coverRect.inflateY(visibleRect.height());
- return adjustCoverRectForPageBounds(coverRect);
-}
-
-double TileGrid::tileDistance2(const IntRect& visibleRect, const IntRect& tileRect) const
-{
- // The "distance" calculated here is used to pick which tile to cache next. The idea is to create those
- // closest to the current viewport first so the user is more likely to see already rendered content we she
- // scrolls. The calculation is weighted to prefer vertical and downward direction.
- if (visibleRect.intersects(tileRect))
- return 0;
- IntPoint visibleCenter = visibleRect.location() + IntSize(visibleRect.width() / 2, visibleRect.height() / 2);
- IntPoint tileCenter = tileRect.location() + IntSize(tileRect.width() / 2, tileRect.height() / 2);
-
- double horizontalBias = 1.0;
- double leftwardBias = 1.0;
- double rightwardBias = 1.0;
-
- double verticalBias = 1.0;
- double upwardBias = 1.0;
- double downwardBias = 1.0;
-
- const double tilingBiasVeryLikely = 0.8;
- const double tilingBiasLikely = 0.9;
-
- switch (m_tileCache->tilingDirection()) {
- case TileCache::TilingDirectionUp:
- verticalBias = tilingBiasVeryLikely;
- upwardBias = tilingBiasLikely;
- break;
- case TileCache::TilingDirectionDown:
- verticalBias = tilingBiasVeryLikely;
- downwardBias = tilingBiasLikely;
- break;
- case TileCache::TilingDirectionLeft:
- horizontalBias = tilingBiasVeryLikely;
- leftwardBias = tilingBiasLikely;
- break;
- case TileCache::TilingDirectionRight:
- horizontalBias = tilingBiasVeryLikely;
- rightwardBias = tilingBiasLikely;
- break;
- }
-
- double xScale = horizontalBias * visibleRect.height() / visibleRect.width() * (tileCenter.x() >= visibleCenter.x() ? rightwardBias : leftwardBias);
- double yScale = verticalBias * visibleRect.width() / visibleRect.height() * (tileCenter.y() >= visibleCenter.y() ? downwardBias : upwardBias);
-
- double xDistance = xScale * (tileCenter.x() - visibleCenter.x());
- double yDistance = yScale * (tileCenter.y() - visibleCenter.y());
-
- double distance2 = xDistance * xDistance + yDistance * yDistance;
- return distance2;
-}
-
-void TileGrid::createTiles(TileCache::SynchronousTileCreationMode creationMode)
-{
- IntRect visibleRect = this->visibleRect();
- if (visibleRect.isEmpty())
- return;
-
- // Drop tiles that are wrong size or outside the frame (because the frame has been resized).
- dropInvalidTiles();
-
- bool centerGrid;
- IntRect coverRect = calculateCoverRect(visibleRect, centerGrid);
-
- // If tile size is bigger than the view, centering minimizes the painting needed to cover the screen.
- // This is especially useful after zooming
- centerGrid = centerGrid || !tileCount();
- if (centerGrid)
- centerTileGridOrigin(visibleRect);
-
- double shortestDistance = std::numeric_limits<double>::infinity();
- double coveredDistance = 0;
- Vector<TileGrid::TileIndex> tilesToCreate;
- unsigned pendingTileCount = 0;
-
- TileGrid::TileIndex topLeftIndex = tileIndexForPoint(topLeft(coverRect));
- TileGrid::TileIndex bottomRightIndex = tileIndexForPoint(bottomRight(coverRect));
- for (int yIndex = topLeftIndex.y(); yIndex <= bottomRightIndex.y(); ++yIndex) {
- for (int xIndex = topLeftIndex.x(); xIndex <= bottomRightIndex.x(); ++xIndex) {
- TileGrid::TileIndex index(xIndex, yIndex);
- // Currently visible tiles have distance of 0 and get all created in the same transaction.
- double distance = tileDistance2(visibleRect, tileRectForIndex(index));
- if (distance > coveredDistance)
- coveredDistance = distance;
- if (tileForIndex(index))
- continue;
- ++pendingTileCount;
- if (distance > shortestDistance)
- continue;
- if (distance < shortestDistance) {
- tilesToCreate.clear();
- shortestDistance = distance;
- }
- tilesToCreate.append(index);
- }
- }
-
- size_t tilesToCreateCount = tilesToCreate.size();
-
- // Tile creation timer will invoke this function again in CoverSpeculative mode.
- bool candidateTilesAreSpeculative = shortestDistance > 0;
- if (creationMode == TileCache::CoverVisibleOnly && candidateTilesAreSpeculative)
- tilesToCreateCount = 0;
-
- // Even if we don't create any tiles, we should still drop distant tiles
- // in case coverRect got smaller.
- double keepDistance = std::min(shortestDistance, coveredDistance);
- if (!dropDistantTiles(tilesToCreateCount, keepDistance))
- return;
-
- ASSERT(pendingTileCount >= tilesToCreateCount);
- if (!pendingTileCount)
- return;
-
- for (size_t n = 0; n < tilesToCreateCount; ++n)
- addTileForIndex(tilesToCreate[n]);
-
- bool didCreateTiles = !!tilesToCreateCount;
- bool createMoreTiles = pendingTileCount > tilesToCreateCount;
- m_tileCache->finishedCreatingTiles(didCreateTiles, createMoreTiles);
-}
-
-void TileGrid::dumpTiles()
-{
- IntRect visibleRect = this->visibleRect();
- NSLog(@"transformed visibleRect = [%6d %6d %6d %6d]", visibleRect.x(), visibleRect.y(), visibleRect.width(), visibleRect.height());
- unsigned i = 0;
- TileMap::iterator end = m_tiles.end();
- for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
- TileIndex& index = it->key;
- IntRect tileRect = it->value->rect();
- NSLog(@"#%-3d (%3d %3d) - [%6d %6d %6d %6d]%@", ++i, index.x(), index.y(), tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height(), tileRect.intersects(visibleRect) ? @" *" : @"");
- NSLog(@" %@", [it->value->tileLayer() contents]);
- }
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileGridTileh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileGridTile.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileGridTile.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileGridTile.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,65 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 TileGridTile_h
-#define TileGridTile_h
-
-#if PLATFORM(IOS)
-
-#include "IntRect.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/RetainPtr.h>
-
-@class TileLayer;
-
-namespace WebCore {
-
-class TileGrid;
-
-// Refcount the tiles so they work nicely in vector and we know when to remove the tile layer from the parent.
-class TileGridTile : public RefCounted<TileGridTile> {
-public:
- static PassRefPtr<TileGridTile> create(TileGrid* grid, const IntRect& rect) { return adoptRef<TileGridTile>(new TileGridTile(grid, rect)); }
- ~TileGridTile();
-
- TileLayer* tileLayer() const { return m_tileLayer.get(); }
- void invalidateRect(const IntRect& rectInSurface);
- IntRect rect() const { return m_rect; }
- void setRect(const IntRect& tileRect);
- void showBorder(bool);
-
-private:
- TileGridTile(TileGrid*, const IntRect&);
-
- TileGrid* m_tileGrid;
- RetainPtr<TileLayer> m_tileLayer;
- IntRect m_rect;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
-#endif // TileGridTile_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileGridTilemm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileGridTile.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileGridTile.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileGridTile.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,131 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 "TileGrid.h"
-
-#if PLATFORM(IOS)
-
-#include "Color.h"
-#include "TileCache.h"
-#include "TileGridTile.h"
-#include "TileLayer.h"
-#include "TileLayerPool.h"
-#include "WAKWindow.h"
-#include <QuartzCore/QuartzCore.h>
-#include <QuartzCore/QuartzCorePrivate.h>
-#include <algorithm>
-#include <functional>
-
-namespace WebCore {
-
-#if LOG_TILING
-static int totalTileCount;
-#endif
-
-TileGridTile::TileGridTile(TileGrid* tileGrid, const IntRect& tileRect)
- : m_tileGrid(tileGrid)
- , m_rect(tileRect)
-{
- ASSERT(!tileRect.isEmpty());
- IntSize pixelSize(m_rect.size());
- const CGFloat screenScale = m_tileGrid->tileCache()->screenScale();
- pixelSize.scale(screenScale);
- m_tileLayer = TileLayerPool::sharedPool()->takeLayerWithSize(pixelSize);
- if (!m_tileLayer) {
-#if LOG_TILING
- NSLog(@"unable to reuse layer with size %d x %d, creating one", pixelSize.width(), pixelSize.height());
-#endif
- m_tileLayer = adoptNS([[TileLayer alloc] init]);
- }
- TileLayer* layer = m_tileLayer.get();
- [layer setTileGrid:tileGrid];
- [layer setOpaque:m_tileGrid->tileCache()->tilesOpaque()];
- [layer setEdgeAntialiasingMask:0];
- [layer setNeedsLayoutOnGeometryChange:NO];
- [layer setContentsScale:screenScale];
- [layer setAcceleratesDrawing:m_tileGrid->tileCache()->acceleratedDrawingEnabled()];
-
- // Host layer may have other sublayers. Keep the tile layers at the beginning of the array
- // so they are painted behind everything else.
- [tileGrid->tileHostLayer() insertSublayer:layer atIndex:tileGrid->tileCount()];
- [layer setFrame:m_rect];
- invalidateRect(m_rect);
- showBorder(m_tileGrid->tileCache()->tileBordersVisible());
-
-#if LOG_TILING
- ++totalTileCount;
- NSLog(@"new Tile (%d,%d) %d %d, count %d", tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height(), totalTileCount);
-#endif
-}
-
-TileGridTile::~TileGridTile()
-{
- [tileLayer() setTileGrid:0];
- [tileLayer() removeFromSuperlayer];
- TileLayerPool::sharedPool()->addLayer(tileLayer());
-#if LOG_TILING
- --totalTileCount;
- NSLog(@"delete Tile (%d,%d) %d %d, count %d", m_rect.x(), m_rect.y(), m_rect.width(), m_rect.height(), totalTileCount);
-#endif
-}
-
-void TileGridTile::invalidateRect(const IntRect& windowDirtyRect)
-{
- IntRect dirtyRect = intersection(windowDirtyRect, m_rect);
- if (dirtyRect.isEmpty())
- return;
- dirtyRect.move(IntPoint() - m_rect.location());
- [tileLayer() setNeedsDisplayInRect:dirtyRect];
-
- if (m_tileGrid->tileCache()->tilePaintCountersVisible())
- [tileLayer() setNeedsDisplayInRect:CGRectMake(0, 0, 46, 25)];
-}
-
-void TileGridTile::setRect(const IntRect& tileRect)
-{
- if (m_rect == tileRect)
- return;
- m_rect = tileRect;
- TileLayer* layer = m_tileLayer.get();
- [layer setFrame:m_rect];
- [layer setNeedsDisplay];
-}
-
-void TileGridTile::showBorder(bool flag)
-{
- TileLayer* layer = m_tileLayer.get();
- if (flag) {
- [layer setBorderColor:cachedCGColor(m_tileGrid->tileCache()->colorForGridTileBorder(m_tileGrid), ColorSpaceDeviceRGB)];
- [layer setBorderWidth:0.5f];
- } else {
- [layer setBorderColor:nil];
- [layer setBorderWidth:0];
- }
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileLayerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileLayer.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileLayer.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileLayer.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,53 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 TileLayer_h
-#define TileLayer_h
-
-#if PLATFORM(IOS)
-
-#include <QuartzCore/CALayer.h>
-
-namespace WebCore {
-class TileGrid;
-};
-
-@interface TileLayer : CALayer {
- WebCore::TileGrid* _tileGrid;
- unsigned _paintCount;
-}
-@property (nonatomic) unsigned paintCount;
-@property (nonatomic) WebCore::TileGrid* tileGrid;
-+ (TileLayer *)layerBeingPainted;
-@end
-
-@interface TileHostLayer : CALayer {
- WebCore::TileGrid* _tileGrid;
-}
-- (id)initWithTileGrid:(WebCore::TileGrid*)tileGrid;
-@end
-
-#endif // PLATFORM(IOS)
-#endif // TileLayer_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileLayermm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileLayer.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileLayer.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileLayer.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,103 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 "TileLayer.h"
-
-#if PLATFORM(IOS)
-
-#include "TileCache.h"
-#include "TileGrid.h"
-#include "WebCoreThread.h"
-
-@implementation TileHostLayer
-- (id)initWithTileGrid:(WebCore::TileGrid*)tileGrid
-{
- self = [super init];
- if (!self)
- return nil;
- _tileGrid = tileGrid;
- [self setAnchorPoint:CGPointZero];
- return self;
-}
-
-- (id<CAAction>)actionForKey:(NSString *)key
-{
- UNUSED_PARAM(key);
- // Disable all default actions
- return nil;
-}
-
-- (void)renderInContext:(CGContextRef)context
-{
- if (pthread_main_np())
- WebThreadLock();
- _tileGrid->tileCache()->doLayoutTiles();
- [super renderInContext:context];
-}
-@end
-
-@implementation TileLayer
-@synthesize paintCount = _paintCount;
-@synthesize tileGrid = _tileGrid;
-
-static TileLayer *layerBeingPainted;
-
-- (void)setNeedsDisplayInRect:(CGRect)rect
-{
- [self setNeedsLayout];
- [super setNeedsDisplayInRect:rect];
-}
-
-- (void)layoutSublayers
-{
- if (pthread_main_np())
- WebThreadLock();
- // This may trigger WebKit layout and generate more repaint rects.
- if (_tileGrid)
- _tileGrid->tileCache()->prepareToDraw();
-}
-
-- (void)drawInContext:(CGContextRef)context
-{
- if (_tileGrid)
- _tileGrid->tileCache()->drawLayer(self, context);
-}
-
-- (id<CAAction>)actionForKey:(NSString *)key
-{
- UNUSED_PARAM(key);
- // Disable all default actions
- return nil;
-}
-
-+ (TileLayer *)layerBeingPainted
-{
- return layerBeingPainted;
-}
-
-@end
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileLayerPoolh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileLayerPool.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileLayerPool.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileLayerPool.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,90 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 TileLayerPool_h
-#define TileLayerPool_h
-
-#if PLATFORM(IOS)
-
-#include "IntSize.h"
-#include "IntSizeHash.h"
-#include "Timer.h"
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
-
-@class TileLayer;
-
-namespace WebCore {
-
-class TileLayerPool {
- WTF_MAKE_NONCOPYABLE(TileLayerPool);
-public:
- static TileLayerPool* sharedPool();
-
- void addLayer(const RetainPtr<TileLayer>&);
- RetainPtr<TileLayer> takeLayerWithSize(const IntSize&);
-
- // The maximum size of all queued layers in bytes.
- unsigned capacity() const { return m_capacity; }
- void setCapacity(unsigned);
- void drain();
-
- unsigned decayedCapacity() const;
-
- static unsigned bytesBackingLayerWithPixelSize(const IntSize&);
-
-private:
- TileLayerPool();
-
- typedef Deque<RetainPtr<TileLayer> > LayerList;
-
- bool canReuseLayerWithSize(const IntSize& size) const { return m_capacity && !size.isEmpty(); }
- void schedulePrune();
- void prune();
- typedef enum { LeaveUnchanged, MarkAsUsed } AccessType;
- LayerList& listOfLayersWithSize(const IntSize&, AccessType = LeaveUnchanged);
-
- HashMap<IntSize, LayerList> m_reuseLists;
- // Ordered by recent use. The last size is the most recently used.
- Vector<IntSize> m_sizesInPruneOrder;
- unsigned m_totalBytes;
- unsigned m_capacity;
- Mutex m_layerPoolMutex;
-
- double m_lastAddTime;
- bool m_needsPrune;
-
- friend NeverDestroyed<TileLayerPool>;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
-#endif // TileLayerPool_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileLayerPoolmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/TileLayerPool.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileLayerPool.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/TileLayerPool.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,174 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011 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 "TileLayerPool.h"
-
-#if PLATFORM(IOS)
-
-#include "Logging.h"
-#include "MemoryPressureHandler.h"
-#include "TileLayer.h"
-#include "TileGrid.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/NeverDestroyed.h>
-
-namespace WebCore {
-
-static const double capacityDecayTime = 5;
-
-TileLayerPool::TileLayerPool()
- : m_totalBytes(0)
- , m_capacity(0)
- , m_lastAddTime(0)
- , m_needsPrune(false)
-{
-}
-
-TileLayerPool* TileLayerPool::sharedPool()
-{
- static NeverDestroyed<TileLayerPool> sharedPool;
- return &sharedPool.get();
-}
-
-unsigned TileLayerPool::bytesBackingLayerWithPixelSize(const IntSize& size)
-{
- return size.width() * size.height() * 4;
-}
-
-TileLayerPool::LayerList& TileLayerPool::listOfLayersWithSize(const IntSize& size, AccessType accessType)
-{
- ASSERT(!m_layerPoolMutex.tryLock());
- HashMap<IntSize, LayerList>::iterator it = m_reuseLists.find(size);
- if (it == m_reuseLists.end()) {
- it = m_reuseLists.add(size, LayerList()).iterator;
- m_sizesInPruneOrder.append(size);
- } else if (accessType == MarkAsUsed) {
- m_sizesInPruneOrder.remove(m_sizesInPruneOrder.reverseFind(size));
- m_sizesInPruneOrder.append(size);
- }
- return it->value;
-}
-
-void TileLayerPool::addLayer(const RetainPtr<TileLayer>& layer)
-{
- IntSize layerSize([layer.get() frame].size);
- layerSize.scale([layer.get() contentsScale]);
- if (!canReuseLayerWithSize(layerSize))
- return;
-
- if (memoryPressureHandler().hasReceivedMemoryPressure()) {
- LOG(MemoryPressure, "Under memory pressure: %s, totalBytes: %d", __PRETTY_FUNCTION__, m_totalBytes);
- return;
- }
-
- MutexLocker locker(m_layerPoolMutex);
- listOfLayersWithSize(layerSize).prepend(layer);
- m_totalBytes += bytesBackingLayerWithPixelSize(layerSize);
-
- m_lastAddTime = currentTime();
- schedulePrune();
-}
-
-RetainPtr<TileLayer> TileLayerPool::takeLayerWithSize(const IntSize& size)
-{
- if (!canReuseLayerWithSize(size))
- return nil;
- MutexLocker locker(m_layerPoolMutex);
- LayerList& reuseList = listOfLayersWithSize(size, MarkAsUsed);
- if (reuseList.isEmpty())
- return nil;
- m_totalBytes -= bytesBackingLayerWithPixelSize(size);
- return reuseList.takeFirst();
-}
-
-void TileLayerPool::setCapacity(unsigned capacity)
-{
- MutexLocker reuseLocker(m_layerPoolMutex);
- if (capacity < m_capacity)
- schedulePrune();
- m_capacity = capacity;
-}
-
-unsigned TileLayerPool::decayedCapacity() const
-{
- // Decay to one quarter over capacityDecayTime
- double timeSinceLastAdd = currentTime() - m_lastAddTime;
- if (timeSinceLastAdd > capacityDecayTime)
- return m_capacity / 4;
- float decayProgess = float(timeSinceLastAdd / capacityDecayTime);
- return m_capacity / 4 + m_capacity * 3 / 4 * (1.f - decayProgess);
-}
-
-void TileLayerPool::schedulePrune()
-{
- ASSERT(!m_layerPoolMutex.tryLock());
- if (m_needsPrune)
- return;
- m_needsPrune = true;
- dispatch_time_t nextPruneTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
- dispatch_after(nextPruneTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- prune();
- });
-}
-
-void TileLayerPool::prune()
-{
- MutexLocker locker(m_layerPoolMutex);
- ASSERT(m_needsPrune);
- m_needsPrune = false;
- unsigned shrinkTo = decayedCapacity();
- while (m_totalBytes > shrinkTo) {
- ASSERT(!m_sizesInPruneOrder.isEmpty());
- IntSize sizeToDrop = m_sizesInPruneOrder.first();
- LayerList& oldestReuseList = m_reuseLists.find(sizeToDrop)->value;
- if (oldestReuseList.isEmpty()) {
- m_reuseLists.remove(sizeToDrop);
- m_sizesInPruneOrder.remove(0);
- continue;
- }
-#if LOG_TILING
- NSLog(@"dropping layer of size %d x %d", sizeToDrop.width(), sizeToDrop.height());
-#endif
- m_totalBytes -= bytesBackingLayerWithPixelSize(sizeToDrop);
- // The last element in the list is the oldest, hence most likely not to
- // still have a backing store.
- oldestReuseList.removeLast();
- }
- if (currentTime() - m_lastAddTime <= capacityDecayTime)
- schedulePrune();
-}
-
-void TileLayerPool::drain()
-{
- MutexLocker reuseLocker(m_layerPoolMutex);
- m_reuseLists.clear();
- m_sizesInPruneOrder.clear();
- m_totalBytes = 0;
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformioswakWAKWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/wak/WAKWindow.h (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/wak/WAKWindow.h        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/wak/WAKWindow.h        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -40,11 +40,11 @@
</span><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> namespace WebCore {
</span><del>- class TileCache;
</del><ins>+ class LegacyTileCache;
</ins><span class="cx"> }
</span><del>-typedef WebCore::TileCache TileCache;
</del><ins>+typedef WebCore::LegacyTileCache LegacyTileCache;
</ins><span class="cx"> #else
</span><del>-typedef struct TileCache TileCache;
</del><ins>+typedef struct LegacyTileCache LegacyTileCache;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> @interface WAKWindow : WAKResponder
</span><span class="cx"> {
</span><span class="cx"> CALayer* _hostLayer;
</span><del>- TileCache* _tileCache;
</del><ins>+ LegacyTileCache* _tileCache;
</ins><span class="cx"> CGRect _frozenVisibleRect;
</span><span class="cx"> CALayer *_rootLayer;
</span><span class="cx">
</span><span class="lines">@@ -160,7 +160,7 @@
</span><span class="cx"> - (float)currentTileScale;
</span><span class="cx"> - (void)setKeepsZoomedOutTiles:(BOOL)keepsZoomedOutTiles;
</span><span class="cx"> - (BOOL)keepsZoomedOutTiles;
</span><del>-- (TileCache *)tileCache;
</del><ins>+- (LegacyTileCache *)tileCache;
</ins><span class="cx">
</span><span class="cx"> - (void)dumpTiles;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformioswakWAKWindowmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><del>-#import "TileCache.h"
</del><ins>+#import "LegacyTileCache.h"
</ins><span class="cx"> #import "WAKViewPrivate.h"
</span><span class="cx"> #import "WebCoreSystemInterface.h"
</span><span class="cx"> #import "WebCoreThreadRun.h"
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> _frame = [_hostLayer frame];
</span><span class="cx"> _screenScale = wkGetScreenScaleFactor();
</span><span class="cx">
</span><del>- _tileCache = new TileCache(self);
</del><ins>+ _tileCache = new LegacyTileCache(self);
</ins><span class="cx">
</span><span class="cx"> _frozenVisibleRect = CGRectNull;
</span><span class="cx">
</span><span class="lines">@@ -484,7 +484,7 @@
</span><span class="cx"> {
</span><span class="cx"> if (!_tileCache)
</span><span class="cx"> return;
</span><del>- _tileCache->setTilingMode((TileCache::TilingMode)mode);
</del><ins>+ _tileCache->setTilingMode((LegacyTileCache::TilingMode)mode);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (WAKWindowTilingMode)tilingMode
</span><span class="lines">@@ -498,7 +498,7 @@
</span><span class="cx"> {
</span><span class="cx"> if (!_tileCache)
</span><span class="cx"> return;
</span><del>- _tileCache->setTilingDirection((TileCache::TilingDirection)tilingDirection);
</del><ins>+ _tileCache->setTilingDirection((LegacyTileCache::TilingDirection)tilingDirection);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (WAKTilingDirection)tilingDirection
</span><span class="lines">@@ -550,7 +550,7 @@
</span><span class="cx"> return _tileCache->keepsZoomedOutTiles();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (TileCache*)tileCache
</del><ins>+- (LegacyTileCache*)tileCache
</ins><span class="cx"> {
</span><span class="cx"> return _tileCache;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -66,10 +66,10 @@
</span><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+#include "LegacyTileCache.h"
</ins><span class="cx"> #include "MainFrame.h"
</span><span class="cx"> #include "Region.h"
</span><span class="cx"> #include "RenderScrollbar.h"
</span><del>-#include "TileCache.h"
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="lines">@@ -2681,16 +2681,16 @@
</span><span class="cx"> float RenderLayerCompositor::contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- TileCache* tileCache = nullptr;
</del><ins>+ LegacyTileCache* tileCache = nullptr;
</ins><span class="cx"> if (Page* page = this->page()) {
</span><span class="cx"> if (FrameView* frameView = page->mainFrame().view())
</span><del>- tileCache = frameView->tileCache();
</del><ins>+ tileCache = frameView->legacyTileCache();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!tileCache)
</span><span class="cx"> return 1;
</span><span class="cx">
</span><del>- return tileCache->tilingMode() == TileCache::Zooming ? 0.125 : 1;
</del><ins>+ return tileCache->tilingMode() == LegacyTileCache::Zooming ? 0.125 : 1;
</ins><span class="cx"> #else
</span><span class="cx"> return 1;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-03-31 Antti Koivisto <antti@apple.com>
+
+ Rename TileCache to LegacyTileCache
+ https://bugs.webkit.org/show_bug.cgi?id=130986
+
+ Reviewed by Simon Fraser.
+
+ * WebView/WebView.mm:
+ (+[WebView drainLayerPool]):
+ (+[WebView _setTileCacheLayerPoolCapacity:]):
+
</ins><span class="cx"> 2014-03-28 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix recently-introduced off-by-one error in centerTruncateToBuffer
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (166528 => 166529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2014-03-31 21:10:44 UTC (rev 166528)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2014-03-31 21:18:23 UTC (rev 166529)
</span><span class="lines">@@ -232,12 +232,12 @@
</span><span class="cx"> #import <WebCore/FontCache.h>
</span><span class="cx"> #import <WebCore/GraphicsLayer.h>
</span><span class="cx"> #import <WebCore/IconController.h>
</span><ins>+#import <WebCore/LegacyTileCache.h>
</ins><span class="cx"> #import <WebCore/NetworkStateNotifier.h>
</span><span class="cx"> #import <WebCore/RuntimeApplicationChecksIOS.h>
</span><span class="cx"> #import <WebCore/SQLiteDatabaseTracker.h>
</span><span class="cx"> #import <WebCore/SmartReplace.h>
</span><span class="cx"> #import <WebCore/TextRun.h>
</span><del>-#import <WebCore/TileCache.h>
</del><span class="cx"> #import <WebCore/TileControllerMemoryHandlerIOS.h>
</span><span class="cx"> #import <WebCore/WAKWindow.h>
</span><span class="cx"> #import <WebCore/WebCoreThread.h>
</span><span class="lines">@@ -1330,7 +1330,7 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(WebThreadIsCurrent());
</span><span class="cx"> WebKit::MemoryMeasure measurer("Memory warning: Draining layer pool.");
</span><del>- WebCore::TileCache::drainLayerPool();
</del><ins>+ WebCore::LegacyTileCache::drainLayerPool();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> + (void)discardAllCompiledCode
</span><span class="lines">@@ -4549,7 +4549,7 @@
</span><span class="cx">
</span><span class="cx"> + (void)_setTileCacheLayerPoolCapacity:(unsigned)capacity
</span><span class="cx"> {
</span><del>- TileCache::setLayerPoolCapacity(capacity);
</del><ins>+ LegacyTileCache::setLayerPoolCapacity(capacity);
</ins><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>