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/test/layer_test_common.h" | 10 #include "cc/test/layer_test_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 namespace cc { | 13 namespace cc { |
13 namespace { | 14 namespace { |
14 | 15 |
15 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 16 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
16 | 17 |
17 TEST(SurfaceLayerImplTest, Occlusion) { | 18 TEST(SurfaceLayerImplTest, Occlusion) { |
18 gfx::Size layer_size(1000, 1000); | 19 gfx::Size layer_size(1000, 1000); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 size_t partially_occluded_count = 0; | 61 size_t partially_occluded_count = 0; |
61 LayerTestCommon::VerifyQuadsAreOccluded( | 62 LayerTestCommon::VerifyQuadsAreOccluded( |
62 impl.quad_list(), occluded, &partially_occluded_count); | 63 impl.quad_list(), occluded, &partially_occluded_count); |
63 // The layer outputs one quad, which is partially occluded. | 64 // The layer outputs one quad, which is partially occluded. |
64 EXPECT_EQ(1u, impl.quad_list().size()); | 65 EXPECT_EQ(1u, impl.quad_list().size()); |
65 EXPECT_EQ(1u, partially_occluded_count); | 66 EXPECT_EQ(1u, partially_occluded_count); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
| 70 TEST(SurfaceLayerImplTest, LayerBoundsDiffFromSurfaceLayerSize) { |
| 71 LayerTestCommon::LayerImplTest impl; |
| 72 SurfaceLayerImpl* surface_layer_impl = |
| 73 impl.AddChildToRoot<SurfaceLayerImpl>(); |
| 74 const LocalFrameId kArbitraryLocalFrameId(9, |
| 75 base::UnguessableToken::Create()); |
| 76 |
| 77 gfx::Size layer_size(100, 300); |
| 78 gfx::Size surface_size(350, 350); |
| 79 float surface_scale = 2.f; |
| 80 surface_layer_impl->SetBounds(layer_size); |
| 81 surface_layer_impl->SetDrawsContent(true); |
| 82 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalFrameId); |
| 83 surface_layer_impl->SetSurfaceId(surface_id); |
| 84 surface_layer_impl->SetSurfaceScale(surface_scale); |
| 85 surface_layer_impl->SetSurfaceSize(surface_size); |
| 86 |
| 87 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 88 AppendQuadsData data; |
| 89 surface_layer_impl->AppendQuads(render_pass.get(), &data); |
| 90 |
| 91 const QuadList& quads = render_pass->quad_list; |
| 92 ASSERT_EQ(1u, quads.size()); |
| 93 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, quads.front()->material); |
| 94 const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state; |
| 95 |
| 96 gfx::Transform transform; |
| 97 float scale_x = 350.f / 100.f; |
| 98 float scale_y = 350.f / 300.f; |
| 99 transform.Scale(SK_MScalar1 / scale_x, SK_MScalar1 / scale_y); |
| 100 EXPECT_EQ(transform, shared_quad_state->quad_to_target_transform); |
| 101 } |
| 102 |
69 } // namespace | 103 } // namespace |
70 } // namespace cc | 104 } // namespace cc |
OLD | NEW |