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 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2676 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2676 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2677 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2677 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2678 SetLayerPropertiesForTesting( | 2678 SetLayerPropertiesForTesting( |
2679 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2679 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2680 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2680 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2681 SetLayerPropertiesForTesting( | 2681 SetLayerPropertiesForTesting( |
2682 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2682 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2683 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2683 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2684 | 2684 |
2685 parent->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); | 2685 parent->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
| 2686 SetElementIdsForTesting(); |
2686 | 2687 |
2687 // Put an animated opacity on the render surface. | 2688 // Put an animated opacity on the render surface. |
2688 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), | 2689 AddOpacityTransitionToElementWithPlayer( |
2689 10.0, 1.f, 0.f, false); | 2690 render_surface1->element_id(), timeline_impl(), 10.0, 1.f, 0.f, false); |
2690 | 2691 |
2691 // Also put an animated opacity on a layer without descendants. | 2692 // Also put an animated opacity on a layer without descendants. |
2692 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), | 2693 AddOpacityTransitionToElementWithPlayer(grand_child_of_root->element_id(), |
2693 timeline_impl(), 10.0, 1.f, 0.f, false); | 2694 timeline_impl(), 10.0, 1.f, 0.f, |
| 2695 false); |
2694 | 2696 |
2695 // Put a transform animation on the render surface. | 2697 // Put a transform animation on the render surface. |
2696 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(), | 2698 AddAnimatedTransformToElementWithPlayer(render_surface2->element_id(), |
2697 10.0, 30, 0); | 2699 timeline_impl(), 10.0, 30, 0); |
2698 | 2700 |
2699 // Also put transform animations on grand_child_of_root, and | 2701 // Also put transform animations on grand_child_of_root, and |
2700 // grand_child_of_rs2 | 2702 // grand_child_of_rs2 |
2701 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), | 2703 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), |
2702 timeline_impl(), 10.0, 30, 0); | 2704 timeline_impl(), 10.0, 30, 0); |
2703 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), | 2705 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), |
2704 timeline_impl(), 10.0, 30, 0); | 2706 timeline_impl(), 10.0, 30, 0); |
2705 | 2707 |
2706 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 2708 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; |
2707 ExecuteCalculateDrawProperties(parent); | 2709 ExecuteCalculateDrawProperties(parent); |
2708 | 2710 |
2709 // Only layers that are associated with render surfaces should have an actual | 2711 // Only layers that are associated with render surfaces should have an actual |
2710 // RenderSurface() value. | 2712 // RenderSurface() value. |
2711 ASSERT_TRUE(parent->render_surface()); | 2713 ASSERT_TRUE(parent->render_surface()); |
2712 ASSERT_FALSE(child_of_root->render_surface()); | 2714 ASSERT_FALSE(child_of_root->render_surface()); |
2713 ASSERT_FALSE(grand_child_of_root->render_surface()); | 2715 ASSERT_FALSE(grand_child_of_root->render_surface()); |
2714 | 2716 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 gfx::Size(10, 10), true, false, true); | 2815 gfx::Size(10, 10), true, false, true); |
2814 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 2816 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
2815 gfx::Size(10, 10), true, false, false); | 2817 gfx::Size(10, 10), true, false, false); |
2816 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 2818 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
2817 gfx::PointF(), gfx::Size(10, 10), true, false, | 2819 gfx::PointF(), gfx::Size(10, 10), true, false, |
2818 false); | 2820 false); |
2819 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), | 2821 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), |
2820 gfx::PointF(), gfx::Size(10, 10), true, false, | 2822 gfx::PointF(), gfx::Size(10, 10), true, false, |
2821 false); | 2823 false); |
2822 | 2824 |
| 2825 SetElementIdsForTesting(); |
| 2826 |
2823 // Add a transform animation with a start delay to |grand_child|. | 2827 // Add a transform animation with a start delay to |grand_child|. |
2824 std::unique_ptr<Animation> animation = Animation::Create( | 2828 std::unique_ptr<Animation> animation = Animation::Create( |
2825 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, | 2829 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, |
2826 TargetProperty::TRANSFORM); | 2830 TargetProperty::TRANSFORM); |
2827 animation->set_fill_mode(Animation::FillMode::NONE); | 2831 animation->set_fill_mode(Animation::FillMode::NONE); |
2828 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 2832 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
2829 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), | 2833 AddAnimationToElementWithPlayer(grand_child->element_id(), timeline_impl(), |
2830 std::move(animation)); | 2834 std::move(animation)); |
2831 ExecuteCalculateDrawProperties(parent); | 2835 ExecuteCalculateDrawProperties(parent); |
2832 | 2836 |
2833 EXPECT_FALSE(parent->screen_space_transform_is_animating()); | 2837 EXPECT_FALSE(parent->screen_space_transform_is_animating()); |
2834 EXPECT_FALSE(child->screen_space_transform_is_animating()); | 2838 EXPECT_FALSE(child->screen_space_transform_is_animating()); |
2835 | 2839 |
2836 EXPECT_FALSE(grand_child->TransformIsAnimating()); | 2840 EXPECT_FALSE(grand_child->TransformIsAnimating()); |
2837 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); | 2841 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); |
2838 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); | 2842 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); |
2839 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); | 2843 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); |
2840 } | 2844 } |
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4541 child2->SetDrawsContent(true); | 4545 child2->SetDrawsContent(true); |
4542 animating_surface->SetDrawsContent(true); | 4546 animating_surface->SetDrawsContent(true); |
4543 child_of_animating_surface->SetDrawsContent(true); | 4547 child_of_animating_surface->SetDrawsContent(true); |
4544 animating_child->SetDrawsContent(true); | 4548 animating_child->SetDrawsContent(true); |
4545 | 4549 |
4546 gfx::Transform backface_matrix; | 4550 gfx::Transform backface_matrix; |
4547 backface_matrix.Translate(50.0, 50.0); | 4551 backface_matrix.Translate(50.0, 50.0); |
4548 backface_matrix.RotateAboutYAxis(180.0); | 4552 backface_matrix.RotateAboutYAxis(180.0); |
4549 backface_matrix.Translate(-50.0, -50.0); | 4553 backface_matrix.Translate(-50.0, -50.0); |
4550 | 4554 |
| 4555 SetElementIdsForTesting(); |
| 4556 |
4551 // Animate the transform on the render surface. | 4557 // Animate the transform on the render surface. |
4552 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), | 4558 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), |
4553 timeline_impl(), 10.0, 30, 0); | 4559 timeline_impl(), 10.0, 30, 0); |
4554 // This is just an animating layer, not a surface. | 4560 // This is just an animating layer, not a surface. |
4555 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline_impl(), | 4561 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), |
4556 10.0, 30, 0); | 4562 timeline_impl(), 10.0, 30, 0); |
4557 | 4563 |
4558 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 4564 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
4559 gfx::PointF(), gfx::Size(100, 100), true, false); | 4565 gfx::PointF(), gfx::Size(100, 100), true, false); |
4560 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), | 4566 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), |
4561 gfx::PointF(), gfx::Size(100, 100), true, false); | 4567 gfx::PointF(), gfx::Size(100, 100), true, false); |
4562 SetLayerPropertiesForTesting(animating_surface, backface_matrix, | 4568 SetLayerPropertiesForTesting(animating_surface, backface_matrix, |
4563 gfx::Point3F(), gfx::PointF(), | 4569 gfx::Point3F(), gfx::PointF(), |
4564 gfx::Size(100, 100), true, false, true); | 4570 gfx::Size(100, 100), true, false, true); |
4565 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, | 4571 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, |
4566 gfx::Point3F(), gfx::PointF(), | 4572 gfx::Point3F(), gfx::PointF(), |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5158 false); | 5164 false); |
5159 child->SetDrawsContent(true); | 5165 child->SetDrawsContent(true); |
5160 child->test_properties()->opacity = 0.0f; | 5166 child->test_properties()->opacity = 0.0f; |
5161 | 5167 |
5162 const int child_id = child->id(); | 5168 const int child_id = child->id(); |
5163 root->test_properties()->AddChild(std::move(child)); | 5169 root->test_properties()->AddChild(std::move(child)); |
5164 root->SetHasRenderSurface(true); | 5170 root->SetHasRenderSurface(true); |
5165 LayerImpl* root_layer = root.get(); | 5171 LayerImpl* root_layer = root.get(); |
5166 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | 5172 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
5167 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 5173 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 5174 |
5168 // Add opacity animation. | 5175 // Add opacity animation. |
5169 scoped_refptr<AnimationTimeline> timeline = | 5176 scoped_refptr<AnimationTimeline> timeline = |
5170 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5177 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
5171 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5178 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 5179 host_impl.pending_tree()->SetElementIdsForTesting(); |
5172 | 5180 |
5173 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, | 5181 ElementId child_element_id = |
5174 false); | 5182 host_impl.pending_tree()->LayerById(child_id)->element_id(); |
| 5183 |
| 5184 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, |
| 5185 0.0f, 1.0f, false); |
5175 | 5186 |
5176 LayerImplList render_surface_layer_list; | 5187 LayerImplList render_surface_layer_list; |
5177 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5188 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
5178 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5189 root_layer, root_layer->bounds(), &render_surface_layer_list); |
5179 inputs.can_adjust_raster_scales = true; | 5190 inputs.can_adjust_raster_scales = true; |
5180 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5191 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
5181 | 5192 |
5182 // We should have one render surface and two layers. The child | 5193 // We should have one render surface and two layers. The child |
5183 // layer should be included even though it is transparent. | 5194 // layer should be included even though it is transparent. |
5184 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5195 ASSERT_EQ(1u, render_surface_layer_list.size()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5277 | 5288 |
5278 // Stash raw pointers to look at later. | 5289 // Stash raw pointers to look at later. |
5279 root_ = root_ptr.get(); | 5290 root_ = root_ptr.get(); |
5280 child_ = child_ptr.get(); | 5291 child_ = child_ptr.get(); |
5281 grand_child_ = grand_child_ptr.get(); | 5292 grand_child_ = grand_child_ptr.get(); |
5282 | 5293 |
5283 child_->test_properties()->AddChild(std::move(grand_child_ptr)); | 5294 child_->test_properties()->AddChild(std::move(grand_child_ptr)); |
5284 root_->test_properties()->AddChild(std::move(child_ptr)); | 5295 root_->test_properties()->AddChild(std::move(child_ptr)); |
5285 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root_ptr)); | 5296 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5286 | 5297 |
| 5298 host_impl_.active_tree()->SetElementIdsForTesting(); |
| 5299 |
5287 root_->SetContentsOpaque(true); | 5300 root_->SetContentsOpaque(true); |
5288 child_->SetContentsOpaque(true); | 5301 child_->SetContentsOpaque(true); |
5289 grand_child_->SetContentsOpaque(true); | 5302 grand_child_->SetContentsOpaque(true); |
5290 | 5303 |
5291 root_->SetDrawsContent(true); | 5304 root_->SetDrawsContent(true); |
5292 child_->SetDrawsContent(true); | 5305 child_->SetDrawsContent(true); |
5293 grand_child_->SetDrawsContent(true); | 5306 grand_child_->SetDrawsContent(true); |
5294 | 5307 |
5295 gfx::Transform identity_matrix; | 5308 gfx::Transform identity_matrix; |
5296 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), | 5309 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5418 | 5431 |
5419 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5432 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
5420 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5433 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
5421 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5434 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
5422 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5435 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
5423 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5436 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
5424 | 5437 |
5425 // Add opacity animation. | 5438 // Add opacity animation. |
5426 child_->test_properties()->opacity = 0.9f; | 5439 child_->test_properties()->opacity = 0.9f; |
5427 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5440 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
5428 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5441 |
5429 0.1f, false); | 5442 SetElementIdsForTesting(); |
| 5443 |
| 5444 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), |
| 5445 10.0, 0.9f, 0.1f, false); |
5430 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5446 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
5431 // Text LCD should be adjusted while animation is active. | 5447 // Text LCD should be adjusted while animation is active. |
5432 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5448 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
5433 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5449 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
5434 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5450 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
5435 } | 5451 } |
5436 | 5452 |
5437 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { | 5453 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { |
5438 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 5454 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
5439 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 5455 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
5440 | 5456 |
5441 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5457 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
5442 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5458 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
5443 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5459 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
5444 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5460 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
5445 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5461 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5462 SetElementIdsForTesting(); |
5446 | 5463 |
5447 // Mark contents non-opaque within the first animation frame. | 5464 // Mark contents non-opaque within the first animation frame. |
5448 child_->SetContentsOpaque(false); | 5465 child_->SetContentsOpaque(false); |
5449 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, | 5466 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), |
5450 0.1f, false); | 5467 10.0, 0.9f, 0.1f, false); |
5451 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5468 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
5452 // LCD text should be disabled for non-opaque layers even during animations. | 5469 // LCD text should be disabled for non-opaque layers even during animations. |
5453 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5470 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
5454 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5471 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
5455 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5472 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
5456 } | 5473 } |
5457 | 5474 |
5458 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5475 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
5459 LCDTextTest, | 5476 LCDTextTest, |
5460 testing::Combine(testing::Bool(), | 5477 testing::Combine(testing::Bool(), |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7273 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), | 7290 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), |
7274 gfx::PointF(), gfx::Size(100, 100), true, false, | 7291 gfx::PointF(), gfx::Size(100, 100), true, false, |
7275 false); | 7292 false); |
7276 | 7293 |
7277 gfx::Transform end_scale; | 7294 gfx::Transform end_scale; |
7278 end_scale.Scale(2.f, 2.f); | 7295 end_scale.Scale(2.f, 2.f); |
7279 TransformOperations start_operations; | 7296 TransformOperations start_operations; |
7280 start_operations.AppendMatrix(start_scale); | 7297 start_operations.AppendMatrix(start_scale); |
7281 TransformOperations end_operations; | 7298 TransformOperations end_operations; |
7282 end_operations.AppendMatrix(end_scale); | 7299 end_operations.AppendMatrix(end_scale); |
7283 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), | 7300 SetElementIdsForTesting(); |
7284 1.0, start_operations, end_operations); | 7301 |
| 7302 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), |
| 7303 timeline_impl(), 1.0, |
| 7304 start_operations, end_operations); |
7285 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7305 gfx::Vector2dF scroll_delta(5.f, 9.f); |
7286 SetScrollOffsetDelta(scroller, scroll_delta); | 7306 SetScrollOffsetDelta(scroller, scroll_delta); |
7287 | 7307 |
7288 ExecuteCalculateDrawProperties(root); | 7308 ExecuteCalculateDrawProperties(root); |
7289 | 7309 |
7290 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7310 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
7291 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7311 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
7292 scroller->DrawTransform().To2dTranslation()); | 7312 scroller->DrawTransform().To2dTranslation()); |
7293 } | 7313 } |
7294 | 7314 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7377 0.f, | 7397 0.f, |
7378 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7398 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7379 | 7399 |
7380 TransformOperations translation; | 7400 TransformOperations translation; |
7381 translation.AppendTranslate(1.f, 2.f, 3.f); | 7401 translation.AppendTranslate(1.f, 2.f, 3.f); |
7382 | 7402 |
7383 scoped_refptr<AnimationTimeline> timeline; | 7403 scoped_refptr<AnimationTimeline> timeline; |
7384 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7404 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
7385 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7405 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7386 | 7406 |
7387 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7407 host_impl.active_tree()->SetElementIdsForTesting(); |
7388 TransformOperations(), translation); | 7408 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
| 7409 1.0, TransformOperations(), |
| 7410 translation); |
7389 | 7411 |
7390 // No layers have scale-affecting animations. | 7412 // No layers have scale-affecting animations. |
7391 EXPECT_EQ( | 7413 EXPECT_EQ( |
7392 0.f, | 7414 0.f, |
7393 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7415 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7394 EXPECT_EQ(0.f, | 7416 EXPECT_EQ(0.f, |
7395 parent_raw->draw_properties().maximum_animation_contents_scale); | 7417 parent_raw->draw_properties().maximum_animation_contents_scale); |
7396 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7418 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7397 EXPECT_EQ( | 7419 EXPECT_EQ( |
7398 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7420 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7399 | 7421 |
7400 EXPECT_EQ( | 7422 EXPECT_EQ( |
7401 0.f, | 7423 0.f, |
7402 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7424 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7403 EXPECT_EQ(0.f, | 7425 EXPECT_EQ(0.f, |
7404 parent_raw->draw_properties().starting_animation_contents_scale); | 7426 parent_raw->draw_properties().starting_animation_contents_scale); |
7405 EXPECT_EQ(0.f, | 7427 EXPECT_EQ(0.f, |
7406 child_raw->draw_properties().starting_animation_contents_scale); | 7428 child_raw->draw_properties().starting_animation_contents_scale); |
7407 EXPECT_EQ( | 7429 EXPECT_EQ( |
7408 0.f, | 7430 0.f, |
7409 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7431 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7410 | 7432 |
7411 TransformOperations scale; | 7433 TransformOperations scale; |
7412 scale.AppendScale(5.f, 4.f, 3.f); | 7434 scale.AppendScale(5.f, 4.f, 3.f); |
7413 | 7435 |
7414 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7436 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
7415 TransformOperations(), scale); | 7437 1.0, TransformOperations(), scale); |
7416 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7438 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7417 ExecuteCalculateDrawProperties(grand_parent_raw); | 7439 ExecuteCalculateDrawProperties(grand_parent_raw); |
7418 | 7440 |
7419 // Only |child| has a scale-affecting animation. | 7441 // Only |child| has a scale-affecting animation. |
7420 EXPECT_EQ( | 7442 EXPECT_EQ( |
7421 0.f, | 7443 0.f, |
7422 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7444 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7423 EXPECT_EQ(0.f, | 7445 EXPECT_EQ(0.f, |
7424 parent_raw->draw_properties().maximum_animation_contents_scale); | 7446 parent_raw->draw_properties().maximum_animation_contents_scale); |
7425 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7447 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7426 EXPECT_EQ( | 7448 EXPECT_EQ( |
7427 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7449 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7428 | 7450 |
7429 EXPECT_EQ( | 7451 EXPECT_EQ( |
7430 0.f, | 7452 0.f, |
7431 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7453 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7432 EXPECT_EQ(0.f, | 7454 EXPECT_EQ(0.f, |
7433 parent_raw->draw_properties().starting_animation_contents_scale); | 7455 parent_raw->draw_properties().starting_animation_contents_scale); |
7434 EXPECT_EQ(1.f, | 7456 EXPECT_EQ(1.f, |
7435 child_raw->draw_properties().starting_animation_contents_scale); | 7457 child_raw->draw_properties().starting_animation_contents_scale); |
7436 EXPECT_EQ( | 7458 EXPECT_EQ( |
7437 1.f, | 7459 1.f, |
7438 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7460 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7439 | 7461 |
7440 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, | 7462 AddAnimatedTransformToElementWithPlayer(grand_parent_raw->element_id(), |
7441 TransformOperations(), scale); | 7463 timeline, 1.0, TransformOperations(), |
| 7464 scale); |
7442 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7465 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7443 ExecuteCalculateDrawProperties(grand_parent_raw); | 7466 ExecuteCalculateDrawProperties(grand_parent_raw); |
7444 | 7467 |
7445 // |grand_parent| and |child| have scale-affecting animations. | 7468 // |grand_parent| and |child| have scale-affecting animations. |
7446 EXPECT_EQ( | 7469 EXPECT_EQ( |
7447 5.f, | 7470 5.f, |
7448 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7471 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7449 EXPECT_EQ(5.f, | 7472 EXPECT_EQ(5.f, |
7450 parent_raw->draw_properties().maximum_animation_contents_scale); | 7473 parent_raw->draw_properties().maximum_animation_contents_scale); |
7451 // 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 |
7452 // that the maximum scale could not be computed. | 7475 // that the maximum scale could not be computed. |
7453 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); |
7454 EXPECT_EQ( | 7477 EXPECT_EQ( |
7455 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7478 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7456 | 7479 |
7457 EXPECT_EQ( | 7480 EXPECT_EQ( |
7458 1.f, | 7481 1.f, |
7459 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7482 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7460 EXPECT_EQ(1.f, | 7483 EXPECT_EQ(1.f, |
7461 parent_raw->draw_properties().starting_animation_contents_scale); | 7484 parent_raw->draw_properties().starting_animation_contents_scale); |
7462 EXPECT_EQ(0.f, | 7485 EXPECT_EQ(0.f, |
7463 child_raw->draw_properties().starting_animation_contents_scale); | 7486 child_raw->draw_properties().starting_animation_contents_scale); |
7464 EXPECT_EQ( | 7487 EXPECT_EQ( |
7465 0.f, | 7488 0.f, |
7466 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7489 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7467 | 7490 |
7468 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7491 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
7469 TransformOperations(), scale); | 7492 1.0, TransformOperations(), scale); |
7470 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7493 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7471 ExecuteCalculateDrawProperties(grand_parent_raw); | 7494 ExecuteCalculateDrawProperties(grand_parent_raw); |
7472 | 7495 |
7473 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7496 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
7474 EXPECT_EQ( | 7497 EXPECT_EQ( |
7475 5.f, | 7498 5.f, |
7476 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7499 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7477 EXPECT_EQ(0.f, | 7500 EXPECT_EQ(0.f, |
7478 parent_raw->draw_properties().maximum_animation_contents_scale); | 7501 parent_raw->draw_properties().maximum_animation_contents_scale); |
7479 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7502 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7480 EXPECT_EQ( | 7503 EXPECT_EQ( |
7481 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7504 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7482 | 7505 |
7483 EXPECT_EQ( | 7506 EXPECT_EQ( |
7484 1.f, | 7507 1.f, |
7485 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7508 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7486 EXPECT_EQ(0.f, | 7509 EXPECT_EQ(0.f, |
7487 parent_raw->draw_properties().starting_animation_contents_scale); | 7510 parent_raw->draw_properties().starting_animation_contents_scale); |
7488 EXPECT_EQ(0.f, | 7511 EXPECT_EQ(0.f, |
7489 child_raw->draw_properties().starting_animation_contents_scale); | 7512 child_raw->draw_properties().starting_animation_contents_scale); |
7490 EXPECT_EQ( | 7513 EXPECT_EQ( |
7491 0.f, | 7514 0.f, |
7492 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7515 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7493 | 7516 |
7494 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, | 7517 AbortAnimationsOnElementWithPlayer(grand_parent_raw->element_id(), timeline, |
7495 TargetProperty::TRANSFORM); | 7518 TargetProperty::TRANSFORM); |
7496 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, | 7519 AbortAnimationsOnElementWithPlayer(parent_raw->element_id(), timeline, |
7497 TargetProperty::TRANSFORM); | 7520 TargetProperty::TRANSFORM); |
7498 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7521 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
7499 TargetProperty::TRANSFORM); | 7522 TargetProperty::TRANSFORM); |
7500 | 7523 |
7501 TransformOperations perspective; | 7524 TransformOperations perspective; |
7502 perspective.AppendPerspective(10.f); | 7525 perspective.AppendPerspective(10.f); |
7503 | 7526 |
7504 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7527 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, |
7505 TransformOperations(), perspective); | 7528 1.0, TransformOperations(), |
| 7529 perspective); |
7506 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7530 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7507 ExecuteCalculateDrawProperties(grand_parent_raw); | 7531 ExecuteCalculateDrawProperties(grand_parent_raw); |
7508 | 7532 |
7509 // |child| has a scale-affecting animation but computing the maximum of this | 7533 // |child| has a scale-affecting animation but computing the maximum of this |
7510 // animation is not supported. | 7534 // animation is not supported. |
7511 EXPECT_EQ( | 7535 EXPECT_EQ( |
7512 0.f, | 7536 0.f, |
7513 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7537 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7514 EXPECT_EQ(0.f, | 7538 EXPECT_EQ(0.f, |
7515 parent_raw->draw_properties().maximum_animation_contents_scale); | 7539 parent_raw->draw_properties().maximum_animation_contents_scale); |
7516 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7540 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
7517 EXPECT_EQ( | 7541 EXPECT_EQ( |
7518 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7542 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
7519 | 7543 |
7520 EXPECT_EQ( | 7544 EXPECT_EQ( |
7521 0.f, | 7545 0.f, |
7522 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7546 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
7523 EXPECT_EQ(0.f, | 7547 EXPECT_EQ(0.f, |
7524 parent_raw->draw_properties().starting_animation_contents_scale); | 7548 parent_raw->draw_properties().starting_animation_contents_scale); |
7525 EXPECT_EQ(0.f, | 7549 EXPECT_EQ(0.f, |
7526 child_raw->draw_properties().starting_animation_contents_scale); | 7550 child_raw->draw_properties().starting_animation_contents_scale); |
7527 EXPECT_EQ( | 7551 EXPECT_EQ( |
7528 0.f, | 7552 0.f, |
7529 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7553 grand_child_raw->draw_properties().starting_animation_contents_scale); |
7530 | 7554 |
7531 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7555 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
7532 TargetProperty::TRANSFORM); | 7556 TargetProperty::TRANSFORM); |
7533 gfx::Transform scale_matrix; | 7557 gfx::Transform scale_matrix; |
7534 scale_matrix.Scale(1.f, 2.f); | 7558 scale_matrix.Scale(1.f, 2.f); |
7535 grand_parent_raw->SetTransform(scale_matrix); | 7559 grand_parent_raw->SetTransform(scale_matrix); |
7536 parent_raw->SetTransform(scale_matrix); | 7560 parent_raw->SetTransform(scale_matrix); |
7537 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7561 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7538 | 7562 |
7539 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7563 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
7540 TransformOperations(), scale); | 7564 1.0, TransformOperations(), scale); |
7541 ExecuteCalculateDrawProperties(grand_parent_raw); | 7565 ExecuteCalculateDrawProperties(grand_parent_raw); |
7542 | 7566 |
7543 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7567 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
7544 // animation with maximum scale 5.f. | 7568 // animation with maximum scale 5.f. |
7545 EXPECT_EQ( | 7569 EXPECT_EQ( |
7546 0.f, | 7570 0.f, |
7547 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7571 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
7548 EXPECT_EQ(10.f, | 7572 EXPECT_EQ(10.f, |
7549 parent_raw->draw_properties().maximum_animation_contents_scale); | 7573 parent_raw->draw_properties().maximum_animation_contents_scale); |
7550 EXPECT_EQ(10.f, | 7574 EXPECT_EQ(10.f, |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7938 std::unique_ptr<LayerImpl> child2 = | 7962 std::unique_ptr<LayerImpl> child2 = |
7939 LayerImpl::Create(host_impl.active_tree(), 3); | 7963 LayerImpl::Create(host_impl.active_tree(), 3); |
7940 LayerImpl* child2_layer = child2.get(); | 7964 LayerImpl* child2_layer = child2.get(); |
7941 | 7965 |
7942 root->test_properties()->AddChild(std::move(child1)); | 7966 root->test_properties()->AddChild(std::move(child1)); |
7943 root->test_properties()->AddChild(std::move(child2)); | 7967 root->test_properties()->AddChild(std::move(child2)); |
7944 root->test_properties()->force_render_surface = true; | 7968 root->test_properties()->force_render_surface = true; |
7945 root->SetDrawsContent(true); | 7969 root->SetDrawsContent(true); |
7946 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7970 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
7947 | 7971 |
| 7972 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7973 |
7948 gfx::Transform identity_matrix, scale_transform_child1, | 7974 gfx::Transform identity_matrix, scale_transform_child1, |
7949 scale_transform_child2; | 7975 scale_transform_child2; |
7950 scale_transform_child1.Scale(2, 3); | 7976 scale_transform_child1.Scale(2, 3); |
7951 scale_transform_child2.Scale(4, 5); | 7977 scale_transform_child2.Scale(4, 5); |
7952 | 7978 |
7953 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7979 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
7954 gfx::PointF(), gfx::Size(1, 1), true, false, | 7980 gfx::PointF(), gfx::Size(1, 1), true, false, |
7955 true); | 7981 true); |
7956 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7982 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
7957 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7983 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
(...skipping 12 matching lines...) Expand all Loading... |
7970 | 7996 |
7971 ExecuteCalculateDrawProperties(root_layer); | 7997 ExecuteCalculateDrawProperties(root_layer); |
7972 | 7998 |
7973 TransformOperations scale; | 7999 TransformOperations scale; |
7974 scale.AppendScale(5.f, 8.f, 3.f); | 8000 scale.AppendScale(5.f, 8.f, 3.f); |
7975 | 8001 |
7976 scoped_refptr<AnimationTimeline> timeline = | 8002 scoped_refptr<AnimationTimeline> timeline = |
7977 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 8003 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
7978 host_impl.animation_host()->AddAnimationTimeline(timeline); | 8004 host_impl.animation_host()->AddAnimationTimeline(timeline); |
7979 | 8005 |
7980 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, | |
7981 TransformOperations(), scale); | |
7982 | |
7983 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 8006 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
7984 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 8007 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
7985 true, false, false); | 8008 true, false, false); |
7986 child2_layer->SetDrawsContent(true); | 8009 child2_layer->SetDrawsContent(true); |
7987 | 8010 |
| 8011 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 8012 1.0, TransformOperations(), scale); |
| 8013 |
7988 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8014 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7989 ExecuteCalculateDrawProperties(root_layer); | 8015 ExecuteCalculateDrawProperties(root_layer); |
7990 | 8016 |
7991 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 8017 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
7992 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 8018 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
7993 EXPECT_FLOAT_EQ( | 8019 EXPECT_FLOAT_EQ( |
7994 3.f, | 8020 3.f, |
7995 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); | 8021 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); |
7996 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); | 8022 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); |
7997 | 8023 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8225 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { | 8251 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
8226 const gfx::Transform identity_matrix; | 8252 const gfx::Transform identity_matrix; |
8227 scoped_refptr<Layer> root = Layer::Create(); | 8253 scoped_refptr<Layer> root = Layer::Create(); |
8228 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8254 scoped_refptr<LayerWithForcedDrawsContent> animated = |
8229 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8255 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8230 | 8256 |
8231 root->AddChild(animated); | 8257 root->AddChild(animated); |
8232 | 8258 |
8233 host()->SetRootLayer(root); | 8259 host()->SetRootLayer(root); |
8234 | 8260 |
| 8261 host()->SetElementIdsForTesting(); |
| 8262 |
8235 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8263 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
8236 gfx::PointF(), gfx::Size(100, 100), true, false); | 8264 gfx::PointF(), gfx::Size(100, 100), true, false); |
8237 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 8265 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
8238 gfx::PointF(), gfx::Size(20, 20), true, false); | 8266 gfx::PointF(), gfx::Size(20, 20), true, false); |
8239 | 8267 |
8240 root->SetMasksToBounds(true); | 8268 root->SetMasksToBounds(true); |
8241 root->SetForceRenderSurfaceForTesting(true); | 8269 root->SetForceRenderSurfaceForTesting(true); |
8242 animated->SetOpacity(0.f); | 8270 animated->SetOpacity(0.f); |
8243 | 8271 |
8244 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, | 8272 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), |
8245 1.f, false); | 8273 10.0, 0.f, 1.f, false); |
8246 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8274 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8247 | 8275 |
8248 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); | 8276 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); |
8249 } | 8277 } |
8250 | 8278 |
8251 TEST_F(LayerTreeHostCommonTest, | 8279 TEST_F(LayerTreeHostCommonTest, |
8252 VisibleContentRectForAnimatedLayerWithSingularTransform) { | 8280 VisibleContentRectForAnimatedLayerWithSingularTransform) { |
8253 const gfx::Transform identity_matrix; | 8281 const gfx::Transform identity_matrix; |
8254 scoped_refptr<Layer> root = Layer::Create(); | 8282 scoped_refptr<Layer> root = Layer::Create(); |
8255 scoped_refptr<Layer> clip = Layer::Create(); | 8283 scoped_refptr<Layer> clip = Layer::Create(); |
8256 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8284 scoped_refptr<LayerWithForcedDrawsContent> animated = |
8257 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8285 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8258 scoped_refptr<LayerWithForcedDrawsContent> surface = | 8286 scoped_refptr<LayerWithForcedDrawsContent> surface = |
8259 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8287 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8260 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = | 8288 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = |
8261 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8289 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
8262 | 8290 |
8263 root->AddChild(clip); | 8291 root->AddChild(clip); |
8264 clip->AddChild(animated); | 8292 clip->AddChild(animated); |
8265 animated->AddChild(surface); | 8293 animated->AddChild(surface); |
8266 surface->AddChild(descendant_of_animation); | 8294 surface->AddChild(descendant_of_animation); |
8267 | 8295 |
8268 clip->SetMasksToBounds(true); | 8296 clip->SetMasksToBounds(true); |
8269 surface->SetForceRenderSurfaceForTesting(true); | 8297 surface->SetForceRenderSurfaceForTesting(true); |
8270 | 8298 |
8271 host()->SetRootLayer(root); | 8299 host()->SetRootLayer(root); |
8272 | 8300 |
| 8301 host()->SetElementIdsForTesting(); |
| 8302 |
8273 gfx::Transform uninvertible_matrix; | 8303 gfx::Transform uninvertible_matrix; |
8274 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); | 8304 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); |
8275 | 8305 |
8276 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8306 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
8277 gfx::PointF(), gfx::Size(100, 100), true, false); | 8307 gfx::PointF(), gfx::Size(100, 100), true, false); |
8278 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), | 8308 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), |
8279 gfx::PointF(), gfx::Size(10, 10), true, false); | 8309 gfx::PointF(), gfx::Size(10, 10), true, false); |
8280 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, | 8310 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, |
8281 gfx::Point3F(), gfx::PointF(), | 8311 gfx::Point3F(), gfx::PointF(), |
8282 gfx::Size(120, 120), true, false); | 8312 gfx::Size(120, 120), true, false); |
8283 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 8313 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
8284 gfx::PointF(), gfx::Size(100, 100), true, false); | 8314 gfx::PointF(), gfx::Size(100, 100), true, false); |
8285 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, | 8315 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, |
8286 gfx::Point3F(), gfx::PointF(), | 8316 gfx::Point3F(), gfx::PointF(), |
8287 gfx::Size(200, 200), true, false); | 8317 gfx::Size(200, 200), true, false); |
8288 | 8318 |
8289 TransformOperations start_transform_operations; | 8319 TransformOperations start_transform_operations; |
8290 start_transform_operations.AppendMatrix(uninvertible_matrix); | 8320 start_transform_operations.AppendMatrix(uninvertible_matrix); |
8291 TransformOperations end_transform_operations; | 8321 TransformOperations end_transform_operations; |
8292 | 8322 |
8293 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, | 8323 SetElementIdsForTesting(); |
8294 start_transform_operations, | 8324 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), |
8295 end_transform_operations); | 8325 10.0, start_transform_operations, |
| 8326 end_transform_operations); |
8296 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8327 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8297 | 8328 |
8298 // The animated layer has a singular transform and maps to a non-empty rect in | 8329 // The animated layer has a singular transform and maps to a non-empty rect in |
8299 // clipped target space, so is treated as fully visible. | 8330 // clipped target space, so is treated as fully visible. |
8300 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); | 8331 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); |
8301 | 8332 |
8302 // The singular transform on |animated| is flattened when inherited by | 8333 // The singular transform on |animated| is flattened when inherited by |
8303 // |surface|, and this happens to make it invertible. | 8334 // |surface|, and this happens to make it invertible. |
8304 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); | 8335 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); |
8305 EXPECT_EQ(gfx::Rect(2, 2), | 8336 EXPECT_EQ(gfx::Rect(2, 2), |
(...skipping 26 matching lines...) Expand all Loading... |
8332 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8363 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
8333 | 8364 |
8334 gfx::Transform identity_transform; | 8365 gfx::Transform identity_transform; |
8335 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8366 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
8336 gfx::PointF(), gfx::Size(50, 50), true, false); | 8367 gfx::PointF(), gfx::Size(50, 50), true, false); |
8337 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8368 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
8338 gfx::PointF(), gfx::Size(50, 50), true, false); | 8369 gfx::PointF(), gfx::Size(50, 50), true, false); |
8339 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8370 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
8340 gfx::PointF(), gfx::Size(50, 50), true, false); | 8371 gfx::PointF(), gfx::Size(50, 50), true, false); |
8341 | 8372 |
8342 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline_impl(), 10.0, 0.1f, | 8373 SetElementIdsForTesting(); |
8343 0.2f); | 8374 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
| 8375 10.0, 0.1f, 0.2f); |
8344 ExecuteCalculateDrawProperties(root); | 8376 ExecuteCalculateDrawProperties(root); |
8345 | 8377 |
8346 EXPECT_TRUE(root->has_render_surface()); | 8378 EXPECT_TRUE(root->has_render_surface()); |
8347 EXPECT_TRUE(child->has_render_surface()); | 8379 EXPECT_TRUE(child->has_render_surface()); |
8348 EXPECT_FALSE(grandchild->has_render_surface()); | 8380 EXPECT_FALSE(grandchild->has_render_surface()); |
8349 | 8381 |
8350 EXPECT_TRUE(root->filters().IsEmpty()); | 8382 EXPECT_TRUE(root->filters().IsEmpty()); |
8351 EXPECT_TRUE(child->filters().IsEmpty()); | 8383 EXPECT_TRUE(child->filters().IsEmpty()); |
8352 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8384 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
8353 | 8385 |
(...skipping 10 matching lines...) Expand all Loading... |
8364 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8396 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
8365 | 8397 |
8366 gfx::Transform identity_transform; | 8398 gfx::Transform identity_transform; |
8367 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8399 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
8368 gfx::PointF(), gfx::Size(50, 50), true, false); | 8400 gfx::PointF(), gfx::Size(50, 50), true, false); |
8369 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8401 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
8370 gfx::PointF(), gfx::Size(50, 50), true, false); | 8402 gfx::PointF(), gfx::Size(50, 50), true, false); |
8371 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8403 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
8372 gfx::PointF(), gfx::Size(50, 50), true, false); | 8404 gfx::PointF(), gfx::Size(50, 50), true, false); |
8373 | 8405 |
| 8406 SetElementIdsForTesting(); |
| 8407 |
8374 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 8408 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
8375 KeyframedFilterAnimationCurve::Create()); | 8409 KeyframedFilterAnimationCurve::Create()); |
8376 FilterOperations start_filters; | 8410 FilterOperations start_filters; |
8377 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); | 8411 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); |
8378 FilterOperations end_filters; | 8412 FilterOperations end_filters; |
8379 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); | 8413 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); |
8380 curve->AddKeyframe( | 8414 curve->AddKeyframe( |
8381 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 8415 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
8382 curve->AddKeyframe(FilterKeyframe::Create( | 8416 curve->AddKeyframe(FilterKeyframe::Create( |
8383 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); | 8417 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); |
8384 std::unique_ptr<Animation> animation = | 8418 std::unique_ptr<Animation> animation = |
8385 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); | 8419 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); |
8386 animation->set_fill_mode(Animation::FillMode::NONE); | 8420 animation->set_fill_mode(Animation::FillMode::NONE); |
8387 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8421 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8388 | 8422 |
8389 AddAnimationToLayerWithPlayer(child->id(), timeline_impl(), | 8423 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), |
8390 std::move(animation)); | 8424 std::move(animation)); |
8391 ExecuteCalculateDrawProperties(root); | 8425 ExecuteCalculateDrawProperties(root); |
8392 | 8426 |
8393 EXPECT_TRUE(root->has_render_surface()); | 8427 EXPECT_TRUE(root->has_render_surface()); |
8394 EXPECT_TRUE(child->has_render_surface()); | 8428 EXPECT_TRUE(child->has_render_surface()); |
8395 EXPECT_FALSE(grandchild->has_render_surface()); | 8429 EXPECT_FALSE(grandchild->has_render_surface()); |
8396 | 8430 |
8397 EXPECT_TRUE(root->filters().IsEmpty()); | 8431 EXPECT_TRUE(root->filters().IsEmpty()); |
8398 EXPECT_TRUE(child->filters().IsEmpty()); | 8432 EXPECT_TRUE(child->filters().IsEmpty()); |
8399 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8433 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
8400 | 8434 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8742 gfx::PointF(), gfx::Size(10, 10), true, false); | 8776 gfx::PointF(), gfx::Size(10, 10), true, false); |
8743 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | 8777 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), |
8744 gfx::PointF(), gfx::Size(10, 10), true, false); | 8778 gfx::PointF(), gfx::Size(10, 10), true, false); |
8745 | 8779 |
8746 root->AddChild(child); | 8780 root->AddChild(child); |
8747 child->AddChild(grandchild); | 8781 child->AddChild(grandchild); |
8748 grandchild->AddChild(greatgrandchild); | 8782 grandchild->AddChild(greatgrandchild); |
8749 | 8783 |
8750 host()->SetRootLayer(root); | 8784 host()->SetRootLayer(root); |
8751 | 8785 |
| 8786 host()->SetElementIdsForTesting(); |
| 8787 |
8752 // Check the non-skipped case. | 8788 // Check the non-skipped case. |
8753 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8789 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8754 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8790 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8755 | 8791 |
8756 // Now we will reset the visible rect from property trees for the grandchild, | 8792 // Now we will reset the visible rect from property trees for the grandchild, |
8757 // and we will configure |child| in several ways that should force the subtree | 8793 // and we will configure |child| in several ways that should force the subtree |
8758 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8794 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8759 // remain empty. | 8795 // remain empty. |
8760 grandchild->set_visible_layer_rect(gfx::Rect()); | 8796 grandchild->set_visible_layer_rect(gfx::Rect()); |
8761 gfx::Transform singular; | 8797 gfx::Transform singular; |
(...skipping 14 matching lines...) Expand all Loading... |
8776 child->SetTransform(zero_z_scale); | 8812 child->SetTransform(zero_z_scale); |
8777 | 8813 |
8778 // Add a transform animation with a start delay. Now, even though |child| has | 8814 // Add a transform animation with a start delay. Now, even though |child| has |
8779 // a singular transform, the subtree should still get processed. | 8815 // a singular transform, the subtree should still get processed. |
8780 int animation_id = 0; | 8816 int animation_id = 0; |
8781 std::unique_ptr<Animation> animation = Animation::Create( | 8817 std::unique_ptr<Animation> animation = Animation::Create( |
8782 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8818 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
8783 animation_id, 1, TargetProperty::TRANSFORM); | 8819 animation_id, 1, TargetProperty::TRANSFORM); |
8784 animation->set_fill_mode(Animation::FillMode::NONE); | 8820 animation->set_fill_mode(Animation::FillMode::NONE); |
8785 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8821 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8786 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); | 8822 AddAnimationToElementWithPlayer(child->element_id(), timeline(), |
| 8823 std::move(animation)); |
8787 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8824 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8788 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8825 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8789 grandchild->set_visible_layer_rect(gfx::Rect()); | 8826 grandchild->set_visible_layer_rect(gfx::Rect()); |
8790 | 8827 |
8791 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), | 8828 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
8792 animation_id); | 8829 animation_id); |
8793 child->SetTransform(identity); | 8830 child->SetTransform(identity); |
8794 child->SetOpacity(0.f); | 8831 child->SetOpacity(0.f); |
8795 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8832 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8796 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8833 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
8797 | 8834 |
8798 // Now, even though child has zero opacity, we will configure |grandchild| and | 8835 // Now, even though child has zero opacity, we will configure |grandchild| and |
8799 // |greatgrandchild| in several ways that should force the subtree to be | 8836 // |greatgrandchild| in several ways that should force the subtree to be |
8800 // processed anyhow. | 8837 // processed anyhow. |
8801 grandchild->RequestCopyOfOutput( | 8838 grandchild->RequestCopyOfOutput( |
8802 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8839 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
8803 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8840 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8804 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8841 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8805 greatgrandchild->set_visible_layer_rect(gfx::Rect()); | 8842 greatgrandchild->set_visible_layer_rect(gfx::Rect()); |
8806 | 8843 |
8807 // Add an opacity animation with a start delay. | 8844 // Add an opacity animation with a start delay. |
8808 animation_id = 1; | 8845 animation_id = 1; |
8809 animation = Animation::Create( | 8846 animation = Animation::Create( |
8810 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8847 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
8811 animation_id, 1, TargetProperty::OPACITY); | 8848 animation_id, 1, TargetProperty::OPACITY); |
8812 animation->set_fill_mode(Animation::FillMode::NONE); | 8849 animation->set_fill_mode(Animation::FillMode::NONE); |
8813 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8850 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8814 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8851 AddAnimationToElementWithExistingPlayer(child->element_id(), timeline(), |
8815 std::move(animation)); | 8852 std::move(animation)); |
8816 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8853 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
8817 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8854 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
8818 } | 8855 } |
8819 | 8856 |
8820 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { | 8857 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
8821 FakeImplTaskRunnerProvider task_runner_provider; | 8858 FakeImplTaskRunnerProvider task_runner_provider; |
8822 TestSharedBitmapManager shared_bitmap_manager; | 8859 TestSharedBitmapManager shared_bitmap_manager; |
8823 TestTaskGraphRunner task_graph_runner; | 8860 TestTaskGraphRunner task_graph_runner; |
8824 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8861 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
8825 &task_graph_runner); | 8862 &task_graph_runner); |
(...skipping 24 matching lines...) Expand all Loading... |
8850 false); | 8887 false); |
8851 | 8888 |
8852 LayerImpl* root_ptr = root.get(); | 8889 LayerImpl* root_ptr = root.get(); |
8853 LayerImpl* child_ptr = child.get(); | 8890 LayerImpl* child_ptr = child.get(); |
8854 LayerImpl* grandchild_ptr = grandchild.get(); | 8891 LayerImpl* grandchild_ptr = grandchild.get(); |
8855 | 8892 |
8856 child->test_properties()->AddChild(std::move(grandchild)); | 8893 child->test_properties()->AddChild(std::move(grandchild)); |
8857 root->test_properties()->AddChild(std::move(child)); | 8894 root->test_properties()->AddChild(std::move(child)); |
8858 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 8895 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
8859 | 8896 |
| 8897 host_impl.active_tree()->SetElementIdsForTesting(); |
| 8898 |
8860 // Check the non-skipped case. | 8899 // Check the non-skipped case. |
8861 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8900 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8862 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8901 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
8863 | 8902 |
8864 // Now we will reset the visible rect from property trees for the grandchild, | 8903 // Now we will reset the visible rect from property trees for the grandchild, |
8865 // and we will configure |child| in several ways that should force the subtree | 8904 // and we will configure |child| in several ways that should force the subtree |
8866 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8905 // to be skipped. The visible content rect for |grandchild| should, therefore, |
8867 // remain empty. | 8906 // remain empty. |
8868 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8907 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8869 | 8908 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8945 TransformOperations operation; | 8984 TransformOperations operation; |
8946 operation.AppendMatrix(transform); | 8985 operation.AppendMatrix(transform); |
8947 curve->AddKeyframe( | 8986 curve->AddKeyframe( |
8948 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8987 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
8949 curve->AddKeyframe(TransformKeyframe::Create( | 8988 curve->AddKeyframe(TransformKeyframe::Create( |
8950 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8989 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
8951 std::unique_ptr<Animation> transform_animation( | 8990 std::unique_ptr<Animation> transform_animation( |
8952 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8991 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
8953 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8992 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8954 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8993 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
8955 root_ptr->id(), player.get()); | 8994 root_ptr->element_id(), player.get()); |
8956 host_impl.active_tree() | 8995 host_impl.active_tree() |
8957 ->animation_host() | 8996 ->animation_host() |
8958 ->GetElementAnimationsForElementId(root_ptr->id()) | 8997 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
8959 ->AddAnimation(std::move(transform_animation)); | 8998 ->AddAnimation(std::move(transform_animation)); |
8960 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8999 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8961 child_ptr->SetScrollClipLayer(root_ptr->id()); | 9000 child_ptr->SetScrollClipLayer(root_ptr->id()); |
8962 root_ptr->SetTransform(singular); | 9001 root_ptr->SetTransform(singular); |
8963 child_ptr->SetTransform(singular); | 9002 child_ptr->SetTransform(singular); |
8964 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9003 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8965 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9004 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8966 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 9005 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8967 | 9006 |
8968 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 9007 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
8969 root_ptr->id(), player.get()); | 9008 root_ptr->element_id(), player.get()); |
8970 } | 9009 } |
8971 | 9010 |
8972 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 9011 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
8973 LayerImpl* root = root_layer_for_testing(); | 9012 LayerImpl* root = root_layer_for_testing(); |
8974 LayerImpl* child = AddChild<LayerImpl>(root); | 9013 LayerImpl* child = AddChild<LayerImpl>(root); |
8975 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 9014 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
8976 | 9015 |
8977 gfx::Transform identity; | 9016 gfx::Transform identity; |
8978 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 9017 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
8979 gfx::Size(10, 10), true, false, true); | 9018 gfx::Size(10, 10), true, false, true); |
8980 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 9019 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
8981 gfx::Size(10, 10), true, false, false); | 9020 gfx::Size(10, 10), true, false, false); |
8982 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 9021 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
8983 gfx::PointF(), gfx::Size(10, 10), true, false, | 9022 gfx::PointF(), gfx::Size(10, 10), true, false, |
8984 false); | 9023 false); |
| 9024 SetElementIdsForTesting(); |
8985 | 9025 |
8986 gfx::Transform singular; | 9026 gfx::Transform singular; |
8987 singular.matrix().set(0, 0, 0); | 9027 singular.matrix().set(0, 0, 0); |
8988 singular.matrix().set(0, 1, 1); | 9028 singular.matrix().set(0, 1, 1); |
8989 | 9029 |
8990 child->SetTransform(singular); | 9030 child->SetTransform(singular); |
8991 child->SetDrawsContent(true); | 9031 child->SetDrawsContent(true); |
8992 grand_child->SetDrawsContent(true); | 9032 grand_child->SetDrawsContent(true); |
8993 | 9033 |
8994 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 9034 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
8995 KeyframedTransformAnimationCurve::Create()); | 9035 KeyframedTransformAnimationCurve::Create()); |
8996 TransformOperations start; | 9036 TransformOperations start; |
8997 start.AppendTranslate(1.f, 2.f, 3.f); | 9037 start.AppendTranslate(1.f, 2.f, 3.f); |
8998 gfx::Transform transform; | 9038 gfx::Transform transform; |
8999 transform.Scale3d(1.0, 2.0, 3.0); | 9039 transform.Scale3d(1.0, 2.0, 3.0); |
9000 TransformOperations operation; | 9040 TransformOperations operation; |
9001 operation.AppendMatrix(transform); | 9041 operation.AppendMatrix(transform); |
9002 curve->AddKeyframe( | 9042 curve->AddKeyframe( |
9003 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 9043 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
9004 curve->AddKeyframe(TransformKeyframe::Create( | 9044 curve->AddKeyframe(TransformKeyframe::Create( |
9005 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 9045 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
9006 std::unique_ptr<Animation> transform_animation( | 9046 std::unique_ptr<Animation> transform_animation( |
9007 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 9047 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
9008 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9048 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
9009 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( | 9049 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( |
9010 grand_child->id(), player.get()); | 9050 grand_child->element_id(), player.get()); |
9011 host_impl() | 9051 host_impl() |
9012 ->active_tree() | 9052 ->active_tree() |
9013 ->animation_host() | 9053 ->animation_host() |
9014 ->GetElementAnimationsForElementId(grand_child->id()) | 9054 ->GetElementAnimationsForElementId(grand_child->element_id()) |
9015 ->AddAnimation(std::move(transform_animation)); | 9055 ->AddAnimation(std::move(transform_animation)); |
9016 | 9056 |
9017 ExecuteCalculateDrawProperties(root); | 9057 ExecuteCalculateDrawProperties(root); |
9018 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); | 9058 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); |
9019 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 9059 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
9020 | 9060 |
9021 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( | 9061 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( |
9022 grand_child->id(), player.get()); | 9062 grand_child->element_id(), player.get()); |
9023 } | 9063 } |
9024 | 9064 |
9025 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 9065 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
9026 FakeImplTaskRunnerProvider task_runner_provider; | 9066 FakeImplTaskRunnerProvider task_runner_provider; |
9027 TestSharedBitmapManager shared_bitmap_manager; | 9067 TestSharedBitmapManager shared_bitmap_manager; |
9028 TestTaskGraphRunner task_graph_runner; | 9068 TestTaskGraphRunner task_graph_runner; |
9029 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 9069 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
9030 &task_graph_runner); | 9070 &task_graph_runner); |
9031 | 9071 |
9032 gfx::Transform identity; | 9072 gfx::Transform identity; |
(...skipping 22 matching lines...) Expand all Loading... |
9055 gfx::PointF(), gfx::Size(10, 10), true, false, | 9095 gfx::PointF(), gfx::Size(10, 10), true, false, |
9056 false); | 9096 false); |
9057 | 9097 |
9058 LayerImpl* root_ptr = root.get(); | 9098 LayerImpl* root_ptr = root.get(); |
9059 LayerImpl* grandchild_ptr = grandchild.get(); | 9099 LayerImpl* grandchild_ptr = grandchild.get(); |
9060 | 9100 |
9061 child->test_properties()->AddChild(std::move(grandchild)); | 9101 child->test_properties()->AddChild(std::move(grandchild)); |
9062 root->test_properties()->AddChild(std::move(child)); | 9102 root->test_properties()->AddChild(std::move(child)); |
9063 | 9103 |
9064 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | 9104 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
| 9105 host_impl.pending_tree()->SetElementIdsForTesting(); |
9065 | 9106 |
9066 // Check the non-skipped case. | 9107 // Check the non-skipped case. |
9067 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9108 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
9068 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9109 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
9069 | 9110 |
9070 std::unique_ptr<KeyframedFloatAnimationCurve> curve( | 9111 std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
9071 KeyframedFloatAnimationCurve::Create()); | 9112 KeyframedFloatAnimationCurve::Create()); |
9072 std::unique_ptr<TimingFunction> func = | 9113 std::unique_ptr<TimingFunction> func = |
9073 CubicBezierTimingFunction::CreatePreset( | 9114 CubicBezierTimingFunction::CreatePreset( |
9074 CubicBezierTimingFunction::EaseType::EASE); | 9115 CubicBezierTimingFunction::EaseType::EASE); |
9075 curve->AddKeyframe( | 9116 curve->AddKeyframe( |
9076 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); | 9117 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
9077 curve->AddKeyframe( | 9118 curve->AddKeyframe( |
9078 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 9119 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
9079 std::unique_ptr<Animation> animation( | 9120 std::unique_ptr<Animation> animation( |
9080 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 9121 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
9081 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9122 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
9082 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 9123 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
9083 root_ptr->id(), player.get()); | 9124 root_ptr->element_id(), player.get()); |
9084 host_impl.active_tree() | 9125 host_impl.active_tree() |
9085 ->animation_host() | 9126 ->animation_host() |
9086 ->GetElementAnimationsForElementId(root_ptr->id()) | 9127 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
9087 ->AddAnimation(std::move(animation)); | 9128 ->AddAnimation(std::move(animation)); |
9088 root_ptr->test_properties()->opacity = 0.f; | 9129 root_ptr->test_properties()->opacity = 0.f; |
9089 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 9130 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
9090 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9131 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9091 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9132 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
9092 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9133 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
9093 | 9134 |
9094 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 9135 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
9095 root_ptr->id(), player.get()); | 9136 root_ptr->element_id(), player.get()); |
9096 } | 9137 } |
9097 | 9138 |
9098 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 9139 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
9099 gfx::Transform identity; | 9140 gfx::Transform identity; |
9100 LayerImpl* root = root_layer_for_testing(); | 9141 LayerImpl* root = root_layer_for_testing(); |
9101 LayerImpl* child = AddChild<LayerImpl>(root); | 9142 LayerImpl* child = AddChild<LayerImpl>(root); |
9102 | 9143 |
9103 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 9144 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
9104 gfx::Size(100, 100), true, false, true); | 9145 gfx::Size(100, 100), true, false, true); |
9105 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 9146 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10011 | 10052 |
10012 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 10053 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
10013 const gfx::Transform identity_matrix; | 10054 const gfx::Transform identity_matrix; |
10014 scoped_refptr<Layer> root = Layer::Create(); | 10055 scoped_refptr<Layer> root = Layer::Create(); |
10015 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10056 scoped_refptr<LayerWithForcedDrawsContent> animated = |
10016 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10057 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
10017 root->AddChild(animated); | 10058 root->AddChild(animated); |
10018 | 10059 |
10019 host()->SetRootLayer(root); | 10060 host()->SetRootLayer(root); |
10020 | 10061 |
| 10062 host()->SetElementIdsForTesting(); |
| 10063 |
10021 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 10064 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
10022 gfx::PointF(), gfx::Size(100, 100), true, false); | 10065 gfx::PointF(), gfx::Size(100, 100), true, false); |
10023 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 10066 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
10024 gfx::PointF(), gfx::Size(20, 20), true, false); | 10067 gfx::PointF(), gfx::Size(20, 20), true, false); |
10025 | 10068 |
10026 root->SetForceRenderSurfaceForTesting(true); | 10069 root->SetForceRenderSurfaceForTesting(true); |
10027 animated->SetOpacity(0.f); | 10070 animated->SetOpacity(0.f); |
10028 | 10071 |
10029 scoped_refptr<AnimationPlayer> player = | 10072 scoped_refptr<AnimationPlayer> player = |
10030 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 10073 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
10031 timeline()->AttachPlayer(player); | 10074 timeline()->AttachPlayer(player); |
10032 player->AttachElement(animated->id()); | 10075 |
| 10076 player->AttachElement(animated->element_id()); |
10033 | 10077 |
10034 int animation_id = 0; | 10078 int animation_id = 0; |
10035 std::unique_ptr<Animation> animation = Animation::Create( | 10079 std::unique_ptr<Animation> animation = Animation::Create( |
10036 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 10080 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
10037 animation_id, 1, TargetProperty::OPACITY); | 10081 animation_id, 1, TargetProperty::OPACITY); |
10038 animation->set_fill_mode(Animation::FillMode::NONE); | 10082 animation->set_fill_mode(Animation::FillMode::NONE); |
10039 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 10083 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
10040 Animation* animation_ptr = animation.get(); | 10084 Animation* animation_ptr = animation.get(); |
10041 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), | 10085 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
10042 std::move(animation)); | 10086 std::move(animation)); |
10043 | 10087 |
10044 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 10088 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
10045 | 10089 |
10046 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; | 10090 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; |
10047 EffectNode* node = tree.Node(animated->effect_tree_index()); | 10091 EffectNode* node = tree.Node(animated->effect_tree_index()); |
10048 EXPECT_FALSE(node->data.is_currently_animating_opacity); | 10092 EXPECT_FALSE(node->data.is_currently_animating_opacity); |
10049 EXPECT_TRUE(node->data.has_potential_opacity_animation); | 10093 EXPECT_TRUE(node->data.has_potential_opacity_animation); |
10050 | 10094 |
10051 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 10095 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
10052 root->layer_tree_host()->AnimateLayers( | 10096 root->layer_tree_host()->AnimateLayers( |
(...skipping 10 matching lines...) Expand all Loading... |
10063 | 10107 |
10064 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 10108 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
10065 const gfx::Transform identity_matrix; | 10109 const gfx::Transform identity_matrix; |
10066 scoped_refptr<Layer> root = Layer::Create(); | 10110 scoped_refptr<Layer> root = Layer::Create(); |
10067 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10111 scoped_refptr<LayerWithForcedDrawsContent> animated = |
10068 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10112 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
10069 root->AddChild(animated); | 10113 root->AddChild(animated); |
10070 | 10114 |
10071 host()->SetRootLayer(root); | 10115 host()->SetRootLayer(root); |
10072 | 10116 |
| 10117 host()->SetElementIdsForTesting(); |
| 10118 |
10073 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 10119 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
10074 gfx::PointF(), gfx::Size(100, 100), true, false); | 10120 gfx::PointF(), gfx::Size(100, 100), true, false); |
10075 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 10121 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
10076 gfx::PointF(), gfx::Size(20, 20), true, false); | 10122 gfx::PointF(), gfx::Size(20, 20), true, false); |
10077 | 10123 |
10078 root->SetForceRenderSurfaceForTesting(true); | 10124 root->SetForceRenderSurfaceForTesting(true); |
10079 | 10125 |
10080 scoped_refptr<AnimationPlayer> player = | 10126 scoped_refptr<AnimationPlayer> player = |
10081 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 10127 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
10082 timeline()->AttachPlayer(player); | 10128 timeline()->AttachPlayer(player); |
10083 player->AttachElement(animated->id()); | 10129 player->AttachElement(animated->element_id()); |
10084 | 10130 |
10085 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 10131 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
10086 KeyframedTransformAnimationCurve::Create()); | 10132 KeyframedTransformAnimationCurve::Create()); |
10087 TransformOperations start; | 10133 TransformOperations start; |
10088 start.AppendTranslate(1.f, 2.f, 3.f); | 10134 start.AppendTranslate(1.f, 2.f, 3.f); |
10089 gfx::Transform transform; | 10135 gfx::Transform transform; |
10090 transform.Scale3d(1.0, 2.0, 3.0); | 10136 transform.Scale3d(1.0, 2.0, 3.0); |
10091 TransformOperations operation; | 10137 TransformOperations operation; |
10092 operation.AppendMatrix(transform); | 10138 operation.AppendMatrix(transform); |
10093 curve->AddKeyframe( | 10139 curve->AddKeyframe( |
10094 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 10140 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
10095 curve->AddKeyframe(TransformKeyframe::Create( | 10141 curve->AddKeyframe(TransformKeyframe::Create( |
10096 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 10142 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
10097 std::unique_ptr<Animation> animation( | 10143 std::unique_ptr<Animation> animation( |
10098 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 10144 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
10099 animation->set_fill_mode(Animation::FillMode::NONE); | 10145 animation->set_fill_mode(Animation::FillMode::NONE); |
10100 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 10146 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
10101 Animation* animation_ptr = animation.get(); | 10147 Animation* animation_ptr = animation.get(); |
10102 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), | 10148 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), |
10103 std::move(animation)); | 10149 std::move(animation)); |
10104 | 10150 |
10105 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 10151 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
10106 | 10152 |
10107 TransformTree& tree = | 10153 TransformTree& tree = |
10108 root->layer_tree_host()->property_trees()->transform_tree; | 10154 root->layer_tree_host()->property_trees()->transform_tree; |
10109 TransformNode* node = tree.Node(animated->transform_tree_index()); | 10155 TransformNode* node = tree.Node(animated->transform_tree_index()); |
10110 EXPECT_FALSE(node->data.is_currently_animating); | 10156 EXPECT_FALSE(node->data.is_currently_animating); |
10111 EXPECT_TRUE(node->data.has_potential_animation); | 10157 EXPECT_TRUE(node->data.has_potential_animation); |
10112 | 10158 |
10113 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 10159 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10349 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10395 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10350 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10396 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10351 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10397 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10352 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10398 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10353 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10399 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10354 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10400 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10355 } | 10401 } |
10356 | 10402 |
10357 } // namespace | 10403 } // namespace |
10358 } // namespace cc | 10404 } // namespace cc |
OLD | NEW |