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

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

Issue 713783002: Revert of Moving background animation ticking from LayerTreeHostImpl into the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler-timesource-refactor
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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_settings.h » ('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/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 BackgroundAnimationInterval(LayerTreeHostImpl* host_impl) { 351 base::TimeDelta LowFrequencyAnimationInterval() const override {
352 return base::TimeDelta::FromSecondsD( 352 return base::TimeDelta::FromMilliseconds(4);
353 1.0 / host_impl->settings().background_animation_rate);
354 } 353 }
355 354
356 void BeginTest() override { 355 void BeginTest() override {
357 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 356 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
358 } 357 }
359 358
360 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 359 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
361 Animation::TargetProperty target_property, 360 Animation::TargetProperty target_property,
362 int group) override { 361 int group) override {
363 // Replace animated commits with an empty tree. 362 // Replace animated commits with an empty tree.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 402 }
404 403
405 // We block activation for several ticks to make sure that, even though 404 // We block activation for several ticks to make sure that, even though
406 // there is a pending tree with animations, we still do not background 405 // there is a pending tree with animations, we still do not background
407 // tick if the active tree is empty. 406 // tick if the active tree is empty.
408 if (host_impl->pending_tree()->source_frame_number() < 3) { 407 if (host_impl->pending_tree()->source_frame_number() < 3) {
409 base::MessageLoopProxy::current()->PostDelayedTask( 408 base::MessageLoopProxy::current()->PostDelayedTask(
410 FROM_HERE, 409 FROM_HERE,
411 base::Bind( 410 base::Bind(
412 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: 411 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
413 UnblockActivations, 412 UnblockActivations,
414 base::Unretained(this), host_impl), 413 base::Unretained(this),
415 4 * BackgroundAnimationInterval(host_impl)); 414 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), host_impl), 451 base::Unretained(this),
452 4 * BackgroundAnimationInterval(host_impl)); 452 host_impl),
453 4 * LowFrequencyAnimationInterval());
453 } 454 }
454 } 455 }
455 456
456 void WillAnimateLayers(LayerTreeHostImpl* host_impl, 457 void WillAnimateLayers(LayerTreeHostImpl* host_impl,
457 base::TimeTicks monotonic_time) override { 458 base::TimeTicks monotonic_time) override {
458 EXPECT_TRUE(host_impl->active_tree()->root_layer()); 459 EXPECT_TRUE(host_impl->active_tree()->root_layer());
459 active_tree_was_animated_ = true; 460 active_tree_was_animated_ = true;
460 } 461 }
461 462
462 void InitiateNextCommit(LayerTreeHostImpl* host_impl) { 463 void InitiateNextCommit(LayerTreeHostImpl* host_impl) {
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 private: 1193 private:
1193 scoped_refptr<Layer> content_; 1194 scoped_refptr<Layer> content_;
1194 int num_swap_buffers_; 1195 int num_swap_buffers_;
1195 }; 1196 };
1196 1197
1197 SINGLE_AND_MULTI_THREAD_TEST_F( 1198 SINGLE_AND_MULTI_THREAD_TEST_F(
1198 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1199 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1199 1200
1200 } // namespace 1201 } // namespace
1201 } // namespace cc 1202 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698