Chromium Code Reviews| 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 "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 17 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
| 17 | 18 |
| 19 TEST(SurfaceLayerImplTest, OcclusionWithDSF) { | |
| 20 float device_scale_factor = 1.25f; | |
| 21 | |
| 22 gfx::Size layer_size(1000, 1000); | |
| 23 gfx::Size scaled_layer_size( | |
|
weiliangc
2017/02/09 18:25:32
nit: Rename to scaled_surface_size, since scaled_l
malaykeshav
2017/02/09 21:00:41
done
| |
| 24 gfx::ScaleToCeiledSize(layer_size, device_scale_factor)); | |
| 25 gfx::Size viewport_size(1250, 1250); | |
| 26 | |
| 27 const LocalSurfaceId kArbitraryLocalSurfaceId( | |
| 28 9, base::UnguessableToken::Create()); | |
| 29 | |
| 30 LayerTestCommon::LayerImplTest impl; | |
| 31 | |
| 32 SurfaceLayerImpl* surface_layer_impl = | |
| 33 impl.AddChildToRoot<SurfaceLayerImpl>(); | |
| 34 surface_layer_impl->SetBounds(layer_size); | |
| 35 surface_layer_impl->SetDrawsContent(true); | |
| 36 SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalSurfaceId); | |
| 37 surface_layer_impl->SetSurfaceInfo( | |
| 38 SurfaceInfo(surface_id, device_scale_factor, scaled_layer_size)); | |
| 39 | |
| 40 LayerImplList layer_list; | |
| 41 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
| 42 impl.root_layer_for_testing(), viewport_size, device_scale_factor, | |
| 43 &layer_list); | |
| 44 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | |
| 45 | |
| 46 { | |
| 47 SCOPED_TRACE("No occlusion"); | |
| 48 gfx::Rect occluded; | |
| 49 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | |
| 50 | |
| 51 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | |
| 52 gfx::Rect(scaled_layer_size)); | |
| 53 EXPECT_EQ(1u, impl.quad_list().size()); | |
| 54 } | |
| 55 | |
| 56 { | |
| 57 SCOPED_TRACE("Full occlusion"); | |
| 58 gfx::Rect occluded(scaled_layer_size); | |
| 59 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | |
| 60 | |
| 61 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); | |
| 62 EXPECT_EQ(impl.quad_list().size(), 0u); | |
| 63 } | |
| 64 | |
| 65 { | |
| 66 SCOPED_TRACE("Partial occlusion"); | |
| 67 gfx::Rect occluded(gfx::ScaleToEnclosedRect(gfx::Rect(200, 0, 800, 1000), | |
|
weiliangc
2017/02/09 18:25:32
I don't think this test really reflects the bug.
malaykeshav
2017/02/09 21:00:41
Yes. But without the patch these 3 tests failed as
| |
| 68 device_scale_factor)); | |
| 69 impl.AppendQuadsWithOcclusion(surface_layer_impl, occluded); | |
| 70 | |
| 71 size_t partially_occluded_count = 0; | |
| 72 LayerTestCommon::VerifyQuadsAreOccluded(impl.quad_list(), occluded, | |
| 73 &partially_occluded_count); | |
| 74 // The layer outputs one quad, which is partially occluded. | |
| 75 EXPECT_EQ(1u, impl.quad_list().size()); | |
| 76 EXPECT_EQ(1u, partially_occluded_count); | |
| 77 } | |
| 78 } | |
| 79 | |
| 18 TEST(SurfaceLayerImplTest, Occlusion) { | 80 TEST(SurfaceLayerImplTest, Occlusion) { |
| 19 gfx::Size layer_size(1000, 1000); | 81 gfx::Size layer_size(1000, 1000); |
| 20 gfx::Size viewport_size(1000, 1000); | 82 gfx::Size viewport_size(1000, 1000); |
| 21 const LocalSurfaceId kArbitraryLocalSurfaceId( | 83 const LocalSurfaceId kArbitraryLocalSurfaceId( |
| 22 9, base::UnguessableToken::Create()); | 84 9, base::UnguessableToken::Create()); |
| 23 | 85 |
| 24 LayerTestCommon::LayerImplTest impl; | 86 LayerTestCommon::LayerImplTest impl; |
| 25 | 87 |
| 26 SurfaceLayerImpl* surface_layer_impl = | 88 SurfaceLayerImpl* surface_layer_impl = |
| 27 impl.AddChildToRoot<SurfaceLayerImpl>(); | 89 impl.AddChildToRoot<SurfaceLayerImpl>(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 gfx::RectF layer_rect(layer_size.width(), layer_size.height()); | 182 gfx::RectF layer_rect(layer_size.width(), layer_size.height()); |
| 121 gfx::RectF transformed_layer_rect = | 183 gfx::RectF transformed_layer_rect = |
| 122 MathUtil::MapClippedRect(target_space_transform, layer_rect); | 184 MathUtil::MapClippedRect(target_space_transform, layer_rect); |
| 123 | 185 |
| 124 // Check if quad rect in target space matches layer rect in target space | 186 // Check if quad rect in target space matches layer rect in target space |
| 125 EXPECT_EQ(transformed_quad_rect, transformed_layer_rect); | 187 EXPECT_EQ(transformed_quad_rect, transformed_layer_rect); |
| 126 } | 188 } |
| 127 | 189 |
| 128 } // namespace | 190 } // namespace |
| 129 } // namespace cc | 191 } // namespace cc |
| OLD | NEW |