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/resources/picture_layer_tiling_set.h" | 5 #include "cc/resources/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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 101 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
102 EXPECT_EQ(3u, low_res_range.start); | 102 EXPECT_EQ(3u, low_res_range.start); |
103 EXPECT_EQ(4u, low_res_range.end); | 103 EXPECT_EQ(4u, low_res_range.end); |
104 | 104 |
105 lower_than_low_res_range = | 105 lower_than_low_res_range = |
106 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 106 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
107 EXPECT_EQ(4u, lower_than_low_res_range.start); | 107 EXPECT_EQ(4u, lower_than_low_res_range.start); |
108 EXPECT_EQ(5u, lower_than_low_res_range.end); | 108 EXPECT_EQ(5u, lower_than_low_res_range.end); |
109 | 109 |
110 auto set_without_low_res = CreateTilingSet(&client); | 110 scoped_ptr<PictureLayerTilingSet> set_without_low_res = |
| 111 CreateTilingSet(&client); |
111 set_without_low_res->AddTiling(2.0, pile); | 112 set_without_low_res->AddTiling(2.0, pile); |
112 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); | 113 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); |
113 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 114 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
114 set_without_low_res->AddTiling(0.5, pile); | 115 set_without_low_res->AddTiling(0.5, pile); |
115 set_without_low_res->AddTiling(0.25, pile); | 116 set_without_low_res->AddTiling(0.25, pile); |
116 | 117 |
117 higher_than_high_res_range = set_without_low_res->GetTilingRange( | 118 higher_than_high_res_range = set_without_low_res->GetTilingRange( |
118 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 119 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
119 EXPECT_EQ(0u, higher_than_high_res_range.start); | 120 EXPECT_EQ(0u, higher_than_high_res_range.start); |
120 EXPECT_EQ(1u, higher_than_high_res_range.end); | 121 EXPECT_EQ(1u, higher_than_high_res_range.end); |
121 | 122 |
122 high_res_range = | 123 high_res_range = |
123 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 124 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
124 EXPECT_EQ(1u, high_res_range.start); | 125 EXPECT_EQ(1u, high_res_range.start); |
125 EXPECT_EQ(2u, high_res_range.end); | 126 EXPECT_EQ(2u, high_res_range.end); |
126 | 127 |
127 between_high_and_low_res_range = set_without_low_res->GetTilingRange( | 128 between_high_and_low_res_range = set_without_low_res->GetTilingRange( |
128 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 129 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
129 EXPECT_EQ(2u, between_high_and_low_res_range.start); | 130 EXPECT_EQ(2u, between_high_and_low_res_range.start); |
130 EXPECT_EQ(4u, between_high_and_low_res_range.end); | 131 EXPECT_EQ(4u, between_high_and_low_res_range.end); |
131 | 132 |
132 low_res_range = | 133 low_res_range = |
133 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 134 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
134 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); | 135 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); |
135 | 136 |
136 lower_than_low_res_range = set_without_low_res->GetTilingRange( | 137 lower_than_low_res_range = set_without_low_res->GetTilingRange( |
137 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 138 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
138 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 139 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
139 | 140 |
140 auto set_with_only_high_and_low_res = CreateTilingSet(&client); | 141 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = |
| 142 CreateTilingSet(&client); |
141 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); | 143 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); |
142 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 144 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
143 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); | 145 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); |
144 low_res_tiling->set_resolution(LOW_RESOLUTION); | 146 low_res_tiling->set_resolution(LOW_RESOLUTION); |
145 | 147 |
146 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( | 148 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( |
147 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 149 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
148 EXPECT_EQ(0u, | 150 EXPECT_EQ(0u, |
149 higher_than_high_res_range.end - higher_than_high_res_range.start); | 151 higher_than_high_res_range.end - higher_than_high_res_range.start); |
150 | 152 |
(...skipping 10 matching lines...) Expand all Loading... |
161 | 163 |
162 low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 164 low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
163 PictureLayerTilingSet::LOW_RES); | 165 PictureLayerTilingSet::LOW_RES); |
164 EXPECT_EQ(1u, low_res_range.start); | 166 EXPECT_EQ(1u, low_res_range.start); |
165 EXPECT_EQ(2u, low_res_range.end); | 167 EXPECT_EQ(2u, low_res_range.end); |
166 | 168 |
167 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 169 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
168 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 170 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
169 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 171 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
170 | 172 |
171 auto set_with_only_high_res = CreateTilingSet(&client); | 173 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = |
| 174 CreateTilingSet(&client); |
172 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); | 175 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); |
173 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 176 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
174 | 177 |
175 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( | 178 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( |
176 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 179 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
177 EXPECT_EQ(0u, | 180 EXPECT_EQ(0u, |
178 higher_than_high_res_range.end - higher_than_high_res_range.start); | 181 higher_than_high_res_range.end - higher_than_high_res_range.start); |
179 | 182 |
180 high_res_range = | 183 high_res_range = |
181 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 184 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 runTest(10, 1.f, 1.f, 5.f, 5.f); | 294 runTest(10, 1.f, 1.f, 5.f, 5.f); |
292 } | 295 } |
293 | 296 |
294 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { | 297 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { |
295 runTest(10, 1.f, 1.f, 4.5f, 5.f); | 298 runTest(10, 1.f, 1.f, 4.5f, 5.f); |
296 } | 299 } |
297 | 300 |
298 TEST(PictureLayerTilingSetTest, TileSizeChange) { | 301 TEST(PictureLayerTilingSetTest, TileSizeChange) { |
299 FakePictureLayerTilingClient pending_client; | 302 FakePictureLayerTilingClient pending_client; |
300 FakePictureLayerTilingClient active_client; | 303 FakePictureLayerTilingClient active_client; |
301 auto pending_set = | 304 scoped_ptr<PictureLayerTilingSet> pending_set = |
302 PictureLayerTilingSet::Create(&pending_client, 1000, 1.f, 1000); | 305 PictureLayerTilingSet::Create(&pending_client, 1000, 1.f, 1000); |
303 auto active_set = | 306 scoped_ptr<PictureLayerTilingSet> active_set = |
304 PictureLayerTilingSet::Create(&active_client, 1000, 1.f, 1000); | 307 PictureLayerTilingSet::Create(&active_client, 1000, 1.f, 1000); |
305 | 308 |
306 gfx::Size layer_bounds(100, 100); | 309 gfx::Size layer_bounds(100, 100); |
307 scoped_refptr<FakePicturePileImpl> pile = | 310 scoped_refptr<FakePicturePileImpl> pile = |
308 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 311 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
309 | 312 |
310 gfx::Size tile_size1(10, 10); | 313 gfx::Size tile_size1(10, 10); |
311 gfx::Size tile_size2(30, 30); | 314 gfx::Size tile_size2(30, 30); |
312 gfx::Size tile_size3(20, 20); | 315 gfx::Size tile_size3(20, 20); |
313 | 316 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // And its tiles are resized. | 395 // And its tiles are resized. |
393 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); | 396 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); |
394 EXPECT_GT(active_tiles.size(), 0u); | 397 EXPECT_GT(active_tiles.size(), 0u); |
395 for (const auto& tile : active_tiles) | 398 for (const auto& tile : active_tiles) |
396 EXPECT_EQ(tile_size3, tile->content_rect().size()); | 399 EXPECT_EQ(tile_size3, tile->content_rect().size()); |
397 } | 400 } |
398 | 401 |
399 TEST(PictureLayerTilingSetTest, MaxContentScale) { | 402 TEST(PictureLayerTilingSetTest, MaxContentScale) { |
400 FakePictureLayerTilingClient pending_client; | 403 FakePictureLayerTilingClient pending_client; |
401 FakePictureLayerTilingClient active_client; | 404 FakePictureLayerTilingClient active_client; |
402 auto pending_set = | 405 scoped_ptr<PictureLayerTilingSet> pending_set = |
403 PictureLayerTilingSet::Create(&pending_client, 1000, 1.f, 1000); | 406 PictureLayerTilingSet::Create(&pending_client, 1000, 1.f, 1000); |
404 auto active_set = | 407 scoped_ptr<PictureLayerTilingSet> active_set = |
405 PictureLayerTilingSet::Create(&active_client, 1000, 1.f, 1000); | 408 PictureLayerTilingSet::Create(&active_client, 1000, 1.f, 1000); |
406 | 409 |
407 gfx::Size layer_bounds(100, 105); | 410 gfx::Size layer_bounds(100, 105); |
408 scoped_refptr<FakePicturePileImpl> pile = | 411 scoped_refptr<FakePicturePileImpl> pile = |
409 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); | 412 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); |
410 | 413 |
411 // Tilings can be added of any scale, the tiling client can controls this. | 414 // Tilings can be added of any scale, the tiling client can controls this. |
412 pending_set->AddTiling(1.f, pile); | 415 pending_set->AddTiling(1.f, pile); |
413 pending_set->AddTiling(2.f, pile); | 416 pending_set->AddTiling(2.f, pile); |
414 pending_set->AddTiling(3.f, pile); | 417 pending_set->AddTiling(3.f, pile); |
(...skipping 28 matching lines...) Expand all Loading... |
443 | 446 |
444 // Clone from the pending to the active tree with the same max content size. | 447 // Clone from the pending to the active tree with the same max content size. |
445 active_set->UpdateTilingsToCurrentRasterSource( | 448 active_set->UpdateTilingsToCurrentRasterSource( |
446 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 449 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); |
447 // All the tilings are on the active tree. | 450 // All the tilings are on the active tree. |
448 EXPECT_EQ(2u, active_set->num_tilings()); | 451 EXPECT_EQ(2u, active_set->num_tilings()); |
449 } | 452 } |
450 | 453 |
451 } // namespace | 454 } // namespace |
452 } // namespace cc | 455 } // namespace cc |
OLD | NEW |