12013-10-24 Tim Horton <timothy_horton@apple.com>
2
3 Make TileController manipulate PlatformCALayers instead of CALayers
4 https://bugs.webkit.org/show_bug.cgi?id=123279
5
6 Reviewed by NOBODY (OOPS!).
7
8 In the interest of making TileController more platform-independent
9 (so that it can be used with the remote layer tree, and maybe Windows),
10 move TileController onto our PlatformCALayer abstraction instead of
11 direct manipulation of CALayers.
12
13 Some fallout from this includes getting rid of special Mac-specific
14 TileController-specific CALayer subclasses, and reworking tile
15 painting to work in a more generic way.
16
17 This is a first step, and doesn't get us all the way to a platform independent
18 TileController, but more patches are forthcoming.
19
20 No new tests, just a (largeish) refactor.
21
22 * WebCore.exp.in:
23 The signature of some methods has changed.
24
25 * WebCore.xcodeproj/project.pbxproj:
26 Remove WebTileLayer.*
27
28 * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
29 (WebCore::ScrollingTreeScrollingNodeMac::logExposedUnfilledArea):
30 Use the "isTile" key on the CALayer dictionary instead of the layer's
31 class to determine if it's a tile. TileController will set this on a tile
32 when it is created, for now.
33
34 * platform/graphics/TiledBacking.h:
35 tiledScrollingIndicatorLayer() should return a PlatformCALayer.
36
37 * platform/graphics/ca/GraphicsLayerCA.cpp:
38 (WebCore::GraphicsLayerCA::platformCALayerPaintContents):
39 * platform/graphics/ca/GraphicsLayerCA.h:
40 (WebCore::GraphicsLayerCA::platformCALayerIncrementRepaintCount):
41 * platform/graphics/ca/PlatformCALayerClient.h:
42 The PlatformCALayerClient paintContents and incrementRepaintCount callbacks
43 should include the platformCALayer that caused the callback.
44
45 * platform/graphics/ca/PlatformCALayer.h:
46 Add LayerTypeSimpleLayer, which is similar to LayerTypeWebLayer
47 except it just calls back its client to paint, instead of doing
48 complicated things with repaint rects. This is so that TileController
49 doesn't re-enter drawLayerContents when asking its GraphicsLayer
50 to paint for each PlatformCALayer (it will be entering drawLayerContents
51 for the first time for each layer). It also happens to be useful
52 for things like the tile controller overlay, which don't need
53 all that complication.
54
55 Add LayerTypeTiledBackingTileLayer, which is used simply to distinguish
56 TileController Tile layers from other LayerTypeSimpleLayers.
57
58 * platform/graphics/ca/mac/LayerPool.h:
59 * platform/graphics/ca/mac/LayerPool.mm:
60 (WebCore::LayerPool::addLayer):
61 (WebCore::LayerPool::takeLayerWithSize):
62 LayerPool should operate on PlatformCALayers now.
63
64 * platform/graphics/ca/mac/PlatformCALayerMac.h:
65 * platform/graphics/ca/mac/PlatformCALayerMac.mm:
66 (PlatformCALayerMac::PlatformCALayerMac):
67 Set the "isTile" key on the CALayer to true for TiledBackingTileLayers,
68 so that the scrolling performance logging can tell a tile apart from
69 any other layer, on the scrolling thread, without touching PlatformCALayers
70 or the TileController or any other main-thread data structures.
71
72 (PlatformCALayerMac::setEdgeAntialiasingMask): Added.
73 * platform/graphics/ca/mac/TileController.h:
74 Remove references to Objective-C classes; instead use PlatformCALayer everywhere.
75 TileController is now a PlatformCALayerClient, and the layers it owns are
76 all PlatformCALayers (and it is constructed with a PlatformCALayer, etc.).
77 Hand in the tile debug border color as a WebCore color, instead of a CGColorRef.
78 blankPixelCountForTiles() now operates on a list of PlatformLayers instead of
79 WebTileLayers specifically, since WebTileLayer is gone.
80 Make drawTileMapContents private because WebTileCacheMapLayer no longer exists.
81
82 (WebCore::TileController::platformCALayerDrawsContent):
83 All of the layers who have TileController as their client paint their contents.
84
85 (WebCore::TileController::platformCALayerContentsOpaque):
86 This will only be called for layers which paint via drawLayerContents,
87 so it's OK that we don't special-case the debugging overlay here.
88
89 * platform/graphics/ca/mac/TileController.mm:
90 Remove CALayer (WebCALayerDetails), WebTiledScrollingIndicatorLayer,
91 and a bunch of includes that we don't need anymore.
92
93 (WebCore::TileController::create):
94 (WebCore::TileController::TileController):
95 TileController is passed a PlatformCALayer for the tile cache root layer,
96 instead of a WebTiledBackingLayer. It also creates a PlatformCALayer with
97 LayerTypeLayer instead of a bare CALayer for the container layer.
98
99 (WebCore::TileController::~TileController):
100 Clear the owner of the PlatformCALayers which the TileController previously owned,
101 so they don't try to call back a destroyed TileController.
102
103 (WebCore::TileController::tileCacheLayerBoundsChanged):
104 (WebCore::TileController::setNeedsDisplay):
105 Straightforward adjustments towards use of PlatformCALayer.
106
107 (WebCore::TileController::setTileNeedsDisplayInRect):
108 Adjustments towards use of PlatformCALayer; we need FloatRects so we can
109 pass pointers to PlatformCALayer::setNeedsDisplay.
110
111 (WebCore::TileController::platformCALayerPaintContents):
112 Replace drawLayer with platformCALayerPaintContents, which will be called
113 back from our various WebSimpleLayers. If the PlatformCALayer is our
114 tiled scrolling debug indicator, paint that. Otherwise, it's a tile.
115 Make use of drawLayerContents() to paint the tile contents.
116 Make use of drawRepaintIndicator() to paint the repaint indicator if needed.
117 Move scrolling performance logging code that used to be in WebTileLayer here.
118
119 (WebCore::TileController::platformCALayerDeviceScaleFactor):
120 (WebCore::TileController::platformCALayerShowDebugBorders):
121 (WebCore::TileController::platformCALayerShowRepaintCounter):
122 Forward these to the owning GraphicsLayerCA, because it will have the right answers.
123
124 (WebCore::TileController::setScale):
125 Adjustments towards use of PlatformCALayer; remove some code that Simon
126 caused to be unused in 156291 but did not remove.
127
128 (WebCore::TileController::setAcceleratesDrawing):
129 (WebCore::TileController::setTilesOpaque):
130 (WebCore::TileController::setVisibleRect):
131 (WebCore::TileController::revalidateTiles):
132 (WebCore::TileController::setTileDebugBorderWidth):
133 (WebCore::TileController::setTileDebugBorderColor):
134 (WebCore::TileController::bounds):
135 (WebCore::TileController::blankPixelCount):
136 (WebCore::TileController::blankPixelCountForTiles):
137 (WebCore::queueTileForRemoval):
138 (WebCore::TileController::setNeedsRevalidateTiles):
139 (WebCore::TileController::ensureTilesForRect):
140 (WebCore::TileController::retainedTileBackingStoreMemory):
141 Straightforward adjustments towards use of PlatformCALayer.
142
143 (WebCore::TileController::updateTileCoverageMap):
144 Adjustments towards use of PlatformCALayer; rename backgroundColor
145 to visibleRectIndicatorColor, since it's actually a border, not a background.
146
147 (WebCore::TileController::tiledScrollingIndicatorLayer):
148 Create a LayerTypeSimpleLayer PlatformCALayer for the tiled scrolling indicator.
149 It will be asked to paint straightforwardly, like a CALayer would.
150 Create a LayerTypeLayer PlatformCALayer for the visible rect indicator.
151 It doesn't need to paint anything, so it doesn't get an owner.
152
153 (WebCore::TileController::createTileLayer):
154 When creating a new tile layer, adopt it by setting its owner.
155 Otherwise, straightforward adjustments towards use of PlatformCALayer.
156
157 (WebCore::TileController::platformCALayerIncrementRepaintCount):
158 Manage repaint counts for tiles in TileController now.
159
160 (WebCore::TileController::drawTileMapContents):
161 Adjustments towards use of PlatformCALayer.
162
163 * platform/graphics/ca/mac/WebTileLayer.h: Removed.
164 * platform/graphics/ca/mac/WebTileLayer.mm: Removed.
165 We don't need WebTileLayer anymore, tiles are now just WebSimpleLayers
166 owned by TileController. Its behavior has been moved into TileController.
167
168 * platform/graphics/ca/mac/WebTiledBackingLayer.h:
169 * platform/graphics/ca/mac/WebTiledBackingLayer.mm:
170 (-[WebTiledBackingLayer createTileController:]):
171 Add createTileController: so that the WebTiledBackingLayer's owner can
172 hand the TileController the PlatformCALayer for the WebTiledBackingLayer
173 without propagating additional usage of PlatformCALayer::platformCALayer(),
174 which we need to remove in light of the remote layer tree work.
175
176 (-[WebTiledBackingLayer setBorderColor:]):
177
178 * platform/graphics/ca/win/PlatformCALayerWin.h:
179 Add an empty implementation of setEdgeAntialiasingMask.
180 We'll probably want to implement it before adopting TileController on Windows.
181
182 * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
183 (PlatformCALayerWinInternal::displayCallback):
184 * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
185 (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerPaintContents):
186 (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerIncrementRepaintCount):
187 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
188 (WebCore::LayerClient::platformCALayerPaintContents):
189 (WebCore::LayerClient::platformCALayerIncrementRepaintCount):
190 Adjust for new parameters on PlatformCALayerClient callbacks.
191
192 * platform/graphics/mac/WebLayer.h:
193 Add WebSimpleLayer, which inherits directly from CALayer, and make
194 our standard WebLayer (which is used for compositing layers in web content)
195 inherit from that.
196
197 * platform/graphics/mac/WebLayer.mm:
198 Move most of the behavior of WebLayer onto WebSimpleLayer, except for its
199 complex painting code. That stays as an override on WebLayer.
200
201 (WebCore::drawLayerContents):
202 Use the PlatformCALayer's PlatformLayer - if it exists - to extract
203 fine-grained repaint rects. If it doesn't, we'll just use the CGContext's
204 clip rect as our single repaint rect.
205 Rename platformLayer to platformCALayer for accuracy.
206 Remove special code for CATiledLayer since we ought not use it on Mac anymore.
207
208 (WebCore::drawRepaintIndicator):
209 Factor repaint indicator code out into its own function so that TileController
210 can use it. It can't be called from drawLayerContents for TileController, since
211 the PlatformCALayer that TileController passes in to drawLayerContents is actually
212 that of the tile cache's root layer, not the tile itself.
213 Also, add a custom background color parameter so TileController can override
214 the default green color with its own standard purple.
215
216 (-[WebLayer drawInContext:]):
217 (-[WebSimpleLayer drawInContext:]):
218 * platform/graphics/mac/WebTiledLayer.mm:
219 (-[WebTiledLayer drawInContext:]):
220 Removed a param from drawLayerContents because it's trivially acquirable
221 from the PlatformCALayer.
222