| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/picture_layer_tiling_set.h" | 5 #include "cc/picture_layer_tiling_set.h" |
| 6 | 6 |
| 7 #include "cc/resource_pool.h" | 7 #include "cc/resource_pool.h" |
| 8 #include "cc/resource_provider.h" | 8 #include "cc/resource_provider.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_picture_layer_tiling_client.h" | 10 #include "cc/test/fake_picture_layer_tiling_client.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 float contents_scale = 2.0; | 30 float contents_scale = 2.0; |
| 31 gfx::Size content_bounds( | 31 gfx::Size content_bounds( |
| 32 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 32 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
| 33 gfx::Rect content_rect(gfx::Point(), content_bounds); | 33 gfx::Rect content_rect(gfx::Point(), content_bounds); |
| 34 | 34 |
| 35 Region remaining(content_rect); | 35 Region remaining(content_rect); |
| 36 PictureLayerTilingSet::Iterator iter( | 36 PictureLayerTilingSet::Iterator iter( |
| 37 &set, | 37 &set, |
| 38 contents_scale, | 38 contents_scale, |
| 39 content_rect, | 39 content_rect, |
| 40 contents_scale); | 40 contents_scale, |
| 41 PictureLayerTiling::LayerDeviceAlignmentUnknown); |
| 41 for (; iter; ++iter) { | 42 for (; iter; ++iter) { |
| 42 gfx::Rect geometry_rect = iter.geometry_rect(); | 43 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 43 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | 44 EXPECT_TRUE(content_rect.Contains(geometry_rect)); |
| 44 ASSERT_TRUE(remaining.Contains(geometry_rect)); | 45 ASSERT_TRUE(remaining.Contains(geometry_rect)); |
| 45 remaining.Subtract(geometry_rect); | 46 remaining.Subtract(geometry_rect); |
| 46 | 47 |
| 47 // No tiles have resources, so no iter represents a real tile. | 48 // No tiles have resources, so no iter represents a real tile. |
| 48 EXPECT_FALSE(*iter); | 49 EXPECT_FALSE(*iter); |
| 49 } | 50 } |
| 50 EXPECT_TRUE(remaining.IsEmpty()); | 51 EXPECT_TRUE(remaining.IsEmpty()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 float max_contents_scale = scale; | 89 float max_contents_scale = scale; |
| 89 gfx::Size content_bounds( | 90 gfx::Size content_bounds( |
| 90 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); | 91 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); |
| 91 gfx::Rect content_rect(gfx::Point(), content_bounds); | 92 gfx::Rect content_rect(gfx::Point(), content_bounds); |
| 92 | 93 |
| 93 Region remaining(content_rect); | 94 Region remaining(content_rect); |
| 94 PictureLayerTilingSet::Iterator iter( | 95 PictureLayerTilingSet::Iterator iter( |
| 95 &set, | 96 &set, |
| 96 max_contents_scale, | 97 max_contents_scale, |
| 97 content_rect, | 98 content_rect, |
| 98 ideal_contents_scale); | 99 ideal_contents_scale, |
| 100 PictureLayerTiling::LayerDeviceAlignmentUnknown); |
| 99 for (; iter; ++iter) { | 101 for (; iter; ++iter) { |
| 100 gfx::Rect geometry_rect = iter.geometry_rect(); | 102 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 101 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | 103 EXPECT_TRUE(content_rect.Contains(geometry_rect)); |
| 102 ASSERT_TRUE(remaining.Contains(geometry_rect)); | 104 ASSERT_TRUE(remaining.Contains(geometry_rect)); |
| 103 remaining.Subtract(geometry_rect); | 105 remaining.Subtract(geometry_rect); |
| 104 | 106 |
| 105 float scale = iter.CurrentTiling()->contents_scale(); | 107 float scale = iter.CurrentTiling()->contents_scale(); |
| 106 EXPECT_EQ(expected_scale, scale); | 108 EXPECT_EQ(expected_scale, scale); |
| 107 | 109 |
| 108 if (num_tilings) | 110 if (num_tilings) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_Equal) { | 144 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_Equal) { |
| 143 runTest(10, 1.f, 1.f, 5.f, 5.f); | 145 runTest(10, 1.f, 1.f, 5.f, 5.f); |
| 144 } | 146 } |
| 145 | 147 |
| 146 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { | 148 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { |
| 147 runTest(10, 1.f, 1.f, 4.5f, 5.f); | 149 runTest(10, 1.f, 1.f, 4.5f, 5.f); |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace | 152 } // namespace |
| 151 } // namespace cc | 153 } // namespace cc |
| OLD | NEW |