Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 95763002: cc: Support animating scroll offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/scrollbar_animation_controller.h" 10 #include "cc/animation/scrollbar_animation_controller.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 current_draw_mode_(DRAW_MODE_NONE), 67 current_draw_mode_(DRAW_MODE_NONE),
68 horizontal_scrollbar_layer_(NULL), 68 horizontal_scrollbar_layer_(NULL),
69 vertical_scrollbar_layer_(NULL) { 69 vertical_scrollbar_layer_(NULL) {
70 DCHECK_GT(layer_id_, 0); 70 DCHECK_GT(layer_id_, 0);
71 DCHECK(layer_tree_impl_); 71 DCHECK(layer_tree_impl_);
72 layer_tree_impl_->RegisterLayer(this); 72 layer_tree_impl_->RegisterLayer(this);
73 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); 73 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar();
74 layer_animation_controller_ = 74 layer_animation_controller_ =
75 registrar->GetAnimationControllerForId(layer_id_); 75 registrar->GetAnimationControllerForId(layer_id_);
76 layer_animation_controller_->AddValueObserver(this); 76 layer_animation_controller_->AddValueObserver(this);
77 if (IsActive())
78 layer_animation_controller_->set_value_provider(this);
77 } 79 }
78 80
79 LayerImpl::~LayerImpl() { 81 LayerImpl::~LayerImpl() {
80 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 82 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
81 83
84 layer_animation_controller_->RemoveValueObserver(this);
85 layer_animation_controller_->remove_value_provider(this);
86
82 layer_tree_impl_->UnregisterLayer(this); 87 layer_tree_impl_->UnregisterLayer(this);
83 layer_animation_controller_->RemoveValueObserver(this);
84 88
85 if (scroll_children_) { 89 if (scroll_children_) {
86 for (std::set<LayerImpl*>::iterator it = scroll_children_->begin(); 90 for (std::set<LayerImpl*>::iterator it = scroll_children_->begin();
87 it != scroll_children_->end(); ++it) 91 it != scroll_children_->end(); ++it)
88 (*it)->scroll_parent_ = NULL; 92 (*it)->scroll_parent_ = NULL;
89 } 93 }
90 94
91 if (scroll_parent_) 95 if (scroll_parent_)
92 scroll_parent_->RemoveScrollChild(this); 96 scroll_parent_->RemoveScrollChild(this);
93 97
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 684 }
681 685
682 for (size_t i = 0; i < children_.size(); ++i) 686 for (size_t i = 0; i < children_.size(); ++i)
683 children_[i]->ResetAllChangeTrackingForSubtree(); 687 children_[i]->ResetAllChangeTrackingForSubtree();
684 } 688 }
685 689
686 bool LayerImpl::LayerIsAlwaysDamaged() const { 690 bool LayerImpl::LayerIsAlwaysDamaged() const {
687 return false; 691 return false;
688 } 692 }
689 693
694 gfx::Vector2dF LayerImpl::ScrollOffsetForAnimation() const {
695 return TotalScrollOffset();
696 }
697
690 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { 698 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) {
691 SetFilters(filters); 699 SetFilters(filters);
692 } 700 }
693 701
694 void LayerImpl::OnOpacityAnimated(float opacity) { 702 void LayerImpl::OnOpacityAnimated(float opacity) {
695 SetOpacity(opacity); 703 SetOpacity(opacity);
696 } 704 }
697 705
698 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) { 706 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) {
699 SetTransform(transform); 707 SetTransform(transform);
700 } 708 }
701 709
710 void LayerImpl::OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) {
711 // Only layers in the active tree should need to do anything here, since
712 // layers in the pending tree will find out about these changes as a
713 // result of the call to SetScrollDelta.
714 if (!IsActive())
715 return;
716
717 SetScrollDelta(scroll_offset - scroll_offset_);
718
719 layer_tree_impl_->DidAnimateScrollOffset();
720 }
721
702 void LayerImpl::OnAnimationWaitingForDeletion() {} 722 void LayerImpl::OnAnimationWaitingForDeletion() {}
703 723
704 bool LayerImpl::IsActive() const { 724 bool LayerImpl::IsActive() const {
705 return layer_tree_impl_->IsActiveTree(); 725 return layer_tree_impl_->IsActiveTree();
706 } 726 }
707 727
708 void LayerImpl::SetBounds(gfx::Size bounds) { 728 void LayerImpl::SetBounds(gfx::Size bounds) {
709 if (bounds_ == bounds) 729 if (bounds_ == bounds)
710 return; 730 return;
711 731
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1392 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1373 AsValueInto(state.get()); 1393 AsValueInto(state.get());
1374 return state.PassAs<base::Value>(); 1394 return state.PassAs<base::Value>();
1375 } 1395 }
1376 1396
1377 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1397 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1378 benchmark->RunOnLayer(this); 1398 benchmark->RunOnLayer(this);
1379 } 1399 }
1380 1400
1381 } // namespace cc 1401 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698