| 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/animation.h" | 8 #include "cc/animation.h" |
| 9 #include "cc/animation_id_provider.h" | 9 #include "cc/animation_id_provider.h" |
| 10 #include "cc/heads_up_display_layer_impl.h" | 10 #include "cc/heads_up_display_layer_impl.h" |
| 11 #include "cc/keyframed_animation_curve.h" | 11 #include "cc/keyframed_animation_curve.h" |
| 12 #include "cc/layer.h" | 12 #include "cc/layer.h" |
| 13 #include "cc/layer_tree_host_common.h" | 13 #include "cc/layer_tree_host_common.h" |
| 14 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
| 15 #include "cc/pinch_zoom_scrollbar.h" | 15 #include "cc/pinch_zoom_scrollbar.h" |
| 16 #include "cc/scrollbar_animation_controller.h" |
| 16 #include "cc/scrollbar_layer_impl.h" | 17 #include "cc/scrollbar_layer_impl.h" |
| 17 #include "ui/gfx/size_conversions.h" | 18 #include "ui/gfx/size_conversions.h" |
| 18 #include "ui/gfx/vector2d_conversions.h" | 19 #include "ui/gfx/vector2d_conversions.h" |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 | 22 |
| 22 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) | 23 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) |
| 23 : layer_tree_host_impl_(layer_tree_host_impl), | 24 : layer_tree_host_impl_(layer_tree_host_impl), |
| 24 source_frame_number_(-1), | 25 source_frame_number_(-1), |
| 25 hud_layer_(0), | 26 hud_layer_(0), |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 139 |
| 139 LayerImpl* LayerTreeImpl::RootClipLayer() const { | 140 LayerImpl* LayerTreeImpl::RootClipLayer() const { |
| 140 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL; | 141 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL; |
| 141 } | 142 } |
| 142 | 143 |
| 143 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { | 144 LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { |
| 144 DCHECK(IsActiveTree()); | 145 DCHECK(IsActiveTree()); |
| 145 return currently_scrolling_layer_; | 146 return currently_scrolling_layer_; |
| 146 } | 147 } |
| 147 | 148 |
| 149 void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) { |
| 150 if (currently_scrolling_layer_ == layer) |
| 151 return; |
| 152 |
| 153 if (currently_scrolling_layer_ && |
| 154 currently_scrolling_layer_->scrollbar_animation_controller()) |
| 155 currently_scrolling_layer_->scrollbar_animation_controller() |
| 156 ->didScrollGestureEnd(base::TimeTicks::Now()); |
| 157 currently_scrolling_layer_ = layer; |
| 158 if (layer && layer->scrollbar_animation_controller()) |
| 159 layer->scrollbar_animation_controller()->didScrollGestureBegin(); |
| 160 } |
| 161 |
| 148 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { | 162 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
| 149 currently_scrolling_layer_ = NULL; | 163 SetCurrentlyScrollingLayer(NULL); |
| 150 scrolling_layer_id_from_previous_tree_ = 0; | 164 scrolling_layer_id_from_previous_tree_ = 0; |
| 151 } | 165 } |
| 152 | 166 |
| 153 void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor, | 167 void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor, |
| 154 float min_page_scale_factor, float max_page_scale_factor) { | 168 float min_page_scale_factor, float max_page_scale_factor) { |
| 155 if (!page_scale_factor) | 169 if (!page_scale_factor) |
| 156 return; | 170 return; |
| 157 | 171 |
| 158 min_page_scale_factor_ = min_page_scale_factor; | 172 min_page_scale_factor_ = min_page_scale_factor; |
| 159 max_page_scale_factor_ = max_page_scale_factor; | 173 max_page_scale_factor_ = max_page_scale_factor; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 layer_id_map_[layer->id()] = layer; | 369 layer_id_map_[layer->id()] = layer; |
| 356 } | 370 } |
| 357 | 371 |
| 358 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 372 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 359 DCHECK(LayerById(layer->id())); | 373 DCHECK(LayerById(layer->id())); |
| 360 layer_id_map_.erase(layer->id()); | 374 layer_id_map_.erase(layer->id()); |
| 361 } | 375 } |
| 362 | 376 |
| 363 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { | 377 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { |
| 364 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; | 378 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; |
| 365 pendingTree->set_currently_scrolling_layer( | 379 pendingTree->SetCurrentlyScrollingLayer( |
| 366 LayerTreeHostCommon::findLayerInSubtree(pendingTree->root_layer(), id)); | 380 LayerTreeHostCommon::findLayerInSubtree(pendingTree->root_layer(), id)); |
| 367 } | 381 } |
| 368 | 382 |
| 369 static void DidBecomeActiveRecursive(LayerImpl* layer) { | 383 static void DidBecomeActiveRecursive(LayerImpl* layer) { |
| 370 layer->DidBecomeActive(); | 384 layer->DidBecomeActive(); |
| 371 for (size_t i = 0; i < layer->children().size(); ++i) | 385 for (size_t i = 0; i < layer->children().size(); ++i) |
| 372 DidBecomeActiveRecursive(layer->children()[i]); | 386 DidBecomeActiveRecursive(layer->children()[i]); |
| 373 } | 387 } |
| 374 | 388 |
| 375 void LayerTreeImpl::DidBecomeActive() { | 389 void LayerTreeImpl::DidBecomeActive() { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 StartFadeOutAnimation(PinchZoomScrollbarVertical()); | 655 StartFadeOutAnimation(PinchZoomScrollbarVertical()); |
| 642 } | 656 } |
| 643 | 657 |
| 644 bool LayerTreeImpl::HasPinchZoomScrollbars() const { | 658 bool LayerTreeImpl::HasPinchZoomScrollbars() const { |
| 645 return pinch_zoom_scrollbar_horizontal_layer_id_ != Layer::INVALID_ID && | 659 return pinch_zoom_scrollbar_horizontal_layer_id_ != Layer::INVALID_ID && |
| 646 pinch_zoom_scrollbar_vertical_layer_id_ != Layer::INVALID_ID; | 660 pinch_zoom_scrollbar_vertical_layer_id_ != Layer::INVALID_ID; |
| 647 } | 661 } |
| 648 | 662 |
| 649 | 663 |
| 650 } // namespace cc | 664 } // namespace cc |
| OLD | NEW |