| 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 "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "cc/layer_tree_host_impl.h" | 21 #include "cc/layer_tree_host_impl.h" |
| 22 #include "cc/layer_tree_impl.h" | 22 #include "cc/layer_tree_impl.h" |
| 23 #include "cc/math_util.h" | 23 #include "cc/math_util.h" |
| 24 #include "cc/occlusion_tracker.h" | 24 #include "cc/occlusion_tracker.h" |
| 25 #include "cc/overdraw_metrics.h" | 25 #include "cc/overdraw_metrics.h" |
| 26 #include "cc/prioritized_resource_manager.h" | 26 #include "cc/prioritized_resource_manager.h" |
| 27 #include "cc/single_thread_proxy.h" | 27 #include "cc/single_thread_proxy.h" |
| 28 #include "cc/switches.h" | 28 #include "cc/switches.h" |
| 29 #include "cc/thread.h" | 29 #include "cc/thread.h" |
| 30 #include "cc/thread_proxy.h" | 30 #include "cc/thread_proxy.h" |
| 31 #include "cc/top_controls_manager.h" |
| 31 #include "cc/tree_synchronizer.h" | 32 #include "cc/tree_synchronizer.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 static int numLayerTreeInstances; | 35 static int numLayerTreeInstances; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace cc { | 38 namespace cc { |
| 38 | 39 |
| 39 bool LayerTreeHost::s_needsFilterContext = false; | 40 bool LayerTreeHost::s_needsFilterContext = false; |
| 40 | 41 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 309 |
| 309 syncTree->set_source_frame_number(commitNumber()); | 310 syncTree->set_source_frame_number(commitNumber()); |
| 310 syncTree->set_background_color(m_backgroundColor); | 311 syncTree->set_background_color(m_backgroundColor); |
| 311 syncTree->set_has_transparent_background(m_hasTransparentBackground); | 312 syncTree->set_has_transparent_background(m_hasTransparentBackground); |
| 312 | 313 |
| 313 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 314 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
| 314 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 315 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
| 315 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); | 316 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); |
| 316 hostImpl->setDebugState(m_debugState); | 317 hostImpl->setDebugState(m_debugState); |
| 317 | 318 |
| 319 if (m_settings.calculateTopControlsPosition && m_topControlsContentLayer &&
hostImpl->topControlsManager()) |
| 320 hostImpl->topControlsManager()->set_content_layer_id(m_topControlsConten
tLayer->id()); |
| 321 |
| 318 m_commitNumber++; | 322 m_commitNumber++; |
| 319 } | 323 } |
| 320 | 324 |
| 321 void LayerTreeHost::willCommit() | 325 void LayerTreeHost::willCommit() |
| 322 { | 326 { |
| 323 m_client->willCommit(); | 327 m_client->willCommit(); |
| 324 | 328 |
| 325 if (m_debugState.showHudInfo()) { | 329 if (m_debugState.showHudInfo()) { |
| 326 if (!m_hudLayer) | 330 if (!m_hudLayer) |
| 327 m_hudLayer = HeadsUpDisplayLayer::create(); | 331 m_hudLayer = HeadsUpDisplayLayer::create(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 return; | 450 return; |
| 447 | 451 |
| 448 if (m_rootLayer) | 452 if (m_rootLayer) |
| 449 m_rootLayer->setLayerTreeHost(0); | 453 m_rootLayer->setLayerTreeHost(0); |
| 450 m_rootLayer = rootLayer; | 454 m_rootLayer = rootLayer; |
| 451 if (m_rootLayer) | 455 if (m_rootLayer) |
| 452 m_rootLayer->setLayerTreeHost(this); | 456 m_rootLayer->setLayerTreeHost(this); |
| 453 | 457 |
| 454 if (m_hudLayer) | 458 if (m_hudLayer) |
| 455 m_hudLayer->removeFromParent(); | 459 m_hudLayer->removeFromParent(); |
| 460 if (m_topControlsContentLayer) |
| 461 m_topControlsContentLayer->removeFromParent(); |
| 456 | 462 |
| 457 setNeedsFullTreeSync(); | 463 setNeedsFullTreeSync(); |
| 458 } | 464 } |
| 459 | 465 |
| 460 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) | 466 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |
| 461 { | 467 { |
| 462 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); | 468 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); |
| 463 | 469 |
| 464 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) | 470 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) |
| 465 return; | 471 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 548 |
| 543 if (!rootLayer()) | 549 if (!rootLayer()) |
| 544 return; | 550 return; |
| 545 | 551 |
| 546 if (layoutViewportSize().IsEmpty()) | 552 if (layoutViewportSize().IsEmpty()) |
| 547 return; | 553 return; |
| 548 | 554 |
| 549 if (memoryAllocationLimitBytes) | 555 if (memoryAllocationLimitBytes) |
| 550 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBy
tes); | 556 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBy
tes); |
| 551 | 557 |
| 558 if (m_settings.calculateTopControlsPosition) { |
| 559 if (!m_topControlsContentLayer) { |
| 560 m_topControlsContentLayer = Layer::create(); |
| 561 m_topControlsContentLayer->setIsDrawable(false); |
| 562 m_topControlsContentLayer->setDebugName("Top Controls Content"); |
| 563 } |
| 564 |
| 565 // Insert a layer that allows the top controls manager to move around |
| 566 // the content without clobbering/being clobbered by other transforms. |
| 567 if (!LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get(), m_topCon
trolsContentLayer->id())) { |
| 568 m_topControlsContentLayer->setLayerTreeHost(m_rootLayer->layerTreeHo
st()); |
| 569 m_topControlsContentLayer->setChildren(m_rootLayer->children()); |
| 570 m_rootLayer->addChild(m_topControlsContentLayer); |
| 571 } |
| 572 } |
| 573 |
| 552 updateLayers(rootLayer(), queue); | 574 updateLayers(rootLayer(), queue); |
| 553 } | 575 } |
| 554 | 576 |
| 555 static Layer* findFirstScrollableLayer(Layer* layer) | 577 static Layer* findFirstScrollableLayer(Layer* layer) |
| 556 { | 578 { |
| 557 if (!layer) | 579 if (!layer) |
| 558 return 0; | 580 return 0; |
| 559 | 581 |
| 560 if (layer->scrollable()) | 582 if (layer->scrollable()) |
| 561 return layer; | 583 return layer; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 891 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 870 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 892 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 871 } | 893 } |
| 872 | 894 |
| 873 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 895 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
| 874 { | 896 { |
| 875 return m_proxy->capturePicture(); | 897 return m_proxy->capturePicture(); |
| 876 } | 898 } |
| 877 | 899 |
| 878 } // namespace cc | 900 } // namespace cc |
| OLD | NEW |