| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 float contents_scale, | 58 float contents_scale, |
| 59 const gfx::Size& layer_bounds, | 59 const gfx::Size& layer_bounds, |
| 60 PictureLayerTilingClient* client) { | 60 PictureLayerTilingClient* client) { |
| 61 return make_scoped_ptr(new TestablePictureLayerTiling( | 61 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 62 contents_scale, | 62 contents_scale, |
| 63 layer_bounds, | 63 layer_bounds, |
| 64 client)); | 64 client)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 67 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 68 bool eviction_tiles_cache_valid() const { | |
| 69 return eviction_tiles_cache_valid_; | |
| 70 } | |
| 71 | 68 |
| 72 using PictureLayerTiling::ComputeSkewport; | 69 using PictureLayerTiling::ComputeSkewport; |
| 73 using PictureLayerTiling::RemoveTileAt; | 70 using PictureLayerTiling::RemoveTileAt; |
| 74 | 71 |
| 75 protected: | 72 protected: |
| 76 TestablePictureLayerTiling(float contents_scale, | 73 TestablePictureLayerTiling(float contents_scale, |
| 77 const gfx::Size& layer_bounds, | 74 const gfx::Size& layer_bounds, |
| 78 PictureLayerTilingClient* client) | 75 PictureLayerTilingClient* client) |
| 79 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 76 : PictureLayerTiling(contents_scale, layer_bounds, client) { } |
| 80 }; | 77 }; |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 tiling->ComputeTilePriorityRects( | 1276 tiling->ComputeTilePriorityRects( |
| 1280 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 1277 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 1281 tiling->UpdateAllTilePrioritiesForTesting(); | 1278 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1282 | 1279 |
| 1283 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1280 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1284 EXPECT_FALSE(empty_iterator); | 1281 EXPECT_FALSE(empty_iterator); |
| 1285 | 1282 |
| 1286 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1283 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1287 | 1284 |
| 1288 PictureLayerTiling::TilingEvictionTileIterator it( | 1285 PictureLayerTiling::TilingEvictionTileIterator it( |
| 1289 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1286 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW, false); |
| 1290 | 1287 |
| 1291 // Tiles don't have resources to evict. | 1288 // Tiles don't have resources to evict. |
| 1292 EXPECT_FALSE(it); | 1289 EXPECT_FALSE(it); |
| 1293 | 1290 |
| 1294 // Sanity check. | 1291 // Sanity check. |
| 1295 EXPECT_EQ(5184u, all_tiles.size()); | 1292 EXPECT_EQ(5184u, all_tiles.size()); |
| 1296 | 1293 |
| 1297 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 1294 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 1298 | 1295 |
| 1299 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 1296 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
| 1300 | 1297 |
| 1301 std::set<Tile*> eviction_tiles; | 1298 std::set<Tile*> eviction_tiles; |
| 1302 | 1299 |
| 1303 it = PictureLayerTiling::TilingEvictionTileIterator( | 1300 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1304 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY); | 1301 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY, |
| 1302 false); |
| 1305 EXPECT_TRUE(it); | 1303 EXPECT_TRUE(it); |
| 1306 for (; it; ++it) { | 1304 for (; it; ++it) { |
| 1307 Tile* tile = *it; | 1305 Tile* tile = *it; |
| 1308 EXPECT_TRUE(tile); | 1306 EXPECT_TRUE(tile); |
| 1309 EXPECT_EQ(TilePriority::EVENTUALLY, | 1307 EXPECT_EQ(TilePriority::EVENTUALLY, |
| 1310 tile->priority(ACTIVE_TREE).priority_bin); | 1308 tile->priority(ACTIVE_TREE).priority_bin); |
| 1311 EXPECT_FALSE(tile->required_for_activation()); | 1309 EXPECT_FALSE(tile->required_for_activation()); |
| 1312 eviction_tiles.insert(tile); | 1310 eviction_tiles.insert(tile); |
| 1313 } | 1311 } |
| 1314 | 1312 |
| 1315 it = PictureLayerTiling::TilingEvictionTileIterator( | 1313 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1316 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON); | 1314 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON, false); |
| 1317 EXPECT_TRUE(it); | 1315 EXPECT_TRUE(it); |
| 1318 for (; it; ++it) { | 1316 for (; it; ++it) { |
| 1319 Tile* tile = *it; | 1317 Tile* tile = *it; |
| 1320 EXPECT_TRUE(tile); | 1318 EXPECT_TRUE(tile); |
| 1321 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); | 1319 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); |
| 1322 EXPECT_FALSE(tile->required_for_activation()); | 1320 EXPECT_FALSE(tile->required_for_activation()); |
| 1323 eviction_tiles.insert(tile); | 1321 eviction_tiles.insert(tile); |
| 1324 } | 1322 } |
| 1325 | 1323 |
| 1326 it = PictureLayerTiling::TilingEvictionTileIterator( | 1324 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1327 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1325 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW, false); |
| 1328 EXPECT_TRUE(it); | 1326 EXPECT_TRUE(it); |
| 1329 for (; it; ++it) { | 1327 for (; it; ++it) { |
| 1330 Tile* tile = *it; | 1328 Tile* tile = *it; |
| 1331 EXPECT_TRUE(tile); | 1329 EXPECT_TRUE(tile); |
| 1332 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 1330 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
| 1333 EXPECT_FALSE(tile->required_for_activation()); | 1331 EXPECT_FALSE(tile->required_for_activation()); |
| 1334 eviction_tiles.insert(tile); | 1332 eviction_tiles.insert(tile); |
| 1335 } | 1333 } |
| 1336 | 1334 |
| 1337 it = PictureLayerTiling::TilingEvictionTileIterator( | 1335 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1338 tiling.get(), | 1336 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, |
| 1339 SMOOTHNESS_TAKES_PRIORITY, | 1337 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION, false); |
| 1340 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | |
| 1341 EXPECT_FALSE(it); | 1338 EXPECT_FALSE(it); |
| 1342 | 1339 |
| 1343 EXPECT_GT(all_tiles_set.size(), 0u); | 1340 EXPECT_GT(all_tiles_set.size(), 0u); |
| 1344 EXPECT_EQ(all_tiles_set, eviction_tiles); | 1341 EXPECT_EQ(all_tiles_set, eviction_tiles); |
| 1345 | |
| 1346 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); | |
| 1347 tiling->RemoveTileAt(0, 0, nullptr); | |
| 1348 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); | |
| 1349 | |
| 1350 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1351 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, | |
| 1352 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | |
| 1353 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); | |
| 1354 tiling->Reset(); | |
| 1355 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); | |
| 1356 } | 1342 } |
| 1357 | 1343 |
| 1358 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { | 1344 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
| 1359 gfx::Size layer_bounds(1099, 801); | 1345 gfx::Size layer_bounds(1099, 801); |
| 1360 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1346 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1361 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1347 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1362 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1348 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1363 | 1349 |
| 1364 client_.set_tree(ACTIVE_TREE); | 1350 client_.set_tree(ACTIVE_TREE); |
| 1365 tiling_->ComputeTilePriorityRects( | 1351 tiling_->ComputeTilePriorityRects( |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(250, 150)); | 2183 tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(250, 150)); |
| 2198 | 2184 |
| 2199 // Tile size in the tiling should be resized to 250x200. | 2185 // Tile size in the tiling should be resized to 250x200. |
| 2200 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2186 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2201 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2187 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2202 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2188 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2203 } | 2189 } |
| 2204 | 2190 |
| 2205 } // namespace | 2191 } // namespace |
| 2206 } // namespace cc | 2192 } // namespace cc |
| OLD | NEW |