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

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

Issue 2261113002: CC Animation: Introduce some dirty flags to optimize PushProperties on commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests. Created 4 years, 4 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 curve->SetInitialValue(initial_value); 228 curve->SetInitialValue(initial_value);
229 229
230 int id = AnimationIdProvider::NextAnimationId(); 230 int id = AnimationIdProvider::NextAnimationId();
231 231
232 std::unique_ptr<Animation> animation(Animation::Create( 232 std::unique_ptr<Animation> animation(Animation::Create(
233 std::move(curve), id, AnimationIdProvider::NextGroupId(), 233 std::move(curve), id, AnimationIdProvider::NextGroupId(),
234 TargetProperty::SCROLL_OFFSET)); 234 TargetProperty::SCROLL_OFFSET));
235 animation->set_is_impl_only(impl_only); 235 animation->set_is_impl_only(impl_only);
236 236
237 target->AddAnimation(std::move(animation)); 237 target->AddAnimation(std::move(animation));
238 target->SetNeedsPushProperties();
ajuma 2016/08/24 15:52:37 Wdyt of making ElementAnimations responsible for s
loyso (OOO) 2016/08/25 00:38:24 ElementAnimations::AddAnimation is a legacy from L
loyso (OOO) 2016/08/25 03:59:02 Done.
238 239
239 return id; 240 return id;
240 } 241 }
241 242
242 int AddOpacityTransitionToElementAnimations(ElementAnimations* target, 243 int AddOpacityTransitionToElementAnimations(ElementAnimations* target,
243 double duration, 244 double duration,
244 float start_opacity, 245 float start_opacity,
245 float end_opacity, 246 float end_opacity,
246 bool use_timing_function) { 247 bool use_timing_function) {
248 target->SetNeedsPushProperties();
247 return AddOpacityTransition(target, duration, start_opacity, end_opacity, 249 return AddOpacityTransition(target, duration, start_opacity, end_opacity,
248 use_timing_function); 250 use_timing_function);
249 } 251 }
250 252
251 int AddAnimatedTransformToElementAnimations(ElementAnimations* target, 253 int AddAnimatedTransformToElementAnimations(ElementAnimations* target,
252 double duration, 254 double duration,
253 int delta_x, 255 int delta_x,
254 int delta_y) { 256 int delta_y) {
257 target->SetNeedsPushProperties();
255 return AddAnimatedTransform(target, duration, delta_x, delta_y); 258 return AddAnimatedTransform(target, duration, delta_x, delta_y);
256 } 259 }
257 260
258 int AddAnimatedFilterToElementAnimations(ElementAnimations* target, 261 int AddAnimatedFilterToElementAnimations(ElementAnimations* target,
259 double duration, 262 double duration,
260 float start_brightness, 263 float start_brightness,
261 float end_brightness) { 264 float end_brightness) {
265 target->SetNeedsPushProperties();
262 return AddAnimatedFilter(target, duration, start_brightness, end_brightness); 266 return AddAnimatedFilter(target, duration, start_brightness, end_brightness);
263 } 267 }
264 268
269 void AddAnimationToElementAnimations(ElementAnimations* target,
270 std::unique_ptr<Animation> animation) {
271 target->SetNeedsPushProperties();
272 target->AddAnimation(std::move(animation));
273 }
274
275 void RemoveAnimationFromElementAnimations(ElementAnimations* target,
276 int animation_id) {
277 target->SetNeedsPushProperties();
278 target->RemoveAnimation(animation_id);
279 }
280
281 void PauseAnimationInElementAnimations(ElementAnimations* target,
282 int animation_id,
283 base::TimeDelta time) {
284 target->SetNeedsPushProperties();
285 target->PauseAnimation(animation_id, time);
286 }
287
288 void AbortAnimationsInElementAnimations(ElementAnimations* target,
289 TargetProperty::Type target_property,
290 bool needs_completion) {
291 target->SetNeedsPushProperties();
292 target->AbortAnimations(target_property, needs_completion);
293 }
294
265 int AddAnimatedTransformToPlayer(AnimationPlayer* player, 295 int AddAnimatedTransformToPlayer(AnimationPlayer* player,
266 double duration, 296 double duration,
267 int delta_x, 297 int delta_x,
268 int delta_y) { 298 int delta_y) {
269 return AddAnimatedTransform(player, duration, delta_x, delta_y); 299 return AddAnimatedTransform(player, duration, delta_x, delta_y);
270 } 300 }
271 301
272 int AddAnimatedTransformToPlayer(AnimationPlayer* player, 302 int AddAnimatedTransformToPlayer(AnimationPlayer* player,
273 double duration, 303 double duration,
274 TransformOperations start_operations, 304 TransformOperations start_operations,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); 339 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr));
310 340
311 int id = AnimationIdProvider::NextAnimationId(); 341 int id = AnimationIdProvider::NextAnimationId();
312 342
313 std::unique_ptr<Animation> animation(Animation::Create( 343 std::unique_ptr<Animation> animation(Animation::Create(
314 std::move(curve), id, AnimationIdProvider::NextGroupId(), 344 std::move(curve), id, AnimationIdProvider::NextGroupId(),
315 TargetProperty::OPACITY)); 345 TargetProperty::OPACITY));
316 animation->set_needs_synchronized_start_time(true); 346 animation->set_needs_synchronized_start_time(true);
317 347
318 target->AddAnimation(std::move(animation)); 348 target->AddAnimation(std::move(animation));
349 target->SetNeedsPushProperties();
350
319 return id; 351 return id;
320 } 352 }
321 353
322 void AddAnimationToElementWithPlayer(ElementId element_id, 354 void AddAnimationToElementWithPlayer(ElementId element_id,
323 scoped_refptr<AnimationTimeline> timeline, 355 scoped_refptr<AnimationTimeline> timeline,
324 std::unique_ptr<Animation> animation) { 356 std::unique_ptr<Animation> animation) {
325 scoped_refptr<AnimationPlayer> player = 357 scoped_refptr<AnimationPlayer> player =
326 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); 358 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId());
327 timeline->AttachPlayer(player); 359 timeline->AttachPlayer(player);
328 player->AttachElement(element_id); 360 player->AttachElement(element_id);
329 DCHECK(player->element_animations()); 361 DCHECK(player->element_animations());
330 player->AddAnimation(std::move(animation)); 362 player->AddAnimation(std::move(animation));
331 } 363 }
332 364
333 void AddAnimationToElementWithExistingPlayer( 365 void AddAnimationToElementWithExistingPlayer(
334 ElementId element_id, 366 ElementId element_id,
335 scoped_refptr<AnimationTimeline> timeline, 367 scoped_refptr<AnimationTimeline> timeline,
336 std::unique_ptr<Animation> animation) { 368 std::unique_ptr<Animation> animation) {
337 scoped_refptr<ElementAnimations> element_animations = 369 scoped_refptr<ElementAnimations> element_animations =
338 timeline->animation_host()->GetElementAnimationsForElementId(element_id); 370 timeline->animation_host()->GetElementAnimationsForElementId(element_id);
339 DCHECK(element_animations); 371 DCHECK(element_animations);
340 element_animations->AddAnimation(std::move(animation)); 372 element_animations->AddAnimation(std::move(animation));
373 element_animations->SetNeedsPushProperties();
341 } 374 }
342 375
343 void RemoveAnimationFromElementWithExistingPlayer( 376 void RemoveAnimationFromElementWithExistingPlayer(
344 ElementId element_id, 377 ElementId element_id,
345 scoped_refptr<AnimationTimeline> timeline, 378 scoped_refptr<AnimationTimeline> timeline,
346 int animation_id) { 379 int animation_id) {
347 scoped_refptr<ElementAnimations> element_animations = 380 scoped_refptr<ElementAnimations> element_animations =
348 timeline->animation_host()->GetElementAnimationsForElementId(element_id); 381 timeline->animation_host()->GetElementAnimationsForElementId(element_id);
349 DCHECK(element_animations); 382 DCHECK(element_animations);
350 element_animations->RemoveAnimation(animation_id); 383 element_animations->RemoveAnimation(animation_id);
384 element_animations->SetNeedsPushProperties();
351 } 385 }
352 386
353 Animation* GetAnimationFromElementWithExistingPlayer( 387 Animation* GetAnimationFromElementWithExistingPlayer(
354 ElementId element_id, 388 ElementId element_id,
355 scoped_refptr<AnimationTimeline> timeline, 389 scoped_refptr<AnimationTimeline> timeline,
356 int animation_id) { 390 int animation_id) {
357 scoped_refptr<ElementAnimations> element_animations = 391 scoped_refptr<ElementAnimations> element_animations =
358 timeline->animation_host()->GetElementAnimationsForElementId(element_id); 392 timeline->animation_host()->GetElementAnimationsForElementId(element_id);
359 DCHECK(element_animations); 393 DCHECK(element_animations);
360 return element_animations->GetAnimationById(animation_id); 394 return element_animations->GetAnimationById(animation_id);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 455 }
422 456
423 void AbortAnimationsOnElementWithPlayer( 457 void AbortAnimationsOnElementWithPlayer(
424 ElementId element_id, 458 ElementId element_id,
425 scoped_refptr<AnimationTimeline> timeline, 459 scoped_refptr<AnimationTimeline> timeline,
426 TargetProperty::Type target_property) { 460 TargetProperty::Type target_property) {
427 scoped_refptr<ElementAnimations> element_animations = 461 scoped_refptr<ElementAnimations> element_animations =
428 timeline->animation_host()->GetElementAnimationsForElementId(element_id); 462 timeline->animation_host()->GetElementAnimationsForElementId(element_id);
429 DCHECK(element_animations); 463 DCHECK(element_animations);
430 element_animations->AbortAnimations(target_property); 464 element_animations->AbortAnimations(target_property);
465 element_animations->SetNeedsPushProperties();
431 } 466 }
432 467
433 } // namespace cc 468 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698