| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 float contents_scale, | 55 float contents_scale, |
| 56 const gfx::Size& layer_bounds, | 56 const gfx::Size& layer_bounds, |
| 57 PictureLayerTilingClient* client) { | 57 PictureLayerTilingClient* client) { |
| 58 return make_scoped_ptr(new TestablePictureLayerTiling( | 58 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 59 contents_scale, | 59 contents_scale, |
| 60 layer_bounds, | 60 layer_bounds, |
| 61 client)); | 61 client)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 64 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 65 bool eviction_tiles_cache_valid() const { | |
| 66 return eviction_tiles_cache_valid_; | |
| 67 } | |
| 68 | 65 |
| 69 using PictureLayerTiling::ComputeSkewport; | 66 using PictureLayerTiling::ComputeSkewport; |
| 70 using PictureLayerTiling::RemoveTileAt; | 67 using PictureLayerTiling::RemoveTileAt; |
| 71 | 68 |
| 72 protected: | 69 protected: |
| 73 TestablePictureLayerTiling(float contents_scale, | 70 TestablePictureLayerTiling(float contents_scale, |
| 74 const gfx::Size& layer_bounds, | 71 const gfx::Size& layer_bounds, |
| 75 PictureLayerTilingClient* client) | 72 PictureLayerTilingClient* client) |
| 76 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 73 : PictureLayerTiling(contents_scale, layer_bounds, client) { } |
| 77 }; | 74 }; |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1264 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 1268 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1265 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1269 tiling->UpdateAllTilePrioritiesForTesting(); | 1266 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1270 | 1267 |
| 1271 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1268 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1272 EXPECT_FALSE(empty_iterator); | 1269 EXPECT_FALSE(empty_iterator); |
| 1273 | 1270 |
| 1274 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1271 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1275 | 1272 |
| 1276 PictureLayerTiling::TilingEvictionTileIterator it( | 1273 PictureLayerTiling::TilingEvictionTileIterator it( |
| 1277 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1274 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW, false); |
| 1278 | 1275 |
| 1279 // Tiles don't have resources to evict. | 1276 // Tiles don't have resources to evict. |
| 1280 EXPECT_FALSE(it); | 1277 EXPECT_FALSE(it); |
| 1281 | 1278 |
| 1282 // Sanity check. | 1279 // Sanity check. |
| 1283 EXPECT_EQ(5184u, all_tiles.size()); | 1280 EXPECT_EQ(5184u, all_tiles.size()); |
| 1284 | 1281 |
| 1285 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 1282 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 1286 | 1283 |
| 1287 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 1284 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
| 1288 | 1285 |
| 1289 std::set<Tile*> eviction_tiles; | 1286 std::set<Tile*> eviction_tiles; |
| 1290 | 1287 |
| 1291 it = PictureLayerTiling::TilingEvictionTileIterator( | 1288 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1292 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY); | 1289 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY, |
| 1290 false); |
| 1293 EXPECT_TRUE(it); | 1291 EXPECT_TRUE(it); |
| 1294 for (; it; ++it) { | 1292 for (; it; ++it) { |
| 1295 Tile* tile = *it; | 1293 Tile* tile = *it; |
| 1296 EXPECT_TRUE(tile); | 1294 EXPECT_TRUE(tile); |
| 1297 EXPECT_EQ(TilePriority::EVENTUALLY, | 1295 EXPECT_EQ(TilePriority::EVENTUALLY, |
| 1298 tile->priority(ACTIVE_TREE).priority_bin); | 1296 tile->priority(ACTIVE_TREE).priority_bin); |
| 1299 EXPECT_FALSE(tile->required_for_activation()); | 1297 EXPECT_FALSE(tile->required_for_activation()); |
| 1300 eviction_tiles.insert(tile); | 1298 eviction_tiles.insert(tile); |
| 1301 } | 1299 } |
| 1302 | 1300 |
| 1303 it = PictureLayerTiling::TilingEvictionTileIterator( | 1301 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1304 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON); | 1302 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON, 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::SOON, tile->priority(ACTIVE_TREE).priority_bin); | 1307 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); |
| 1310 EXPECT_FALSE(tile->required_for_activation()); | 1308 EXPECT_FALSE(tile->required_for_activation()); |
| 1311 eviction_tiles.insert(tile); | 1309 eviction_tiles.insert(tile); |
| 1312 } | 1310 } |
| 1313 | 1311 |
| 1314 it = PictureLayerTiling::TilingEvictionTileIterator( | 1312 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1315 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1313 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW, false); |
| 1316 EXPECT_TRUE(it); | 1314 EXPECT_TRUE(it); |
| 1317 for (; it; ++it) { | 1315 for (; it; ++it) { |
| 1318 Tile* tile = *it; | 1316 Tile* tile = *it; |
| 1319 EXPECT_TRUE(tile); | 1317 EXPECT_TRUE(tile); |
| 1320 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 1318 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
| 1321 EXPECT_FALSE(tile->required_for_activation()); | 1319 EXPECT_FALSE(tile->required_for_activation()); |
| 1322 eviction_tiles.insert(tile); | 1320 eviction_tiles.insert(tile); |
| 1323 } | 1321 } |
| 1324 | 1322 |
| 1325 it = PictureLayerTiling::TilingEvictionTileIterator( | 1323 it = PictureLayerTiling::TilingEvictionTileIterator( |
| 1326 tiling.get(), | 1324 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, |
| 1327 SMOOTHNESS_TAKES_PRIORITY, | 1325 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION, false); |
| 1328 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | |
| 1329 EXPECT_FALSE(it); | 1326 EXPECT_FALSE(it); |
| 1330 | 1327 |
| 1331 EXPECT_GT(all_tiles_set.size(), 0u); | 1328 EXPECT_GT(all_tiles_set.size(), 0u); |
| 1332 EXPECT_EQ(all_tiles_set, eviction_tiles); | 1329 EXPECT_EQ(all_tiles_set, eviction_tiles); |
| 1333 | |
| 1334 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); | |
| 1335 tiling->RemoveTileAt(0, 0, nullptr); | |
| 1336 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); | |
| 1337 | |
| 1338 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1339 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, | |
| 1340 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | |
| 1341 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); | |
| 1342 tiling->Reset(); | |
| 1343 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); | |
| 1344 } | 1330 } |
| 1345 | 1331 |
| 1346 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { | 1332 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
| 1347 gfx::Size layer_bounds(1099, 801); | 1333 gfx::Size layer_bounds(1099, 801); |
| 1348 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1334 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1349 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1335 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1350 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1336 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1351 | 1337 |
| 1352 client_.set_tree(ACTIVE_TREE); | 1338 client_.set_tree(ACTIVE_TREE); |
| 1353 tiling_->ComputeTilePriorityRects( | 1339 tiling_->ComputeTilePriorityRects( |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 invalidation, gfx::Size(250, 150)); | 2137 invalidation, gfx::Size(250, 150)); |
| 2152 | 2138 |
| 2153 // Tile size in the tiling should be resized to 250x200. | 2139 // Tile size in the tiling should be resized to 250x200. |
| 2154 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2140 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2155 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2141 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2156 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2142 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2157 } | 2143 } |
| 2158 | 2144 |
| 2159 } // namespace | 2145 } // namespace |
| 2160 } // namespace cc | 2146 } // namespace cc |
| OLD | NEW |