OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/surface_layer_impl.h" | 5 #include "cc/layers/surface_layer_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/test/layer_test_common.h" | 10 #include "cc/test/layer_test_common.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 LayerTestCommon::LayerImplTest impl; | 69 LayerTestCommon::LayerImplTest impl; |
70 SurfaceLayerImpl* surface_layer_impl = | 70 SurfaceLayerImpl* surface_layer_impl = |
71 impl.AddChildToRoot<SurfaceLayerImpl>(); | 71 impl.AddChildToRoot<SurfaceLayerImpl>(); |
72 const LocalFrameId kArbitraryLocalFrameId(9, | 72 const LocalFrameId kArbitraryLocalFrameId(9, |
73 base::UnguessableToken::Create()); | 73 base::UnguessableToken::Create()); |
74 | 74 |
75 // Given condition: layer and surface have different size and different | 75 // Given condition: layer and surface have different size and different |
76 // aspect ratios. | 76 // aspect ratios. |
77 gfx::Size layer_size(400, 100); | 77 gfx::Size layer_size(400, 100); |
78 gfx::Size surface_size(300, 300); | 78 gfx::Size surface_size(300, 300); |
| 79 gfx::Size viewport_size(1000, 1000); |
79 float surface_scale = 1.f; | 80 float surface_scale = 1.f; |
80 gfx::Transform target_space_transform( | 81 gfx::Transform target_space_transform( |
81 surface_layer_impl->draw_properties().target_space_transform); | 82 surface_layer_impl->draw_properties().target_space_transform); |
82 | 83 |
83 // The following code is mimicking the PushPropertiesTo from pending to | 84 // The following code is mimicking the PushPropertiesTo from pending to |
84 // active tree. | 85 // active tree. |
85 surface_layer_impl->SetBounds(layer_size); | 86 surface_layer_impl->SetBounds(layer_size); |
86 surface_layer_impl->SetDrawsContent(true); | 87 surface_layer_impl->SetDrawsContent(true); |
87 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalFrameId); | 88 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalFrameId); |
88 surface_layer_impl->SetSurfaceInfo( | 89 surface_layer_impl->SetSurfaceInfo( |
89 SurfaceInfo(surface_id, surface_scale, surface_size)); | 90 SurfaceInfo(surface_id, surface_scale, surface_size)); |
90 surface_layer_impl->SetStretchContentToFillBounds(true); | 91 surface_layer_impl->SetStretchContentToFillBounds(true); |
91 | 92 |
| 93 impl.CalcDrawProps(viewport_size); |
| 94 |
92 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 95 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
93 AppendQuadsData data; | 96 AppendQuadsData data; |
94 surface_layer_impl->AppendQuads(render_pass.get(), &data); | 97 surface_layer_impl->AppendQuads(render_pass.get(), &data); |
95 | 98 |
96 const QuadList& quads = render_pass->quad_list; | 99 const QuadList& quads = render_pass->quad_list; |
97 ASSERT_EQ(1u, quads.size()); | 100 ASSERT_EQ(1u, quads.size()); |
98 const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state; | 101 const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state; |
99 | 102 |
100 // We expect that the transform for the quad stretches the quad to cover the | 103 // We expect that the transform for the quad stretches the quad to cover the |
101 // entire bounds of the layer. | 104 // entire bounds of the layer. |
(...skipping 15 matching lines...) Expand all Loading... |
117 gfx::RectF layer_rect(layer_size.width(), layer_size.height()); | 120 gfx::RectF layer_rect(layer_size.width(), layer_size.height()); |
118 gfx::RectF transformed_layer_rect = | 121 gfx::RectF transformed_layer_rect = |
119 MathUtil::MapClippedRect(target_space_transform, layer_rect); | 122 MathUtil::MapClippedRect(target_space_transform, layer_rect); |
120 | 123 |
121 // Check if quad rect in target space matches layer rect in target space | 124 // Check if quad rect in target space matches layer rect in target space |
122 EXPECT_EQ(transformed_quad_rect, transformed_layer_rect); | 125 EXPECT_EQ(transformed_quad_rect, transformed_layer_rect); |
123 } | 126 } |
124 | 127 |
125 } // namespace | 128 } // namespace |
126 } // namespace cc | 129 } // namespace cc |
OLD | NEW |