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

Side by Side Diff: cc/animation/element_animations.cc

Issue 1894023002: CC Animation: Make ElementAnimations a ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/animation/animation_host.h" 9 #include "cc/animation/animation_host.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
11 #include "cc/trees/mutator_host_client.h" 11 #include "cc/trees/mutator_host_client.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 std::unique_ptr<ElementAnimations> ElementAnimations::Create( 15 scoped_refptr<ElementAnimations> ElementAnimations::Create(
16 AnimationHost* host) { 16 AnimationHost* host) {
17 return base::WrapUnique(new ElementAnimations(host)); 17 return make_scoped_refptr(new ElementAnimations(host));
18 } 18 }
19 19
20 ElementAnimations::ElementAnimations(AnimationHost* host) 20 ElementAnimations::ElementAnimations(AnimationHost* host)
21 : players_list_(new PlayersList()), animation_host_(host) { 21 : players_list_(new PlayersList()), animation_host_(host) {
22 DCHECK(animation_host_); 22 DCHECK(animation_host_);
23 } 23 }
24 24
25 ElementAnimations::~ElementAnimations() { 25 ElementAnimations::~ElementAnimations() {
26 DCHECK(!layer_animation_controller_); 26 DCHECK(!layer_animation_controller_);
27 } 27 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return; 96 return;
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 bool ElementAnimations::IsEmpty() const { 101 bool ElementAnimations::IsEmpty() const {
102 return players_list_->empty(); 102 return players_list_->empty();
103 } 103 }
104 104
105 void ElementAnimations::PushPropertiesTo( 105 void ElementAnimations::PushPropertiesTo(
106 ElementAnimations* element_animations_impl) { 106 scoped_refptr<ElementAnimations> element_animations_impl) {
107 DCHECK(layer_animation_controller_); 107 DCHECK(layer_animation_controller_);
108 DCHECK(element_animations_impl->layer_animation_controller_); 108 DCHECK(element_animations_impl->layer_animation_controller_);
109 109
110 layer_animation_controller_->PushAnimationUpdatesTo( 110 layer_animation_controller_->PushAnimationUpdatesTo(
111 element_animations_impl->layer_animation_controller_.get()); 111 element_animations_impl->layer_animation_controller_.get());
112 } 112 }
113 113
114 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { 114 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) {
115 layer_animation_controller_->AddAnimation(std::move(animation)); 115 layer_animation_controller_->AddAnimation(std::move(animation));
116 } 116 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 LayerTreeType tree_type, 184 LayerTreeType tree_type,
185 const gfx::ScrollOffset& scroll_offset) { 185 const gfx::ScrollOffset& scroll_offset) {
186 DCHECK(layer_id()); 186 DCHECK(layer_id());
187 DCHECK(animation_host()); 187 DCHECK(animation_host());
188 DCHECK(animation_host()->mutator_host_client()); 188 DCHECK(animation_host()->mutator_host_client());
189 animation_host()->mutator_host_client()->SetLayerScrollOffsetMutated( 189 animation_host()->mutator_host_client()->SetLayerScrollOffsetMutated(
190 layer_id(), tree_type, scroll_offset); 190 layer_id(), tree_type, scroll_offset);
191 } 191 }
192 192
193 void ElementAnimations::OnAnimationWaitingForDeletion() { 193 void ElementAnimations::OnAnimationWaitingForDeletion() {
194 // TODO(loyso): See Layer::OnAnimationWaitingForDeletion. But we always do 194 // TODO(loyso): Invalidate AnimationHost::SetNeedsPushProperties here.
195 // PushProperties for AnimationTimelines for now. 195 // But we always do PushProperties in AnimationHost for now. crbug.com/604280
196 } 196 }
197 197
198 void ElementAnimations::OnTransformIsPotentiallyAnimatingChanged( 198 void ElementAnimations::OnTransformIsPotentiallyAnimatingChanged(
199 LayerTreeType tree_type, 199 LayerTreeType tree_type,
200 bool is_animating) { 200 bool is_animating) {
201 DCHECK(layer_id()); 201 DCHECK(layer_id());
202 DCHECK(animation_host()); 202 DCHECK(animation_host());
203 DCHECK(animation_host()->mutator_host_client()); 203 DCHECK(animation_host()->mutator_host_client());
204 animation_host() 204 animation_host()
205 ->mutator_host_client() 205 ->mutator_host_client()
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (animation_host()) { 283 if (animation_host()) {
284 DCHECK(animation_host()->mutator_host_client()); 284 DCHECK(animation_host()->mutator_host_client());
285 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 285 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
286 layer_id()); 286 layer_id());
287 } 287 }
288 288
289 return gfx::ScrollOffset(); 289 return gfx::ScrollOffset();
290 } 290 }
291 291
292 } // namespace cc 292 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698