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

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/scroll_offset_animation_curve.h" 9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic); 341 LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic);
342 342
343 // Ensures that animations do not tick when we are backgrounded and 343 // Ensures that animations do not tick when we are backgrounded and
344 // and we have an empty active tree. 344 // and we have an empty active tree.
345 class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree 345 class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree
346 : public LayerTreeHostAnimationTest { 346 : public LayerTreeHostAnimationTest {
347 protected: 347 protected:
348 LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree() 348 LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree()
349 : active_tree_was_animated_(false) {} 349 : active_tree_was_animated_(false) {}
350 350
351 base::TimeDelta LowFrequencyAnimationInterval() const override { 351 base::TimeDelta BackgroundAnimationInterval(LayerTreeHostImpl* host_impl) {
352 return base::TimeDelta::FromMilliseconds(4); 352 return base::TimeDelta::FromSecondsD(
353 1.0 / host_impl->settings().background_animation_rate);
353 } 354 }
354 355
355 void BeginTest() override { 356 void BeginTest() override {
356 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 357 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
357 } 358 }
358 359
359 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 360 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
360 Animation::TargetProperty target_property, 361 Animation::TargetProperty target_property,
361 int group) override { 362 int group) override {
362 // Replace animated commits with an empty tree. 363 // Replace animated commits with an empty tree.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 403 }
403 404
404 // We block activation for several ticks to make sure that, even though 405 // We block activation for several ticks to make sure that, even though
405 // there is a pending tree with animations, we still do not background 406 // there is a pending tree with animations, we still do not background
406 // tick if the active tree is empty. 407 // tick if the active tree is empty.
407 if (host_impl->pending_tree()->source_frame_number() < 3) { 408 if (host_impl->pending_tree()->source_frame_number() < 3) {
408 base::MessageLoopProxy::current()->PostDelayedTask( 409 base::MessageLoopProxy::current()->PostDelayedTask(
409 FROM_HERE, 410 FROM_HERE,
410 base::Bind( 411 base::Bind(
411 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: 412 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
412 UnblockActivations, 413 UnblockActivations,
413 base::Unretained(this), 414 base::Unretained(this), host_impl),
414 host_impl), 415 4 * BackgroundAnimationInterval(host_impl));
415 4 * LowFrequencyAnimationInterval());
416 } 416 }
417 } 417 }
418 418
419 virtual void UnblockActivations(LayerTreeHostImpl* host_impl) { 419 virtual void UnblockActivations(LayerTreeHostImpl* host_impl) {
420 if (host_impl->settings().impl_side_painting) 420 if (host_impl->settings().impl_side_painting)
421 host_impl->BlockNotifyReadyToActivateForTesting(false); 421 host_impl->BlockNotifyReadyToActivateForTesting(false);
422 } 422 }
423 423
424 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 424 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
425 active_tree_was_animated_ = false; 425 active_tree_was_animated_ = false;
(...skipping 14 matching lines...) Expand all
440 break; 440 break;
441 } 441 }
442 442
443 if (host_impl->active_tree()->source_frame_number() < 3) { 443 if (host_impl->active_tree()->source_frame_number() < 3) {
444 // Initiate the next commit after a delay to give us a chance to 444 // Initiate the next commit after a delay to give us a chance to
445 // background tick if the active tree isn't empty. 445 // background tick if the active tree isn't empty.
446 base::MessageLoopProxy::current()->PostDelayedTask( 446 base::MessageLoopProxy::current()->PostDelayedTask(
447 FROM_HERE, 447 FROM_HERE,
448 base::Bind( 448 base::Bind(
449 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: 449 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
450 InitiateNextCommit, 450 InitiateNextCommit,
451 base::Unretained(this), 451 base::Unretained(this), host_impl),
452 host_impl), 452 4 * BackgroundAnimationInterval(host_impl));
453 4 * LowFrequencyAnimationInterval());
454 } 453 }
455 } 454 }
456 455
457 void WillAnimateLayers(LayerTreeHostImpl* host_impl, 456 void WillAnimateLayers(LayerTreeHostImpl* host_impl,
458 base::TimeTicks monotonic_time) override { 457 base::TimeTicks monotonic_time) override {
459 EXPECT_TRUE(host_impl->active_tree()->root_layer()); 458 EXPECT_TRUE(host_impl->active_tree()->root_layer());
460 active_tree_was_animated_ = true; 459 active_tree_was_animated_ = true;
461 } 460 }
462 461
463 void InitiateNextCommit(LayerTreeHostImpl* host_impl) { 462 void InitiateNextCommit(LayerTreeHostImpl* host_impl) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 host_impl->active_tree()->root_layer()->children()[0]-> 497 host_impl->active_tree()->root_layer()->children()[0]->
499 layer_animation_controller(); 498 layer_animation_controller();
500 Animation* animation = 499 Animation* animation =
501 controller_impl->GetAnimation(Animation::Opacity); 500 controller_impl->GetAnimation(Animation::Opacity);
502 if (!animation) 501 if (!animation)
503 return; 502 return;
504 503
505 const FloatAnimationCurve* curve = 504 const FloatAnimationCurve* curve =
506 animation->curve()->ToFloatAnimationCurve(); 505 animation->curve()->ToFloatAnimationCurve();
507 float start_opacity = curve->GetValue(0.0); 506 float start_opacity = curve->GetValue(0.0);
508 float end_opacity = curve->GetValue(curve->Duration()); 507 float end_opacity = curve->GetValue(curve->Duration().InSecondsF());
509 float linearly_interpolated_opacity = 508 float linearly_interpolated_opacity =
510 0.25f * end_opacity + 0.75f * start_opacity; 509 0.25f * end_opacity + 0.75f * start_opacity;
511 double time = curve->Duration() * 0.25; 510 double time = curve->Duration().InSecondsF() * 0.25;
512 // If the linear timing function associated with this animation was not 511 // If the linear timing function associated with this animation was not
513 // picked up, then the linearly interpolated opacity would be different 512 // picked up, then the linearly interpolated opacity would be different
514 // because of the default ease timing function. 513 // because of the default ease timing function.
515 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); 514 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time));
516 515
517 EndTest(); 516 EndTest();
518 } 517 }
519 518
520 void AfterTest() override {} 519 void AfterTest() override {}
521 520
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 private: 1192 private:
1194 scoped_refptr<Layer> content_; 1193 scoped_refptr<Layer> content_;
1195 int num_swap_buffers_; 1194 int num_swap_buffers_;
1196 }; 1195 };
1197 1196
1198 SINGLE_AND_MULTI_THREAD_TEST_F( 1197 SINGLE_AND_MULTI_THREAD_TEST_F(
1199 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1198 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1200 1199
1201 } // namespace 1200 } // namespace
1202 } // namespace cc 1201 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_no_message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698