Chromium Code Reviews| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "cc/animation_registrar.h" | 13 #include "cc/animation_registrar.h" |
| 14 #include "cc/heads_up_display_layer.h" | 14 #include "cc/heads_up_display_layer.h" |
| 15 #include "cc/heads_up_display_layer_impl.h" | 15 #include "cc/heads_up_display_layer_impl.h" |
| 16 #include "cc/layer.h" | 16 #include "cc/layer.h" |
| 17 #include "cc/layer_animation_controller.h" | 17 #include "cc/layer_animation_controller.h" |
| 18 #include "cc/layer_iterator.h" | 18 #include "cc/layer_iterator.h" |
| 19 #include "cc/layer_tree_host_client.h" | 19 #include "cc/layer_tree_host_client.h" |
| 20 #include "cc/layer_tree_host_common.h" | 20 #include "cc/layer_tree_host_common.h" |
| 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/pinch_zoom_scrollbar.h" | |
| 27 #include "cc/pinch_zoom_scrollbar_geometry.h" | |
| 28 #include "cc/pinch_zoom_scrollbar_painter.h" | |
| 26 #include "cc/prioritized_resource_manager.h" | 29 #include "cc/prioritized_resource_manager.h" |
| 30 #include "cc/scrollbar_layer.h" | |
| 27 #include "cc/single_thread_proxy.h" | 31 #include "cc/single_thread_proxy.h" |
| 28 #include "cc/switches.h" | 32 #include "cc/switches.h" |
| 29 #include "cc/thread.h" | 33 #include "cc/thread.h" |
| 30 #include "cc/thread_proxy.h" | 34 #include "cc/thread_proxy.h" |
| 31 #include "cc/top_controls_manager.h" | 35 #include "cc/top_controls_manager.h" |
| 32 #include "cc/tree_synchronizer.h" | 36 #include "cc/tree_synchronizer.h" |
| 33 | 37 |
| 34 namespace { | 38 namespace { |
| 35 static int numLayerTreeInstances; | 39 static int numLayerTreeInstances; |
| 36 } | 40 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); | 323 hostImpl->setDeviceScaleFactor(deviceScaleFactor()); |
| 320 hostImpl->setDebugState(m_debugState); | 324 hostImpl->setDebugState(m_debugState); |
| 321 | 325 |
| 322 DCHECK(!syncTree->ViewportSizeInvalid()); | 326 DCHECK(!syncTree->ViewportSizeInvalid()); |
| 323 | 327 |
| 324 if (newImplTreeHasNoEvictedResources) { | 328 if (newImplTreeHasNoEvictedResources) { |
| 325 if (syncTree->ContentsTexturesPurged()) | 329 if (syncTree->ContentsTexturesPurged()) |
| 326 syncTree->ResetContentsTexturesPurged(); | 330 syncTree->ResetContentsTexturesPurged(); |
| 327 } | 331 } |
| 328 | 332 |
| 333 syncTree->SetPinchZoomHorizontalLayerId( | |
| 334 m_pinchZoomScrollbarHorizontal ? m_pinchZoomScrollbarHorizontal->id() : -1); | |
|
enne (OOO)
2013/03/11 21:08:24
Don't use -1 here. Use the constant.
wjmaclean
2013/03/12 16:13:07
Done.
| |
| 335 syncTree->SetPinchZoomVerticalLayerId( | |
| 336 m_pinchZoomScrollbarVertical ? m_pinchZoomScrollbarVertical->id() : -1); | |
|
enne (OOO)
2013/03/11 21:08:24
Don't use -1 here. Use the constant.
wjmaclean
2013/03/12 16:13:07
Done.
| |
| 337 | |
| 329 if (!m_settings.implSidePainting) { | 338 if (!m_settings.implSidePainting) { |
| 330 // If we're not in impl-side painting, the tree is immediately | 339 // If we're not in impl-side painting, the tree is immediately |
| 331 // considered active. | 340 // considered active. |
| 332 syncTree->DidBecomeActive(); | 341 syncTree->DidBecomeActive(); |
| 333 } | 342 } |
| 334 | 343 |
| 335 if (m_debugState.continuousPainting) | 344 if (m_debugState.continuousPainting) |
| 336 hostImpl->savePaintTime(m_renderingStats.totalPaintTime, commitNumber()) ; | 345 hostImpl->savePaintTime(m_renderingStats.totalPaintTime, commitNumber()) ; |
| 337 | 346 |
| 338 m_commitNumber++; | 347 m_commitNumber++; |
| 339 } | 348 } |
| 340 | 349 |
| 350 void LayerTreeHost::setPinchZoomScrollbarsBoundsAndPosition() | |
| 351 { | |
| 352 if (!m_pinchZoomScrollbarHorizontal || !m_pinchZoomScrollbarVertical) | |
| 353 return; | |
| 354 | |
| 355 gfx::Size size = layoutViewportSize(); | |
| 356 int trackWidth = PinchZoomScrollbarGeometry::kTrackWidth; | |
| 357 | |
| 358 m_pinchZoomScrollbarHorizontal->setBounds(gfx::Size(size.width() - trackWidt h, trackWidth)); | |
| 359 m_pinchZoomScrollbarHorizontal->setPosition(gfx::PointF(0, size.height() - t rackWidth)); | |
| 360 | |
| 361 m_pinchZoomScrollbarVertical->setBounds(gfx::Size(trackWidth, size.height() - trackWidth)); | |
| 362 m_pinchZoomScrollbarVertical->setPosition(gfx::PointF(size.width() - trackWi dth, 0)); | |
| 363 } | |
| 364 | |
| 365 static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar( | |
| 366 WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner) | |
| 367 { | |
| 368 scoped_refptr<ScrollbarLayer> scrollbarLayer = ScrollbarLayer::create( | |
| 369 make_scoped_ptr( | |
| 370 new PinchZoomScrollbar(orientation, owner)).PassAs<WebKit::WebScroll bar>(), | |
| 371 scoped_ptr<ScrollbarThemePainter>(new PinchZoomScrollbarPainter).Pass(), | |
| 372 scoped_ptr<WebKit::WebScrollbarThemeGeometry>( | |
| 373 new PinchZoomScrollbarGeometry).Pass(), | |
| 374 Layer::s_invalidLayerId); | |
| 375 scrollbarLayer->setIsDrawable(true); | |
| 376 scrollbarLayer->setOpacity(0); | |
| 377 return scrollbarLayer; | |
| 378 } | |
| 379 | |
| 380 void LayerTreeHost::createAndAddPinchZoomScrollbars() | |
| 381 { | |
| 382 bool needsPropertiesUpdated = false; | |
| 383 | |
| 384 if (!m_pinchZoomScrollbarHorizontal || !m_pinchZoomScrollbarVertical) { | |
| 385 m_pinchZoomScrollbarHorizontal = CreatePinchZoomScrollbar(WebKit::WebScr ollbar::Horizontal, this); | |
| 386 m_pinchZoomScrollbarVertical = CreatePinchZoomScrollbar( WebKit::WebScro llbar::Vertical, this); | |
| 387 needsPropertiesUpdated = true; | |
| 388 } | |
| 389 | |
| 390 DCHECK(m_pinchZoomScrollbarHorizontal && m_pinchZoomScrollbarVertical); | |
| 391 | |
| 392 if (!m_pinchZoomScrollbarHorizontal->parent()) | |
| 393 m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal); | |
| 394 | |
| 395 if (!m_pinchZoomScrollbarVertical->parent()) | |
| 396 m_rootLayer->addChild(m_pinchZoomScrollbarVertical); | |
| 397 | |
| 398 if (needsPropertiesUpdated) | |
| 399 setPinchZoomScrollbarsBoundsAndPosition(); | |
| 400 } | |
| 401 | |
| 341 void LayerTreeHost::willCommit() | 402 void LayerTreeHost::willCommit() |
| 342 { | 403 { |
| 343 m_client->willCommit(); | 404 m_client->willCommit(); |
| 405 | |
| 406 if (m_settings.usePinchZoomScrollbars) | |
| 407 createAndAddPinchZoomScrollbars(); | |
| 344 } | 408 } |
| 345 | 409 |
| 346 void LayerTreeHost::updateHudLayer() | 410 void LayerTreeHost::updateHudLayer() |
| 347 { | 411 { |
| 348 if (m_debugState.showHudInfo()) { | 412 if (m_debugState.showHudInfo()) { |
| 349 if (!m_hudLayer) | 413 if (!m_hudLayer) |
| 350 m_hudLayer = HeadsUpDisplayLayer::create(); | 414 m_hudLayer = HeadsUpDisplayLayer::create(); |
| 351 | 415 |
| 352 if (m_rootLayer && !m_hudLayer->parent()) | 416 if (m_rootLayer && !m_hudLayer->parent()) |
| 353 m_rootLayer->addChild(m_hudLayer); | 417 m_rootLayer->addChild(m_hudLayer); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 } | 558 } |
| 495 | 559 |
| 496 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) | 560 void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g fx::Size& deviceViewportSize) |
| 497 { | 561 { |
| 498 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) | 562 if (layoutViewportSize == m_layoutViewportSize && deviceViewportSize == m_de viceViewportSize) |
| 499 return; | 563 return; |
| 500 | 564 |
| 501 m_layoutViewportSize = layoutViewportSize; | 565 m_layoutViewportSize = layoutViewportSize; |
| 502 m_deviceViewportSize = deviceViewportSize; | 566 m_deviceViewportSize = deviceViewportSize; |
| 503 | 567 |
| 568 setPinchZoomScrollbarsBoundsAndPosition(); | |
| 504 setNeedsCommit(); | 569 setNeedsCommit(); |
| 505 } | 570 } |
| 506 | 571 |
| 507 void LayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float min PageScaleFactor, float maxPageScaleFactor) | 572 void LayerTreeHost::setPageScaleFactorAndLimits(float pageScaleFactor, float min PageScaleFactor, float maxPageScaleFactor) |
| 508 { | 573 { |
| 509 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor) | 574 if (pageScaleFactor == m_pageScaleFactor && minPageScaleFactor == m_minPageS caleFactor && maxPageScaleFactor == m_maxPageScaleFactor) |
| 510 return; | 575 return; |
| 511 | 576 |
| 512 m_pageScaleFactor = pageScaleFactor; | 577 m_pageScaleFactor = pageScaleFactor; |
| 513 m_minPageScaleFactor = minPageScaleFactor; | 578 m_minPageScaleFactor = minPageScaleFactor; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 | 652 |
| 588 for (size_t i = 0; i < layer->children().size(); ++i) { | 653 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 589 Layer* found = findFirstScrollableLayer(layer->children()[i].get()); | 654 Layer* found = findFirstScrollableLayer(layer->children()[i].get()); |
| 590 if (found) | 655 if (found) |
| 591 return found; | 656 return found; |
| 592 } | 657 } |
| 593 | 658 |
| 594 return 0; | 659 return 0; |
| 595 } | 660 } |
| 596 | 661 |
| 662 const Layer* LayerTreeHost::rootScrollLayer() const | |
| 663 { | |
| 664 return findFirstScrollableLayer(m_rootLayer.get()); | |
| 665 } | |
| 666 | |
| 597 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) | 667 void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) |
| 598 { | 668 { |
| 599 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); | 669 TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); |
| 600 | 670 |
| 601 LayerList updateList; | 671 LayerList updateList; |
| 602 | 672 |
| 603 { | 673 { |
| 604 Layer* rootScroll = findFirstScrollableLayer(rootLayer); | 674 Layer* rootScroll = findFirstScrollableLayer(rootLayer); |
| 605 if (rootScroll) | 675 if (rootScroll) |
| 606 rootScroll->setImplTransform(m_implTransform); | 676 rootScroll->setImplTransform(m_implTransform); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) | 979 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) |
| 910 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); | 980 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); |
| 911 } | 981 } |
| 912 | 982 |
| 913 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 983 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
| 914 { | 984 { |
| 915 return m_proxy->capturePicture(); | 985 return m_proxy->capturePicture(); |
| 916 } | 986 } |
| 917 | 987 |
| 918 } // namespace cc | 988 } // namespace cc |
| OLD | NEW |