Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: cc/layer_tree_host.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHost.h" 7 #include "CCLayerTreeHost.h"
8 8
9 #include "CCFontAtlas.h" 9 #include "CCFontAtlas.h"
10 #include "CCGraphicsContext.h" 10 #include "CCGraphicsContext.h"
(...skipping 16 matching lines...) Expand all
27 27
28 using namespace std; 28 using namespace std;
29 using WebKit::WebTransformationMatrix; 29 using WebKit::WebTransformationMatrix;
30 30
31 namespace { 31 namespace {
32 static int numLayerTreeInstances; 32 static int numLayerTreeInstances;
33 } 33 }
34 34
35 namespace cc { 35 namespace cc {
36 36
37 bool CCLayerTreeHost::s_needsFilterContext = false; 37 bool LayerTreeHost::s_needsFilterContext = false;
38 38
39 CCLayerTreeSettings::CCLayerTreeSettings() 39 LayerTreeSettings::LayerTreeSettings()
40 : acceleratePainting(false) 40 : acceleratePainting(false)
41 , showFPSCounter(false) 41 , showFPSCounter(false)
42 , showPlatformLayerTree(false) 42 , showPlatformLayerTree(false)
43 , showPaintRects(false) 43 , showPaintRects(false)
44 , showPropertyChangedRects(false) 44 , showPropertyChangedRects(false)
45 , showSurfaceDamageRects(false) 45 , showSurfaceDamageRects(false)
46 , showScreenSpaceRects(false) 46 , showScreenSpaceRects(false)
47 , showReplicaScreenSpaceRects(false) 47 , showReplicaScreenSpaceRects(false)
48 , showOccludingRects(false) 48 , showOccludingRects(false)
49 , renderVSyncEnabled(true) 49 , renderVSyncEnabled(true)
50 , refreshRate(0) 50 , refreshRate(0)
51 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) 51 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max())
52 , defaultTileSize(IntSize(256, 256)) 52 , defaultTileSize(IntSize(256, 256))
53 , maxUntiledLayerSize(IntSize(512, 512)) 53 , maxUntiledLayerSize(IntSize(512, 512))
54 , minimumOcclusionTrackingSize(IntSize(160, 160)) 54 , minimumOcclusionTrackingSize(IntSize(160, 160))
55 { 55 {
56 } 56 }
57 57
58 CCLayerTreeSettings::~CCLayerTreeSettings() 58 LayerTreeSettings::~LayerTreeSettings()
59 { 59 {
60 } 60 }
61 61
62 RendererCapabilities::RendererCapabilities() 62 RendererCapabilities::RendererCapabilities()
63 : bestTextureFormat(0) 63 : bestTextureFormat(0)
64 , contextHasCachedFrontBuffer(false) 64 , contextHasCachedFrontBuffer(false)
65 , usingPartialSwap(false) 65 , usingPartialSwap(false)
66 , usingAcceleratedPainting(false) 66 , usingAcceleratedPainting(false)
67 , usingSetVisibility(false) 67 , usingSetVisibility(false)
68 , usingSwapCompleteCallback(false) 68 , usingSwapCompleteCallback(false)
69 , usingGpuMemoryManager(false) 69 , usingGpuMemoryManager(false)
70 , usingDiscardFramebuffer(false) 70 , usingDiscardFramebuffer(false)
71 , usingEglImage(false) 71 , usingEglImage(false)
72 , maxTextureSize(0) 72 , maxTextureSize(0)
73 { 73 {
74 } 74 }
75 75
76 RendererCapabilities::~RendererCapabilities() 76 RendererCapabilities::~RendererCapabilities()
77 { 77 {
78 } 78 }
79 79
80 bool CCLayerTreeHost::anyLayerTreeHostInstanceExists() 80 bool LayerTreeHost::anyLayerTreeHostInstanceExists()
81 { 81 {
82 return numLayerTreeInstances > 0; 82 return numLayerTreeInstances > 0;
83 } 83 }
84 84
85 scoped_ptr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* clien t, const CCLayerTreeSettings& settings) 85 scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con st LayerTreeSettings& settings)
86 { 86 {
87 scoped_ptr<CCLayerTreeHost> layerTreeHost(new CCLayerTreeHost(client, settin gs)); 87 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings)) ;
88 if (!layerTreeHost->initialize()) 88 if (!layerTreeHost->initialize())
89 return scoped_ptr<CCLayerTreeHost>(); 89 return scoped_ptr<LayerTreeHost>();
90 return layerTreeHost.Pass(); 90 return layerTreeHost.Pass();
91 } 91 }
92 92
93 CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCLayerTre eSettings& settings) 93 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting s& settings)
94 : m_animating(false) 94 : m_animating(false)
95 , m_needsAnimateLayers(false) 95 , m_needsAnimateLayers(false)
96 , m_client(client) 96 , m_client(client)
97 , m_commitNumber(0) 97 , m_commitNumber(0)
98 , m_renderingStats() 98 , m_renderingStats()
99 , m_rendererInitialized(false) 99 , m_rendererInitialized(false)
100 , m_contextLost(false) 100 , m_contextLost(false)
101 , m_numTimesRecreateShouldFail(0) 101 , m_numTimesRecreateShouldFail(0)
102 , m_numFailedRecreateAttempts(0) 102 , m_numFailedRecreateAttempts(0)
103 , m_settings(settings) 103 , m_settings(settings)
104 , m_deviceScaleFactor(1) 104 , m_deviceScaleFactor(1)
105 , m_visible(true) 105 , m_visible(true)
106 , m_pageScaleFactor(1) 106 , m_pageScaleFactor(1)
107 , m_minPageScaleFactor(1) 107 , m_minPageScaleFactor(1)
108 , m_maxPageScaleFactor(1) 108 , m_maxPageScaleFactor(1)
109 , m_triggerIdleUpdates(true) 109 , m_triggerIdleUpdates(true)
110 , m_backgroundColor(SK_ColorWHITE) 110 , m_backgroundColor(SK_ColorWHITE)
111 , m_hasTransparentBackground(false) 111 , m_hasTransparentBackground(false)
112 , m_partialTextureUpdateRequests(0) 112 , m_partialTextureUpdateRequests(0)
113 { 113 {
114 ASSERT(CCProxy::isMainThread()); 114 ASSERT(Proxy::isMainThread());
115 numLayerTreeInstances++; 115 numLayerTreeInstances++;
116 } 116 }
117 117
118 bool CCLayerTreeHost::initialize() 118 bool LayerTreeHost::initialize()
119 { 119 {
120 TRACE_EVENT0("cc", "CCLayerTreeHost::initialize"); 120 TRACE_EVENT0("cc", "LayerTreeHost::initialize");
121 121
122 if (CCProxy::hasImplThread()) 122 if (Proxy::hasImplThread())
123 m_proxy = CCThreadProxy::create(this); 123 m_proxy = ThreadProxy::create(this);
124 else 124 else
125 m_proxy = CCSingleThreadProxy::create(this); 125 m_proxy = SingleThreadProxy::create(this);
126 m_proxy->start(); 126 m_proxy->start();
127 127
128 return m_proxy->initializeContext(); 128 return m_proxy->initializeContext();
129 } 129 }
130 130
131 CCLayerTreeHost::~CCLayerTreeHost() 131 LayerTreeHost::~LayerTreeHost()
132 { 132 {
133 if (m_rootLayer) 133 if (m_rootLayer)
134 m_rootLayer->setLayerTreeHost(0); 134 m_rootLayer->setLayerTreeHost(0);
135 ASSERT(CCProxy::isMainThread()); 135 ASSERT(Proxy::isMainThread());
136 TRACE_EVENT0("cc", "CCLayerTreeHost::~CCLayerTreeHost"); 136 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
137 ASSERT(m_proxy.get()); 137 ASSERT(m_proxy.get());
138 m_proxy->stop(); 138 m_proxy->stop();
139 m_proxy.reset(); 139 m_proxy.reset();
140 numLayerTreeInstances--; 140 numLayerTreeInstances--;
141 RateLimiterMap::iterator it = m_rateLimiters.begin(); 141 RateLimiterMap::iterator it = m_rateLimiters.begin();
142 if (it != m_rateLimiters.end()) 142 if (it != m_rateLimiters.end())
143 it->second->stop(); 143 it->second->stop();
144 } 144 }
145 145
146 void CCLayerTreeHost::setSurfaceReady() 146 void LayerTreeHost::setSurfaceReady()
147 { 147 {
148 m_proxy->setSurfaceReady(); 148 m_proxy->setSurfaceReady();
149 } 149 }
150 150
151 void CCLayerTreeHost::initializeRenderer() 151 void LayerTreeHost::initializeRenderer()
152 { 152 {
153 TRACE_EVENT0("cc", "CCLayerTreeHost::initializeRenderer"); 153 TRACE_EVENT0("cc", "LayerTreeHost::initializeRenderer");
154 if (!m_proxy->initializeRenderer()) { 154 if (!m_proxy->initializeRenderer()) {
155 // Uh oh, better tell the client that we can't do anything with this con text. 155 // Uh oh, better tell the client that we can't do anything with this con text.
156 m_client->didRecreateOutputSurface(false); 156 m_client->didRecreateOutputSurface(false);
157 return; 157 return;
158 } 158 }
159 159
160 // Update m_settings based on capabilities that we got back from the rendere r. 160 // Update m_settings based on capabilities that we got back from the rendere r.
161 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler atedPainting; 161 m_settings.acceleratePainting = m_proxy->rendererCapabilities().usingAcceler atedPainting;
162 162
163 // Update m_settings based on partial update capability. 163 // Update m_settings based on partial update capability.
164 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate s, m_proxy->maxPartialTextureUpdates()); 164 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdate s, m_proxy->maxPartialTextureUpdates());
165 165
166 m_contentsTextureManager = CCPrioritizedTextureManager::create(0, m_proxy->r endererCapabilities().maxTextureSize, CCRenderer::ContentPool); 166 m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->ren dererCapabilities().maxTextureSize, Renderer::ContentPool);
167 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize (), GraphicsContext3D::RGBA); 167 m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(IntSize (), GraphicsContext3D::RGBA);
168 168
169 m_rendererInitialized = true; 169 m_rendererInitialized = true;
170 170
171 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(), m_proxy->rendererCapabilities().maxTextureSize), 171 m_settings.defaultTileSize = IntSize(min(m_settings.defaultTileSize.width(), m_proxy->rendererCapabilities().maxTextureSize),
172 min(m_settings.defaultTileSize.height() , m_proxy->rendererCapabilities().maxTextureSize)); 172 min(m_settings.defaultTileSize.height() , m_proxy->rendererCapabilities().maxTextureSize));
173 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize. width(), m_proxy->rendererCapabilities().maxTextureSize), 173 m_settings.maxUntiledLayerSize = IntSize(min(m_settings.maxUntiledLayerSize. width(), m_proxy->rendererCapabilities().maxTextureSize),
174 min(m_settings.maxUntiledLayerSize. height(), m_proxy->rendererCapabilities().maxTextureSize)); 174 min(m_settings.maxUntiledLayerSize. height(), m_proxy->rendererCapabilities().maxTextureSize));
175 } 175 }
176 176
177 CCLayerTreeHost::RecreateResult CCLayerTreeHost::recreateContext() 177 LayerTreeHost::RecreateResult LayerTreeHost::recreateContext()
178 { 178 {
179 TRACE_EVENT0("cc", "CCLayerTreeHost::recreateContext"); 179 TRACE_EVENT0("cc", "LayerTreeHost::recreateContext");
180 ASSERT(m_contextLost); 180 ASSERT(m_contextLost);
181 181
182 bool recreated = false; 182 bool recreated = false;
183 if (!m_numTimesRecreateShouldFail) 183 if (!m_numTimesRecreateShouldFail)
184 recreated = m_proxy->recreateContext(); 184 recreated = m_proxy->recreateContext();
185 else 185 else
186 m_numTimesRecreateShouldFail--; 186 m_numTimesRecreateShouldFail--;
187 187
188 if (recreated) { 188 if (recreated) {
189 m_client->didRecreateOutputSurface(true); 189 m_client->didRecreateOutputSurface(true);
190 m_contextLost = false; 190 m_contextLost = false;
191 return RecreateSucceeded; 191 return RecreateSucceeded;
192 } 192 }
193 193
194 // Tolerate a certain number of recreation failures to work around races 194 // Tolerate a certain number of recreation failures to work around races
195 // in the context-lost machinery. 195 // in the context-lost machinery.
196 m_numFailedRecreateAttempts++; 196 m_numFailedRecreateAttempts++;
197 if (m_numFailedRecreateAttempts < 5) { 197 if (m_numFailedRecreateAttempts < 5) {
198 // FIXME: The single thread does not self-schedule context 198 // FIXME: The single thread does not self-schedule context
199 // recreation. So force another recreation attempt to happen by requesti ng 199 // recreation. So force another recreation attempt to happen by requesti ng
200 // another commit. 200 // another commit.
201 if (!CCProxy::hasImplThread()) 201 if (!Proxy::hasImplThread())
202 setNeedsCommit(); 202 setNeedsCommit();
203 return RecreateFailedButTryAgain; 203 return RecreateFailedButTryAgain;
204 } 204 }
205 205
206 // We have tried too many times to recreate the context. Tell the host to fa ll 206 // We have tried too many times to recreate the context. Tell the host to fa ll
207 // back to software rendering. 207 // back to software rendering.
208 m_client->didRecreateOutputSurface(false); 208 m_client->didRecreateOutputSurface(false);
209 return RecreateFailedAndGaveUp; 209 return RecreateFailedAndGaveUp;
210 } 210 }
211 211
212 void CCLayerTreeHost::deleteContentsTexturesOnImplThread(CCResourceProvider* res ourceProvider) 212 void LayerTreeHost::deleteContentsTexturesOnImplThread(ResourceProvider* resourc eProvider)
213 { 213 {
214 ASSERT(CCProxy::isImplThread()); 214 ASSERT(Proxy::isImplThread());
215 if (m_rendererInitialized) 215 if (m_rendererInitialized)
216 m_contentsTextureManager->clearAllMemory(resourceProvider); 216 m_contentsTextureManager->clearAllMemory(resourceProvider);
217 } 217 }
218 218
219 void CCLayerTreeHost::acquireLayerTextures() 219 void LayerTreeHost::acquireLayerTextures()
220 { 220 {
221 ASSERT(CCProxy::isMainThread()); 221 ASSERT(Proxy::isMainThread());
222 m_proxy->acquireLayerTextures(); 222 m_proxy->acquireLayerTextures();
223 } 223 }
224 224
225 void CCLayerTreeHost::updateAnimations(double monotonicFrameBeginTime) 225 void LayerTreeHost::updateAnimations(double monotonicFrameBeginTime)
226 { 226 {
227 m_animating = true; 227 m_animating = true;
228 m_client->animate(monotonicFrameBeginTime); 228 m_client->animate(monotonicFrameBeginTime);
229 animateLayers(monotonicFrameBeginTime); 229 animateLayers(monotonicFrameBeginTime);
230 m_animating = false; 230 m_animating = false;
231 231
232 m_renderingStats.numAnimationFrames++; 232 m_renderingStats.numAnimationFrames++;
233 } 233 }
234 234
235 void CCLayerTreeHost::layout() 235 void LayerTreeHost::layout()
236 { 236 {
237 m_client->layout(); 237 m_client->layout();
238 } 238 }
239 239
240 void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) 240 void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl)
241 { 241 {
242 ASSERT(CCProxy::isImplThread()); 242 ASSERT(Proxy::isImplThread());
243 TRACE_EVENT0("cc", "CCLayerTreeHost::commitTo"); 243 TRACE_EVENT0("cc", "LayerTreeHost::commitTo");
244 } 244 }
245 245
246 // This function commits the CCLayerTreeHost to an impl tree. When modifying 246 // This function commits the LayerTreeHost to an impl tree. When modifying
247 // this function, keep in mind that the function *runs* on the impl thread! Any 247 // this function, keep in mind that the function *runs* on the impl thread! Any
248 // code that is logically a main thread operation, e.g. deletion of a LayerChrom ium, 248 // code that is logically a main thread operation, e.g. deletion of a Layer,
249 // should be delayed until the CCLayerTreeHost::commitComplete, which will run 249 // should be delayed until the LayerTreeHost::commitComplete, which will run
250 // after the commit, but on the main thread. 250 // after the commit, but on the main thread.
251 void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl) 251 void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
252 { 252 {
253 ASSERT(CCProxy::isImplThread()); 253 ASSERT(Proxy::isImplThread());
254 254
255 m_contentsTextureManager->updateBackingsInDrawingImplTree(); 255 m_contentsTextureManager->updateBackingsInDrawingImplTree();
256 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); 256 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider());
257 257
258 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostI mpl->detachLayerTree(), hostImpl)); 258 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostI mpl->detachLayerTree(), hostImpl));
259 259
260 if (m_rootLayer && m_hudLayer) 260 if (m_rootLayer && m_hudLayer)
261 hostImpl->setHudLayer(static_cast<CCHeadsUpDisplayLayerImpl*>(CCLayerTre eHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); 261 hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHos tCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id())));
262 else 262 else
263 hostImpl->setHudLayer(0); 263 hostImpl->setHudLayer(0);
264 264
265 // We may have added an animation during the tree sync. This will cause both layer tree hosts 265 // We may have added an animation during the tree sync. This will cause both layer tree hosts
266 // to visit their controllers. 266 // to visit their controllers.
267 if (rootLayer() && m_needsAnimateLayers) 267 if (rootLayer() && m_needsAnimateLayers)
268 hostImpl->setNeedsAnimateLayers(); 268 hostImpl->setNeedsAnimateLayers();
269 269
270 hostImpl->setSourceFrameNumber(commitNumber()); 270 hostImpl->setSourceFrameNumber(commitNumber());
271 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); 271 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize());
272 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); 272 hostImpl->setDeviceScaleFactor(deviceScaleFactor());
273 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor); 273 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto r, m_maxPageScaleFactor);
274 hostImpl->setBackgroundColor(m_backgroundColor); 274 hostImpl->setBackgroundColor(m_backgroundColor);
275 hostImpl->setHasTransparentBackground(m_hasTransparentBackground); 275 hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
276 276
277 m_commitNumber++; 277 m_commitNumber++;
278 } 278 }
279 279
280 void CCLayerTreeHost::setFontAtlas(scoped_ptr<CCFontAtlas> fontAtlas) 280 void LayerTreeHost::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas)
281 { 281 {
282 m_fontAtlas = fontAtlas.Pass(); 282 m_fontAtlas = fontAtlas.Pass();
283 setNeedsCommit(); 283 setNeedsCommit();
284 } 284 }
285 285
286 void CCLayerTreeHost::willCommit() 286 void LayerTreeHost::willCommit()
287 { 287 {
288 m_client->willCommit(); 288 m_client->willCommit();
289 if (m_rootLayer && m_settings.showDebugInfo()) { 289 if (m_rootLayer && m_settings.showDebugInfo()) {
290 if (!m_hudLayer) 290 if (!m_hudLayer)
291 m_hudLayer = HeadsUpDisplayLayerChromium::create(); 291 m_hudLayer = HeadsUpDisplayLayer::create();
292 292
293 if (m_fontAtlas.get()) 293 if (m_fontAtlas.get())
294 m_hudLayer->setFontAtlas(m_fontAtlas.Pass()); 294 m_hudLayer->setFontAtlas(m_fontAtlas.Pass());
295 295
296 if (!m_hudLayer->parent()) 296 if (!m_hudLayer->parent())
297 m_rootLayer->addChild(m_hudLayer); 297 m_rootLayer->addChild(m_hudLayer);
298 } 298 }
299 } 299 }
300 300
301 void CCLayerTreeHost::commitComplete() 301 void LayerTreeHost::commitComplete()
302 { 302 {
303 m_deleteTextureAfterCommitList.clear(); 303 m_deleteTextureAfterCommitList.clear();
304 m_client->didCommit(); 304 m_client->didCommit();
305 } 305 }
306 306
307 scoped_ptr<CCGraphicsContext> CCLayerTreeHost::createContext() 307 scoped_ptr<GraphicsContext> LayerTreeHost::createContext()
308 { 308 {
309 return m_client->createOutputSurface(); 309 return m_client->createOutputSurface();
310 } 310 }
311 311
312 scoped_ptr<CCInputHandler> CCLayerTreeHost::createInputHandler() 312 scoped_ptr<InputHandler> LayerTreeHost::createInputHandler()
313 { 313 {
314 return m_client->createInputHandler(); 314 return m_client->createInputHandler();
315 } 315 }
316 316
317 scoped_ptr<CCLayerTreeHostImpl> CCLayerTreeHost::createLayerTreeHostImpl(CCLayer TreeHostImplClient* client) 317 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHo stImplClient* client)
318 { 318 {
319 return CCLayerTreeHostImpl::create(m_settings, client); 319 return LayerTreeHostImpl::create(m_settings, client);
320 } 320 }
321 321
322 void CCLayerTreeHost::didLoseContext() 322 void LayerTreeHost::didLoseContext()
323 { 323 {
324 TRACE_EVENT0("cc", "CCLayerTreeHost::didLoseContext"); 324 TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext");
325 ASSERT(CCProxy::isMainThread()); 325 ASSERT(Proxy::isMainThread());
326 m_contextLost = true; 326 m_contextLost = true;
327 m_numFailedRecreateAttempts = 0; 327 m_numFailedRecreateAttempts = 0;
328 setNeedsCommit(); 328 setNeedsCommit();
329 } 329 }
330 330
331 bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect) 331 bool LayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect)
332 { 332 {
333 m_triggerIdleUpdates = false; 333 m_triggerIdleUpdates = false;
334 bool ret = m_proxy->compositeAndReadback(pixels, rect); 334 bool ret = m_proxy->compositeAndReadback(pixels, rect);
335 m_triggerIdleUpdates = true; 335 m_triggerIdleUpdates = true;
336 return ret; 336 return ret;
337 } 337 }
338 338
339 void CCLayerTreeHost::finishAllRendering() 339 void LayerTreeHost::finishAllRendering()
340 { 340 {
341 if (!m_rendererInitialized) 341 if (!m_rendererInitialized)
342 return; 342 return;
343 m_proxy->finishAllRendering(); 343 m_proxy->finishAllRendering();
344 } 344 }
345 345
346 void CCLayerTreeHost::renderingStats(CCRenderingStats* stats) const 346 void LayerTreeHost::renderingStats(RenderingStats* stats) const
347 { 347 {
348 *stats = m_renderingStats; 348 *stats = m_renderingStats;
349 m_proxy->renderingStats(stats); 349 m_proxy->renderingStats(stats);
350 } 350 }
351 351
352 const RendererCapabilities& CCLayerTreeHost::rendererCapabilities() const 352 const RendererCapabilities& LayerTreeHost::rendererCapabilities() const
353 { 353 {
354 return m_proxy->rendererCapabilities(); 354 return m_proxy->rendererCapabilities();
355 } 355 }
356 356
357 void CCLayerTreeHost::setNeedsAnimate() 357 void LayerTreeHost::setNeedsAnimate()
358 { 358 {
359 ASSERT(CCProxy::hasImplThread()); 359 ASSERT(Proxy::hasImplThread());
360 m_proxy->setNeedsAnimate(); 360 m_proxy->setNeedsAnimate();
361 } 361 }
362 362
363 void CCLayerTreeHost::setNeedsCommit() 363 void LayerTreeHost::setNeedsCommit()
364 { 364 {
365 m_proxy->setNeedsCommit(); 365 m_proxy->setNeedsCommit();
366 } 366 }
367 367
368 void CCLayerTreeHost::setNeedsRedraw() 368 void LayerTreeHost::setNeedsRedraw()
369 { 369 {
370 m_proxy->setNeedsRedraw(); 370 m_proxy->setNeedsRedraw();
371 if (!CCThreadProxy::implThread()) 371 if (!ThreadProxy::implThread())
372 m_client->scheduleComposite(); 372 m_client->scheduleComposite();
373 } 373 }
374 374
375 bool CCLayerTreeHost::commitRequested() const 375 bool LayerTreeHost::commitRequested() const
376 { 376 {
377 return m_proxy->commitRequested(); 377 return m_proxy->commitRequested();
378 } 378 }
379 379
380 void CCLayerTreeHost::setAnimationEvents(scoped_ptr<CCAnimationEventsVector> eve nts, double wallClockTime) 380 void LayerTreeHost::setAnimationEvents(scoped_ptr<AnimationEventsVector> events, double wallClockTime)
381 { 381 {
382 ASSERT(CCThreadProxy::isMainThread()); 382 ASSERT(ThreadProxy::isMainThread());
383 setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime) ; 383 setAnimationEventsRecursive(*events.get(), m_rootLayer.get(), wallClockTime) ;
384 } 384 }
385 385
386 void CCLayerTreeHost::didAddAnimation() 386 void LayerTreeHost::didAddAnimation()
387 { 387 {
388 m_needsAnimateLayers = true; 388 m_needsAnimateLayers = true;
389 m_proxy->didAddAnimation(); 389 m_proxy->didAddAnimation();
390 } 390 }
391 391
392 void CCLayerTreeHost::setRootLayer(scoped_refptr<LayerChromium> rootLayer) 392 void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer)
393 { 393 {
394 if (m_rootLayer == rootLayer) 394 if (m_rootLayer == rootLayer)
395 return; 395 return;
396 396
397 if (m_rootLayer) 397 if (m_rootLayer)
398 m_rootLayer->setLayerTreeHost(0); 398 m_rootLayer->setLayerTreeHost(0);
399 m_rootLayer = rootLayer; 399 m_rootLayer = rootLayer;
400 if (m_rootLayer) 400 if (m_rootLayer)
401 m_rootLayer->setLayerTreeHost(this); 401 m_rootLayer->setLayerTreeHost(this);
402 402
403 if (m_hudLayer) 403 if (m_hudLayer)
404 m_hudLayer->removeFromParent(); 404 m_hudLayer->removeFromParent();
405 405
406 setNeedsCommit(); 406 setNeedsCommit();
407 } 407 }
408 408
409 void CCLayerTreeHost::setViewportSize(const IntSize& layoutViewportSize, const I ntSize& deviceViewportSize) 409 void LayerTreeHost::setViewportSize(const IntSize& layoutViewportSize, const Int Size& deviceViewportSize)
410 { 410 {
411 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) 411 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize)
412 return; 412 return;
413 413
414 m_layoutViewportSize = layoutViewportSize; 414 m_layoutViewportSize = layoutViewportSize;
415 m_deviceViewportSize = deviceViewportSize; 415 m_deviceViewportSize = deviceViewportSize;
416 416
417 setNeedsCommit(); 417 setNeedsCommit();
418 } 418 }
419 419
420 void CCLayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float m inPageScaleFactor, float maxPageScaleFactor) 420 void LayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float min PageScaleFactor, float maxPageScaleFactor)
421 { 421 {
422 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor) 422 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor)
423 return; 423 return;
424 424
425 m_pageScaleFactor = pageScaleFactor; 425 m_pageScaleFactor = pageScaleFactor;
426 m_minPageScaleFactor = minPageScaleFactor; 426 m_minPageScaleFactor = minPageScaleFactor;
427 m_maxPageScaleFactor = maxPageScaleFactor; 427 m_maxPageScaleFactor = maxPageScaleFactor;
428 setNeedsCommit(); 428 setNeedsCommit();
429 } 429 }
430 430
431 void CCLayerTreeHost::setVisible(bool visible) 431 void LayerTreeHost::setVisible(bool visible)
432 { 432 {
433 if (m_visible == visible) 433 if (m_visible == visible)
434 return; 434 return;
435 m_visible = visible; 435 m_visible = visible;
436 m_proxy->setVisible(visible); 436 m_proxy->setVisible(visible);
437 } 437 }
438 438
439 void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, boo l useAnchor, float scale, double durationSec) 439 void LayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
440 { 440 {
441 m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationS ec); 441 m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationS ec);
442 } 442 }
443 443
444 void CCLayerTreeHost::loseContext(int numTimes) 444 void LayerTreeHost::loseContext(int numTimes)
445 { 445 {
446 TRACE_EVENT1("cc", "CCLayerTreeHost::loseCompositorContext", "numTimes", num Times); 446 TRACE_EVENT1("cc", "LayerTreeHost::loseCompositorContext", "numTimes", numTi mes);
447 m_numTimesRecreateShouldFail = numTimes - 1; 447 m_numTimesRecreateShouldFail = numTimes - 1;
448 m_proxy->loseContext(); 448 m_proxy->loseContext();
449 } 449 }
450 450
451 CCPrioritizedTextureManager* CCLayerTreeHost::contentsTextureManager() const 451 PrioritizedTextureManager* LayerTreeHost::contentsTextureManager() const
452 { 452 {
453 return m_contentsTextureManager.get(); 453 return m_contentsTextureManager.get();
454 } 454 }
455 455
456 void CCLayerTreeHost::composite() 456 void LayerTreeHost::composite()
457 { 457 {
458 ASSERT(!CCThreadProxy::implThread()); 458 ASSERT(!ThreadProxy::implThread());
459 static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately(); 459 static_cast<SingleThreadProxy*>(m_proxy.get())->compositeImmediately();
460 } 460 }
461 461
462 void CCLayerTreeHost::scheduleComposite() 462 void LayerTreeHost::scheduleComposite()
463 { 463 {
464 m_client->scheduleComposite(); 464 m_client->scheduleComposite();
465 } 465 }
466 466
467 bool CCLayerTreeHost::initializeRendererIfNeeded() 467 bool LayerTreeHost::initializeRendererIfNeeded()
468 { 468 {
469 if (!m_rendererInitialized) { 469 if (!m_rendererInitialized) {
470 initializeRenderer(); 470 initializeRenderer();
471 // If we couldn't initialize, then bail since we're returning to softwar e mode. 471 // If we couldn't initialize, then bail since we're returning to softwar e mode.
472 if (!m_rendererInitialized) 472 if (!m_rendererInitialized)
473 return false; 473 return false;
474 } 474 }
475 if (m_contextLost) { 475 if (m_contextLost) {
476 if (recreateContext() != RecreateSucceeded) 476 if (recreateContext() != RecreateSucceeded)
477 return false; 477 return false;
478 } 478 }
479 return true; 479 return true;
480 } 480 }
481 481
482 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll ocationLimitBytes) 482 void LayerTreeHost::updateLayers(TextureUpdateQueue& queue, size_t memoryAllocat ionLimitBytes)
483 { 483 {
484 ASSERT(m_rendererInitialized); 484 ASSERT(m_rendererInitialized);
485 ASSERT(memoryAllocationLimitBytes); 485 ASSERT(memoryAllocationLimitBytes);
486 486
487 if (!rootLayer()) 487 if (!rootLayer())
488 return; 488 return;
489 489
490 if (layoutViewportSize().isEmpty()) 490 if (layoutViewportSize().isEmpty())
491 return; 491 return;
492 492
493 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes) ; 493 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes) ;
494 494
495 updateLayers(rootLayer(), queue); 495 updateLayers(rootLayer(), queue);
496 } 496 }
497 497
498 static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageSc aleFactor) 498 static void setScale(Layer* layer, float deviceScaleFactor, float pageScaleFacto r)
499 { 499 {
500 if (layer->boundsContainPageScale()) 500 if (layer->boundsContainPageScale())
501 layer->setContentsScale(deviceScaleFactor); 501 layer->setContentsScale(deviceScaleFactor);
502 else 502 else
503 layer->setContentsScale(deviceScaleFactor * pageScaleFactor); 503 layer->setContentsScale(deviceScaleFactor * pageScaleFactor);
504 } 504 }
505 505
506 static LayerChromium* findFirstScrollableLayer(LayerChromium* layer) 506 static Layer* findFirstScrollableLayer(Layer* layer)
507 { 507 {
508 if (!layer) 508 if (!layer)
509 return 0; 509 return 0;
510 510
511 if (layer->scrollable()) 511 if (layer->scrollable())
512 return layer; 512 return layer;
513 513
514 for (size_t i = 0; i < layer->children().size(); ++i) { 514 for (size_t i = 0; i < layer->children().size(); ++i) {
515 LayerChromium* found = findFirstScrollableLayer(layer->children()[i].get ()); 515 Layer* found = findFirstScrollableLayer(layer->children()[i].get());
516 if (found) 516 if (found)
517 return found; 517 return found;
518 } 518 }
519 519
520 return 0; 520 return 0;
521 } 521 }
522 522
523 static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, floa t pageScaleFactor) 523 static void updateLayerScale(Layer* layer, float deviceScaleFactor, float pageSc aleFactor)
524 { 524 {
525 setScale(layer, deviceScaleFactor, pageScaleFactor); 525 setScale(layer, deviceScaleFactor, pageScaleFactor);
526 526
527 LayerChromium* maskLayer = layer->maskLayer(); 527 Layer* maskLayer = layer->maskLayer();
528 if (maskLayer) 528 if (maskLayer)
529 setScale(maskLayer, deviceScaleFactor, pageScaleFactor); 529 setScale(maskLayer, deviceScaleFactor, pageScaleFactor);
530 530
531 LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLaye r()->maskLayer() : 0; 531 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0;
532 if (replicaMaskLayer) 532 if (replicaMaskLayer)
533 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor); 533 setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor);
534 534
535 const std::vector<scoped_refptr<LayerChromium> >& children = layer->children (); 535 const std::vector<scoped_refptr<Layer> >& children = layer->children();
536 for (unsigned int i = 0; i < children.size(); ++i) 536 for (unsigned int i = 0; i < children.size(); ++i)
537 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor); 537 updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor);
538 } 538 }
539 539
540 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueu e& queue) 540 void LayerTreeHost::updateLayers(Layer* rootLayer, TextureUpdateQueue& queue)
541 { 541 {
542 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers"); 542 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers");
543 543
544 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor); 544 updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor);
545 545
546 LayerList updateList; 546 LayerList updateList;
547 547
548 { 548 {
549 if (CCSettings::pageScalePinchZoomEnabled()) { 549 if (Settings::pageScalePinchZoomEnabled()) {
550 LayerChromium* rootScroll = findFirstScrollableLayer(rootLayer); 550 Layer* rootScroll = findFirstScrollableLayer(rootLayer);
551 if (rootScroll) 551 if (rootScroll)
552 rootScroll->setImplTransform(m_implTransform); 552 rootScroll->setImplTransform(m_implTransform);
553 } 553 }
554 554
555 TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers::calcDrawEtc"); 555 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc");
556 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewport Size(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList); 556 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSi ze(), m_deviceScaleFactor, rendererCapabilities().maxTextureSize, updateList);
557 } 557 }
558 558
559 // Reset partial texture update requests. 559 // Reset partial texture update requests.
560 m_partialTextureUpdateRequests = 0; 560 m_partialTextureUpdateRequests = 0;
561 561
562 bool needMoreUpdates = paintLayerContents(updateList, queue); 562 bool needMoreUpdates = paintLayerContents(updateList, queue);
563 if (m_triggerIdleUpdates && needMoreUpdates) 563 if (m_triggerIdleUpdates && needMoreUpdates)
564 setNeedsCommit(); 564 setNeedsCommit();
565 565
566 for (size_t i = 0; i < updateList.size(); ++i) 566 for (size_t i = 0; i < updateList.size(); ++i)
567 updateList[i]->clearRenderSurface(); 567 updateList[i]->clearRenderSurface();
568 } 568 }
569 569
570 void CCLayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes) 570 void LayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes)
571 { 571 {
572 // Surfaces have a place holder for their memory since they are managed 572 // Surfaces have a place holder for their memory since they are managed
573 // independantly but should still be tracked and reduce other memory usage. 573 // independantly but should still be tracked and reduce other memory usage.
574 m_surfaceMemoryPlaceholder->setTextureManager(m_contentsTextureManager.get() ); 574 m_surfaceMemoryPlaceholder->setTextureManager(m_contentsTextureManager.get() );
575 m_surfaceMemoryPlaceholder->setRequestPriority(CCPriorityCalculator::renderS urfacePriority()); 575 m_surfaceMemoryPlaceholder->setRequestPriority(PriorityCalculator::renderSur facePriority());
576 m_surfaceMemoryPlaceholder->setToSelfManagedMemoryPlaceholder(surfaceMemoryB ytes); 576 m_surfaceMemoryPlaceholder->setToSelfManagedMemoryPlaceholder(surfaceMemoryB ytes);
577 } 577 }
578 578
579 void CCLayerTreeHost::setPrioritiesForLayers(const LayerList& updateList) 579 void LayerTreeHost::setPrioritiesForLayers(const LayerList& updateList)
580 { 580 {
581 // Use BackToFront since it's cheap and this isn't order-dependent. 581 // Use BackToFront since it's cheap and this isn't order-dependent.
582 typedef CCLayerIterator<LayerChromium, LayerList, RenderSurfaceChromium, CCL ayerIteratorActions::BackToFront> CCLayerIteratorType; 582 typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions: :BackToFront> LayerIteratorType;
583 583
584 CCPriorityCalculator calculator; 584 PriorityCalculator calculator;
585 CCLayerIteratorType end = CCLayerIteratorType::end(&updateList); 585 LayerIteratorType end = LayerIteratorType::end(&updateList);
586 for (CCLayerIteratorType it = CCLayerIteratorType::begin(&updateList); it != end; ++it) { 586 for (LayerIteratorType it = LayerIteratorType::begin(&updateList); it != end ; ++it) {
587 if (it.representsItself()) 587 if (it.representsItself())
588 it->setTexturePriorities(calculator); 588 it->setTexturePriorities(calculator);
589 else if (it.representsTargetRenderSurface()) { 589 else if (it.representsTargetRenderSurface()) {
590 if (it->maskLayer()) 590 if (it->maskLayer())
591 it->maskLayer()->setTexturePriorities(calculator); 591 it->maskLayer()->setTexturePriorities(calculator);
592 if (it->replicaLayer() && it->replicaLayer()->maskLayer()) 592 if (it->replicaLayer() && it->replicaLayer()->maskLayer())
593 it->replicaLayer()->maskLayer()->setTexturePriorities(calculator ); 593 it->replicaLayer()->maskLayer()->setTexturePriorities(calculator );
594 } 594 }
595 } 595 }
596 } 596 }
597 597
598 void CCLayerTreeHost::prioritizeTextures(const LayerList& renderSurfaceLayerList , CCOverdrawMetrics& metrics) 598 void LayerTreeHost::prioritizeTextures(const LayerList& renderSurfaceLayerList, OverdrawMetrics& metrics)
599 { 599 {
600 m_contentsTextureManager->clearPriorities(); 600 m_contentsTextureManager->clearPriorities();
601 601
602 size_t memoryForRenderSurfacesMetric = calculateMemoryForRenderSurfaces(rend erSurfaceLayerList); 602 size_t memoryForRenderSurfacesMetric = calculateMemoryForRenderSurfaces(rend erSurfaceLayerList);
603 603
604 setPrioritiesForLayers(renderSurfaceLayerList); 604 setPrioritiesForLayers(renderSurfaceLayerList);
605 setPrioritiesForSurfaces(memoryForRenderSurfacesMetric); 605 setPrioritiesForSurfaces(memoryForRenderSurfacesMetric);
606 606
607 metrics.didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAbo veCutoffBytes()); 607 metrics.didUseContentsTextureMemoryBytes(m_contentsTextureManager->memoryAbo veCutoffBytes());
608 metrics.didUseRenderSurfaceTextureMemoryBytes(memoryForRenderSurfacesMetric) ; 608 metrics.didUseRenderSurfaceTextureMemoryBytes(memoryForRenderSurfacesMetric) ;
609 609
610 m_contentsTextureManager->prioritizeTextures(); 610 m_contentsTextureManager->prioritizeTextures();
611 } 611 }
612 612
613 size_t CCLayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& update List) 613 size_t LayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateLi st)
614 { 614 {
615 size_t readbackBytes = 0; 615 size_t readbackBytes = 0;
616 size_t maxBackgroundTextureBytes = 0; 616 size_t maxBackgroundTextureBytes = 0;
617 size_t contentsTextureBytes = 0; 617 size_t contentsTextureBytes = 0;
618 618
619 // Start iteration at 1 to skip the root surface as it does not have a textu re cost. 619 // Start iteration at 1 to skip the root surface as it does not have a textu re cost.
620 for (size_t i = 1; i < updateList.size(); ++i) { 620 for (size_t i = 1; i < updateList.size(); ++i) {
621 LayerChromium* renderSurfaceLayer = updateList[i].get(); 621 Layer* renderSurfaceLayer = updateList[i].get();
622 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface (); 622 RenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
623 623
624 size_t bytes = CCTexture::memorySizeBytes(renderSurface->contentRect().s ize(), GraphicsContext3D::RGBA); 624 size_t bytes = Texture::memorySizeBytes(renderSurface->contentRect().siz e(), GraphicsContext3D::RGBA);
625 contentsTextureBytes += bytes; 625 contentsTextureBytes += bytes;
626 626
627 if (renderSurfaceLayer->backgroundFilters().isEmpty()) 627 if (renderSurfaceLayer->backgroundFilters().isEmpty())
628 continue; 628 continue;
629 629
630 if (bytes > maxBackgroundTextureBytes) 630 if (bytes > maxBackgroundTextureBytes)
631 maxBackgroundTextureBytes = bytes; 631 maxBackgroundTextureBytes = bytes;
632 if (!readbackBytes) 632 if (!readbackBytes)
633 readbackBytes = CCTexture::memorySizeBytes(m_deviceViewportSize, Gra phicsContext3D::RGBA); 633 readbackBytes = Texture::memorySizeBytes(m_deviceViewportSize, Graph icsContext3D::RGBA);
634 } 634 }
635 return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes; 635 return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
636 } 636 }
637 637
638 bool CCLayerTreeHost::paintMasksForRenderSurface(LayerChromium* renderSurfaceLay er, CCTextureUpdateQueue& queue) 638 bool LayerTreeHost::paintMasksForRenderSurface(Layer* renderSurfaceLayer, Textur eUpdateQueue& queue)
639 { 639 {
640 // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point 640 // Note: Masks and replicas only exist for layers that own render surfaces. If we reach this point
641 // in code, we already know that at least something will be drawn into this render surface, so the 641 // in code, we already know that at least something will be drawn into this render surface, so the
642 // mask and replica should be painted. 642 // mask and replica should be painted.
643 643
644 bool needMoreUpdates = false; 644 bool needMoreUpdates = false;
645 LayerChromium* maskLayer = renderSurfaceLayer->maskLayer(); 645 Layer* maskLayer = renderSurfaceLayer->maskLayer();
646 if (maskLayer) { 646 if (maskLayer) {
647 maskLayer->update(queue, 0, m_renderingStats); 647 maskLayer->update(queue, 0, m_renderingStats);
648 needMoreUpdates |= maskLayer->needMoreUpdates(); 648 needMoreUpdates |= maskLayer->needMoreUpdates();
649 } 649 }
650 650
651 LayerChromium* replicaMaskLayer = renderSurfaceLayer->replicaLayer() ? rende rSurfaceLayer->replicaLayer()->maskLayer() : 0; 651 Layer* replicaMaskLayer = renderSurfaceLayer->replicaLayer() ? renderSurface Layer->replicaLayer()->maskLayer() : 0;
652 if (replicaMaskLayer) { 652 if (replicaMaskLayer) {
653 replicaMaskLayer->update(queue, 0, m_renderingStats); 653 replicaMaskLayer->update(queue, 0, m_renderingStats);
654 needMoreUpdates |= replicaMaskLayer->needMoreUpdates(); 654 needMoreUpdates |= replicaMaskLayer->needMoreUpdates();
655 } 655 }
656 return needMoreUpdates; 656 return needMoreUpdates;
657 } 657 }
658 658
659 bool CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList , CCTextureUpdateQueue& queue) 659 bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, TextureUpdateQueue& queue)
660 { 660 {
661 // Use FrontToBack to allow for testing occlusion and performing culling dur ing the tree walk. 661 // Use FrontToBack to allow for testing occlusion and performing culling dur ing the tree walk.
662 typedef CCLayerIterator<LayerChromium, LayerList, RenderSurfaceChromium, CCL ayerIteratorActions::FrontToBack> CCLayerIteratorType; 662 typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions: :FrontToBack> LayerIteratorType;
663 663
664 bool needMoreUpdates = false; 664 bool needMoreUpdates = false;
665 bool recordMetricsForFrame = true; // FIXME: In the future, disable this whe n about:tracing is off. 665 bool recordMetricsForFrame = true; // FIXME: In the future, disable this whe n about:tracing is off.
666 CCOcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRec t(), recordMetricsForFrame); 666 OcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect( ), recordMetricsForFrame);
667 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS ize); 667 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS ize);
668 668
669 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics( )); 669 prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics( ));
670 670
671 CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); 671 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList);
672 for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayer List); it != end; ++it) { 672 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList ); it != end; ++it) {
673 occlusionTracker.enterLayer(it); 673 occlusionTracker.enterLayer(it);
674 674
675 if (it.representsTargetRenderSurface()) { 675 if (it.representsTargetRenderSurface()) {
676 ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->dr awOpacityIsAnimating()); 676 ASSERT(it->renderSurface()->drawOpacity() || it->renderSurface()->dr awOpacityIsAnimating());
677 needMoreUpdates |= paintMasksForRenderSurface(*it, queue); 677 needMoreUpdates |= paintMasksForRenderSurface(*it, queue);
678 } else if (it.representsItself()) { 678 } else if (it.representsItself()) {
679 ASSERT(!it->bounds().isEmpty()); 679 ASSERT(!it->bounds().isEmpty());
680 it->update(queue, &occlusionTracker, m_renderingStats); 680 it->update(queue, &occlusionTracker, m_renderingStats);
681 needMoreUpdates |= it->needMoreUpdates(); 681 needMoreUpdates |= it->needMoreUpdates();
682 } 682 }
683 683
684 occlusionTracker.leaveLayer(it); 684 occlusionTracker.leaveLayer(it);
685 } 685 }
686 686
687 occlusionTracker.overdrawMetrics().recordMetrics(this); 687 occlusionTracker.overdrawMetrics().recordMetrics(this);
688 688
689 return needMoreUpdates; 689 return needMoreUpdates;
690 } 690 }
691 691
692 void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info) 692 void LayerTreeHost::applyScrollAndScale(const ScrollAndScaleSet& info)
693 { 693 {
694 if (!m_rootLayer) 694 if (!m_rootLayer)
695 return; 695 return;
696 696
697 LayerChromium* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get()) ; 697 Layer* rootScrollLayer = findFirstScrollableLayer(m_rootLayer.get());
698 IntSize rootScrollDelta; 698 IntSize rootScrollDelta;
699 699
700 for (size_t i = 0; i < info.scrolls.size(); ++i) { 700 for (size_t i = 0; i < info.scrolls.size(); ++i) {
701 LayerChromium* layer = CCLayerTreeHostCommon::findLayerInSubtree(m_rootL ayer.get(), info.scrolls[i].layerId); 701 Layer* layer = LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get() , info.scrolls[i].layerId);
702 if (!layer) 702 if (!layer)
703 continue; 703 continue;
704 if (layer == rootScrollLayer) 704 if (layer == rootScrollLayer)
705 rootScrollDelta += info.scrolls[i].scrollDelta; 705 rootScrollDelta += info.scrolls[i].scrollDelta;
706 else 706 else
707 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s crollDelta); 707 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].s crollDelta);
708 } 708 }
709 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) 709 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1)
710 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta); 710 m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta);
711 } 711 }
712 712
713 void CCLayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& tr ansform) 713 void LayerTreeHost::setImplTransform(const WebKit::WebTransformationMatrix& tran sform)
714 { 714 {
715 m_implTransform = transform; 715 m_implTransform = transform;
716 } 716 }
717 717
718 void CCLayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) 718 void LayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context)
719 { 719 {
720 if (m_animating) 720 if (m_animating)
721 return; 721 return;
722 722
723 ASSERT(context); 723 ASSERT(context);
724 RateLimiterMap::iterator it = m_rateLimiters.find(context); 724 RateLimiterMap::iterator it = m_rateLimiters.find(context);
725 if (it != m_rateLimiters.end()) 725 if (it != m_rateLimiters.end())
726 it->second->start(); 726 it->second->start();
727 else { 727 else {
728 scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, th is); 728 scoped_refptr<RateLimiter> rateLimiter = RateLimiter::create(context, th is);
729 m_rateLimiters[context] = rateLimiter; 729 m_rateLimiters[context] = rateLimiter;
730 rateLimiter->start(); 730 rateLimiter->start();
731 } 731 }
732 } 732 }
733 733
734 void CCLayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context) 734 void LayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context)
735 { 735 {
736 RateLimiterMap::iterator it = m_rateLimiters.find(context); 736 RateLimiterMap::iterator it = m_rateLimiters.find(context);
737 if (it != m_rateLimiters.end()) { 737 if (it != m_rateLimiters.end()) {
738 it->second->stop(); 738 it->second->stop();
739 m_rateLimiters.erase(it); 739 m_rateLimiters.erase(it);
740 } 740 }
741 } 741 }
742 742
743 void CCLayerTreeHost::rateLimit() 743 void LayerTreeHost::rateLimit()
744 { 744 {
745 // Force a no-op command on the compositor context, so that any ratelimiting commands will wait for the compositing 745 // Force a no-op command on the compositor context, so that any ratelimiting commands will wait for the compositing
746 // context, and therefore for the SwapBuffers. 746 // context, and therefore for the SwapBuffers.
747 m_proxy->forceSerializeOnSwapBuffers(); 747 m_proxy->forceSerializeOnSwapBuffers();
748 } 748 }
749 749
750 bool CCLayerTreeHost::bufferedUpdates() 750 bool LayerTreeHost::bufferedUpdates()
751 { 751 {
752 return m_settings.maxPartialTextureUpdates != numeric_limits<size_t>::max(); 752 return m_settings.maxPartialTextureUpdates != numeric_limits<size_t>::max();
753 } 753 }
754 754
755 bool CCLayerTreeHost::requestPartialTextureUpdate() 755 bool LayerTreeHost::requestPartialTextureUpdate()
756 { 756 {
757 if (m_partialTextureUpdateRequests >= m_settings.maxPartialTextureUpdates) 757 if (m_partialTextureUpdateRequests >= m_settings.maxPartialTextureUpdates)
758 return false; 758 return false;
759 759
760 m_partialTextureUpdateRequests++; 760 m_partialTextureUpdateRequests++;
761 return true; 761 return true;
762 } 762 }
763 763
764 void CCLayerTreeHost::deleteTextureAfterCommit(scoped_ptr<CCPrioritizedTexture> texture) 764 void LayerTreeHost::deleteTextureAfterCommit(scoped_ptr<PrioritizedTexture> text ure)
765 { 765 {
766 m_deleteTextureAfterCommitList.append(texture.Pass()); 766 m_deleteTextureAfterCommitList.append(texture.Pass());
767 } 767 }
768 768
769 void CCLayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor) 769 void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor)
770 { 770 {
771 if (deviceScaleFactor == m_deviceScaleFactor) 771 if (deviceScaleFactor == m_deviceScaleFactor)
772 return; 772 return;
773 m_deviceScaleFactor = deviceScaleFactor; 773 m_deviceScaleFactor = deviceScaleFactor;
774 774
775 setNeedsCommit(); 775 setNeedsCommit();
776 } 776 }
777 777
778 void CCLayerTreeHost::animateLayers(double monotonicTime) 778 void LayerTreeHost::animateLayers(double monotonicTime)
779 { 779 {
780 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers) 780 if (!Settings::acceleratedAnimationEnabled() || !m_needsAnimateLayers)
781 return; 781 return;
782 782
783 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers"); 783 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers");
784 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), monotonicTi me); 784 m_needsAnimateLayers = animateLayersRecursive(m_rootLayer.get(), monotonicTi me);
785 } 785 }
786 786
787 bool CCLayerTreeHost::animateLayersRecursive(LayerChromium* current, double mono tonicTime) 787 bool LayerTreeHost::animateLayersRecursive(Layer* current, double monotonicTime)
788 { 788 {
789 if (!current) 789 if (!current)
790 return false; 790 return false;
791 791
792 bool subtreeNeedsAnimateLayers = false; 792 bool subtreeNeedsAnimateLayers = false;
793 CCLayerAnimationController* currentController = current->layerAnimationContr oller(); 793 LayerAnimationController* currentController = current->layerAnimationControl ler();
794 currentController->animate(monotonicTime, 0); 794 currentController->animate(monotonicTime, 0);
795 795
796 // If the current controller still has an active animation, we must continue animating layers. 796 // If the current controller still has an active animation, we must continue animating layers.
797 if (currentController->hasActiveAnimation()) 797 if (currentController->hasActiveAnimation())
798 subtreeNeedsAnimateLayers = true; 798 subtreeNeedsAnimateLayers = true;
799 799
800 for (size_t i = 0; i < current->children().size(); ++i) { 800 for (size_t i = 0; i < current->children().size(); ++i) {
801 if (animateLayersRecursive(current->children()[i].get(), monotonicTime)) 801 if (animateLayersRecursive(current->children()[i].get(), monotonicTime))
802 subtreeNeedsAnimateLayers = true; 802 subtreeNeedsAnimateLayers = true;
803 } 803 }
804 804
805 return subtreeNeedsAnimateLayers; 805 return subtreeNeedsAnimateLayers;
806 } 806 }
807 807
808 void CCLayerTreeHost::setAnimationEventsRecursive(const CCAnimationEventsVector& events, LayerChromium* layer, double wallClockTime) 808 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve nts, Layer* layer, double wallClockTime)
809 { 809 {
810 if (!layer) 810 if (!layer)
811 return; 811 return;
812 812
813 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { 813 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) {
814 if (layer->id() == events[eventIndex].layerId) { 814 if (layer->id() == events[eventIndex].layerId) {
815 if (events[eventIndex].type == CCAnimationEvent::Started) 815 if (events[eventIndex].type == AnimationEvent::Started)
816 layer->notifyAnimationStarted(events[eventIndex], wallClockTime) ; 816 layer->notifyAnimationStarted(events[eventIndex], wallClockTime) ;
817 else 817 else
818 layer->notifyAnimationFinished(wallClockTime); 818 layer->notifyAnimationFinished(wallClockTime);
819 } 819 }
820 } 820 }
821 821
822 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 822 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
823 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 823 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
824 } 824 }
825 825
826 } // namespace cc 826 } // namespace cc
OLDNEW
« cc/active_animation.h ('K') | « cc/layer_tree_host.h ('k') | cc/layer_tree_host_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698