| 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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1240 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1241 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1241 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1242 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1242 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 static void TileExists(bool exists, Tile* tile, | 1245 static void TileExists(bool exists, Tile* tile, |
| 1246 const gfx::Rect& geometry_rect) { | 1246 const gfx::Rect& geometry_rect) { |
| 1247 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString(); | 1247 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString(); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 TEST(PictureLayerTilingTest, TilingEvictionTileIteratorStaticViewport) { | |
| 1251 FakeOutputSurfaceClient output_surface_client; | |
| 1252 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | |
| 1253 CHECK(output_surface->BindToClient(&output_surface_client)); | |
| 1254 TestSharedBitmapManager shared_bitmap_manager; | |
| 1255 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | |
| 1256 output_surface.get(), &shared_bitmap_manager, NULL, NULL, 0, false, 1); | |
| 1257 | |
| 1258 FakePictureLayerTilingClient client(resource_provider.get()); | |
| 1259 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1260 | |
| 1261 gfx::Rect viewport(50, 50, 100, 100); | |
| 1262 gfx::Size layer_bounds(2000, 2000); | |
| 1263 | |
| 1264 client.SetTileSize(gfx::Size(30, 30)); | |
| 1265 client.set_tree(ACTIVE_TREE); | |
| 1266 | |
| 1267 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | |
| 1268 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | |
| 1269 tiling->UpdateAllTilePrioritiesForTesting(); | |
| 1270 | |
| 1271 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | |
| 1272 EXPECT_FALSE(empty_iterator); | |
| 1273 | |
| 1274 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | |
| 1275 | |
| 1276 PictureLayerTiling::TilingEvictionTileIterator it( | |
| 1277 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | |
| 1278 | |
| 1279 // Tiles don't have resources to evict. | |
| 1280 EXPECT_FALSE(it); | |
| 1281 | |
| 1282 // Sanity check. | |
| 1283 EXPECT_EQ(5184u, all_tiles.size()); | |
| 1284 | |
| 1285 client.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | |
| 1286 | |
| 1287 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | |
| 1288 | |
| 1289 std::set<Tile*> eviction_tiles; | |
| 1290 | |
| 1291 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1292 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::EVENTUALLY); | |
| 1293 EXPECT_TRUE(it); | |
| 1294 for (; it; ++it) { | |
| 1295 Tile* tile = *it; | |
| 1296 EXPECT_TRUE(tile); | |
| 1297 EXPECT_EQ(TilePriority::EVENTUALLY, | |
| 1298 tile->priority(ACTIVE_TREE).priority_bin); | |
| 1299 EXPECT_FALSE(tile->required_for_activation()); | |
| 1300 eviction_tiles.insert(tile); | |
| 1301 } | |
| 1302 | |
| 1303 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1304 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::SOON); | |
| 1305 EXPECT_TRUE(it); | |
| 1306 for (; it; ++it) { | |
| 1307 Tile* tile = *it; | |
| 1308 EXPECT_TRUE(tile); | |
| 1309 EXPECT_EQ(TilePriority::SOON, tile->priority(ACTIVE_TREE).priority_bin); | |
| 1310 EXPECT_FALSE(tile->required_for_activation()); | |
| 1311 eviction_tiles.insert(tile); | |
| 1312 } | |
| 1313 | |
| 1314 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1315 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | |
| 1316 EXPECT_TRUE(it); | |
| 1317 for (; it; ++it) { | |
| 1318 Tile* tile = *it; | |
| 1319 EXPECT_TRUE(tile); | |
| 1320 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | |
| 1321 EXPECT_FALSE(tile->required_for_activation()); | |
| 1322 eviction_tiles.insert(tile); | |
| 1323 } | |
| 1324 | |
| 1325 it = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1326 tiling.get(), | |
| 1327 SMOOTHNESS_TAKES_PRIORITY, | |
| 1328 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | |
| 1329 EXPECT_FALSE(it); | |
| 1330 | |
| 1331 EXPECT_GT(all_tiles_set.size(), 0u); | |
| 1332 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 } | |
| 1345 | |
| 1346 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { | 1250 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
| 1347 gfx::Size layer_bounds(1099, 801); | 1251 gfx::Size layer_bounds(1099, 801); |
| 1348 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1252 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1349 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1253 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1350 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1254 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1351 | 1255 |
| 1352 client_.set_tree(ACTIVE_TREE); | 1256 client_.set_tree(ACTIVE_TREE); |
| 1353 tiling_->ComputeTilePriorityRects( | 1257 tiling_->ComputeTilePriorityRects( |
| 1354 gfx::Rect(layer_bounds), // visible content rect | 1258 gfx::Rect(layer_bounds), // visible content rect |
| 1355 1.f, // current contents scale | 1259 1.f, // current contents scale |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 invalidation, gfx::Size(250, 150)); | 2055 invalidation, gfx::Size(250, 150)); |
| 2152 | 2056 |
| 2153 // Tile size in the tiling should be resized to 250x200. | 2057 // Tile size in the tiling should be resized to 250x200. |
| 2154 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2058 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2155 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2059 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2156 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2060 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2157 } | 2061 } |
| 2158 | 2062 |
| 2159 } // namespace | 2063 } // namespace |
| 2160 } // namespace cc | 2064 } // namespace cc |
| OLD | NEW |