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

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

Issue 1782433002: CC Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasetests
Patch Set: Remove vtbl in LayerAnimationController. Fix formatting. Created 4 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 SetLayerPropertiesForTesting( 2504 SetLayerPropertiesForTesting(
2505 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), 2505 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
2506 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); 2506 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
2507 SetLayerPropertiesForTesting( 2507 SetLayerPropertiesForTesting(
2508 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), 2508 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
2509 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); 2509 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
2510 SetLayerPropertiesForTesting( 2510 SetLayerPropertiesForTesting(
2511 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), 2511 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f),
2512 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); 2512 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false);
2513 2513
2514 if (layer_settings().use_compositor_animation_timelines) { 2514 // Put an animated opacity on the render surface.
2515 // Put an animated opacity on the render surface. 2515 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(),
2516 AddOpacityTransitionToLayerWithPlayer( 2516 10.0, 1.f, 0.f, false);
2517 render_surface1->id(), timeline_impl(), 10.0, 1.f, 0.f, false);
2518 2517
2519 // Also put an animated opacity on a layer without descendants. 2518 // Also put an animated opacity on a layer without descendants.
2520 AddOpacityTransitionToLayerWithPlayer( 2519 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(),
2521 grand_child_of_root->id(), timeline_impl(), 10.0, 1.f, 0.f, false); 2520 timeline_impl(), 10.0, 1.f, 0.f, false);
2522 2521
2523 // Put a transform animation on the render surface. 2522 // Put a transform animation on the render surface.
2524 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), 2523 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(),
2525 timeline_impl(), 10.0, 30, 0); 2524 10.0, 30, 0);
2526 2525
2527 // Also put transform animations on grand_child_of_root, and 2526 // Also put transform animations on grand_child_of_root, and
2528 // grand_child_of_rs2 2527 // grand_child_of_rs2
2529 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), 2528 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(),
2530 timeline_impl(), 10.0, 30, 0); 2529 timeline_impl(), 10.0, 30, 0);
2531 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), 2530 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(),
2532 timeline_impl(), 10.0, 30, 0); 2531 timeline_impl(), 10.0, 30, 0);
2533 } else {
2534 // Put an animated opacity on the render surface.
2535 AddOpacityTransitionToController(
2536 render_surface1->layer_animation_controller(), 10.0, 1.f, 0.f, false);
2537
2538 // Also put an animated opacity on a layer without descendants.
2539 AddOpacityTransitionToController(
2540 grand_child_of_root->layer_animation_controller(), 10.0, 1.f, 0.f,
2541 false);
2542
2543 // Put a transform animation on the render surface.
2544 AddAnimatedTransformToController(
2545 render_surface2->layer_animation_controller(), 10.0, 30, 0);
2546
2547 // Also put transform animations on grand_child_of_root, and
2548 // grand_child_of_rs2
2549 AddAnimatedTransformToController(
2550 grand_child_of_root->layer_animation_controller(), 10.0, 30, 0);
2551 AddAnimatedTransformToController(
2552 grand_child_of_rs2->layer_animation_controller(), 10.0, 30, 0);
2553 }
2554 2532
2555 ExecuteCalculateDrawProperties(parent); 2533 ExecuteCalculateDrawProperties(parent);
2556 2534
2557 // Only layers that are associated with render surfaces should have an actual 2535 // Only layers that are associated with render surfaces should have an actual
2558 // RenderSurface() value. 2536 // RenderSurface() value.
2559 ASSERT_TRUE(parent->render_surface()); 2537 ASSERT_TRUE(parent->render_surface());
2560 ASSERT_FALSE(child_of_root->render_surface()); 2538 ASSERT_FALSE(child_of_root->render_surface());
2561 ASSERT_FALSE(grand_child_of_root->render_surface()); 2539 ASSERT_FALSE(grand_child_of_root->render_surface());
2562 2540
2563 ASSERT_TRUE(render_surface1->render_surface()); 2541 ASSERT_TRUE(render_surface1->render_surface());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), 2641 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(),
2664 gfx::PointF(), gfx::Size(10, 10), true, false, 2642 gfx::PointF(), gfx::Size(10, 10), true, false,
2665 false); 2643 false);
2666 2644
2667 // Add a transform animation with a start delay to |grand_child|. 2645 // Add a transform animation with a start delay to |grand_child|.
2668 scoped_ptr<Animation> animation = Animation::Create( 2646 scoped_ptr<Animation> animation = Animation::Create(
2669 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, 2647 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1,
2670 TargetProperty::TRANSFORM); 2648 TargetProperty::TRANSFORM);
2671 animation->set_fill_mode(Animation::FILL_MODE_NONE); 2649 animation->set_fill_mode(Animation::FILL_MODE_NONE);
2672 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 2650 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
2673 if (layer_settings().use_compositor_animation_timelines) { 2651 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(),
2674 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), 2652 std::move(animation));
2675 std::move(animation));
2676 } else {
2677 grand_child->layer_animation_controller()->AddAnimation(
2678 std::move(animation));
2679 }
2680 ExecuteCalculateDrawProperties(parent); 2653 ExecuteCalculateDrawProperties(parent);
2681 2654
2682 EXPECT_FALSE(parent->screen_space_transform_is_animating()); 2655 EXPECT_FALSE(parent->screen_space_transform_is_animating());
2683 EXPECT_FALSE(child->screen_space_transform_is_animating()); 2656 EXPECT_FALSE(child->screen_space_transform_is_animating());
2684 2657
2685 EXPECT_FALSE(grand_child->TransformIsAnimating()); 2658 EXPECT_FALSE(grand_child->TransformIsAnimating());
2686 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); 2659 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation());
2687 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); 2660 EXPECT_TRUE(grand_child->screen_space_transform_is_animating());
2688 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); 2661 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating());
2689 } 2662 }
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 false); 3584 false);
3612 3585
3613 child->set_sorted_for_recursion(true); 3586 child->set_sorted_for_recursion(true);
3614 3587
3615 TransformOperations start_transform_operations; 3588 TransformOperations start_transform_operations;
3616 start_transform_operations.AppendScale(1.f, 0.f, 0.f); 3589 start_transform_operations.AppendScale(1.f, 0.f, 0.f);
3617 3590
3618 TransformOperations end_transform_operations; 3591 TransformOperations end_transform_operations;
3619 end_transform_operations.AppendScale(1.f, 1.f, 0.f); 3592 end_transform_operations.AppendScale(1.f, 1.f, 0.f);
3620 3593
3621 if (layer_settings().use_compositor_animation_timelines) { 3594 AddAnimatedTransformToLayerWithPlayer(root->id(), timeline(), 10.0,
3622 AddAnimatedTransformToLayerWithPlayer(root->id(), timeline(), 10.0, 3595 start_transform_operations,
3623 start_transform_operations, 3596 end_transform_operations);
3624 end_transform_operations);
3625 } else {
3626 AddAnimatedTransformToLayer(root.get(), 10.0, start_transform_operations,
3627 end_transform_operations);
3628 }
3629 EXPECT_TRUE(root->TransformIsAnimating()); 3597 EXPECT_TRUE(root->TransformIsAnimating());
3630 3598
3631 ExecuteCalculateDrawProperties(root.get()); 3599 ExecuteCalculateDrawProperties(root.get());
3632 3600
3633 EXPECT_FALSE(child->sorted_for_recursion()); 3601 EXPECT_FALSE(child->sorted_for_recursion());
3634 } 3602 }
3635 3603
3636 TEST_F(LayerTreeHostCommonTest, 3604 TEST_F(LayerTreeHostCommonTest,
3637 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { 3605 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
3638 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 3606 scoped_refptr<Layer> root = Layer::Create(layer_settings());
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 animating_child->SetDoubleSided(false); 4494 animating_child->SetDoubleSided(false);
4527 4495
4528 gfx::Transform backface_matrix; 4496 gfx::Transform backface_matrix;
4529 backface_matrix.Translate(50.0, 50.0); 4497 backface_matrix.Translate(50.0, 50.0);
4530 backface_matrix.RotateAboutYAxis(180.0); 4498 backface_matrix.RotateAboutYAxis(180.0);
4531 backface_matrix.Translate(-50.0, -50.0); 4499 backface_matrix.Translate(-50.0, -50.0);
4532 4500
4533 // Make our render surface. 4501 // Make our render surface.
4534 animating_surface->SetForceRenderSurface(true); 4502 animating_surface->SetForceRenderSurface(true);
4535 4503
4536 if (layer_settings().use_compositor_animation_timelines) { 4504 // Animate the transform on the render surface.
4537 // Animate the transform on the render surface. 4505 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(),
4538 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), 4506 10.0, 30, 0);
4539 10.0, 30, 0); 4507 // This is just an animating layer, not a surface.
4540 // This is just an animating layer, not a surface. 4508 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0,
4541 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 4509 30, 0);
4542 10.0, 30, 0);
4543 } else {
4544 // Animate the transform on the render surface.
4545 AddAnimatedTransformToController(
4546 animating_surface->layer_animation_controller(), 10.0, 30, 0);
4547 // This is just an animating layer, not a surface.
4548 AddAnimatedTransformToController(
4549 animating_child->layer_animation_controller(), 10.0, 30, 0);
4550 }
4551 4510
4552 SetLayerPropertiesForTesting(parent.get(), 4511 SetLayerPropertiesForTesting(parent.get(),
4553 identity_matrix, 4512 identity_matrix,
4554 gfx::Point3F(), 4513 gfx::Point3F(),
4555 gfx::PointF(), 4514 gfx::PointF(),
4556 gfx::Size(100, 100), 4515 gfx::Size(100, 100),
4557 true, 4516 true,
4558 false); 4517 false);
4559 SetLayerPropertiesForTesting(child.get(), 4518 SetLayerPropertiesForTesting(child.get(),
4560 backface_matrix, 4519 backface_matrix,
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 root->SetDrawsContent(true); 5185 root->SetDrawsContent(true);
5227 5186
5228 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); 5187 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
5229 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), 5188 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
5230 gfx::PointF(), gfx::Size(50, 50), true, false, 5189 gfx::PointF(), gfx::Size(50, 50), true, false,
5231 false); 5190 false);
5232 child->SetDrawsContent(true); 5191 child->SetDrawsContent(true);
5233 child->SetOpacity(0.0f); 5192 child->SetOpacity(0.0f);
5234 5193
5235 // Add opacity animation. 5194 // Add opacity animation.
5236 if (layer_settings().use_compositor_animation_timelines) { 5195 scoped_refptr<AnimationTimeline> timeline =
5237 scoped_refptr<AnimationTimeline> timeline = 5196 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5238 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5197 host_impl.animation_host()->AddAnimationTimeline(timeline);
5239 host_impl.animation_host()->AddAnimationTimeline(timeline);
5240 5198
5241 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 5199 AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f,
5242 1.0f, false); 5200 false);
5243 } else {
5244 AddOpacityTransitionToController(child->layer_animation_controller(), 10.0,
5245 0.0f, 1.0f, false);
5246 }
5247 5201
5248 root->AddChild(std::move(child)); 5202 root->AddChild(std::move(child));
5249 root->SetHasRenderSurface(true); 5203 root->SetHasRenderSurface(true);
5250 5204
5251 LayerImplList render_surface_layer_list; 5205 LayerImplList render_surface_layer_list;
5252 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); 5206 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
5253 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5207 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5254 root.get(), root->bounds(), &render_surface_layer_list, 5208 root.get(), root->bounds(), &render_surface_layer_list,
5255 root->layer_tree_impl()->current_render_surface_list_id()); 5209 root->layer_tree_impl()->current_render_surface_list_id());
5256 inputs.can_adjust_raster_scales = true; 5210 inputs.can_adjust_raster_scales = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5316 &shared_bitmap_manager_, 5270 &shared_bitmap_manager_,
5317 &task_graph_runner_), 5271 &task_graph_runner_),
5318 root_(nullptr), 5272 root_(nullptr),
5319 child_(nullptr), 5273 child_(nullptr),
5320 grand_child_(nullptr) {} 5274 grand_child_(nullptr) {}
5321 5275
5322 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } 5276 scoped_refptr<AnimationTimeline> timeline() { return timeline_; }
5323 5277
5324 protected: 5278 protected:
5325 void SetUp() override { 5279 void SetUp() override {
5326 if (layer_settings().use_compositor_animation_timelines) { 5280 timeline_ =
5327 timeline_ = 5281 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
5328 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 5282 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
5329 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
5330 }
5331 5283
5332 can_use_lcd_text_ = std::tr1::get<0>(GetParam()); 5284 can_use_lcd_text_ = std::tr1::get<0>(GetParam());
5333 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); 5285 layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam());
5334 5286
5335 scoped_ptr<LayerImpl> root_ptr = 5287 scoped_ptr<LayerImpl> root_ptr =
5336 LayerImpl::Create(host_impl_.active_tree(), 1); 5288 LayerImpl::Create(host_impl_.active_tree(), 1);
5337 scoped_ptr<LayerImpl> child_ptr = 5289 scoped_ptr<LayerImpl> child_ptr =
5338 LayerImpl::Create(host_impl_.active_tree(), 2); 5290 LayerImpl::Create(host_impl_.active_tree(), 2);
5339 scoped_ptr<LayerImpl> grand_child_ptr = 5291 scoped_ptr<LayerImpl> grand_child_ptr =
5340 LayerImpl::Create(host_impl_.active_tree(), 3); 5292 LayerImpl::Create(host_impl_.active_tree(), 3);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
5493 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5445 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5494 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5446 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5495 layers_always_allowed_lcd_text_); 5447 layers_always_allowed_lcd_text_);
5496 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5448 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5497 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5449 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5498 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5450 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5499 5451
5500 // Add opacity animation. 5452 // Add opacity animation.
5501 child_->SetOpacity(0.9f); 5453 child_->SetOpacity(0.9f);
5502 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; 5454 child_->layer_tree_impl()->property_trees()->needs_rebuild = true;
5503 if (layer_settings().use_compositor_animation_timelines) { 5455 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f,
5504 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, 5456 0.1f, false);
5505 0.1f, false);
5506 } else {
5507 AddOpacityTransitionToController(child_->layer_animation_controller(), 10.0,
5508 0.9f, 0.1f, false);
5509 }
5510 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5457 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5511 layers_always_allowed_lcd_text_); 5458 layers_always_allowed_lcd_text_);
5512 // Text LCD should be adjusted while animation is active. 5459 // Text LCD should be adjusted while animation is active.
5513 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5460 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5514 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5461 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5515 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); 5462 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text());
5516 } 5463 }
5517 5464
5518 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { 5465 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) {
5519 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; 5466 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_;
5520 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; 5467 bool expect_not_lcd_text = layers_always_allowed_lcd_text_;
5521 5468
5522 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5469 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5523 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5470 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5524 layers_always_allowed_lcd_text_); 5471 layers_always_allowed_lcd_text_);
5525 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5472 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5526 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); 5473 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text());
5527 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5474 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5528 5475
5529 // Mark contents non-opaque within the first animation frame. 5476 // Mark contents non-opaque within the first animation frame.
5530 child_->SetContentsOpaque(false); 5477 child_->SetContentsOpaque(false);
5531 if (layer_settings().use_compositor_animation_timelines) { 5478 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f,
5532 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, 5479 0.1f, false);
5533 0.1f, false);
5534 } else {
5535 AddOpacityTransitionToController(child_->layer_animation_controller(), 10.0,
5536 0.9f, 0.1f, false);
5537 }
5538 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, 5480 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_,
5539 layers_always_allowed_lcd_text_); 5481 layers_always_allowed_lcd_text_);
5540 // LCD text should be disabled for non-opaque layers even during animations. 5482 // LCD text should be disabled for non-opaque layers even during animations.
5541 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); 5483 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text());
5542 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); 5484 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text());
5543 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); 5485 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text());
5544 } 5486 }
5545 5487
5546 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5488 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5547 LCDTextTest, 5489 LCDTextTest,
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
7364 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), 7306 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(),
7365 gfx::PointF(), gfx::Size(100, 100), true, false, 7307 gfx::PointF(), gfx::Size(100, 100), true, false,
7366 false); 7308 false);
7367 7309
7368 gfx::Transform end_scale; 7310 gfx::Transform end_scale;
7369 end_scale.Scale(2.f, 2.f); 7311 end_scale.Scale(2.f, 2.f);
7370 TransformOperations start_operations; 7312 TransformOperations start_operations;
7371 start_operations.AppendMatrix(start_scale); 7313 start_operations.AppendMatrix(start_scale);
7372 TransformOperations end_operations; 7314 TransformOperations end_operations;
7373 end_operations.AppendMatrix(end_scale); 7315 end_operations.AppendMatrix(end_scale);
7374 if (layer_settings().use_compositor_animation_timelines) { 7316 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(),
7375 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), 7317 1.0, start_operations, end_operations);
7376 1.0, start_operations,
7377 end_operations);
7378 } else {
7379 AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations,
7380 end_operations);
7381 }
7382 gfx::Vector2dF scroll_delta(5.f, 9.f); 7318 gfx::Vector2dF scroll_delta(5.f, 9.f);
7383 scroller->SetScrollDelta(scroll_delta); 7319 scroller->SetScrollDelta(scroll_delta);
7384 7320
7385 ExecuteCalculateDrawProperties(root); 7321 ExecuteCalculateDrawProperties(root);
7386 7322
7387 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); 7323 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f);
7388 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, 7324 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation,
7389 scroller->DrawTransform().To2dTranslation()); 7325 scroller->DrawTransform().To2dTranslation());
7390 } 7326 }
7391 7327
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
7466 EXPECT_EQ(0.f, 7402 EXPECT_EQ(0.f,
7467 child_raw->draw_properties().starting_animation_contents_scale); 7403 child_raw->draw_properties().starting_animation_contents_scale);
7468 EXPECT_EQ( 7404 EXPECT_EQ(
7469 0.f, 7405 0.f,
7470 grand_child_raw->draw_properties().starting_animation_contents_scale); 7406 grand_child_raw->draw_properties().starting_animation_contents_scale);
7471 7407
7472 TransformOperations translation; 7408 TransformOperations translation;
7473 translation.AppendTranslate(1.f, 2.f, 3.f); 7409 translation.AppendTranslate(1.f, 2.f, 3.f);
7474 7410
7475 scoped_refptr<AnimationTimeline> timeline; 7411 scoped_refptr<AnimationTimeline> timeline;
7476 if (layer_settings().use_compositor_animation_timelines) { 7412 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
7477 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 7413 host_impl.animation_host()->AddAnimationTimeline(timeline);
7478 host_impl.animation_host()->AddAnimationTimeline(timeline);
7479 7414
7480 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7415 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
7481 TransformOperations(), translation); 7416 TransformOperations(), translation);
7482 } else {
7483 AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(),
7484 translation);
7485 }
7486 7417
7487 // No layers have scale-affecting animations. 7418 // No layers have scale-affecting animations.
7488 EXPECT_EQ(0.f, 7419 EXPECT_EQ(0.f,
7489 grand_parent->draw_properties().maximum_animation_contents_scale); 7420 grand_parent->draw_properties().maximum_animation_contents_scale);
7490 EXPECT_EQ(0.f, 7421 EXPECT_EQ(0.f,
7491 parent_raw->draw_properties().maximum_animation_contents_scale); 7422 parent_raw->draw_properties().maximum_animation_contents_scale);
7492 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7423 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7493 EXPECT_EQ( 7424 EXPECT_EQ(
7494 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7425 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7495 7426
7496 EXPECT_EQ(0.f, 7427 EXPECT_EQ(0.f,
7497 grand_parent->draw_properties().starting_animation_contents_scale); 7428 grand_parent->draw_properties().starting_animation_contents_scale);
7498 EXPECT_EQ(0.f, 7429 EXPECT_EQ(0.f,
7499 parent_raw->draw_properties().starting_animation_contents_scale); 7430 parent_raw->draw_properties().starting_animation_contents_scale);
7500 EXPECT_EQ(0.f, 7431 EXPECT_EQ(0.f,
7501 child_raw->draw_properties().starting_animation_contents_scale); 7432 child_raw->draw_properties().starting_animation_contents_scale);
7502 EXPECT_EQ( 7433 EXPECT_EQ(
7503 0.f, 7434 0.f,
7504 grand_child_raw->draw_properties().starting_animation_contents_scale); 7435 grand_child_raw->draw_properties().starting_animation_contents_scale);
7505 7436
7506 TransformOperations scale; 7437 TransformOperations scale;
7507 scale.AppendScale(5.f, 4.f, 3.f); 7438 scale.AppendScale(5.f, 4.f, 3.f);
7508 7439
7509 if (layer_settings().use_compositor_animation_timelines) { 7440 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0,
7510 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, 7441 TransformOperations(), scale);
7511 TransformOperations(), scale);
7512 } else {
7513 AddAnimatedTransformToLayer(child_raw, 1.0, TransformOperations(), scale);
7514 }
7515 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7442 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7516 ExecuteCalculateDrawProperties(grand_parent.get()); 7443 ExecuteCalculateDrawProperties(grand_parent.get());
7517 7444
7518 // Only |child| has a scale-affecting animation. 7445 // Only |child| has a scale-affecting animation.
7519 EXPECT_EQ(0.f, 7446 EXPECT_EQ(0.f,
7520 grand_parent->draw_properties().maximum_animation_contents_scale); 7447 grand_parent->draw_properties().maximum_animation_contents_scale);
7521 EXPECT_EQ(0.f, 7448 EXPECT_EQ(0.f,
7522 parent_raw->draw_properties().maximum_animation_contents_scale); 7449 parent_raw->draw_properties().maximum_animation_contents_scale);
7523 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); 7450 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale);
7524 EXPECT_EQ( 7451 EXPECT_EQ(
7525 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7452 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7526 7453
7527 EXPECT_EQ(0.f, 7454 EXPECT_EQ(0.f,
7528 grand_parent->draw_properties().starting_animation_contents_scale); 7455 grand_parent->draw_properties().starting_animation_contents_scale);
7529 EXPECT_EQ(0.f, 7456 EXPECT_EQ(0.f,
7530 parent_raw->draw_properties().starting_animation_contents_scale); 7457 parent_raw->draw_properties().starting_animation_contents_scale);
7531 EXPECT_EQ(1.f, 7458 EXPECT_EQ(1.f,
7532 child_raw->draw_properties().starting_animation_contents_scale); 7459 child_raw->draw_properties().starting_animation_contents_scale);
7533 EXPECT_EQ( 7460 EXPECT_EQ(
7534 1.f, 7461 1.f,
7535 grand_child_raw->draw_properties().starting_animation_contents_scale); 7462 grand_child_raw->draw_properties().starting_animation_contents_scale);
7536 7463
7537 if (layer_settings().use_compositor_animation_timelines) { 7464 AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0,
7538 AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0, 7465 TransformOperations(), scale);
7539 TransformOperations(), scale);
7540 } else {
7541 AddAnimatedTransformToLayer(grand_parent.get(), 1.0, TransformOperations(),
7542 scale);
7543 }
7544 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; 7466 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
7545 ExecuteCalculateDrawProperties(grand_parent.get()); 7467 ExecuteCalculateDrawProperties(grand_parent.get());
7546 7468
7547 // |grand_parent| and |child| have scale-affecting animations. 7469 // |grand_parent| and |child| have scale-affecting animations.
7548 EXPECT_EQ(5.f, 7470 EXPECT_EQ(5.f,
7549 grand_parent->draw_properties().maximum_animation_contents_scale); 7471 grand_parent->draw_properties().maximum_animation_contents_scale);
7550 EXPECT_EQ(5.f, 7472 EXPECT_EQ(5.f,
7551 parent_raw->draw_properties().maximum_animation_contents_scale); 7473 parent_raw->draw_properties().maximum_animation_contents_scale);
7552 // We don't support combining animated scales from two nodes; 0.f means 7474 // We don't support combining animated scales from two nodes; 0.f means
7553 // that the maximum scale could not be computed. 7475 // that the maximum scale could not be computed.
7554 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7476 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7555 EXPECT_EQ( 7477 EXPECT_EQ(
7556 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7478 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7557 7479
7558 EXPECT_EQ(1.f, 7480 EXPECT_EQ(1.f,
7559 grand_parent->draw_properties().starting_animation_contents_scale); 7481 grand_parent->draw_properties().starting_animation_contents_scale);
7560 EXPECT_EQ(1.f, 7482 EXPECT_EQ(1.f,
7561 parent_raw->draw_properties().starting_animation_contents_scale); 7483 parent_raw->draw_properties().starting_animation_contents_scale);
7562 EXPECT_EQ(0.f, 7484 EXPECT_EQ(0.f,
7563 child_raw->draw_properties().starting_animation_contents_scale); 7485 child_raw->draw_properties().starting_animation_contents_scale);
7564 EXPECT_EQ( 7486 EXPECT_EQ(
7565 0.f, 7487 0.f,
7566 grand_child_raw->draw_properties().starting_animation_contents_scale); 7488 grand_child_raw->draw_properties().starting_animation_contents_scale);
7567 7489
7568 if (layer_settings().use_compositor_animation_timelines) { 7490 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
7569 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7491 TransformOperations(), scale);
7570 TransformOperations(), scale);
7571 } else {
7572 AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale);
7573 }
7574 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7492 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7575 ExecuteCalculateDrawProperties(grand_parent.get()); 7493 ExecuteCalculateDrawProperties(grand_parent.get());
7576 7494
7577 // |grand_parent|, |parent|, and |child| have scale-affecting animations. 7495 // |grand_parent|, |parent|, and |child| have scale-affecting animations.
7578 EXPECT_EQ(5.f, 7496 EXPECT_EQ(5.f,
7579 grand_parent->draw_properties().maximum_animation_contents_scale); 7497 grand_parent->draw_properties().maximum_animation_contents_scale);
7580 EXPECT_EQ(0.f, 7498 EXPECT_EQ(0.f,
7581 parent_raw->draw_properties().maximum_animation_contents_scale); 7499 parent_raw->draw_properties().maximum_animation_contents_scale);
7582 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7500 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7583 EXPECT_EQ( 7501 EXPECT_EQ(
7584 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7502 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7585 7503
7586 EXPECT_EQ(1.f, 7504 EXPECT_EQ(1.f,
7587 grand_parent->draw_properties().starting_animation_contents_scale); 7505 grand_parent->draw_properties().starting_animation_contents_scale);
7588 EXPECT_EQ(0.f, 7506 EXPECT_EQ(0.f,
7589 parent_raw->draw_properties().starting_animation_contents_scale); 7507 parent_raw->draw_properties().starting_animation_contents_scale);
7590 EXPECT_EQ(0.f, 7508 EXPECT_EQ(0.f,
7591 child_raw->draw_properties().starting_animation_contents_scale); 7509 child_raw->draw_properties().starting_animation_contents_scale);
7592 EXPECT_EQ( 7510 EXPECT_EQ(
7593 0.f, 7511 0.f,
7594 grand_child_raw->draw_properties().starting_animation_contents_scale); 7512 grand_child_raw->draw_properties().starting_animation_contents_scale);
7595 7513
7596 if (layer_settings().use_compositor_animation_timelines) { 7514 AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline,
7597 AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline, 7515 TargetProperty::TRANSFORM);
7598 TargetProperty::TRANSFORM); 7516 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline,
7599 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, 7517 TargetProperty::TRANSFORM);
7600 TargetProperty::TRANSFORM); 7518 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline,
7601 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, 7519 TargetProperty::TRANSFORM);
7602 TargetProperty::TRANSFORM);
7603 } else {
7604 grand_parent->layer_animation_controller()->AbortAnimations(
7605 TargetProperty::TRANSFORM);
7606 parent_raw->layer_animation_controller()->AbortAnimations(
7607 TargetProperty::TRANSFORM);
7608 child_raw->layer_animation_controller()->AbortAnimations(
7609 TargetProperty::TRANSFORM);
7610 }
7611 7520
7612 TransformOperations perspective; 7521 TransformOperations perspective;
7613 perspective.AppendPerspective(10.f); 7522 perspective.AppendPerspective(10.f);
7614 7523
7615 if (layer_settings().use_compositor_animation_timelines) { 7524 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0,
7616 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, 7525 TransformOperations(), perspective);
7617 TransformOperations(), perspective);
7618 } else {
7619 AddAnimatedTransformToLayer(child_raw, 1.0, TransformOperations(),
7620 perspective);
7621 }
7622 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; 7526 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
7623 ExecuteCalculateDrawProperties(grand_parent.get()); 7527 ExecuteCalculateDrawProperties(grand_parent.get());
7624 7528
7625 // |child| has a scale-affecting animation but computing the maximum of this 7529 // |child| has a scale-affecting animation but computing the maximum of this
7626 // animation is not supported. 7530 // animation is not supported.
7627 EXPECT_EQ(0.f, 7531 EXPECT_EQ(0.f,
7628 grand_parent->draw_properties().maximum_animation_contents_scale); 7532 grand_parent->draw_properties().maximum_animation_contents_scale);
7629 EXPECT_EQ(0.f, 7533 EXPECT_EQ(0.f,
7630 parent_raw->draw_properties().maximum_animation_contents_scale); 7534 parent_raw->draw_properties().maximum_animation_contents_scale);
7631 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); 7535 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
7632 EXPECT_EQ( 7536 EXPECT_EQ(
7633 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); 7537 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
7634 7538
7635 EXPECT_EQ(0.f, 7539 EXPECT_EQ(0.f,
7636 grand_parent->draw_properties().starting_animation_contents_scale); 7540 grand_parent->draw_properties().starting_animation_contents_scale);
7637 EXPECT_EQ(0.f, 7541 EXPECT_EQ(0.f,
7638 parent_raw->draw_properties().starting_animation_contents_scale); 7542 parent_raw->draw_properties().starting_animation_contents_scale);
7639 EXPECT_EQ(0.f, 7543 EXPECT_EQ(0.f,
7640 child_raw->draw_properties().starting_animation_contents_scale); 7544 child_raw->draw_properties().starting_animation_contents_scale);
7641 EXPECT_EQ( 7545 EXPECT_EQ(
7642 0.f, 7546 0.f,
7643 grand_child_raw->draw_properties().starting_animation_contents_scale); 7547 grand_child_raw->draw_properties().starting_animation_contents_scale);
7644 7548
7645 if (layer_settings().use_compositor_animation_timelines) { 7549 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline,
7646 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, 7550 TargetProperty::TRANSFORM);
7647 TargetProperty::TRANSFORM);
7648 } else {
7649 child_raw->layer_animation_controller()->AbortAnimations(
7650 TargetProperty::TRANSFORM);
7651 }
7652 gfx::Transform scale_matrix; 7551 gfx::Transform scale_matrix;
7653 scale_matrix.Scale(1.f, 2.f); 7552 scale_matrix.Scale(1.f, 2.f);
7654 grand_parent->SetTransform(scale_matrix); 7553 grand_parent->SetTransform(scale_matrix);
7655 parent_raw->SetTransform(scale_matrix); 7554 parent_raw->SetTransform(scale_matrix);
7656 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; 7555 grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
7657 7556
7658 if (layer_settings().use_compositor_animation_timelines) { 7557 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
7659 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, 7558 TransformOperations(), scale);
7660 TransformOperations(), scale);
7661 } else {
7662 AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale);
7663 }
7664 ExecuteCalculateDrawProperties(grand_parent.get()); 7559 ExecuteCalculateDrawProperties(grand_parent.get());
7665 7560
7666 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale 7561 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale
7667 // animation with maximum scale 5.f. 7562 // animation with maximum scale 5.f.
7668 EXPECT_EQ(0.f, 7563 EXPECT_EQ(0.f,
7669 grand_parent->draw_properties().maximum_animation_contents_scale); 7564 grand_parent->draw_properties().maximum_animation_contents_scale);
7670 EXPECT_EQ(10.f, 7565 EXPECT_EQ(10.f,
7671 parent_raw->draw_properties().maximum_animation_contents_scale); 7566 parent_raw->draw_properties().maximum_animation_contents_scale);
7672 EXPECT_EQ(10.f, 7567 EXPECT_EQ(10.f,
7673 child_raw->draw_properties().maximum_animation_contents_scale); 7568 child_raw->draw_properties().maximum_animation_contents_scale);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
8074 LayerImpl::Create(host_impl.active_tree(), 5); 7969 LayerImpl::Create(host_impl.active_tree(), 5);
8075 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); 7970 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6));
8076 child1_layer->SetReplicaLayer(std::move(replica_layer)); 7971 child1_layer->SetReplicaLayer(std::move(replica_layer));
8077 child1_layer->SetHasRenderSurface(true); 7972 child1_layer->SetHasRenderSurface(true);
8078 7973
8079 ExecuteCalculateDrawProperties(root_layer); 7974 ExecuteCalculateDrawProperties(root_layer);
8080 7975
8081 TransformOperations scale; 7976 TransformOperations scale;
8082 scale.AppendScale(5.f, 8.f, 3.f); 7977 scale.AppendScale(5.f, 8.f, 3.f);
8083 7978
8084 if (layer_settings().use_compositor_animation_timelines) { 7979 scoped_refptr<AnimationTimeline> timeline =
8085 scoped_refptr<AnimationTimeline> timeline = 7980 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
8086 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 7981 host_impl.animation_host()->AddAnimationTimeline(timeline);
8087 host_impl.animation_host()->AddAnimationTimeline(timeline);
8088 7982
8089 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, 7983 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0,
8090 TransformOperations(), scale); 7984 TransformOperations(), scale);
8091 } else {
8092 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(),
8093 scale);
8094 }
8095 7985
8096 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, 7986 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2,
8097 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), 7987 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1),
8098 true, false, false); 7988 true, false, false);
8099 child2_layer->SetDrawsContent(true); 7989 child2_layer->SetDrawsContent(true);
8100 7990
8101 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 7991 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
8102 ExecuteCalculateDrawProperties(root_layer); 7992 ExecuteCalculateDrawProperties(root_layer);
8103 7993
8104 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); 7994 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale());
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
8391 8281
8392 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 8282 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
8393 gfx::PointF(), gfx::Size(100, 100), true, false); 8283 gfx::PointF(), gfx::Size(100, 100), true, false);
8394 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), 8284 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(),
8395 gfx::PointF(), gfx::Size(20, 20), true, false); 8285 gfx::PointF(), gfx::Size(20, 20), true, false);
8396 8286
8397 root->SetMasksToBounds(true); 8287 root->SetMasksToBounds(true);
8398 root->SetForceRenderSurface(true); 8288 root->SetForceRenderSurface(true);
8399 animated->SetOpacity(0.f); 8289 animated->SetOpacity(0.f);
8400 8290
8401 if (layer_settings().use_compositor_animation_timelines) { 8291 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f,
8402 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, 8292 1.f, false);
8403 1.f, false);
8404 } else {
8405 AddOpacityTransitionToController(animated->layer_animation_controller(),
8406 10.0, 0.f, 1.f, false);
8407 }
8408 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8293 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8409 8294
8410 EXPECT_FALSE(animated->visible_layer_rect().IsEmpty()); 8295 EXPECT_FALSE(animated->visible_layer_rect().IsEmpty());
8411 } 8296 }
8412 8297
8413 TEST_F(LayerTreeHostCommonTest, 8298 TEST_F(LayerTreeHostCommonTest,
8414 VisibleContentRectForAnimatedLayerWithSingularTransform) { 8299 VisibleContentRectForAnimatedLayerWithSingularTransform) {
8415 const gfx::Transform identity_matrix; 8300 const gfx::Transform identity_matrix;
8416 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 8301 scoped_refptr<Layer> root = Layer::Create(layer_settings());
8417 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 8302 scoped_refptr<Layer> clip = Layer::Create(layer_settings());
(...skipping 27 matching lines...) Expand all
8445 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), 8330 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(),
8446 gfx::PointF(), gfx::Size(100, 100), true, false); 8331 gfx::PointF(), gfx::Size(100, 100), true, false);
8447 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, 8332 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix,
8448 gfx::Point3F(), gfx::PointF(), 8333 gfx::Point3F(), gfx::PointF(),
8449 gfx::Size(200, 200), true, false); 8334 gfx::Size(200, 200), true, false);
8450 8335
8451 TransformOperations start_transform_operations; 8336 TransformOperations start_transform_operations;
8452 start_transform_operations.AppendMatrix(uninvertible_matrix); 8337 start_transform_operations.AppendMatrix(uninvertible_matrix);
8453 TransformOperations end_transform_operations; 8338 TransformOperations end_transform_operations;
8454 8339
8455 if (layer_settings().use_compositor_animation_timelines) { 8340 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0,
8456 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, 8341 start_transform_operations,
8457 start_transform_operations, 8342 end_transform_operations);
8458 end_transform_operations);
8459 } else {
8460 AddAnimatedTransformToLayer(animated.get(), 10.0,
8461 start_transform_operations,
8462 end_transform_operations);
8463 }
8464 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8343 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8465 8344
8466 // The animated layer has a singular transform and maps to a non-empty rect in 8345 // The animated layer has a singular transform and maps to a non-empty rect in
8467 // clipped target space, so is treated as fully visible. 8346 // clipped target space, so is treated as fully visible.
8468 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); 8347 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect());
8469 8348
8470 // The singular transform on |animated| is flattened when inherited by 8349 // The singular transform on |animated| is flattened when inherited by
8471 // |surface|, and this happens to make it invertible. 8350 // |surface|, and this happens to make it invertible.
8472 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); 8351 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect());
8473 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); 8352 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect());
(...skipping 28 matching lines...) Expand all
8502 gfx::Transform identity_transform; 8381 gfx::Transform identity_transform;
8503 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), 8382 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
8504 gfx::PointF(), gfx::Size(50, 50), true, false); 8383 gfx::PointF(), gfx::Size(50, 50), true, false);
8505 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(), 8384 SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
8506 gfx::PointF(), gfx::Size(50, 50), true, false); 8385 gfx::PointF(), gfx::Size(50, 50), true, false);
8507 SetLayerPropertiesForTesting(grandchild.get(), identity_transform, 8386 SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
8508 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), 8387 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
8509 true, false); 8388 true, false);
8510 host()->SetRootLayer(root); 8389 host()->SetRootLayer(root);
8511 8390
8512 if (layer_settings().use_compositor_animation_timelines) { 8391 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f, 0.2f);
8513 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f,
8514 0.2f);
8515 } else {
8516 AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f);
8517 }
8518 ExecuteCalculateDrawProperties(root.get()); 8392 ExecuteCalculateDrawProperties(root.get());
8519 8393
8520 EXPECT_TRUE(root->has_render_surface()); 8394 EXPECT_TRUE(root->has_render_surface());
8521 EXPECT_TRUE(child->has_render_surface()); 8395 EXPECT_TRUE(child->has_render_surface());
8522 EXPECT_FALSE(grandchild->has_render_surface()); 8396 EXPECT_FALSE(grandchild->has_render_surface());
8523 8397
8524 EXPECT_TRUE(root->filters().IsEmpty()); 8398 EXPECT_TRUE(root->filters().IsEmpty());
8525 EXPECT_TRUE(child->filters().IsEmpty()); 8399 EXPECT_TRUE(child->filters().IsEmpty());
8526 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8400 EXPECT_TRUE(grandchild->filters().IsEmpty());
8527 8401
(...skipping 29 matching lines...) Expand all
8557 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); 8431 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f));
8558 curve->AddKeyframe( 8432 curve->AddKeyframe(
8559 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); 8433 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr));
8560 curve->AddKeyframe(FilterKeyframe::Create( 8434 curve->AddKeyframe(FilterKeyframe::Create(
8561 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); 8435 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr));
8562 scoped_ptr<Animation> animation = 8436 scoped_ptr<Animation> animation =
8563 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); 8437 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER);
8564 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8438 animation->set_fill_mode(Animation::FILL_MODE_NONE);
8565 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8439 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
8566 8440
8567 if (layer_settings().use_compositor_animation_timelines) { 8441 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation));
8568 AddAnimationToLayerWithPlayer(child->id(), timeline(),
8569 std::move(animation));
8570 } else {
8571 child->layer_animation_controller()->AddAnimation(std::move(animation));
8572 }
8573 ExecuteCalculateDrawProperties(root.get()); 8442 ExecuteCalculateDrawProperties(root.get());
8574 8443
8575 EXPECT_TRUE(root->has_render_surface()); 8444 EXPECT_TRUE(root->has_render_surface());
8576 EXPECT_TRUE(child->has_render_surface()); 8445 EXPECT_TRUE(child->has_render_surface());
8577 EXPECT_FALSE(grandchild->has_render_surface()); 8446 EXPECT_FALSE(grandchild->has_render_surface());
8578 8447
8579 EXPECT_TRUE(root->filters().IsEmpty()); 8448 EXPECT_TRUE(root->filters().IsEmpty());
8580 EXPECT_TRUE(child->filters().IsEmpty()); 8449 EXPECT_TRUE(child->filters().IsEmpty());
8581 EXPECT_TRUE(grandchild->filters().IsEmpty()); 8450 EXPECT_TRUE(grandchild->filters().IsEmpty());
8582 8451
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
9033 child->SetTransform(zero_z_scale); 8902 child->SetTransform(zero_z_scale);
9034 8903
9035 // Add a transform animation with a start delay. Now, even though |child| has 8904 // Add a transform animation with a start delay. Now, even though |child| has
9036 // a singular transform, the subtree should still get processed. 8905 // a singular transform, the subtree should still get processed.
9037 int animation_id = 0; 8906 int animation_id = 0;
9038 scoped_ptr<Animation> animation = Animation::Create( 8907 scoped_ptr<Animation> animation = Animation::Create(
9039 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 8908 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)),
9040 animation_id, 1, TargetProperty::TRANSFORM); 8909 animation_id, 1, TargetProperty::TRANSFORM);
9041 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8910 animation->set_fill_mode(Animation::FILL_MODE_NONE);
9042 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8911 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
9043 if (layer_settings().use_compositor_animation_timelines) { 8912 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation));
9044 AddAnimationToLayerWithPlayer(child->id(), timeline(),
9045 std::move(animation));
9046 } else {
9047 child->AddAnimation(std::move(animation));
9048 }
9049 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8913 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9050 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); 8914 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect());
9051 grandchild->set_visible_layer_rect(gfx::Rect()); 8915 grandchild->set_visible_layer_rect(gfx::Rect());
9052 8916
9053 if (layer_settings().use_compositor_animation_timelines) { 8917 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(),
9054 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), 8918 animation_id);
9055 animation_id);
9056 } else {
9057 child->RemoveAnimation(animation_id);
9058 }
9059 child->SetTransform(identity); 8919 child->SetTransform(identity);
9060 child->SetOpacity(0.f); 8920 child->SetOpacity(0.f);
9061 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8921 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9062 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect()); 8922 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect());
9063 8923
9064 // Now, even though child has zero opacity, we will configure |grandchild| and 8924 // Now, even though child has zero opacity, we will configure |grandchild| and
9065 // |greatgrandchild| in several ways that should force the subtree to be 8925 // |greatgrandchild| in several ways that should force the subtree to be
9066 // processed anyhow. 8926 // processed anyhow.
9067 grandchild->RequestCopyOfOutput( 8927 grandchild->RequestCopyOfOutput(
9068 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 8928 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
9069 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8929 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9070 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); 8930 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect());
9071 greatgrandchild->set_visible_layer_rect(gfx::Rect()); 8931 greatgrandchild->set_visible_layer_rect(gfx::Rect());
9072 8932
9073 // Add an opacity animation with a start delay. 8933 // Add an opacity animation with a start delay.
9074 animation_id = 1; 8934 animation_id = 1;
9075 animation = Animation::Create( 8935 animation = Animation::Create(
9076 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 8936 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
9077 animation_id, 1, TargetProperty::OPACITY); 8937 animation_id, 1, TargetProperty::OPACITY);
9078 animation->set_fill_mode(Animation::FILL_MODE_NONE); 8938 animation->set_fill_mode(Animation::FILL_MODE_NONE);
9079 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); 8939 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000));
9080 if (layer_settings().use_compositor_animation_timelines) { 8940 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(),
9081 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), 8941 std::move(animation));
9082 std::move(animation));
9083 } else {
9084 child->AddAnimation(std::move(animation));
9085 }
9086 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8942 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
9087 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); 8943 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect());
9088 } 8944 }
9089 8945
9090 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) { 8946 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
9091 FakeImplTaskRunnerProvider task_runner_provider; 8947 FakeImplTaskRunnerProvider task_runner_provider;
9092 TestSharedBitmapManager shared_bitmap_manager; 8948 TestSharedBitmapManager shared_bitmap_manager;
9093 TestTaskGraphRunner task_graph_runner; 8949 TestTaskGraphRunner task_graph_runner;
9094 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 8950 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
9095 &task_graph_runner); 8951 &task_graph_runner);
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
10199 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10055 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10200 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10056 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10201 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10057 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10202 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10058 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10203 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10059 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10204 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10060 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10205 } 10061 }
10206 10062
10207 } // namespace 10063 } // namespace
10208 } // namespace cc 10064 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698