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_impl.h" | 5 #include "cc/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/heads_up_display_layer_impl.h" | 8 #include "cc/heads_up_display_layer_impl.h" |
| 9 #include "cc/layer_tree_host_common.h" | 9 #include "cc/layer_tree_host_common.h" |
| 10 #include "cc/layer_tree_host_impl.h" | 10 #include "cc/layer_tree_host_impl.h" |
| 11 #include "cc/scrollbar_layer_impl.h" | |
| 11 #include "ui/gfx/vector2d_conversions.h" | 12 #include "ui/gfx/vector2d_conversions.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) | 16 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) |
| 16 : layer_tree_host_impl_(layer_tree_host_impl), | 17 : layer_tree_host_impl_(layer_tree_host_impl), |
| 17 source_frame_number_(-1), | 18 source_frame_number_(-1), |
| 18 hud_layer_(0), | 19 hud_layer_(0), |
| 19 root_scroll_layer_(0), | 20 root_scroll_layer_(0), |
| 20 currently_scrolling_layer_(0), | 21 currently_scrolling_layer_(0), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 target_tree->SetViewportSizeInvalid(); | 110 target_tree->SetViewportSizeInvalid(); |
| 110 else | 111 else |
| 111 target_tree->ResetViewportSizeInvalid(); | 112 target_tree->ResetViewportSizeInvalid(); |
| 112 | 113 |
| 113 if (hud_layer()) | 114 if (hud_layer()) |
| 114 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 115 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
| 115 LayerTreeHostCommon::findLayerInSubtree( | 116 LayerTreeHostCommon::findLayerInSubtree( |
| 116 target_tree->RootLayer(), hud_layer()->id()))); | 117 target_tree->RootLayer(), hud_layer()->id()))); |
| 117 else | 118 else |
| 118 target_tree->set_hud_layer(NULL); | 119 target_tree->set_hud_layer(NULL); |
| 120 | |
| 121 target_tree->SetPinchZoomHorizontalLayerId(pinch_zoom_scrollbar_horizontal_lay er_id); | |
| 122 target_tree->SetPinchZoomVerticalLayerId(pinch_zoom_scrollbar_vertical_layer_i d); | |
| 119 } | 123 } |
| 120 | 124 |
| 121 LayerImpl* LayerTreeImpl::RootScrollLayer() { | 125 LayerImpl* LayerTreeImpl::RootScrollLayer() { |
| 122 DCHECK(IsActiveTree()); | 126 DCHECK(IsActiveTree()); |
| 123 return root_scroll_layer_; | 127 return root_scroll_layer_; |
| 124 } | 128 } |
| 125 | 129 |
| 126 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() { | 130 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() { |
| 127 DCHECK(IsActiveTree()); | 131 DCHECK(IsActiveTree()); |
| 128 return currently_scrolling_layer_; | 132 return currently_scrolling_layer_; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_); | 483 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_); |
| 480 for (LayerIteratorType it = LayerIteratorType::begin( | 484 for (LayerIteratorType it = LayerIteratorType::begin( |
| 481 &render_surface_layer_list_); it != end; ++it) { | 485 &render_surface_layer_list_); it != end; ++it) { |
| 482 if (!it.representsItself()) | 486 if (!it.representsItself()) |
| 483 continue; | 487 continue; |
| 484 state->Append((*it)->AsValue().release()); | 488 state->Append((*it)->AsValue().release()); |
| 485 } | 489 } |
| 486 return state.PassAs<base::Value>(); | 490 return state.PassAs<base::Value>(); |
| 487 } | 491 } |
| 488 | 492 |
| 493 void LayerTreeImpl::SetPinchZoomHorizontalLayerId(int layer_id) { | |
| 494 pinch_zoom_scrollbar_horizontal_layer_id = layer_id; | |
| 495 } | |
| 496 | |
| 497 ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarHorizontal() { | |
| 498 return static_cast<ScrollbarLayerImpl*>(LayerById( | |
| 499 pinch_zoom_scrollbar_horizontal_layer_id)); | |
| 500 } | |
| 501 | |
| 502 void LayerTreeImpl::SetPinchZoomVerticalLayerId(int layer_id) { | |
| 503 pinch_zoom_scrollbar_vertical_layer_id = layer_id; | |
| 504 } | |
| 505 | |
| 506 ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarVertical() { | |
| 507 return static_cast<ScrollbarLayerImpl*>(LayerById( | |
| 508 pinch_zoom_scrollbar_vertical_layer_id)); | |
| 509 } | |
| 510 | |
| 511 void LayerTreeImpl::UpdatePinchZoomScrollbarsIfNeeded() { | |
| 512 LayerImpl* rootScrollLayer = RootScrollLayer(); | |
| 513 if (!rootScrollLayer || (rootScrollLayer != CurrentlyScrollingLayer())) | |
| 514 return; | |
| 515 | |
| 516 if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarHorizontal()) { | |
| 517 scrollbar->setCurrentPos(rootScrollLayer->scrollOffset().x()); | |
| 518 scrollbar->setTotalSize(rootScrollLayer->bounds().width()); | |
| 519 scrollbar->setMaximum(rootScrollLayer->maxScrollOffset().x()); | |
| 520 } | |
| 521 if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarVertical()) { | |
| 522 scrollbar->setCurrentPos(rootScrollLayer->scrollOffset().y()); | |
| 523 scrollbar->setTotalSize(rootScrollLayer->bounds().height()); | |
| 524 scrollbar->setMaximum(rootScrollLayer->maxScrollOffset().y()); | |
| 525 } | |
| 526 } | |
| 527 | |
| 528 void LayerTreeImpl::SetPinchZoomScrollbarsVisibility() { | |
| 529 LayerImpl* rootScrollLayer = RootScrollLayer(); | |
| 530 bool pinchZoomScrollbarShouldDraw = rootScrollLayer && | |
| 531 rootScrollLayer == CurrentlyScrollingLayer() && | |
| 532 total_page_scale_factor() > 1; | |
| 533 | |
| 534 float opacity = pinchZoomScrollbarShouldDraw ? 0.5 : 0; | |
|
jamesr
2013/02/26 20:48:46
0.5 seems like another magical value - where does
wjmaclean
2013/03/01 15:30:32
Fixed.
| |
| 535 | |
| 536 if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarHorizontal()) | |
| 537 scrollbar->setOpacity(opacity); | |
| 538 | |
| 539 if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarVertical()) | |
| 540 scrollbar->setOpacity(opacity); | |
| 541 } | |
| 542 | |
| 489 } // namespace cc | 543 } // namespace cc |
| OLD | NEW |