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/io_surface_layer_impl.h" | 5 #include "cc/layers/render_surface_impl.h" |
6 | 6 |
7 #include "cc/test/layer_test_common.h" | 7 #include "cc/test/layer_test_common.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 namespace { | 11 namespace { |
12 | 12 |
13 TEST(IOSurfaceLayerImplTest, Occlusion) { | 13 TEST(RenderSurfaceLayerImplTest, Occlusion) { |
14 gfx::Size layer_size(1000, 1000); | 14 gfx::Size layer_size(1000, 1000); |
15 gfx::Size viewport_size(1000, 1000); | 15 gfx::Size viewport_size(1000, 1000); |
16 | 16 |
17 LayerTestCommon::LayerImplTest impl; | 17 LayerTestCommon::LayerImplTest impl; |
18 | 18 |
19 IOSurfaceLayerImpl* io_surface_layer_impl = | 19 LayerImpl* owning_layer_impl = impl.AddChildToRoot<LayerImpl>(); |
20 impl.AddChildToRoot<IOSurfaceLayerImpl>(); | 20 owning_layer_impl->SetAnchorPoint(gfx::PointF()); |
21 io_surface_layer_impl->SetAnchorPoint(gfx::PointF()); | 21 owning_layer_impl->SetBounds(layer_size); |
22 io_surface_layer_impl->SetBounds(layer_size); | 22 owning_layer_impl->SetContentBounds(layer_size); |
23 io_surface_layer_impl->SetContentBounds(layer_size); | 23 owning_layer_impl->SetDrawsContent(true); |
24 io_surface_layer_impl->SetDrawsContent(true); | 24 owning_layer_impl->SetForceRenderSurface(true); |
25 | 25 |
26 impl.CalcDrawProps(viewport_size); | 26 impl.CalcDrawProps(viewport_size); |
27 | 27 |
| 28 RenderSurfaceImpl* render_surface_impl = owning_layer_impl->render_surface(); |
| 29 ASSERT_TRUE(render_surface_impl); |
| 30 |
28 { | 31 { |
29 SCOPED_TRACE("No occlusion"); | 32 SCOPED_TRACE("No occlusion"); |
30 gfx::Rect occluded; | 33 gfx::Rect occluded; |
31 impl.AppendQuadsWithOcclusion(io_surface_layer_impl, occluded); | 34 impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); |
32 | 35 |
33 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | 36 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), |
34 gfx::Rect(layer_size)); | 37 gfx::Rect(layer_size)); |
35 EXPECT_EQ(1u, impl.quad_list().size()); | 38 EXPECT_EQ(1u, impl.quad_list().size()); |
36 } | 39 } |
37 | 40 |
38 { | 41 { |
39 SCOPED_TRACE("Full occlusion"); | 42 SCOPED_TRACE("Full occlusion"); |
40 gfx::Rect occluded(io_surface_layer_impl->visible_content_rect()); | 43 gfx::Rect occluded(owning_layer_impl->visible_content_rect()); |
41 impl.AppendQuadsWithOcclusion(io_surface_layer_impl, occluded); | 44 impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); |
42 | 45 |
43 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); | 46 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); |
44 EXPECT_EQ(impl.quad_list().size(), 0u); | 47 EXPECT_EQ(impl.quad_list().size(), 0u); |
45 } | 48 } |
46 | 49 |
47 { | 50 { |
48 SCOPED_TRACE("Partial occlusion"); | 51 SCOPED_TRACE("Partial occlusion"); |
49 gfx::Rect occluded(200, 0, 800, 1000); | 52 gfx::Rect occluded(200, 0, 800, 1000); |
50 impl.AppendQuadsWithOcclusion(io_surface_layer_impl, occluded); | 53 impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); |
51 | 54 |
52 size_t partially_occluded_count = 0; | 55 size_t partially_occluded_count = 0; |
53 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( | 56 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( |
54 impl.quad_list(), | 57 impl.quad_list(), |
55 gfx::Rect(layer_size), | 58 gfx::Rect(layer_size), |
56 occluded, | 59 occluded, |
57 &partially_occluded_count); | 60 &partially_occluded_count); |
58 // The layer outputs one quad, which is partially occluded. | 61 // The layer outputs one quad, which is partially occluded. |
59 EXPECT_EQ(1u, impl.quad_list().size()); | 62 EXPECT_EQ(1u, impl.quad_list().size()); |
60 EXPECT_EQ(1u, partially_occluded_count); | 63 EXPECT_EQ(1u, partially_occluded_count); |
61 } | 64 } |
62 } | 65 } |
63 | 66 |
64 } // namespace | 67 } // namespace |
65 } // namespace cc | 68 } // namespace cc |
OLD | NEW |