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

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: 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
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver() 214 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
215 : opacity_(0.0f), 215 : opacity_(0.0f),
216 animation_waiting_for_deletion_(false), 216 animation_waiting_for_deletion_(false),
217 transform_is_animating_(false) {} 217 transform_is_animating_(false) {}
218 218
219 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {} 219 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {}
220 220
221 void FakeLayerAnimationValueObserver::OnFilterAnimated( 221 void FakeLayerAnimationValueObserver::OnFilterAnimated(
222 LayerTreeType tree_type,
222 const FilterOperations& filters) { 223 const FilterOperations& filters) {
223 filters_ = filters; 224 filters_ = filters;
224 } 225 }
225 226
226 void FakeLayerAnimationValueObserver::OnOpacityAnimated(float opacity) { 227 void FakeLayerAnimationValueObserver::OnOpacityAnimated(LayerTreeType tree_type,
228 float opacity) {
227 opacity_ = opacity; 229 opacity_ = opacity;
228 } 230 }
229 231
230 void FakeLayerAnimationValueObserver::OnTransformAnimated( 232 void FakeLayerAnimationValueObserver::OnTransformAnimated(
233 LayerTreeType tree_type,
231 const gfx::Transform& transform) { 234 const gfx::Transform& transform) {
232 transform_ = transform; 235 transform_ = transform;
233 } 236 }
234 237
235 void FakeLayerAnimationValueObserver::OnScrollOffsetAnimated( 238 void FakeLayerAnimationValueObserver::OnScrollOffsetAnimated(
239 LayerTreeType tree_type,
236 const gfx::ScrollOffset& scroll_offset) { 240 const gfx::ScrollOffset& scroll_offset) {
237 scroll_offset_ = scroll_offset; 241 scroll_offset_ = scroll_offset;
238 } 242 }
239 243
240 void FakeLayerAnimationValueObserver::OnAnimationWaitingForDeletion() { 244 void FakeLayerAnimationValueObserver::OnAnimationWaitingForDeletion() {
241 animation_waiting_for_deletion_ = true; 245 animation_waiting_for_deletion_ = true;
242 } 246 }
243 247
244 void FakeLayerAnimationValueObserver::OnTransformIsPotentiallyAnimatingChanged( 248 void FakeLayerAnimationValueObserver::OnTransformIsPotentiallyAnimatingChanged(
249 LayerTreeType tree_type,
245 bool is_animating) { 250 bool is_animating) {
246 transform_is_animating_ = is_animating; 251 transform_is_animating_ = is_animating;
247 } 252 }
248 253
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() 254 gfx::ScrollOffset FakeLayerAnimationValueProvider::ScrollOffsetForAnimation()
258 const { 255 const {
259 return scroll_offset_; 256 return scroll_offset_;
260 } 257 }
261 258
259 FakeTypedLayerAnimationValueObserver::FakeTypedLayerAnimationValueObserver()
260 : animation_waiting_for_deletion_(false) {
261 opacity_[ToIndex(LayerTreeType::ACTIVE)] = 0.0f;
262 opacity_[ToIndex(LayerTreeType::PENDING)] = 0.0f;
263
264 transform_is_animating_[ToIndex(LayerTreeType::ACTIVE)] = false;
265 transform_is_animating_[ToIndex(LayerTreeType::PENDING)] = false;
266 }
267
268 FakeTypedLayerAnimationValueObserver::~FakeTypedLayerAnimationValueObserver() {}
269
270 int FakeTypedLayerAnimationValueObserver::ToIndex(LayerTreeType tree_type) {
271 int index = static_cast<int>(tree_type);
272 DCHECK_GE(index, 0);
273 DCHECK_LE(index, 1);
274 return index;
275 }
276
277 void FakeTypedLayerAnimationValueObserver::OnFilterAnimated(
278 LayerTreeType tree_type,
279 const FilterOperations& filters) {
280 filters_[ToIndex(tree_type)] = filters;
281 }
282
283 void FakeTypedLayerAnimationValueObserver::OnOpacityAnimated(
284 LayerTreeType tree_type,
285 float opacity) {
286 opacity_[ToIndex(tree_type)] = opacity;
287 }
288
289 void FakeTypedLayerAnimationValueObserver::OnTransformAnimated(
290 LayerTreeType tree_type,
291 const gfx::Transform& transform) {
292 transform_[ToIndex(tree_type)] = transform;
293 }
294
295 void FakeTypedLayerAnimationValueObserver::OnScrollOffsetAnimated(
296 LayerTreeType tree_type,
297 const gfx::ScrollOffset& scroll_offset) {
298 scroll_offset_[ToIndex(tree_type)] = scroll_offset;
299 }
300
301 void FakeTypedLayerAnimationValueObserver::OnAnimationWaitingForDeletion() {
302 animation_waiting_for_deletion_ = true;
303 }
304
305 void FakeTypedLayerAnimationValueObserver::
306 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type,
307 bool is_animating) {
308 transform_is_animating_[ToIndex(tree_type)] = is_animating;
309 }
310
262 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const { 311 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const {
263 return base::WrapUnique(new FakeFloatTransition(*this)); 312 return base::WrapUnique(new FakeFloatTransition(*this));
264 } 313 }
265 314
266 int AddOpacityTransitionToController(LayerAnimationController* controller, 315 int AddOpacityTransitionToController(LayerAnimationController* controller,
267 double duration, 316 double duration,
268 float start_opacity, 317 float start_opacity,
269 float end_opacity, 318 float end_opacity,
270 bool use_timing_function) { 319 bool use_timing_function) {
271 return AddOpacityTransition(controller, 320 return AddOpacityTransition(controller,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void AbortAnimationsOnLayerWithPlayer(int layer_id, 503 void AbortAnimationsOnLayerWithPlayer(int layer_id,
455 scoped_refptr<AnimationTimeline> timeline, 504 scoped_refptr<AnimationTimeline> timeline,
456 TargetProperty::Type target_property) { 505 TargetProperty::Type target_property) {
457 LayerAnimationController* controller = 506 LayerAnimationController* controller =
458 timeline->animation_host()->GetControllerForLayerId(layer_id); 507 timeline->animation_host()->GetControllerForLayerId(layer_id);
459 DCHECK(controller); 508 DCHECK(controller);
460 controller->AbortAnimations(target_property); 509 controller->AbortAnimations(target_property);
461 } 510 }
462 511
463 } // namespace cc 512 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698