| 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.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1278 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 1279 tiling->ComputeTilePriorityRects( | 1279 tiling->ComputeTilePriorityRects( |
| 1280 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 1280 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 1281 tiling->UpdateAllTilePrioritiesForTesting(); | 1281 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1282 | 1282 |
| 1283 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1283 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1284 EXPECT_FALSE(empty_iterator); | 1284 EXPECT_FALSE(empty_iterator); |
| 1285 | 1285 |
| 1286 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1286 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1287 | 1287 |
| 1288 PictureLayerTiling::TilingEvictionTileIterator it( | 1288 PictureLayerTiling::TilingEvictionTileIterator it(tiling.get(), |
| 1289 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1289 SMOOTHNESS_TAKES_PRIORITY, |
| 1290 PictureLayerTiling::NOW, |
| 1291 true, |
| 1292 true); |
| 1290 | 1293 |
| 1291 // Tiles don't have resources to evict. | 1294 // Tiles don't have resources to evict. |
| 1292 EXPECT_FALSE(it); | 1295 EXPECT_FALSE(it); |
| 1293 | 1296 |
| 1294 // Sanity check. | 1297 // Sanity check. |
| 1295 EXPECT_EQ(5184u, all_tiles.size()); | 1298 EXPECT_EQ(5184u, all_tiles.size()); |
| 1296 | 1299 |
| 1297 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 1300 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 1298 | 1301 |
| 1299 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 1302 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
| 1300 | 1303 |
| 1301 std::set<Tile*> eviction_tiles; | 1304 std::set<Tile*> eviction_tiles; |
| 1302 | 1305 |
| 1303 it = PictureLayerTiling::TilingEvictionTileIterator( | 1306 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1304 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY); | 1307 tiling.get(), |
| 1308 SMOOTHNESS_TAKES_PRIORITY, |
| 1309 PictureLayerTiling::EVENTUALLY, |
| 1310 true, |
| 1311 true); |
| 1305 EXPECT_TRUE(it); | 1312 EXPECT_TRUE(it); |
| 1306 for (; it; ++it) { | 1313 for (; it; ++it) { |
| 1307 Tile* tile = *it; | 1314 Tile* tile = *it; |
| 1308 EXPECT_TRUE(tile); | 1315 EXPECT_TRUE(tile); |
| 1309 EXPECT_EQ(TilePriority::EVENTUALLY, | 1316 EXPECT_EQ(TilePriority::EVENTUALLY, |
| 1310 tile->priority(ACTIVE_TREE).priority_bin); | 1317 tile->priority(ACTIVE_TREE).priority_bin); |
| 1311 EXPECT_FALSE(tile->required_for_activation()); | 1318 EXPECT_FALSE(tile->required_for_activation()); |
| 1312 eviction_tiles.insert(tile); | 1319 eviction_tiles.insert(tile); |
| 1313 } | 1320 } |
| 1314 | 1321 |
| 1315 it = PictureLayerTiling::TilingEvictionTileIterator( | 1322 it = PictureLayerTiling::TilingEvictionTileIterator(tiling.get(), |
| 1316 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON); | 1323 SMOOTHNESS_TAKES_PRIORITY, |
| 1324 PictureLayerTiling::SOON, |
| 1325 true, |
| 1326 true); |
| 1317 EXPECT_TRUE(it); | 1327 EXPECT_TRUE(it); |
| 1318 for (; it; ++it) { | 1328 for (; it; ++it) { |
| 1319 Tile* tile = *it; | 1329 Tile* tile = *it; |
| 1320 EXPECT_TRUE(tile); | 1330 EXPECT_TRUE(tile); |
| 1321 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); | 1331 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); |
| 1322 EXPECT_FALSE(tile->required_for_activation()); | 1332 EXPECT_FALSE(tile->required_for_activation()); |
| 1323 eviction_tiles.insert(tile); | 1333 eviction_tiles.insert(tile); |
| 1324 } | 1334 } |
| 1325 | 1335 |
| 1326 it = PictureLayerTiling::TilingEvictionTileIterator( | 1336 it = PictureLayerTiling::TilingEvictionTileIterator(tiling.get(), |
| 1327 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1337 SMOOTHNESS_TAKES_PRIORITY, |
| 1338 PictureLayerTiling::NOW, |
| 1339 true, |
| 1340 true); |
| 1328 EXPECT_TRUE(it); | 1341 EXPECT_TRUE(it); |
| 1329 for (; it; ++it) { | 1342 for (; it; ++it) { |
| 1330 Tile* tile = *it; | 1343 Tile* tile = *it; |
| 1331 EXPECT_TRUE(tile); | 1344 EXPECT_TRUE(tile); |
| 1332 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 1345 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
| 1333 EXPECT_FALSE(tile->required_for_activation()); | 1346 EXPECT_FALSE(tile->required_for_activation()); |
| 1334 eviction_tiles.insert(tile); | 1347 eviction_tiles.insert(tile); |
| 1335 } | 1348 } |
| 1336 | 1349 |
| 1337 it = PictureLayerTiling::TilingEvictionTileIterator( | 1350 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1338 tiling.get(), | 1351 tiling.get(), |
| 1339 SMOOTHNESS_TAKES_PRIORITY, | 1352 SMOOTHNESS_TAKES_PRIORITY, |
| 1340 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | 1353 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION, |
| 1354 true, |
| 1355 true); |
| 1341 EXPECT_FALSE(it); | 1356 EXPECT_FALSE(it); |
| 1342 | 1357 |
| 1343 EXPECT_GT(all_tiles_set.size(), 0u); | 1358 EXPECT_GT(all_tiles_set.size(), 0u); |
| 1344 EXPECT_EQ(all_tiles_set, eviction_tiles); | 1359 EXPECT_EQ(all_tiles_set, eviction_tiles); |
| 1345 | 1360 |
| 1346 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); | 1361 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); |
| 1347 tiling->RemoveTileAt(0, 0, nullptr); | 1362 tiling->RemoveTileAt(0, 0, nullptr); |
| 1348 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); | 1363 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); |
| 1349 } | 1364 } |
| 1350 | 1365 |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2181 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
| 2167 | 2182 |
| 2168 // Reset the active tiling. The recycle tiles should be released too. | 2183 // Reset the active tiling. The recycle tiles should be released too. |
| 2169 active_tiling->Reset(); | 2184 active_tiling->Reset(); |
| 2170 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2185 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 2171 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2186 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 2172 } | 2187 } |
| 2173 | 2188 |
| 2174 } // namespace | 2189 } // namespace |
| 2175 } // namespace cc | 2190 } // namespace cc |
| OLD | NEW |