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

Side by Side Diff: cc/test/animation_test_common.cc

Issue 1882733005: CC Animation: Make LayerAnimationController to have just one value observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@privatelac
Patch Set: Fix codereview issues. 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/test/animation_test_common.h ('k') | cc/trees/layer_tree_host_unittest_animation.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 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/test/animation_test_common.h" 5 #include "cc/test/animation_test_common.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_id_provider.h" 9 #include "cc/animation/animation_id_provider.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return duration_; 204 return duration_;
205 } 205 }
206 206
207 float FakeFloatTransition::GetValue(base::TimeDelta time) const { 207 float FakeFloatTransition::GetValue(base::TimeDelta time) const {
208 double progress = TimeUtil::Divide(time, duration_); 208 double progress = TimeUtil::Divide(time, duration_);
209 if (progress >= 1.0) 209 if (progress >= 1.0)
210 progress = 1.0; 210 progress = 1.0;
211 return (1.0 - progress) * from_ + progress * to_; 211 return (1.0 - progress) * from_ + progress * to_;
212 } 212 }
213 213
214 gfx::ScrollOffset FakeLayerAnimationValueProvider::ScrollOffsetForAnimation()
215 const {
216 return scroll_offset_;
217 }
218
214 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver() 219 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
215 : opacity_(0.0f), 220 : animation_waiting_for_deletion_(false) {
216 animation_waiting_for_deletion_(false), 221 opacity_[ToIndex(LayerTreeType::ACTIVE)] = 0.0f;
217 transform_is_animating_(false) {} 222 opacity_[ToIndex(LayerTreeType::PENDING)] = 0.0f;
223
224 transform_is_animating_[ToIndex(LayerTreeType::ACTIVE)] = false;
225 transform_is_animating_[ToIndex(LayerTreeType::PENDING)] = false;
226 }
218 227
219 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {} 228 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {}
220 229
221 void FakeLayerAnimationValueObserver::OnFilterAnimated( 230 int FakeLayerAnimationValueObserver::ToIndex(LayerTreeType tree_type) {
222 const FilterOperations& filters) { 231 int index = static_cast<int>(tree_type);
223 filters_ = filters; 232 DCHECK_GE(index, 0);
233 DCHECK_LE(index, 1);
234 return index;
224 } 235 }
225 236
226 void FakeLayerAnimationValueObserver::OnOpacityAnimated(float opacity) { 237 void FakeLayerAnimationValueObserver::OnFilterAnimated(
227 opacity_ = opacity; 238 LayerTreeType tree_type,
239 const FilterOperations& filters) {
240 filters_[ToIndex(tree_type)] = filters;
241 }
242
243 void FakeLayerAnimationValueObserver::OnOpacityAnimated(LayerTreeType tree_type,
244 float opacity) {
245 opacity_[ToIndex(tree_type)] = opacity;
228 } 246 }
229 247
230 void FakeLayerAnimationValueObserver::OnTransformAnimated( 248 void FakeLayerAnimationValueObserver::OnTransformAnimated(
249 LayerTreeType tree_type,
231 const gfx::Transform& transform) { 250 const gfx::Transform& transform) {
232 transform_ = transform; 251 transform_[ToIndex(tree_type)] = transform;
233 } 252 }
234 253
235 void FakeLayerAnimationValueObserver::OnScrollOffsetAnimated( 254 void FakeLayerAnimationValueObserver::OnScrollOffsetAnimated(
255 LayerTreeType tree_type,
236 const gfx::ScrollOffset& scroll_offset) { 256 const gfx::ScrollOffset& scroll_offset) {
237 scroll_offset_ = scroll_offset; 257 scroll_offset_[ToIndex(tree_type)] = scroll_offset;
238 } 258 }
239 259
240 void FakeLayerAnimationValueObserver::OnAnimationWaitingForDeletion() { 260 void FakeLayerAnimationValueObserver::OnAnimationWaitingForDeletion() {
241 animation_waiting_for_deletion_ = true; 261 animation_waiting_for_deletion_ = true;
242 } 262 }
243 263
244 void FakeLayerAnimationValueObserver::OnTransformIsPotentiallyAnimatingChanged( 264 void FakeLayerAnimationValueObserver::OnTransformIsPotentiallyAnimatingChanged(
265 LayerTreeType tree_type,
245 bool is_animating) { 266 bool is_animating) {
246 transform_is_animating_ = is_animating; 267 transform_is_animating_[ToIndex(tree_type)] = is_animating;
247 }
248
249 bool FakeLayerAnimationValueObserver::IsActive() const {
250 return true;
251 }
252
253 bool FakeInactiveLayerAnimationValueObserver::IsActive() const {
254 return false;
255 }
256
257 gfx::ScrollOffset FakeLayerAnimationValueProvider::ScrollOffsetForAnimation()
258 const {
259 return scroll_offset_;
260 } 268 }
261 269
262 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const { 270 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const {
263 return base::WrapUnique(new FakeFloatTransition(*this)); 271 return base::WrapUnique(new FakeFloatTransition(*this));
264 } 272 }
265 273
266 int AddOpacityTransitionToController(LayerAnimationController* controller, 274 int AddOpacityTransitionToController(LayerAnimationController* controller,
267 double duration, 275 double duration,
268 float start_opacity, 276 float start_opacity,
269 float end_opacity, 277 float end_opacity,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void AbortAnimationsOnLayerWithPlayer(int layer_id, 462 void AbortAnimationsOnLayerWithPlayer(int layer_id,
455 scoped_refptr<AnimationTimeline> timeline, 463 scoped_refptr<AnimationTimeline> timeline,
456 TargetProperty::Type target_property) { 464 TargetProperty::Type target_property) {
457 LayerAnimationController* controller = 465 LayerAnimationController* controller =
458 timeline->animation_host()->GetControllerForLayerId(layer_id); 466 timeline->animation_host()->GetControllerForLayerId(layer_id);
459 DCHECK(controller); 467 DCHECK(controller);
460 controller->AbortAnimations(target_property); 468 controller->AbortAnimations(target_property);
461 } 469 }
462 470
463 } // namespace cc 471 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_test_common.h ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698