| 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" |
| 11 #include "cc/trees/layer_tree_host_common.h" | 11 #include "cc/trees/layer_tree_host_common.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using testing::UnorderedElementsAre; | 15 using testing::UnorderedElementsAre; |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 20 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
| 21 | 21 |
| 22 TEST(SurfaceLayerImplTest, OcclusionWithDeviceScaleFactor) { | 22 TEST(SurfaceLayerImplTest, OcclusionWithDeviceScaleFactor) { |
| 23 float device_scale_factor = 1.25f; | 23 float device_scale_factor = 1.33f; |
| 24 | 24 |
| 25 gfx::Size layer_size(1000, 1000); | 25 gfx::Size layer_size(512, 512); |
| 26 gfx::Size scaled_surface_size( | 26 gfx::Size scaled_surface_size( |
| 27 gfx::ScaleToCeiledSize(layer_size, device_scale_factor)); | 27 gfx::ScaleToCeiledSize(layer_size, device_scale_factor)); |
| 28 gfx::Size viewport_size(1250, 1325); | 28 gfx::Size viewport_size(681, 750); |
| 29 | 29 |
| 30 const LocalSurfaceId kArbitraryLocalSurfaceId( | 30 const LocalSurfaceId kArbitraryLocalSurfaceId( |
| 31 9, base::UnguessableToken::Create()); | 31 9, base::UnguessableToken::Create()); |
| 32 | 32 |
| 33 LayerTestCommon::LayerImplTest impl; | 33 LayerTestCommon::LayerImplTest impl; |
| 34 | 34 |
| 35 SurfaceLayerImpl* surface_layer_impl = | 35 SurfaceLayerImpl* surface_layer_impl = |
| 36 impl.AddChildToRoot<SurfaceLayerImpl>(); | 36 impl.AddChildToRoot<SurfaceLayerImpl>(); |
| 37 surface_layer_impl->SetBounds(layer_size); | 37 surface_layer_impl->SetBounds(layer_size); |
| 38 surface_layer_impl->SetDrawsContent(true); | 38 surface_layer_impl->SetDrawsContent(true); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 60 SCOPED_TRACE("Full occlusion"); | 60 SCOPED_TRACE("Full occlusion"); |
| 61 gfx::Rect occluded(scaled_surface_size); | 61 gfx::Rect occluded(scaled_surface_size); |
| 62 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | 62 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); |
| 63 | 63 |
| 64 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); | 64 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); |
| 65 EXPECT_EQ(impl.quad_list().size(), 0u); | 65 EXPECT_EQ(impl.quad_list().size(), 0u); |
| 66 } | 66 } |
| 67 | 67 |
| 68 { | 68 { |
| 69 SCOPED_TRACE("Partial occlusion"); | 69 SCOPED_TRACE("Partial occlusion"); |
| 70 gfx::Rect occluded(gfx::ScaleToEnclosingRect(gfx::Rect(200, 0, 800, 1000), | 70 gfx::Rect occluded(gfx::ScaleToEnclosingRect(gfx::Rect(200, 0, 312, 512), |
| 71 device_scale_factor)); | 71 device_scale_factor)); |
| 72 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | 72 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); |
| 73 | 73 |
| 74 size_t partially_occluded_count = 0; | 74 size_t partially_occluded_count = 0; |
| 75 LayerTestCommon::VerifyQuadsAreOccluded(impl.quad_list(), occluded, | 75 LayerTestCommon::VerifyQuadsAreOccluded(impl.quad_list(), occluded, |
| 76 &partially_occluded_count); | 76 &partially_occluded_count); |
| 77 // The layer outputs one quad, which is partially occluded. | 77 // The layer outputs one quad, which is partially occluded. |
| 78 EXPECT_EQ(1u, impl.quad_list().size()); | 78 EXPECT_EQ(1u, impl.quad_list().size()); |
| 79 EXPECT_EQ(1u, partially_occluded_count); | 79 EXPECT_EQ(1u, partially_occluded_count); |
| 80 } | 80 } |
| 81 { | 81 { |
| 82 SCOPED_TRACE("No outside occlusion"); | 82 SCOPED_TRACE("No outside occlusion"); |
| 83 gfx::Rect occluded(gfx::ScaleToEnclosingRect(gfx::Rect(0, 1000, 1250, 300), | 83 gfx::Rect occluded(gfx::ScaleToEnclosingRect(gfx::Rect(0, 681, 681, 69), |
| 84 device_scale_factor)); | 84 device_scale_factor)); |
| 85 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | 85 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); |
| 86 | 86 |
| 87 LayerTestCommon::VerifyQuadsExactlyCoverRect( | 87 LayerTestCommon::VerifyQuadsExactlyCoverRect( |
| 88 impl.quad_list(), gfx::Rect(scaled_surface_size)); | 88 impl.quad_list(), gfx::Rect(scaled_surface_size)); |
| 89 EXPECT_EQ(1u, impl.quad_list().size()); | 89 EXPECT_EQ(1u, impl.quad_list().size()); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST(SurfaceLayerImplTest, Occlusion) { | 93 TEST(SurfaceLayerImplTest, Occlusion) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 ASSERT_TRUE(surface_draw_quad1); | 341 ASSERT_TRUE(surface_draw_quad1); |
| 342 | 342 |
| 343 EXPECT_EQ(SurfaceDrawQuadType::PRIMARY, | 343 EXPECT_EQ(SurfaceDrawQuadType::PRIMARY, |
| 344 surface_draw_quad1->surface_draw_quad_type); | 344 surface_draw_quad1->surface_draw_quad_type); |
| 345 EXPECT_EQ(surface_id1, surface_draw_quad1->surface_id); | 345 EXPECT_EQ(surface_id1, surface_draw_quad1->surface_id); |
| 346 EXPECT_FALSE(surface_draw_quad1->fallback_quad); | 346 EXPECT_FALSE(surface_draw_quad1->fallback_quad); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace | 349 } // namespace |
| 350 } // namespace cc | 350 } // namespace cc |
| OLD | NEW |