OLD | NEW |
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 break; | 390 break; |
391 case 4: | 391 case 4: |
392 EndTest(); | 392 EndTest(); |
393 break; | 393 break; |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 397 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
398 // At the start of every commit, block activations and make sure | 398 // At the start of every commit, block activations and make sure |
399 // we are backgrounded. | 399 // we are backgrounded. |
400 host_impl->BlockNotifyReadyToActivateForTesting(true); | 400 if (host_impl->settings().impl_side_painting) |
| 401 host_impl->BlockNotifyReadyToActivateForTesting(true); |
401 PostSetVisibleToMainThread(false); | 402 PostSetVisibleToMainThread(false); |
402 } | 403 } |
403 | 404 |
404 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 405 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
405 if (!host_impl->settings().impl_side_painting) { | 406 if (!host_impl->settings().impl_side_painting) { |
406 // There are no activations to block if we're not impl-side-painting, | 407 // There are no activations to block if we're not impl-side-painting, |
407 // so just advance the test immediately. | 408 // so just advance the test immediately. |
408 if (host_impl->active_tree()->source_frame_number() < 3) | 409 if (host_impl->active_tree()->source_frame_number() < 3) |
409 UnblockActivations(host_impl); | 410 UnblockActivations(host_impl); |
410 return; | 411 return; |
411 } | 412 } |
412 | 413 |
413 // We block activation for several ticks to make sure that, even though | 414 // We block activation for several ticks to make sure that, even though |
414 // there is a pending tree with animations, we still do not background | 415 // there is a pending tree with animations, we still do not background |
415 // tick if the active tree is empty. | 416 // tick if the active tree is empty. |
416 if (host_impl->pending_tree()->source_frame_number() < 3) { | 417 if (host_impl->pending_tree()->source_frame_number() < 3) { |
417 base::MessageLoopProxy::current()->PostDelayedTask( | 418 base::MessageLoopProxy::current()->PostDelayedTask( |
418 FROM_HERE, | 419 FROM_HERE, |
419 base::Bind( | 420 base::Bind( |
420 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: | 421 &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree:: |
421 UnblockActivations, | 422 UnblockActivations, |
422 base::Unretained(this), | 423 base::Unretained(this), |
423 host_impl), | 424 host_impl), |
424 4 * LowFrequencyAnimationInterval()); | 425 4 * LowFrequencyAnimationInterval()); |
425 } | 426 } |
426 } | 427 } |
427 | 428 |
428 virtual void UnblockActivations(LayerTreeHostImpl* host_impl) { | 429 virtual void UnblockActivations(LayerTreeHostImpl* host_impl) { |
429 host_impl->BlockNotifyReadyToActivateForTesting(false); | 430 if (host_impl->settings().impl_side_painting) |
| 431 host_impl->BlockNotifyReadyToActivateForTesting(false); |
430 } | 432 } |
431 | 433 |
432 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 434 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
433 active_tree_was_animated_ = false; | 435 active_tree_was_animated_ = false; |
434 | 436 |
435 // Verify that commits are actually alternating with empty / non-empty | 437 // Verify that commits are actually alternating with empty / non-empty |
436 // trees. | 438 // trees. |
437 int frame_number = host_impl->active_tree()->source_frame_number(); | 439 int frame_number = host_impl->active_tree()->source_frame_number(); |
438 switch (frame_number) { | 440 switch (frame_number) { |
439 case 0: | 441 case 0: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 477 |
476 // The next commit is blocked until we become visible again. | 478 // The next commit is blocked until we become visible again. |
477 PostSetVisibleToMainThread(true); | 479 PostSetVisibleToMainThread(true); |
478 } | 480 } |
479 | 481 |
480 virtual void AfterTest() override {} | 482 virtual void AfterTest() override {} |
481 | 483 |
482 bool active_tree_was_animated_; | 484 bool active_tree_was_animated_; |
483 }; | 485 }; |
484 | 486 |
485 SINGLE_AND_MULTI_THREAD_TEST_F( | 487 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
486 LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree); | 488 LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree); |
487 | 489 |
488 // Ensure that an animation's timing function is respected. | 490 // Ensure that an animation's timing function is respected. |
489 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction | 491 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
490 : public LayerTreeHostAnimationTest { | 492 : public LayerTreeHostAnimationTest { |
491 public: | 493 public: |
492 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} | 494 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} |
493 | 495 |
494 virtual void SetupTree() override { | 496 virtual void SetupTree() override { |
495 LayerTreeHostAnimationTest::SetupTree(); | 497 LayerTreeHostAnimationTest::SetupTree(); |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 | 1164 |
1163 scoped_refptr<Layer> layer = Layer::Create(); | 1165 scoped_refptr<Layer> layer = Layer::Create(); |
1164 layer_tree_host()->root_layer()->AddChild(layer); | 1166 layer_tree_host()->root_layer()->AddChild(layer); |
1165 layer->set_layer_animation_delegate(this); | 1167 layer->set_layer_animation_delegate(this); |
1166 layer->SetBounds(gfx::Size(4, 4)); | 1168 layer->SetBounds(gfx::Size(4, 4)); |
1167 AddOpacityTransitionToLayer(layer.get(), 1, 0.f, 0.5f, true); | 1169 AddOpacityTransitionToLayer(layer.get(), 1, 0.f, 0.5f, true); |
1168 } | 1170 } |
1169 } | 1171 } |
1170 | 1172 |
1171 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 1173 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
1172 host_impl->BlockNotifyReadyToActivateForTesting(true); | 1174 if (host_impl->settings().impl_side_painting) |
| 1175 host_impl->BlockNotifyReadyToActivateForTesting(true); |
1173 } | 1176 } |
1174 | 1177 |
1175 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1178 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
1176 // For the commit that added animations to new and existing layers, keep | 1179 // For the commit that added animations to new and existing layers, keep |
1177 // blocking activation. We want to verify that even with activation blocked, | 1180 // blocking activation. We want to verify that even with activation blocked, |
1178 // the animation on the layer that's already in the active tree won't get a | 1181 // the animation on the layer that's already in the active tree won't get a |
1179 // head start. | 1182 // head start. |
1180 if (!host_impl->settings().impl_side_painting || | 1183 if (host_impl->settings().impl_side_painting && |
1181 host_impl->pending_tree()->source_frame_number() != 2) | 1184 host_impl->pending_tree()->source_frame_number() != 2) { |
1182 host_impl->BlockNotifyReadyToActivateForTesting(false); | 1185 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 1186 } |
1183 } | 1187 } |
1184 | 1188 |
1185 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | 1189 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, |
1186 const BeginFrameArgs& args) override { | 1190 const BeginFrameArgs& args) override { |
1187 if (!host_impl->pending_tree() || | 1191 if (!host_impl->pending_tree() || |
1188 host_impl->pending_tree()->source_frame_number() != 2) | 1192 host_impl->pending_tree()->source_frame_number() != 2) |
1189 return; | 1193 return; |
1190 | 1194 |
1191 frame_count_with_pending_tree_++; | 1195 frame_count_with_pending_tree_++; |
1192 if (frame_count_with_pending_tree_ == 2) | 1196 if (frame_count_with_pending_tree_ == 2 && |
| 1197 host_impl->settings().impl_side_painting) { |
1193 host_impl->BlockNotifyReadyToActivateForTesting(false); | 1198 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 1199 } |
1194 } | 1200 } |
1195 | 1201 |
1196 virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 1202 virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
1197 bool has_unfinished_animation) override { | 1203 bool has_unfinished_animation) override { |
1198 LayerAnimationController* root_controller_impl = | 1204 LayerAnimationController* root_controller_impl = |
1199 host_impl->active_tree()->root_layer()->layer_animation_controller(); | 1205 host_impl->active_tree()->root_layer()->layer_animation_controller(); |
1200 Animation* root_animation = | 1206 Animation* root_animation = |
1201 root_controller_impl->GetAnimation(Animation::Opacity); | 1207 root_controller_impl->GetAnimation(Animation::Opacity); |
1202 if (!root_animation || root_animation->run_state() != Animation::Running) | 1208 if (!root_animation || root_animation->run_state() != Animation::Running) |
1203 return; | 1209 return; |
(...skipping 10 matching lines...) Expand all Loading... |
1214 child_controller_impl->AbortAnimations(Animation::Opacity); | 1220 child_controller_impl->AbortAnimations(Animation::Opacity); |
1215 EndTest(); | 1221 EndTest(); |
1216 } | 1222 } |
1217 | 1223 |
1218 virtual void AfterTest() override {} | 1224 virtual void AfterTest() override {} |
1219 | 1225 |
1220 private: | 1226 private: |
1221 int frame_count_with_pending_tree_; | 1227 int frame_count_with_pending_tree_; |
1222 }; | 1228 }; |
1223 | 1229 |
1224 SINGLE_AND_MULTI_THREAD_TEST_F( | 1230 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
1225 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers); | 1231 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers); |
1226 | 1232 |
1227 class LayerTreeHostAnimationTestAddAnimationAfterAnimating | 1233 class LayerTreeHostAnimationTestAddAnimationAfterAnimating |
1228 : public LayerTreeHostAnimationTest { | 1234 : public LayerTreeHostAnimationTest { |
1229 public: | 1235 public: |
1230 LayerTreeHostAnimationTestAddAnimationAfterAnimating() | 1236 LayerTreeHostAnimationTestAddAnimationAfterAnimating() |
1231 : num_swap_buffers_(0) {} | 1237 : num_swap_buffers_(0) {} |
1232 | 1238 |
1233 virtual void SetupTree() override { | 1239 virtual void SetupTree() override { |
1234 LayerTreeHostAnimationTest::SetupTree(); | 1240 LayerTreeHostAnimationTest::SetupTree(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 private: | 1290 private: |
1285 scoped_refptr<Layer> content_; | 1291 scoped_refptr<Layer> content_; |
1286 int num_swap_buffers_; | 1292 int num_swap_buffers_; |
1287 }; | 1293 }; |
1288 | 1294 |
1289 SINGLE_AND_MULTI_THREAD_TEST_F( | 1295 SINGLE_AND_MULTI_THREAD_TEST_F( |
1290 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1296 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
1291 | 1297 |
1292 } // namespace | 1298 } // namespace |
1293 } // namespace cc | 1299 } // namespace cc |
OLD | NEW |