OLD | NEW |
---|---|
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 <memory> | 10 #include <memory> |
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2546 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2547 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2547 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2548 SetLayerPropertiesForTesting( | 2548 SetLayerPropertiesForTesting( |
2549 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2549 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2550 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2550 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2551 SetLayerPropertiesForTesting( | 2551 SetLayerPropertiesForTesting( |
2552 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2552 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2553 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2553 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2554 | 2554 |
2555 parent->layer_tree_impl()->BuildPropertyTreesForTesting(); | 2555 parent->layer_tree_impl()->BuildPropertyTreesForTesting(); |
2556 SetElementIdsForTesting(); | |
2556 | 2557 |
2557 // Put an animated opacity on the render surface. | 2558 // Put an animated opacity on the render surface. |
2558 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), | 2559 AddOpacityTransitionToElementWithPlayer( |
2559 10.0, 1.f, 0.f, false); | 2560 render_surface1->element_id(), timeline_impl(), 10.0, 1.f, 0.f, false); |
2560 | 2561 |
2561 // Also put an animated opacity on a layer without descendants. | 2562 // Also put an animated opacity on a layer without descendants. |
2562 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), | 2563 AddOpacityTransitionToElementWithPlayer(grand_child_of_root->element_id(), |
2563 timeline_impl(), 10.0, 1.f, 0.f, false); | 2564 timeline_impl(), 10.0, 1.f, 0.f, |
2565 false); | |
2564 | 2566 |
2565 // Put a transform animation on the render surface. | 2567 // Put a transform animation on the render surface. |
2566 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(), | 2568 AddAnimatedTransformToElementWithPlayer(render_surface2->element_id(), |
2567 10.0, 30, 0); | 2569 timeline_impl(), 10.0, 30, 0); |
2568 | 2570 |
2569 // Also put transform animations on grand_child_of_root, and | 2571 // Also put transform animations on grand_child_of_root, and |
2570 // grand_child_of_rs2 | 2572 // grand_child_of_rs2 |
2571 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), | 2573 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), |
2572 timeline_impl(), 10.0, 30, 0); | 2574 timeline_impl(), 10.0, 30, 0); |
2573 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), | 2575 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), |
2574 timeline_impl(), 10.0, 30, 0); | 2576 timeline_impl(), 10.0, 30, 0); |
2575 | 2577 |
2576 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 2578 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; |
2577 ExecuteCalculateDrawProperties(parent); | 2579 ExecuteCalculateDrawProperties(parent); |
2578 | 2580 |
2579 // Only layers that are associated with render surfaces should have an actual | 2581 // Only layers that are associated with render surfaces should have an actual |
2580 // RenderSurface() value. | 2582 // RenderSurface() value. |
2581 ASSERT_TRUE(parent->render_surface()); | 2583 ASSERT_TRUE(parent->render_surface()); |
2582 ASSERT_FALSE(child_of_root->render_surface()); | 2584 ASSERT_FALSE(child_of_root->render_surface()); |
2583 ASSERT_FALSE(grand_child_of_root->render_surface()); | 2585 ASSERT_FALSE(grand_child_of_root->render_surface()); |
2584 | 2586 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2683 gfx::Size(10, 10), true, false, true); | 2685 gfx::Size(10, 10), true, false, true); |
2684 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 2686 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
2685 gfx::Size(10, 10), true, false, false); | 2687 gfx::Size(10, 10), true, false, false); |
2686 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 2688 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
2687 gfx::PointF(), gfx::Size(10, 10), true, false, | 2689 gfx::PointF(), gfx::Size(10, 10), true, false, |
2688 false); | 2690 false); |
2689 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), | 2691 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), |
2690 gfx::PointF(), gfx::Size(10, 10), true, false, | 2692 gfx::PointF(), gfx::Size(10, 10), true, false, |
2691 false); | 2693 false); |
2692 | 2694 |
2695 SetElementIdsForTesting(); | |
2696 | |
2693 // Add a transform animation with a start delay to |grand_child|. | 2697 // Add a transform animation with a start delay to |grand_child|. |
2694 std::unique_ptr<Animation> animation = Animation::Create( | 2698 std::unique_ptr<Animation> animation = Animation::Create( |
2695 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, | 2699 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, |
2696 TargetProperty::TRANSFORM); | 2700 TargetProperty::TRANSFORM); |
2697 animation->set_fill_mode(Animation::FillMode::NONE); | 2701 animation->set_fill_mode(Animation::FillMode::NONE); |
2698 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 2702 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
2699 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), | 2703 AddAnimationToElementWithPlayer(grand_child->element_id(), timeline_impl(), |
2700 std::move(animation)); | 2704 std::move(animation)); |
2701 ExecuteCalculateDrawProperties(parent); | 2705 ExecuteCalculateDrawProperties(parent); |
2702 | 2706 |
2703 EXPECT_FALSE(parent->screen_space_transform_is_animating()); | 2707 EXPECT_FALSE(parent->screen_space_transform_is_animating()); |
2704 EXPECT_FALSE(child->screen_space_transform_is_animating()); | 2708 EXPECT_FALSE(child->screen_space_transform_is_animating()); |
2705 | 2709 |
2706 EXPECT_FALSE(grand_child->TransformIsAnimating()); | 2710 EXPECT_FALSE(grand_child->TransformIsAnimating()); |
2707 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); | 2711 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); |
2708 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); | 2712 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); |
2709 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); | 2713 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); |
2710 } | 2714 } |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4411 child2->SetDrawsContent(true); | 4415 child2->SetDrawsContent(true); |
4412 animating_surface->SetDrawsContent(true); | 4416 animating_surface->SetDrawsContent(true); |
4413 child_of_animating_surface->SetDrawsContent(true); | 4417 child_of_animating_surface->SetDrawsContent(true); |
4414 animating_child->SetDrawsContent(true); | 4418 animating_child->SetDrawsContent(true); |
4415 | 4419 |
4416 gfx::Transform backface_matrix; | 4420 gfx::Transform backface_matrix; |
4417 backface_matrix.Translate(50.0, 50.0); | 4421 backface_matrix.Translate(50.0, 50.0); |
4418 backface_matrix.RotateAboutYAxis(180.0); | 4422 backface_matrix.RotateAboutYAxis(180.0); |
4419 backface_matrix.Translate(-50.0, -50.0); | 4423 backface_matrix.Translate(-50.0, -50.0); |
4420 | 4424 |
4425 SetElementIdsForTesting(); | |
4426 | |
4421 // Animate the transform on the render surface. | 4427 // Animate the transform on the render surface. |
4422 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), | 4428 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), |
4423 timeline_impl(), 10.0, 30, 0); | 4429 timeline_impl(), 10.0, 30, 0); |
4424 // This is just an animating layer, not a surface. | 4430 // This is just an animating layer, not a surface. |
4425 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline_impl(), | 4431 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), |
4426 10.0, 30, 0); | 4432 timeline_impl(), 10.0, 30, 0); |
4427 | 4433 |
4428 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 4434 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
4429 gfx::PointF(), gfx::Size(100, 100), true, false); | 4435 gfx::PointF(), gfx::Size(100, 100), true, false); |
4430 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), | 4436 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), |
4431 gfx::PointF(), gfx::Size(100, 100), true, false); | 4437 gfx::PointF(), gfx::Size(100, 100), true, false); |
4432 SetLayerPropertiesForTesting(animating_surface, backface_matrix, | 4438 SetLayerPropertiesForTesting(animating_surface, backface_matrix, |
4433 gfx::Point3F(), gfx::PointF(), | 4439 gfx::Point3F(), gfx::PointF(), |
4434 gfx::Size(100, 100), true, false, true); | 4440 gfx::Size(100, 100), true, false, true); |
4435 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, | 4441 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, |
4436 gfx::Point3F(), gfx::PointF(), | 4442 gfx::Point3F(), gfx::PointF(), |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5028 false); | 5034 false); |
5029 child->SetDrawsContent(true); | 5035 child->SetDrawsContent(true); |
5030 child->test_properties()->opacity = 0.0f; | 5036 child->test_properties()->opacity = 0.0f; |
5031 | 5037 |
5032 const int child_id = child->id(); | 5038 const int child_id = child->id(); |
5033 root->AddChild(std::move(child)); | 5039 root->AddChild(std::move(child)); |
5034 root->SetHasRenderSurface(true); | 5040 root->SetHasRenderSurface(true); |
5035 LayerImpl* root_layer = root.get(); | 5041 LayerImpl* root_layer = root.get(); |
5036 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5042 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
5037 host_impl.pending_tree()->BuildPropertyTreesForTesting(); | 5043 host_impl.pending_tree()->BuildPropertyTreesForTesting(); |
5044 | |
5038 // Add opacity animation. | 5045 // Add opacity animation. |
5039 scoped_refptr<AnimationTimeline> timeline = | 5046 scoped_refptr<AnimationTimeline> timeline = |
5040 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5047 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
5041 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5048 host_impl.animation_host()->AddAnimationTimeline(timeline); |
5049 host_impl.pending_tree()->SetElementIdsForTesting(); | |
5042 | 5050 |
5043 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, | 5051 ElementId child_element_id = |
5044 false); | 5052 host_impl.pending_tree()->LayerById(child_id)->element_id(); |
5053 | |
5054 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, | |
5055 0.0f, 1.0f, false); | |
5045 | 5056 |
5046 LayerImplList render_surface_layer_list; | 5057 LayerImplList render_surface_layer_list; |
5047 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5058 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5048 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5059 root_layer, root_layer->bounds(), &render_surface_layer_list); |
5049 inputs.can_adjust_raster_scales = true; | 5060 inputs.can_adjust_raster_scales = true; |
5050 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5061 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
5051 | 5062 |
5052 // We should have one render surface and two layers. The child | 5063 // We should have one render surface and two layers. The child |
5053 // layer should be included even though it is transparent. | 5064 // layer should be included even though it is transparent. |
5054 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5065 ASSERT_EQ(1u, render_surface_layer_list.size()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5138 | 5149 |
5139 // Stash raw pointers to look at later. | 5150 // Stash raw pointers to look at later. |
5140 root_ = root_ptr.get(); | 5151 root_ = root_ptr.get(); |
5141 child_ = child_ptr.get(); | 5152 child_ = child_ptr.get(); |
5142 grand_child_ = grand_child_ptr.get(); | 5153 grand_child_ = grand_child_ptr.get(); |
5143 | 5154 |
5144 child_->AddChild(std::move(grand_child_ptr)); | 5155 child_->AddChild(std::move(grand_child_ptr)); |
5145 root_->AddChild(std::move(child_ptr)); | 5156 root_->AddChild(std::move(child_ptr)); |
5146 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); | 5157 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); |
5147 | 5158 |
5159 host_impl_.active_tree()->SetElementIdsForTesting(); | |
5160 | |
5148 root_->SetContentsOpaque(true); | 5161 root_->SetContentsOpaque(true); |
5149 child_->SetContentsOpaque(true); | 5162 child_->SetContentsOpaque(true); |
5150 grand_child_->SetContentsOpaque(true); | 5163 grand_child_->SetContentsOpaque(true); |
5151 | 5164 |
5152 root_->SetDrawsContent(true); | 5165 root_->SetDrawsContent(true); |
5153 child_->SetDrawsContent(true); | 5166 child_->SetDrawsContent(true); |
5154 grand_child_->SetDrawsContent(true); | 5167 grand_child_->SetDrawsContent(true); |
5155 | 5168 |
5156 gfx::Transform identity_matrix; | 5169 gfx::Transform identity_matrix; |
5157 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), | 5170 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5290 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5303 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
5291 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5304 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5292 layers_always_allowed_lcd_text_); | 5305 layers_always_allowed_lcd_text_); |
5293 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5306 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5294 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5307 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
5295 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5308 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
5296 | 5309 |
5297 // Add opacity animation. | 5310 // Add opacity animation. |
5298 child_->test_properties()->opacity = 0.9f; | 5311 child_->test_properties()->opacity = 0.9f; |
5299 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5312 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5300 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5313 SetElementIdsForTesting(); |
5301 0.1f, false); | 5314 |
5315 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), | |
5316 10.0, 0.9f, 0.1f, false); | |
5302 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5317 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5303 layers_always_allowed_lcd_text_); | 5318 layers_always_allowed_lcd_text_); |
5304 // Text LCD should be adjusted while animation is active. | 5319 // Text LCD should be adjusted while animation is active. |
5305 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5320 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5306 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5321 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
5307 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); | 5322 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
5308 } | 5323 } |
5309 | 5324 |
5310 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { | 5325 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { |
5311 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 5326 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
5312 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 5327 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
5313 | 5328 |
5314 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5329 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
5315 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5330 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5316 layers_always_allowed_lcd_text_); | 5331 layers_always_allowed_lcd_text_); |
5317 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5332 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5318 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5333 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
5319 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5334 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
5335 SetElementIdsForTesting(); | |
5320 | 5336 |
5321 // Mark contents non-opaque within the first animation frame. | 5337 // Mark contents non-opaque within the first animation frame. |
5322 child_->SetContentsOpaque(false); | 5338 child_->SetContentsOpaque(false); |
5323 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5339 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), |
5324 0.1f, false); | 5340 10.0, 0.9f, 0.1f, false); |
5325 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5341 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
5326 layers_always_allowed_lcd_text_); | 5342 layers_always_allowed_lcd_text_); |
5327 // LCD text should be disabled for non-opaque layers even during animations. | 5343 // LCD text should be disabled for non-opaque layers even during animations. |
5328 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5344 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
5329 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); | 5345 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
5330 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5346 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
5331 } | 5347 } |
5332 | 5348 |
5333 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5349 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
5334 LCDTextTest, | 5350 LCDTextTest, |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7080 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), | 7096 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), |
7081 gfx::PointF(), gfx::Size(100, 100), true, false, | 7097 gfx::PointF(), gfx::Size(100, 100), true, false, |
7082 false); | 7098 false); |
7083 | 7099 |
7084 gfx::Transform end_scale; | 7100 gfx::Transform end_scale; |
7085 end_scale.Scale(2.f, 2.f); | 7101 end_scale.Scale(2.f, 2.f); |
7086 TransformOperations start_operations; | 7102 TransformOperations start_operations; |
7087 start_operations.AppendMatrix(start_scale); | 7103 start_operations.AppendMatrix(start_scale); |
7088 TransformOperations end_operations; | 7104 TransformOperations end_operations; |
7089 end_operations.AppendMatrix(end_scale); | 7105 end_operations.AppendMatrix(end_scale); |
7090 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), | 7106 SetElementIdsForTesting(); |
7091 1.0, start_operations, end_operations); | 7107 |
7108 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), | |
7109 timeline_impl(), 1.0, | |
7110 start_operations, end_operations); | |
7092 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7111 gfx::Vector2dF scroll_delta(5.f, 9.f); |
7093 SetScrollOffsetDelta(scroller, scroll_delta); | 7112 SetScrollOffsetDelta(scroller, scroll_delta); |
7094 | 7113 |
7095 ExecuteCalculateDrawProperties(root); | 7114 ExecuteCalculateDrawProperties(root); |
7096 | 7115 |
7097 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7116 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
7098 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7117 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
7099 scroller->DrawTransform().To2dTranslation()); | 7118 scroller->DrawTransform().To2dTranslation()); |
7100 } | 7119 } |
7101 | 7120 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7184 0.f, | 7203 0.f, |
7185 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7204 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7186 | 7205 |
7187 TransformOperations translation; | 7206 TransformOperations translation; |
7188 translation.AppendTranslate(1.f, 2.f, 3.f); | 7207 translation.AppendTranslate(1.f, 2.f, 3.f); |
7189 | 7208 |
7190 scoped_refptr<AnimationTimeline> timeline; | 7209 scoped_refptr<AnimationTimeline> timeline; |
7191 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7210 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
7192 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7211 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7193 | 7212 |
7194 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7213 host_impl.active_tree()->SetElementIdsForTesting(); |
7195 TransformOperations(), translation); | 7214 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
7215 1.0, TransformOperations(), | |
7216 translation); | |
7196 | 7217 |
7197 // No layers have scale-affecting animations. | 7218 // No layers have scale-affecting animations. |
7198 EXPECT_EQ( | 7219 EXPECT_EQ( |
7199 0.f, | 7220 0.f, |
7200 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7221 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7201 EXPECT_EQ(0.f, | 7222 EXPECT_EQ(0.f, |
7202 parent_raw->draw_properties().maximum_animation_contents_scale); | 7223 parent_raw->draw_properties().maximum_animation_contents_scale); |
7203 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7224 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7204 EXPECT_EQ( | 7225 EXPECT_EQ( |
7205 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7226 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7206 | 7227 |
7207 EXPECT_EQ( | 7228 EXPECT_EQ( |
7208 0.f, | 7229 0.f, |
7209 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7230 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7210 EXPECT_EQ(0.f, | 7231 EXPECT_EQ(0.f, |
7211 parent_raw->draw_properties().starting_animation_contents_scale); | 7232 parent_raw->draw_properties().starting_animation_contents_scale); |
7212 EXPECT_EQ(0.f, | 7233 EXPECT_EQ(0.f, |
7213 child_raw->draw_properties().starting_animation_contents_scale); | 7234 child_raw->draw_properties().starting_animation_contents_scale); |
7214 EXPECT_EQ( | 7235 EXPECT_EQ( |
7215 0.f, | 7236 0.f, |
7216 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7237 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7217 | 7238 |
7218 TransformOperations scale; | 7239 TransformOperations scale; |
7219 scale.AppendScale(5.f, 4.f, 3.f); | 7240 scale.AppendScale(5.f, 4.f, 3.f); |
7220 | 7241 |
7221 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7242 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
7222 TransformOperations(), scale); | 7243 1.0, TransformOperations(), scale); |
7223 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7244 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7224 ExecuteCalculateDrawProperties(grand_parent_raw); | 7245 ExecuteCalculateDrawProperties(grand_parent_raw); |
7225 | 7246 |
7226 // Only |child| has a scale-affecting animation. | 7247 // Only |child| has a scale-affecting animation. |
7227 EXPECT_EQ( | 7248 EXPECT_EQ( |
7228 0.f, | 7249 0.f, |
7229 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7250 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7230 EXPECT_EQ(0.f, | 7251 EXPECT_EQ(0.f, |
7231 parent_raw->draw_properties().maximum_animation_contents_scale); | 7252 parent_raw->draw_properties().maximum_animation_contents_scale); |
7232 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7253 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7233 EXPECT_EQ( | 7254 EXPECT_EQ( |
7234 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7255 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7235 | 7256 |
7236 EXPECT_EQ( | 7257 EXPECT_EQ( |
7237 0.f, | 7258 0.f, |
7238 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7259 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7239 EXPECT_EQ(0.f, | 7260 EXPECT_EQ(0.f, |
7240 parent_raw->draw_properties().starting_animation_contents_scale); | 7261 parent_raw->draw_properties().starting_animation_contents_scale); |
7241 EXPECT_EQ(1.f, | 7262 EXPECT_EQ(1.f, |
7242 child_raw->draw_properties().starting_animation_contents_scale); | 7263 child_raw->draw_properties().starting_animation_contents_scale); |
7243 EXPECT_EQ( | 7264 EXPECT_EQ( |
7244 1.f, | 7265 1.f, |
7245 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7266 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7246 | 7267 |
7247 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, | 7268 AddAnimatedTransformToElementWithPlayer(grand_parent_raw->element_id(), |
7248 TransformOperations(), scale); | 7269 timeline, 1.0, TransformOperations(), |
7270 scale); | |
7249 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7271 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7250 ExecuteCalculateDrawProperties(grand_parent_raw); | 7272 ExecuteCalculateDrawProperties(grand_parent_raw); |
7251 | 7273 |
7252 // |grand_parent| and |child| have scale-affecting animations. | 7274 // |grand_parent| and |child| have scale-affecting animations. |
7253 EXPECT_EQ( | 7275 EXPECT_EQ( |
7254 5.f, | 7276 5.f, |
7255 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7277 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7256 EXPECT_EQ(5.f, | 7278 EXPECT_EQ(5.f, |
7257 parent_raw->draw_properties().maximum_animation_contents_scale); | 7279 parent_raw->draw_properties().maximum_animation_contents_scale); |
7258 // We don't support combining animated scales from two nodes; 0.f means | 7280 // We don't support combining animated scales from two nodes; 0.f means |
7259 // that the maximum scale could not be computed. | 7281 // that the maximum scale could not be computed. |
7260 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7282 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7261 EXPECT_EQ( | 7283 EXPECT_EQ( |
7262 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7284 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7263 | 7285 |
7264 EXPECT_EQ( | 7286 EXPECT_EQ( |
7265 1.f, | 7287 1.f, |
7266 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7288 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7267 EXPECT_EQ(1.f, | 7289 EXPECT_EQ(1.f, |
7268 parent_raw->draw_properties().starting_animation_contents_scale); | 7290 parent_raw->draw_properties().starting_animation_contents_scale); |
7269 EXPECT_EQ(0.f, | 7291 EXPECT_EQ(0.f, |
7270 child_raw->draw_properties().starting_animation_contents_scale); | 7292 child_raw->draw_properties().starting_animation_contents_scale); |
7271 EXPECT_EQ( | 7293 EXPECT_EQ( |
7272 0.f, | 7294 0.f, |
7273 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7295 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7274 | 7296 |
7275 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7297 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
7276 TransformOperations(), scale); | 7298 1.0, TransformOperations(), scale); |
7277 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7299 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7278 ExecuteCalculateDrawProperties(grand_parent_raw); | 7300 ExecuteCalculateDrawProperties(grand_parent_raw); |
7279 | 7301 |
7280 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7302 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
7281 EXPECT_EQ( | 7303 EXPECT_EQ( |
7282 5.f, | 7304 5.f, |
7283 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7305 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7284 EXPECT_EQ(0.f, | 7306 EXPECT_EQ(0.f, |
7285 parent_raw->draw_properties().maximum_animation_contents_scale); | 7307 parent_raw->draw_properties().maximum_animation_contents_scale); |
7286 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7308 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7287 EXPECT_EQ( | 7309 EXPECT_EQ( |
7288 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7310 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7289 | 7311 |
7290 EXPECT_EQ( | 7312 EXPECT_EQ( |
7291 1.f, | 7313 1.f, |
7292 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7314 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7293 EXPECT_EQ(0.f, | 7315 EXPECT_EQ(0.f, |
7294 parent_raw->draw_properties().starting_animation_contents_scale); | 7316 parent_raw->draw_properties().starting_animation_contents_scale); |
7295 EXPECT_EQ(0.f, | 7317 EXPECT_EQ(0.f, |
7296 child_raw->draw_properties().starting_animation_contents_scale); | 7318 child_raw->draw_properties().starting_animation_contents_scale); |
7297 EXPECT_EQ( | 7319 EXPECT_EQ( |
7298 0.f, | 7320 0.f, |
7299 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7321 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7300 | 7322 |
7301 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, | 7323 AbortAnimationsOnElementWithPlayer(grand_parent_raw->element_id(), timeline, |
7302 TargetProperty::TRANSFORM); | 7324 TargetProperty::TRANSFORM); |
7303 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, | 7325 AbortAnimationsOnElementWithPlayer(parent_raw->element_id(), timeline, |
7304 TargetProperty::TRANSFORM); | 7326 TargetProperty::TRANSFORM); |
7305 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7327 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
7306 TargetProperty::TRANSFORM); | 7328 TargetProperty::TRANSFORM); |
7307 | 7329 |
7308 TransformOperations perspective; | 7330 TransformOperations perspective; |
7309 perspective.AppendPerspective(10.f); | 7331 perspective.AppendPerspective(10.f); |
7310 | 7332 |
7311 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7333 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
7312 TransformOperations(), perspective); | 7334 1.0, TransformOperations(), |
7335 perspective); | |
7313 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7336 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7314 ExecuteCalculateDrawProperties(grand_parent_raw); | 7337 ExecuteCalculateDrawProperties(grand_parent_raw); |
7315 | 7338 |
7316 // |child| has a scale-affecting animation but computing the maximum of this | 7339 // |child| has a scale-affecting animation but computing the maximum of this |
7317 // animation is not supported. | 7340 // animation is not supported. |
7318 EXPECT_EQ( | 7341 EXPECT_EQ( |
7319 0.f, | 7342 0.f, |
7320 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7343 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7321 EXPECT_EQ(0.f, | 7344 EXPECT_EQ(0.f, |
7322 parent_raw->draw_properties().maximum_animation_contents_scale); | 7345 parent_raw->draw_properties().maximum_animation_contents_scale); |
7323 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7346 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7324 EXPECT_EQ( | 7347 EXPECT_EQ( |
7325 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7348 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7326 | 7349 |
7327 EXPECT_EQ( | 7350 EXPECT_EQ( |
7328 0.f, | 7351 0.f, |
7329 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7352 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7330 EXPECT_EQ(0.f, | 7353 EXPECT_EQ(0.f, |
7331 parent_raw->draw_properties().starting_animation_contents_scale); | 7354 parent_raw->draw_properties().starting_animation_contents_scale); |
7332 EXPECT_EQ(0.f, | 7355 EXPECT_EQ(0.f, |
7333 child_raw->draw_properties().starting_animation_contents_scale); | 7356 child_raw->draw_properties().starting_animation_contents_scale); |
7334 EXPECT_EQ( | 7357 EXPECT_EQ( |
7335 0.f, | 7358 0.f, |
7336 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7359 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7337 | 7360 |
7338 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7361 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
7339 TargetProperty::TRANSFORM); | 7362 TargetProperty::TRANSFORM); |
7340 gfx::Transform scale_matrix; | 7363 gfx::Transform scale_matrix; |
7341 scale_matrix.Scale(1.f, 2.f); | 7364 scale_matrix.Scale(1.f, 2.f); |
7342 grand_parent_raw->SetTransform(scale_matrix); | 7365 grand_parent_raw->SetTransform(scale_matrix); |
7343 parent_raw->SetTransform(scale_matrix); | 7366 parent_raw->SetTransform(scale_matrix); |
7344 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7367 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7345 | 7368 |
7346 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7369 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
7347 TransformOperations(), scale); | 7370 1.0, TransformOperations(), scale); |
7348 ExecuteCalculateDrawProperties(grand_parent_raw); | 7371 ExecuteCalculateDrawProperties(grand_parent_raw); |
7349 | 7372 |
7350 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7373 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
7351 // animation with maximum scale 5.f. | 7374 // animation with maximum scale 5.f. |
7352 EXPECT_EQ( | 7375 EXPECT_EQ( |
7353 0.f, | 7376 0.f, |
7354 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7377 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7355 EXPECT_EQ(10.f, | 7378 EXPECT_EQ(10.f, |
7356 parent_raw->draw_properties().maximum_animation_contents_scale); | 7379 parent_raw->draw_properties().maximum_animation_contents_scale); |
7357 EXPECT_EQ(10.f, | 7380 EXPECT_EQ(10.f, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7740 std::unique_ptr<LayerImpl> child2 = | 7763 std::unique_ptr<LayerImpl> child2 = |
7741 LayerImpl::Create(host_impl.active_tree(), 3); | 7764 LayerImpl::Create(host_impl.active_tree(), 3); |
7742 LayerImpl* child2_layer = child2.get(); | 7765 LayerImpl* child2_layer = child2.get(); |
7743 | 7766 |
7744 root->AddChild(std::move(child1)); | 7767 root->AddChild(std::move(child1)); |
7745 root->AddChild(std::move(child2)); | 7768 root->AddChild(std::move(child2)); |
7746 root->test_properties()->force_render_surface = true; | 7769 root->test_properties()->force_render_surface = true; |
7747 root->SetDrawsContent(true); | 7770 root->SetDrawsContent(true); |
7748 host_impl.active_tree()->SetRootLayer(std::move(root)); | 7771 host_impl.active_tree()->SetRootLayer(std::move(root)); |
7749 | 7772 |
7773 host_impl.active_tree()->SetElementIdsForTesting(); | |
7774 | |
7750 gfx::Transform identity_matrix, scale_transform_child1, | 7775 gfx::Transform identity_matrix, scale_transform_child1, |
7751 scale_transform_child2; | 7776 scale_transform_child2; |
7752 scale_transform_child1.Scale(2, 3); | 7777 scale_transform_child1.Scale(2, 3); |
7753 scale_transform_child2.Scale(4, 5); | 7778 scale_transform_child2.Scale(4, 5); |
7754 | 7779 |
7755 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7780 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
7756 gfx::PointF(), gfx::Size(1, 1), true, false, | 7781 gfx::PointF(), gfx::Size(1, 1), true, false, |
7757 true); | 7782 true); |
7758 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7783 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
7759 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7784 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
(...skipping 10 matching lines...) Expand all Loading... | |
7770 | 7795 |
7771 ExecuteCalculateDrawProperties(root_layer); | 7796 ExecuteCalculateDrawProperties(root_layer); |
7772 | 7797 |
7773 TransformOperations scale; | 7798 TransformOperations scale; |
7774 scale.AppendScale(5.f, 8.f, 3.f); | 7799 scale.AppendScale(5.f, 8.f, 3.f); |
7775 | 7800 |
7776 scoped_refptr<AnimationTimeline> timeline = | 7801 scoped_refptr<AnimationTimeline> timeline = |
7777 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7802 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
7778 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7803 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7779 | 7804 |
7780 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, | |
7781 TransformOperations(), scale); | |
7782 | |
7783 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 7805 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
7784 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7806 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
7785 true, false, false); | 7807 true, false, false); |
7786 child2_layer->SetDrawsContent(true); | 7808 child2_layer->SetDrawsContent(true); |
7787 | 7809 |
7810 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | |
7811 1.0, TransformOperations(), scale); | |
7812 | |
7788 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7813 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7789 ExecuteCalculateDrawProperties(root_layer); | 7814 ExecuteCalculateDrawProperties(root_layer); |
7790 | 7815 |
7791 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7816 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
7792 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7817 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
7793 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); | 7818 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); |
7794 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); | 7819 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); |
7795 | 7820 |
7796 EXPECT_FLOAT_EQ( | 7821 EXPECT_FLOAT_EQ( |
7797 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7822 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8045 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { | 8070 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
8046 const gfx::Transform identity_matrix; | 8071 const gfx::Transform identity_matrix; |
8047 scoped_refptr<Layer> root = Layer::Create(); | 8072 scoped_refptr<Layer> root = Layer::Create(); |
8048 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8073 scoped_refptr<LayerWithForcedDrawsContent> animated = |
8049 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8074 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8050 | 8075 |
8051 root->AddChild(animated); | 8076 root->AddChild(animated); |
8052 | 8077 |
8053 host()->SetRootLayer(root); | 8078 host()->SetRootLayer(root); |
8054 | 8079 |
8080 host()->SetElementIdsForTesting(); | |
8081 | |
8055 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8082 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
8056 gfx::PointF(), gfx::Size(100, 100), true, false); | 8083 gfx::PointF(), gfx::Size(100, 100), true, false); |
8057 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 8084 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
8058 gfx::PointF(), gfx::Size(20, 20), true, false); | 8085 gfx::PointF(), gfx::Size(20, 20), true, false); |
8059 | 8086 |
8060 root->SetMasksToBounds(true); | 8087 root->SetMasksToBounds(true); |
8061 root->SetForceRenderSurfaceForTesting(true); | 8088 root->SetForceRenderSurfaceForTesting(true); |
8062 animated->SetOpacity(0.f); | 8089 animated->SetOpacity(0.f); |
8063 | 8090 |
8064 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, | 8091 SetElementIdsForTesting(); |
ajuma
2016/06/01 23:53:42
This adds ids to the the LTHI's active tree, right
Ian Vollick
2016/06/02 19:03:11
Nope, removed.
| |
8065 1.f, false); | 8092 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), |
8093 10.0, 0.f, 1.f, false); | |
8066 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8094 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8067 | 8095 |
8068 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); | 8096 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); |
8069 } | 8097 } |
8070 | 8098 |
8071 TEST_F(LayerTreeHostCommonTest, | 8099 TEST_F(LayerTreeHostCommonTest, |
8072 VisibleContentRectForAnimatedLayerWithSingularTransform) { | 8100 VisibleContentRectForAnimatedLayerWithSingularTransform) { |
8073 const gfx::Transform identity_matrix; | 8101 const gfx::Transform identity_matrix; |
8074 scoped_refptr<Layer> root = Layer::Create(); | 8102 scoped_refptr<Layer> root = Layer::Create(); |
8075 scoped_refptr<Layer> clip = Layer::Create(); | 8103 scoped_refptr<Layer> clip = Layer::Create(); |
8076 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8104 scoped_refptr<LayerWithForcedDrawsContent> animated = |
8077 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8105 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8078 scoped_refptr<LayerWithForcedDrawsContent> surface = | 8106 scoped_refptr<LayerWithForcedDrawsContent> surface = |
8079 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8107 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8080 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = | 8108 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = |
8081 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8109 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8082 | 8110 |
8083 root->AddChild(clip); | 8111 root->AddChild(clip); |
8084 clip->AddChild(animated); | 8112 clip->AddChild(animated); |
8085 animated->AddChild(surface); | 8113 animated->AddChild(surface); |
8086 surface->AddChild(descendant_of_animation); | 8114 surface->AddChild(descendant_of_animation); |
8087 | 8115 |
8088 clip->SetMasksToBounds(true); | 8116 clip->SetMasksToBounds(true); |
8089 surface->SetForceRenderSurfaceForTesting(true); | 8117 surface->SetForceRenderSurfaceForTesting(true); |
8090 | 8118 |
8091 host()->SetRootLayer(root); | 8119 host()->SetRootLayer(root); |
8092 | 8120 |
8121 host()->SetElementIdsForTesting(); | |
8122 | |
8093 gfx::Transform uninvertible_matrix; | 8123 gfx::Transform uninvertible_matrix; |
8094 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); | 8124 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); |
8095 | 8125 |
8096 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8126 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
8097 gfx::PointF(), gfx::Size(100, 100), true, false); | 8127 gfx::PointF(), gfx::Size(100, 100), true, false); |
8098 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), | 8128 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), |
8099 gfx::PointF(), gfx::Size(10, 10), true, false); | 8129 gfx::PointF(), gfx::Size(10, 10), true, false); |
8100 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, | 8130 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, |
8101 gfx::Point3F(), gfx::PointF(), | 8131 gfx::Point3F(), gfx::PointF(), |
8102 gfx::Size(120, 120), true, false); | 8132 gfx::Size(120, 120), true, false); |
8103 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 8133 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
8104 gfx::PointF(), gfx::Size(100, 100), true, false); | 8134 gfx::PointF(), gfx::Size(100, 100), true, false); |
8105 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, | 8135 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, |
8106 gfx::Point3F(), gfx::PointF(), | 8136 gfx::Point3F(), gfx::PointF(), |
8107 gfx::Size(200, 200), true, false); | 8137 gfx::Size(200, 200), true, false); |
8108 | 8138 |
8109 TransformOperations start_transform_operations; | 8139 TransformOperations start_transform_operations; |
8110 start_transform_operations.AppendMatrix(uninvertible_matrix); | 8140 start_transform_operations.AppendMatrix(uninvertible_matrix); |
8111 TransformOperations end_transform_operations; | 8141 TransformOperations end_transform_operations; |
8112 | 8142 |
8113 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, | 8143 SetElementIdsForTesting(); |
8114 start_transform_operations, | 8144 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), |
8115 end_transform_operations); | 8145 10.0, start_transform_operations, |
8146 end_transform_operations); | |
8116 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8147 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8117 | 8148 |
8118 // The animated layer has a singular transform and maps to a non-empty rect in | 8149 // The animated layer has a singular transform and maps to a non-empty rect in |
8119 // clipped target space, so is treated as fully visible. | 8150 // clipped target space, so is treated as fully visible. |
8120 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); | 8151 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); |
8121 | 8152 |
8122 // The singular transform on |animated| is flattened when inherited by | 8153 // The singular transform on |animated| is flattened when inherited by |
8123 // |surface|, and this happens to make it invertible. | 8154 // |surface|, and this happens to make it invertible. |
8124 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); | 8155 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); |
8125 EXPECT_EQ(gfx::Rect(2, 2), | 8156 EXPECT_EQ(gfx::Rect(2, 2), |
(...skipping 26 matching lines...) Expand all Loading... | |
8152 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8183 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
8153 | 8184 |
8154 gfx::Transform identity_transform; | 8185 gfx::Transform identity_transform; |
8155 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8186 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
8156 gfx::PointF(), gfx::Size(50, 50), true, false); | 8187 gfx::PointF(), gfx::Size(50, 50), true, false); |
8157 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8188 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
8158 gfx::PointF(), gfx::Size(50, 50), true, false); | 8189 gfx::PointF(), gfx::Size(50, 50), true, false); |
8159 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8190 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
8160 gfx::PointF(), gfx::Size(50, 50), true, false); | 8191 gfx::PointF(), gfx::Size(50, 50), true, false); |
8161 | 8192 |
8162 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline_impl(), 10.0, 0.1f, | 8193 SetElementIdsForTesting(); |
8163 0.2f); | 8194 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
8195 10.0, 0.1f, 0.2f); | |
8164 ExecuteCalculateDrawProperties(root); | 8196 ExecuteCalculateDrawProperties(root); |
8165 | 8197 |
8166 EXPECT_TRUE(root->has_render_surface()); | 8198 EXPECT_TRUE(root->has_render_surface()); |
8167 EXPECT_TRUE(child->has_render_surface()); | 8199 EXPECT_TRUE(child->has_render_surface()); |
8168 EXPECT_FALSE(grandchild->has_render_surface()); | 8200 EXPECT_FALSE(grandchild->has_render_surface()); |
8169 | 8201 |
8170 EXPECT_TRUE(root->filters().IsEmpty()); | 8202 EXPECT_TRUE(root->filters().IsEmpty()); |
8171 EXPECT_TRUE(child->filters().IsEmpty()); | 8203 EXPECT_TRUE(child->filters().IsEmpty()); |
8172 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8204 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
8173 | 8205 |
(...skipping 10 matching lines...) Expand all Loading... | |
8184 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8216 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
8185 | 8217 |
8186 gfx::Transform identity_transform; | 8218 gfx::Transform identity_transform; |
8187 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8219 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
8188 gfx::PointF(), gfx::Size(50, 50), true, false); | 8220 gfx::PointF(), gfx::Size(50, 50), true, false); |
8189 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8221 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
8190 gfx::PointF(), gfx::Size(50, 50), true, false); | 8222 gfx::PointF(), gfx::Size(50, 50), true, false); |
8191 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8223 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
8192 gfx::PointF(), gfx::Size(50, 50), true, false); | 8224 gfx::PointF(), gfx::Size(50, 50), true, false); |
8193 | 8225 |
8226 SetElementIdsForTesting(); | |
8227 | |
8194 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 8228 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
8195 KeyframedFilterAnimationCurve::Create()); | 8229 KeyframedFilterAnimationCurve::Create()); |
8196 FilterOperations start_filters; | 8230 FilterOperations start_filters; |
8197 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); | 8231 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); |
8198 FilterOperations end_filters; | 8232 FilterOperations end_filters; |
8199 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); | 8233 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); |
8200 curve->AddKeyframe( | 8234 curve->AddKeyframe( |
8201 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 8235 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
8202 curve->AddKeyframe(FilterKeyframe::Create( | 8236 curve->AddKeyframe(FilterKeyframe::Create( |
8203 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); | 8237 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); |
8204 std::unique_ptr<Animation> animation = | 8238 std::unique_ptr<Animation> animation = |
8205 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); | 8239 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); |
8206 animation->set_fill_mode(Animation::FillMode::NONE); | 8240 animation->set_fill_mode(Animation::FillMode::NONE); |
8207 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8241 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8208 | 8242 |
8209 AddAnimationToLayerWithPlayer(child->id(), timeline_impl(), | 8243 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), |
8210 std::move(animation)); | 8244 std::move(animation)); |
8211 ExecuteCalculateDrawProperties(root); | 8245 ExecuteCalculateDrawProperties(root); |
8212 | 8246 |
8213 EXPECT_TRUE(root->has_render_surface()); | 8247 EXPECT_TRUE(root->has_render_surface()); |
8214 EXPECT_TRUE(child->has_render_surface()); | 8248 EXPECT_TRUE(child->has_render_surface()); |
8215 EXPECT_FALSE(grandchild->has_render_surface()); | 8249 EXPECT_FALSE(grandchild->has_render_surface()); |
8216 | 8250 |
8217 EXPECT_TRUE(root->filters().IsEmpty()); | 8251 EXPECT_TRUE(root->filters().IsEmpty()); |
8218 EXPECT_TRUE(child->filters().IsEmpty()); | 8252 EXPECT_TRUE(child->filters().IsEmpty()); |
8219 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8253 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
8220 | 8254 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8562 gfx::PointF(), gfx::Size(10, 10), true, false); | 8596 gfx::PointF(), gfx::Size(10, 10), true, false); |
8563 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | 8597 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), |
8564 gfx::PointF(), gfx::Size(10, 10), true, false); | 8598 gfx::PointF(), gfx::Size(10, 10), true, false); |
8565 | 8599 |
8566 root->AddChild(child); | 8600 root->AddChild(child); |
8567 child->AddChild(grandchild); | 8601 child->AddChild(grandchild); |
8568 grandchild->AddChild(greatgrandchild); | 8602 grandchild->AddChild(greatgrandchild); |
8569 | 8603 |
8570 host()->SetRootLayer(root); | 8604 host()->SetRootLayer(root); |
8571 | 8605 |
8606 host()->SetElementIdsForTesting(); | |
8607 | |
8572 // Check the non-skipped case. | 8608 // Check the non-skipped case. |
8573 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8609 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8574 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8610 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8575 | 8611 |
8576 // Now we will reset the visible rect from property trees for the grandchild, | 8612 // Now we will reset the visible rect from property trees for the grandchild, |
8577 // and we will configure |child| in several ways that should force the subtree | 8613 // and we will configure |child| in several ways that should force the subtree |
8578 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8614 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8579 // remain empty. | 8615 // remain empty. |
8580 grandchild->set_visible_layer_rect(gfx::Rect()); | 8616 grandchild->set_visible_layer_rect(gfx::Rect()); |
8581 gfx::Transform singular; | 8617 gfx::Transform singular; |
8582 singular.matrix().set(0, 0, 0); | 8618 singular.matrix().set(0, 0, 0); |
8583 | 8619 |
8584 child->SetTransform(singular); | 8620 child->SetTransform(singular); |
8585 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8621 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8586 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8622 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
8587 child->SetTransform(identity); | 8623 child->SetTransform(identity); |
8588 | 8624 |
8589 child->SetHideLayerAndSubtree(true); | 8625 child->SetHideLayerAndSubtree(true); |
8590 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8626 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8591 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8627 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
8592 child->SetHideLayerAndSubtree(false); | 8628 child->SetHideLayerAndSubtree(false); |
8593 | 8629 |
8594 gfx::Transform zero_z_scale; | 8630 gfx::Transform zero_z_scale; |
8595 zero_z_scale.Scale3d(1, 1, 0); | 8631 zero_z_scale.Scale3d(1, 1, 0); |
8596 child->SetTransform(zero_z_scale); | 8632 child->SetTransform(zero_z_scale); |
8597 | 8633 |
8634 SetElementIdsForTesting(); | |
ajuma
2016/06/01 23:53:42
Is this needed? (this test only has Layers, not La
Ian Vollick
2016/06/02 19:03:11
Whoops, removed. I clearly added the host()->SetEl
| |
8635 | |
8598 // Add a transform animation with a start delay. Now, even though |child| has | 8636 // Add a transform animation with a start delay. Now, even though |child| has |
8599 // a singular transform, the subtree should still get processed. | 8637 // a singular transform, the subtree should still get processed. |
8600 int animation_id = 0; | 8638 int animation_id = 0; |
8601 std::unique_ptr<Animation> animation = Animation::Create( | 8639 std::unique_ptr<Animation> animation = Animation::Create( |
8602 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8640 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
8603 animation_id, 1, TargetProperty::TRANSFORM); | 8641 animation_id, 1, TargetProperty::TRANSFORM); |
8604 animation->set_fill_mode(Animation::FillMode::NONE); | 8642 animation->set_fill_mode(Animation::FillMode::NONE); |
8605 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8643 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8606 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); | 8644 AddAnimationToElementWithPlayer(child->element_id(), timeline(), |
8645 std::move(animation)); | |
8607 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8646 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8608 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8647 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8609 grandchild->set_visible_layer_rect(gfx::Rect()); | 8648 grandchild->set_visible_layer_rect(gfx::Rect()); |
8610 | 8649 |
8611 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), | 8650 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
8612 animation_id); | 8651 animation_id); |
8613 child->SetTransform(identity); | 8652 child->SetTransform(identity); |
8614 child->SetOpacity(0.f); | 8653 child->SetOpacity(0.f); |
8615 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8654 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8616 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8655 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
8617 | 8656 |
8618 // Now, even though child has zero opacity, we will configure |grandchild| and | 8657 // Now, even though child has zero opacity, we will configure |grandchild| and |
8619 // |greatgrandchild| in several ways that should force the subtree to be | 8658 // |greatgrandchild| in several ways that should force the subtree to be |
8620 // processed anyhow. | 8659 // processed anyhow. |
8621 grandchild->RequestCopyOfOutput( | 8660 grandchild->RequestCopyOfOutput( |
8622 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8661 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
8623 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8662 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8624 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8663 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8625 greatgrandchild->set_visible_layer_rect(gfx::Rect()); | 8664 greatgrandchild->set_visible_layer_rect(gfx::Rect()); |
8626 | 8665 |
8627 // Add an opacity animation with a start delay. | 8666 // Add an opacity animation with a start delay. |
8628 animation_id = 1; | 8667 animation_id = 1; |
8629 animation = Animation::Create( | 8668 animation = Animation::Create( |
8630 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8669 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
8631 animation_id, 1, TargetProperty::OPACITY); | 8670 animation_id, 1, TargetProperty::OPACITY); |
8632 animation->set_fill_mode(Animation::FillMode::NONE); | 8671 animation->set_fill_mode(Animation::FillMode::NONE); |
8633 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8672 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8634 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8673 AddAnimationToElementWithExistingPlayer(child->element_id(), timeline(), |
8635 std::move(animation)); | 8674 std::move(animation)); |
8636 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8675 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8637 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8676 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8638 } | 8677 } |
8639 | 8678 |
8640 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { | 8679 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
8641 FakeImplTaskRunnerProvider task_runner_provider; | 8680 FakeImplTaskRunnerProvider task_runner_provider; |
8642 TestSharedBitmapManager shared_bitmap_manager; | 8681 TestSharedBitmapManager shared_bitmap_manager; |
8643 TestTaskGraphRunner task_graph_runner; | 8682 TestTaskGraphRunner task_graph_runner; |
8644 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8683 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
8645 &task_graph_runner); | 8684 &task_graph_runner); |
(...skipping 24 matching lines...) Expand all Loading... | |
8670 false); | 8709 false); |
8671 | 8710 |
8672 LayerImpl* root_ptr = root.get(); | 8711 LayerImpl* root_ptr = root.get(); |
8673 LayerImpl* child_ptr = child.get(); | 8712 LayerImpl* child_ptr = child.get(); |
8674 LayerImpl* grandchild_ptr = grandchild.get(); | 8713 LayerImpl* grandchild_ptr = grandchild.get(); |
8675 | 8714 |
8676 child->AddChild(std::move(grandchild)); | 8715 child->AddChild(std::move(grandchild)); |
8677 root->AddChild(std::move(child)); | 8716 root->AddChild(std::move(child)); |
8678 host_impl.active_tree()->SetRootLayer(std::move(root)); | 8717 host_impl.active_tree()->SetRootLayer(std::move(root)); |
8679 | 8718 |
8719 host_impl.active_tree()->SetElementIdsForTesting(); | |
8720 | |
8680 // Check the non-skipped case. | 8721 // Check the non-skipped case. |
8681 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8722 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8682 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8723 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8683 | 8724 |
8684 // Now we will reset the visible rect from property trees for the grandchild, | 8725 // Now we will reset the visible rect from property trees for the grandchild, |
8685 // and we will configure |child| in several ways that should force the subtree | 8726 // and we will configure |child| in several ways that should force the subtree |
8686 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8727 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8687 // remain empty. | 8728 // remain empty. |
8688 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8729 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8689 | 8730 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8765 TransformOperations operation; | 8806 TransformOperations operation; |
8766 operation.AppendMatrix(transform); | 8807 operation.AppendMatrix(transform); |
8767 curve->AddKeyframe( | 8808 curve->AddKeyframe( |
8768 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8809 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
8769 curve->AddKeyframe(TransformKeyframe::Create( | 8810 curve->AddKeyframe(TransformKeyframe::Create( |
8770 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8811 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
8771 std::unique_ptr<Animation> transform_animation( | 8812 std::unique_ptr<Animation> transform_animation( |
8772 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8813 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
8773 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8814 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8774 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8815 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
8775 root_ptr->id(), player.get()); | 8816 root_ptr->element_id(), player.get()); |
8776 host_impl.active_tree() | 8817 host_impl.active_tree() |
8777 ->animation_host() | 8818 ->animation_host() |
8778 ->GetElementAnimationsForElementId(root_ptr->id()) | 8819 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
8779 ->AddAnimation(std::move(transform_animation)); | 8820 ->AddAnimation(std::move(transform_animation)); |
8780 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8821 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8781 child_ptr->SetScrollClipLayer(root_ptr->id()); | 8822 child_ptr->SetScrollClipLayer(root_ptr->id()); |
8782 root_ptr->SetTransform(singular); | 8823 root_ptr->SetTransform(singular); |
8783 child_ptr->SetTransform(singular); | 8824 child_ptr->SetTransform(singular); |
8784 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8825 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8785 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8826 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8786 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8827 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8787 | 8828 |
8788 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8829 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
8789 root_ptr->id(), player.get()); | 8830 root_ptr->element_id(), player.get()); |
8790 } | 8831 } |
8791 | 8832 |
8792 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8833 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
8793 LayerImpl* root = root_layer(); | 8834 LayerImpl* root = root_layer(); |
8794 LayerImpl* child = AddChild<LayerImpl>(root); | 8835 LayerImpl* child = AddChild<LayerImpl>(root); |
8795 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8836 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
8796 | 8837 |
8797 gfx::Transform identity; | 8838 gfx::Transform identity; |
8798 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8839 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
8799 gfx::Size(10, 10), true, false, true); | 8840 gfx::Size(10, 10), true, false, true); |
8800 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 8841 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
8801 gfx::Size(10, 10), true, false, false); | 8842 gfx::Size(10, 10), true, false, false); |
8802 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 8843 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
8803 gfx::PointF(), gfx::Size(10, 10), true, false, | 8844 gfx::PointF(), gfx::Size(10, 10), true, false, |
8804 false); | 8845 false); |
8846 SetElementIdsForTesting(); | |
8805 | 8847 |
8806 gfx::Transform singular; | 8848 gfx::Transform singular; |
8807 singular.matrix().set(0, 0, 0); | 8849 singular.matrix().set(0, 0, 0); |
8808 singular.matrix().set(0, 1, 1); | 8850 singular.matrix().set(0, 1, 1); |
8809 | 8851 |
8810 child->SetTransform(singular); | 8852 child->SetTransform(singular); |
8811 child->SetDrawsContent(true); | 8853 child->SetDrawsContent(true); |
8812 grand_child->SetDrawsContent(true); | 8854 grand_child->SetDrawsContent(true); |
8813 | 8855 |
8814 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8856 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
8815 KeyframedTransformAnimationCurve::Create()); | 8857 KeyframedTransformAnimationCurve::Create()); |
8816 TransformOperations start; | 8858 TransformOperations start; |
8817 start.AppendTranslate(1.f, 2.f, 3.f); | 8859 start.AppendTranslate(1.f, 2.f, 3.f); |
8818 gfx::Transform transform; | 8860 gfx::Transform transform; |
8819 transform.Scale3d(1.0, 2.0, 3.0); | 8861 transform.Scale3d(1.0, 2.0, 3.0); |
8820 TransformOperations operation; | 8862 TransformOperations operation; |
8821 operation.AppendMatrix(transform); | 8863 operation.AppendMatrix(transform); |
8822 curve->AddKeyframe( | 8864 curve->AddKeyframe( |
8823 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8865 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
8824 curve->AddKeyframe(TransformKeyframe::Create( | 8866 curve->AddKeyframe(TransformKeyframe::Create( |
8825 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8867 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
8826 std::unique_ptr<Animation> transform_animation( | 8868 std::unique_ptr<Animation> transform_animation( |
8827 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8869 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
8828 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8870 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8829 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( | 8871 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( |
8830 grand_child->id(), player.get()); | 8872 grand_child->element_id(), player.get()); |
8831 host_impl() | 8873 host_impl() |
8832 ->active_tree() | 8874 ->active_tree() |
8833 ->animation_host() | 8875 ->animation_host() |
8834 ->GetElementAnimationsForElementId(grand_child->id()) | 8876 ->GetElementAnimationsForElementId(grand_child->element_id()) |
8835 ->AddAnimation(std::move(transform_animation)); | 8877 ->AddAnimation(std::move(transform_animation)); |
8836 | 8878 |
8837 ExecuteCalculateDrawProperties(root); | 8879 ExecuteCalculateDrawProperties(root); |
8838 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); | 8880 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); |
8839 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8881 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
8840 | 8882 |
8841 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( | 8883 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( |
8842 grand_child->id(), player.get()); | 8884 grand_child->element_id(), player.get()); |
8843 } | 8885 } |
8844 | 8886 |
8845 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 8887 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
8846 FakeImplTaskRunnerProvider task_runner_provider; | 8888 FakeImplTaskRunnerProvider task_runner_provider; |
8847 TestSharedBitmapManager shared_bitmap_manager; | 8889 TestSharedBitmapManager shared_bitmap_manager; |
8848 TestTaskGraphRunner task_graph_runner; | 8890 TestTaskGraphRunner task_graph_runner; |
8849 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8891 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
8850 &task_graph_runner); | 8892 &task_graph_runner); |
8851 | 8893 |
8852 gfx::Transform identity; | 8894 gfx::Transform identity; |
(...skipping 22 matching lines...) Expand all Loading... | |
8875 gfx::PointF(), gfx::Size(10, 10), true, false, | 8917 gfx::PointF(), gfx::Size(10, 10), true, false, |
8876 false); | 8918 false); |
8877 | 8919 |
8878 LayerImpl* root_ptr = root.get(); | 8920 LayerImpl* root_ptr = root.get(); |
8879 LayerImpl* grandchild_ptr = grandchild.get(); | 8921 LayerImpl* grandchild_ptr = grandchild.get(); |
8880 | 8922 |
8881 child->AddChild(std::move(grandchild)); | 8923 child->AddChild(std::move(grandchild)); |
8882 root->AddChild(std::move(child)); | 8924 root->AddChild(std::move(child)); |
8883 | 8925 |
8884 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 8926 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
8927 host_impl.pending_tree()->SetElementIdsForTesting(); | |
8885 | 8928 |
8886 // Check the non-skipped case. | 8929 // Check the non-skipped case. |
8887 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8930 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8888 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8931 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8889 | 8932 |
8890 std::unique_ptr<KeyframedFloatAnimationCurve> curve( | 8933 std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
8891 KeyframedFloatAnimationCurve::Create()); | 8934 KeyframedFloatAnimationCurve::Create()); |
8892 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); | 8935 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); |
8893 curve->AddKeyframe( | 8936 curve->AddKeyframe( |
8894 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); | 8937 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
8895 curve->AddKeyframe( | 8938 curve->AddKeyframe( |
8896 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 8939 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
8897 std::unique_ptr<Animation> animation( | 8940 std::unique_ptr<Animation> animation( |
8898 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 8941 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
8899 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8942 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8900 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8943 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
8901 root_ptr->id(), player.get()); | 8944 root_ptr->element_id(), player.get()); |
8902 host_impl.active_tree() | 8945 host_impl.active_tree() |
8903 ->animation_host() | 8946 ->animation_host() |
8904 ->GetElementAnimationsForElementId(root_ptr->id()) | 8947 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
8905 ->AddAnimation(std::move(animation)); | 8948 ->AddAnimation(std::move(animation)); |
8906 root_ptr->test_properties()->opacity = 0.f; | 8949 root_ptr->test_properties()->opacity = 0.f; |
8907 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8950 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8908 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8951 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8909 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8952 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8910 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8953 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8911 | 8954 |
8912 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8955 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
8913 root_ptr->id(), player.get()); | 8956 root_ptr->element_id(), player.get()); |
8914 } | 8957 } |
8915 | 8958 |
8916 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8959 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
8917 gfx::Transform identity; | 8960 gfx::Transform identity; |
8918 LayerImpl* root = root_layer(); | 8961 LayerImpl* root = root_layer(); |
8919 LayerImpl* child = AddChild<LayerImpl>(root); | 8962 LayerImpl* child = AddChild<LayerImpl>(root); |
8920 | 8963 |
8921 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8964 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
8922 gfx::Size(100, 100), true, false, true); | 8965 gfx::Size(100, 100), true, false, true); |
8923 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 8966 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9754 | 9797 |
9755 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9798 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
9756 const gfx::Transform identity_matrix; | 9799 const gfx::Transform identity_matrix; |
9757 scoped_refptr<Layer> root = Layer::Create(); | 9800 scoped_refptr<Layer> root = Layer::Create(); |
9758 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9801 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9759 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9802 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9760 root->AddChild(animated); | 9803 root->AddChild(animated); |
9761 | 9804 |
9762 host()->SetRootLayer(root); | 9805 host()->SetRootLayer(root); |
9763 | 9806 |
9807 host()->SetElementIdsForTesting(); | |
9808 | |
9764 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9809 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
9765 gfx::PointF(), gfx::Size(100, 100), true, false); | 9810 gfx::PointF(), gfx::Size(100, 100), true, false); |
9766 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 9811 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
9767 gfx::PointF(), gfx::Size(20, 20), true, false); | 9812 gfx::PointF(), gfx::Size(20, 20), true, false); |
9768 | 9813 |
9769 root->SetForceRenderSurfaceForTesting(true); | 9814 root->SetForceRenderSurfaceForTesting(true); |
9770 animated->SetOpacity(0.f); | 9815 animated->SetOpacity(0.f); |
9771 | 9816 |
9772 scoped_refptr<AnimationPlayer> player = | 9817 scoped_refptr<AnimationPlayer> player = |
9773 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9818 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9774 timeline()->AttachPlayer(player); | 9819 timeline()->AttachPlayer(player); |
9775 player->AttachElement(animated->id()); | 9820 |
9821 player->AttachElement(animated->element_id()); | |
9776 | 9822 |
9777 int animation_id = 0; | 9823 int animation_id = 0; |
9778 std::unique_ptr<Animation> animation = Animation::Create( | 9824 std::unique_ptr<Animation> animation = Animation::Create( |
9779 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 9825 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
9780 animation_id, 1, TargetProperty::OPACITY); | 9826 animation_id, 1, TargetProperty::OPACITY); |
9781 animation->set_fill_mode(Animation::FillMode::NONE); | 9827 animation->set_fill_mode(Animation::FillMode::NONE); |
9782 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9828 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
9783 Animation* animation_ptr = animation.get(); | 9829 Animation* animation_ptr = animation.get(); |
9784 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), | 9830 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
9785 std::move(animation)); | 9831 std::move(animation)); |
9786 | 9832 |
9787 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9833 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
9788 | 9834 |
9789 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; | 9835 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; |
9790 EffectNode* node = tree.Node(animated->effect_tree_index()); | 9836 EffectNode* node = tree.Node(animated->effect_tree_index()); |
9791 EXPECT_FALSE(node->data.is_currently_animating_opacity); | 9837 EXPECT_FALSE(node->data.is_currently_animating_opacity); |
9792 EXPECT_TRUE(node->data.has_potential_opacity_animation); | 9838 EXPECT_TRUE(node->data.has_potential_opacity_animation); |
9793 | 9839 |
9794 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9840 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
9795 root->layer_tree_host()->AnimateLayers( | 9841 root->layer_tree_host()->AnimateLayers( |
(...skipping 10 matching lines...) Expand all Loading... | |
9806 | 9852 |
9807 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 9853 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
9808 const gfx::Transform identity_matrix; | 9854 const gfx::Transform identity_matrix; |
9809 scoped_refptr<Layer> root = Layer::Create(); | 9855 scoped_refptr<Layer> root = Layer::Create(); |
9810 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9856 scoped_refptr<LayerWithForcedDrawsContent> animated = |
9811 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9857 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
9812 root->AddChild(animated); | 9858 root->AddChild(animated); |
9813 | 9859 |
9814 host()->SetRootLayer(root); | 9860 host()->SetRootLayer(root); |
9815 | 9861 |
9862 host()->SetElementIdsForTesting(); | |
9863 | |
9816 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9864 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
9817 gfx::PointF(), gfx::Size(100, 100), true, false); | 9865 gfx::PointF(), gfx::Size(100, 100), true, false); |
9818 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 9866 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
9819 gfx::PointF(), gfx::Size(20, 20), true, false); | 9867 gfx::PointF(), gfx::Size(20, 20), true, false); |
9820 | 9868 |
9821 root->SetForceRenderSurfaceForTesting(true); | 9869 root->SetForceRenderSurfaceForTesting(true); |
9822 | 9870 |
9823 scoped_refptr<AnimationPlayer> player = | 9871 scoped_refptr<AnimationPlayer> player = |
9824 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9872 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
9825 timeline()->AttachPlayer(player); | 9873 timeline()->AttachPlayer(player); |
9826 player->AttachElement(animated->id()); | 9874 player->AttachElement(animated->element_id()); |
9827 | 9875 |
9828 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 9876 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
9829 KeyframedTransformAnimationCurve::Create()); | 9877 KeyframedTransformAnimationCurve::Create()); |
9830 TransformOperations start; | 9878 TransformOperations start; |
9831 start.AppendTranslate(1.f, 2.f, 3.f); | 9879 start.AppendTranslate(1.f, 2.f, 3.f); |
9832 gfx::Transform transform; | 9880 gfx::Transform transform; |
9833 transform.Scale3d(1.0, 2.0, 3.0); | 9881 transform.Scale3d(1.0, 2.0, 3.0); |
9834 TransformOperations operation; | 9882 TransformOperations operation; |
9835 operation.AppendMatrix(transform); | 9883 operation.AppendMatrix(transform); |
9836 curve->AddKeyframe( | 9884 curve->AddKeyframe( |
9837 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 9885 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
9838 curve->AddKeyframe(TransformKeyframe::Create( | 9886 curve->AddKeyframe(TransformKeyframe::Create( |
9839 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 9887 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
9840 std::unique_ptr<Animation> animation( | 9888 std::unique_ptr<Animation> animation( |
9841 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 9889 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
9842 animation->set_fill_mode(Animation::FillMode::NONE); | 9890 animation->set_fill_mode(Animation::FillMode::NONE); |
9843 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9891 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
9844 Animation* animation_ptr = animation.get(); | 9892 Animation* animation_ptr = animation.get(); |
9845 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), | 9893 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
9846 std::move(animation)); | 9894 std::move(animation)); |
9847 | 9895 |
9848 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9896 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
9849 | 9897 |
9850 TransformTree& tree = | 9898 TransformTree& tree = |
9851 root->layer_tree_host()->property_trees()->transform_tree; | 9899 root->layer_tree_host()->property_trees()->transform_tree; |
9852 TransformNode* node = tree.Node(animated->transform_tree_index()); | 9900 TransformNode* node = tree.Node(animated->transform_tree_index()); |
9853 EXPECT_FALSE(node->data.is_currently_animating); | 9901 EXPECT_FALSE(node->data.is_currently_animating); |
9854 EXPECT_TRUE(node->data.has_potential_animation); | 9902 EXPECT_TRUE(node->data.has_potential_animation); |
9855 | 9903 |
9856 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9904 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10092 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10140 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10093 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10141 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10094 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10142 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10095 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10143 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10096 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10144 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10097 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10145 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10098 } | 10146 } |
10099 | 10147 |
10100 } // namespace | 10148 } // namespace |
10101 } // namespace cc | 10149 } // namespace cc |
OLD | NEW |