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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 329 |
329 syncTree->set_source_frame_number(commitNumber()); | 330 syncTree->set_source_frame_number(commitNumber()); |
330 syncTree->set_background_color(m_backgroundColor); | 331 syncTree->set_background_color(m_backgroundColor); |
331 syncTree->set_has_transparent_background(m_hasTransparentBackground); | 332 syncTree->set_has_transparent_background(m_hasTransparentBackground); |
332 | 333 |
333 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 334 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
334 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 335 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
335 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); | 336 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); |
336 hostImpl->setDebugState(m_debugState); | 337 hostImpl->setDebugState(m_debugState); |
337 | 338 |
| 339 if (m_settings.calculateTopControlsPosition && m_topControlsContentLayer &&
hostImpl->topControlsManager()) |
| 340 hostImpl->topControlsManager()->set_content_layer_id(m_topControlsConten
tLayer->id()); |
| 341 |
338 m_commitNumber++; | 342 m_commitNumber++; |
339 } | 343 } |
340 | 344 |
341 void LayerTreeHost::willCommit() | 345 void LayerTreeHost::willCommit() |
342 { | 346 { |
343 m_client->willCommit(); | 347 m_client->willCommit(); |
344 | 348 |
345 if (m_debugState.showHudInfo()) { | 349 if (m_debugState.showHudInfo()) { |
346 if (!m_hudLayer) | 350 if (!m_hudLayer) |
347 m_hudLayer = HeadsUpDisplayLayer::create(); | 351 m_hudLayer = HeadsUpDisplayLayer::create(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return; | 470 return; |
467 | 471 |
468 if (m_rootLayer) | 472 if (m_rootLayer) |
469 m_rootLayer->setLayerTreeHost(0); | 473 m_rootLayer->setLayerTreeHost(0); |
470 m_rootLayer = rootLayer; | 474 m_rootLayer = rootLayer; |
471 if (m_rootLayer) | 475 if (m_rootLayer) |
472 m_rootLayer->setLayerTreeHost(this); | 476 m_rootLayer->setLayerTreeHost(this); |
473 | 477 |
474 if (m_hudLayer) | 478 if (m_hudLayer) |
475 m_hudLayer->removeFromParent(); | 479 m_hudLayer->removeFromParent(); |
| 480 if (m_topControlsContentLayer) |
| 481 m_topControlsContentLayer->removeFromParent(); |
476 | 482 |
477 setNeedsFullTreeSync(); | 483 setNeedsFullTreeSync(); |
478 } | 484 } |
479 | 485 |
480 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) | 486 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |
481 { | 487 { |
482 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); | 488 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); |
483 | 489 |
484 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) | 490 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) |
485 return; | 491 return; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 568 |
563 if (!rootLayer()) | 569 if (!rootLayer()) |
564 return; | 570 return; |
565 | 571 |
566 if (layoutViewportSize().IsEmpty()) | 572 if (layoutViewportSize().IsEmpty()) |
567 return; | 573 return; |
568 | 574 |
569 if (memoryAllocationLimitBytes) | 575 if (memoryAllocationLimitBytes) |
570 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBy
tes); | 576 m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBy
tes); |
571 | 577 |
| 578 if (m_settings.calculateTopControlsPosition) { |
| 579 if (!m_topControlsContentLayer) { |
| 580 m_topControlsContentLayer = Layer::create(); |
| 581 m_topControlsContentLayer->setIsDrawable(false); |
| 582 m_topControlsContentLayer->setDebugName("Top Controls Content"); |
| 583 } |
| 584 |
| 585 // Insert a layer that allows the top controls manager to move around |
| 586 // the content without clobbering/being clobbered by other transforms. |
| 587 if (!LayerTreeHostCommon::findLayerInSubtree(m_rootLayer.get(), m_topCon
trolsContentLayer->id())) { |
| 588 m_topControlsContentLayer->setLayerTreeHost(m_rootLayer->layerTreeHo
st()); |
| 589 m_topControlsContentLayer->setChildren(m_rootLayer->children()); |
| 590 m_rootLayer->addChild(m_topControlsContentLayer); |
| 591 } |
| 592 } |
| 593 |
572 updateLayers(rootLayer(), queue); | 594 updateLayers(rootLayer(), queue); |
573 } | 595 } |
574 | 596 |
575 static Layer* findFirstScrollableLayer(Layer* layer) | 597 static Layer* findFirstScrollableLayer(Layer* layer) |
576 { | 598 { |
577 if (!layer) | 599 if (!layer) |
578 return 0; | 600 return 0; |
579 | 601 |
580 if (layer->scrollable()) | 602 if (layer->scrollable()) |
581 return layer; | 603 return layer; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 911 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
890 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 912 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
891 } | 913 } |
892 | 914 |
893 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 915 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
894 { | 916 { |
895 return m_proxy->capturePicture(); | 917 return m_proxy->capturePicture(); |
896 } | 918 } |
897 | 919 |
898 } // namespace cc | 920 } // namespace cc |
OLD | NEW |