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

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

Issue 1009233002: CC Animations: Port Impl-only-scrolling to use compositor animation timelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ui
Patch Set: Add unittests. Created 5 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/animation_host.cc ('k') | cc/animation/animation_player_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/animation_player.h" 5 #include "cc/animation/animation_player.h"
6 6
7 #include "cc/animation/animation_host.h" 7 #include "cc/animation/animation_host.h"
8 #include "cc/animation/animation_registrar.h" 8 #include "cc/animation/animation_registrar.h"
9 #include "cc/animation/animation_timeline.h" 9 #include "cc/animation/animation_timeline.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 19 matching lines...) Expand all
30 30
31 void OnTransformAnimated(const gfx::Transform& transform) override { 31 void OnTransformAnimated(const gfx::Transform& transform) override {
32 player_->SetTransformMutated(is_active_, transform); 32 player_->SetTransformMutated(is_active_, transform);
33 } 33 }
34 34
35 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override { 35 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override {
36 player_->SetScrollOffsetMutated(is_active_, scroll_offset); 36 player_->SetScrollOffsetMutated(is_active_, scroll_offset);
37 } 37 }
38 38
39 void OnAnimationWaitingForDeletion() override { 39 void OnAnimationWaitingForDeletion() override {
40 // TODO(loyso): implement it. 40 // TODO(loyso): See Layer::OnAnimationWaitingForDeletion. But we always do
41 // PushProperties for AnimationTimelines for now.
41 } 42 }
42 43
43 bool IsActive() const override { return is_active_; } 44 bool IsActive() const override { return is_active_; }
44 45
45 private: 46 private:
46 AnimationPlayer* player_; 47 AnimationPlayer* player_;
47 bool is_active_; 48 bool is_active_;
48 49
49 DISALLOW_COPY_AND_ASSIGN(ValueObserver); 50 DISALLOW_COPY_AND_ASSIGN(ValueObserver);
50 }; 51 };
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 164 }
164 } 165 }
165 166
166 void AnimationPlayer::LayerUnregistered(int layer_id, bool is_active_tree) { 167 void AnimationPlayer::LayerUnregistered(int layer_id, bool is_active_tree) {
167 DCHECK_EQ(layer_id_, layer_id); 168 DCHECK_EQ(layer_id_, layer_id);
168 is_active_tree ? DestroyActiveValueObserver() : DestroyPendingValueObserver(); 169 is_active_tree ? DestroyActiveValueObserver() : DestroyPendingValueObserver();
169 } 170 }
170 171
171 void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) { 172 void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) {
172 DCHECK(layer_animation_controller_); 173 DCHECK(layer_animation_controller_);
174 DCHECK(animation->target_property() != Animation::SCROLL_OFFSET ||
175 !animation_host_ || animation_host_->GetSupportsScrollAnimations());
173 layer_animation_controller_->AddAnimation(animation.Pass()); 176 layer_animation_controller_->AddAnimation(animation.Pass());
174 SetNeedsCommit(); 177 SetNeedsCommit();
175 } 178 }
176 179
177 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) { 180 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) {
178 DCHECK(layer_animation_controller_); 181 DCHECK(layer_animation_controller_);
179 layer_animation_controller_->PauseAnimation( 182 layer_animation_controller_->PauseAnimation(
180 animation_id, base::TimeDelta::FromSecondsD(time_offset)); 183 animation_id, base::TimeDelta::FromSecondsD(time_offset));
181 SetNeedsCommit(); 184 SetNeedsCommit();
182 } 185 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 284 }
282 285
283 void AnimationPlayer::DestroyPendingValueObserver() { 286 void AnimationPlayer::DestroyPendingValueObserver() {
284 if (layer_animation_controller_ && pending_value_observer_) 287 if (layer_animation_controller_ && pending_value_observer_)
285 layer_animation_controller_->RemoveValueObserver( 288 layer_animation_controller_->RemoveValueObserver(
286 pending_value_observer_.get()); 289 pending_value_observer_.get());
287 pending_value_observer_ = nullptr; 290 pending_value_observer_ = nullptr;
288 } 291 }
289 292
290 gfx::ScrollOffset AnimationPlayer::ScrollOffsetForAnimation() const { 293 gfx::ScrollOffset AnimationPlayer::ScrollOffsetForAnimation() const {
291 // TODO(loyso): implement it. 294 DCHECK(layer_id_);
295 if (animation_host()) {
296 DCHECK(animation_host()->layer_tree_mutators_client());
297 return animation_host()
298 ->layer_tree_mutators_client()
299 ->GetScrollOffsetForAnimation(layer_id_);
300 }
301
292 return gfx::ScrollOffset(); 302 return gfx::ScrollOffset();
293 } 303 }
294 304
295 } // namespace cc 305 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698