| 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 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2657 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2658 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2658 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2659 SetLayerPropertiesForTesting( | 2659 SetLayerPropertiesForTesting( |
| 2660 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2660 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2661 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2661 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2662 SetLayerPropertiesForTesting( | 2662 SetLayerPropertiesForTesting( |
| 2663 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2663 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
| 2664 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2664 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
| 2665 | 2665 |
| 2666 parent->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); | 2666 parent->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
| 2667 SetElementIdsForTesting(); | |
| 2668 | 2667 |
| 2669 // Put an animated opacity on the render surface. | 2668 // Put an animated opacity on the render surface. |
| 2670 AddOpacityTransitionToElementWithPlayer( | 2669 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), |
| 2671 render_surface1->element_id(), timeline_impl(), 10.0, 1.f, 0.f, false); | 2670 10.0, 1.f, 0.f, false); |
| 2672 | 2671 |
| 2673 // Also put an animated opacity on a layer without descendants. | 2672 // Also put an animated opacity on a layer without descendants. |
| 2674 AddOpacityTransitionToElementWithPlayer(grand_child_of_root->element_id(), | 2673 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), |
| 2675 timeline_impl(), 10.0, 1.f, 0.f, | 2674 timeline_impl(), 10.0, 1.f, 0.f, false); |
| 2676 false); | |
| 2677 | 2675 |
| 2678 // Put a transform animation on the render surface. | 2676 // Put a transform animation on the render surface. |
| 2679 AddAnimatedTransformToElementWithPlayer(render_surface2->element_id(), | 2677 AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(), |
| 2680 timeline_impl(), 10.0, 30, 0); | 2678 10.0, 30, 0); |
| 2681 | 2679 |
| 2682 // Also put transform animations on grand_child_of_root, and | 2680 // Also put transform animations on grand_child_of_root, and |
| 2683 // grand_child_of_rs2 | 2681 // grand_child_of_rs2 |
| 2684 AddAnimatedTransformToElementWithPlayer(grand_child_of_root->element_id(), | 2682 AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), |
| 2685 timeline_impl(), 10.0, 30, 0); | 2683 timeline_impl(), 10.0, 30, 0); |
| 2686 AddAnimatedTransformToElementWithPlayer(grand_child_of_rs2->element_id(), | 2684 AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), |
| 2687 timeline_impl(), 10.0, 30, 0); | 2685 timeline_impl(), 10.0, 30, 0); |
| 2688 | 2686 |
| 2689 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; | 2687 parent->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 2690 ExecuteCalculateDrawProperties(parent); | 2688 ExecuteCalculateDrawProperties(parent); |
| 2691 | 2689 |
| 2692 // Only layers that are associated with render surfaces should have an actual | 2690 // Only layers that are associated with render surfaces should have an actual |
| 2693 // RenderSurface() value. | 2691 // RenderSurface() value. |
| 2694 ASSERT_TRUE(parent->render_surface()); | 2692 ASSERT_TRUE(parent->render_surface()); |
| 2695 ASSERT_FALSE(child_of_root->render_surface()); | 2693 ASSERT_FALSE(child_of_root->render_surface()); |
| 2696 ASSERT_FALSE(grand_child_of_root->render_surface()); | 2694 ASSERT_FALSE(grand_child_of_root->render_surface()); |
| 2697 | 2695 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 gfx::Size(10, 10), true, false, true); | 2794 gfx::Size(10, 10), true, false, true); |
| 2797 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 2795 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
| 2798 gfx::Size(10, 10), true, false, false); | 2796 gfx::Size(10, 10), true, false, false); |
| 2799 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 2797 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
| 2800 gfx::PointF(), gfx::Size(10, 10), true, false, | 2798 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 2801 false); | 2799 false); |
| 2802 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), | 2800 SetLayerPropertiesForTesting(great_grand_child, identity, gfx::Point3F(), |
| 2803 gfx::PointF(), gfx::Size(10, 10), true, false, | 2801 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 2804 false); | 2802 false); |
| 2805 | 2803 |
| 2806 SetElementIdsForTesting(); | |
| 2807 | |
| 2808 // Add a transform animation with a start delay to |grand_child|. | 2804 // Add a transform animation with a start delay to |grand_child|. |
| 2809 std::unique_ptr<Animation> animation = Animation::Create( | 2805 std::unique_ptr<Animation> animation = Animation::Create( |
| 2810 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, | 2806 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, |
| 2811 TargetProperty::TRANSFORM); | 2807 TargetProperty::TRANSFORM); |
| 2812 animation->set_fill_mode(Animation::FillMode::NONE); | 2808 animation->set_fill_mode(Animation::FillMode::NONE); |
| 2813 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 2809 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 2814 AddAnimationToElementWithPlayer(grand_child->element_id(), timeline_impl(), | 2810 AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), |
| 2815 std::move(animation)); | 2811 std::move(animation)); |
| 2816 ExecuteCalculateDrawProperties(parent); | 2812 ExecuteCalculateDrawProperties(parent); |
| 2817 | 2813 |
| 2818 EXPECT_FALSE(parent->screen_space_transform_is_animating()); | 2814 EXPECT_FALSE(parent->screen_space_transform_is_animating()); |
| 2819 EXPECT_FALSE(child->screen_space_transform_is_animating()); | 2815 EXPECT_FALSE(child->screen_space_transform_is_animating()); |
| 2820 | 2816 |
| 2821 EXPECT_FALSE(grand_child->TransformIsAnimating()); | 2817 EXPECT_FALSE(grand_child->TransformIsAnimating()); |
| 2822 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); | 2818 EXPECT_TRUE(grand_child->HasPotentiallyRunningTransformAnimation()); |
| 2823 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); | 2819 EXPECT_TRUE(grand_child->screen_space_transform_is_animating()); |
| 2824 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); | 2820 EXPECT_TRUE(great_grand_child->screen_space_transform_is_animating()); |
| 2825 } | 2821 } |
| (...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4526 child2->SetDrawsContent(true); | 4522 child2->SetDrawsContent(true); |
| 4527 animating_surface->SetDrawsContent(true); | 4523 animating_surface->SetDrawsContent(true); |
| 4528 child_of_animating_surface->SetDrawsContent(true); | 4524 child_of_animating_surface->SetDrawsContent(true); |
| 4529 animating_child->SetDrawsContent(true); | 4525 animating_child->SetDrawsContent(true); |
| 4530 | 4526 |
| 4531 gfx::Transform backface_matrix; | 4527 gfx::Transform backface_matrix; |
| 4532 backface_matrix.Translate(50.0, 50.0); | 4528 backface_matrix.Translate(50.0, 50.0); |
| 4533 backface_matrix.RotateAboutYAxis(180.0); | 4529 backface_matrix.RotateAboutYAxis(180.0); |
| 4534 backface_matrix.Translate(-50.0, -50.0); | 4530 backface_matrix.Translate(-50.0, -50.0); |
| 4535 | 4531 |
| 4536 SetElementIdsForTesting(); | |
| 4537 | |
| 4538 // Animate the transform on the render surface. | 4532 // Animate the transform on the render surface. |
| 4539 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), | 4533 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), |
| 4540 timeline_impl(), 10.0, 30, 0); | 4534 timeline_impl(), 10.0, 30, 0); |
| 4541 // This is just an animating layer, not a surface. | 4535 // This is just an animating layer, not a surface. |
| 4542 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), | 4536 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline_impl(), |
| 4543 timeline_impl(), 10.0, 30, 0); | 4537 10.0, 30, 0); |
| 4544 | 4538 |
| 4545 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 4539 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 4546 gfx::PointF(), gfx::Size(100, 100), true, false); | 4540 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 4547 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), | 4541 SetLayerPropertiesForTesting(child, backface_matrix, gfx::Point3F(), |
| 4548 gfx::PointF(), gfx::Size(100, 100), true, false); | 4542 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 4549 SetLayerPropertiesForTesting(animating_surface, backface_matrix, | 4543 SetLayerPropertiesForTesting(animating_surface, backface_matrix, |
| 4550 gfx::Point3F(), gfx::PointF(), | 4544 gfx::Point3F(), gfx::PointF(), |
| 4551 gfx::Size(100, 100), true, false, true); | 4545 gfx::Size(100, 100), true, false, true); |
| 4552 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, | 4546 SetLayerPropertiesForTesting(child_of_animating_surface, backface_matrix, |
| 4553 gfx::Point3F(), gfx::PointF(), | 4547 gfx::Point3F(), gfx::PointF(), |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5145 false); | 5139 false); |
| 5146 child->SetDrawsContent(true); | 5140 child->SetDrawsContent(true); |
| 5147 child->test_properties()->opacity = 0.0f; | 5141 child->test_properties()->opacity = 0.0f; |
| 5148 | 5142 |
| 5149 const int child_id = child->id(); | 5143 const int child_id = child->id(); |
| 5150 root->AddChild(std::move(child)); | 5144 root->AddChild(std::move(child)); |
| 5151 root->SetHasRenderSurface(true); | 5145 root->SetHasRenderSurface(true); |
| 5152 LayerImpl* root_layer = root.get(); | 5146 LayerImpl* root_layer = root.get(); |
| 5153 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5147 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 5154 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 5148 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 5155 | |
| 5156 // Add opacity animation. | 5149 // Add opacity animation. |
| 5157 scoped_refptr<AnimationTimeline> timeline = | 5150 scoped_refptr<AnimationTimeline> timeline = |
| 5158 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5151 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 5159 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5152 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 5160 host_impl.pending_tree()->SetElementIdsForTesting(); | |
| 5161 | 5153 |
| 5162 ElementId child_element_id = | 5154 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, |
| 5163 host_impl.pending_tree()->LayerById(child_id)->element_id(); | 5155 false); |
| 5164 | |
| 5165 AddOpacityTransitionToElementWithPlayer(child_element_id, timeline, 10.0, | |
| 5166 0.0f, 1.0f, false); | |
| 5167 | 5156 |
| 5168 LayerImplList render_surface_layer_list; | 5157 LayerImplList render_surface_layer_list; |
| 5169 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5158 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5170 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5159 root_layer, root_layer->bounds(), &render_surface_layer_list); |
| 5171 inputs.can_adjust_raster_scales = true; | 5160 inputs.can_adjust_raster_scales = true; |
| 5172 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5161 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5173 | 5162 |
| 5174 // We should have one render surface and two layers. The child | 5163 // We should have one render surface and two layers. The child |
| 5175 // layer should be included even though it is transparent. | 5164 // layer should be included even though it is transparent. |
| 5176 ASSERT_EQ(1u, render_surface_layer_list.size()); | 5165 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5268 | 5257 |
| 5269 // Stash raw pointers to look at later. | 5258 // Stash raw pointers to look at later. |
| 5270 root_ = root_ptr.get(); | 5259 root_ = root_ptr.get(); |
| 5271 child_ = child_ptr.get(); | 5260 child_ = child_ptr.get(); |
| 5272 grand_child_ = grand_child_ptr.get(); | 5261 grand_child_ = grand_child_ptr.get(); |
| 5273 | 5262 |
| 5274 child_->AddChild(std::move(grand_child_ptr)); | 5263 child_->AddChild(std::move(grand_child_ptr)); |
| 5275 root_->AddChild(std::move(child_ptr)); | 5264 root_->AddChild(std::move(child_ptr)); |
| 5276 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); | 5265 host_impl_.active_tree()->SetRootLayer(std::move(root_ptr)); |
| 5277 | 5266 |
| 5278 host_impl_.active_tree()->SetElementIdsForTesting(); | |
| 5279 | |
| 5280 root_->SetContentsOpaque(true); | 5267 root_->SetContentsOpaque(true); |
| 5281 child_->SetContentsOpaque(true); | 5268 child_->SetContentsOpaque(true); |
| 5282 grand_child_->SetContentsOpaque(true); | 5269 grand_child_->SetContentsOpaque(true); |
| 5283 | 5270 |
| 5284 root_->SetDrawsContent(true); | 5271 root_->SetDrawsContent(true); |
| 5285 child_->SetDrawsContent(true); | 5272 child_->SetDrawsContent(true); |
| 5286 grand_child_->SetDrawsContent(true); | 5273 grand_child_->SetDrawsContent(true); |
| 5287 | 5274 |
| 5288 gfx::Transform identity_matrix; | 5275 gfx::Transform identity_matrix; |
| 5289 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), | 5276 SetLayerPropertiesForTesting(root_, identity_matrix, gfx::Point3F(), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5411 | 5398 |
| 5412 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5399 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 5413 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5400 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 5414 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5401 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5415 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5402 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 5416 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5403 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5417 | 5404 |
| 5418 // Add opacity animation. | 5405 // Add opacity animation. |
| 5419 child_->test_properties()->opacity = 0.9f; | 5406 child_->test_properties()->opacity = 0.9f; |
| 5420 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5407 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5421 | 5408 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, |
| 5422 SetElementIdsForTesting(); | 5409 0.1f, false); |
| 5423 | |
| 5424 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), | |
| 5425 10.0, 0.9f, 0.1f, false); | |
| 5426 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5410 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 5427 // Text LCD should be adjusted while animation is active. | 5411 // Text LCD should be adjusted while animation is active. |
| 5428 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5412 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5429 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5413 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5430 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5414 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5431 } | 5415 } |
| 5432 | 5416 |
| 5433 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { | 5417 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { |
| 5434 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 5418 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
| 5435 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 5419 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
| 5436 | 5420 |
| 5437 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5421 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 5438 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5422 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 5439 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5423 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5440 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5424 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 5441 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5425 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5442 SetElementIdsForTesting(); | |
| 5443 | 5426 |
| 5444 // Mark contents non-opaque within the first animation frame. | 5427 // Mark contents non-opaque within the first animation frame. |
| 5445 child_->SetContentsOpaque(false); | 5428 child_->SetContentsOpaque(false); |
| 5446 AddOpacityTransitionToElementWithPlayer(child_->element_id(), timeline(), | 5429 AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, |
| 5447 10.0, 0.9f, 0.1f, false); | 5430 0.1f, false); |
| 5448 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 5431 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 5449 // LCD text should be disabled for non-opaque layers even during animations. | 5432 // LCD text should be disabled for non-opaque layers even during animations. |
| 5450 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5433 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5451 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5434 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5452 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5435 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5453 } | 5436 } |
| 5454 | 5437 |
| 5455 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5438 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5456 LCDTextTest, | 5439 LCDTextTest, |
| 5457 testing::Combine(testing::Bool(), | 5440 testing::Combine(testing::Bool(), |
| (...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7202 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), | 7185 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), |
| 7203 gfx::PointF(), gfx::Size(100, 100), true, false, | 7186 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 7204 false); | 7187 false); |
| 7205 | 7188 |
| 7206 gfx::Transform end_scale; | 7189 gfx::Transform end_scale; |
| 7207 end_scale.Scale(2.f, 2.f); | 7190 end_scale.Scale(2.f, 2.f); |
| 7208 TransformOperations start_operations; | 7191 TransformOperations start_operations; |
| 7209 start_operations.AppendMatrix(start_scale); | 7192 start_operations.AppendMatrix(start_scale); |
| 7210 TransformOperations end_operations; | 7193 TransformOperations end_operations; |
| 7211 end_operations.AppendMatrix(end_scale); | 7194 end_operations.AppendMatrix(end_scale); |
| 7212 SetElementIdsForTesting(); | 7195 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), |
| 7213 | 7196 1.0, start_operations, end_operations); |
| 7214 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), | |
| 7215 timeline_impl(), 1.0, | |
| 7216 start_operations, end_operations); | |
| 7217 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7197 gfx::Vector2dF scroll_delta(5.f, 9.f); |
| 7218 SetScrollOffsetDelta(scroller, scroll_delta); | 7198 SetScrollOffsetDelta(scroller, scroll_delta); |
| 7219 | 7199 |
| 7220 ExecuteCalculateDrawProperties(root); | 7200 ExecuteCalculateDrawProperties(root); |
| 7221 | 7201 |
| 7222 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7202 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
| 7223 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7203 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
| 7224 scroller->DrawTransform().To2dTranslation()); | 7204 scroller->DrawTransform().To2dTranslation()); |
| 7225 } | 7205 } |
| 7226 | 7206 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7309 0.f, | 7289 0.f, |
| 7310 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7290 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7311 | 7291 |
| 7312 TransformOperations translation; | 7292 TransformOperations translation; |
| 7313 translation.AppendTranslate(1.f, 2.f, 3.f); | 7293 translation.AppendTranslate(1.f, 2.f, 3.f); |
| 7314 | 7294 |
| 7315 scoped_refptr<AnimationTimeline> timeline; | 7295 scoped_refptr<AnimationTimeline> timeline; |
| 7316 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7296 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7317 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7297 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7318 | 7298 |
| 7319 host_impl.active_tree()->SetElementIdsForTesting(); | 7299 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7320 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, | 7300 TransformOperations(), translation); |
| 7321 1.0, TransformOperations(), | |
| 7322 translation); | |
| 7323 | 7301 |
| 7324 // No layers have scale-affecting animations. | 7302 // No layers have scale-affecting animations. |
| 7325 EXPECT_EQ( | 7303 EXPECT_EQ( |
| 7326 0.f, | 7304 0.f, |
| 7327 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7305 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7328 EXPECT_EQ(0.f, | 7306 EXPECT_EQ(0.f, |
| 7329 parent_raw->draw_properties().maximum_animation_contents_scale); | 7307 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7330 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); |
| 7331 EXPECT_EQ( | 7309 EXPECT_EQ( |
| 7332 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7310 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7333 | 7311 |
| 7334 EXPECT_EQ( | 7312 EXPECT_EQ( |
| 7335 0.f, | 7313 0.f, |
| 7336 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7314 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7337 EXPECT_EQ(0.f, | 7315 EXPECT_EQ(0.f, |
| 7338 parent_raw->draw_properties().starting_animation_contents_scale); | 7316 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7339 EXPECT_EQ(0.f, | 7317 EXPECT_EQ(0.f, |
| 7340 child_raw->draw_properties().starting_animation_contents_scale); | 7318 child_raw->draw_properties().starting_animation_contents_scale); |
| 7341 EXPECT_EQ( | 7319 EXPECT_EQ( |
| 7342 0.f, | 7320 0.f, |
| 7343 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7321 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7344 | 7322 |
| 7345 TransformOperations scale; | 7323 TransformOperations scale; |
| 7346 scale.AppendScale(5.f, 4.f, 3.f); | 7324 scale.AppendScale(5.f, 4.f, 3.f); |
| 7347 | 7325 |
| 7348 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, | 7326 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
| 7349 1.0, TransformOperations(), scale); | 7327 TransformOperations(), scale); |
| 7350 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7328 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7351 ExecuteCalculateDrawProperties(grand_parent_raw); | 7329 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7352 | 7330 |
| 7353 // Only |child| has a scale-affecting animation. | 7331 // Only |child| has a scale-affecting animation. |
| 7354 EXPECT_EQ( | 7332 EXPECT_EQ( |
| 7355 0.f, | 7333 0.f, |
| 7356 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7334 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7357 EXPECT_EQ(0.f, | 7335 EXPECT_EQ(0.f, |
| 7358 parent_raw->draw_properties().maximum_animation_contents_scale); | 7336 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7359 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7337 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7360 EXPECT_EQ( | 7338 EXPECT_EQ( |
| 7361 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7339 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7362 | 7340 |
| 7363 EXPECT_EQ( | 7341 EXPECT_EQ( |
| 7364 0.f, | 7342 0.f, |
| 7365 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7343 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7366 EXPECT_EQ(0.f, | 7344 EXPECT_EQ(0.f, |
| 7367 parent_raw->draw_properties().starting_animation_contents_scale); | 7345 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7368 EXPECT_EQ(1.f, | 7346 EXPECT_EQ(1.f, |
| 7369 child_raw->draw_properties().starting_animation_contents_scale); | 7347 child_raw->draw_properties().starting_animation_contents_scale); |
| 7370 EXPECT_EQ( | 7348 EXPECT_EQ( |
| 7371 1.f, | 7349 1.f, |
| 7372 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7350 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7373 | 7351 |
| 7374 AddAnimatedTransformToElementWithPlayer(grand_parent_raw->element_id(), | 7352 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, |
| 7375 timeline, 1.0, TransformOperations(), | 7353 TransformOperations(), scale); |
| 7376 scale); | |
| 7377 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7354 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7378 ExecuteCalculateDrawProperties(grand_parent_raw); | 7355 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7379 | 7356 |
| 7380 // |grand_parent| and |child| have scale-affecting animations. | 7357 // |grand_parent| and |child| have scale-affecting animations. |
| 7381 EXPECT_EQ( | 7358 EXPECT_EQ( |
| 7382 5.f, | 7359 5.f, |
| 7383 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7360 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7384 EXPECT_EQ(5.f, | 7361 EXPECT_EQ(5.f, |
| 7385 parent_raw->draw_properties().maximum_animation_contents_scale); | 7362 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7386 // We don't support combining animated scales from two nodes; 0.f means | 7363 // We don't support combining animated scales from two nodes; 0.f means |
| 7387 // that the maximum scale could not be computed. | 7364 // that the maximum scale could not be computed. |
| 7388 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7365 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7389 EXPECT_EQ( | 7366 EXPECT_EQ( |
| 7390 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7367 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7391 | 7368 |
| 7392 EXPECT_EQ( | 7369 EXPECT_EQ( |
| 7393 1.f, | 7370 1.f, |
| 7394 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7371 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7395 EXPECT_EQ(1.f, | 7372 EXPECT_EQ(1.f, |
| 7396 parent_raw->draw_properties().starting_animation_contents_scale); | 7373 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7397 EXPECT_EQ(0.f, | 7374 EXPECT_EQ(0.f, |
| 7398 child_raw->draw_properties().starting_animation_contents_scale); | 7375 child_raw->draw_properties().starting_animation_contents_scale); |
| 7399 EXPECT_EQ( | 7376 EXPECT_EQ( |
| 7400 0.f, | 7377 0.f, |
| 7401 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7378 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7402 | 7379 |
| 7403 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, | 7380 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7404 1.0, TransformOperations(), scale); | 7381 TransformOperations(), scale); |
| 7405 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7382 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7406 ExecuteCalculateDrawProperties(grand_parent_raw); | 7383 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7407 | 7384 |
| 7408 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7385 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
| 7409 EXPECT_EQ( | 7386 EXPECT_EQ( |
| 7410 5.f, | 7387 5.f, |
| 7411 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7388 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7412 EXPECT_EQ(0.f, | 7389 EXPECT_EQ(0.f, |
| 7413 parent_raw->draw_properties().maximum_animation_contents_scale); | 7390 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7414 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7391 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7415 EXPECT_EQ( | 7392 EXPECT_EQ( |
| 7416 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7393 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7417 | 7394 |
| 7418 EXPECT_EQ( | 7395 EXPECT_EQ( |
| 7419 1.f, | 7396 1.f, |
| 7420 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7397 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7421 EXPECT_EQ(0.f, | 7398 EXPECT_EQ(0.f, |
| 7422 parent_raw->draw_properties().starting_animation_contents_scale); | 7399 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7423 EXPECT_EQ(0.f, | 7400 EXPECT_EQ(0.f, |
| 7424 child_raw->draw_properties().starting_animation_contents_scale); | 7401 child_raw->draw_properties().starting_animation_contents_scale); |
| 7425 EXPECT_EQ( | 7402 EXPECT_EQ( |
| 7426 0.f, | 7403 0.f, |
| 7427 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7404 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7428 | 7405 |
| 7429 AbortAnimationsOnElementWithPlayer(grand_parent_raw->element_id(), timeline, | 7406 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, |
| 7430 TargetProperty::TRANSFORM); | 7407 TargetProperty::TRANSFORM); |
| 7431 AbortAnimationsOnElementWithPlayer(parent_raw->element_id(), timeline, | 7408 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, |
| 7432 TargetProperty::TRANSFORM); | 7409 TargetProperty::TRANSFORM); |
| 7433 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, | 7410 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
| 7434 TargetProperty::TRANSFORM); | 7411 TargetProperty::TRANSFORM); |
| 7435 | 7412 |
| 7436 TransformOperations perspective; | 7413 TransformOperations perspective; |
| 7437 perspective.AppendPerspective(10.f); | 7414 perspective.AppendPerspective(10.f); |
| 7438 | 7415 |
| 7439 AddAnimatedTransformToElementWithPlayer(child_raw->element_id(), timeline, | 7416 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
| 7440 1.0, TransformOperations(), | 7417 TransformOperations(), perspective); |
| 7441 perspective); | |
| 7442 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7418 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7443 ExecuteCalculateDrawProperties(grand_parent_raw); | 7419 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7444 | 7420 |
| 7445 // |child| has a scale-affecting animation but computing the maximum of this | 7421 // |child| has a scale-affecting animation but computing the maximum of this |
| 7446 // animation is not supported. | 7422 // animation is not supported. |
| 7447 EXPECT_EQ( | 7423 EXPECT_EQ( |
| 7448 0.f, | 7424 0.f, |
| 7449 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7425 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7450 EXPECT_EQ(0.f, | 7426 EXPECT_EQ(0.f, |
| 7451 parent_raw->draw_properties().maximum_animation_contents_scale); | 7427 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7452 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7428 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); |
| 7453 EXPECT_EQ( | 7429 EXPECT_EQ( |
| 7454 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | 7430 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); |
| 7455 | 7431 |
| 7456 EXPECT_EQ( | 7432 EXPECT_EQ( |
| 7457 0.f, | 7433 0.f, |
| 7458 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7434 grand_parent_raw->draw_properties().starting_animation_contents_scale); |
| 7459 EXPECT_EQ(0.f, | 7435 EXPECT_EQ(0.f, |
| 7460 parent_raw->draw_properties().starting_animation_contents_scale); | 7436 parent_raw->draw_properties().starting_animation_contents_scale); |
| 7461 EXPECT_EQ(0.f, | 7437 EXPECT_EQ(0.f, |
| 7462 child_raw->draw_properties().starting_animation_contents_scale); | 7438 child_raw->draw_properties().starting_animation_contents_scale); |
| 7463 EXPECT_EQ( | 7439 EXPECT_EQ( |
| 7464 0.f, | 7440 0.f, |
| 7465 grand_child_raw->draw_properties().starting_animation_contents_scale); | 7441 grand_child_raw->draw_properties().starting_animation_contents_scale); |
| 7466 | 7442 |
| 7467 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, | 7443 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
| 7468 TargetProperty::TRANSFORM); | 7444 TargetProperty::TRANSFORM); |
| 7469 gfx::Transform scale_matrix; | 7445 gfx::Transform scale_matrix; |
| 7470 scale_matrix.Scale(1.f, 2.f); | 7446 scale_matrix.Scale(1.f, 2.f); |
| 7471 grand_parent_raw->SetTransform(scale_matrix); | 7447 grand_parent_raw->SetTransform(scale_matrix); |
| 7472 parent_raw->SetTransform(scale_matrix); | 7448 parent_raw->SetTransform(scale_matrix); |
| 7473 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7449 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7474 | 7450 |
| 7475 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, | 7451 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7476 1.0, TransformOperations(), scale); | 7452 TransformOperations(), scale); |
| 7477 ExecuteCalculateDrawProperties(grand_parent_raw); | 7453 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7478 | 7454 |
| 7479 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7455 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
| 7480 // animation with maximum scale 5.f. | 7456 // animation with maximum scale 5.f. |
| 7481 EXPECT_EQ( | 7457 EXPECT_EQ( |
| 7482 0.f, | 7458 0.f, |
| 7483 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7459 grand_parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7484 EXPECT_EQ(10.f, | 7460 EXPECT_EQ(10.f, |
| 7485 parent_raw->draw_properties().maximum_animation_contents_scale); | 7461 parent_raw->draw_properties().maximum_animation_contents_scale); |
| 7486 EXPECT_EQ(10.f, | 7462 EXPECT_EQ(10.f, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7869 std::unique_ptr<LayerImpl> child2 = | 7845 std::unique_ptr<LayerImpl> child2 = |
| 7870 LayerImpl::Create(host_impl.active_tree(), 3); | 7846 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7871 LayerImpl* child2_layer = child2.get(); | 7847 LayerImpl* child2_layer = child2.get(); |
| 7872 | 7848 |
| 7873 root->AddChild(std::move(child1)); | 7849 root->AddChild(std::move(child1)); |
| 7874 root->AddChild(std::move(child2)); | 7850 root->AddChild(std::move(child2)); |
| 7875 root->test_properties()->force_render_surface = true; | 7851 root->test_properties()->force_render_surface = true; |
| 7876 root->SetDrawsContent(true); | 7852 root->SetDrawsContent(true); |
| 7877 host_impl.active_tree()->SetRootLayer(std::move(root)); | 7853 host_impl.active_tree()->SetRootLayer(std::move(root)); |
| 7878 | 7854 |
| 7879 host_impl.active_tree()->SetElementIdsForTesting(); | |
| 7880 | |
| 7881 gfx::Transform identity_matrix, scale_transform_child1, | 7855 gfx::Transform identity_matrix, scale_transform_child1, |
| 7882 scale_transform_child2; | 7856 scale_transform_child2; |
| 7883 scale_transform_child1.Scale(2, 3); | 7857 scale_transform_child1.Scale(2, 3); |
| 7884 scale_transform_child2.Scale(4, 5); | 7858 scale_transform_child2.Scale(4, 5); |
| 7885 | 7859 |
| 7886 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7860 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), |
| 7887 gfx::PointF(), gfx::Size(1, 1), true, false, | 7861 gfx::PointF(), gfx::Size(1, 1), true, false, |
| 7888 true); | 7862 true); |
| 7889 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7863 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, |
| 7890 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7864 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7901 | 7875 |
| 7902 ExecuteCalculateDrawProperties(root_layer); | 7876 ExecuteCalculateDrawProperties(root_layer); |
| 7903 | 7877 |
| 7904 TransformOperations scale; | 7878 TransformOperations scale; |
| 7905 scale.AppendScale(5.f, 8.f, 3.f); | 7879 scale.AppendScale(5.f, 8.f, 3.f); |
| 7906 | 7880 |
| 7907 scoped_refptr<AnimationTimeline> timeline = | 7881 scoped_refptr<AnimationTimeline> timeline = |
| 7908 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7882 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7909 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7883 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7910 | 7884 |
| 7885 AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, |
| 7886 TransformOperations(), scale); |
| 7887 |
| 7911 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 7888 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, |
| 7912 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7889 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), |
| 7913 true, false, false); | 7890 true, false, false); |
| 7914 child2_layer->SetDrawsContent(true); | 7891 child2_layer->SetDrawsContent(true); |
| 7915 | 7892 |
| 7916 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | |
| 7917 1.0, TransformOperations(), scale); | |
| 7918 | |
| 7919 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7893 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7920 ExecuteCalculateDrawProperties(root_layer); | 7894 ExecuteCalculateDrawProperties(root_layer); |
| 7921 | 7895 |
| 7922 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7896 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
| 7923 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7897 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
| 7924 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); | 7898 EXPECT_FLOAT_EQ(3.f, child1_layer->mask_layer()->GetIdealContentsScale()); |
| 7925 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); | 7899 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); |
| 7926 | 7900 |
| 7927 EXPECT_FLOAT_EQ( | 7901 EXPECT_FLOAT_EQ( |
| 7928 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7902 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8176 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { | 8150 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
| 8177 const gfx::Transform identity_matrix; | 8151 const gfx::Transform identity_matrix; |
| 8178 scoped_refptr<Layer> root = Layer::Create(); | 8152 scoped_refptr<Layer> root = Layer::Create(); |
| 8179 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8153 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 8180 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8154 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8181 | 8155 |
| 8182 root->AddChild(animated); | 8156 root->AddChild(animated); |
| 8183 | 8157 |
| 8184 host()->SetRootLayer(root); | 8158 host()->SetRootLayer(root); |
| 8185 | 8159 |
| 8186 host()->SetElementIdsForTesting(); | |
| 8187 | |
| 8188 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8160 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 8189 gfx::PointF(), gfx::Size(100, 100), true, false); | 8161 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8190 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 8162 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 8191 gfx::PointF(), gfx::Size(20, 20), true, false); | 8163 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 8192 | 8164 |
| 8193 root->SetMasksToBounds(true); | 8165 root->SetMasksToBounds(true); |
| 8194 root->SetForceRenderSurfaceForTesting(true); | 8166 root->SetForceRenderSurfaceForTesting(true); |
| 8195 animated->SetOpacity(0.f); | 8167 animated->SetOpacity(0.f); |
| 8196 | 8168 |
| 8197 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), | 8169 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, |
| 8198 10.0, 0.f, 1.f, false); | 8170 1.f, false); |
| 8199 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8171 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8200 | 8172 |
| 8201 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); | 8173 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); |
| 8202 } | 8174 } |
| 8203 | 8175 |
| 8204 TEST_F(LayerTreeHostCommonTest, | 8176 TEST_F(LayerTreeHostCommonTest, |
| 8205 VisibleContentRectForAnimatedLayerWithSingularTransform) { | 8177 VisibleContentRectForAnimatedLayerWithSingularTransform) { |
| 8206 const gfx::Transform identity_matrix; | 8178 const gfx::Transform identity_matrix; |
| 8207 scoped_refptr<Layer> root = Layer::Create(); | 8179 scoped_refptr<Layer> root = Layer::Create(); |
| 8208 scoped_refptr<Layer> clip = Layer::Create(); | 8180 scoped_refptr<Layer> clip = Layer::Create(); |
| 8209 scoped_refptr<LayerWithForcedDrawsContent> animated = | 8181 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 8210 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8182 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8211 scoped_refptr<LayerWithForcedDrawsContent> surface = | 8183 scoped_refptr<LayerWithForcedDrawsContent> surface = |
| 8212 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8184 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8213 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = | 8185 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = |
| 8214 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 8186 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8215 | 8187 |
| 8216 root->AddChild(clip); | 8188 root->AddChild(clip); |
| 8217 clip->AddChild(animated); | 8189 clip->AddChild(animated); |
| 8218 animated->AddChild(surface); | 8190 animated->AddChild(surface); |
| 8219 surface->AddChild(descendant_of_animation); | 8191 surface->AddChild(descendant_of_animation); |
| 8220 | 8192 |
| 8221 clip->SetMasksToBounds(true); | 8193 clip->SetMasksToBounds(true); |
| 8222 surface->SetForceRenderSurfaceForTesting(true); | 8194 surface->SetForceRenderSurfaceForTesting(true); |
| 8223 | 8195 |
| 8224 host()->SetRootLayer(root); | 8196 host()->SetRootLayer(root); |
| 8225 | 8197 |
| 8226 host()->SetElementIdsForTesting(); | |
| 8227 | |
| 8228 gfx::Transform uninvertible_matrix; | 8198 gfx::Transform uninvertible_matrix; |
| 8229 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); | 8199 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); |
| 8230 | 8200 |
| 8231 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 8201 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 8232 gfx::PointF(), gfx::Size(100, 100), true, false); | 8202 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8233 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), | 8203 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), |
| 8234 gfx::PointF(), gfx::Size(10, 10), true, false); | 8204 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 8235 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, | 8205 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, |
| 8236 gfx::Point3F(), gfx::PointF(), | 8206 gfx::Point3F(), gfx::PointF(), |
| 8237 gfx::Size(120, 120), true, false); | 8207 gfx::Size(120, 120), true, false); |
| 8238 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 8208 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), |
| 8239 gfx::PointF(), gfx::Size(100, 100), true, false); | 8209 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8240 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, | 8210 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, |
| 8241 gfx::Point3F(), gfx::PointF(), | 8211 gfx::Point3F(), gfx::PointF(), |
| 8242 gfx::Size(200, 200), true, false); | 8212 gfx::Size(200, 200), true, false); |
| 8243 | 8213 |
| 8244 TransformOperations start_transform_operations; | 8214 TransformOperations start_transform_operations; |
| 8245 start_transform_operations.AppendMatrix(uninvertible_matrix); | 8215 start_transform_operations.AppendMatrix(uninvertible_matrix); |
| 8246 TransformOperations end_transform_operations; | 8216 TransformOperations end_transform_operations; |
| 8247 | 8217 |
| 8248 SetElementIdsForTesting(); | 8218 AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, |
| 8249 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), | 8219 start_transform_operations, |
| 8250 10.0, start_transform_operations, | 8220 end_transform_operations); |
| 8251 end_transform_operations); | |
| 8252 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8221 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8253 | 8222 |
| 8254 // The animated layer has a singular transform and maps to a non-empty rect in | 8223 // The animated layer has a singular transform and maps to a non-empty rect in |
| 8255 // clipped target space, so is treated as fully visible. | 8224 // clipped target space, so is treated as fully visible. |
| 8256 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); | 8225 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); |
| 8257 | 8226 |
| 8258 // The singular transform on |animated| is flattened when inherited by | 8227 // The singular transform on |animated| is flattened when inherited by |
| 8259 // |surface|, and this happens to make it invertible. | 8228 // |surface|, and this happens to make it invertible. |
| 8260 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); | 8229 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); |
| 8261 EXPECT_EQ(gfx::Rect(2, 2), | 8230 EXPECT_EQ(gfx::Rect(2, 2), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 8288 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8257 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8289 | 8258 |
| 8290 gfx::Transform identity_transform; | 8259 gfx::Transform identity_transform; |
| 8291 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8260 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
| 8292 gfx::PointF(), gfx::Size(50, 50), true, false); | 8261 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8293 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8262 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
| 8294 gfx::PointF(), gfx::Size(50, 50), true, false); | 8263 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8295 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8264 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
| 8296 gfx::PointF(), gfx::Size(50, 50), true, false); | 8265 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8297 | 8266 |
| 8298 SetElementIdsForTesting(); | 8267 AddAnimatedFilterToLayerWithPlayer(child->id(), timeline_impl(), 10.0, 0.1f, |
| 8299 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), | 8268 0.2f); |
| 8300 10.0, 0.1f, 0.2f); | |
| 8301 ExecuteCalculateDrawProperties(root); | 8269 ExecuteCalculateDrawProperties(root); |
| 8302 | 8270 |
| 8303 EXPECT_TRUE(root->has_render_surface()); | 8271 EXPECT_TRUE(root->has_render_surface()); |
| 8304 EXPECT_TRUE(child->has_render_surface()); | 8272 EXPECT_TRUE(child->has_render_surface()); |
| 8305 EXPECT_FALSE(grandchild->has_render_surface()); | 8273 EXPECT_FALSE(grandchild->has_render_surface()); |
| 8306 | 8274 |
| 8307 EXPECT_TRUE(root->filters().IsEmpty()); | 8275 EXPECT_TRUE(root->filters().IsEmpty()); |
| 8308 EXPECT_TRUE(child->filters().IsEmpty()); | 8276 EXPECT_TRUE(child->filters().IsEmpty()); |
| 8309 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8277 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
| 8310 | 8278 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8321 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8289 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8322 | 8290 |
| 8323 gfx::Transform identity_transform; | 8291 gfx::Transform identity_transform; |
| 8324 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8292 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
| 8325 gfx::PointF(), gfx::Size(50, 50), true, false); | 8293 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8326 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8294 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
| 8327 gfx::PointF(), gfx::Size(50, 50), true, false); | 8295 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8328 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8296 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
| 8329 gfx::PointF(), gfx::Size(50, 50), true, false); | 8297 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 8330 | 8298 |
| 8331 SetElementIdsForTesting(); | |
| 8332 | |
| 8333 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 8299 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
| 8334 KeyframedFilterAnimationCurve::Create()); | 8300 KeyframedFilterAnimationCurve::Create()); |
| 8335 FilterOperations start_filters; | 8301 FilterOperations start_filters; |
| 8336 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); | 8302 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); |
| 8337 FilterOperations end_filters; | 8303 FilterOperations end_filters; |
| 8338 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); | 8304 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); |
| 8339 curve->AddKeyframe( | 8305 curve->AddKeyframe( |
| 8340 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 8306 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 8341 curve->AddKeyframe(FilterKeyframe::Create( | 8307 curve->AddKeyframe(FilterKeyframe::Create( |
| 8342 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); | 8308 base::TimeDelta::FromMilliseconds(100), end_filters, nullptr)); |
| 8343 std::unique_ptr<Animation> animation = | 8309 std::unique_ptr<Animation> animation = |
| 8344 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); | 8310 Animation::Create(std::move(curve), 0, 1, TargetProperty::FILTER); |
| 8345 animation->set_fill_mode(Animation::FillMode::NONE); | 8311 animation->set_fill_mode(Animation::FillMode::NONE); |
| 8346 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8312 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8347 | 8313 |
| 8348 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), | 8314 AddAnimationToLayerWithPlayer(child->id(), timeline_impl(), |
| 8349 std::move(animation)); | 8315 std::move(animation)); |
| 8350 ExecuteCalculateDrawProperties(root); | 8316 ExecuteCalculateDrawProperties(root); |
| 8351 | 8317 |
| 8352 EXPECT_TRUE(root->has_render_surface()); | 8318 EXPECT_TRUE(root->has_render_surface()); |
| 8353 EXPECT_TRUE(child->has_render_surface()); | 8319 EXPECT_TRUE(child->has_render_surface()); |
| 8354 EXPECT_FALSE(grandchild->has_render_surface()); | 8320 EXPECT_FALSE(grandchild->has_render_surface()); |
| 8355 | 8321 |
| 8356 EXPECT_TRUE(root->filters().IsEmpty()); | 8322 EXPECT_TRUE(root->filters().IsEmpty()); |
| 8357 EXPECT_TRUE(child->filters().IsEmpty()); | 8323 EXPECT_TRUE(child->filters().IsEmpty()); |
| 8358 EXPECT_TRUE(grandchild->filters().IsEmpty()); | 8324 EXPECT_TRUE(grandchild->filters().IsEmpty()); |
| 8359 | 8325 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8701 gfx::PointF(), gfx::Size(10, 10), true, false); | 8667 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 8702 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | 8668 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), |
| 8703 gfx::PointF(), gfx::Size(10, 10), true, false); | 8669 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 8704 | 8670 |
| 8705 root->AddChild(child); | 8671 root->AddChild(child); |
| 8706 child->AddChild(grandchild); | 8672 child->AddChild(grandchild); |
| 8707 grandchild->AddChild(greatgrandchild); | 8673 grandchild->AddChild(greatgrandchild); |
| 8708 | 8674 |
| 8709 host()->SetRootLayer(root); | 8675 host()->SetRootLayer(root); |
| 8710 | 8676 |
| 8711 host()->SetElementIdsForTesting(); | |
| 8712 | |
| 8713 // Check the non-skipped case. | 8677 // Check the non-skipped case. |
| 8714 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8678 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8715 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8679 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8716 | 8680 |
| 8717 // Now we will reset the visible rect from property trees for the grandchild, | 8681 // Now we will reset the visible rect from property trees for the grandchild, |
| 8718 // and we will configure |child| in several ways that should force the subtree | 8682 // and we will configure |child| in several ways that should force the subtree |
| 8719 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8683 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 8720 // remain empty. | 8684 // remain empty. |
| 8721 grandchild->set_visible_layer_rect(gfx::Rect()); | 8685 grandchild->set_visible_layer_rect(gfx::Rect()); |
| 8722 gfx::Transform singular; | 8686 gfx::Transform singular; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8737 child->SetTransform(zero_z_scale); | 8701 child->SetTransform(zero_z_scale); |
| 8738 | 8702 |
| 8739 // Add a transform animation with a start delay. Now, even though |child| has | 8703 // Add a transform animation with a start delay. Now, even though |child| has |
| 8740 // a singular transform, the subtree should still get processed. | 8704 // a singular transform, the subtree should still get processed. |
| 8741 int animation_id = 0; | 8705 int animation_id = 0; |
| 8742 std::unique_ptr<Animation> animation = Animation::Create( | 8706 std::unique_ptr<Animation> animation = Animation::Create( |
| 8743 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8707 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
| 8744 animation_id, 1, TargetProperty::TRANSFORM); | 8708 animation_id, 1, TargetProperty::TRANSFORM); |
| 8745 animation->set_fill_mode(Animation::FillMode::NONE); | 8709 animation->set_fill_mode(Animation::FillMode::NONE); |
| 8746 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8710 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8747 AddAnimationToElementWithPlayer(child->element_id(), timeline(), | 8711 AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); |
| 8748 std::move(animation)); | |
| 8749 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8712 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8750 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8713 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8751 grandchild->set_visible_layer_rect(gfx::Rect()); | 8714 grandchild->set_visible_layer_rect(gfx::Rect()); |
| 8752 | 8715 |
| 8753 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), | 8716 RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), |
| 8754 animation_id); | 8717 animation_id); |
| 8755 child->SetTransform(identity); | 8718 child->SetTransform(identity); |
| 8756 child->SetOpacity(0.f); | 8719 child->SetOpacity(0.f); |
| 8757 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8720 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8758 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8721 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
| 8759 | 8722 |
| 8760 // Now, even though child has zero opacity, we will configure |grandchild| and | 8723 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8761 // |greatgrandchild| in several ways that should force the subtree to be | 8724 // |greatgrandchild| in several ways that should force the subtree to be |
| 8762 // processed anyhow. | 8725 // processed anyhow. |
| 8763 grandchild->RequestCopyOfOutput( | 8726 grandchild->RequestCopyOfOutput( |
| 8764 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8727 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8765 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8728 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8766 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8729 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8767 greatgrandchild->set_visible_layer_rect(gfx::Rect()); | 8730 greatgrandchild->set_visible_layer_rect(gfx::Rect()); |
| 8768 | 8731 |
| 8769 // Add an opacity animation with a start delay. | 8732 // Add an opacity animation with a start delay. |
| 8770 animation_id = 1; | 8733 animation_id = 1; |
| 8771 animation = Animation::Create( | 8734 animation = Animation::Create( |
| 8772 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8735 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 8773 animation_id, 1, TargetProperty::OPACITY); | 8736 animation_id, 1, TargetProperty::OPACITY); |
| 8774 animation->set_fill_mode(Animation::FillMode::NONE); | 8737 animation->set_fill_mode(Animation::FillMode::NONE); |
| 8775 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8738 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8776 AddAnimationToElementWithExistingPlayer(child->element_id(), timeline(), | 8739 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
| 8777 std::move(animation)); | 8740 std::move(animation)); |
| 8778 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8741 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8779 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8742 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8780 } | 8743 } |
| 8781 | 8744 |
| 8782 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { | 8745 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
| 8783 FakeImplTaskRunnerProvider task_runner_provider; | 8746 FakeImplTaskRunnerProvider task_runner_provider; |
| 8784 TestSharedBitmapManager shared_bitmap_manager; | 8747 TestSharedBitmapManager shared_bitmap_manager; |
| 8785 TestTaskGraphRunner task_graph_runner; | 8748 TestTaskGraphRunner task_graph_runner; |
| 8786 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8749 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8787 &task_graph_runner); | 8750 &task_graph_runner); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 8812 false); | 8775 false); |
| 8813 | 8776 |
| 8814 LayerImpl* root_ptr = root.get(); | 8777 LayerImpl* root_ptr = root.get(); |
| 8815 LayerImpl* child_ptr = child.get(); | 8778 LayerImpl* child_ptr = child.get(); |
| 8816 LayerImpl* grandchild_ptr = grandchild.get(); | 8779 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8817 | 8780 |
| 8818 child->AddChild(std::move(grandchild)); | 8781 child->AddChild(std::move(grandchild)); |
| 8819 root->AddChild(std::move(child)); | 8782 root->AddChild(std::move(child)); |
| 8820 host_impl.active_tree()->SetRootLayer(std::move(root)); | 8783 host_impl.active_tree()->SetRootLayer(std::move(root)); |
| 8821 | 8784 |
| 8822 host_impl.active_tree()->SetElementIdsForTesting(); | |
| 8823 | |
| 8824 // Check the non-skipped case. | 8785 // Check the non-skipped case. |
| 8825 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8786 // ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8826 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8787 // EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8827 | 8788 |
| 8828 // Now we will reset the visible rect from property trees for the grandchild, | 8789 // Now we will reset the visible rect from property trees for the grandchild, |
| 8829 // and we will configure |child| in several ways that should force the subtree | 8790 // and we will configure |child| in several ways that should force the subtree |
| 8830 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8791 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 8831 // remain empty. | 8792 // remain empty. |
| 8832 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8793 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8833 | 8794 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8909 TransformOperations operation; | 8870 TransformOperations operation; |
| 8910 operation.AppendMatrix(transform); | 8871 operation.AppendMatrix(transform); |
| 8911 curve->AddKeyframe( | 8872 curve->AddKeyframe( |
| 8912 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8873 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8913 curve->AddKeyframe(TransformKeyframe::Create( | 8874 curve->AddKeyframe(TransformKeyframe::Create( |
| 8914 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8875 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8915 std::unique_ptr<Animation> transform_animation( | 8876 std::unique_ptr<Animation> transform_animation( |
| 8916 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8877 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8917 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8878 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8918 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8879 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
| 8919 root_ptr->element_id(), player.get()); | 8880 root_ptr->id(), player.get()); |
| 8920 host_impl.active_tree() | 8881 host_impl.active_tree() |
| 8921 ->animation_host() | 8882 ->animation_host() |
| 8922 ->GetElementAnimationsForElementId(root_ptr->element_id()) | 8883 ->GetElementAnimationsForElementId(root_ptr->id()) |
| 8923 ->AddAnimation(std::move(transform_animation)); | 8884 ->AddAnimation(std::move(transform_animation)); |
| 8924 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8885 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8925 child_ptr->SetScrollClipLayer(root_ptr->id()); | 8886 child_ptr->SetScrollClipLayer(root_ptr->id()); |
| 8926 root_ptr->SetTransform(singular); | 8887 root_ptr->SetTransform(singular); |
| 8927 child_ptr->SetTransform(singular); | 8888 child_ptr->SetTransform(singular); |
| 8928 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8889 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8929 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8890 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8930 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8891 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8931 | 8892 |
| 8932 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8893 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8933 root_ptr->element_id(), player.get()); | 8894 root_ptr->id(), player.get()); |
| 8934 } | 8895 } |
| 8935 | 8896 |
| 8936 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8897 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
| 8937 LayerImpl* root = root_layer(); | 8898 LayerImpl* root = root_layer(); |
| 8938 LayerImpl* child = AddChild<LayerImpl>(root); | 8899 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8939 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8900 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 8940 | 8901 |
| 8941 gfx::Transform identity; | 8902 gfx::Transform identity; |
| 8942 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8903 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 8943 gfx::Size(10, 10), true, false, true); | 8904 gfx::Size(10, 10), true, false, true); |
| 8944 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 8905 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
| 8945 gfx::Size(10, 10), true, false, false); | 8906 gfx::Size(10, 10), true, false, false); |
| 8946 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | 8907 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), |
| 8947 gfx::PointF(), gfx::Size(10, 10), true, false, | 8908 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8948 false); | 8909 false); |
| 8949 SetElementIdsForTesting(); | |
| 8950 | 8910 |
| 8951 gfx::Transform singular; | 8911 gfx::Transform singular; |
| 8952 singular.matrix().set(0, 0, 0); | 8912 singular.matrix().set(0, 0, 0); |
| 8953 singular.matrix().set(0, 1, 1); | 8913 singular.matrix().set(0, 1, 1); |
| 8954 | 8914 |
| 8955 child->SetTransform(singular); | 8915 child->SetTransform(singular); |
| 8956 child->SetDrawsContent(true); | 8916 child->SetDrawsContent(true); |
| 8957 grand_child->SetDrawsContent(true); | 8917 grand_child->SetDrawsContent(true); |
| 8958 | 8918 |
| 8959 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8919 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 8960 KeyframedTransformAnimationCurve::Create()); | 8920 KeyframedTransformAnimationCurve::Create()); |
| 8961 TransformOperations start; | 8921 TransformOperations start; |
| 8962 start.AppendTranslate(1.f, 2.f, 3.f); | 8922 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8963 gfx::Transform transform; | 8923 gfx::Transform transform; |
| 8964 transform.Scale3d(1.0, 2.0, 3.0); | 8924 transform.Scale3d(1.0, 2.0, 3.0); |
| 8965 TransformOperations operation; | 8925 TransformOperations operation; |
| 8966 operation.AppendMatrix(transform); | 8926 operation.AppendMatrix(transform); |
| 8967 curve->AddKeyframe( | 8927 curve->AddKeyframe( |
| 8968 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8928 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8969 curve->AddKeyframe(TransformKeyframe::Create( | 8929 curve->AddKeyframe(TransformKeyframe::Create( |
| 8970 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8930 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8971 std::unique_ptr<Animation> transform_animation( | 8931 std::unique_ptr<Animation> transform_animation( |
| 8972 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8932 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8973 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8933 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8974 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( | 8934 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( |
| 8975 grand_child->element_id(), player.get()); | 8935 grand_child->id(), player.get()); |
| 8976 host_impl() | 8936 host_impl() |
| 8977 ->active_tree() | 8937 ->active_tree() |
| 8978 ->animation_host() | 8938 ->animation_host() |
| 8979 ->GetElementAnimationsForElementId(grand_child->element_id()) | 8939 ->GetElementAnimationsForElementId(grand_child->id()) |
| 8980 ->AddAnimation(std::move(transform_animation)); | 8940 ->AddAnimation(std::move(transform_animation)); |
| 8981 | 8941 |
| 8982 ExecuteCalculateDrawProperties(root); | 8942 ExecuteCalculateDrawProperties(root); |
| 8983 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); | 8943 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); |
| 8984 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8944 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8985 | 8945 |
| 8986 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( | 8946 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8987 grand_child->element_id(), player.get()); | 8947 grand_child->id(), player.get()); |
| 8988 } | 8948 } |
| 8989 | 8949 |
| 8990 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 8950 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
| 8991 FakeImplTaskRunnerProvider task_runner_provider; | 8951 FakeImplTaskRunnerProvider task_runner_provider; |
| 8992 TestSharedBitmapManager shared_bitmap_manager; | 8952 TestSharedBitmapManager shared_bitmap_manager; |
| 8993 TestTaskGraphRunner task_graph_runner; | 8953 TestTaskGraphRunner task_graph_runner; |
| 8994 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8954 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8995 &task_graph_runner); | 8955 &task_graph_runner); |
| 8996 | 8956 |
| 8997 gfx::Transform identity; | 8957 gfx::Transform identity; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 9020 gfx::PointF(), gfx::Size(10, 10), true, false, | 8980 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 9021 false); | 8981 false); |
| 9022 | 8982 |
| 9023 LayerImpl* root_ptr = root.get(); | 8983 LayerImpl* root_ptr = root.get(); |
| 9024 LayerImpl* grandchild_ptr = grandchild.get(); | 8984 LayerImpl* grandchild_ptr = grandchild.get(); |
| 9025 | 8985 |
| 9026 child->AddChild(std::move(grandchild)); | 8986 child->AddChild(std::move(grandchild)); |
| 9027 root->AddChild(std::move(child)); | 8987 root->AddChild(std::move(child)); |
| 9028 | 8988 |
| 9029 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 8989 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
| 9030 host_impl.pending_tree()->SetElementIdsForTesting(); | |
| 9031 | 8990 |
| 9032 // Check the non-skipped case. | 8991 // Check the non-skipped case. |
| 9033 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8992 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 9034 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8993 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9035 | 8994 |
| 9036 std::unique_ptr<KeyframedFloatAnimationCurve> curve( | 8995 std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
| 9037 KeyframedFloatAnimationCurve::Create()); | 8996 KeyframedFloatAnimationCurve::Create()); |
| 9038 std::unique_ptr<TimingFunction> func = | 8997 std::unique_ptr<TimingFunction> func = |
| 9039 CubicBezierTimingFunction::CreatePreset( | 8998 CubicBezierTimingFunction::CreatePreset( |
| 9040 CubicBezierTimingFunction::EaseType::EASE); | 8999 CubicBezierTimingFunction::EaseType::EASE); |
| 9041 curve->AddKeyframe( | 9000 curve->AddKeyframe( |
| 9042 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); | 9001 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
| 9043 curve->AddKeyframe( | 9002 curve->AddKeyframe( |
| 9044 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 9003 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
| 9045 std::unique_ptr<Animation> animation( | 9004 std::unique_ptr<Animation> animation( |
| 9046 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 9005 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
| 9047 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9006 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 9048 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 9007 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
| 9049 root_ptr->element_id(), player.get()); | 9008 root_ptr->id(), player.get()); |
| 9050 host_impl.active_tree() | 9009 host_impl.active_tree() |
| 9051 ->animation_host() | 9010 ->animation_host() |
| 9052 ->GetElementAnimationsForElementId(root_ptr->element_id()) | 9011 ->GetElementAnimationsForElementId(root_ptr->id()) |
| 9053 ->AddAnimation(std::move(animation)); | 9012 ->AddAnimation(std::move(animation)); |
| 9054 root_ptr->test_properties()->opacity = 0.f; | 9013 root_ptr->test_properties()->opacity = 0.f; |
| 9055 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 9014 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 9056 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9015 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9057 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9016 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 9058 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9017 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9059 | 9018 |
| 9060 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 9019 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 9061 root_ptr->element_id(), player.get()); | 9020 root_ptr->id(), player.get()); |
| 9062 } | 9021 } |
| 9063 | 9022 |
| 9064 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 9023 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
| 9065 gfx::Transform identity; | 9024 gfx::Transform identity; |
| 9066 LayerImpl* root = root_layer(); | 9025 LayerImpl* root = root_layer(); |
| 9067 LayerImpl* child = AddChild<LayerImpl>(root); | 9026 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9068 | 9027 |
| 9069 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 9028 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 9070 gfx::Size(100, 100), true, false, true); | 9029 gfx::Size(100, 100), true, false, true); |
| 9071 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | 9030 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9902 | 9861 |
| 9903 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9862 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 9904 const gfx::Transform identity_matrix; | 9863 const gfx::Transform identity_matrix; |
| 9905 scoped_refptr<Layer> root = Layer::Create(); | 9864 scoped_refptr<Layer> root = Layer::Create(); |
| 9906 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9865 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9907 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9866 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9908 root->AddChild(animated); | 9867 root->AddChild(animated); |
| 9909 | 9868 |
| 9910 host()->SetRootLayer(root); | 9869 host()->SetRootLayer(root); |
| 9911 | 9870 |
| 9912 host()->SetElementIdsForTesting(); | |
| 9913 | |
| 9914 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9871 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 9915 gfx::PointF(), gfx::Size(100, 100), true, false); | 9872 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 9916 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 9873 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 9917 gfx::PointF(), gfx::Size(20, 20), true, false); | 9874 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 9918 | 9875 |
| 9919 root->SetForceRenderSurfaceForTesting(true); | 9876 root->SetForceRenderSurfaceForTesting(true); |
| 9920 animated->SetOpacity(0.f); | 9877 animated->SetOpacity(0.f); |
| 9921 | 9878 |
| 9922 scoped_refptr<AnimationPlayer> player = | 9879 scoped_refptr<AnimationPlayer> player = |
| 9923 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9880 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 9924 timeline()->AttachPlayer(player); | 9881 timeline()->AttachPlayer(player); |
| 9925 | 9882 player->AttachElement(animated->id()); |
| 9926 player->AttachElement(animated->element_id()); | |
| 9927 | 9883 |
| 9928 int animation_id = 0; | 9884 int animation_id = 0; |
| 9929 std::unique_ptr<Animation> animation = Animation::Create( | 9885 std::unique_ptr<Animation> animation = Animation::Create( |
| 9930 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 9886 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 9931 animation_id, 1, TargetProperty::OPACITY); | 9887 animation_id, 1, TargetProperty::OPACITY); |
| 9932 animation->set_fill_mode(Animation::FillMode::NONE); | 9888 animation->set_fill_mode(Animation::FillMode::NONE); |
| 9933 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9889 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 9934 Animation* animation_ptr = animation.get(); | 9890 Animation* animation_ptr = animation.get(); |
| 9935 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 9891 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), |
| 9936 std::move(animation)); | 9892 std::move(animation)); |
| 9937 | 9893 |
| 9938 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9894 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9939 | 9895 |
| 9940 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; | 9896 EffectTree& tree = root->layer_tree_host()->property_trees()->effect_tree; |
| 9941 EffectNode* node = tree.Node(animated->effect_tree_index()); | 9897 EffectNode* node = tree.Node(animated->effect_tree_index()); |
| 9942 EXPECT_FALSE(node->data.is_currently_animating_opacity); | 9898 EXPECT_FALSE(node->data.is_currently_animating_opacity); |
| 9943 EXPECT_TRUE(node->data.has_potential_opacity_animation); | 9899 EXPECT_TRUE(node->data.has_potential_opacity_animation); |
| 9944 | 9900 |
| 9945 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9901 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
| 9946 root->layer_tree_host()->AnimateLayers( | 9902 root->layer_tree_host()->AnimateLayers( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9957 | 9913 |
| 9958 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 9914 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
| 9959 const gfx::Transform identity_matrix; | 9915 const gfx::Transform identity_matrix; |
| 9960 scoped_refptr<Layer> root = Layer::Create(); | 9916 scoped_refptr<Layer> root = Layer::Create(); |
| 9961 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9917 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9962 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9918 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9963 root->AddChild(animated); | 9919 root->AddChild(animated); |
| 9964 | 9920 |
| 9965 host()->SetRootLayer(root); | 9921 host()->SetRootLayer(root); |
| 9966 | 9922 |
| 9967 host()->SetElementIdsForTesting(); | |
| 9968 | |
| 9969 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9923 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 9970 gfx::PointF(), gfx::Size(100, 100), true, false); | 9924 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 9971 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | 9925 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 9972 gfx::PointF(), gfx::Size(20, 20), true, false); | 9926 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 9973 | 9927 |
| 9974 root->SetForceRenderSurfaceForTesting(true); | 9928 root->SetForceRenderSurfaceForTesting(true); |
| 9975 | 9929 |
| 9976 scoped_refptr<AnimationPlayer> player = | 9930 scoped_refptr<AnimationPlayer> player = |
| 9977 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9931 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 9978 timeline()->AttachPlayer(player); | 9932 timeline()->AttachPlayer(player); |
| 9979 player->AttachElement(animated->element_id()); | 9933 player->AttachElement(animated->id()); |
| 9980 | 9934 |
| 9981 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 9935 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 9982 KeyframedTransformAnimationCurve::Create()); | 9936 KeyframedTransformAnimationCurve::Create()); |
| 9983 TransformOperations start; | 9937 TransformOperations start; |
| 9984 start.AppendTranslate(1.f, 2.f, 3.f); | 9938 start.AppendTranslate(1.f, 2.f, 3.f); |
| 9985 gfx::Transform transform; | 9939 gfx::Transform transform; |
| 9986 transform.Scale3d(1.0, 2.0, 3.0); | 9940 transform.Scale3d(1.0, 2.0, 3.0); |
| 9987 TransformOperations operation; | 9941 TransformOperations operation; |
| 9988 operation.AppendMatrix(transform); | 9942 operation.AppendMatrix(transform); |
| 9989 curve->AddKeyframe( | 9943 curve->AddKeyframe( |
| 9990 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 9944 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 9991 curve->AddKeyframe(TransformKeyframe::Create( | 9945 curve->AddKeyframe(TransformKeyframe::Create( |
| 9992 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 9946 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 9993 std::unique_ptr<Animation> animation( | 9947 std::unique_ptr<Animation> animation( |
| 9994 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 9948 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 9995 animation->set_fill_mode(Animation::FillMode::NONE); | 9949 animation->set_fill_mode(Animation::FillMode::NONE); |
| 9996 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 9950 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 9997 Animation* animation_ptr = animation.get(); | 9951 Animation* animation_ptr = animation.get(); |
| 9998 AddAnimationToElementWithExistingPlayer(animated->element_id(), timeline(), | 9952 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), |
| 9999 std::move(animation)); | 9953 std::move(animation)); |
| 10000 | 9954 |
| 10001 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9955 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 10002 | 9956 |
| 10003 TransformTree& tree = | 9957 TransformTree& tree = |
| 10004 root->layer_tree_host()->property_trees()->transform_tree; | 9958 root->layer_tree_host()->property_trees()->transform_tree; |
| 10005 TransformNode* node = tree.Node(animated->transform_tree_index()); | 9959 TransformNode* node = tree.Node(animated->transform_tree_index()); |
| 10006 EXPECT_FALSE(node->data.is_currently_animating); | 9960 EXPECT_FALSE(node->data.is_currently_animating); |
| 10007 EXPECT_TRUE(node->data.has_potential_animation); | 9961 EXPECT_TRUE(node->data.has_potential_animation); |
| 10008 | 9962 |
| 10009 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); | 9963 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10245 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10199 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10246 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10200 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10247 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10201 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10248 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10202 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10249 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10203 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10250 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10204 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10251 } | 10205 } |
| 10252 | 10206 |
| 10253 } // namespace | 10207 } // namespace |
| 10254 } // namespace cc | 10208 } // namespace cc |
| OLD | NEW |