<!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>[169919] trunk/Source/WebCore</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/169919">169919</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-06-12 16:10:29 -0700 (Thu, 12 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Correct file locations after <a href="http://trac.webkit.org/projects/webkit/changeset/169914">r169914</a>. These should have been
in platform/graphics/ca.
Rubberstamped by Tim Horton.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/ca/TileController.cpp: Copied from platform/graphics/ca/mac/TileController.cpp.
* platform/graphics/ca/TileController.h: Copied from platform/graphics/ca/mac/TileController.h.
* platform/graphics/ca/TileGrid.cpp: Copied from platform/graphics/ca/mac/TileGrid.cpp.
* platform/graphics/ca/TileGrid.h: Copied from platform/graphics/ca/mac/TileGrid.h.
* platform/graphics/ca/mac/TileController.cpp: Removed.
* platform/graphics/ca/mac/TileController.h: Removed.
* platform/graphics/ca/mac/TileGrid.cpp: Removed.
* platform/graphics/ca/mac/TileGrid.h: Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllercpp">trunk/Source/WebCore/platform/graphics/ca/TileController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllerh">trunk/Source/WebCore/platform/graphics/ca/TileController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridcpp">trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridh">trunk/Source/WebCore/platform/graphics/ca/TileGrid.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileControllercpp">trunk/Source/WebCore/platform/graphics/ca/mac/TileController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileControllerh">trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileGridcpp">trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileGridh">trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/ChangeLog        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-06-12 Brent Fulgham <bfulgham@apple.com>
+
+ Correct file locations after r169914. These should have been
+ in platform/graphics/ca.
+
+ Rubberstamped by Tim Horton.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/ca/TileController.cpp: Copied from platform/graphics/ca/mac/TileController.cpp.
+ * platform/graphics/ca/TileController.h: Copied from platform/graphics/ca/mac/TileController.h.
+ * platform/graphics/ca/TileGrid.cpp: Copied from platform/graphics/ca/mac/TileGrid.cpp.
+ * platform/graphics/ca/TileGrid.h: Copied from platform/graphics/ca/mac/TileGrid.h.
+ * platform/graphics/ca/mac/TileController.cpp: Removed.
+ * platform/graphics/ca/mac/TileController.h: Removed.
+ * platform/graphics/ca/mac/TileGrid.cpp: Removed.
+ * platform/graphics/ca/mac/TileGrid.h: Removed.
+
</ins><span class="cx"> 2014-06-12 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix the build after r169913.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -777,8 +777,6 @@
</span><span class="cx">                 1A927FD31416A15B003A83C8 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD01416A15B003A83C8 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1A927FD41416A15B003A83C8 /* nptypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD11416A15B003A83C8 /* nptypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1A98956B0AA78F80005EF5EF /* URLCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98956A0AA78F80005EF5EF /* URLCF.cpp */; };
</span><del>-                1AA7160A149BC4DB0016EC19 /* TileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA71608149BC4DA0016EC19 /* TileController.cpp */; };
-                1AA7160B149BC4DB0016EC19 /* TileController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA71609149BC4DB0016EC19 /* TileController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">                 1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */; };
</span><span class="cx">                 1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA8798F11CBE846003C664F /* PluginStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2346,6 +2344,10 @@
</span><span class="cx">                 7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; };
</span><span class="cx">                 7A93868518DCC14500B8263D /* VTTScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A93868218DCC14500B8263D /* VTTScanner.cpp */; };
</span><span class="cx">                 7A93868618DCC14500B8263D /* VTTScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A93868318DCC14500B8263D /* VTTScanner.h */; };
</span><ins>+                7AA3A699194A64E7001CBD24 /* TileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA3A695194A64E7001CBD24 /* TileController.cpp */; };
+                7AA3A69A194A64E7001CBD24 /* TileController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA3A696194A64E7001CBD24 /* TileController.h */; };
+                7AA3A69B194A64E7001CBD24 /* TileGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA3A697194A64E7001CBD24 /* TileGrid.cpp */; };
+                7AA3A69C194A64E7001CBD24 /* TileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA3A698194A64E7001CBD24 /* TileGrid.h */; };
</ins><span class="cx">                 7AABA25914BC613300AA9A11 /* DOMEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AABA25714BC613300AA9A11 /* DOMEditor.cpp */; };
</span><span class="cx">                 7AABA25A14BC613300AA9A11 /* DOMEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AABA25814BC613300AA9A11 /* DOMEditor.h */; };
</span><span class="cx">                 7AB0B1C01211A62200A76940 /* InspectorDatabaseAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */; };
</span><span class="lines">@@ -6145,8 +6147,6 @@
</span><span class="cx">                 E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */ = {isa = PBXBuildFile; fileRef = E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4C1789A0EE6903800824D69 /* CSSSelectorList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C178950EE6903800824D69 /* CSSSelectorList.cpp */; };
</span><span class="cx">                 E4C1789B0EE6903800824D69 /* CSSSelectorList.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C178960EE6903800824D69 /* CSSSelectorList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                E4C274CA18E988EA00602C76 /* TileGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C274C918E988EA00602C76 /* TileGrid.cpp */; };
-                E4C274CC18E988F500602C76 /* TileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C274CB18E988F500602C76 /* TileGrid.h */; };
</del><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><span class="cx">                 E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7704,8 +7704,6 @@
</span><span class="cx">                 1A927FD01416A15B003A83C8 /* npruntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = npruntime.h; sourceTree = "<group>"; };
</span><span class="cx">                 1A927FD11416A15B003A83C8 /* nptypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nptypes.h; sourceTree = "<group>"; };
</span><span class="cx">                 1A98956A0AA78F80005EF5EF /* URLCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = URLCF.cpp; sourceTree = "<group>"; };
</span><del>-                1AA71608149BC4DA0016EC19 /* TileController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileController.cpp; path = ca/mac/TileController.cpp; sourceTree = "<group>"; };
-                1AA71609149BC4DB0016EC19 /* TileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileController.h; path = ca/mac/TileController.h; sourceTree = "<group>"; };
</del><span class="cx">                 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollElasticityController.mm; sourceTree = "<group>"; };
</span><span class="cx">                 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollElasticityController.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AA8798F11CBE846003C664F /* PluginStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginStrategy.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -9450,6 +9448,10 @@
</span><span class="cx">                 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHostCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7A93868218DCC14500B8263D /* VTTScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTScanner.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7A93868318DCC14500B8263D /* VTTScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTTScanner.h; sourceTree = "<group>"; };
</span><ins>+                7AA3A695194A64E7001CBD24 /* TileController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileController.cpp; path = ca/TileController.cpp; sourceTree = "<group>"; };
+                7AA3A696194A64E7001CBD24 /* TileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileController.h; path = ca/TileController.h; sourceTree = "<group>"; };
+                7AA3A697194A64E7001CBD24 /* TileGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileGrid.cpp; path = ca/TileGrid.cpp; sourceTree = "<group>"; };
+                7AA3A698194A64E7001CBD24 /* TileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGrid.h; path = ca/TileGrid.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7AABA25714BC613300AA9A11 /* DOMEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMEditor.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7AABA25814BC613300AA9A11 /* DOMEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMEditor.h; sourceTree = "<group>"; };
</span><span class="cx">                 7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDatabaseAgent.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -13622,8 +13624,6 @@
</span><span class="cx">                 E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRule.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4C178950EE6903800824D69 /* CSSSelectorList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSSelectorList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4C178960EE6903800824D69 /* CSSSelectorList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSSelectorList.h; sourceTree = "<group>"; };
</span><del>-                E4C274C918E988EA00602C76 /* TileGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileGrid.cpp; path = ca/mac/TileGrid.cpp; sourceTree = "<group>"; };
-                E4C274CB18E988F500602C76 /* TileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGrid.h; path = ca/mac/TileGrid.h; sourceTree = "<group>"; };
</del><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><span class="cx">                 E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyTileCache.h; path = ios/LegacyTileCache.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -15832,10 +15832,10 @@
</span><span class="cx">                                 2D70BA1418074F850001908A /* PlatformCALayer.cpp */,
</span><span class="cx">                                 499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
</span><span class="cx">                                 493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
</span><del>-                                1AA71609149BC4DB0016EC19 /* TileController.h */,
-                                1AA71608149BC4DA0016EC19 /* TileController.cpp */,
-                                E4C274CB18E988F500602C76 /* TileGrid.h */,
-                                E4C274C918E988EA00602C76 /* TileGrid.cpp */,
</del><ins>+                                7AA3A695194A64E7001CBD24 /* TileController.cpp */,
+                                7AA3A696194A64E7001CBD24 /* TileController.h */,
+                                7AA3A697194A64E7001CBD24 /* TileGrid.cpp */,
+                                7AA3A698194A64E7001CBD24 /* TileGrid.h */,
</ins><span class="cx">                                 494BC40C12AEDD9E00743BD2 /* TransformationMatrixCA.cpp */,
</span><span class="cx">                         );
</span><span class="cx">                         name = ca;
</span><span class="lines">@@ -24697,7 +24697,6 @@
</span><span class="cx">                                 C585A68D11D4FB08004C3E4B /* JSIDBKeyRange.h in Headers */,
</span><span class="cx">                                 C585A68F11D4FB08004C3E4B /* JSIDBObjectStore.h in Headers */,
</span><span class="cx">                                 C585A69111D4FB08004C3E4B /* JSIDBRequest.h in Headers */,
</span><del>-                                E4C274CC18E988F500602C76 /* TileGrid.h in Headers */,
</del><span class="cx">                                 B6566270120B1227006EA85C /* JSIDBTransaction.h in Headers */,
</span><span class="cx">                                 269239961505E1AA009E57FC /* JSIDBVersionChangeEvent.h in Headers */,
</span><span class="cx">                                 BC6C49F40D7DBA0500FFA558 /* JSImageConstructor.h in Headers */,
</span><span class="lines">@@ -24849,6 +24848,7 @@
</span><span class="cx">                                 B2FA3D510AB75A6F000E5AC4 /* JSSVGAnimatedTransformList.h in Headers */,
</span><span class="cx">                                 B2FA3D530AB75A6F000E5AC4 /* JSSVGAnimateElement.h in Headers */,
</span><span class="cx">                                 4496E39E1398136C003EE32A /* JSSVGAnimateMotionElement.h in Headers */,
</span><ins>+                                7AA3A69C194A64E7001CBD24 /* TileGrid.h in Headers */,
</ins><span class="cx">                                 B2FA3D550AB75A6F000E5AC4 /* JSSVGAnimateTransformElement.h in Headers */,
</span><span class="cx">                                 B2FA3D570AB75A6F000E5AC4 /* JSSVGAnimationElement.h in Headers */,
</span><span class="cx">                                 B2FA3D590AB75A6F000E5AC4 /* JSSVGCircleElement.h in Headers */,
</span><span class="lines">@@ -25238,6 +25238,7 @@
</span><span class="cx">                                 656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */,
</span><span class="cx">                                 628D214C12131ED10055DCFC /* NetworkingContext.h in Headers */,
</span><span class="cx">                                 59C27F07138D28CF0079B7E2 /* NetworkResourcesData.h in Headers */,
</span><ins>+                                7AA3A69A194A64E7001CBD24 /* TileController.h in Headers */,
</ins><span class="cx">                                 1A7FA6190DDA3B3A0028F8A5 /* NetworkStateNotifier.h in Headers */,
</span><span class="cx">                                 E13EF3441684ECF40034C83F /* NetworkStorageSession.h in Headers */,
</span><span class="cx">                                 BCEF43DD0E674012001C1287 /* NinePieceImage.h in Headers */,
</span><span class="lines">@@ -26229,7 +26230,6 @@
</span><span class="cx">                                 E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */,
</span><span class="cx">                                 185BCF290F3279CE000EA262 /* ThreadTimers.h in Headers */,
</span><span class="cx">                                 E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */,
</span><del>-                                1AA7160B149BC4DB0016EC19 /* TileController.h in Headers */,
</del><span class="cx">                                 1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */,
</span><span class="cx">                                 1AF89A421518FDEA00E547B5 /* TiledBacking.h in Headers */,
</span><span class="cx">                                 E4B65A58132FA8E70070E7BE /* LegacyTileGrid.h in Headers */,
</span><span class="lines">@@ -28519,7 +28519,6 @@
</span><span class="cx">                                 516BB7940CE91E6800512F79 /* JSTreeWalkerCustom.cpp in Sources */,
</span><span class="cx">                                 A86629D009DA2B48009633A5 /* JSUIEvent.cpp in Sources */,
</span><span class="cx">                                 AAA4FAD3175D5CB300743873 /* JSUIRequestEvent.cpp in Sources */,
</span><del>-                                E4C274CA18E988EA00602C76 /* TileGrid.cpp in Sources */,
</del><span class="cx">                                 15C77094100D3CA8005BA267 /* JSValidityState.cpp in Sources */,
</span><span class="cx">                                 CDE83DB6183D352A0031EAA3 /* JSVideoPlaybackQuality.cpp in Sources */,
</span><span class="cx">                                 07C59B5F17F4B208000FBCBB /* JSVideoStreamTrack.cpp in Sources */,
</span><span class="lines">@@ -29435,6 +29434,7 @@
</span><span class="cx">                                 B2227AA20D00BF220071B782 /* SVGScriptElement.cpp in Sources */,
</span><span class="cx">                                 B2227AA50D00BF220071B782 /* SVGSetElement.cpp in Sources */,
</span><span class="cx">                                 E4AFD00F0DAF335500F5F55C /* SVGSMILElement.cpp in Sources */,
</span><ins>+                                7AA3A699194A64E7001CBD24 /* TileController.cpp in Sources */,
</ins><span class="cx">                                 B2227AA80D00BF220071B782 /* SVGStopElement.cpp in Sources */,
</span><span class="cx">                                 B2227AAB0D00BF220071B782 /* SVGStringList.cpp in Sources */,
</span><span class="cx">                                 B2227AB70D00BF220071B782 /* SVGStyleElement.cpp in Sources */,
</span><span class="lines">@@ -29474,6 +29474,7 @@
</span><span class="cx">                                 CE7B2DB61586ABAD0098B3FA /* TextAlternativeWithRange.mm in Sources */,
</span><span class="cx">                                 0F54DCE51881051D003EEDBB /* TextAutoSizing.cpp in Sources */,
</span><span class="cx">                                 372C00C4129611F1005C9575 /* TextBoundaries.cpp in Sources */,
</span><ins>+                                7AA3A69B194A64E7001CBD24 /* TileGrid.cpp in Sources */,
</ins><span class="cx">                                 B2AFFC970D00A5DF0030074D /* TextBoundaries.mm in Sources */,
</span><span class="cx">                                 BCD8A5F015F56F2C0098D071 /* TextBreakIterator.cpp in Sources */,
</span><span class="cx">                                 B2AFFC980D00A5DF0030074D /* TextBreakIteratorInternalICUMac.mm in Sources */,
</span><span class="lines">@@ -29525,7 +29526,6 @@
</span><span class="cx">                                 E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */,
</span><span class="cx">                                 185BCF280F3279CE000EA262 /* ThreadTimers.cpp in Sources */,
</span><span class="cx">                                 E4C3B1FC0F0E4170009693F6 /* LegacyTileCache.mm in Sources */,
</span><del>-                                1AA7160A149BC4DB0016EC19 /* TileController.cpp in Sources */,
</del><span class="cx">                                 1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */,
</span><span class="cx">                                 E4B65A5A132FAAF90070E7BE /* LegacyTileGrid.mm in Sources */,
</span><span class="cx">                                 E424A3A01330DF1E00CF6DC9 /* LegacyTileGridTile.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllercppfromrev169914trunkSourceWebCoreplatformgraphicscamacTileControllercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (from rev 169914, trunk/Source/WebCore/platform/graphics/ca/mac/TileController.cpp) (0 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -0,0 +1,551 @@
</span><ins>+/*
+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TileController.h"
+
+#include "IntRect.h"
+#include "LayerPool.h"
+#include "PlatformCALayer.h"
+#include "Region.h"
+#include "TileCoverageMap.h"
+#include "TileGrid.h"
+#include "WebLayer.h"
+#include <utility>
+#include <wtf/MainThread.h>
+
+#if PLATFORM(IOS)
+#include "TileControllerMemoryHandlerIOS.h"
+#endif
+
+namespace WebCore {
+
+PassOwnPtr<TileController> TileController::create(PlatformCALayer* rootPlatformLayer)
+{
+ return adoptPtr(new TileController(rootPlatformLayer));
+}
+
+TileController::TileController(PlatformCALayer* rootPlatformLayer)
+ : m_tileCacheLayer(rootPlatformLayer)
+ , m_tileGrid(std::make_unique<TileGrid>(*this))
+ , m_tileSize(defaultTileWidth, defaultTileHeight)
+ , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
+ , m_zoomedOutContentsScale(0)
+ , m_deviceScaleFactor(owningGraphicsLayer()->platformCALayerDeviceScaleFactor())
+ , m_tileCoverage(CoverageForVisibleArea)
+ , m_marginTop(0)
+ , m_marginBottom(0)
+ , m_marginLeft(0)
+ , m_marginRight(0)
+ , m_isInWindow(false)
+ , m_scrollingPerformanceLoggingEnabled(false)
+ , m_unparentsOffscreenTiles(false)
+ , m_acceleratesDrawing(false)
+ , m_tilesAreOpaque(false)
+ , m_hasTilesWithTemporaryScaleFactor(false)
+ , m_tileDebugBorderWidth(0)
+ , m_indicatorMode(AsyncScrollingIndication)
+ , m_topContentInset(0)
+{
+}
+
+TileController::~TileController()
+{
+ ASSERT(isMainThread());
+
+#if PLATFORM(IOS)
+ tileControllerMemoryHandler().removeTileController(this);
+#endif
+}
+
+void TileController::tileCacheLayerBoundsChanged()
+{
+ ASSERT(owningGraphicsLayer()->isCommittingChanges());
+ setNeedsRevalidateTiles();
+}
+
+void TileController::setNeedsDisplay()
+{
+ tileGrid().setNeedsDisplay();
+ m_zoomedOutTileGrid = nullptr;
+}
+
+void TileController::setNeedsDisplayInRect(const IntRect& rect)
+{
+ tileGrid().setNeedsDisplayInRect(rect);
+ if (m_zoomedOutTileGrid)
+ m_zoomedOutTileGrid->dropTilesInRect(rect);
+}
+
+void TileController::setContentsScale(float scale)
+{
+ ASSERT(owningGraphicsLayer()->isCommittingChanges());
+
+ float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
+ // The scale we get is the product of the page scale factor and device scale factor.
+ // Divide by the device scale factor so we'll get the page scale factor.
+ scale /= deviceScaleFactor;
+
+ if (tileGrid().scale() == scale && m_deviceScaleFactor == deviceScaleFactor && !m_hasTilesWithTemporaryScaleFactor)
+ return;
+
+ m_hasTilesWithTemporaryScaleFactor = false;
+ m_deviceScaleFactor = deviceScaleFactor;
+
+ if (m_coverageMap)
+ m_coverageMap->setDeviceScaleFactor(deviceScaleFactor);
+
+ if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
+ m_tileGrid = std::move(m_zoomedOutTileGrid);
+ m_tileGrid->revalidateTiles(0);
+ return;
+ }
+
+ if (m_zoomedOutContentsScale && m_zoomedOutContentsScale == tileGrid().scale() && tileGrid().scale() != scale && !m_hasTilesWithTemporaryScaleFactor) {
+ m_zoomedOutTileGrid = std::move(m_tileGrid);
+ m_tileGrid = std::make_unique<TileGrid>(*this);
+ }
+
+ tileGrid().setScale(scale);
+ tileGrid().setNeedsDisplay();
+}
+
+float TileController::contentsScale() const
+{
+ return tileGrid().scale() * m_deviceScaleFactor;
+}
+
+float TileController::zoomedOutContentsScale() const
+{
+ return m_zoomedOutContentsScale * m_deviceScaleFactor;
+}
+
+void TileController::setZoomedOutContentsScale(float scale)
+{
+ ASSERT(owningGraphicsLayer()->isCommittingChanges());
+
+ float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
+ scale /= deviceScaleFactor;
+
+ if (m_zoomedOutContentsScale == scale)
+ return;
+ m_zoomedOutContentsScale = scale;
+
+ if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() != m_zoomedOutContentsScale)
+ m_zoomedOutTileGrid = nullptr;
+}
+
+void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
+{
+ if (m_acceleratesDrawing == acceleratesDrawing)
+ return;
+ m_acceleratesDrawing = acceleratesDrawing;
+
+ tileGrid().updateTileLayerProperties();
+}
+
+void TileController::setTilesOpaque(bool opaque)
+{
+ if (opaque == m_tilesAreOpaque)
+ return;
+ m_tilesAreOpaque = opaque;
+
+ tileGrid().updateTileLayerProperties();
+}
+
+void TileController::setVisibleRect(const FloatRect& visibleRect)
+{
+ ASSERT(owningGraphicsLayer()->isCommittingChanges());
+ if (m_visibleRect == visibleRect)
+ return;
+
+ m_visibleRect = visibleRect;
+ setNeedsRevalidateTiles();
+}
+
+bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
+{
+ if (bounds().isEmpty())
+ return false;
+ return tileGrid().tilesWouldChangeForVisibleRect(newVisibleRect, m_visibleRect);
+}
+
+void TileController::setTopContentInset(float topContentInset)
+{
+ m_topContentInset = topContentInset;
+ setTiledScrollingIndicatorPosition(FloatPoint(0, m_topContentInset));
+}
+
+void TileController::setTiledScrollingIndicatorPosition(const FloatPoint& position)
+{
+ if (!m_coverageMap)
+ return;
+ m_coverageMap->setPosition(position);
+ m_coverageMap->update();
+}
+
+void TileController::prepopulateRect(const FloatRect& rect)
+{
+ if (tileGrid().prepopulateRect(rect))
+ setNeedsRevalidateTiles();
+}
+
+void TileController::setIsInWindow(bool isInWindow)
+{
+ if (m_isInWindow == isInWindow)
+ return;
+
+ m_isInWindow = isInWindow;
+
+ if (m_isInWindow)
+ setNeedsRevalidateTiles();
+ else {
+ const double tileRevalidationTimeout = 4;
+ scheduleTileRevalidation(tileRevalidationTimeout);
+ }
+}
+
+void TileController::setTileCoverage(TileCoverage coverage)
+{
+ if (coverage == m_tileCoverage)
+ return;
+
+ m_tileCoverage = coverage;
+ setNeedsRevalidateTiles();
+}
+
+void TileController::revalidateTiles()
+{
+ ASSERT(owningGraphicsLayer()->isCommittingChanges());
+ tileGrid().revalidateTiles(0);
+ m_visibleRectAtLastRevalidate = m_visibleRect;
+}
+
+void TileController::forceRepaint()
+{
+ setNeedsDisplay();
+}
+
+void TileController::setTileDebugBorderWidth(float borderWidth)
+{
+ if (m_tileDebugBorderWidth == borderWidth)
+ return;
+ m_tileDebugBorderWidth = borderWidth;
+
+ tileGrid().updateTileLayerProperties();
+}
+
+void TileController::setTileDebugBorderColor(Color borderColor)
+{
+ if (m_tileDebugBorderColor == borderColor)
+ return;
+ m_tileDebugBorderColor = borderColor;
+
+ tileGrid().updateTileLayerProperties();
+}
+
+IntRect TileController::bounds() const
+{
+ IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
+ IntSize boundsSizeIncludingMargin = expandedIntSize(m_tileCacheLayer->bounds().size());
+ boundsSizeIncludingMargin.expand(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight());
+
+ return IntRect(boundsOriginIncludingMargin, boundsSizeIncludingMargin);
+}
+
+IntRect TileController::boundsWithoutMargin() const
+{
+ return IntRect(IntPoint(), expandedIntSize(m_tileCacheLayer->bounds().size()));
+}
+
+IntRect TileController::boundsAtLastRevalidateWithoutMargin() const
+{
+ IntRect boundsWithoutMargin = IntRect(IntPoint(), m_boundsAtLastRevalidate.size());
+ boundsWithoutMargin.contract(IntSize(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight()));
+ return boundsWithoutMargin;
+}
+
+FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
+{
+ // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
+ if (!m_isInWindow)
+ return visibleRect;
+
+ // FIXME: look at how far the document can scroll in each dimension.
+ float coverageHorizontalSize = visibleRect.width();
+ float coverageVerticalSize = visibleRect.height();
+
+#if PLATFORM(IOS)
+ UNUSED_PARAM(previousVisibleRect);
+ return visibleRect;
+#else
+ bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
+
+ // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
+ // These values were chosen because it's more common to have tall pages and to scroll vertically,
+ // so we keep more tiles above and below the current area.
+
+ if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange)
+ coverageHorizontalSize *= 2;
+
+ if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
+ coverageVerticalSize *= 3;
+#endif
+ coverageVerticalSize += topMarginHeight() + bottomMarginHeight();
+ coverageHorizontalSize += leftMarginWidth() + rightMarginWidth();
+
+ FloatRect coverageBounds = bounds();
+ float coverageLeft = visibleRect.x() - (coverageHorizontalSize - visibleRect.width()) / 2;
+ coverageLeft = std::min(coverageLeft, coverageBounds.maxX() - coverageHorizontalSize);
+ coverageLeft = std::max(coverageLeft, coverageBounds.x());
+
+ float coverageTop = visibleRect.y() - (coverageVerticalSize - visibleRect.height()) / 2;
+ coverageTop = std::min(coverageTop, coverageBounds.maxY() - coverageVerticalSize);
+ coverageTop = std::max(coverageTop, coverageBounds.y());
+
+ return FloatRect(coverageLeft, coverageTop, coverageHorizontalSize, coverageVerticalSize);
+}
+
+void TileController::scheduleTileRevalidation(double interval)
+{
+ if (m_tileRevalidationTimer.isActive() && m_tileRevalidationTimer.nextFireInterval() < interval)
+ return;
+
+ m_tileRevalidationTimer.startOneShot(interval);
+}
+
+bool TileController::shouldAggressivelyRetainTiles() const
+{
+ return owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer);
+}
+
+bool TileController::shouldTemporarilyRetainTileCohorts() const
+{
+ return owningGraphicsLayer()->platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer);
+}
+
+void TileController::tileRevalidationTimerFired(Timer<TileController>*)
+{
+ if (!owningGraphicsLayer())
+ return;
+
+ if (m_isInWindow) {
+ setNeedsRevalidateTiles();
+ return;
+ }
+ // If we are not visible get rid of the zoomed-out tiles.
+ m_zoomedOutTileGrid = nullptr;
+
+ unsigned validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : TileGrid::PruneSecondaryTiles) | TileGrid::UnparentAllTiles;
+
+ tileGrid().revalidateTiles(validationPolicy);
+}
+
+void TileController::didRevalidateTiles()
+{
+ m_visibleRectAtLastRevalidate = visibleRect();
+ m_boundsAtLastRevalidate = bounds();
+
+ updateTileCoverageMap();
+}
+
+unsigned TileController::blankPixelCount() const
+{
+ return tileGrid().blankPixelCount();
+}
+
+unsigned TileController::blankPixelCountForTiles(const PlatformLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
+{
+ Region paintedVisibleTiles;
+
+ for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
+ const PlatformLayer* tileLayer = it->get();
+
+ FloatRect visiblePart(CGRectOffset(frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
+ visiblePart.intersect(visibleRect);
+
+ if (!visiblePart.isEmpty())
+ paintedVisibleTiles.unite(enclosingIntRect(visiblePart));
+ }
+
+ Region uncoveredRegion(enclosingIntRect(visibleRect));
+ uncoveredRegion.subtract(paintedVisibleTiles);
+
+ return uncoveredRegion.totalArea();
+}
+
+void TileController::setNeedsRevalidateTiles()
+{
+ owningGraphicsLayer()->platformCALayerSetNeedsToRevalidateTiles();
+}
+
+void TileController::updateTileCoverageMap()
+{
+ if (m_coverageMap)
+ m_coverageMap->update();
+}
+
+IntRect TileController::tileGridExtent() const
+{
+ return tileGrid().extent();
+}
+
+double TileController::retainedTileBackingStoreMemory() const
+{
+ double bytes = tileGrid().retainedTileBackingStoreMemory();
+ if (m_zoomedOutTileGrid)
+ bytes += m_zoomedOutTileGrid->retainedTileBackingStoreMemory();
+ return bytes;
+}
+
+// Return the rect in layer coords, not tile coords.
+IntRect TileController::tileCoverageRect() const
+{
+ return tileGrid().tileCoverageRect();
+}
+
+PlatformCALayer* TileController::tiledScrollingIndicatorLayer()
+{
+ if (!m_coverageMap)
+ m_coverageMap = std::make_unique<TileCoverageMap>(*this);
+
+ return &m_coverageMap->layer();
+}
+
+void TileController::setScrollingModeIndication(ScrollingModeIndication scrollingMode)
+{
+ if (scrollingMode == m_indicatorMode)
+ return;
+
+ m_indicatorMode = scrollingMode;
+
+ updateTileCoverageMap();
+}
+
+void TileController::setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight)
+{
+ m_marginTop = marginTop;
+ m_marginBottom = marginBottom;
+ m_marginLeft = marginLeft;
+ m_marginRight = marginRight;
+
+ setNeedsRevalidateTiles();
+}
+
+bool TileController::hasMargins() const
+{
+ return m_marginTop || m_marginBottom || m_marginLeft || m_marginRight;
+}
+
+bool TileController::hasHorizontalMargins() const
+{
+ return m_marginLeft || m_marginRight;
+}
+
+bool TileController::hasVerticalMargins() const
+{
+ return m_marginTop || m_marginBottom;
+}
+
+int TileController::topMarginHeight() const
+{
+ return m_marginTop / tileGrid().scale();
+}
+
+int TileController::bottomMarginHeight() const
+{
+ return m_marginBottom / tileGrid().scale();
+}
+
+int TileController::leftMarginWidth() const
+{
+ return m_marginLeft / tileGrid().scale();
+}
+
+int TileController::rightMarginWidth() const
+{
+ return m_marginRight / tileGrid().scale();
+}
+
+RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect, TileGrid& grid)
+{
+ RefPtr<PlatformCALayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
+
+ if (layer)
+ layer->setOwner(&grid);
+ else
+ layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, &grid);
+
+ layer->setAnchorPoint(FloatPoint3D());
+ layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
+ layer->setPosition(tileRect.location());
+ layer->setBorderColor(m_tileDebugBorderColor);
+ layer->setBorderWidth(m_tileDebugBorderWidth);
+ layer->setEdgeAntialiasingMask(0);
+ layer->setOpaque(m_tilesAreOpaque);
+#ifndef NDEBUG
+ layer->setName("Tile");
+#endif
+
+ float temporaryScaleFactor = owningGraphicsLayer()->platformCALayerContentsScaleMultiplierForNewTiles(m_tileCacheLayer);
+ m_hasTilesWithTemporaryScaleFactor |= temporaryScaleFactor != 1;
+
+ layer->setContentsScale(m_deviceScaleFactor * temporaryScaleFactor);
+ layer->setAcceleratesDrawing(m_acceleratesDrawing);
+
+ layer->setNeedsDisplay();
+
+ return layer;
+}
+
+Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
+{
+ Vector<RefPtr<PlatformCALayer>> layerList;
+ if (m_zoomedOutTileGrid)
+ layerList.append(&m_zoomedOutTileGrid->containerLayer());
+ layerList.append(&tileGrid().containerLayer());
+ return layerList;
+}
+
+#if PLATFORM(IOS)
+unsigned TileController::numberOfUnparentedTiles() const
+{
+ unsigned count = tileGrid().numberOfUnparentedTiles();
+ if (m_zoomedOutTileGrid)
+ count += m_zoomedOutTileGrid->numberOfUnparentedTiles();
+ return count;
+}
+
+void TileController::removeUnparentedTilesNow()
+{
+ tileGrid().removeUnparentedTilesNow();
+ if (m_zoomedOutTileGrid)
+ m_zoomedOutTileGrid->removeUnparentedTilesNow();
+
+ updateTileCoverageMap();
+}
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllerhfromrev169913trunkSourceWebCoreplatformgraphicscamacTileControllerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/ca/TileController.h (from rev 169913, trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h) (0 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -0,0 +1,209 @@
</span><ins>+/*
+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TileController_h
+#define TileController_h
+
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "PlatformCALayer.h"
+#include "PlatformCALayerClient.h"
+#include "TiledBacking.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class FloatRect;
+class IntPoint;
+class IntRect;
+class TileCoverageMap;
+class TileGrid;
+
+typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
+
+class TileController final : public TiledBacking {
+ WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED;
+ friend class TileCoverageMap;
+ friend class TileGrid;
+public:
+ static PassOwnPtr<TileController> create(PlatformCALayer*);
+ ~TileController();
+
+ void tileCacheLayerBoundsChanged();
+
+ void setNeedsDisplay();
+ void setNeedsDisplayInRect(const IntRect&);
+
+ void setContentsScale(float);
+ float contentsScale() const;
+
+ bool acceleratesDrawing() const { return m_acceleratesDrawing; }
+ void setAcceleratesDrawing(bool);
+
+ void setTilesOpaque(bool);
+ bool tilesAreOpaque() const { return m_tilesAreOpaque; }
+
+ PlatformCALayer& rootLayer() { return *m_tileCacheLayer; }
+ const PlatformCALayer& rootLayer() const { return *m_tileCacheLayer; }
+
+ void setTileDebugBorderWidth(float);
+ void setTileDebugBorderColor(Color);
+
+ virtual FloatRect visibleRect() const override { return m_visibleRect; }
+
+ unsigned blankPixelCount() const;
+ static unsigned blankPixelCountForTiles(const PlatformLayerList&, const FloatRect&, const IntPoint&);
+
+#if PLATFORM(IOS)
+ unsigned numberOfUnparentedTiles() const;
+ void removeUnparentedTilesNow();
+#endif
+
+ float deviceScaleFactor() const { return m_deviceScaleFactor; }
+
+ Color tileDebugBorderColor() const { return m_tileDebugBorderColor; }
+ float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
+ ScrollingModeIndication indicatorMode() const { return m_indicatorMode; }
+
+ virtual IntSize tileSize() const override { return m_tileSize; }
+ virtual IntRect bounds() const override;
+ virtual IntRect boundsWithoutMargin() const override;
+ virtual bool hasMargins() const override;
+ virtual bool hasHorizontalMargins() const override;
+ virtual bool hasVerticalMargins() const override;
+ virtual int topMarginHeight() const override;
+ virtual int bottomMarginHeight() const override;
+ virtual int leftMarginWidth() const override;
+ virtual int rightMarginWidth() const override;
+ virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
+ virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
+ virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
+
+ FloatRect computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const;
+
+ IntRect boundsAtLastRevalidate() const { return m_boundsAtLastRevalidate; }
+ IntRect boundsAtLastRevalidateWithoutMargin() const;
+ FloatRect visibleRectAtLastRevalidate() const { return m_visibleRectAtLastRevalidate; }
+ void didRevalidateTiles();
+
+ bool shouldAggressivelyRetainTiles() const;
+ bool shouldTemporarilyRetainTileCohorts() const;
+
+ void updateTileCoverageMap();
+
+ RefPtr<PlatformCALayer> createTileLayer(const IntRect&, TileGrid&);
+
+ const TileGrid& tileGrid() const { return *m_tileGrid; }
+
+ Vector<RefPtr<PlatformCALayer>> containerLayers();
+
+protected:
+ void scheduleTileRevalidation(double interval);
+
+ bool isInWindow() const { return m_isInWindow; }
+ float topContentInset() const { return m_topContentInset; }
+
+private:
+ TileController(PlatformCALayer*);
+
+ TileGrid& tileGrid() { return *m_tileGrid; }
+
+ // TiledBacking member functions.
+ virtual void setVisibleRect(const FloatRect&) override;
+ virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const override;
+ virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) override;
+ virtual void setTopContentInset(float) override;
+ virtual void prepopulateRect(const FloatRect&) override;
+ virtual void setIsInWindow(bool) override;
+ virtual void setTileCoverage(TileCoverage) override;
+ virtual void revalidateTiles() override;
+ virtual void forceRepaint() override;
+ virtual IntRect tileGridExtent() const override;
+ virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
+ virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; }
+ virtual double retainedTileBackingStoreMemory() const override;
+ virtual IntRect tileCoverageRect() const override;
+ virtual PlatformCALayer* tiledScrollingIndicatorLayer() override;
+ virtual void setScrollingModeIndication(ScrollingModeIndication) override;
+ virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
+ virtual void setZoomedOutContentsScale(float) override;
+ virtual float zoomedOutContentsScale() const override;
+
+
+ void tileRevalidationTimerFired(Timer<TileController>*);
+
+ void setNeedsRevalidateTiles();
+
+ PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
+
+ PlatformCALayer* m_tileCacheLayer;
+
+ std::unique_ptr<TileCoverageMap> m_coverageMap;
+
+ std::unique_ptr<TileGrid> m_tileGrid;
+ std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
+
+ IntSize m_tileSize;
+ FloatRect m_visibleRect;
+ FloatRect m_visibleRectAtLastRevalidate;
+ IntRect m_boundsAtLastRevalidate;
+
+ Timer<TileController> m_tileRevalidationTimer;
+
+ float m_zoomedOutContentsScale;
+ float m_deviceScaleFactor;
+
+ TileCoverage m_tileCoverage;
+
+ // m_marginTop and m_marginBottom are the height in pixels of the top and bottom margin tiles. The width
+ // of those tiles will be equivalent to the width of the other tiles in the grid. m_marginRight and
+ // m_marginLeft are the width in pixels of the right and left margin tiles, respectively. The height of
+ // those tiles will be equivalent to the height of the other tiles in the grid.
+ int m_marginTop;
+ int m_marginBottom;
+ int m_marginLeft;
+ int m_marginRight;
+
+ bool m_isInWindow;
+ bool m_scrollingPerformanceLoggingEnabled;
+ bool m_unparentsOffscreenTiles;
+ bool m_acceleratesDrawing;
+ bool m_tilesAreOpaque;
+ bool m_hasTilesWithTemporaryScaleFactor; // Used to make low-res tiles when zooming.
+
+ Color m_tileDebugBorderColor;
+ float m_tileDebugBorderWidth;
+ ScrollingModeIndication m_indicatorMode;
+ float m_topContentInset;
+};
+
+} // namespace WebCore
+
+#endif // TileController_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridcppfromrev169914trunkSourceWebCoreplatformgraphicscamacTileGridcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (from rev 169914, trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.cpp) (0 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -0,0 +1,713 @@
</span><ins>+/*
+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TileGrid.h"
+
+#include "GraphicsContext.h"
+#include "LayerPool.h"
+#include "PlatformCALayer.h"
+#include "TileController.h"
+#include "WebLayer.h"
+#include <wtf/MainThread.h>
+
+#if PLATFORM(IOS)
+#include "TileControllerMemoryHandlerIOS.h"
+#endif
+
+namespace WebCore {
+
+TileGrid::TileGrid(TileController& controller)
+ : m_controller(controller)
+ , m_containerLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
+ , m_scale(1)
+ , m_cohortRemovalTimer(this, &TileGrid::cohortRemovalTimerFired)
+{
+#ifndef NDEBUG
+ m_containerLayer.get().setName("TileGrid Container Layer");
+#endif
+}
+
+TileGrid::~TileGrid()
+{
+ ASSERT(isMainThread());
+
+ for (auto& tile : m_tiles.values())
+ tile.layer->setOwner(nullptr);
+}
+
+void TileGrid::setScale(float scale)
+{
+ m_scale = scale;
+
+ TransformationMatrix transform;
+ transform.scale(1 / m_scale);
+ m_containerLayer->setTransform(transform);
+
+ // FIXME: we may revalidateTiles twice in this commit.
+ revalidateTiles(PruneSecondaryTiles);
+
+ for (auto& tile : m_tiles.values())
+ tile.layer->setContentsScale(m_controller.deviceScaleFactor());
+}
+
+void TileGrid::setNeedsDisplay()
+{
+ for (auto& entry : m_tiles) {
+ TileInfo& tileInfo = entry.value;
+ IntRect tileRect = rectForTileIndex(entry.key);
+
+ if (tileRect.intersects(m_primaryTileCoverageRect) && tileInfo.layer->superlayer())
+ tileInfo.layer->setNeedsDisplay();
+ else
+ tileInfo.hasStaleContent = true;
+ }
+}
+
+void TileGrid::setNeedsDisplayInRect(const IntRect& rect)
+{
+ if (m_tiles.isEmpty())
+ return;
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect repaintRectInTileCoords(enclosingIntRect(scaledRect));
+
+ IntSize tileSize = m_controller.tileSize();
+
+ // For small invalidations, lookup the covered tiles.
+ if (repaintRectInTileCoords.height() < 2 * tileSize.height() && repaintRectInTileCoords.width() < 2 * tileSize.width()) {
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight);
+
+ for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+ for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+ TileIndex tileIndex(x, y);
+
+ TileMap::iterator it = m_tiles.find(tileIndex);
+ if (it != m_tiles.end())
+ setTileNeedsDisplayInRect(tileIndex, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+ }
+ }
+ return;
+ }
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ setTileNeedsDisplayInRect(it->key, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+}
+
+void TileGrid::dropTilesInRect(const IntRect& rect)
+{
+ if (m_tiles.isEmpty())
+ return;
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect dropRectInTileCoords(enclosingIntRect(scaledRect));
+
+ Vector<TileIndex> tilesToRemove;
+
+ for (auto& index : m_tiles.keys()) {
+ if (rectForTileIndex(index).intersects(dropRectInTileCoords))
+ tilesToRemove.append(index);
+ }
+
+ removeTiles(tilesToRemove);
+}
+
+void TileGrid::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
+{
+ PlatformCALayer* tileLayer = tileInfo.layer.get();
+
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ FloatRect tileRepaintRect = tileRect;
+ tileRepaintRect.intersect(repaintRectInTileCoords);
+ if (tileRepaintRect.isEmpty())
+ return;
+
+ tileRepaintRect.moveBy(-tileRect.location());
+
+ // We could test for intersection with the visible rect. This would reduce painting yet more,
+ // but may make scrolling stale tiles into view more frequent.
+ if (tileRect.intersects(coverageRectInTileCoords) && tileLayer->superlayer()) {
+ tileLayer->setNeedsDisplay(&tileRepaintRect);
+
+ if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0)) {
+ FloatRect indicatorRect(0, 0, 52, 27);
+ tileLayer->setNeedsDisplay(&indicatorRect);
+ }
+ } else
+ tileInfo.hasStaleContent = true;
+}
+
+void TileGrid::updateTileLayerProperties()
+{
+ bool acceleratesDrawing = m_controller.acceleratesDrawing();
+ bool opaque = m_controller.tilesAreOpaque();
+ Color tileDebugBorderColor = m_controller.tileDebugBorderColor();
+ float tileDebugBorderWidth = m_controller.tileDebugBorderWidth();
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ tileInfo.layer->setAcceleratesDrawing(acceleratesDrawing);
+ tileInfo.layer->setOpaque(opaque);
+ tileInfo.layer->setBorderColor(tileDebugBorderColor);
+ tileInfo.layer->setBorderWidth(tileDebugBorderWidth);
+ }
+}
+
+bool TileGrid::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const
+{
+ FloatRect visibleRect = newVisibleRect;
+
+ if (visibleRect.isEmpty())
+ return false;
+
+ FloatRect currentTileCoverageRect = m_controller.computeTileCoverageRect(oldVisibleRect, newVisibleRect);
+ FloatRect scaledRect(currentTileCoverageRect);
+ scaledRect.scale(m_scale);
+ IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
+
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
+
+ IntRect coverageRect = rectForTileIndex(topLeft);
+ coverageRect.unite(rectForTileIndex(bottomRight));
+ return coverageRect != m_primaryTileCoverageRect;
+}
+
+bool TileGrid::prepopulateRect(const FloatRect& rect)
+{
+ IntRect enclosingCoverageRect = enclosingIntRect(rect);
+ if (m_primaryTileCoverageRect.contains(enclosingCoverageRect))
+ return false;
+
+ m_secondaryTileCoverageRects.append(enclosingCoverageRect);
+ return true;
+}
+
+IntRect TileGrid::rectForTileIndex(const TileIndex& tileIndex) const
+{
+ // FIXME: calculating the scaled size here should match with the rest of calculated sizes where we use the combination of
+ // enclosingIntRect, expandedIntSize (floor vs ceil).
+ // However enclosing this size could reveal gap on root layer's background. see RenderView::backgroundRect()
+ IntSize tileSize = m_controller.tileSize();
+ IntRect rect(tileIndex.x() * tileSize.width(), tileIndex.y() * tileSize.height(), tileSize.width(), tileSize.height());
+ IntRect scaledBounds(m_controller.bounds());
+ scaledBounds.scale(m_scale);
+ rect.intersect(scaledBounds);
+ return rect;
+}
+
+void TileGrid::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
+{
+ IntRect clampedRect = m_controller.bounds();
+ clampedRect.scale(m_scale);
+ clampedRect.intersect(rect);
+
+ auto tileSize = m_controller.tileSize();
+ if (clampedRect.x() >= 0)
+ topLeft.setX(clampedRect.x() / tileSize.width());
+ else
+ topLeft.setX(floorf((float)clampedRect.x() / tileSize.width()));
+
+ if (clampedRect.y() >= 0)
+ topLeft.setY(clampedRect.y() / tileSize.height());
+ else
+ topLeft.setY(floorf((float)clampedRect.y() / tileSize.height()));
+
+ int bottomXRatio = ceil((float)clampedRect.maxX() / tileSize.width());
+ bottomRight.setX(std::max(bottomXRatio - 1, 0));
+
+ int bottomYRatio = ceil((float)clampedRect.maxY() / tileSize.height());
+ bottomRight.setY(std::max(bottomYRatio - 1, 0));
+}
+
+unsigned TileGrid::blankPixelCount() const
+{
+ PlatformLayerList tiles(m_tiles.size());
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ if (PlatformLayer *layer = it->value.layer->platformLayer())
+ tiles.append(layer);
+ }
+
+ return TileController::blankPixelCountForTiles(tiles, m_controller.visibleRect(), IntPoint(0, 0));
+}
+
+void TileGrid::removeTiles(Vector<TileGrid::TileIndex>& toRemove)
+{
+ for (size_t i = 0; i < toRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(toRemove[i]);
+ tileInfo.layer->removeFromSuperlayer();
+ m_tileRepaintCounts.remove(tileInfo.layer.get());
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+ }
+}
+
+void TileGrid::removeAllSecondaryTiles()
+{
+ Vector<TileIndex> tilesToRemove;
+
+ for (auto& entry : m_tiles) {
+ const TileInfo& tileInfo = entry.value;
+ if (tileInfo.cohort == VisibleTileCohort)
+ continue;
+ tilesToRemove.append(entry.key);
+ }
+
+ removeTiles(tilesToRemove);
+}
+
+void TileGrid::removeTilesInCohort(TileCohort cohort)
+{
+ ASSERT(cohort != VisibleTileCohort);
+ Vector<TileIndex> tilesToRemove;
+
+ for (auto& entry : m_tiles) {
+ const TileInfo& tileInfo = entry.value;
+ if (tileInfo.cohort != cohort)
+ continue;
+ tilesToRemove.append(entry.key);
+ }
+
+ removeTiles(tilesToRemove);
+}
+
+void TileGrid::revalidateTiles(unsigned validationPolicy)
+{
+ FloatRect visibleRect = m_controller.visibleRect();
+ IntRect bounds = m_controller.bounds();
+
+ if (visibleRect.isEmpty() || bounds.isEmpty())
+ return;
+
+ FloatRect tileCoverageRect = m_controller.computeTileCoverageRect(m_controller.visibleRectAtLastRevalidate(), visibleRect);
+ FloatRect scaledRect(tileCoverageRect);
+ scaledRect.scale(m_scale);
+ IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
+
+ TileCohort currCohort = nextTileCohort();
+ unsigned tilesInCohort = 0;
+
+ double minimumRevalidationTimerDuration = std::numeric_limits<double>::max();
+ bool needsTileRevalidation = false;
+
+ // Move tiles newly outside the coverage rect into the cohort map.
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ TileInfo& tileInfo = it->value;
+ TileIndex tileIndex = it->key;
+
+ PlatformCALayer* tileLayer = tileInfo.layer.get();
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ if (tileRect.intersects(coverageRectInTileCoords)) {
+ tileInfo.cohort = VisibleTileCohort;
+ if (tileInfo.hasStaleContent) {
+ // FIXME: store a dirty region per layer?
+ tileLayer->setNeedsDisplay();
+ tileInfo.hasStaleContent = false;
+ }
+ } else {
+ // Add to the currentCohort if not already in one.
+ if (tileInfo.cohort == VisibleTileCohort) {
+ tileInfo.cohort = currCohort;
+ ++tilesInCohort;
+
+ if (m_controller.unparentsOffscreenTiles())
+ tileLayer->removeFromSuperlayer();
+ } else if (m_controller.unparentsOffscreenTiles() && m_controller.shouldAggressivelyRetainTiles() && tileLayer->superlayer()) {
+ // Aggressive tile retention means we'll never remove cohorts, but we need to make sure they're unparented.
+ // We can't immediately unparent cohorts comprised of secondary tiles that never touch the primary coverage rect,
+ // because that would defeat the usefulness of prepopulateRect(); instead, age prepopulated tiles out as if they were being removed.
+ for (auto& cohort : m_cohortList) {
+ if (cohort.cohort != tileInfo.cohort)
+ continue;
+ double timeUntilCohortExpires = cohort.timeUntilExpiration();
+ if (timeUntilCohortExpires > 0) {
+ minimumRevalidationTimerDuration = std::min(minimumRevalidationTimerDuration, timeUntilCohortExpires);
+ needsTileRevalidation = true;
+ } else
+ tileLayer->removeFromSuperlayer();
+ break;
+ }
+ }
+ }
+ }
+
+ if (needsTileRevalidation)
+ m_controller.scheduleTileRevalidation(minimumRevalidationTimerDuration);
+
+ if (tilesInCohort)
+ startedNewCohort(currCohort);
+
+ if (!m_controller.shouldAggressivelyRetainTiles()) {
+ if (m_controller.shouldTemporarilyRetainTileCohorts())
+ scheduleCohortRemoval();
+ else if (tilesInCohort)
+ removeTilesInCohort(currCohort);
+ }
+
+ // Ensure primary tile coverage tiles.
+ m_primaryTileCoverageRect = ensureTilesForRect(tileCoverageRect, CoverageType::PrimaryTiles);
+
+ if (validationPolicy & PruneSecondaryTiles) {
+ removeAllSecondaryTiles();
+ m_cohortList.clear();
+ } else {
+ for (auto& secondaryCoverageRect : m_secondaryTileCoverageRects) {
+ FloatRect secondaryRectInLayerCoordinates(secondaryCoverageRect);
+ secondaryRectInLayerCoordinates.scale(1 / m_scale);
+ ensureTilesForRect(secondaryRectInLayerCoordinates, CoverageType::SecondaryTiles);
+ }
+ m_secondaryTileCoverageRects.clear();
+ }
+
+ if (m_controller.unparentsOffscreenTiles() && (validationPolicy & UnparentAllTiles)) {
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ it->value.layer->removeFromSuperlayer();
+ }
+
+ auto boundsAtLastRevalidate = m_controller.boundsAtLastRevalidate();
+ if (boundsAtLastRevalidate != bounds) {
+ // If there are margin tiles and the bounds have grown taller or wider, then the tiles that used to
+ // be bottom or right margin tiles need to be invalidated.
+ if (m_controller.hasMargins()) {
+ if (bounds.width() > boundsAtLastRevalidate.width() || bounds.height() > boundsAtLastRevalidate.height()) {
+ IntRect boundsWithoutMargin = m_controller.boundsWithoutMargin();
+ IntRect oldBoundsWithoutMargin = m_controller.boundsAtLastRevalidateWithoutMargin();
+
+ if (bounds.height() > boundsAtLastRevalidate.height()) {
+ IntRect formerBottomMarginRect = IntRect(oldBoundsWithoutMargin.x(), oldBoundsWithoutMargin.height(),
+ oldBoundsWithoutMargin.width(), boundsWithoutMargin.height() - oldBoundsWithoutMargin.height());
+ setNeedsDisplayInRect(formerBottomMarginRect);
+ }
+
+ if (bounds.width() > boundsAtLastRevalidate.width()) {
+ IntRect formerRightMarginRect = IntRect(oldBoundsWithoutMargin.width(), oldBoundsWithoutMargin.y(),
+ boundsWithoutMargin.width() - oldBoundsWithoutMargin.width(), oldBoundsWithoutMargin.height());
+ setNeedsDisplayInRect(formerRightMarginRect);
+ }
+ }
+ }
+
+ FloatRect scaledBounds(bounds);
+ scaledBounds.scale(m_scale);
+ IntRect boundsInTileCoords(enclosingIntRect(scaledBounds));
+
+ TileIndex topLeftForBounds;
+ TileIndex bottomRightForBounds;
+ getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
+
+ Vector<TileIndex> tilesToRemove;
+ for (auto& index : m_tiles.keys()) {
+ if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x())
+ tilesToRemove.append(index);
+ }
+ removeTiles(tilesToRemove);
+ }
+
+ m_controller.didRevalidateTiles();
+}
+
+TileGrid::TileCohort TileGrid::nextTileCohort() const
+{
+ if (!m_cohortList.isEmpty())
+ return m_cohortList.last().cohort + 1;
+
+ return 1;
+}
+
+void TileGrid::startedNewCohort(TileCohort cohort)
+{
+ m_cohortList.append(TileCohortInfo(cohort, monotonicallyIncreasingTime()));
+#if PLATFORM(IOS)
+ if (!m_controller.isInWindow())
+ tileControllerMemoryHandler().tileControllerGainedUnparentedTiles(&m_controller);
+#endif
+}
+
+TileGrid::TileCohort TileGrid::newestTileCohort() const
+{
+ return m_cohortList.isEmpty() ? 0 : m_cohortList.last().cohort;
+}
+
+TileGrid::TileCohort TileGrid::oldestTileCohort() const
+{
+ return m_cohortList.isEmpty() ? 0 : m_cohortList.first().cohort;
+}
+
+void TileGrid::scheduleCohortRemoval()
+{
+ const double cohortRemovalTimerSeconds = 1;
+
+ // Start the timer, or reschedule the timer from now if it's already active.
+ if (!m_cohortRemovalTimer.isActive())
+ m_cohortRemovalTimer.startRepeating(cohortRemovalTimerSeconds);
+}
+
+double TileGrid::TileCohortInfo::timeUntilExpiration()
+{
+ double cohortLifeTimeSeconds = 2;
+ double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
+ return creationTime - timeThreshold;
+}
+
+void TileGrid::cohortRemovalTimerFired(Timer<TileGrid>*)
+{
+ if (m_cohortList.isEmpty()) {
+ m_cohortRemovalTimer.stop();
+ return;
+ }
+
+ while (!m_cohortList.isEmpty() && m_cohortList.first().timeUntilExpiration() < 0) {
+ TileCohortInfo firstCohort = m_cohortList.takeFirst();
+ removeTilesInCohort(firstCohort.cohort);
+ }
+
+ m_controller.updateTileCoverageMap();
+}
+
+IntRect TileGrid::ensureTilesForRect(const FloatRect& rect, CoverageType newTileType)
+{
+ if (m_controller.unparentsOffscreenTiles() && !m_controller.isInWindow())
+ return IntRect();
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect rectInTileCoords(enclosingIntRect(scaledRect));
+
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
+
+ TileCohort currCohort = nextTileCohort();
+ unsigned tilesInCohort = 0;
+
+ IntRect coverageRect;
+
+ for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+ for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+ TileIndex tileIndex(x, y);
+
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
+
+ coverageRect.unite(tileRect);
+
+ bool shouldChangeTileLayerFrame = false;
+
+ if (!tileInfo.layer) {
+ tileInfo.layer = m_controller.createTileLayer(tileRect, *this);
+ ASSERT(!m_tileRepaintCounts.contains(tileInfo.layer.get()));
+ } else {
+ // We already have a layer for this tile. Ensure that its size is correct.
+ FloatSize tileLayerSize(tileInfo.layer->bounds().size());
+ shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
+
+ if (shouldChangeTileLayerFrame) {
+ tileInfo.layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
+ tileInfo.layer->setPosition(tileRect.location());
+ tileInfo.layer->setNeedsDisplay();
+ }
+ }
+
+ if (newTileType == CoverageType::SecondaryTiles && !tileRect.intersects(m_primaryTileCoverageRect)) {
+ tileInfo.cohort = currCohort;
+ ++tilesInCohort;
+ }
+
+ bool shouldParentTileLayer = (!m_controller.unparentsOffscreenTiles() || m_controller.isInWindow()) && !tileInfo.layer->superlayer();
+
+ if (shouldParentTileLayer)
+ m_containerLayer.get().appendSublayer(tileInfo.layer.get());
+ }
+ }
+
+ if (tilesInCohort)
+ startedNewCohort(currCohort);
+
+ return coverageRect;
+}
+
+IntRect TileGrid::extent() const
+{
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight);
+
+ // Return index of top, left tile and the number of tiles across and down.
+ return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
+}
+
+double TileGrid::retainedTileBackingStoreMemory() const
+{
+ double totalBytes = 0;
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if (tileInfo.layer->superlayer()) {
+ FloatRect bounds = tileInfo.layer->bounds();
+ double contentsScale = tileInfo.layer->contentsScale();
+ totalBytes += 4 * bounds.width() * contentsScale * bounds.height() * contentsScale;
+ }
+ }
+
+ return totalBytes;
+}
+
+// Return the rect in layer coords, not tile coords.
+IntRect TileGrid::tileCoverageRect() const
+{
+ IntRect coverageRectInLayerCoords(m_primaryTileCoverageRect);
+ coverageRectInLayerCoords.scale(1 / m_scale);
+ return coverageRectInLayerCoords;
+}
+
+void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const
+{
+ CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
+ CGContextFillRect(context, layerBounds);
+
+ CGFloat scaleFactor = layerBounds.size.width / m_controller.bounds().width();
+
+ CGFloat contextScale = scaleFactor / m_scale;
+ CGContextScaleCTM(context, contextScale, contextScale);
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ PlatformCALayer* tileLayer = tileInfo.layer.get();
+
+ CGFloat red = 1;
+ CGFloat green = 1;
+ CGFloat blue = 1;
+ CGFloat alpha = 1;
+ if (tileInfo.hasStaleContent) {
+ red = 0.25;
+ green = 0.125;
+ blue = 0;
+ } else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) {
+ red = 0.8;
+ green = 0.8;
+ blue = 0.8;
+ }
+
+ TileCohort newestCohort = newestTileCohort();
+ TileCohort oldestCohort = oldestTileCohort();
+
+ if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort)
+ alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort));
+
+ CGContextSetRGBFillColor(context, red, green, blue, alpha);
+
+ if (tileLayer->superlayer()) {
+ CGContextSetLineWidth(context, 0.5 / contextScale);
+ CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
+ } else {
+ CGContextSetLineWidth(context, 1 / contextScale);
+ CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);
+ }
+
+ CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height());
+ CGContextFillRect(context, frame);
+ CGContextStrokeRect(context, frame);
+ }
+}
+
+void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)
+{
+#if PLATFORM(IOS)
+ if (pthread_main_np())
+ WebThreadLock();
+#endif
+
+ {
+ GraphicsContextStateSaver stateSaver(context);
+
+ FloatPoint3D layerOrigin = platformCALayer->position();
+ context.translate(-layerOrigin.x(), -layerOrigin.y());
+ context.scale(FloatSize(m_scale, m_scale));
+
+ RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
+ drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
+ }
+
+ int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
+ if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0))
+ drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
+
+ if (m_controller.scrollingPerformanceLoggingEnabled()) {
+ FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
+ visiblePart.intersect(m_controller.visibleRect());
+
+ if (repaintCount == 1 && !visiblePart.isEmpty())
+ WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());
+ }
+}
+
+float TileGrid::platformCALayerDeviceScaleFactor() const
+{
+ return m_controller.rootLayer().owner()->platformCALayerDeviceScaleFactor();
+}
+
+bool TileGrid::platformCALayerShowDebugBorders() const
+{
+ return m_controller.rootLayer().owner()->platformCALayerShowDebugBorders();
+}
+
+bool TileGrid::platformCALayerShowRepaintCounter(PlatformCALayer*) const
+{
+ return m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0);
+}
+
+bool TileGrid::platformCALayerContentsOpaque() const
+{
+ return m_controller.tilesAreOpaque();
+}
+
+int TileGrid::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
+{
+ int repaintCount = 0;
+
+ if (m_tileRepaintCounts.contains(platformCALayer))
+ repaintCount = m_tileRepaintCounts.get(platformCALayer);
+
+ m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
+
+ return repaintCount;
+}
+
+#if PLATFORM(IOS)
+void TileGrid::removeUnparentedTilesNow()
+{
+ while (!m_cohortList.isEmpty()) {
+ TileCohortInfo firstCohort = m_cohortList.takeFirst();
+ removeTilesInCohort(firstCohort.cohort);
+ }
+}
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridhfromrev169914trunkSourceWebCoreplatformgraphicscamacTileGridh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/ca/TileGrid.h (from rev 169914, trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h) (0 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.h        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -0,0 +1,164 @@
</span><ins>+/*
+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TileGrid_h
+#define TileGrid_h
+
+#include "IntPointHash.h"
+#include "IntRect.h"
+#include "PlatformCALayerClient.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Ref.h>
+
+#if PLATFORM(COCOA)
+typedef struct CGContext *CGContextRef;
+#endif
+
+namespace WebCore {
+
+class GraphicsContext;
+class PlatformCALayer;
+class TileController;
+
+class TileGrid : public PlatformCALayerClient {
+ WTF_MAKE_NONCOPYABLE(TileGrid); WTF_MAKE_FAST_ALLOCATED;
+public:
+ TileGrid(TileController&);
+ ~TileGrid();
+
+ PlatformCALayer& containerLayer() { return m_containerLayer.get(); }
+
+ void setScale(float);
+ float scale() const { return m_scale; }
+
+ void setNeedsDisplay();
+ void setNeedsDisplayInRect(const IntRect&);
+ void dropTilesInRect(const IntRect&);
+
+ void updateTileLayerProperties();
+
+ bool prepopulateRect(const FloatRect&);
+
+ enum TileValidationPolicyFlag {
+ PruneSecondaryTiles = 1 << 0,
+ UnparentAllTiles = 1 << 1
+ };
+ void revalidateTiles(unsigned validationPolicyFlags);
+ bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
+
+ IntRect tileCoverageRect() const;
+ IntRect extent() const;
+
+ double retainedTileBackingStoreMemory() const;
+ unsigned blankPixelCount() const;
+
+ void drawTileMapContents(CGContextRef, CGRect layerBounds) const;
+
+#if PLATFORM(IOS)
+ unsigned numberOfUnparentedTiles() const { return m_cohortList.size(); }
+ void removeUnparentedTilesNow();
+#endif
+
+ typedef IntPoint TileIndex;
+ typedef unsigned TileCohort;
+ static const TileCohort VisibleTileCohort = UINT_MAX;
+
+ struct TileInfo {
+ RefPtr<PlatformCALayer> layer;
+ TileCohort cohort; // VisibleTileCohort is visible.
+ bool hasStaleContent;
+
+ TileInfo()
+ : cohort(VisibleTileCohort)
+ , hasStaleContent(false)
+ { }
+ };
+
+private:
+ void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
+
+ IntRect rectForTileIndex(const TileIndex&) const;
+ void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
+
+ enum class CoverageType { PrimaryTiles, SecondaryTiles };
+ IntRect ensureTilesForRect(const FloatRect&, CoverageType);
+
+ struct TileCohortInfo {
+ TileCohort cohort;
+ double creationTime; // in monotonicallyIncreasingTime().
+ TileCohortInfo(TileCohort inCohort, double inTime)
+ : cohort(inCohort)
+ , creationTime(inTime)
+ { }
+
+ double timeUntilExpiration();
+ };
+
+ void removeAllSecondaryTiles();
+ void removeTilesInCohort(TileCohort);
+
+ void scheduleCohortRemoval();
+ void cohortRemovalTimerFired(Timer<TileGrid>*);
+ TileCohort nextTileCohort() const;
+ void startedNewCohort(TileCohort);
+ TileCohort newestTileCohort() const;
+ TileCohort oldestTileCohort() const;
+
+ void removeTiles(Vector<TileGrid::TileIndex>& toRemove);
+
+ // PlatformCALayerClient
+ virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;
+ virtual bool platformCALayerShowDebugBorders() const override;
+ virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
+ virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
+ virtual bool platformCALayerContentsOpaque() const override;
+ virtual bool platformCALayerDrawsContent() const override { return true; }
+ virtual float platformCALayerDeviceScaleFactor() const override;
+
+ TileController& m_controller;
+ Ref<PlatformCALayer> m_containerLayer;
+
+ typedef HashMap<TileIndex, TileInfo> TileMap;
+ TileMap m_tiles;
+
+ IntRect m_primaryTileCoverageRect;
+ Vector<FloatRect> m_secondaryTileCoverageRects;
+
+ float m_scale;
+
+ typedef Deque<TileCohortInfo> TileCohortList;
+ TileCohortList m_cohortList;
+
+ Timer<TileGrid> m_cohortRemovalTimer;
+
+ typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
+ RepaintCountMap m_tileRepaintCounts;
+};
+
+}
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileControllercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.cpp (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.cpp        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.cpp        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -1,551 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TileController.h"
-
-#include "IntRect.h"
-#include "LayerPool.h"
-#include "PlatformCALayer.h"
-#include "Region.h"
-#include "TileCoverageMap.h"
-#include "TileGrid.h"
-#include "WebLayer.h"
-#include <utility>
-#include <wtf/MainThread.h>
-
-#if PLATFORM(IOS)
-#include "TileControllerMemoryHandlerIOS.h"
-#endif
-
-namespace WebCore {
-
-PassOwnPtr<TileController> TileController::create(PlatformCALayer* rootPlatformLayer)
-{
- return adoptPtr(new TileController(rootPlatformLayer));
-}
-
-TileController::TileController(PlatformCALayer* rootPlatformLayer)
- : m_tileCacheLayer(rootPlatformLayer)
- , m_tileGrid(std::make_unique<TileGrid>(*this))
- , m_tileSize(defaultTileWidth, defaultTileHeight)
- , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
- , m_zoomedOutContentsScale(0)
- , m_deviceScaleFactor(owningGraphicsLayer()->platformCALayerDeviceScaleFactor())
- , m_tileCoverage(CoverageForVisibleArea)
- , m_marginTop(0)
- , m_marginBottom(0)
- , m_marginLeft(0)
- , m_marginRight(0)
- , m_isInWindow(false)
- , m_scrollingPerformanceLoggingEnabled(false)
- , m_unparentsOffscreenTiles(false)
- , m_acceleratesDrawing(false)
- , m_tilesAreOpaque(false)
- , m_hasTilesWithTemporaryScaleFactor(false)
- , m_tileDebugBorderWidth(0)
- , m_indicatorMode(AsyncScrollingIndication)
- , m_topContentInset(0)
-{
-}
-
-TileController::~TileController()
-{
- ASSERT(isMainThread());
-
-#if PLATFORM(IOS)
- tileControllerMemoryHandler().removeTileController(this);
-#endif
-}
-
-void TileController::tileCacheLayerBoundsChanged()
-{
- ASSERT(owningGraphicsLayer()->isCommittingChanges());
- setNeedsRevalidateTiles();
-}
-
-void TileController::setNeedsDisplay()
-{
- tileGrid().setNeedsDisplay();
- m_zoomedOutTileGrid = nullptr;
-}
-
-void TileController::setNeedsDisplayInRect(const IntRect& rect)
-{
- tileGrid().setNeedsDisplayInRect(rect);
- if (m_zoomedOutTileGrid)
- m_zoomedOutTileGrid->dropTilesInRect(rect);
-}
-
-void TileController::setContentsScale(float scale)
-{
- ASSERT(owningGraphicsLayer()->isCommittingChanges());
-
- float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
- // The scale we get is the product of the page scale factor and device scale factor.
- // Divide by the device scale factor so we'll get the page scale factor.
- scale /= deviceScaleFactor;
-
- if (tileGrid().scale() == scale && m_deviceScaleFactor == deviceScaleFactor && !m_hasTilesWithTemporaryScaleFactor)
- return;
-
- m_hasTilesWithTemporaryScaleFactor = false;
- m_deviceScaleFactor = deviceScaleFactor;
-
- if (m_coverageMap)
- m_coverageMap->setDeviceScaleFactor(deviceScaleFactor);
-
- if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
- m_tileGrid = std::move(m_zoomedOutTileGrid);
- m_tileGrid->revalidateTiles(0);
- return;
- }
-
- if (m_zoomedOutContentsScale && m_zoomedOutContentsScale == tileGrid().scale() && tileGrid().scale() != scale && !m_hasTilesWithTemporaryScaleFactor) {
- m_zoomedOutTileGrid = std::move(m_tileGrid);
- m_tileGrid = std::make_unique<TileGrid>(*this);
- }
-
- tileGrid().setScale(scale);
- tileGrid().setNeedsDisplay();
-}
-
-float TileController::contentsScale() const
-{
- return tileGrid().scale() * m_deviceScaleFactor;
-}
-
-float TileController::zoomedOutContentsScale() const
-{
- return m_zoomedOutContentsScale * m_deviceScaleFactor;
-}
-
-void TileController::setZoomedOutContentsScale(float scale)
-{
- ASSERT(owningGraphicsLayer()->isCommittingChanges());
-
- float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
- scale /= deviceScaleFactor;
-
- if (m_zoomedOutContentsScale == scale)
- return;
- m_zoomedOutContentsScale = scale;
-
- if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() != m_zoomedOutContentsScale)
- m_zoomedOutTileGrid = nullptr;
-}
-
-void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
-{
- if (m_acceleratesDrawing == acceleratesDrawing)
- return;
- m_acceleratesDrawing = acceleratesDrawing;
-
- tileGrid().updateTileLayerProperties();
-}
-
-void TileController::setTilesOpaque(bool opaque)
-{
- if (opaque == m_tilesAreOpaque)
- return;
- m_tilesAreOpaque = opaque;
-
- tileGrid().updateTileLayerProperties();
-}
-
-void TileController::setVisibleRect(const FloatRect& visibleRect)
-{
- ASSERT(owningGraphicsLayer()->isCommittingChanges());
- if (m_visibleRect == visibleRect)
- return;
-
- m_visibleRect = visibleRect;
- setNeedsRevalidateTiles();
-}
-
-bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
-{
- if (bounds().isEmpty())
- return false;
- return tileGrid().tilesWouldChangeForVisibleRect(newVisibleRect, m_visibleRect);
-}
-
-void TileController::setTopContentInset(float topContentInset)
-{
- m_topContentInset = topContentInset;
- setTiledScrollingIndicatorPosition(FloatPoint(0, m_topContentInset));
-}
-
-void TileController::setTiledScrollingIndicatorPosition(const FloatPoint& position)
-{
- if (!m_coverageMap)
- return;
- m_coverageMap->setPosition(position);
- m_coverageMap->update();
-}
-
-void TileController::prepopulateRect(const FloatRect& rect)
-{
- if (tileGrid().prepopulateRect(rect))
- setNeedsRevalidateTiles();
-}
-
-void TileController::setIsInWindow(bool isInWindow)
-{
- if (m_isInWindow == isInWindow)
- return;
-
- m_isInWindow = isInWindow;
-
- if (m_isInWindow)
- setNeedsRevalidateTiles();
- else {
- const double tileRevalidationTimeout = 4;
- scheduleTileRevalidation(tileRevalidationTimeout);
- }
-}
-
-void TileController::setTileCoverage(TileCoverage coverage)
-{
- if (coverage == m_tileCoverage)
- return;
-
- m_tileCoverage = coverage;
- setNeedsRevalidateTiles();
-}
-
-void TileController::revalidateTiles()
-{
- ASSERT(owningGraphicsLayer()->isCommittingChanges());
- tileGrid().revalidateTiles(0);
- m_visibleRectAtLastRevalidate = m_visibleRect;
-}
-
-void TileController::forceRepaint()
-{
- setNeedsDisplay();
-}
-
-void TileController::setTileDebugBorderWidth(float borderWidth)
-{
- if (m_tileDebugBorderWidth == borderWidth)
- return;
- m_tileDebugBorderWidth = borderWidth;
-
- tileGrid().updateTileLayerProperties();
-}
-
-void TileController::setTileDebugBorderColor(Color borderColor)
-{
- if (m_tileDebugBorderColor == borderColor)
- return;
- m_tileDebugBorderColor = borderColor;
-
- tileGrid().updateTileLayerProperties();
-}
-
-IntRect TileController::bounds() const
-{
- IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
- IntSize boundsSizeIncludingMargin = expandedIntSize(m_tileCacheLayer->bounds().size());
- boundsSizeIncludingMargin.expand(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight());
-
- return IntRect(boundsOriginIncludingMargin, boundsSizeIncludingMargin);
-}
-
-IntRect TileController::boundsWithoutMargin() const
-{
- return IntRect(IntPoint(), expandedIntSize(m_tileCacheLayer->bounds().size()));
-}
-
-IntRect TileController::boundsAtLastRevalidateWithoutMargin() const
-{
- IntRect boundsWithoutMargin = IntRect(IntPoint(), m_boundsAtLastRevalidate.size());
- boundsWithoutMargin.contract(IntSize(leftMarginWidth() + rightMarginWidth(), topMarginHeight() + bottomMarginHeight()));
- return boundsWithoutMargin;
-}
-
-FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
-{
- // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
- if (!m_isInWindow)
- return visibleRect;
-
- // FIXME: look at how far the document can scroll in each dimension.
- float coverageHorizontalSize = visibleRect.width();
- float coverageVerticalSize = visibleRect.height();
-
-#if PLATFORM(IOS)
- UNUSED_PARAM(previousVisibleRect);
- return visibleRect;
-#else
- bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
-
- // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
- // These values were chosen because it's more common to have tall pages and to scroll vertically,
- // so we keep more tiles above and below the current area.
-
- if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange)
- coverageHorizontalSize *= 2;
-
- if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
- coverageVerticalSize *= 3;
-#endif
- coverageVerticalSize += topMarginHeight() + bottomMarginHeight();
- coverageHorizontalSize += leftMarginWidth() + rightMarginWidth();
-
- FloatRect coverageBounds = bounds();
- float coverageLeft = visibleRect.x() - (coverageHorizontalSize - visibleRect.width()) / 2;
- coverageLeft = std::min(coverageLeft, coverageBounds.maxX() - coverageHorizontalSize);
- coverageLeft = std::max(coverageLeft, coverageBounds.x());
-
- float coverageTop = visibleRect.y() - (coverageVerticalSize - visibleRect.height()) / 2;
- coverageTop = std::min(coverageTop, coverageBounds.maxY() - coverageVerticalSize);
- coverageTop = std::max(coverageTop, coverageBounds.y());
-
- return FloatRect(coverageLeft, coverageTop, coverageHorizontalSize, coverageVerticalSize);
-}
-
-void TileController::scheduleTileRevalidation(double interval)
-{
- if (m_tileRevalidationTimer.isActive() && m_tileRevalidationTimer.nextFireInterval() < interval)
- return;
-
- m_tileRevalidationTimer.startOneShot(interval);
-}
-
-bool TileController::shouldAggressivelyRetainTiles() const
-{
- return owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer);
-}
-
-bool TileController::shouldTemporarilyRetainTileCohorts() const
-{
- return owningGraphicsLayer()->platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer);
-}
-
-void TileController::tileRevalidationTimerFired(Timer<TileController>*)
-{
- if (!owningGraphicsLayer())
- return;
-
- if (m_isInWindow) {
- setNeedsRevalidateTiles();
- return;
- }
- // If we are not visible get rid of the zoomed-out tiles.
- m_zoomedOutTileGrid = nullptr;
-
- unsigned validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : TileGrid::PruneSecondaryTiles) | TileGrid::UnparentAllTiles;
-
- tileGrid().revalidateTiles(validationPolicy);
-}
-
-void TileController::didRevalidateTiles()
-{
- m_visibleRectAtLastRevalidate = visibleRect();
- m_boundsAtLastRevalidate = bounds();
-
- updateTileCoverageMap();
-}
-
-unsigned TileController::blankPixelCount() const
-{
- return tileGrid().blankPixelCount();
-}
-
-unsigned TileController::blankPixelCountForTiles(const PlatformLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
-{
- Region paintedVisibleTiles;
-
- for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
- const PlatformLayer* tileLayer = it->get();
-
- FloatRect visiblePart(CGRectOffset(frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
- visiblePart.intersect(visibleRect);
-
- if (!visiblePart.isEmpty())
- paintedVisibleTiles.unite(enclosingIntRect(visiblePart));
- }
-
- Region uncoveredRegion(enclosingIntRect(visibleRect));
- uncoveredRegion.subtract(paintedVisibleTiles);
-
- return uncoveredRegion.totalArea();
-}
-
-void TileController::setNeedsRevalidateTiles()
-{
- owningGraphicsLayer()->platformCALayerSetNeedsToRevalidateTiles();
-}
-
-void TileController::updateTileCoverageMap()
-{
- if (m_coverageMap)
- m_coverageMap->update();
-}
-
-IntRect TileController::tileGridExtent() const
-{
- return tileGrid().extent();
-}
-
-double TileController::retainedTileBackingStoreMemory() const
-{
- double bytes = tileGrid().retainedTileBackingStoreMemory();
- if (m_zoomedOutTileGrid)
- bytes += m_zoomedOutTileGrid->retainedTileBackingStoreMemory();
- return bytes;
-}
-
-// Return the rect in layer coords, not tile coords.
-IntRect TileController::tileCoverageRect() const
-{
- return tileGrid().tileCoverageRect();
-}
-
-PlatformCALayer* TileController::tiledScrollingIndicatorLayer()
-{
- if (!m_coverageMap)
- m_coverageMap = std::make_unique<TileCoverageMap>(*this);
-
- return &m_coverageMap->layer();
-}
-
-void TileController::setScrollingModeIndication(ScrollingModeIndication scrollingMode)
-{
- if (scrollingMode == m_indicatorMode)
- return;
-
- m_indicatorMode = scrollingMode;
-
- updateTileCoverageMap();
-}
-
-void TileController::setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight)
-{
- m_marginTop = marginTop;
- m_marginBottom = marginBottom;
- m_marginLeft = marginLeft;
- m_marginRight = marginRight;
-
- setNeedsRevalidateTiles();
-}
-
-bool TileController::hasMargins() const
-{
- return m_marginTop || m_marginBottom || m_marginLeft || m_marginRight;
-}
-
-bool TileController::hasHorizontalMargins() const
-{
- return m_marginLeft || m_marginRight;
-}
-
-bool TileController::hasVerticalMargins() const
-{
- return m_marginTop || m_marginBottom;
-}
-
-int TileController::topMarginHeight() const
-{
- return m_marginTop / tileGrid().scale();
-}
-
-int TileController::bottomMarginHeight() const
-{
- return m_marginBottom / tileGrid().scale();
-}
-
-int TileController::leftMarginWidth() const
-{
- return m_marginLeft / tileGrid().scale();
-}
-
-int TileController::rightMarginWidth() const
-{
- return m_marginRight / tileGrid().scale();
-}
-
-RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect, TileGrid& grid)
-{
- RefPtr<PlatformCALayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
-
- if (layer)
- layer->setOwner(&grid);
- else
- layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, &grid);
-
- layer->setAnchorPoint(FloatPoint3D());
- layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
- layer->setPosition(tileRect.location());
- layer->setBorderColor(m_tileDebugBorderColor);
- layer->setBorderWidth(m_tileDebugBorderWidth);
- layer->setEdgeAntialiasingMask(0);
- layer->setOpaque(m_tilesAreOpaque);
-#ifndef NDEBUG
- layer->setName("Tile");
-#endif
-
- float temporaryScaleFactor = owningGraphicsLayer()->platformCALayerContentsScaleMultiplierForNewTiles(m_tileCacheLayer);
- m_hasTilesWithTemporaryScaleFactor |= temporaryScaleFactor != 1;
-
- layer->setContentsScale(m_deviceScaleFactor * temporaryScaleFactor);
- layer->setAcceleratesDrawing(m_acceleratesDrawing);
-
- layer->setNeedsDisplay();
-
- return layer;
-}
-
-Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
-{
- Vector<RefPtr<PlatformCALayer>> layerList;
- if (m_zoomedOutTileGrid)
- layerList.append(&m_zoomedOutTileGrid->containerLayer());
- layerList.append(&tileGrid().containerLayer());
- return layerList;
-}
-
-#if PLATFORM(IOS)
-unsigned TileController::numberOfUnparentedTiles() const
-{
- unsigned count = tileGrid().numberOfUnparentedTiles();
- if (m_zoomedOutTileGrid)
- count += m_zoomedOutTileGrid->numberOfUnparentedTiles();
- return count;
-}
-
-void TileController::removeUnparentedTilesNow()
-{
- tileGrid().removeUnparentedTilesNow();
- if (m_zoomedOutTileGrid)
- m_zoomedOutTileGrid->removeUnparentedTilesNow();
-
- updateTileCoverageMap();
-}
-#endif
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileControllerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -1,209 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TileController_h
-#define TileController_h
-
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "PlatformCALayer.h"
-#include "PlatformCALayerClient.h"
-#include "TiledBacking.h"
-#include "Timer.h"
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-class FloatRect;
-class IntPoint;
-class IntRect;
-class TileCoverageMap;
-class TileGrid;
-
-typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
-
-class TileController final : public TiledBacking {
- WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED;
- friend class TileCoverageMap;
- friend class TileGrid;
-public:
- static PassOwnPtr<TileController> create(PlatformCALayer*);
- ~TileController();
-
- void tileCacheLayerBoundsChanged();
-
- void setNeedsDisplay();
- void setNeedsDisplayInRect(const IntRect&);
-
- void setContentsScale(float);
- float contentsScale() const;
-
- bool acceleratesDrawing() const { return m_acceleratesDrawing; }
- void setAcceleratesDrawing(bool);
-
- void setTilesOpaque(bool);
- bool tilesAreOpaque() const { return m_tilesAreOpaque; }
-
- PlatformCALayer& rootLayer() { return *m_tileCacheLayer; }
- const PlatformCALayer& rootLayer() const { return *m_tileCacheLayer; }
-
- void setTileDebugBorderWidth(float);
- void setTileDebugBorderColor(Color);
-
- virtual FloatRect visibleRect() const override { return m_visibleRect; }
-
- unsigned blankPixelCount() const;
- static unsigned blankPixelCountForTiles(const PlatformLayerList&, const FloatRect&, const IntPoint&);
-
-#if PLATFORM(IOS)
- unsigned numberOfUnparentedTiles() const;
- void removeUnparentedTilesNow();
-#endif
-
- float deviceScaleFactor() const { return m_deviceScaleFactor; }
-
- Color tileDebugBorderColor() const { return m_tileDebugBorderColor; }
- float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
- ScrollingModeIndication indicatorMode() const { return m_indicatorMode; }
-
- virtual IntSize tileSize() const override { return m_tileSize; }
- virtual IntRect bounds() const override;
- virtual IntRect boundsWithoutMargin() const override;
- virtual bool hasMargins() const override;
- virtual bool hasHorizontalMargins() const override;
- virtual bool hasVerticalMargins() const override;
- virtual int topMarginHeight() const override;
- virtual int bottomMarginHeight() const override;
- virtual int leftMarginWidth() const override;
- virtual int rightMarginWidth() const override;
- virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
- virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
- virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
-
- FloatRect computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const;
-
- IntRect boundsAtLastRevalidate() const { return m_boundsAtLastRevalidate; }
- IntRect boundsAtLastRevalidateWithoutMargin() const;
- FloatRect visibleRectAtLastRevalidate() const { return m_visibleRectAtLastRevalidate; }
- void didRevalidateTiles();
-
- bool shouldAggressivelyRetainTiles() const;
- bool shouldTemporarilyRetainTileCohorts() const;
-
- void updateTileCoverageMap();
-
- RefPtr<PlatformCALayer> createTileLayer(const IntRect&, TileGrid&);
-
- const TileGrid& tileGrid() const { return *m_tileGrid; }
-
- Vector<RefPtr<PlatformCALayer>> containerLayers();
-
-protected:
- void scheduleTileRevalidation(double interval);
-
- bool isInWindow() const { return m_isInWindow; }
- float topContentInset() const { return m_topContentInset; }
-
-private:
- TileController(PlatformCALayer*);
-
- TileGrid& tileGrid() { return *m_tileGrid; }
-
- // TiledBacking member functions.
- virtual void setVisibleRect(const FloatRect&) override;
- virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const override;
- virtual void setTiledScrollingIndicatorPosition(const FloatPoint&) override;
- virtual void setTopContentInset(float) override;
- virtual void prepopulateRect(const FloatRect&) override;
- virtual void setIsInWindow(bool) override;
- virtual void setTileCoverage(TileCoverage) override;
- virtual void revalidateTiles() override;
- virtual void forceRepaint() override;
- virtual IntRect tileGridExtent() const override;
- virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
- virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; }
- virtual double retainedTileBackingStoreMemory() const override;
- virtual IntRect tileCoverageRect() const override;
- virtual PlatformCALayer* tiledScrollingIndicatorLayer() override;
- virtual void setScrollingModeIndication(ScrollingModeIndication) override;
- virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
- virtual void setZoomedOutContentsScale(float) override;
- virtual float zoomedOutContentsScale() const override;
-
-
- void tileRevalidationTimerFired(Timer<TileController>*);
-
- void setNeedsRevalidateTiles();
-
- PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
-
- PlatformCALayer* m_tileCacheLayer;
-
- std::unique_ptr<TileCoverageMap> m_coverageMap;
-
- std::unique_ptr<TileGrid> m_tileGrid;
- std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
-
- IntSize m_tileSize;
- FloatRect m_visibleRect;
- FloatRect m_visibleRectAtLastRevalidate;
- IntRect m_boundsAtLastRevalidate;
-
- Timer<TileController> m_tileRevalidationTimer;
-
- float m_zoomedOutContentsScale;
- float m_deviceScaleFactor;
-
- TileCoverage m_tileCoverage;
-
- // m_marginTop and m_marginBottom are the height in pixels of the top and bottom margin tiles. The width
- // of those tiles will be equivalent to the width of the other tiles in the grid. m_marginRight and
- // m_marginLeft are the width in pixels of the right and left margin tiles, respectively. The height of
- // those tiles will be equivalent to the height of the other tiles in the grid.
- int m_marginTop;
- int m_marginBottom;
- int m_marginLeft;
- int m_marginRight;
-
- bool m_isInWindow;
- bool m_scrollingPerformanceLoggingEnabled;
- bool m_unparentsOffscreenTiles;
- bool m_acceleratesDrawing;
- bool m_tilesAreOpaque;
- bool m_hasTilesWithTemporaryScaleFactor; // Used to make low-res tiles when zooming.
-
- Color m_tileDebugBorderColor;
- float m_tileDebugBorderWidth;
- ScrollingModeIndication m_indicatorMode;
- float m_topContentInset;
-};
-
-} // namespace WebCore
-
-#endif // TileController_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileGridcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.cpp (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.cpp        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.cpp        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -1,713 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TileGrid.h"
-
-#include "GraphicsContext.h"
-#include "LayerPool.h"
-#include "PlatformCALayer.h"
-#include "TileController.h"
-#include "WebLayer.h"
-#include <wtf/MainThread.h>
-
-#if PLATFORM(IOS)
-#include "TileControllerMemoryHandlerIOS.h"
-#endif
-
-namespace WebCore {
-
-TileGrid::TileGrid(TileController& controller)
- : m_controller(controller)
- , m_containerLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
- , m_scale(1)
- , m_cohortRemovalTimer(this, &TileGrid::cohortRemovalTimerFired)
-{
-#ifndef NDEBUG
- m_containerLayer.get().setName("TileGrid Container Layer");
-#endif
-}
-
-TileGrid::~TileGrid()
-{
- ASSERT(isMainThread());
-
- for (auto& tile : m_tiles.values())
- tile.layer->setOwner(nullptr);
-}
-
-void TileGrid::setScale(float scale)
-{
- m_scale = scale;
-
- TransformationMatrix transform;
- transform.scale(1 / m_scale);
- m_containerLayer->setTransform(transform);
-
- // FIXME: we may revalidateTiles twice in this commit.
- revalidateTiles(PruneSecondaryTiles);
-
- for (auto& tile : m_tiles.values())
- tile.layer->setContentsScale(m_controller.deviceScaleFactor());
-}
-
-void TileGrid::setNeedsDisplay()
-{
- for (auto& entry : m_tiles) {
- TileInfo& tileInfo = entry.value;
- IntRect tileRect = rectForTileIndex(entry.key);
-
- if (tileRect.intersects(m_primaryTileCoverageRect) && tileInfo.layer->superlayer())
- tileInfo.layer->setNeedsDisplay();
- else
- tileInfo.hasStaleContent = true;
- }
-}
-
-void TileGrid::setNeedsDisplayInRect(const IntRect& rect)
-{
- if (m_tiles.isEmpty())
- return;
-
- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
- IntRect repaintRectInTileCoords(enclosingIntRect(scaledRect));
-
- IntSize tileSize = m_controller.tileSize();
-
- // For small invalidations, lookup the covered tiles.
- if (repaintRectInTileCoords.height() < 2 * tileSize.height() && repaintRectInTileCoords.width() < 2 * tileSize.width()) {
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight);
-
- for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
- for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
- TileIndex tileIndex(x, y);
-
- TileMap::iterator it = m_tiles.find(tileIndex);
- if (it != m_tiles.end())
- setTileNeedsDisplayInRect(tileIndex, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
- }
- }
- return;
- }
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- setTileNeedsDisplayInRect(it->key, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
-}
-
-void TileGrid::dropTilesInRect(const IntRect& rect)
-{
- if (m_tiles.isEmpty())
- return;
-
- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
- IntRect dropRectInTileCoords(enclosingIntRect(scaledRect));
-
- Vector<TileIndex> tilesToRemove;
-
- for (auto& index : m_tiles.keys()) {
- if (rectForTileIndex(index).intersects(dropRectInTileCoords))
- tilesToRemove.append(index);
- }
-
- removeTiles(tilesToRemove);
-}
-
-void TileGrid::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
-{
- PlatformCALayer* tileLayer = tileInfo.layer.get();
-
- IntRect tileRect = rectForTileIndex(tileIndex);
- FloatRect tileRepaintRect = tileRect;
- tileRepaintRect.intersect(repaintRectInTileCoords);
- if (tileRepaintRect.isEmpty())
- return;
-
- tileRepaintRect.moveBy(-tileRect.location());
-
- // We could test for intersection with the visible rect. This would reduce painting yet more,
- // but may make scrolling stale tiles into view more frequent.
- if (tileRect.intersects(coverageRectInTileCoords) && tileLayer->superlayer()) {
- tileLayer->setNeedsDisplay(&tileRepaintRect);
-
- if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0)) {
- FloatRect indicatorRect(0, 0, 52, 27);
- tileLayer->setNeedsDisplay(&indicatorRect);
- }
- } else
- tileInfo.hasStaleContent = true;
-}
-
-void TileGrid::updateTileLayerProperties()
-{
- bool acceleratesDrawing = m_controller.acceleratesDrawing();
- bool opaque = m_controller.tilesAreOpaque();
- Color tileDebugBorderColor = m_controller.tileDebugBorderColor();
- float tileDebugBorderWidth = m_controller.tileDebugBorderWidth();
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- tileInfo.layer->setAcceleratesDrawing(acceleratesDrawing);
- tileInfo.layer->setOpaque(opaque);
- tileInfo.layer->setBorderColor(tileDebugBorderColor);
- tileInfo.layer->setBorderWidth(tileDebugBorderWidth);
- }
-}
-
-bool TileGrid::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const
-{
- FloatRect visibleRect = newVisibleRect;
-
- if (visibleRect.isEmpty())
- return false;
-
- FloatRect currentTileCoverageRect = m_controller.computeTileCoverageRect(oldVisibleRect, newVisibleRect);
- FloatRect scaledRect(currentTileCoverageRect);
- scaledRect.scale(m_scale);
- IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
-
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
-
- IntRect coverageRect = rectForTileIndex(topLeft);
- coverageRect.unite(rectForTileIndex(bottomRight));
- return coverageRect != m_primaryTileCoverageRect;
-}
-
-bool TileGrid::prepopulateRect(const FloatRect& rect)
-{
- IntRect enclosingCoverageRect = enclosingIntRect(rect);
- if (m_primaryTileCoverageRect.contains(enclosingCoverageRect))
- return false;
-
- m_secondaryTileCoverageRects.append(enclosingCoverageRect);
- return true;
-}
-
-IntRect TileGrid::rectForTileIndex(const TileIndex& tileIndex) const
-{
- // FIXME: calculating the scaled size here should match with the rest of calculated sizes where we use the combination of
- // enclosingIntRect, expandedIntSize (floor vs ceil).
- // However enclosing this size could reveal gap on root layer's background. see RenderView::backgroundRect()
- IntSize tileSize = m_controller.tileSize();
- IntRect rect(tileIndex.x() * tileSize.width(), tileIndex.y() * tileSize.height(), tileSize.width(), tileSize.height());
- IntRect scaledBounds(m_controller.bounds());
- scaledBounds.scale(m_scale);
- rect.intersect(scaledBounds);
- return rect;
-}
-
-void TileGrid::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
-{
- IntRect clampedRect = m_controller.bounds();
- clampedRect.scale(m_scale);
- clampedRect.intersect(rect);
-
- auto tileSize = m_controller.tileSize();
- if (clampedRect.x() >= 0)
- topLeft.setX(clampedRect.x() / tileSize.width());
- else
- topLeft.setX(floorf((float)clampedRect.x() / tileSize.width()));
-
- if (clampedRect.y() >= 0)
- topLeft.setY(clampedRect.y() / tileSize.height());
- else
- topLeft.setY(floorf((float)clampedRect.y() / tileSize.height()));
-
- int bottomXRatio = ceil((float)clampedRect.maxX() / tileSize.width());
- bottomRight.setX(std::max(bottomXRatio - 1, 0));
-
- int bottomYRatio = ceil((float)clampedRect.maxY() / tileSize.height());
- bottomRight.setY(std::max(bottomYRatio - 1, 0));
-}
-
-unsigned TileGrid::blankPixelCount() const
-{
- PlatformLayerList tiles(m_tiles.size());
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- if (PlatformLayer *layer = it->value.layer->platformLayer())
- tiles.append(layer);
- }
-
- return TileController::blankPixelCountForTiles(tiles, m_controller.visibleRect(), IntPoint(0, 0));
-}
-
-void TileGrid::removeTiles(Vector<TileGrid::TileIndex>& toRemove)
-{
- for (size_t i = 0; i < toRemove.size(); ++i) {
- TileInfo tileInfo = m_tiles.take(toRemove[i]);
- tileInfo.layer->removeFromSuperlayer();
- m_tileRepaintCounts.remove(tileInfo.layer.get());
- LayerPool::sharedPool()->addLayer(tileInfo.layer);
- }
-}
-
-void TileGrid::removeAllSecondaryTiles()
-{
- Vector<TileIndex> tilesToRemove;
-
- for (auto& entry : m_tiles) {
- const TileInfo& tileInfo = entry.value;
- if (tileInfo.cohort == VisibleTileCohort)
- continue;
- tilesToRemove.append(entry.key);
- }
-
- removeTiles(tilesToRemove);
-}
-
-void TileGrid::removeTilesInCohort(TileCohort cohort)
-{
- ASSERT(cohort != VisibleTileCohort);
- Vector<TileIndex> tilesToRemove;
-
- for (auto& entry : m_tiles) {
- const TileInfo& tileInfo = entry.value;
- if (tileInfo.cohort != cohort)
- continue;
- tilesToRemove.append(entry.key);
- }
-
- removeTiles(tilesToRemove);
-}
-
-void TileGrid::revalidateTiles(unsigned validationPolicy)
-{
- FloatRect visibleRect = m_controller.visibleRect();
- IntRect bounds = m_controller.bounds();
-
- if (visibleRect.isEmpty() || bounds.isEmpty())
- return;
-
- FloatRect tileCoverageRect = m_controller.computeTileCoverageRect(m_controller.visibleRectAtLastRevalidate(), visibleRect);
- FloatRect scaledRect(tileCoverageRect);
- scaledRect.scale(m_scale);
- IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
-
- TileCohort currCohort = nextTileCohort();
- unsigned tilesInCohort = 0;
-
- double minimumRevalidationTimerDuration = std::numeric_limits<double>::max();
- bool needsTileRevalidation = false;
-
- // Move tiles newly outside the coverage rect into the cohort map.
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- TileInfo& tileInfo = it->value;
- TileIndex tileIndex = it->key;
-
- PlatformCALayer* tileLayer = tileInfo.layer.get();
- IntRect tileRect = rectForTileIndex(tileIndex);
- if (tileRect.intersects(coverageRectInTileCoords)) {
- tileInfo.cohort = VisibleTileCohort;
- if (tileInfo.hasStaleContent) {
- // FIXME: store a dirty region per layer?
- tileLayer->setNeedsDisplay();
- tileInfo.hasStaleContent = false;
- }
- } else {
- // Add to the currentCohort if not already in one.
- if (tileInfo.cohort == VisibleTileCohort) {
- tileInfo.cohort = currCohort;
- ++tilesInCohort;
-
- if (m_controller.unparentsOffscreenTiles())
- tileLayer->removeFromSuperlayer();
- } else if (m_controller.unparentsOffscreenTiles() && m_controller.shouldAggressivelyRetainTiles() && tileLayer->superlayer()) {
- // Aggressive tile retention means we'll never remove cohorts, but we need to make sure they're unparented.
- // We can't immediately unparent cohorts comprised of secondary tiles that never touch the primary coverage rect,
- // because that would defeat the usefulness of prepopulateRect(); instead, age prepopulated tiles out as if they were being removed.
- for (auto& cohort : m_cohortList) {
- if (cohort.cohort != tileInfo.cohort)
- continue;
- double timeUntilCohortExpires = cohort.timeUntilExpiration();
- if (timeUntilCohortExpires > 0) {
- minimumRevalidationTimerDuration = std::min(minimumRevalidationTimerDuration, timeUntilCohortExpires);
- needsTileRevalidation = true;
- } else
- tileLayer->removeFromSuperlayer();
- break;
- }
- }
- }
- }
-
- if (needsTileRevalidation)
- m_controller.scheduleTileRevalidation(minimumRevalidationTimerDuration);
-
- if (tilesInCohort)
- startedNewCohort(currCohort);
-
- if (!m_controller.shouldAggressivelyRetainTiles()) {
- if (m_controller.shouldTemporarilyRetainTileCohorts())
- scheduleCohortRemoval();
- else if (tilesInCohort)
- removeTilesInCohort(currCohort);
- }
-
- // Ensure primary tile coverage tiles.
- m_primaryTileCoverageRect = ensureTilesForRect(tileCoverageRect, CoverageType::PrimaryTiles);
-
- if (validationPolicy & PruneSecondaryTiles) {
- removeAllSecondaryTiles();
- m_cohortList.clear();
- } else {
- for (auto& secondaryCoverageRect : m_secondaryTileCoverageRects) {
- FloatRect secondaryRectInLayerCoordinates(secondaryCoverageRect);
- secondaryRectInLayerCoordinates.scale(1 / m_scale);
- ensureTilesForRect(secondaryRectInLayerCoordinates, CoverageType::SecondaryTiles);
- }
- m_secondaryTileCoverageRects.clear();
- }
-
- if (m_controller.unparentsOffscreenTiles() && (validationPolicy & UnparentAllTiles)) {
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- it->value.layer->removeFromSuperlayer();
- }
-
- auto boundsAtLastRevalidate = m_controller.boundsAtLastRevalidate();
- if (boundsAtLastRevalidate != bounds) {
- // If there are margin tiles and the bounds have grown taller or wider, then the tiles that used to
- // be bottom or right margin tiles need to be invalidated.
- if (m_controller.hasMargins()) {
- if (bounds.width() > boundsAtLastRevalidate.width() || bounds.height() > boundsAtLastRevalidate.height()) {
- IntRect boundsWithoutMargin = m_controller.boundsWithoutMargin();
- IntRect oldBoundsWithoutMargin = m_controller.boundsAtLastRevalidateWithoutMargin();
-
- if (bounds.height() > boundsAtLastRevalidate.height()) {
- IntRect formerBottomMarginRect = IntRect(oldBoundsWithoutMargin.x(), oldBoundsWithoutMargin.height(),
- oldBoundsWithoutMargin.width(), boundsWithoutMargin.height() - oldBoundsWithoutMargin.height());
- setNeedsDisplayInRect(formerBottomMarginRect);
- }
-
- if (bounds.width() > boundsAtLastRevalidate.width()) {
- IntRect formerRightMarginRect = IntRect(oldBoundsWithoutMargin.width(), oldBoundsWithoutMargin.y(),
- boundsWithoutMargin.width() - oldBoundsWithoutMargin.width(), oldBoundsWithoutMargin.height());
- setNeedsDisplayInRect(formerRightMarginRect);
- }
- }
- }
-
- FloatRect scaledBounds(bounds);
- scaledBounds.scale(m_scale);
- IntRect boundsInTileCoords(enclosingIntRect(scaledBounds));
-
- TileIndex topLeftForBounds;
- TileIndex bottomRightForBounds;
- getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
-
- Vector<TileIndex> tilesToRemove;
- for (auto& index : m_tiles.keys()) {
- if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x())
- tilesToRemove.append(index);
- }
- removeTiles(tilesToRemove);
- }
-
- m_controller.didRevalidateTiles();
-}
-
-TileGrid::TileCohort TileGrid::nextTileCohort() const
-{
- if (!m_cohortList.isEmpty())
- return m_cohortList.last().cohort + 1;
-
- return 1;
-}
-
-void TileGrid::startedNewCohort(TileCohort cohort)
-{
- m_cohortList.append(TileCohortInfo(cohort, monotonicallyIncreasingTime()));
-#if PLATFORM(IOS)
- if (!m_controller.isInWindow())
- tileControllerMemoryHandler().tileControllerGainedUnparentedTiles(&m_controller);
-#endif
-}
-
-TileGrid::TileCohort TileGrid::newestTileCohort() const
-{
- return m_cohortList.isEmpty() ? 0 : m_cohortList.last().cohort;
-}
-
-TileGrid::TileCohort TileGrid::oldestTileCohort() const
-{
- return m_cohortList.isEmpty() ? 0 : m_cohortList.first().cohort;
-}
-
-void TileGrid::scheduleCohortRemoval()
-{
- const double cohortRemovalTimerSeconds = 1;
-
- // Start the timer, or reschedule the timer from now if it's already active.
- if (!m_cohortRemovalTimer.isActive())
- m_cohortRemovalTimer.startRepeating(cohortRemovalTimerSeconds);
-}
-
-double TileGrid::TileCohortInfo::timeUntilExpiration()
-{
- double cohortLifeTimeSeconds = 2;
- double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
- return creationTime - timeThreshold;
-}
-
-void TileGrid::cohortRemovalTimerFired(Timer<TileGrid>*)
-{
- if (m_cohortList.isEmpty()) {
- m_cohortRemovalTimer.stop();
- return;
- }
-
- while (!m_cohortList.isEmpty() && m_cohortList.first().timeUntilExpiration() < 0) {
- TileCohortInfo firstCohort = m_cohortList.takeFirst();
- removeTilesInCohort(firstCohort.cohort);
- }
-
- m_controller.updateTileCoverageMap();
-}
-
-IntRect TileGrid::ensureTilesForRect(const FloatRect& rect, CoverageType newTileType)
-{
- if (m_controller.unparentsOffscreenTiles() && !m_controller.isInWindow())
- return IntRect();
-
- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
- IntRect rectInTileCoords(enclosingIntRect(scaledRect));
-
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
-
- TileCohort currCohort = nextTileCohort();
- unsigned tilesInCohort = 0;
-
- IntRect coverageRect;
-
- for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
- for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
- TileIndex tileIndex(x, y);
-
- IntRect tileRect = rectForTileIndex(tileIndex);
- TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
-
- coverageRect.unite(tileRect);
-
- bool shouldChangeTileLayerFrame = false;
-
- if (!tileInfo.layer) {
- tileInfo.layer = m_controller.createTileLayer(tileRect, *this);
- ASSERT(!m_tileRepaintCounts.contains(tileInfo.layer.get()));
- } else {
- // We already have a layer for this tile. Ensure that its size is correct.
- FloatSize tileLayerSize(tileInfo.layer->bounds().size());
- shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
-
- if (shouldChangeTileLayerFrame) {
- tileInfo.layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
- tileInfo.layer->setPosition(tileRect.location());
- tileInfo.layer->setNeedsDisplay();
- }
- }
-
- if (newTileType == CoverageType::SecondaryTiles && !tileRect.intersects(m_primaryTileCoverageRect)) {
- tileInfo.cohort = currCohort;
- ++tilesInCohort;
- }
-
- bool shouldParentTileLayer = (!m_controller.unparentsOffscreenTiles() || m_controller.isInWindow()) && !tileInfo.layer->superlayer();
-
- if (shouldParentTileLayer)
- m_containerLayer.get().appendSublayer(tileInfo.layer.get());
- }
- }
-
- if (tilesInCohort)
- startedNewCohort(currCohort);
-
- return coverageRect;
-}
-
-IntRect TileGrid::extent() const
-{
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight);
-
- // Return index of top, left tile and the number of tiles across and down.
- return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
-}
-
-double TileGrid::retainedTileBackingStoreMemory() const
-{
- double totalBytes = 0;
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- if (tileInfo.layer->superlayer()) {
- FloatRect bounds = tileInfo.layer->bounds();
- double contentsScale = tileInfo.layer->contentsScale();
- totalBytes += 4 * bounds.width() * contentsScale * bounds.height() * contentsScale;
- }
- }
-
- return totalBytes;
-}
-
-// Return the rect in layer coords, not tile coords.
-IntRect TileGrid::tileCoverageRect() const
-{
- IntRect coverageRectInLayerCoords(m_primaryTileCoverageRect);
- coverageRectInLayerCoords.scale(1 / m_scale);
- return coverageRectInLayerCoords;
-}
-
-void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const
-{
- CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
- CGContextFillRect(context, layerBounds);
-
- CGFloat scaleFactor = layerBounds.size.width / m_controller.bounds().width();
-
- CGFloat contextScale = scaleFactor / m_scale;
- CGContextScaleCTM(context, contextScale, contextScale);
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- PlatformCALayer* tileLayer = tileInfo.layer.get();
-
- CGFloat red = 1;
- CGFloat green = 1;
- CGFloat blue = 1;
- CGFloat alpha = 1;
- if (tileInfo.hasStaleContent) {
- red = 0.25;
- green = 0.125;
- blue = 0;
- } else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) {
- red = 0.8;
- green = 0.8;
- blue = 0.8;
- }
-
- TileCohort newestCohort = newestTileCohort();
- TileCohort oldestCohort = oldestTileCohort();
-
- if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort)
- alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort));
-
- CGContextSetRGBFillColor(context, red, green, blue, alpha);
-
- if (tileLayer->superlayer()) {
- CGContextSetLineWidth(context, 0.5 / contextScale);
- CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
- } else {
- CGContextSetLineWidth(context, 1 / contextScale);
- CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);
- }
-
- CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height());
- CGContextFillRect(context, frame);
- CGContextStrokeRect(context, frame);
- }
-}
-
-void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)
-{
-#if PLATFORM(IOS)
- if (pthread_main_np())
- WebThreadLock();
-#endif
-
- {
- GraphicsContextStateSaver stateSaver(context);
-
- FloatPoint3D layerOrigin = platformCALayer->position();
- context.translate(-layerOrigin.x(), -layerOrigin.y());
- context.scale(FloatSize(m_scale, m_scale));
-
- RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
- drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
- }
-
- int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
- if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0))
- drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
-
- if (m_controller.scrollingPerformanceLoggingEnabled()) {
- FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
- visiblePart.intersect(m_controller.visibleRect());
-
- if (repaintCount == 1 && !visiblePart.isEmpty())
- WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());
- }
-}
-
-float TileGrid::platformCALayerDeviceScaleFactor() const
-{
- return m_controller.rootLayer().owner()->platformCALayerDeviceScaleFactor();
-}
-
-bool TileGrid::platformCALayerShowDebugBorders() const
-{
- return m_controller.rootLayer().owner()->platformCALayerShowDebugBorders();
-}
-
-bool TileGrid::platformCALayerShowRepaintCounter(PlatformCALayer*) const
-{
- return m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0);
-}
-
-bool TileGrid::platformCALayerContentsOpaque() const
-{
- return m_controller.tilesAreOpaque();
-}
-
-int TileGrid::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
-{
- int repaintCount = 0;
-
- if (m_tileRepaintCounts.contains(platformCALayer))
- repaintCount = m_tileRepaintCounts.get(platformCALayer);
-
- m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
-
- return repaintCount;
-}
-
-#if PLATFORM(IOS)
-void TileGrid::removeUnparentedTilesNow()
-{
- while (!m_cohortList.isEmpty()) {
- TileCohortInfo firstCohort = m_cohortList.takeFirst();
- removeTilesInCohort(firstCohort.cohort);
- }
-}
-#endif
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileGridh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h (169918 => 169919)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h        2014-06-12 22:48:00 UTC (rev 169918)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h        2014-06-12 23:10:29 UTC (rev 169919)
</span><span class="lines">@@ -1,164 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TileGrid_h
-#define TileGrid_h
-
-#include "IntPointHash.h"
-#include "IntRect.h"
-#include "PlatformCALayerClient.h"
-#include "Timer.h"
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Ref.h>
-
-#if PLATFORM(COCOA)
-typedef struct CGContext *CGContextRef;
-#endif
-
-namespace WebCore {
-
-class GraphicsContext;
-class PlatformCALayer;
-class TileController;
-
-class TileGrid : public PlatformCALayerClient {
- WTF_MAKE_NONCOPYABLE(TileGrid); WTF_MAKE_FAST_ALLOCATED;
-public:
- TileGrid(TileController&);
- ~TileGrid();
-
- PlatformCALayer& containerLayer() { return m_containerLayer.get(); }
-
- void setScale(float);
- float scale() const { return m_scale; }
-
- void setNeedsDisplay();
- void setNeedsDisplayInRect(const IntRect&);
- void dropTilesInRect(const IntRect&);
-
- void updateTileLayerProperties();
-
- bool prepopulateRect(const FloatRect&);
-
- enum TileValidationPolicyFlag {
- PruneSecondaryTiles = 1 << 0,
- UnparentAllTiles = 1 << 1
- };
- void revalidateTiles(unsigned validationPolicyFlags);
- bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
-
- IntRect tileCoverageRect() const;
- IntRect extent() const;
-
- double retainedTileBackingStoreMemory() const;
- unsigned blankPixelCount() const;
-
- void drawTileMapContents(CGContextRef, CGRect layerBounds) const;
-
-#if PLATFORM(IOS)
- unsigned numberOfUnparentedTiles() const { return m_cohortList.size(); }
- void removeUnparentedTilesNow();
-#endif
-
- typedef IntPoint TileIndex;
- typedef unsigned TileCohort;
- static const TileCohort VisibleTileCohort = UINT_MAX;
-
- struct TileInfo {
- RefPtr<PlatformCALayer> layer;
- TileCohort cohort; // VisibleTileCohort is visible.
- bool hasStaleContent;
-
- TileInfo()
- : cohort(VisibleTileCohort)
- , hasStaleContent(false)
- { }
- };
-
-private:
- void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
-
- IntRect rectForTileIndex(const TileIndex&) const;
- void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
-
- enum class CoverageType { PrimaryTiles, SecondaryTiles };
- IntRect ensureTilesForRect(const FloatRect&, CoverageType);
-
- struct TileCohortInfo {
- TileCohort cohort;
- double creationTime; // in monotonicallyIncreasingTime().
- TileCohortInfo(TileCohort inCohort, double inTime)
- : cohort(inCohort)
- , creationTime(inTime)
- { }
-
- double timeUntilExpiration();
- };
-
- void removeAllSecondaryTiles();
- void removeTilesInCohort(TileCohort);
-
- void scheduleCohortRemoval();
- void cohortRemovalTimerFired(Timer<TileGrid>*);
- TileCohort nextTileCohort() const;
- void startedNewCohort(TileCohort);
- TileCohort newestTileCohort() const;
- TileCohort oldestTileCohort() const;
-
- void removeTiles(Vector<TileGrid::TileIndex>& toRemove);
-
- // PlatformCALayerClient
- virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;
- virtual bool platformCALayerShowDebugBorders() const override;
- virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
- virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
- virtual bool platformCALayerContentsOpaque() const override;
- virtual bool platformCALayerDrawsContent() const override { return true; }
- virtual float platformCALayerDeviceScaleFactor() const override;
-
- TileController& m_controller;
- Ref<PlatformCALayer> m_containerLayer;
-
- typedef HashMap<TileIndex, TileInfo> TileMap;
- TileMap m_tiles;
-
- IntRect m_primaryTileCoverageRect;
- Vector<FloatRect> m_secondaryTileCoverageRects;
-
- float m_scale;
-
- typedef Deque<TileCohortInfo> TileCohortList;
- TileCohortList m_cohortList;
-
- Timer<TileGrid> m_cohortRemovalTimer;
-
- typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
- RepaintCountMap m_tileRepaintCounts;
-};
-
-}
-#endif
</del></span></pre>
</div>
</div>
</body>
</html>