| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/resources/picture_layer_tiling_set.h" | |
| 6 | |
| 7 #include <map> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "cc/resources/resource_provider.h" | |
| 11 #include "cc/test/fake_output_surface.h" | |
| 12 #include "cc/test/fake_output_surface_client.h" | |
| 13 #include "cc/test/fake_picture_layer_tiling_client.h" | |
| 14 #include "cc/test/fake_picture_pile_impl.h" | |
| 15 #include "cc/test/test_shared_bitmap_manager.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 #include "ui/gfx/geometry/size_conversions.h" | |
| 18 | |
| 19 namespace cc { | |
| 20 namespace { | |
| 21 | |
| 22 scoped_ptr<PictureLayerTilingSet> CreateTilingSet( | |
| 23 PictureLayerTilingClient* client) { | |
| 24 LayerTreeSettings defaults; | |
| 25 return PictureLayerTilingSet::Create( | |
| 26 ACTIVE_TREE, client, defaults.tiling_interest_area_viewport_multiplier, | |
| 27 defaults.skewport_target_time_in_seconds, | |
| 28 defaults.skewport_extrapolation_limit_in_content_pixels); | |
| 29 } | |
| 30 | |
| 31 TEST(PictureLayerTilingSetTest, NoResources) { | |
| 32 FakePictureLayerTilingClient client; | |
| 33 gfx::Size layer_bounds(1000, 800); | |
| 34 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | |
| 35 client.SetTileSize(gfx::Size(256, 256)); | |
| 36 | |
| 37 scoped_refptr<FakePicturePileImpl> pile = | |
| 38 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); | |
| 39 | |
| 40 set->AddTiling(1.0, pile); | |
| 41 set->AddTiling(1.5, pile); | |
| 42 set->AddTiling(2.0, pile); | |
| 43 | |
| 44 float contents_scale = 2.0; | |
| 45 gfx::Size content_bounds( | |
| 46 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | |
| 47 gfx::Rect content_rect(content_bounds); | |
| 48 | |
| 49 Region remaining(content_rect); | |
| 50 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, | |
| 51 content_rect, contents_scale); | |
| 52 for (; iter; ++iter) { | |
| 53 gfx::Rect geometry_rect = iter.geometry_rect(); | |
| 54 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | |
| 55 ASSERT_TRUE(remaining.Contains(geometry_rect)); | |
| 56 remaining.Subtract(geometry_rect); | |
| 57 | |
| 58 // No tiles have resources, so no iter represents a real tile. | |
| 59 EXPECT_FALSE(*iter); | |
| 60 } | |
| 61 EXPECT_TRUE(remaining.IsEmpty()); | |
| 62 } | |
| 63 | |
| 64 TEST(PictureLayerTilingSetTest, TilingRange) { | |
| 65 FakePictureLayerTilingClient client; | |
| 66 gfx::Size layer_bounds(10, 10); | |
| 67 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); | |
| 68 PictureLayerTilingSet::TilingRange high_res_range(0, 0); | |
| 69 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); | |
| 70 PictureLayerTilingSet::TilingRange low_res_range(0, 0); | |
| 71 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); | |
| 72 PictureLayerTiling* high_res_tiling; | |
| 73 PictureLayerTiling* low_res_tiling; | |
| 74 | |
| 75 scoped_refptr<FakePicturePileImpl> pile = | |
| 76 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | |
| 77 | |
| 78 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | |
| 79 set->AddTiling(2.0, pile); | |
| 80 high_res_tiling = set->AddTiling(1.0, pile); | |
| 81 high_res_tiling->set_resolution(HIGH_RESOLUTION); | |
| 82 set->AddTiling(0.5, pile); | |
| 83 low_res_tiling = set->AddTiling(0.25, pile); | |
| 84 low_res_tiling->set_resolution(LOW_RESOLUTION); | |
| 85 set->AddTiling(0.125, pile); | |
| 86 | |
| 87 higher_than_high_res_range = | |
| 88 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | |
| 89 EXPECT_EQ(0, higher_than_high_res_range.start); | |
| 90 EXPECT_EQ(1, higher_than_high_res_range.end); | |
| 91 | |
| 92 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | |
| 93 EXPECT_EQ(1, high_res_range.start); | |
| 94 EXPECT_EQ(2, high_res_range.end); | |
| 95 | |
| 96 between_high_and_low_res_range = | |
| 97 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | |
| 98 EXPECT_EQ(2, between_high_and_low_res_range.start); | |
| 99 EXPECT_EQ(3, between_high_and_low_res_range.end); | |
| 100 | |
| 101 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); | |
| 102 EXPECT_EQ(3, low_res_range.start); | |
| 103 EXPECT_EQ(4, low_res_range.end); | |
| 104 | |
| 105 lower_than_low_res_range = | |
| 106 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); | |
| 107 EXPECT_EQ(4, lower_than_low_res_range.start); | |
| 108 EXPECT_EQ(5, lower_than_low_res_range.end); | |
| 109 | |
| 110 scoped_ptr<PictureLayerTilingSet> set_without_low_res = | |
| 111 CreateTilingSet(&client); | |
| 112 set_without_low_res->AddTiling(2.0, pile); | |
| 113 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); | |
| 114 high_res_tiling->set_resolution(HIGH_RESOLUTION); | |
| 115 set_without_low_res->AddTiling(0.5, pile); | |
| 116 set_without_low_res->AddTiling(0.25, pile); | |
| 117 | |
| 118 higher_than_high_res_range = set_without_low_res->GetTilingRange( | |
| 119 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | |
| 120 EXPECT_EQ(0, higher_than_high_res_range.start); | |
| 121 EXPECT_EQ(1, higher_than_high_res_range.end); | |
| 122 | |
| 123 high_res_range = | |
| 124 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | |
| 125 EXPECT_EQ(1, high_res_range.start); | |
| 126 EXPECT_EQ(2, high_res_range.end); | |
| 127 | |
| 128 between_high_and_low_res_range = set_without_low_res->GetTilingRange( | |
| 129 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | |
| 130 EXPECT_EQ(2, between_high_and_low_res_range.start); | |
| 131 EXPECT_EQ(4, between_high_and_low_res_range.end); | |
| 132 | |
| 133 low_res_range = | |
| 134 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); | |
| 135 EXPECT_EQ(0, low_res_range.end - low_res_range.start); | |
| 136 | |
| 137 lower_than_low_res_range = set_without_low_res->GetTilingRange( | |
| 138 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | |
| 139 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); | |
| 140 | |
| 141 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = | |
| 142 CreateTilingSet(&client); | |
| 143 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); | |
| 144 high_res_tiling->set_resolution(HIGH_RESOLUTION); | |
| 145 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); | |
| 146 low_res_tiling->set_resolution(LOW_RESOLUTION); | |
| 147 | |
| 148 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( | |
| 149 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | |
| 150 EXPECT_EQ(0, | |
| 151 higher_than_high_res_range.end - higher_than_high_res_range.start); | |
| 152 | |
| 153 high_res_range = set_with_only_high_and_low_res->GetTilingRange( | |
| 154 PictureLayerTilingSet::HIGH_RES); | |
| 155 EXPECT_EQ(0, high_res_range.start); | |
| 156 EXPECT_EQ(1, high_res_range.end); | |
| 157 | |
| 158 between_high_and_low_res_range = | |
| 159 set_with_only_high_and_low_res->GetTilingRange( | |
| 160 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | |
| 161 EXPECT_EQ(0, between_high_and_low_res_range.end - | |
| 162 between_high_and_low_res_range.start); | |
| 163 | |
| 164 low_res_range = set_with_only_high_and_low_res->GetTilingRange( | |
| 165 PictureLayerTilingSet::LOW_RES); | |
| 166 EXPECT_EQ(1, low_res_range.start); | |
| 167 EXPECT_EQ(2, low_res_range.end); | |
| 168 | |
| 169 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( | |
| 170 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | |
| 171 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); | |
| 172 | |
| 173 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = | |
| 174 CreateTilingSet(&client); | |
| 175 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); | |
| 176 high_res_tiling->set_resolution(HIGH_RESOLUTION); | |
| 177 | |
| 178 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( | |
| 179 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | |
| 180 EXPECT_EQ(0, | |
| 181 higher_than_high_res_range.end - higher_than_high_res_range.start); | |
| 182 | |
| 183 high_res_range = | |
| 184 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | |
| 185 EXPECT_EQ(0, high_res_range.start); | |
| 186 EXPECT_EQ(1, high_res_range.end); | |
| 187 | |
| 188 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange( | |
| 189 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | |
| 190 EXPECT_EQ(0, between_high_and_low_res_range.end - | |
| 191 between_high_and_low_res_range.start); | |
| 192 | |
| 193 low_res_range = | |
| 194 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); | |
| 195 EXPECT_EQ(0, low_res_range.end - low_res_range.start); | |
| 196 | |
| 197 lower_than_low_res_range = set_with_only_high_res->GetTilingRange( | |
| 198 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | |
| 199 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); | |
| 200 } | |
| 201 | |
| 202 class PictureLayerTilingSetTestWithResources : public testing::Test { | |
| 203 public: | |
| 204 void RunTest(int num_tilings, | |
| 205 float min_scale, | |
| 206 float scale_increment, | |
| 207 float ideal_contents_scale, | |
| 208 float expected_scale) { | |
| 209 FakeOutputSurfaceClient output_surface_client; | |
| 210 scoped_ptr<FakeOutputSurface> output_surface = | |
| 211 FakeOutputSurface::Create3d(); | |
| 212 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 213 | |
| 214 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 215 new TestSharedBitmapManager()); | |
| 216 scoped_ptr<ResourceProvider> resource_provider = | |
| 217 ResourceProvider::Create(output_surface.get(), | |
| 218 shared_bitmap_manager.get(), | |
| 219 NULL, | |
| 220 NULL, | |
| 221 0, | |
| 222 false, | |
| 223 1); | |
| 224 | |
| 225 FakePictureLayerTilingClient client(resource_provider.get()); | |
| 226 client.SetTileSize(gfx::Size(256, 256)); | |
| 227 gfx::Size layer_bounds(1000, 800); | |
| 228 scoped_ptr<PictureLayerTilingSet> set = CreateTilingSet(&client); | |
| 229 scoped_refptr<FakePicturePileImpl> pile = | |
| 230 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | |
| 231 | |
| 232 float scale = min_scale; | |
| 233 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { | |
| 234 PictureLayerTiling* tiling = set->AddTiling(scale, pile); | |
| 235 tiling->CreateAllTilesForTesting(); | |
| 236 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | |
| 237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | |
| 238 } | |
| 239 | |
| 240 float max_contents_scale = scale; | |
| 241 gfx::Size content_bounds( | |
| 242 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); | |
| 243 gfx::Rect content_rect(content_bounds); | |
| 244 | |
| 245 Region remaining(content_rect); | |
| 246 PictureLayerTilingSet::CoverageIterator iter( | |
| 247 set.get(), max_contents_scale, content_rect, ideal_contents_scale); | |
| 248 for (; iter; ++iter) { | |
| 249 gfx::Rect geometry_rect = iter.geometry_rect(); | |
| 250 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | |
| 251 ASSERT_TRUE(remaining.Contains(geometry_rect)); | |
| 252 remaining.Subtract(geometry_rect); | |
| 253 | |
| 254 float scale = iter.CurrentTiling()->contents_scale(); | |
| 255 EXPECT_EQ(expected_scale, scale); | |
| 256 | |
| 257 if (num_tilings) | |
| 258 EXPECT_TRUE(*iter); | |
| 259 else | |
| 260 EXPECT_FALSE(*iter); | |
| 261 } | |
| 262 EXPECT_TRUE(remaining.IsEmpty()); | |
| 263 } | |
| 264 }; | |
| 265 | |
| 266 TEST_F(PictureLayerTilingSetTestWithResources, NoTilings) { | |
| 267 RunTest(0, 0.f, 0.f, 2.f, 0.f); | |
| 268 } | |
| 269 TEST_F(PictureLayerTilingSetTestWithResources, OneTiling_Smaller) { | |
| 270 RunTest(1, 1.f, 0.f, 2.f, 1.f); | |
| 271 } | |
| 272 TEST_F(PictureLayerTilingSetTestWithResources, OneTiling_Larger) { | |
| 273 RunTest(1, 3.f, 0.f, 2.f, 3.f); | |
| 274 } | |
| 275 TEST_F(PictureLayerTilingSetTestWithResources, TwoTilings_Smaller) { | |
| 276 RunTest(2, 1.f, 1.f, 3.f, 2.f); | |
| 277 } | |
| 278 | |
| 279 TEST_F(PictureLayerTilingSetTestWithResources, TwoTilings_SmallerEqual) { | |
| 280 RunTest(2, 1.f, 1.f, 2.f, 2.f); | |
| 281 } | |
| 282 | |
| 283 TEST_F(PictureLayerTilingSetTestWithResources, TwoTilings_LargerEqual) { | |
| 284 RunTest(2, 1.f, 1.f, 1.f, 1.f); | |
| 285 } | |
| 286 | |
| 287 TEST_F(PictureLayerTilingSetTestWithResources, TwoTilings_Larger) { | |
| 288 RunTest(2, 2.f, 8.f, 1.f, 2.f); | |
| 289 } | |
| 290 | |
| 291 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_Equal) { | |
| 292 RunTest(10, 1.f, 1.f, 5.f, 5.f); | |
| 293 } | |
| 294 | |
| 295 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { | |
| 296 RunTest(10, 1.f, 1.f, 4.5f, 5.f); | |
| 297 } | |
| 298 | |
| 299 TEST(PictureLayerTilingSetTest, TileSizeChange) { | |
| 300 FakePictureLayerTilingClient pending_client; | |
| 301 FakePictureLayerTilingClient active_client; | |
| 302 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( | |
| 303 PENDING_TREE, &pending_client, 1000, 1.f, 1000); | |
| 304 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( | |
| 305 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); | |
| 306 | |
| 307 gfx::Size layer_bounds(100, 100); | |
| 308 scoped_refptr<FakePicturePileImpl> pile = | |
| 309 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | |
| 310 | |
| 311 gfx::Size tile_size1(10, 10); | |
| 312 gfx::Size tile_size2(30, 30); | |
| 313 gfx::Size tile_size3(20, 20); | |
| 314 | |
| 315 pending_client.SetTileSize(tile_size1); | |
| 316 pending_set->AddTiling(1.f, pile); | |
| 317 // New tilings get the correct tile size. | |
| 318 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); | |
| 319 | |
| 320 // Set some expected things for the tiling set to function. | |
| 321 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | |
| 322 active_client.set_twin_tiling_set(pending_set.get()); | |
| 323 | |
| 324 // Set a priority rect so we get tiles. | |
| 325 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, | |
| 326 Occlusion(), false); | |
| 327 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); | |
| 328 | |
| 329 // The tiles should get the correct size. | |
| 330 std::vector<Tile*> pending_tiles = | |
| 331 pending_set->tiling_at(0)->AllTilesForTesting(); | |
| 332 EXPECT_GT(pending_tiles.size(), 0u); | |
| 333 for (const auto& tile : pending_tiles) | |
| 334 EXPECT_EQ(tile_size1, tile->content_rect().size()); | |
| 335 | |
| 336 // Update to a new source frame with a new tile size. | |
| 337 pending_client.SetTileSize(tile_size2); | |
| 338 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), | |
| 339 1.f, 1.f); | |
| 340 // The tiling should get the correct tile size. | |
| 341 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | |
| 342 | |
| 343 // Set a priority rect so we get tiles. | |
| 344 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, | |
| 345 Occlusion(), false); | |
| 346 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); | |
| 347 | |
| 348 // Tiles should have the new correct size. | |
| 349 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | |
| 350 EXPECT_GT(pending_tiles.size(), 0u); | |
| 351 for (const auto& tile : pending_tiles) | |
| 352 EXPECT_EQ(tile_size2, tile->content_rect().size()); | |
| 353 | |
| 354 // Clone from the pending to the active tree. | |
| 355 active_client.SetTileSize(tile_size2); | |
| 356 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | |
| 357 pile.get(), pending_set.get(), Region(), 1.f, 1.f); | |
| 358 // The active tiling should get the right tile size. | |
| 359 EXPECT_EQ(tile_size2, active_set->tiling_at(0)->tile_size()); | |
| 360 | |
| 361 // Cloned tiles should have the right size. | |
| 362 std::vector<Tile*> active_tiles = | |
| 363 active_set->tiling_at(0)->AllTilesForTesting(); | |
| 364 EXPECT_GT(active_tiles.size(), 0u); | |
| 365 for (const auto& tile : active_tiles) | |
| 366 EXPECT_EQ(tile_size2, tile->content_rect().size()); | |
| 367 | |
| 368 // A new source frame with a new tile size. | |
| 369 pending_client.SetTileSize(tile_size3); | |
| 370 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(pile.get(), Region(), | |
| 371 1.f, 1.f); | |
| 372 // The tiling gets the new size correctly. | |
| 373 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | |
| 374 | |
| 375 // Set a priority rect so we get tiles. | |
| 376 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 3.0, | |
| 377 Occlusion(), false); | |
| 378 EXPECT_EQ(tile_size3, pending_set->tiling_at(0)->tile_size()); | |
| 379 | |
| 380 // Tiles are resized for the new size. | |
| 381 pending_tiles = pending_set->tiling_at(0)->AllTilesForTesting(); | |
| 382 EXPECT_GT(pending_tiles.size(), 0u); | |
| 383 for (const auto& tile : pending_tiles) | |
| 384 EXPECT_EQ(tile_size3, tile->content_rect().size()); | |
| 385 | |
| 386 // Now we activate with a different tile size for the active tiling. | |
| 387 active_client.SetTileSize(tile_size3); | |
| 388 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | |
| 389 pile.get(), pending_set.get(), Region(), 1.f, 1.f); | |
| 390 // The active tiling changes its tile size. | |
| 391 EXPECT_EQ(tile_size3, active_set->tiling_at(0)->tile_size()); | |
| 392 | |
| 393 // And its tiles are resized. | |
| 394 active_tiles = active_set->tiling_at(0)->AllTilesForTesting(); | |
| 395 EXPECT_GT(active_tiles.size(), 0u); | |
| 396 for (const auto& tile : active_tiles) | |
| 397 EXPECT_EQ(tile_size3, tile->content_rect().size()); | |
| 398 } | |
| 399 | |
| 400 TEST(PictureLayerTilingSetTest, MaxContentScale) { | |
| 401 FakePictureLayerTilingClient pending_client; | |
| 402 FakePictureLayerTilingClient active_client; | |
| 403 scoped_ptr<PictureLayerTilingSet> pending_set = PictureLayerTilingSet::Create( | |
| 404 PENDING_TREE, &pending_client, 1000, 1.f, 1000); | |
| 405 scoped_ptr<PictureLayerTilingSet> active_set = PictureLayerTilingSet::Create( | |
| 406 ACTIVE_TREE, &active_client, 1000, 1.f, 1000); | |
| 407 | |
| 408 gfx::Size layer_bounds(100, 105); | |
| 409 scoped_refptr<FakePicturePileImpl> pile = | |
| 410 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(layer_bounds); | |
| 411 | |
| 412 // Tilings can be added of any scale, the tiling client can controls this. | |
| 413 pending_set->AddTiling(1.f, pile); | |
| 414 pending_set->AddTiling(2.f, pile); | |
| 415 pending_set->AddTiling(3.f, pile); | |
| 416 | |
| 417 // Set some expected things for the tiling set to function. | |
| 418 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | |
| 419 active_client.set_twin_tiling_set(pending_set.get()); | |
| 420 | |
| 421 // Update to a new source frame with a max content scale that is larger than | |
| 422 // everything. | |
| 423 float max_content_scale = 3.f; | |
| 424 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( | |
| 425 pile.get(), Region(), 1.f, max_content_scale); | |
| 426 | |
| 427 // All the tilings are there still. | |
| 428 EXPECT_EQ(3u, pending_set->num_tilings()); | |
| 429 | |
| 430 // Clone from the pending to the active tree with the same max content size. | |
| 431 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | |
| 432 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | |
| 433 // All the tilings are on the active tree. | |
| 434 EXPECT_EQ(3u, active_set->num_tilings()); | |
| 435 | |
| 436 // Update to a new source frame with a max content scale that will drop one | |
| 437 // tiling. | |
| 438 max_content_scale = 2.9f; | |
| 439 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( | |
| 440 pile.get(), Region(), 1.f, max_content_scale); | |
| 441 // All the tilings are there still. | |
| 442 EXPECT_EQ(2u, pending_set->num_tilings()); | |
| 443 | |
| 444 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); | |
| 445 | |
| 446 // Clone from the pending to the active tree with the same max content size. | |
| 447 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | |
| 448 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); | |
| 449 // All the tilings are on the active tree. | |
| 450 EXPECT_EQ(2u, active_set->num_tilings()); | |
| 451 } | |
| 452 | |
| 453 } // namespace | |
| 454 } // namespace cc | |
| OLD | NEW |