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/tiles/picture_layer_tiling_set.h" | 5 #include "cc/tiles/picture_layer_tiling_set.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
| 11 #include "cc/test/fake_display_list_raster_source.h" |
11 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
13 #include "cc/test/fake_picture_layer_tiling_client.h" | 14 #include "cc/test/fake_picture_layer_tiling_client.h" |
14 #include "cc/test/fake_picture_pile_impl.h" | |
15 #include "cc/test/fake_resource_provider.h" | 15 #include "cc/test/fake_resource_provider.h" |
16 #include "cc/test/test_shared_bitmap_manager.h" | 16 #include "cc/test/test_shared_bitmap_manager.h" |
17 #include "cc/trees/layer_tree_settings.h" | 17 #include "cc/trees/layer_tree_settings.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 namespace { | 22 namespace { |
23 | 23 |
24 scoped_ptr<PictureLayerTilingSet> CreateTilingSet( | 24 scoped_ptr<PictureLayerTilingSet> CreateTilingSet( |
25 PictureLayerTilingClient* client) { | 25 PictureLayerTilingClient* client) { |
26 LayerTreeSettings defaults; | 26 LayerTreeSettings defaults; |
27 return PictureLayerTilingSet::Create( | 27 return PictureLayerTilingSet::Create( |
28 ACTIVE_TREE, client, defaults.tiling_interest_area_padding, | 28 ACTIVE_TREE, client, defaults.tiling_interest_area_padding, |
29 defaults.skewport_target_time_in_seconds, | 29 defaults.skewport_target_time_in_seconds, |
30 defaults.skewport_extrapolation_limit_in_content_pixels); | 30 defaults.skewport_extrapolation_limit_in_content_pixels); |
31 } | 31 } |
32 | 32 |
33 TEST(PictureLayerTilingSetTest, NoResources) { | 33 TEST(PictureLayerTilingSetTest, NoResources) { |
34 FakePictureLayerTilingClient client; | 34 FakePictureLayerTilingClient client; |
35 gfx::Size layer_bounds(1000, 800); | 35 gfx::Size layer_bounds(1000, 800); |
36 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | 36 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); |
37 client.SetTileSize(gfx::Size(256, 256)); | 37 client.SetTileSize(gfx::Size(256, 256)); |
38 | 38 |
39 scoped_refptr<FakePicturePileImpl> pile = | 39 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
40 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); | 40 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); |
41 | 41 |
42 set->AddTiling(1.0, pile); | 42 set->AddTiling(1.0, raster_source); |
43 set->AddTiling(1.5, pile); | 43 set->AddTiling(1.5, raster_source); |
44 set->AddTiling(2.0, pile); | 44 set->AddTiling(2.0, raster_source); |
45 | 45 |
46 float contents_scale = 2.0; | 46 float contents_scale = 2.0; |
47 gfx::Size content_bounds( | 47 gfx::Size content_bounds( |
48 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 48 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
49 gfx::Rect content_rect(content_bounds); | 49 gfx::Rect content_rect(content_bounds); |
50 | 50 |
51 Region remaining(content_rect); | 51 Region remaining(content_rect); |
52 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, | 52 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, |
53 content_rect, contents_scale); | 53 content_rect, contents_scale); |
54 for (; iter; ++iter) { | 54 for (; iter; ++iter) { |
(...skipping 12 matching lines...) Expand all Loading... |
67 FakePictureLayerTilingClient client; | 67 FakePictureLayerTilingClient client; |
68 gfx::Size layer_bounds(10, 10); | 68 gfx::Size layer_bounds(10, 10); |
69 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); | 69 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); |
70 PictureLayerTilingSet::TilingRange high_res_range(0, 0); | 70 PictureLayerTilingSet::TilingRange high_res_range(0, 0); |
71 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); | 71 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); |
72 PictureLayerTilingSet::TilingRange low_res_range(0, 0); | 72 PictureLayerTilingSet::TilingRange low_res_range(0, 0); |
73 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); | 73 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); |
74 PictureLayerTiling* high_res_tiling; | 74 PictureLayerTiling* high_res_tiling; |
75 PictureLayerTiling* low_res_tiling; | 75 PictureLayerTiling* low_res_tiling; |
76 | 76 |
77 scoped_refptr<FakePicturePileImpl> pile = | 77 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
78 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 78 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
79 | 79 |
80 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | 80 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); |
81 set->AddTiling(2.0, pile); | 81 set->AddTiling(2.0, raster_source); |
82 high_res_tiling = set->AddTiling(1.0, pile); | 82 high_res_tiling = set->AddTiling(1.0, raster_source); |
83 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 83 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
84 set->AddTiling(0.5, pile); | 84 set->AddTiling(0.5, raster_source); |
85 low_res_tiling = set->AddTiling(0.25, pile); | 85 low_res_tiling = set->AddTiling(0.25, raster_source); |
86 low_res_tiling->set_resolution(LOW_RESOLUTION); | 86 low_res_tiling->set_resolution(LOW_RESOLUTION); |
87 set->AddTiling(0.125, pile); | 87 set->AddTiling(0.125, raster_source); |
88 | 88 |
89 higher_than_high_res_range = | 89 higher_than_high_res_range = |
90 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 90 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
91 EXPECT_EQ(0u, higher_than_high_res_range.start); | 91 EXPECT_EQ(0u, higher_than_high_res_range.start); |
92 EXPECT_EQ(1u, higher_than_high_res_range.end); | 92 EXPECT_EQ(1u, higher_than_high_res_range.end); |
93 | 93 |
94 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 94 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
95 EXPECT_EQ(1u, high_res_range.start); | 95 EXPECT_EQ(1u, high_res_range.start); |
96 EXPECT_EQ(2u, high_res_range.end); | 96 EXPECT_EQ(2u, high_res_range.end); |
97 | 97 |
98 between_high_and_low_res_range = | 98 between_high_and_low_res_range = |
99 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 99 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
100 EXPECT_EQ(2u, between_high_and_low_res_range.start); | 100 EXPECT_EQ(2u, between_high_and_low_res_range.start); |
101 EXPECT_EQ(3u, between_high_and_low_res_range.end); | 101 EXPECT_EQ(3u, between_high_and_low_res_range.end); |
102 | 102 |
103 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 103 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
104 EXPECT_EQ(3u, low_res_range.start); | 104 EXPECT_EQ(3u, low_res_range.start); |
105 EXPECT_EQ(4u, low_res_range.end); | 105 EXPECT_EQ(4u, low_res_range.end); |
106 | 106 |
107 lower_than_low_res_range = | 107 lower_than_low_res_range = |
108 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 108 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
109 EXPECT_EQ(4u, lower_than_low_res_range.start); | 109 EXPECT_EQ(4u, lower_than_low_res_range.start); |
110 EXPECT_EQ(5u, lower_than_low_res_range.end); | 110 EXPECT_EQ(5u, lower_than_low_res_range.end); |
111 | 111 |
112 scoped_ptr<PictureLayerTilingSet> set_without_low_res = | 112 scoped_ptr<PictureLayerTilingSet> set_without_low_res = |
113 CreateTilingSet(&client); | 113 CreateTilingSet(&client); |
114 set_without_low_res->AddTiling(2.0, pile); | 114 set_without_low_res->AddTiling(2.0, raster_source); |
115 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); | 115 high_res_tiling = set_without_low_res->AddTiling(1.0, raster_source); |
116 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 116 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
117 set_without_low_res->AddTiling(0.5, pile); | 117 set_without_low_res->AddTiling(0.5, raster_source); |
118 set_without_low_res->AddTiling(0.25, pile); | 118 set_without_low_res->AddTiling(0.25, raster_source); |
119 | 119 |
120 higher_than_high_res_range = set_without_low_res->GetTilingRange( | 120 higher_than_high_res_range = set_without_low_res->GetTilingRange( |
121 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 121 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
122 EXPECT_EQ(0u, higher_than_high_res_range.start); | 122 EXPECT_EQ(0u, higher_than_high_res_range.start); |
123 EXPECT_EQ(1u, higher_than_high_res_range.end); | 123 EXPECT_EQ(1u, higher_than_high_res_range.end); |
124 | 124 |
125 high_res_range = | 125 high_res_range = |
126 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 126 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
127 EXPECT_EQ(1u, high_res_range.start); | 127 EXPECT_EQ(1u, high_res_range.start); |
128 EXPECT_EQ(2u, high_res_range.end); | 128 EXPECT_EQ(2u, high_res_range.end); |
129 | 129 |
130 between_high_and_low_res_range = set_without_low_res->GetTilingRange( | 130 between_high_and_low_res_range = set_without_low_res->GetTilingRange( |
131 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 131 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
132 EXPECT_EQ(2u, between_high_and_low_res_range.start); | 132 EXPECT_EQ(2u, between_high_and_low_res_range.start); |
133 EXPECT_EQ(4u, between_high_and_low_res_range.end); | 133 EXPECT_EQ(4u, between_high_and_low_res_range.end); |
134 | 134 |
135 low_res_range = | 135 low_res_range = |
136 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 136 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
137 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); | 137 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); |
138 | 138 |
139 lower_than_low_res_range = set_without_low_res->GetTilingRange( | 139 lower_than_low_res_range = set_without_low_res->GetTilingRange( |
140 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 140 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
141 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 141 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
142 | 142 |
143 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = | 143 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = |
144 CreateTilingSet(&client); | 144 CreateTilingSet(&client); |
145 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); | 145 high_res_tiling = |
| 146 set_with_only_high_and_low_res->AddTiling(1.0, raster_source); |
146 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 147 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
147 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); | 148 low_res_tiling = |
| 149 set_with_only_high_and_low_res->AddTiling(0.5, raster_source); |
148 low_res_tiling->set_resolution(LOW_RESOLUTION); | 150 low_res_tiling->set_resolution(LOW_RESOLUTION); |
149 | 151 |
150 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( | 152 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( |
151 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 153 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
152 EXPECT_EQ(0u, | 154 EXPECT_EQ(0u, |
153 higher_than_high_res_range.end - higher_than_high_res_range.start); | 155 higher_than_high_res_range.end - higher_than_high_res_range.start); |
154 | 156 |
155 high_res_range = set_with_only_high_and_low_res->GetTilingRange( | 157 high_res_range = set_with_only_high_and_low_res->GetTilingRange( |
156 PictureLayerTilingSet::HIGH_RES); | 158 PictureLayerTilingSet::HIGH_RES); |
157 EXPECT_EQ(0u, high_res_range.start); | 159 EXPECT_EQ(0u, high_res_range.start); |
158 EXPECT_EQ(1u, high_res_range.end); | 160 EXPECT_EQ(1u, high_res_range.end); |
159 | 161 |
160 between_high_and_low_res_range = | 162 between_high_and_low_res_range = |
161 set_with_only_high_and_low_res->GetTilingRange( | 163 set_with_only_high_and_low_res->GetTilingRange( |
162 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 164 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
163 EXPECT_EQ(0u, between_high_and_low_res_range.end - | 165 EXPECT_EQ(0u, between_high_and_low_res_range.end - |
164 between_high_and_low_res_range.start); | 166 between_high_and_low_res_range.start); |
165 | 167 |
166 low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 168 low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
167 PictureLayerTilingSet::LOW_RES); | 169 PictureLayerTilingSet::LOW_RES); |
168 EXPECT_EQ(1u, low_res_range.start); | 170 EXPECT_EQ(1u, low_res_range.start); |
169 EXPECT_EQ(2u, low_res_range.end); | 171 EXPECT_EQ(2u, low_res_range.end); |
170 | 172 |
171 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 173 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
172 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 174 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
173 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 175 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
174 | 176 |
175 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = | 177 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = |
176 CreateTilingSet(&client); | 178 CreateTilingSet(&client); |
177 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); | 179 high_res_tiling = set_with_only_high_res->AddTiling(1.0, raster_source); |
178 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 180 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
179 | 181 |
180 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( | 182 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( |
181 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 183 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
182 EXPECT_EQ(0u, | 184 EXPECT_EQ(0u, |
183 higher_than_high_res_range.end - higher_than_high_res_range.start); | 185 higher_than_high_res_range.end - higher_than_high_res_range.start); |
184 | 186 |
185 high_res_range = | 187 high_res_range = |
186 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 188 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
187 EXPECT_EQ(0u, high_res_range.start); | 189 EXPECT_EQ(0u, high_res_range.start); |
(...skipping 28 matching lines...) Expand all Loading... |
216 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 218 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
217 new TestSharedBitmapManager()); | 219 new TestSharedBitmapManager()); |
218 scoped_ptr<ResourceProvider> resource_provider = | 220 scoped_ptr<ResourceProvider> resource_provider = |
219 FakeResourceProvider::Create(output_surface.get(), | 221 FakeResourceProvider::Create(output_surface.get(), |
220 shared_bitmap_manager.get()); | 222 shared_bitmap_manager.get()); |
221 | 223 |
222 FakePictureLayerTilingClient client(resource_provider.get()); | 224 FakePictureLayerTilingClient client(resource_provider.get()); |
223 client.SetTileSize(gfx::Size(256, 256)); | 225 client.SetTileSize(gfx::Size(256, 256)); |
224 gfx::Size layer_bounds(1000, 800); | 226 gfx::Size layer_bounds(1000, 800); |
225 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | 227 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); |
226 scoped_refptr<FakePicturePileImpl> pile = | 228 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
227 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 229 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
228 | 230 |
229 float scale = min_scale; | 231 float scale = min_scale; |
230 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { | 232 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { |
231 PictureLayerTiling* tiling = set->AddTiling(scale, pile); | 233 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source); |
232 tiling->set_resolution(HIGH_RESOLUTION); | 234 tiling->set_resolution(HIGH_RESOLUTION); |
233 tiling->CreateAllTilesForTesting(); | 235 tiling->CreateAllTilesForTesting(); |
234 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 236 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
235 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
236 } | 238 } |
237 | 239 |
238 float max_contents_scale = scale; | 240 float max_contents_scale = scale; |
239 gfx::Size content_bounds( | 241 gfx::Size content_bounds( |
240 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); | 242 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); |
241 gfx::Rect content_rect(content_bounds); | 243 gfx::Rect content_rect(content_bounds); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 298 |
297 TEST(PictureLayerTilingSetTest, TileSizeChange) { | 299 TEST(PictureLayerTilingSetTest, TileSizeChange) { |
298 FakePictureLayerTilingClient pending_client; | 300 FakePictureLayerTilingClient pending_client; |
299 FakePictureLayerTilingClient active_client; | 301 FakePictureLayerTilingClient active_client; |
300 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( | 302 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( |
301 PENDING_TREE, &pending_client, 1000, 1.f, 1000); | 303 PENDING_TREE, &pending_client, 1000, 1.f, 1000); |
302 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( | 304 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( |
303 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); | 305 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); |
304 | 306 |
305 gfx::Size layer_bounds(100, 100); | 307 gfx::Size layer_bounds(100, 100); |
306 scoped_refptr<FakePicturePileImpl> pile = | 308 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
307 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 309 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
308 | 310 |
309 gfx::Size tile_size1(10, 10); | 311 gfx::Size tile_size1(10, 10); |
310 gfx::Size tile_size2(30, 30); | 312 gfx::Size tile_size2(30, 30); |
311 gfx::Size tile_size3(20, 20); | 313 gfx::Size tile_size3(20, 20); |
312 | 314 |
313 pending_client.SetTileSize(tile_size1); | 315 pending_client.SetTileSize(tile_size1); |
314 pending_set->AddTiling(1.f, pile); | 316 pending_set->AddTiling(1.f, raster_source); |
315 // New tilings get the correct tile size. | 317 // New tilings get the correct tile size. |
316 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); | 318 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); |
317 | 319 |
318 // Set some expected things for the tiling set to function. | 320 // Set some expected things for the tiling set to function. |
319 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 321 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
320 active_client.set_twin_tiling_set(pending_set.get()); | 322 active_client.set_twin_tiling_set(pending_set.get()); |
321 | 323 |
322 // Set a priority rect so we get tiles. | 324 // Set a priority rect so we get tiles. |
323 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, | 325 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, |
324 Occlusion(), false); | 326 Occlusion(), false); |
325 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); | 327 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); |
326 | 328 |
327 // The tiles should get the correct size. | 329 // The tiles should get the correct size. |
328 std::vector<Tile*> pending_tiles = | 330 std::vector<Tile*> pending_tiles = |
329 pending_set->tiling_at(0)->AllTilesForTesting(); | 331 pending_set->tiling_at(0)->AllTilesForTesting(); |
330 EXPECT_GT(pending_tiles.size(), 0u); | 332 EXPECT_GT(pending_tiles.size(), 0u); |
331 for (const auto& tile : pending_tiles) | 333 for (const auto& tile : pending_tiles) |
332 EXPECT_EQ(tile_size1, tile->content_rect().size()); | 334 EXPECT_EQ(tile_size1, tile->content_rect().size()); |
333 | 335 |
334 // Update to a new source frame with a new tile size. | 336 // Update to a new source frame with a new tile size. |
335 // Note that setting a new raster source can typically only happen after | 337 // Note that setting a new raster source can typically only happen after |
336 // activation, since we can't set the raster source twice on the pending tree | 338 // activation, since we can't set the raster source twice on the pending tree |
337 // without activating. For test, just remove and add a new tiling instead. | 339 // without activating. For test, just remove and add a new tiling instead. |
338 pending_set->RemoveAllTilings(); | 340 pending_set->RemoveAllTilings(); |
339 pending_set->AddTiling(1.f, pile); | 341 pending_set->AddTiling(1.f, raster_source); |
340 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 342 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
341 pending_client.SetTileSize(tile_size2); | 343 pending_client.SetTileSize(tile_size2); |
342 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), | 344 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), |
343 1.f, 1.f); | 345 Region(), 1.f, 1.f); |
344 // The tiling should get the correct tile size. | 346 // The tiling should get the correct tile size. |
345 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 347 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
346 | 348 |
347 // Set a priority rect so we get tiles. | 349 // Set a priority rect so we get tiles. |
348 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, | 350 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, |
349 Occlusion(), false); | 351 Occlusion(), false); |
350 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | 352 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); |
351 | 353 |
352 // Tiles should have the new correct size. | 354 // Tiles should have the new correct size. |
353 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 355 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
354 EXPECT_GT(pending_tiles.size(), 0u); | 356 EXPECT_GT(pending_tiles.size(), 0u); |
355 for (const auto& tile : pending_tiles) | 357 for (const auto& tile : pending_tiles) |
356 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 358 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
357 | 359 |
358 // Clone from the pending to the active tree. | 360 // Clone from the pending to the active tree. |
359 active_client.SetTileSize(tile_size2); | 361 active_client.SetTileSize(tile_size2); |
360 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 362 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
361 pile.get(), pending_set.get(), Region(), 1.f, 1.f); | 363 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); |
362 // The active tiling should get the right tile size. | 364 // The active tiling should get the right tile size. |
363 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); | 365 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); |
364 | 366 |
365 // Cloned tiles should have the right size. | 367 // Cloned tiles should have the right size. |
366 std::vector<Tile*> active_tiles = | 368 std::vector<Tile*> active_tiles = |
367 active_set->tiling_at(0)->AllTilesForTesting(); | 369 active_set->tiling_at(0)->AllTilesForTesting(); |
368 EXPECT_GT(active_tiles.size(), 0u); | 370 EXPECT_GT(active_tiles.size(), 0u); |
369 for (const auto& tile : active_tiles) | 371 for (const auto& tile : active_tiles) |
370 EXPECT_EQ(tile_size2, tile->content_rect().size()); | 372 EXPECT_EQ(tile_size2, tile->content_rect().size()); |
371 | 373 |
372 // A new source frame with a new tile size. | 374 // A new source frame with a new tile size. |
373 pending_client.SetTileSize(tile_size3); | 375 pending_client.SetTileSize(tile_size3); |
374 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), | 376 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), |
375 1.f, 1.f); | 377 Region(), 1.f, 1.f); |
376 // The tiling gets the new size correctly. | 378 // The tiling gets the new size correctly. |
377 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 379 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
378 | 380 |
379 // Set a priority rect so we get tiles. | 381 // Set a priority rect so we get tiles. |
380 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, | 382 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, |
381 Occlusion(), false); | 383 Occlusion(), false); |
382 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | 384 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); |
383 | 385 |
384 // Tiles are resized for the new size. | 386 // Tiles are resized for the new size. |
385 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | 387 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); |
386 EXPECT_GT(pending_tiles.size(), 0u); | 388 EXPECT_GT(pending_tiles.size(), 0u); |
387 for (const auto& tile : pending_tiles) | 389 for (const auto& tile : pending_tiles) |
388 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 390 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
389 | 391 |
390 // Now we activate with a different tile size for the active tiling. | 392 // Now we activate with a different tile size for the active tiling. |
391 active_client.SetTileSize(tile_size3); | 393 active_client.SetTileSize(tile_size3); |
392 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 394 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
393 pile.get(), pending_set.get(), Region(), 1.f, 1.f); | 395 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f); |
394 // The active tiling changes its tile size. | 396 // The active tiling changes its tile size. |
395 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); | 397 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); |
396 | 398 |
397 // And its tiles are resized. | 399 // And its tiles are resized. |
398 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); | 400 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); |
399 EXPECT_GT(active_tiles.size(), 0u); | 401 EXPECT_GT(active_tiles.size(), 0u); |
400 for (const auto& tile : active_tiles) | 402 for (const auto& tile : active_tiles) |
401 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 403 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
402 } | 404 } |
403 | 405 |
404 TEST(PictureLayerTilingSetTest, MaxContentScale) { | 406 TEST(PictureLayerTilingSetTest, MaxContentScale) { |
405 FakePictureLayerTilingClient pending_client; | 407 FakePictureLayerTilingClient pending_client; |
406 FakePictureLayerTilingClient active_client; | 408 FakePictureLayerTilingClient active_client; |
407 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( | 409 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( |
408 PENDING_TREE, &pending_client, 1000, 1.f, 1000); | 410 PENDING_TREE, &pending_client, 1000, 1.f, 1000); |
409 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( | 411 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( |
410 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); | 412 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); |
411 | 413 |
412 gfx::Size layer_bounds(100, 105); | 414 gfx::Size layer_bounds(100, 105); |
413 scoped_refptr<FakePicturePileImpl> pile = | 415 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
414 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); | 416 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); |
415 | 417 |
416 // Tilings can be added of any scale, the tiling client can controls this. | 418 // Tilings can be added of any scale, the tiling client can controls this. |
417 pending_set->AddTiling(1.f, pile); | 419 pending_set->AddTiling(1.f, raster_source); |
418 pending_set->AddTiling(2.f, pile); | 420 pending_set->AddTiling(2.f, raster_source); |
419 pending_set->AddTiling(3.f, pile); | 421 pending_set->AddTiling(3.f, raster_source); |
420 | 422 |
421 // Set some expected things for the tiling set to function. | 423 // Set some expected things for the tiling set to function. |
422 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 424 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
423 active_client.set_twin_tiling_set(pending_set.get()); | 425 active_client.set_twin_tiling_set(pending_set.get()); |
424 | 426 |
425 // Update to a new source frame with a max content scale that is larger than | 427 // Update to a new source frame with a max content scale that is larger than |
426 // everything. | 428 // everything. |
427 float max_content_scale = 3.f; | 429 float max_content_scale = 3.f; |
428 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( | 430 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( |
429 pile.get(), Region(), 1.f, max_content_scale); | 431 raster_source.get(), Region(), 1.f, max_content_scale); |
430 | 432 |
431 // All the tilings are there still. | 433 // All the tilings are there still. |
432 EXPECT_EQ(3u, pending_set->num_tilings()); | 434 EXPECT_EQ(3u, pending_set->num_tilings()); |
433 | 435 |
434 // Clone from the pending to the active tree with the same max content size. | 436 // Clone from the pending to the active tree with the same max content size. |
435 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 437 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
436 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 438 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale); |
437 // All the tilings are on the active tree. | 439 // All the tilings are on the active tree. |
438 EXPECT_EQ(3u, active_set->num_tilings()); | 440 EXPECT_EQ(3u, active_set->num_tilings()); |
439 | 441 |
440 // Update to a new source frame with a max content scale that will drop one | 442 // Update to a new source frame with a max content scale that will drop one |
441 // tiling. | 443 // tiling. |
442 max_content_scale = 2.9f; | 444 max_content_scale = 2.9f; |
443 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( | 445 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( |
444 pile.get(), Region(), 1.f, max_content_scale); | 446 raster_source.get(), Region(), 1.f, max_content_scale); |
445 // All the tilings are there still. | 447 // All the tilings are there still. |
446 EXPECT_EQ(2u, pending_set->num_tilings()); | 448 EXPECT_EQ(2u, pending_set->num_tilings()); |
447 | 449 |
448 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | 450 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); |
449 | 451 |
450 // Clone from the pending to the active tree with the same max content size. | 452 // Clone from the pending to the active tree with the same max content size. |
451 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 453 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
452 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 454 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale); |
453 // All the tilings are on the active tree. | 455 // All the tilings are on the active tree. |
454 EXPECT_EQ(2u, active_set->num_tilings()); | 456 EXPECT_EQ(2u, active_set->num_tilings()); |
455 } | 457 } |
456 | 458 |
457 } // namespace | 459 } // namespace |
458 } // namespace cc | 460 } // namespace cc |
OLD | NEW |