OLD | NEW |
---|---|
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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "cc/font_atlas.h" | 10 #include "cc/font_atlas.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 { | 153 { |
154 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings)) ; | 154 scoped_ptr<LayerTreeHost> layerTreeHost(new LayerTreeHost(client, settings)) ; |
155 if (!layerTreeHost->initialize(implThread.Pass())) | 155 if (!layerTreeHost->initialize(implThread.Pass())) |
156 return scoped_ptr<LayerTreeHost>(); | 156 return scoped_ptr<LayerTreeHost>(); |
157 return layerTreeHost.Pass(); | 157 return layerTreeHost.Pass(); |
158 } | 158 } |
159 | 159 |
160 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting s& settings) | 160 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting s& settings) |
161 : m_animating(false) | 161 : m_animating(false) |
162 , m_needsAnimateLayers(false) | 162 , m_needsAnimateLayers(false) |
163 , m_needsFullTreeSync(true) | |
163 , m_client(client) | 164 , m_client(client) |
164 , m_commitNumber(0) | 165 , m_commitNumber(0) |
165 , m_renderingStats() | 166 , m_renderingStats() |
166 , m_rendererInitialized(false) | 167 , m_rendererInitialized(false) |
167 , m_contextLost(false) | 168 , m_contextLost(false) |
168 , m_numTimesRecreateShouldFail(0) | 169 , m_numTimesRecreateShouldFail(0) |
169 , m_numFailedRecreateAttempts(0) | 170 , m_numFailedRecreateAttempts(0) |
170 , m_settings(settings) | 171 , m_settings(settings) |
171 , m_debugState(settings.initialDebugState) | 172 , m_debugState(settings.initialDebugState) |
172 , m_deviceScaleFactor(1) | 173 , m_deviceScaleFactor(1) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 { | 303 { |
303 m_client->layout(); | 304 m_client->layout(); |
304 } | 305 } |
305 | 306 |
306 void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) | 307 void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
307 { | 308 { |
308 DCHECK(m_proxy->isImplThread()); | 309 DCHECK(m_proxy->isImplThread()); |
309 TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); | 310 TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); |
310 } | 311 } |
311 | 312 |
313 static void pushPropertiesRecursive(Layer* layer, LayerImpl* layerImpl) | |
314 { | |
315 if (!layer) { | |
316 DCHECK(!layerImpl); | |
317 return; | |
318 } | |
319 | |
320 DCHECK_EQ(layer->id(), layerImpl->id()); | |
321 layer->pushPropertiesTo(layerImpl); | |
322 | |
323 pushPropertiesRecursive(layer->maskLayer(), layerImpl->maskLayer()); | |
324 pushPropertiesRecursive(layer->replicaLayer(), layerImpl->replicaLayer()); | |
325 | |
326 const std::vector<scoped_refptr<Layer> >& children = layer->children(); | |
327 const ScopedPtrVector<LayerImpl>& implChildren = layerImpl->children(); | |
328 DCHECK_EQ(children.size(), implChildren.size()); | |
danakj
2012/12/03 18:46:25
should it CRASH() in this case? We could end up pa
| |
329 | |
330 for (size_t i = 0; i < children.size(); ++i) { | |
331 pushPropertiesRecursive(children[i].get(), implChildren[i]); | |
332 } | |
333 } | |
334 | |
312 // This function commits the LayerTreeHost to an impl tree. When modifying | 335 // This function commits the LayerTreeHost to an impl tree. When modifying |
313 // this function, keep in mind that the function *runs* on the impl thread! Any | 336 // this function, keep in mind that the function *runs* on the impl thread! Any |
314 // code that is logically a main thread operation, e.g. deletion of a Layer, | 337 // code that is logically a main thread operation, e.g. deletion of a Layer, |
315 // should be delayed until the LayerTreeHost::commitComplete, which will run | 338 // should be delayed until the LayerTreeHost::commitComplete, which will run |
316 // after the commit, but on the main thread. | 339 // after the commit, but on the main thread. |
317 void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) | 340 void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
318 { | 341 { |
319 DCHECK(m_proxy->isImplThread()); | 342 DCHECK(m_proxy->isImplThread()); |
320 | 343 |
321 m_contentsTextureManager->updateBackingsInDrawingImplTree(); | 344 m_contentsTextureManager->updateBackingsInDrawingImplTree(); |
322 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); | 345 m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); |
323 | 346 |
324 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostI mpl->detachLayerTree(), hostImpl)); | 347 if (m_needsFullTreeSync) { |
348 hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), h ostImpl->detachLayerTree(), hostImpl)); | |
349 } else { | |
350 TRACE_EVENT0("cc", "LayerTreeHost::pushPropertiesRecursive"); | |
351 pushPropertiesRecursive(rootLayer(), hostImpl->rootLayer()); | |
352 } | |
353 m_needsFullTreeSync = false; | |
325 | 354 |
326 if (m_rootLayer && m_hudLayer) | 355 if (m_rootLayer && m_hudLayer) |
327 hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHos tCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); | 356 hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHos tCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); |
328 else | 357 else |
329 hostImpl->setHudLayer(0); | 358 hostImpl->setHudLayer(0); |
330 | 359 |
331 // We may have added an animation during the tree sync. This will cause both layer tree hosts | 360 // We may have added an animation during the tree sync. This will cause both layer tree hosts |
332 // to visit their controllers. | 361 // to visit their controllers. |
333 if (rootLayer() && m_needsAnimateLayers) | 362 if (rootLayer() && m_needsAnimateLayers) |
334 hostImpl->setNeedsAnimateLayers(); | 363 hostImpl->setNeedsAnimateLayers(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 | 464 |
436 void LayerTreeHost::setNeedsCommit() | 465 void LayerTreeHost::setNeedsCommit() |
437 { | 466 { |
438 if (!m_prepaintCallback.IsCancelled()) { | 467 if (!m_prepaintCallback.IsCancelled()) { |
439 TRACE_EVENT_INSTANT0("cc", "LayerTreeHost::setNeedsCommit::cancel prepai nt"); | 468 TRACE_EVENT_INSTANT0("cc", "LayerTreeHost::setNeedsCommit::cancel prepai nt"); |
440 m_prepaintCallback.Cancel(); | 469 m_prepaintCallback.Cancel(); |
441 } | 470 } |
442 m_proxy->setNeedsCommit(); | 471 m_proxy->setNeedsCommit(); |
443 } | 472 } |
444 | 473 |
474 void LayerTreeHost::setNeedsFullTreeSync() | |
475 { | |
476 m_needsFullTreeSync = true; | |
477 setNeedsCommit(); | |
478 } | |
479 | |
445 void LayerTreeHost::setNeedsRedraw() | 480 void LayerTreeHost::setNeedsRedraw() |
446 { | 481 { |
447 m_proxy->setNeedsRedraw(); | 482 m_proxy->setNeedsRedraw(); |
448 if (!m_proxy->implThread()) | 483 if (!m_proxy->implThread()) |
449 m_client->scheduleComposite(); | 484 m_client->scheduleComposite(); |
450 } | 485 } |
451 | 486 |
452 bool LayerTreeHost::commitRequested() const | 487 bool LayerTreeHost::commitRequested() const |
453 { | 488 { |
454 return m_proxy->commitRequested(); | 489 return m_proxy->commitRequested(); |
(...skipping 18 matching lines...) Expand all Loading... | |
473 | 508 |
474 if (m_rootLayer) | 509 if (m_rootLayer) |
475 m_rootLayer->setLayerTreeHost(0); | 510 m_rootLayer->setLayerTreeHost(0); |
476 m_rootLayer = rootLayer; | 511 m_rootLayer = rootLayer; |
477 if (m_rootLayer) | 512 if (m_rootLayer) |
478 m_rootLayer->setLayerTreeHost(this); | 513 m_rootLayer->setLayerTreeHost(this); |
479 | 514 |
480 if (m_hudLayer) | 515 if (m_hudLayer) |
481 m_hudLayer->removeFromParent(); | 516 m_hudLayer->removeFromParent(); |
482 | 517 |
483 setNeedsCommit(); | 518 setNeedsFullTreeSync(); |
484 } | 519 } |
485 | 520 |
486 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) | 521 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |
487 { | 522 { |
488 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in itialDebugState, debugState); | 523 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in itialDebugState, debugState); |
489 | 524 |
490 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) | 525 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) |
491 return; | 526 return; |
492 | 527 |
493 m_debugState = newDebugState; | 528 m_debugState = newDebugState; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 else | 944 else |
910 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 945 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
911 } | 946 } |
912 } | 947 } |
913 | 948 |
914 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) | 949 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) |
915 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); | 950 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); |
916 } | 951 } |
917 | 952 |
918 } // namespace cc | 953 } // namespace cc |
OLD | NEW |