<!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>[166805] tags/Safari-538.26.3/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166805">166805</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2014-04-04 15:17:40 -0700 (Fri, 04 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/166654">r166654</a>. </pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsSafari538263SourceWebCoreChangeLog">tags/Safari-538.26.3/Source/WebCore/ChangeLog</a></li>
<li><a href="#tagsSafari538263SourceWebCoreWebCoreexpin">tags/Safari-538.26.3/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#tagsSafari538263SourceWebCoreWebCorexcodeprojprojectpbxproj">tags/Safari-538.26.3/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacPlatformCALayerMach">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h</a></li>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacPlatformCALayerMacmm">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm</a></li>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacTileControllerh">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.h</a></li>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacTileControllermm">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.mm</a></li>
<li><a href="#tagsSafari538263SourceWebKit2ChangeLog">tags/Safari-538.26.3/Source/WebKit2/ChangeLog</a></li>
<li><a href="#tagsSafari538263SourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteTiledBackingcpp">tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp</a></li>
<li><a href="#tagsSafari538263SourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteTiledBackingh">tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacTileGridh">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.h</a></li>
<li><a href="#tagsSafari538263SourceWebCoreplatformgraphicscamacTileGridmm">tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsSafari538263SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/ChangeLog (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/ChangeLog        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/ChangeLog        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2014-04-04 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r166654
+
+ 2014-04-02 Antti Koivisto <antti@apple.com>
+
+ Split tile grid out from TileController
+ https://bugs.webkit.org/show_bug.cgi?id=131102
+
+ Reviewed by Simon Fraser.
+
+ Add a TileGrid class that encapsulates tiles, zoom level and the related metadata.
+ This will make it possible to have multiple grids per TileController later.
+
+2014-04-04 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r166542
</span><span class="cx">
</span><span class="cx"> 2014-03-31 Simon Fraser <simon.fraser@apple.com>
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/WebCore.exp.in (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/WebCore.exp.in        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/WebCore.exp.in        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -429,6 +429,7 @@
</span><span class="cx"> __ZN7WebCore14StorageTracker7trackerEv
</span><span class="cx"> __ZN7WebCore14SubframeLoader12allowPluginsENS_28ReasonForCallingAllowPluginsE
</span><span class="cx"> __ZN7WebCore14TileController14setTilesOpaqueEb
</span><ins>+__ZN7WebCore14TileController15containerLayersEv
</ins><span class="cx"> __ZN7WebCore14TileController15setNeedsDisplayEv
</span><span class="cx"> __ZN7WebCore14TileController21setAcceleratesDrawingEb
</span><span class="cx"> __ZN7WebCore14TileController21setNeedsDisplayInRectERKNS_7IntRectE
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -6067,6 +6067,8 @@
</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><ins>+                E4C274CA18E988EA00602C76 /* TileGrid.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4C274C918E988EA00602C76 /* TileGrid.mm */; };
+                E4C274CC18E988F500602C76 /* TileGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C274CB18E988F500602C76 /* TileGrid.h */; };
</ins><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 /* TileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* TileCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -13466,6 +13468,8 @@
</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><ins>+                E4C274C918E988EA00602C76 /* TileGrid.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileGrid.mm; path = ca/mac/TileGrid.mm; sourceTree = "<group>"; };
+                E4C274CB18E988F500602C76 /* TileGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileGrid.h; path = ca/mac/TileGrid.h; sourceTree = "<group>"; };
</ins><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 /* TileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileCache.h; path = ios/TileCache.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -15603,6 +15607,8 @@
</span><span class="cx">                                 4958782012A57DDF007238AC /* PlatformCALayerMac.mm */,
</span><span class="cx">                                 1AA71609149BC4DB0016EC19 /* TileController.h */,
</span><span class="cx">                                 1AA71608149BC4DA0016EC19 /* TileController.mm */,
</span><ins>+                                E4C274CB18E988F500602C76 /* TileGrid.h */,
+                                E4C274C918E988EA00602C76 /* TileGrid.mm */,
</ins><span class="cx">                                 0F580FA11496939100FB5BD8 /* WebTiledBackingLayer.h */,
</span><span class="cx">                                 0F580FA21496939100FB5BD8 /* WebTiledBackingLayer.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -24438,6 +24444,7 @@
</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><ins>+                                E4C274CC18E988F500602C76 /* TileGrid.h in Headers */,
</ins><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">@@ -28212,6 +28219,7 @@
</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><ins>+                                E4C274CA18E988EA00602C76 /* TileGrid.mm in Sources */,
</ins><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></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacPlatformCALayerMach"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -158,7 +158,7 @@
</span><span class="cx"> bool requiresCustomAppearanceUpdateOnBoundsChange() const;
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSObject> m_delegate;
</span><del>- OwnPtr<PlatformCALayerList> m_customSublayers;
</del><ins>+ std::unique_ptr<PlatformCALayerList> m_customSublayers;
</ins><span class="cx"> GraphicsLayer::CustomAppearance m_customAppearance;
</span><span class="cx"> GraphicsLayer::CustomBehavior m_customBehavior;
</span><span class="cx"> };
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacPlatformCALayerMacmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -230,9 +230,7 @@
</span><span class="cx"> WebTiledBackingLayer* tiledBackingLayer = static_cast<WebTiledBackingLayer*>(m_layer.get());
</span><span class="cx"> TileController* tileController = [tiledBackingLayer createTileController:this];
</span><span class="cx">
</span><del>- m_customSublayers = adoptPtr(new PlatformCALayerList(1));
- PlatformCALayer* tileCacheTileContainerLayer = tileController->tileContainerLayer();
- (*m_customSublayers)[0] = tileCacheTileContainerLayer;
</del><ins>+ m_customSublayers = std::make_unique<PlatformCALayerList>(tileController->containerLayers());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> END_BLOCK_OBJC_EXCEPTIONS
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacTileControllerh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.h (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.h        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> #define TileController_h
</span><span class="cx">
</span><span class="cx"> #include "FloatRect.h"
</span><del>-#include "IntPointHash.h"
</del><span class="cx"> #include "IntRect.h"
</span><span class="cx"> #include "PlatformCALayer.h"
</span><span class="cx"> #include "PlatformCALayerClient.h"
</span><span class="lines">@@ -44,10 +43,11 @@
</span><span class="cx"> class FloatRect;
</span><span class="cx"> class IntPoint;
</span><span class="cx"> class IntRect;
</span><ins>+class TileGrid;
</ins><span class="cx">
</span><span class="cx"> typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
</span><span class="cx">
</span><del>-class TileController : public TiledBacking, public PlatformCALayerClient {
</del><ins>+class TileController final : public TiledBacking, public PlatformCALayerClient {
</ins><span class="cx"> WTF_MAKE_NONCOPYABLE(TileController);
</span><span class="cx">
</span><span class="cx"> public:
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> void setNeedsDisplayInRect(const IntRect&);
</span><span class="cx">
</span><span class="cx"> void setScale(float);
</span><del>- float scale() const { return m_scale; }
</del><ins>+ float scale() const;
</ins><span class="cx">
</span><span class="cx"> bool acceleratesDrawing() const { return m_acceleratesDrawing; }
</span><span class="cx"> void setAcceleratesDrawing(bool);
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> void setTilesOpaque(bool);
</span><span class="cx"> bool tilesAreOpaque() const { return m_tilesAreOpaque; }
</span><span class="cx">
</span><del>- PlatformCALayer *tileContainerLayer() const { return m_tileContainerLayer.get(); }
</del><ins>+ PlatformCALayer& rootLayer() { return *m_tileCacheLayer; }
</ins><span class="cx">
</span><span class="cx"> void setTileDebugBorderWidth(float);
</span><span class="cx"> void setTileDebugBorderColor(Color);
</span><span class="lines">@@ -79,31 +79,57 @@
</span><span class="cx"> static unsigned blankPixelCountForTiles(const PlatformLayerList&, const FloatRect&, const IntPoint&);
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- unsigned numberOfUnparentedTiles() const { return m_cohortList.size(); }
</del><ins>+ unsigned numberOfUnparentedTiles() const;
</ins><span class="cx"> void removeUnparentedTilesNow();
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> public:
</span><del>- // Only public for inline methods in the implementation file.
- typedef IntPoint TileIndex;
- typedef unsigned TileCohort;
- static const TileCohort VisibleTileCohort = UINT_MAX;
</del><ins>+ // Public for TileGrid
+ bool isInWindow() const { return m_isInWindow; }
+
+ float deviceScaleFactor() const { return m_deviceScaleFactor; }
+ FloatRect exposedRect() const { return m_exposedRect; }
+
+ Color tileDebugBorderColor() const { return m_tileDebugBorderColor; }
+ float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
+
+ virtual IntSize tileSize() const override { return m_tileSize; }
+ virtual IntRect bounds() const override;
+ virtual bool hasMargins() 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; }
+
+ IntRect boundsWithoutMargin() const;
+
+ 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;
+
</ins><span class="cx"> typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
</span><ins>+ RepaintCountMap& repaintCountMap() { return m_tileRepaintCounts; }
</ins><span class="cx">
</span><del>- struct TileInfo {
- RefPtr<PlatformCALayer> layer;
- TileCohort cohort; // VisibleTileCohort is visible.
- bool hasStaleContent;
-
- TileInfo()
- : cohort(VisibleTileCohort)
- , hasStaleContent(false)
- { }
- };
</del><ins>+ void updateTileCoverageMap();
</ins><span class="cx">
</span><ins>+ RefPtr<PlatformCALayer> createTileLayer(const IntRect&);
+
+ Vector<RefPtr<PlatformCALayer>> containerLayers();
+
</ins><span class="cx"> private:
</span><span class="cx"> TileController(PlatformCALayer*);
</span><span class="cx">
</span><ins>+ TileGrid& tileGrid() { return *m_tileGrid; }
+ const TileGrid& tileGrid() const { return *m_tileGrid; }
+
</ins><span class="cx"> // TiledBacking member functions.
</span><span class="cx"> virtual void setVisibleRect(const FloatRect&) override;
</span><span class="cx"> virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const override;
</span><span class="lines">@@ -111,25 +137,17 @@
</span><span class="cx"> virtual void prepopulateRect(const FloatRect&) override;
</span><span class="cx"> virtual void setIsInWindow(bool) override;
</span><span class="cx"> virtual void setTileCoverage(TileCoverage) override;
</span><del>- virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
</del><span class="cx"> virtual void revalidateTiles() override;
</span><span class="cx"> virtual void forceRepaint() override;
</span><del>- virtual IntSize tileSize() const override { return m_tileSize; }
</del><span class="cx"> virtual IntRect tileGridExtent() const override;
</span><span class="cx"> virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
</span><span class="cx"> virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
</span><span class="cx"> virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; }
</span><del>- virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
</del><span class="cx"> virtual double retainedTileBackingStoreMemory() const override;
</span><span class="cx"> virtual IntRect tileCoverageRect() const override;
</span><span class="cx"> virtual PlatformCALayer* tiledScrollingIndicatorLayer() override;
</span><span class="cx"> virtual void setScrollingModeIndication(ScrollingModeIndication) override;
</span><span class="cx"> virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
</span><del>- virtual bool hasMargins() const override;
- virtual int topMarginHeight() const override;
- virtual int bottomMarginHeight() const override;
- virtual int leftMarginWidth() const override;
- virtual int rightMarginWidth() const override;
</del><span class="cx">
</span><span class="cx"> // PlatformCALayerClient
</span><span class="cx"> virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
</span><span class="lines">@@ -148,86 +166,31 @@
</span><span class="cx"> virtual void platformCALayerSetNeedsToRevalidateTiles() override { }
</span><span class="cx"> virtual float platformCALayerDeviceScaleFactor() const override;
</span><span class="cx">
</span><del>- virtual IntRect bounds() const override;
- IntRect boundsWithoutMargin() const;
- IntRect boundsAtLastRevalidateWithoutMargin() const;
-
- IntRect rectForTileIndex(const TileIndex&) const;
- void adjustRectAtTileIndexForMargin(const TileIndex&, IntRect&) const;
- void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
-
- FloatRect computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const;
-
</del><span class="cx"> void scheduleTileRevalidation(double interval);
</span><span class="cx"> void tileRevalidationTimerFired(Timer<TileController>*);
</span><span class="cx">
</span><del>- void scheduleCohortRemoval();
- void cohortRemovalTimerFired(Timer<TileController>*);
-
- typedef unsigned TileValidationPolicyFlags;
-
</del><span class="cx"> void setNeedsRevalidateTiles();
</span><del>- void revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy, TileValidationPolicyFlags backgroundValidationPolicy);
- enum class CoverageType { PrimaryTiles, SecondaryTiles };
</del><span class="cx">
</span><del>- // Returns the bounds of the covered tiles.
- IntRect ensureTilesForRect(const FloatRect&, CoverageType);
- void updateTileCoverageMap();
-
- void removeAllTiles();
- void removeAllSecondaryTiles();
- void removeTilesInCohort(TileCohort);
-
- TileCohort nextTileCohort() const;
- void startedNewCohort(TileCohort);
-
- TileCohort newestTileCohort() const;
- TileCohort oldestTileCohort() const;
-
- void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
-
- RefPtr<PlatformCALayer> createTileLayer(const IntRect&);
-
</del><span class="cx"> void drawTileMapContents(CGContextRef, CGRect);
</span><span class="cx">
</span><span class="cx"> PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
</span><span class="cx">
</span><del>- FloatRect scaledExposedRect() const;
-
</del><span class="cx"> PlatformCALayer* m_tileCacheLayer;
</span><del>- RefPtr<PlatformCALayer> m_tileContainerLayer;
</del><span class="cx"> RefPtr<PlatformCALayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
</span><span class="cx"> RefPtr<PlatformCALayer> m_visibleRectIndicatorLayer;
</span><span class="cx">
</span><ins>+ std::unique_ptr<TileGrid> m_tileGrid;
+
</ins><span class="cx"> IntSize m_tileSize;
</span><span class="cx"> FloatRect m_visibleRect;
</span><span class="cx"> FloatRect m_visibleRectAtLastRevalidate;
</span><span class="cx"> FloatRect m_exposedRect; // The exposed area of containing platform views.
</span><span class="cx"> IntRect m_boundsAtLastRevalidate;
</span><del>-
- Vector<FloatRect> m_secondaryTileCoverageRects;
</del><span class="cx">
</span><del>- typedef HashMap<TileIndex, TileInfo> TileMap;
- TileMap m_tiles;
</del><span class="cx"> Timer<TileController> m_tileRevalidationTimer;
</span><del>- Timer<TileController> m_cohortRemovalTimer;
</del><span class="cx">
</span><span class="cx"> RepaintCountMap m_tileRepaintCounts;
</span><span class="cx">
</span><del>- struct TileCohortInfo {
- TileCohort cohort;
- double creationTime; // in monotonicallyIncreasingTime().
- TileCohortInfo(TileCohort inCohort, double inTime)
- : cohort(inCohort)
- , creationTime(inTime)
- { }
- };
- typedef Deque<TileCohortInfo> TileCohortList;
- TileCohortList m_cohortList;
-
- IntRect m_primaryTileCoverageRect; // In tile coords.
-
- float m_scale;
</del><span class="cx"> float m_deviceScaleFactor;
</span><span class="cx">
</span><span class="cx"> TileCoverage m_tileCoverage;
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacTileControllermm"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.mm (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #import "IntRect.h"
</span><span class="cx"> #import "PlatformCALayer.h"
</span><span class="cx"> #import "Region.h"
</span><ins>+#import "TileGrid.h"
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> #import "LayerPool.h"
</span><span class="cx"> #endif
</span><span class="lines">@@ -55,11 +56,10 @@
</span><span class="cx">
</span><span class="cx"> TileController::TileController(PlatformCALayer* rootPlatformLayer)
</span><span class="cx"> : m_tileCacheLayer(rootPlatformLayer)
</span><ins>+ , m_tileGrid(std::make_unique<TileGrid>(*this))
</ins><span class="cx"> , m_tileSize(defaultTileWidth, defaultTileHeight)
</span><span class="cx"> , m_exposedRect(FloatRect::infiniteRect())
</span><span class="cx"> , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
</span><del>- , m_cohortRemovalTimer(this, &TileController::cohortRemovalTimerFired)
- , m_scale(1)
</del><span class="cx"> , m_deviceScaleFactor(1)
</span><span class="cx"> , m_tileCoverage(CoverageForVisibleArea)
</span><span class="cx"> , m_marginTop(0)
</span><span class="lines">@@ -75,10 +75,6 @@
</span><span class="cx"> , m_tileDebugBorderWidth(0)
</span><span class="cx"> , m_indicatorMode(AsyncScrollingIndication)
</span><span class="cx"> {
</span><del>- m_tileContainerLayer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr);
-#ifndef NDEBUG
- m_tileContainerLayer->setName("TileController Container Layer");
-#endif
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TileController::~TileController()
</span><span class="lines">@@ -89,9 +85,6 @@
</span><span class="cx"> tileControllerMemoryHandler().removeTileController(this);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- it->value.layer->setOwner(nullptr);
-
</del><span class="cx"> if (m_tiledScrollingIndicatorLayer)
</span><span class="cx"> m_tiledScrollingIndicatorLayer->setOwner(nullptr);
</span><span class="cx"> }
</span><span class="lines">@@ -104,73 +97,14 @@
</span><span class="cx">
</span><span class="cx"> void TileController::setNeedsDisplay()
</span><span class="cx"> {
</span><del>- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- TileInfo& tileInfo = it->value;
- IntRect tileRect = rectForTileIndex(it->key);
-
- if (tileRect.intersects(m_primaryTileCoverageRect) && tileInfo.layer->superlayer())
- tileInfo.layer->setNeedsDisplay();
- else
- tileInfo.hasStaleContent = true;
- }
</del><ins>+ tileGrid().setNeedsDisplay();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setNeedsDisplayInRect(const IntRect& rect)
</span><span class="cx"> {
</span><del>- if (m_tiles.isEmpty())
- return;
-
- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
- IntRect repaintRectInTileCoords(enclosingIntRect(scaledRect));
-
- // For small invalidations, lookup the covered tiles.
- if (repaintRectInTileCoords.height() < 2 * m_tileSize.height() && repaintRectInTileCoords.width() < 2 * m_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);
</del><ins>+ tileGrid().setNeedsDisplayInRect(rect);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void TileController::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 (owningGraphicsLayer()->platformCALayerShowRepaintCounter(0)) {
- FloatRect indicatorRect(0, 0, 52, 27);
- tileLayer->setNeedsDisplay(&indicatorRect);
- }
- } else
- tileInfo.hasStaleContent = true;
-}
-
</del><span class="cx"> void TileController::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -179,7 +113,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> if (platformCALayer == m_tiledScrollingIndicatorLayer.get()) {
</span><del>- drawTileMapContents(context.platformContext(), m_tiledScrollingIndicatorLayer->bounds());
</del><ins>+ tileGrid().drawTileMapContents(context.platformContext(), m_tiledScrollingIndicatorLayer->bounds());
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -188,7 +122,7 @@
</span><span class="cx">
</span><span class="cx"> FloatPoint3D layerOrigin = platformCALayer->position();
</span><span class="cx"> context.translate(-layerOrigin.x(), -layerOrigin.y());
</span><del>- context.scale(FloatSize(m_scale, m_scale));
</del><ins>+ context.scale(FloatSize(tileGrid().scale(), tileGrid().scale()));
</ins><span class="cx">
</span><span class="cx"> RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
</span><span class="cx"> drawLayerContents(context.platformContext(), m_tileCacheLayer, dirtyRects);
</span><span class="lines">@@ -222,58 +156,46 @@
</span><span class="cx"> return owningGraphicsLayer()->platformCALayerShowRepaintCounter(0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+float TileController::scale() const
+{
+ return tileGrid().scale();
+}
+
</ins><span class="cx"> void TileController::setScale(float scale)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(owningGraphicsLayer()->isCommittingChanges());
</span><span class="cx">
</span><del>- float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
</del><ins>+ float deviceScaleFactor = platformCALayerDeviceScaleFactor();
</ins><span class="cx">
</span><span class="cx"> // The scale we get is the product of the page scale factor and device scale factor.
</span><span class="cx"> // Divide by the device scale factor so we'll get the page scale factor.
</span><span class="cx"> scale /= deviceScaleFactor;
</span><span class="cx">
</span><del>- if (m_scale == scale && m_deviceScaleFactor == deviceScaleFactor && !m_hasTilesWithTemporaryScaleFactor)
</del><ins>+ if (tileGrid().scale() == scale && m_deviceScaleFactor == deviceScaleFactor && !m_hasTilesWithTemporaryScaleFactor)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_hasTilesWithTemporaryScaleFactor = false;
</span><span class="cx"> m_deviceScaleFactor = deviceScaleFactor;
</span><del>- m_scale = scale;
</del><span class="cx">
</span><del>- TransformationMatrix transform;
- transform.scale(1 / m_scale);
- m_tileContainerLayer->setTransform(transform);
-
- // FIXME: we may revalidateTiles twice in this commit.
- revalidateTiles(PruneSecondaryTiles, PruneSecondaryTiles);
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- it->value.layer->setContentsScale(deviceScaleFactor);
</del><ins>+ tileGrid().setScale(scale);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
</span><span class="cx"> {
</span><span class="cx"> if (m_acceleratesDrawing == acceleratesDrawing)
</span><span class="cx"> return;
</span><del>-
</del><span class="cx"> m_acceleratesDrawing = acceleratesDrawing;
</span><span class="cx">
</span><del>- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- tileInfo.layer->setAcceleratesDrawing(m_acceleratesDrawing);
- }
</del><ins>+ tileGrid().updateTilerLayerProperties();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setTilesOpaque(bool opaque)
</span><span class="cx"> {
</span><span class="cx"> if (opaque == m_tilesAreOpaque)
</span><span class="cx"> return;
</span><del>-
</del><span class="cx"> m_tilesAreOpaque = opaque;
</span><span class="cx">
</span><del>- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- tileInfo.layer->setOpaque(opaque);
- }
</del><ins>+ tileGrid().updateTilerLayerProperties();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setVisibleRect(const FloatRect& visibleRect)
</span><span class="lines">@@ -288,24 +210,9 @@
</span><span class="cx">
</span><span class="cx"> bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
</span><span class="cx"> {
</span><del>- FloatRect visibleRect = newVisibleRect;
- visibleRect.intersect(scaledExposedRect());
-
- if (visibleRect.isEmpty() || bounds().isEmpty())
</del><ins>+ if (bounds().isEmpty())
</ins><span class="cx"> return false;
</span><del>-
- FloatRect currentTileCoverageRect = computeTileCoverageRect(m_visibleRect, 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;
</del><ins>+ return tileGrid().tilesWouldChangeForVisibleRect(newVisibleRect, m_visibleRect);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setExposedRect(const FloatRect& exposedRect)
</span><span class="lines">@@ -317,24 +224,10 @@
</span><span class="cx"> setNeedsRevalidateTiles();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-FloatRect TileController::scaledExposedRect() const
-{
- FloatRect scaledExposedRect = m_exposedRect;
- scaledExposedRect.scale(1 / m_scale);
- return scaledExposedRect;
-}
-
</del><span class="cx"> void TileController::prepopulateRect(const FloatRect& rect)
</span><span class="cx"> {
</span><del>- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
- IntRect rectInTileCoords(enclosingIntRect(scaledRect));
-
- if (m_primaryTileCoverageRect.contains(rectInTileCoords))
- return;
-
- m_secondaryTileCoverageRects.append(rect);
- setNeedsRevalidateTiles();
</del><ins>+ if (tileGrid().prepopulateRect(rect))
+ setNeedsRevalidateTiles();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setIsInWindow(bool isInWindow)
</span><span class="lines">@@ -364,7 +257,8 @@
</span><span class="cx"> void TileController::revalidateTiles()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(owningGraphicsLayer()->isCommittingChanges());
</span><del>- revalidateTiles(0, 0);
</del><ins>+ tileGrid().revalidateTiles(0);
+ m_visibleRectAtLastRevalidate = m_visibleRect;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::forceRepaint()
</span><span class="lines">@@ -376,22 +270,18 @@
</span><span class="cx"> {
</span><span class="cx"> if (m_tileDebugBorderWidth == borderWidth)
</span><span class="cx"> return;
</span><del>-
</del><span class="cx"> m_tileDebugBorderWidth = borderWidth;
</span><del>- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- tileInfo.layer->setBorderWidth(m_tileDebugBorderWidth);
- }
</del><ins>+
+ tileGrid().updateTilerLayerProperties();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setTileDebugBorderColor(Color borderColor)
</span><span class="cx"> {
</span><span class="cx"> if (m_tileDebugBorderColor == borderColor)
</span><span class="cx"> return;
</span><del>-
</del><span class="cx"> m_tileDebugBorderColor = borderColor;
</span><del>- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- it->value.layer->setBorderColor(borderColor);
</del><ins>+
+ tileGrid().updateTilerLayerProperties();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> IntRect TileController::bounds() const
</span><span class="lines">@@ -415,80 +305,8 @@
</span><span class="cx"> return boundsWithoutMargin;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TileController::adjustRectAtTileIndexForMargin(const TileIndex& tileIndex, IntRect& rect) const
</del><ins>+FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& visibleRect) const
</ins><span class="cx"> {
</span><del>- if (!hasMargins())
- return;
-
- // This is a tile in the top margin.
- if (m_marginTop && tileIndex.y() < 0) {
- rect.setY(tileIndex.y() * topMarginHeight());
- rect.setHeight(topMarginHeight());
- }
-
- // This is a tile in the left margin.
- if (m_marginLeft && tileIndex.x() < 0) {
- rect.setX(tileIndex.x() * leftMarginWidth());
- rect.setWidth(leftMarginWidth());
- }
-
- TileIndex contentTopLeft;
- TileIndex contentBottomRight;
- getTileIndexRangeForRect(boundsWithoutMargin(), contentTopLeft, contentBottomRight);
-
- // This is a tile in the bottom margin.
- if (m_marginBottom && tileIndex.y() > contentBottomRight.y())
- rect.setHeight(bottomMarginHeight());
-
- // This is a tile in the right margin.
- if (m_marginRight && tileIndex.x() > contentBottomRight.x())
- rect.setWidth(rightMarginWidth());
-}
-
-IntRect TileController::rectForTileIndex(const TileIndex& tileIndex) const
-{
- IntRect rect(tileIndex.x() * m_tileSize.width(), tileIndex.y() * m_tileSize.height(), m_tileSize.width(), m_tileSize.height());
- IntRect scaledBounds(bounds());
- scaledBounds.scale(m_scale);
-
- rect.intersect(scaledBounds);
-
- // These rect computations assume m_tileSize is the correct size to use. However, a tile in the margin area
- // might be a different size depending on the size of the margins. So adjustRectAtTileIndexForMargin() will
- // fix the rect we've computed to match the margin sizes if this tile is in the margins.
- adjustRectAtTileIndexForMargin(tileIndex, rect);
-
- return rect;
-}
-
-void TileController::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
-{
- IntRect clampedRect = bounds();
- clampedRect.scale(m_scale);
- clampedRect.intersect(rect);
-
- if (clampedRect.x() >= 0)
- topLeft.setX(clampedRect.x() / m_tileSize.width());
- else
- topLeft.setX(floorf((float)clampedRect.x() / leftMarginWidth()));
-
- if (clampedRect.y() >= 0)
- topLeft.setY(clampedRect.y() / m_tileSize.height());
- else
- topLeft.setY(floorf((float)clampedRect.y() / topMarginHeight()));
-
- int bottomXRatio = ceil((float)clampedRect.maxX() / m_tileSize.width());
- bottomRight.setX(std::max(bottomXRatio - 1, 0));
-
- int bottomYRatio = ceil((float)clampedRect.maxY() / m_tileSize.height());
- bottomRight.setY(std::max(bottomYRatio - 1, 0));
-}
-
-FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const
-{
- FloatRect visibleRect = currentVisibleRect;
- visibleRect.intersect(scaledExposedRect());
-
</del><span class="cx"> // 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.
</span><span class="cx"> if (!m_isInWindow)
</span><span class="cx"> return visibleRect;
</span><span class="lines">@@ -536,6 +354,16 @@
</span><span class="cx"> m_tileRevalidationTimer.startOneShot(interval);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool TileController::shouldAggressivelyRetainTiles() const
+{
+ return owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer);
+}
+
+bool TileController::shouldTemporarilyRetainTileCohorts() const
+{
+ return owningGraphicsLayer()->platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer);
+}
+
</ins><span class="cx"> void TileController::tileRevalidationTimerFired(Timer<TileController>*)
</span><span class="cx"> {
</span><span class="cx"> if (m_isInWindow) {
</span><span class="lines">@@ -543,22 +371,22 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- TileValidationPolicyFlags foregroundValidationPolicy = owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer) ? 0 : PruneSecondaryTiles;
- TileValidationPolicyFlags backgroundValidationPolicy = foregroundValidationPolicy | UnparentAllTiles;
</del><ins>+ TileGrid::TileValidationPolicyFlags validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : PruneSecondaryTiles) | UnparentAllTiles;
</ins><span class="cx">
</span><del>- revalidateTiles(foregroundValidationPolicy, backgroundValidationPolicy);
</del><ins>+ tileGrid().revalidateTiles(validationPolicy);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-unsigned TileController::blankPixelCount() const
</del><ins>+void TileController::didRevalidateTiles()
</ins><span class="cx"> {
</span><del>- PlatformLayerList tiles(m_tiles.size());
</del><ins>+ m_visibleRectAtLastRevalidate = visibleRect();
+ m_boundsAtLastRevalidate = bounds();
</ins><span class="cx">
</span><del>- 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);
- }
</del><ins>+ updateTileCoverageMap();
+}
</ins><span class="cx">
</span><del>- return blankPixelCountForTiles(tiles, m_visibleRect, IntPoint(0,0));
</del><ins>+unsigned TileController::blankPixelCount() const
+{
+ return tileGrid().blankPixelCount();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> unsigned TileController::blankPixelCountForTiles(const PlatformLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
</span><span class="lines">@@ -581,324 +409,19 @@
</span><span class="cx"> return uncoveredRegion.totalArea();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline void queueTileForRemoval(const TileController::TileIndex& tileIndex, const TileController::TileInfo& tileInfo, Vector<TileController::TileIndex>& tilesToRemove, TileController::RepaintCountMap& repaintCounts)
-{
- tileInfo.layer->removeFromSuperlayer();
- repaintCounts.remove(tileInfo.layer.get());
- tilesToRemove.append(tileIndex);
-}
-
-void TileController::removeAllTiles()
-{
- Vector<TileIndex> tilesToRemove;
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
-
- for (size_t i = 0; i < tilesToRemove.size(); ++i) {
- TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
- LayerPool::sharedPool()->addLayer(tileInfo.layer);
-#endif
- }
-}
-
-void TileController::removeAllSecondaryTiles()
-{
- Vector<TileIndex> tilesToRemove;
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- if (tileInfo.cohort == VisibleTileCohort)
- continue;
-
- queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
- }
-
- for (size_t i = 0; i < tilesToRemove.size(); ++i) {
- TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
- LayerPool::sharedPool()->addLayer(tileInfo.layer);
-#endif
- }
-}
-
-void TileController::removeTilesInCohort(TileCohort cohort)
-{
- ASSERT(cohort != VisibleTileCohort);
- Vector<TileIndex> tilesToRemove;
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileInfo& tileInfo = it->value;
- if (tileInfo.cohort != cohort)
- continue;
-
- queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
- }
-
- for (size_t i = 0; i < tilesToRemove.size(); ++i) {
- TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
- LayerPool::sharedPool()->addLayer(tileInfo.layer);
-#endif
- }
-}
-
</del><span class="cx"> void TileController::setNeedsRevalidateTiles()
</span><span class="cx"> {
</span><span class="cx"> owningGraphicsLayer()->platformCALayerSetNeedsToRevalidateTiles();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy, TileValidationPolicyFlags backgroundValidationPolicy)
-{
- FloatRect visibleRect = m_visibleRect;
- IntRect bounds = this->bounds();
-
- visibleRect.intersect(scaledExposedRect());
-
- if (visibleRect.isEmpty() || bounds.isEmpty())
- return;
-
- TileValidationPolicyFlags validationPolicy = m_isInWindow ? foregroundValidationPolicy : backgroundValidationPolicy;
-
- FloatRect tileCoverageRect = computeTileCoverageRect(m_visibleRectAtLastRevalidate, m_visibleRect);
- FloatRect scaledRect(tileCoverageRect);
- scaledRect.scale(m_scale);
- IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
-
- TileCohort currCohort = nextTileCohort();
- unsigned tilesInCohort = 0;
-
- // 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_unparentsOffscreenTiles)
- tileLayer->removeFromSuperlayer();
- }
- }
- }
-
- if (tilesInCohort)
- startedNewCohort(currCohort);
-
- if (!owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer)) {
- if (owningGraphicsLayer()->platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer))
- 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 (size_t i = 0; i < m_secondaryTileCoverageRects.size(); ++i)
- ensureTilesForRect(m_secondaryTileCoverageRects[i], CoverageType::SecondaryTiles);
- m_secondaryTileCoverageRects.clear();
- }
-
- if (m_unparentsOffscreenTiles && (validationPolicy & UnparentAllTiles)) {
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- it->value.layer->removeFromSuperlayer();
- }
-
- if (m_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 (hasMargins()) {
- if (bounds.width() > m_boundsAtLastRevalidate.width() || bounds.height() > m_boundsAtLastRevalidate.height()) {
- IntRect boundsWithoutMargin = this->boundsWithoutMargin();
- IntRect oldBoundsWithoutMargin = boundsAtLastRevalidateWithoutMargin();
-
- if (bounds.height() > m_boundsAtLastRevalidate.height()) {
- IntRect formerBottomMarginRect = IntRect(oldBoundsWithoutMargin.x(), oldBoundsWithoutMargin.height(),
- oldBoundsWithoutMargin.width(), boundsWithoutMargin.height() - oldBoundsWithoutMargin.height());
- setNeedsDisplayInRect(formerBottomMarginRect);
- }
-
- if (bounds.width() > m_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 (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileIndex& index = it->key;
- if (index.y() < topLeftForBounds.y()
- || index.y() > bottomRightForBounds.y()
- || index.x() < topLeftForBounds.x()
- || index.x() > bottomRightForBounds.x())
- queueTileForRemoval(index, it->value, tilesToRemove, m_tileRepaintCounts);
- }
-
- for (size_t i = 0, size = tilesToRemove.size(); i < size; ++i) {
- TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
-#if !PLATFORM(IOS)
- LayerPool::sharedPool()->addLayer(tileInfo.layer);
-#endif
- }
- }
-
- if (m_tiledScrollingIndicatorLayer)
- updateTileCoverageMap();
-
- m_visibleRectAtLastRevalidate = visibleRect;
- m_boundsAtLastRevalidate = bounds;
-}
-
-TileController::TileCohort TileController::nextTileCohort() const
-{
- if (!m_cohortList.isEmpty())
- return m_cohortList.last().cohort + 1;
-
- return 1;
-}
-
-void TileController::startedNewCohort(TileCohort cohort)
-{
- m_cohortList.append(TileCohortInfo(cohort, monotonicallyIncreasingTime()));
-#if PLATFORM(IOS)
- if (!m_isInWindow)
- tileControllerMemoryHandler().tileControllerGainedUnparentedTiles(this);
-#endif
-}
-
-TileController::TileCohort TileController::newestTileCohort() const
-{
- return m_cohortList.isEmpty() ? 0 : m_cohortList.last().cohort;
-}
-
-TileController::TileCohort TileController::oldestTileCohort() const
-{
- return m_cohortList.isEmpty() ? 0 : m_cohortList.first().cohort;
-}
-
-void TileController::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);
-}
-
-void TileController::cohortRemovalTimerFired(Timer<TileController>*)
-{
- if (m_cohortList.isEmpty()) {
- m_cohortRemovalTimer.stop();
- return;
- }
-
- double cohortLifeTimeSeconds = 2;
- double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
-
- while (!m_cohortList.isEmpty() && m_cohortList.first().creationTime < timeThreshold) {
- TileCohortInfo firstCohort = m_cohortList.takeFirst();
- removeTilesInCohort(firstCohort.cohort);
- }
-
- if (m_tiledScrollingIndicatorLayer)
- updateTileCoverageMap();
-}
-
-IntRect TileController::ensureTilesForRect(const FloatRect& rect, CoverageType newTileType)
-{
- if (m_unparentsOffscreenTiles && !m_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 = createTileLayer(tileRect);
- 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_unparentsOffscreenTiles || m_isInWindow) && !tileInfo.layer->superlayer();
-
- if (shouldParentTileLayer)
- m_tileContainerLayer->appendSublayer(tileInfo.layer.get());
- }
- }
-
- if (tilesInCohort)
- startedNewCohort(currCohort);
-
- return coverageRect;
-}
-
</del><span class="cx"> void TileController::updateTileCoverageMap()
</span><span class="cx"> {
</span><ins>+ if (!m_tiledScrollingIndicatorLayer)
+ return;
</ins><span class="cx"> FloatRect containerBounds = bounds();
</span><span class="cx"> FloatRect visibleRect = this->visibleRect();
</span><span class="cx">
</span><del>- visibleRect.intersect(scaledExposedRect());
</del><ins>+ visibleRect.intersect(tileGrid().scaledExposedRect());
</ins><span class="cx"> visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
</span><span class="cx">
</span><span class="cx"> float widthScale = 1;
</span><span class="lines">@@ -908,7 +431,7 @@
</span><span class="cx"> scale = std::min(widthScale, visibleRect.height() / containerBounds.height());
</span><span class="cx"> }
</span><span class="cx">
</span><del>- float indicatorScale = scale * m_scale;
</del><ins>+ float indicatorScale = scale * tileGrid().scale();
</ins><span class="cx"> FloatRect mapBounds = containerBounds;
</span><span class="cx"> mapBounds.scale(indicatorScale, indicatorScale);
</span><span class="cx">
</span><span class="lines">@@ -943,36 +466,18 @@
</span><span class="cx">
</span><span class="cx"> IntRect TileController::tileGridExtent() const
</span><span class="cx"> {
</span><del>- 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);
</del><ins>+ return tileGrid().extent();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> double TileController::retainedTileBackingStoreMemory() const
</span><span class="cx"> {
</span><del>- 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;
</del><ins>+ return tileGrid().retainedTileBackingStoreMemory();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Return the rect in layer coords, not tile coords.
</span><span class="cx"> IntRect TileController::tileCoverageRect() const
</span><span class="cx"> {
</span><del>- IntRect coverageRectInLayerCoords(m_primaryTileCoverageRect);
- coverageRectInLayerCoords.scale(1 / m_scale);
- return coverageRectInLayerCoords;
</del><ins>+ return tileGrid().tileCoverageRect();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PlatformCALayer* TileController::tiledScrollingIndicatorLayer()
</span><span class="lines">@@ -1005,8 +510,7 @@
</span><span class="cx">
</span><span class="cx"> m_indicatorMode = scrollingMode;
</span><span class="cx">
</span><del>- if (m_tiledScrollingIndicatorLayer)
- updateTileCoverageMap();
</del><ins>+ updateTileCoverageMap();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TileController::setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight)
</span><span class="lines">@@ -1092,62 +596,24 @@
</span><span class="cx"> return repaintCount;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TileController::drawTileMapContents(CGContextRef context, CGRect layerBounds)
</del><ins>+Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
</ins><span class="cx"> {
</span><del>- CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
- CGContextFillRect(context, layerBounds);
-
- CGFloat scaleFactor = layerBounds.size.width / bounds().width();
-
- CGFloat contextScale = scaleFactor / 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;
- if (tileInfo.hasStaleContent) {
- red = 0.25;
- green = 0.125;
- blue = 0;
- }
-
- TileCohort newestCohort = newestTileCohort();
- TileCohort oldestCohort = oldestTileCohort();
-
- if (!owningGraphicsLayer()->platformCALayerShouldAggressivelyRetainTiles(m_tileCacheLayer) && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) {
- float cohortProportion = static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort);
- CGContextSetRGBFillColor(context, red, green, blue, 1 - cohortProportion);
- } else
- CGContextSetRGBFillColor(context, red, green, blue, 1);
-
- 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);
- }
</del><ins>+ Vector<RefPtr<PlatformCALayer>> layerList(1);
+ layerList[0] = &tileGrid().containerLayer();
+ return layerList;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+unsigned TileController::numberOfUnparentedTiles() const
+{
+ return tileGrid().numberOfUnparentedTiles();
+}
+
</ins><span class="cx"> void TileController::removeUnparentedTilesNow()
</span><span class="cx"> {
</span><del>- while (!m_cohortList.isEmpty()) {
- TileCohortInfo firstCohort = m_cohortList.takeFirst();
- removeTilesInCohort(firstCohort.cohort);
- }
</del><ins>+ tileGrid().removeUnparentedTilesNow();
</ins><span class="cx">
</span><del>- if (m_tiledScrollingIndicatorLayer)
- updateTileCoverageMap();
</del><ins>+ updateTileCoverageMap();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacTileGridhfromrev166654trunkSourceWebCoreplatformgraphicscamacTileGridh"></a>
<div class="copfile"><h4>Copied: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.h (from rev 166654, trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h) (0 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.h         (rev 0)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.h        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -0,0 +1,140 @@
</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 "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Ref.h>
+
+namespace WebCore {
+
+class PlatformCALayer;
+class TileController;
+
+class TileGrid {
+ WTF_MAKE_NONCOPYABLE(TileGrid);
+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 updateTilerLayerProperties();
+
+ bool prepopulateRect(const FloatRect&);
+
+ typedef unsigned TileValidationPolicyFlags;
+ void revalidateTiles(TileValidationPolicyFlags);
+ bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
+
+ FloatRect scaledExposedRect() const;
+
+ IntRect tileCoverageRect() const;
+ IntRect extent() const;
+
+ double retainedTileBackingStoreMemory() const;
+ unsigned blankPixelCount() const;
+
+ void drawTileMapContents(CGContextRef, CGRect layerBounds);
+
+#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 adjustRectAtTileIndexForMargin(const TileIndex&, IntRect&) const;
+ void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
+
+ enum class CoverageType { PrimaryTiles, SecondaryTiles };
+ IntRect ensureTilesForRect(const FloatRect&, CoverageType);
+
+ void removeAllSecondaryTiles();
+ void removeTilesInCohort(TileCohort);
+
+ void scheduleCohortRemoval();
+ void cohortRemovalTimerFired(Timer<TileGrid>*);
+ TileCohort nextTileCohort() const;
+ void startedNewCohort(TileCohort);
+ TileCohort newestTileCohort() const;
+ TileCohort oldestTileCohort() const;
+
+ 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;
+
+ struct TileCohortInfo {
+ TileCohort cohort;
+ double creationTime; // in monotonicallyIncreasingTime().
+ TileCohortInfo(TileCohort inCohort, double inTime)
+ : cohort(inCohort)
+ , creationTime(inTime)
+ { }
+ };
+ typedef Deque<TileCohortInfo> TileCohortList;
+ TileCohortList m_cohortList;
+
+ Timer<TileGrid> m_cohortRemovalTimer;
+};
+
+}
+#endif
</ins></span></pre></div>
<a id="tagsSafari538263SourceWebCoreplatformgraphicscamacTileGridmmfromrev166654trunkSourceWebCoreplatformgraphicscamacTileGridmm"></a>
<div class="copfile"><h4>Copied: tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm (from rev 166654, trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm) (0 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm         (rev 0)
+++ tags/Safari-538.26.3/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -0,0 +1,666 @@
</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.
+ */
+
+#import "config.h"
+#import "TileGrid.h"
+
+#import "LayerPool.h"
+#import "PlatformCALayer.h"
+#import "TileController.h"
+#import <wtf/MainThread.h>
+
+#if PLATFORM(IOS)
+#import "TileControllerMemoryHandlerIOS.h"
+#endif
+
+namespace WebCore {
+
+enum TileValidationPolicyFlag {
+ PruneSecondaryTiles = 1 << 0,
+ UnparentAllTiles = 1 << 1
+};
+
+TileGrid::TileGrid(TileController& controller)
+ : m_controller(controller)
+ , m_containerLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
+ , 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::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::updateTilerLayerProperties()
+{
+ 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;
+ visibleRect.intersect(scaledExposedRect());
+
+ 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;
+}
+
+FloatRect TileGrid::scaledExposedRect() const
+{
+ FloatRect scaledExposedRect = m_controller.exposedRect();
+ scaledExposedRect.scale(1 / m_scale);
+ return scaledExposedRect;
+}
+
+bool TileGrid::prepopulateRect(const FloatRect& rect)
+{
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect rectInTileCoords(enclosingIntRect(scaledRect));
+
+ if (m_primaryTileCoverageRect.contains(rectInTileCoords))
+ return false;
+
+ m_secondaryTileCoverageRects.append(rect);
+ return true;
+}
+
+void TileGrid::adjustRectAtTileIndexForMargin(const TileIndex& tileIndex, IntRect& rect) const
+{
+ if (!m_controller.hasMargins())
+ return;
+
+ // This is a tile in the top margin.
+ if (m_controller.topMarginHeight() && tileIndex.y() < 0) {
+ rect.setY(tileIndex.y() * m_controller.topMarginHeight());
+ rect.setHeight(m_controller.topMarginHeight());
+ }
+
+ // This is a tile in the left margin.
+ if (m_controller.leftMarginWidth() && tileIndex.x() < 0) {
+ rect.setX(tileIndex.x() * m_controller.leftMarginWidth());
+ rect.setWidth(m_controller.leftMarginWidth());
+ }
+
+ TileIndex contentTopLeft;
+ TileIndex contentBottomRight;
+ getTileIndexRangeForRect(m_controller.boundsWithoutMargin(), contentTopLeft, contentBottomRight);
+
+ // This is a tile in the bottom margin.
+ if (m_controller.bottomMarginHeight() && tileIndex.y() > contentBottomRight.y())
+ rect.setHeight(m_controller.bottomMarginHeight());
+
+ // This is a tile in the right margin.
+ if (m_controller.rightMarginWidth() && tileIndex.x() > contentBottomRight.x())
+ rect.setWidth(m_controller.rightMarginWidth());
+}
+
+IntRect TileGrid::rectForTileIndex(const TileIndex& tileIndex) const
+{
+ 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);
+
+ // These rect computations assume m_tileSize is the correct size to use. However, a tile in the margin area
+ // might be a different size depending on the size of the margins. So adjustRectAtTileIndexForMargin() will
+ // fix the rect we've computed to match the margin sizes if this tile is in the margins.
+ adjustRectAtTileIndexForMargin(tileIndex, rect);
+
+ 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() / m_controller.leftMarginWidth()));
+
+ if (clampedRect.y() >= 0)
+ topLeft.setY(clampedRect.y() / tileSize.height());
+ else
+ topLeft.setY(floorf((float)clampedRect.y() / m_controller.topMarginHeight()));
+
+ 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));
+}
+
+static inline void queueTileForRemoval(const TileGrid::TileIndex& tileIndex, const TileGrid::TileInfo& tileInfo, Vector<TileGrid::TileIndex>& tilesToRemove, TileController::RepaintCountMap& repaintCounts)
+{
+ tileInfo.layer->removeFromSuperlayer();
+ repaintCounts.remove(tileInfo.layer.get());
+ tilesToRemove.append(tileIndex);
+}
+
+void TileGrid::removeAllSecondaryTiles()
+{
+ Vector<TileIndex> tilesToRemove;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if (tileInfo.cohort == VisibleTileCohort)
+ continue;
+
+ queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap());
+ }
+
+ for (size_t i = 0; i < tilesToRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+#if !PLATFORM(IOS)
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+#endif
+ }
+}
+
+void TileGrid::removeTilesInCohort(TileCohort cohort)
+{
+ ASSERT(cohort != VisibleTileCohort);
+ Vector<TileIndex> tilesToRemove;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if (tileInfo.cohort != cohort)
+ continue;
+
+ queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap());
+ }
+
+ for (size_t i = 0; i < tilesToRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+#if !PLATFORM(IOS)
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+#endif
+ }
+}
+
+void TileGrid::revalidateTiles(TileValidationPolicyFlags validationPolicy)
+{
+ FloatRect visibleRect = m_controller.visibleRect();
+ IntRect bounds = m_controller.bounds();
+
+ visibleRect.intersect(scaledExposedRect());
+
+ 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;
+
+ // 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();
+ }
+ }
+ }
+
+ 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 (size_t i = 0; i < m_secondaryTileCoverageRects.size(); ++i)
+ ensureTilesForRect(m_secondaryTileCoverageRects[i], 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 (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileIndex& index = it->key;
+ if (index.y() < topLeftForBounds.y()
+ || index.y() > bottomRightForBounds.y()
+ || index.x() < topLeftForBounds.x()
+ || index.x() > bottomRightForBounds.x())
+ queueTileForRemoval(index, it->value, tilesToRemove, m_controller.repaintCountMap());
+ }
+
+ for (size_t i = 0, size = tilesToRemove.size(); i < size; ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+#if !PLATFORM(IOS)
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+#endif
+ }
+ }
+
+ 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);
+}
+
+void TileGrid::cohortRemovalTimerFired(Timer<TileGrid>*)
+{
+ if (m_cohortList.isEmpty()) {
+ m_cohortRemovalTimer.stop();
+ return;
+ }
+
+ double cohortLifeTimeSeconds = 2;
+ double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
+
+ while (!m_cohortList.isEmpty() && m_cohortList.first().creationTime < timeThreshold) {
+ 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);
+ 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)
+{
+ 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;
+ if (tileInfo.hasStaleContent) {
+ red = 0.25;
+ green = 0.125;
+ blue = 0;
+ }
+
+ TileCohort newestCohort = newestTileCohort();
+ TileCohort oldestCohort = oldestTileCohort();
+
+ if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) {
+ float cohortProportion = static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort);
+ CGContextSetRGBFillColor(context, red, green, blue, 1 - cohortProportion);
+ } else
+ CGContextSetRGBFillColor(context, red, green, blue, 1);
+
+ 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);
+ }
+}
+
+#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="tagsSafari538263SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebKit2/ChangeLog (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebKit2/ChangeLog        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebKit2/ChangeLog        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2014-04-04 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r166654
+
+ 2014-04-02 Antti Koivisto <antti@apple.com>
+
+ Split tile grid out from TileController
+ https://bugs.webkit.org/show_bug.cgi?id=131102
+
+ Reviewed by Simon Fraser.
+
+ * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
+ (WebKit::PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking):
+ * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:
+
+2014-04-04 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r166542
</span><span class="cx">
</span><span class="cx"> 2014-03-31 Simon Fraser <simon.fraser@apple.com>
</span></span></pre></div>
<a id="tagsSafari538263SourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteTiledBackingcpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -40,10 +40,7 @@
</span><span class="cx"> : PlatformCALayerRemote(layerType, owner, context)
</span><span class="cx"> {
</span><span class="cx"> m_tileController = TileController::create(this);
</span><del>-
- m_customSublayers = adoptPtr(new PlatformCALayerList(1));
- PlatformCALayer* tileCacheTileContainerLayer = m_tileController->tileContainerLayer();
- (*m_customSublayers)[0] = tileCacheTileContainerLayer;
</del><ins>+ m_customSublayers = std::make_unique<PlatformCALayerList>(m_tileController->containerLayers());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PlatformCALayerRemoteTiledBacking::~PlatformCALayerRemoteTiledBacking()
</span></span></pre></div>
<a id="tagsSafari538263SourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteTiledBackingh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h (166804 => 166805)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h        2014-04-04 22:13:54 UTC (rev 166804)
+++ tags/Safari-538.26.3/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h        2014-04-04 22:17:40 UTC (rev 166805)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> virtual void setBorderColor(const WebCore::Color&) override;
</span><span class="cx">
</span><span class="cx"> OwnPtr<WebCore::TileController> m_tileController;
</span><del>- OwnPtr<WebCore::PlatformCALayerList> m_customSublayers;
</del><ins>+ std::unique_ptr<WebCore::PlatformCALayerList> m_customSublayers;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>
</body>
</html>