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 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 SetLayerPropertiesForTesting( | 2593 SetLayerPropertiesForTesting( |
2594 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2594 grand_child_of_root, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2595 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2595 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2596 SetLayerPropertiesForTesting( | 2596 SetLayerPropertiesForTesting( |
2597 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2597 grand_child_of_rs1, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2598 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2598 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2599 SetLayerPropertiesForTesting( | 2599 SetLayerPropertiesForTesting( |
2600 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), | 2600 grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), |
2601 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); | 2601 gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); |
2602 | 2602 |
2603 parent->layer_tree_impl()->BuildPropertyTreesForTesting(); | 2603 parent->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
2604 | 2604 |
2605 // Put an animated opacity on the render surface. | 2605 // Put an animated opacity on the render surface. |
2606 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), | 2606 AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), |
2607 10.0, 1.f, 0.f, false); | 2607 10.0, 1.f, 0.f, false); |
2608 | 2608 |
2609 // Also put an animated opacity on a layer without descendants. | 2609 // Also put an animated opacity on a layer without descendants. |
2610 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), | 2610 AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), |
2611 timeline_impl(), 10.0, 1.f, 0.f, false); | 2611 timeline_impl(), 10.0, 1.f, 0.f, false); |
2612 | 2612 |
2613 // Put a transform animation on the render surface. | 2613 // Put a transform animation on the render surface. |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 gfx::Size(200, 200), false, false, false); | 3641 gfx::Size(200, 200), false, false, false); |
3642 | 3642 |
3643 host_impl.SetViewportSize(root->bounds()); | 3643 host_impl.SetViewportSize(root->bounds()); |
3644 | 3644 |
3645 child->AddChild(std::move(grand_child)); | 3645 child->AddChild(std::move(grand_child)); |
3646 root->AddChild(std::move(child)); | 3646 root->AddChild(std::move(child)); |
3647 root->AddChild(std::move(occluding_child)); | 3647 root->AddChild(std::move(occluding_child)); |
3648 host_impl.active_tree()->SetRootLayer(std::move(root)); | 3648 host_impl.active_tree()->SetRootLayer(std::move(root)); |
3649 host_impl.SetVisible(true); | 3649 host_impl.SetVisible(true); |
3650 host_impl.InitializeRenderer(output_surface.get()); | 3650 host_impl.InitializeRenderer(output_surface.get()); |
3651 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 3651 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
3652 bool update_lcd_text = false; | 3652 bool update_lcd_text = false; |
3653 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); | 3653 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
3654 | 3654 |
3655 LayerImpl* grand_child_ptr = | 3655 LayerImpl* grand_child_ptr = |
3656 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; | 3656 host_impl.active_tree()->root_layer()->children()[0]->children()[0]; |
3657 | 3657 |
3658 // Though all layers have invertible transforms, matrix multiplication using | 3658 // Though all layers have invertible transforms, matrix multiplication using |
3659 // floating-point math makes the draw transform uninvertible. | 3659 // floating-point math makes the draw transform uninvertible. |
3660 EXPECT_FALSE( | 3660 EXPECT_FALSE( |
3661 host_impl.active_tree() | 3661 host_impl.active_tree() |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4697 gfx::Point3F(), gfx::PointF(2.f, 2.f), | 4697 gfx::Point3F(), gfx::PointF(2.f, 2.f), |
4698 gfx::Size(10, 10), false, true, true); | 4698 gfx::Size(10, 10), false, true, true); |
4699 scale_surface->SetDrawsContent(true); | 4699 scale_surface->SetDrawsContent(true); |
4700 | 4700 |
4701 float device_scale_factor = 2.5f; | 4701 float device_scale_factor = 2.5f; |
4702 float page_scale_factor = 3.f; | 4702 float page_scale_factor = 3.f; |
4703 root->layer_tree_impl()->SetViewportLayersFromIds( | 4703 root->layer_tree_impl()->SetViewportLayersFromIds( |
4704 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, | 4704 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, |
4705 Layer::INVALID_ID); | 4705 Layer::INVALID_ID); |
4706 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); | 4706 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); |
4707 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 4707 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
4708 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); | 4708 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); |
4709 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, | 4709 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, |
4710 root); | 4710 root); |
4711 | 4711 |
4712 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent); | 4712 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent); |
4713 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, | 4713 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, |
4714 perspective_surface); | 4714 perspective_surface); |
4715 // Ideal scale is the max 2d scale component of the combined transform up to | 4715 // Ideal scale is the max 2d scale component of the combined transform up to |
4716 // the nearest render target. Here this includes the layer transform as well | 4716 // the nearest render target. Here this includes the layer transform as well |
4717 // as the device and page scale factors. | 4717 // as the device and page scale factors. |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5075 gfx::PointF(), gfx::Size(50, 50), true, false, | 5075 gfx::PointF(), gfx::Size(50, 50), true, false, |
5076 false); | 5076 false); |
5077 child->SetDrawsContent(true); | 5077 child->SetDrawsContent(true); |
5078 child->test_properties()->opacity = 0.0f; | 5078 child->test_properties()->opacity = 0.0f; |
5079 | 5079 |
5080 const int child_id = child->id(); | 5080 const int child_id = child->id(); |
5081 root->AddChild(std::move(child)); | 5081 root->AddChild(std::move(child)); |
5082 root->SetHasRenderSurface(true); | 5082 root->SetHasRenderSurface(true); |
5083 LayerImpl* root_layer = root.get(); | 5083 LayerImpl* root_layer = root.get(); |
5084 host_impl.pending_tree()->SetRootLayer(std::move(root)); | 5084 host_impl.pending_tree()->SetRootLayer(std::move(root)); |
5085 host_impl.pending_tree()->BuildPropertyTreesForTesting(); | 5085 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
5086 // Add opacity animation. | 5086 // Add opacity animation. |
5087 scoped_refptr<AnimationTimeline> timeline = | 5087 scoped_refptr<AnimationTimeline> timeline = |
5088 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5088 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
5089 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5089 host_impl.animation_host()->AddAnimationTimeline(timeline); |
5090 | 5090 |
5091 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, | 5091 AddOpacityTransitionToLayerWithPlayer(child_id, timeline, 10.0, 0.0f, 1.0f, |
5092 false); | 5092 false); |
5093 | 5093 |
5094 LayerImplList render_surface_layer_list; | 5094 LayerImplList render_surface_layer_list; |
5095 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5095 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7001 container->SetDrawsContent(true); | 7001 container->SetDrawsContent(true); |
7002 scroller->SetDrawsContent(true); | 7002 scroller->SetDrawsContent(true); |
7003 fixed->SetDrawsContent(true); | 7003 fixed->SetDrawsContent(true); |
7004 scroller->AddChild(std::move(fixed)); | 7004 scroller->AddChild(std::move(fixed)); |
7005 container->AddChild(std::move(scroller)); | 7005 container->AddChild(std::move(scroller)); |
7006 root->AddChild(std::move(container)); | 7006 root->AddChild(std::move(container)); |
7007 | 7007 |
7008 // Rounded to integers already. | 7008 // Rounded to integers already. |
7009 { | 7009 { |
7010 root->layer_tree_impl()->SetRootLayer(std::move(root_ptr)); | 7010 root->layer_tree_impl()->SetRootLayer(std::move(root_ptr)); |
7011 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 7011 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
7012 | 7012 |
7013 gfx::Vector2dF scroll_delta(3.0, 5.0); | 7013 gfx::Vector2dF scroll_delta(3.0, 5.0); |
7014 SetScrollOffsetDelta(scroll_layer, scroll_delta); | 7014 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7015 | 7015 |
7016 LayerImplList render_surface_layer_list; | 7016 LayerImplList render_surface_layer_list; |
7017 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7017 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7018 root, root->bounds(), &render_surface_layer_list); | 7018 root, root->bounds(), &render_surface_layer_list); |
7019 root->layer_tree_impl() | 7019 root->layer_tree_impl() |
7020 ->property_trees() | 7020 ->property_trees() |
7021 ->transform_tree.set_source_to_parent_updates_allowed(false); | 7021 ->transform_tree.set_source_to_parent_updates_allowed(false); |
7022 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7022 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
7023 | 7023 |
7024 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7024 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7025 container_layer->draw_properties().screen_space_transform, | 7025 container_layer->draw_properties().screen_space_transform, |
7026 fixed_layer->draw_properties().screen_space_transform); | 7026 fixed_layer->draw_properties().screen_space_transform); |
7027 EXPECT_VECTOR_EQ( | 7027 EXPECT_VECTOR_EQ( |
7028 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7028 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7029 container_offset); | 7029 container_offset); |
7030 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7030 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7031 .screen_space_transform.To2dTranslation(), | 7031 .screen_space_transform.To2dTranslation(), |
7032 container_offset - scroll_delta); | 7032 container_offset - scroll_delta); |
7033 } | 7033 } |
7034 | 7034 |
7035 // Scroll delta requiring rounding. | 7035 // Scroll delta requiring rounding. |
7036 { | 7036 { |
7037 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 7037 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
7038 | 7038 |
7039 gfx::Vector2dF scroll_delta(4.1f, 8.1f); | 7039 gfx::Vector2dF scroll_delta(4.1f, 8.1f); |
7040 SetScrollOffsetDelta(scroll_layer, scroll_delta); | 7040 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7041 | 7041 |
7042 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); | 7042 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); |
7043 | 7043 |
7044 LayerImplList render_surface_layer_list; | 7044 LayerImplList render_surface_layer_list; |
7045 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7045 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7046 root, root->bounds(), &render_surface_layer_list); | 7046 root, root->bounds(), &render_surface_layer_list); |
7047 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7047 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
7048 | 7048 |
7049 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7049 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7050 container_layer->draw_properties().screen_space_transform, | 7050 container_layer->draw_properties().screen_space_transform, |
7051 fixed_layer->draw_properties().screen_space_transform); | 7051 fixed_layer->draw_properties().screen_space_transform); |
7052 EXPECT_VECTOR_EQ( | 7052 EXPECT_VECTOR_EQ( |
7053 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7053 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7054 container_offset); | 7054 container_offset); |
7055 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7055 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7056 .screen_space_transform.To2dTranslation(), | 7056 .screen_space_transform.To2dTranslation(), |
7057 container_offset - rounded_scroll_delta); | 7057 container_offset - rounded_scroll_delta); |
7058 } | 7058 } |
7059 | 7059 |
7060 // Scale is applied earlier in the tree. | 7060 // Scale is applied earlier in the tree. |
7061 { | 7061 { |
7062 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 7062 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
7063 gfx::Transform scaled_container_transform = container_transform; | 7063 gfx::Transform scaled_container_transform = container_transform; |
7064 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); | 7064 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); |
7065 container_layer->SetTransform(scaled_container_transform); | 7065 container_layer->SetTransform(scaled_container_transform); |
7066 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7066 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7067 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 7067 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
7068 | 7068 |
7069 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 7069 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
7070 SetScrollOffsetDelta(scroll_layer, scroll_delta); | 7070 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7071 | 7071 |
7072 LayerImplList render_surface_layer_list; | 7072 LayerImplList render_surface_layer_list; |
7073 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7073 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7074 root, root->bounds(), &render_surface_layer_list); | 7074 root, root->bounds(), &render_surface_layer_list); |
7075 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7075 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
7076 | 7076 |
7077 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7077 EXPECT_TRANSFORMATION_MATRIX_EQ( |
(...skipping 3058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10142 } | 10142 } |
10143 | 10143 |
10144 } // namespace | 10144 } // namespace |
10145 } // namespace cc | 10145 } // namespace cc |
OLD | NEW |