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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "cc/font_atlas.h" | 11 #include "cc/font_atlas.h" |
12 #include "cc/heads_up_display_layer.h" | 12 #include "cc/heads_up_display_layer.h" |
13 #include "cc/heads_up_display_layer_impl.h" | 13 #include "cc/heads_up_display_layer_impl.h" |
14 #include "cc/layer.h" | 14 #include "cc/layer.h" |
15 #include "cc/layer_animation_controller.h" | 15 #include "cc/layer_animation_controller.h" |
16 #include "cc/layer_iterator.h" | 16 #include "cc/layer_iterator.h" |
17 #include "cc/layer_tree_host_client.h" | 17 #include "cc/layer_tree_host_client.h" |
18 #include "cc/layer_tree_host_common.h" | 18 #include "cc/layer_tree_host_common.h" |
19 #include "cc/layer_tree_host_impl.h" | 19 #include "cc/layer_tree_host_impl.h" |
20 #include "cc/layer_tree_impl.h" | 20 #include "cc/layer_tree_impl.h" |
21 #include "cc/math_util.h" | 21 #include "cc/math_util.h" |
22 #include "cc/occlusion_tracker.h" | 22 #include "cc/occlusion_tracker.h" |
23 #include "cc/overdraw_metrics.h" | 23 #include "cc/overdraw_metrics.h" |
| 24 #include "cc/pinch_zoom_scrollbar_layer.h" |
| 25 #include "cc/scrollbar_layer_impl.h" |
24 #include "cc/single_thread_proxy.h" | 26 #include "cc/single_thread_proxy.h" |
25 #include "cc/switches.h" | 27 #include "cc/switches.h" |
26 #include "cc/thread.h" | 28 #include "cc/thread.h" |
27 #include "cc/thread_proxy.h" | 29 #include "cc/thread_proxy.h" |
28 #include "cc/tree_synchronizer.h" | 30 #include "cc/tree_synchronizer.h" |
29 | 31 |
30 using namespace std; | 32 using namespace std; |
31 | 33 |
32 namespace { | 34 namespace { |
33 static int numLayerTreeInstances; | 35 static int numLayerTreeInstances; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 , m_visible(true) | 87 , m_visible(true) |
86 , m_pageScaleFactor(1) | 88 , m_pageScaleFactor(1) |
87 , m_minPageScaleFactor(1) | 89 , m_minPageScaleFactor(1) |
88 , m_maxPageScaleFactor(1) | 90 , m_maxPageScaleFactor(1) |
89 , m_triggerIdleUpdates(true) | 91 , m_triggerIdleUpdates(true) |
90 , m_backgroundColor(SK_ColorWHITE) | 92 , m_backgroundColor(SK_ColorWHITE) |
91 , m_hasTransparentBackground(false) | 93 , m_hasTransparentBackground(false) |
92 , m_partialTextureUpdateRequests(0) | 94 , m_partialTextureUpdateRequests(0) |
93 { | 95 { |
94 numLayerTreeInstances++; | 96 numLayerTreeInstances++; |
| 97 |
| 98 if (m_settings.pageScalePinchZoomEnabled) { |
| 99 m_pinchZoomScrollbarVertical = PinchZoomScrollbarLayer::create(); |
| 100 m_pinchZoomScrollbarHorizontal = PinchZoomScrollbarLayer::create(); |
| 101 } |
95 } | 102 } |
96 | 103 |
97 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) | 104 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) |
98 { | 105 { |
99 if (implThread) | 106 if (implThread) |
100 return initializeProxy(ThreadProxy::create(this, implThread.Pass())); | 107 return initializeProxy(ThreadProxy::create(this, implThread.Pass())); |
101 else | 108 else |
102 return initializeProxy(SingleThreadProxy::create(this)); | 109 return initializeProxy(SingleThreadProxy::create(this)); |
103 } | 110 } |
104 | 111 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 TRACE_EVENT0("cc", "LayerTreeHost::pushPropertiesRecursive"); | 280 TRACE_EVENT0("cc", "LayerTreeHost::pushPropertiesRecursive"); |
274 pushPropertiesRecursive(rootLayer(), hostImpl->rootLayer()); | 281 pushPropertiesRecursive(rootLayer(), hostImpl->rootLayer()); |
275 } | 282 } |
276 m_needsFullTreeSync = false; | 283 m_needsFullTreeSync = false; |
277 | 284 |
278 if (m_rootLayer && m_hudLayer) | 285 if (m_rootLayer && m_hudLayer) |
279 hostImpl->activeTree()->set_hud_layer(static_cast<HeadsUpDisplayLayerImp
l*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->i
d()))); | 286 hostImpl->activeTree()->set_hud_layer(static_cast<HeadsUpDisplayLayerImp
l*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->i
d()))); |
280 else | 287 else |
281 hostImpl->activeTree()->set_hud_layer(0); | 288 hostImpl->activeTree()->set_hud_layer(0); |
282 | 289 |
| 290 if (m_rootLayer && m_pinchZoomScrollbarVertical) |
| 291 hostImpl->activeTree()->set_pinch_zoom_scrollbar_vertical(static_cast<Sc
rollbarLayerImpl*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer()
, m_pinchZoomScrollbarVertical->id()))); |
| 292 else |
| 293 hostImpl->activeTree()->set_pinch_zoom_scrollbar_vertical(0); |
| 294 |
| 295 if (m_rootLayer && m_pinchZoomScrollbarHorizontal) |
| 296 hostImpl->activeTree()->set_pinch_zoom_scrollbar_horizontal(static_cast<
ScrollbarLayerImpl*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer
(), m_pinchZoomScrollbarHorizontal->id()))); |
| 297 else |
| 298 hostImpl->activeTree()->set_pinch_zoom_scrollbar_horizontal(0); |
| 299 |
283 // We may have added an animation during the tree sync. This will cause both
layer tree hosts | 300 // We may have added an animation during the tree sync. This will cause both
layer tree hosts |
284 // to visit their controllers. | 301 // to visit their controllers. |
285 if (rootLayer() && m_needsAnimateLayers) | 302 if (rootLayer() && m_needsAnimateLayers) |
286 hostImpl->setNeedsAnimateLayers(); | 303 hostImpl->setNeedsAnimateLayers(); |
287 | 304 |
288 hostImpl->activeTree()->set_source_frame_number(commitNumber()); | 305 hostImpl->activeTree()->set_source_frame_number(commitNumber()); |
289 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); | 306 hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize()); |
290 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 307 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
291 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); | 308 hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFacto
r, m_maxPageScaleFactor); |
292 hostImpl->setBackgroundColor(m_backgroundColor); | 309 hostImpl->setBackgroundColor(m_backgroundColor); |
(...skipping 13 matching lines...) Expand all Loading... |
306 | 323 |
307 if (m_debugState.hudNeedsFont() && !m_hudLayer->hasFontAtlas()) | 324 if (m_debugState.hudNeedsFont() && !m_hudLayer->hasFontAtlas()) |
308 m_hudLayer->setFontAtlas(m_client->createFontAtlas()); | 325 m_hudLayer->setFontAtlas(m_client->createFontAtlas()); |
309 | 326 |
310 if (m_rootLayer && !m_hudLayer->parent()) | 327 if (m_rootLayer && !m_hudLayer->parent()) |
311 m_rootLayer->addChild(m_hudLayer); | 328 m_rootLayer->addChild(m_hudLayer); |
312 } else if (m_hudLayer) { | 329 } else if (m_hudLayer) { |
313 m_hudLayer->removeFromParent(); | 330 m_hudLayer->removeFromParent(); |
314 m_hudLayer = 0; | 331 m_hudLayer = 0; |
315 } | 332 } |
| 333 |
| 334 if (m_settings.pageScalePinchZoomEnabled && m_rootLayer) { |
| 335 DCHECK(m_pinchZoomScrollbarVertical); |
| 336 if (m_pinchZoomScrollbarVertical && !m_pinchZoomScrollbarVertical->paren
t()) |
| 337 m_rootLayer->addChild(m_pinchZoomScrollbarVertical); |
| 338 |
| 339 DCHECK(m_pinchZoomScrollbarHorizontal); |
| 340 if (m_pinchZoomScrollbarHorizontal && !m_pinchZoomScrollbarHorizontal->p
arent()) |
| 341 m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal); |
| 342 } |
316 } | 343 } |
317 | 344 |
318 void LayerTreeHost::commitComplete() | 345 void LayerTreeHost::commitComplete() |
319 { | 346 { |
320 m_client->didCommit(); | 347 m_client->didCommit(); |
321 } | 348 } |
322 | 349 |
323 scoped_ptr<OutputSurface> LayerTreeHost::createOutputSurface() | 350 scoped_ptr<OutputSurface> LayerTreeHost::createOutputSurface() |
324 { | 351 { |
325 return m_client->createOutputSurface(); | 352 return m_client->createOutputSurface(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 458 |
432 if (m_rootLayer) | 459 if (m_rootLayer) |
433 m_rootLayer->setLayerTreeHost(0); | 460 m_rootLayer->setLayerTreeHost(0); |
434 m_rootLayer = rootLayer; | 461 m_rootLayer = rootLayer; |
435 if (m_rootLayer) | 462 if (m_rootLayer) |
436 m_rootLayer->setLayerTreeHost(this); | 463 m_rootLayer->setLayerTreeHost(this); |
437 | 464 |
438 if (m_hudLayer) | 465 if (m_hudLayer) |
439 m_hudLayer->removeFromParent(); | 466 m_hudLayer->removeFromParent(); |
440 | 467 |
| 468 if (m_pinchZoomScrollbarVertical) |
| 469 m_pinchZoomScrollbarVertical->removeFromParent(); |
| 470 |
| 471 if (m_pinchZoomScrollbarHorizontal) |
| 472 m_pinchZoomScrollbarHorizontal->removeFromParent(); |
| 473 |
441 setNeedsFullTreeSync(); | 474 setNeedsFullTreeSync(); |
442 } | 475 } |
443 | 476 |
444 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) | 477 void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |
445 { | 478 { |
446 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); | 479 LayerTreeDebugState newDebugState = LayerTreeDebugState::unite(m_settings.in
itialDebugState, debugState); |
447 | 480 |
448 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) | 481 if (LayerTreeDebugState::equal(m_debugState, newDebugState)) |
449 return; | 482 return; |
450 | 483 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 594 } |
562 | 595 |
563 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) | 596 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) |
564 { | 597 { |
565 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); | 598 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); |
566 | 599 |
567 LayerList updateList; | 600 LayerList updateList; |
568 | 601 |
569 { | 602 { |
570 if (m_settings.pageScalePinchZoomEnabled) { | 603 if (m_settings.pageScalePinchZoomEnabled) { |
571 Layer* rootScroll = findFirstScrollableLayer(rootLayer); | 604 const LayerList& children = m_rootLayer->children(); |
572 if (rootScroll) | 605 for (size_t i = 0; i < children.size(); ++i) { |
573 rootScroll->setImplTransform(m_implTransform); | 606 Layer* layer = children[i].get(); |
| 607 if (layer != m_pinchZoomScrollbarVertical.get() |
| 608 && layer != m_pinchZoomScrollbarHorizontal.get()) |
| 609 layer->setImplTransform(m_implTransform); |
| 610 } |
574 } | 611 } |
575 | 612 |
576 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc"); | 613 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc"); |
577 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSi
ze(), m_deviceScaleFactor, m_pageScaleFactor, rendererCapabilities().maxTextureS
ize, updateList); | 614 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSi
ze(), m_deviceScaleFactor, m_pageScaleFactor, rendererCapabilities().maxTextureS
ize, updateList); |
578 } | 615 } |
579 | 616 |
580 // Reset partial texture update requests. | 617 // Reset partial texture update requests. |
581 m_partialTextureUpdateRequests = 0; | 618 m_partialTextureUpdateRequests = 0; |
582 | 619 |
583 bool needMoreUpdates = paintLayerContents(updateList, queue); | 620 bool needMoreUpdates = paintLayerContents(updateList, queue); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 else | 904 else |
868 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 905 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
869 } | 906 } |
870 } | 907 } |
871 | 908 |
872 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 909 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
873 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 910 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
874 } | 911 } |
875 | 912 |
876 } // namespace cc | 913 } // namespace cc |
OLD | NEW |