OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1232 | 1232 |
1233 AppendQuadsData data; | 1233 AppendQuadsData data; |
1234 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); | 1234 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); |
1235 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 1235 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
1236 active_layer_->DidDraw(NULL); | 1236 active_layer_->DidDraw(NULL); |
1237 | 1237 |
1238 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1238 ASSERT_EQ(1U, render_pass->quad_list.size()); |
1239 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); | 1239 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); |
1240 } | 1240 } |
1241 | 1241 |
1242 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { | |
vmpstr
2014/07/02 23:51:29
These types of tests no longer apply, since MarkVi
| |
1243 gfx::Size tile_size(100, 100); | |
1244 gfx::Size layer_bounds(1000, 1000); | |
1245 | |
1246 scoped_refptr<FakePicturePileImpl> pending_pile = | |
1247 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
1248 // Layers with entirely empty piles can't get tilings. | |
1249 pending_pile->AddRecordingAt(0, 0); | |
1250 | |
1251 SetupPendingTree(pending_pile); | |
1252 | |
1253 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
1254 pending_layer_->AddTiling(1.0f); | |
1255 pending_layer_->AddTiling(2.0f); | |
1256 | |
1257 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
1258 // on a layer with no recordings. | |
1259 host_impl_.pending_tree()->UpdateDrawProperties(); | |
1260 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1261 } | |
1262 | |
1263 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1242 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
1264 gfx::Size tile_size(100, 100); | 1243 gfx::Size tile_size(100, 100); |
1265 gfx::Size layer_bounds(200, 200); | 1244 gfx::Size layer_bounds(200, 200); |
1266 | 1245 |
1267 scoped_refptr<FakePicturePileImpl> pending_pile = | 1246 scoped_refptr<FakePicturePileImpl> pending_pile = |
1268 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1247 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1269 SetupPendingTree(pending_pile); | 1248 SetupPendingTree(pending_pile); |
1270 | 1249 |
1271 pending_layer_->set_fixed_tile_size(tile_size); | 1250 pending_layer_->set_fixed_tile_size(tile_size); |
1272 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1251 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
1273 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1252 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
1274 host_impl_.pending_tree()->UpdateDrawProperties(); | 1253 host_impl_.pending_tree()->UpdateDrawProperties(); |
1275 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | |
1276 | |
1277 pending_layer_->draw_properties().visible_content_rect = | 1254 pending_layer_->draw_properties().visible_content_rect = |
1278 gfx::Rect(0, 0, 100, 200); | 1255 gfx::Rect(0, 0, 100, 200); |
1256 pending_layer_->UpdateTiles(NULL); | |
1279 | 1257 |
1280 // Fake set priorities. | 1258 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
1281 for (PictureLayerTiling::CoverageIterator iter( | |
1282 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | |
1283 iter; | |
1284 ++iter) { | |
1285 if (!*iter) | |
1286 continue; | |
1287 Tile* tile = *iter; | |
1288 TilePriority priority; | |
1289 priority.resolution = HIGH_RESOLUTION; | |
1290 gfx::Rect tile_bounds = iter.geometry_rect(); | |
1291 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { | |
1292 priority.priority_bin = TilePriority::NOW; | |
1293 priority.distance_to_visible = 0.f; | |
1294 } else { | |
1295 priority.priority_bin = TilePriority::SOON; | |
1296 priority.distance_to_visible = 1.f; | |
1297 } | |
1298 tile->SetPriority(PENDING_TREE, priority); | |
1299 } | |
1300 | |
1301 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1302 | 1259 |
1303 int num_visible = 0; | 1260 int num_visible = 0; |
1304 int num_offscreen = 0; | 1261 int num_offscreen = 0; |
1305 | 1262 |
1306 for (PictureLayerTiling::CoverageIterator iter( | 1263 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling, PENDING_TREE); |
1307 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | |
1308 iter; | 1264 iter; |
1309 ++iter) { | 1265 ++iter) { |
1310 if (!*iter) | |
1311 continue; | |
1312 const Tile* tile = *iter; | 1266 const Tile* tile = *iter; |
1313 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1267 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
1314 EXPECT_TRUE(tile->required_for_activation()); | 1268 EXPECT_TRUE(tile->required_for_activation()); |
1315 num_visible++; | 1269 num_visible++; |
1316 } else { | 1270 } else { |
1317 EXPECT_FALSE(tile->required_for_activation()); | 1271 EXPECT_FALSE(tile->required_for_activation()); |
1318 num_offscreen++; | 1272 num_offscreen++; |
1319 } | 1273 } |
1320 } | 1274 } |
1321 | 1275 |
1322 EXPECT_GT(num_visible, 0); | 1276 EXPECT_GT(num_visible, 0); |
1323 EXPECT_GT(num_offscreen, 0); | 1277 EXPECT_GT(num_offscreen, 0); |
1324 } | 1278 } |
1325 | 1279 // |
1326 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 1280 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
1327 gfx::Size layer_bounds(400, 400); | 1281 gfx::Size layer_bounds(400, 400); |
1328 gfx::Size tile_size(100, 100); | 1282 gfx::Size tile_size(100, 100); |
1329 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1283 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1330 | 1284 |
1331 // No tiles shared. | 1285 // No tiles shared. |
1332 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); | 1286 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); |
1333 | 1287 |
1334 CreateHighLowResAndSetAllTilesVisible(); | 1288 CreateHighLowResAndSetAllTilesVisible(); |
1335 | 1289 |
1336 active_layer_->SetAllTilesReady(); | 1290 active_layer_->SetAllTilesReady(); |
1337 | 1291 |
1338 // No shared tiles and all active tiles ready, so pending can only | 1292 // No shared tiles and all active tiles ready, so pending can only |
1339 // activate with all high res tiles. | 1293 // activate with all high res tiles. |
1340 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1341 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1294 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1342 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1295 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1343 } | 1296 } |
1344 | 1297 |
1345 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 1298 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
1346 gfx::Size layer_bounds(400, 400); | 1299 gfx::Size layer_bounds(400, 400); |
1347 gfx::Size tile_size(100, 100); | 1300 gfx::Size tile_size(100, 100); |
1348 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1301 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1349 | 1302 |
1303 host_impl_.active_tree()->SetRequiresHighResToDraw(); | |
vmpstr
2014/07/02 23:51:29
The order here is kind of important, since creatin
| |
1304 | |
1350 // All tiles shared (no invalidation). | 1305 // All tiles shared (no invalidation). |
1351 CreateHighLowResAndSetAllTilesVisible(); | 1306 CreateHighLowResAndSetAllTilesVisible(); |
1352 | 1307 |
1353 // Verify active tree not ready. | 1308 // Verify active tree not ready. |
1354 Tile* some_active_tile = | 1309 Tile* some_active_tile = |
1355 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1310 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1356 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1311 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1357 | 1312 |
1358 // When high res are required, even if the active tree is not ready, | 1313 // When high res are required, even if the active tree is not ready, |
1359 // the high res tiles must be ready. | 1314 // the high res tiles must be ready. |
1360 host_impl_.active_tree()->SetRequiresHighResToDraw(); | |
1361 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1362 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1315 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1363 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1316 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1364 } | 1317 } |
1365 | 1318 |
1366 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 1319 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
1367 gfx::Size layer_bounds(400, 400); | 1320 gfx::Size layer_bounds(400, 400); |
1368 gfx::Size tile_size(100, 100); | 1321 gfx::Size tile_size(100, 100); |
1369 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1322 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1370 | 1323 |
1371 CreateHighLowResAndSetAllTilesVisible(); | 1324 CreateHighLowResAndSetAllTilesVisible(); |
1372 | 1325 |
1373 Tile* some_active_tile = | 1326 Tile* some_active_tile = |
1374 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1327 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1375 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1328 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1376 | 1329 |
1377 // All tiles shared (no invalidation), so even though the active tree's | 1330 // All tiles shared (no invalidation), so even though the active tree's |
1378 // tiles aren't ready, there is nothing required. | 1331 // tiles aren't ready, there is nothing required. |
1379 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1380 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1332 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1381 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1333 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1382 } | 1334 } |
1383 | 1335 |
1384 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1336 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1385 gfx::Size layer_bounds(400, 400); | 1337 gfx::Size layer_bounds(400, 400); |
1386 gfx::Size tile_size(100, 100); | 1338 gfx::Size tile_size(100, 100); |
1387 scoped_refptr<FakePicturePileImpl> pending_pile = | 1339 scoped_refptr<FakePicturePileImpl> pending_pile = |
1388 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1340 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1389 // This pile will create tilings, but has no recordings so will not create any | 1341 // This pile will create tilings, but has no recordings so will not create any |
1390 // tiles. This is attempting to simulate scrolling past the end of recorded | 1342 // tiles. This is attempting to simulate scrolling past the end of recorded |
1391 // content on the active layer, where the recordings are so far away that | 1343 // content on the active layer, where the recordings are so far away that |
1392 // no tiles are created. | 1344 // no tiles are created. |
1393 scoped_refptr<FakePicturePileImpl> active_pile = | 1345 scoped_refptr<FakePicturePileImpl> active_pile = |
1394 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1346 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1395 tile_size, layer_bounds); | 1347 tile_size, layer_bounds); |
1396 SetupTrees(pending_pile, active_pile); | 1348 SetupTrees(pending_pile, active_pile); |
1397 pending_layer_->set_fixed_tile_size(tile_size); | 1349 pending_layer_->set_fixed_tile_size(tile_size); |
1398 active_layer_->set_fixed_tile_size(tile_size); | 1350 active_layer_->set_fixed_tile_size(tile_size); |
1399 | 1351 |
1400 CreateHighLowResAndSetAllTilesVisible(); | 1352 CreateHighLowResAndSetAllTilesVisible(); |
1401 | 1353 |
1402 // Active layer has tilings, but no tiles due to missing recordings. | 1354 // Active layer has tilings, but no tiles due to missing recordings. |
1403 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1355 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1404 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1356 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
1405 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1357 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
1406 | 1358 |
1407 // Since the active layer has no tiles at all, the pending layer doesn't | 1359 // Since the active layer has no tiles at all, the pending layer doesn't |
1408 // need content in order to activate. | 1360 // need content in order to activate. |
1409 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1410 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1361 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1411 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1362 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1412 } | 1363 } |
1413 | 1364 |
1414 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1365 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
1415 gfx::Size layer_bounds(400, 400); | 1366 gfx::Size layer_bounds(400, 400); |
1416 gfx::Size tile_size(100, 100); | 1367 gfx::Size tile_size(100, 100); |
1417 scoped_refptr<FakePicturePileImpl> pending_pile = | 1368 scoped_refptr<FakePicturePileImpl> pending_pile = |
1418 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1369 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1419 scoped_refptr<FakePicturePileImpl> active_pile = | 1370 scoped_refptr<FakePicturePileImpl> active_pile = |
1420 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1371 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
1421 SetupTrees(pending_pile, active_pile); | 1372 SetupTrees(pending_pile, active_pile); |
1422 pending_layer_->set_fixed_tile_size(tile_size); | 1373 pending_layer_->set_fixed_tile_size(tile_size); |
1423 active_layer_->set_fixed_tile_size(tile_size); | 1374 active_layer_->set_fixed_tile_size(tile_size); |
1424 | 1375 |
1425 CreateHighLowResAndSetAllTilesVisible(); | 1376 CreateHighLowResAndSetAllTilesVisible(); |
1426 | 1377 |
1427 // Active layer can't have tiles. | 1378 // Active layer can't have tiles. |
1428 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1379 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
1429 | 1380 |
1430 // All high res tiles required. This should be considered identical | 1381 // All high res tiles required. This should be considered identical |
1431 // to the case where there is no active layer, to avoid flashing content. | 1382 // to the case where there is no active layer, to avoid flashing content. |
1432 // This can happen if a layer exists for a while and switches from | 1383 // This can happen if a layer exists for a while and switches from |
1433 // not being able to have content to having content. | 1384 // not being able to have content to having content. |
1434 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1435 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1385 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1436 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1386 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1437 } | 1387 } |
1438 | 1388 |
1439 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 1389 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
1440 gfx::Size layer_bounds(200, 200); | 1390 gfx::Size layer_bounds(200, 200); |
1441 gfx::Size tile_size(100, 100); | 1391 gfx::Size tile_size(100, 100); |
1442 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1392 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1443 | 1393 |
1444 gfx::Size pending_layer_bounds(400, 400); | 1394 gfx::Size pending_layer_bounds(400, 400); |
1445 pending_layer_->SetBounds(pending_layer_bounds); | 1395 pending_layer_->SetBounds(pending_layer_bounds); |
1446 | 1396 |
1447 CreateHighLowResAndSetAllTilesVisible(); | 1397 CreateHighLowResAndSetAllTilesVisible(); |
1398 pending_layer_->HighResTiling()->SetLayerBounds(pending_layer_bounds); | |
1399 pending_layer_->HighResTiling()->UpdateTilePriorities( | |
1400 PENDING_TREE, | |
1401 gfx::Rect(pending_layer_bounds), | |
1402 1.f, | |
1403 1.f, | |
1404 NULL, | |
1405 NULL, | |
1406 gfx::Transform()); | |
1407 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | |
1448 | 1408 |
1449 active_layer_->SetAllTilesReady(); | 1409 active_layer_->SetAllTilesReady(); |
1450 | 1410 |
1451 // Since the active layer has different bounds, the pending layer needs all | 1411 // Since the active layer has different bounds, the pending layer needs all |
1452 // high res tiles in order to activate. | 1412 // high res tiles in order to activate. |
1453 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1454 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1413 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1455 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1414 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1456 } | 1415 } |
1457 | 1416 |
1458 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 1417 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
1459 gfx::Size tile_size(100, 100); | 1418 gfx::Size tile_size(100, 100); |
1460 gfx::Size layer_bounds(400, 400); | 1419 gfx::Size layer_bounds(400, 400); |
1461 scoped_refptr<FakePicturePileImpl> pending_pile = | 1420 scoped_refptr<FakePicturePileImpl> pending_pile = |
1462 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1421 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1463 | 1422 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1969 tilings.push_back(pending_layer_->AddTiling(2.0f)); | 1928 tilings.push_back(pending_layer_->AddTiling(2.0f)); |
1970 | 1929 |
1971 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 1930 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
1972 host_impl_.pending_tree()->UpdateDrawProperties(); | 1931 host_impl_.pending_tree()->UpdateDrawProperties(); |
1973 | 1932 |
1974 std::vector<Tile*> all_tiles; | 1933 std::vector<Tile*> all_tiles; |
1975 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 1934 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
1976 tilings.begin(); | 1935 tilings.begin(); |
1977 tiling_iterator != tilings.end(); | 1936 tiling_iterator != tilings.end(); |
1978 ++tiling_iterator) { | 1937 ++tiling_iterator) { |
1938 (*tiling_iterator)->CreateAllTilesForTesting(); | |
1979 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 1939 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
1980 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 1940 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
1981 } | 1941 } |
1982 | 1942 |
1983 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 1943 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
1984 | 1944 |
1985 bool mark_required = false; | 1945 bool mark_required = false; |
1986 size_t number_of_marked_tiles = 0u; | 1946 size_t number_of_marked_tiles = 0u; |
1987 size_t number_of_unmarked_tiles = 0u; | 1947 size_t number_of_unmarked_tiles = 0u; |
1988 for (size_t i = 0; i < tilings.size(); ++i) { | 1948 for (size_t i = 0; i < tilings.size(); ++i) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2112 scoped_refptr<FakePicturePileImpl> pending_pile = | 2072 scoped_refptr<FakePicturePileImpl> pending_pile = |
2113 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); | 2073 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); |
2114 SetupPendingTree(pending_pile); | 2074 SetupPendingTree(pending_pile); |
2115 pending_layer_->SetBounds(layer_bounds); | 2075 pending_layer_->SetBounds(layer_bounds); |
2116 ActivateTree(); | 2076 ActivateTree(); |
2117 active_layer_->set_fixed_tile_size(tile_size); | 2077 active_layer_->set_fixed_tile_size(tile_size); |
2118 | 2078 |
2119 host_impl_.SetViewportSize(viewport_size); | 2079 host_impl_.SetViewportSize(viewport_size); |
2120 host_impl_.active_tree()->UpdateDrawProperties(); | 2080 host_impl_.active_tree()->UpdateDrawProperties(); |
2121 | 2081 |
2082 active_layer_->HighResTiling()->CreateAllTilesForTesting(); | |
2122 std::vector<Tile*> tiles = | 2083 std::vector<Tile*> tiles = |
2123 active_layer_->HighResTiling()->AllTilesForTesting(); | 2084 active_layer_->HighResTiling()->AllTilesForTesting(); |
2124 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 2085 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
2125 | 2086 |
2126 { | 2087 { |
2127 SCOPED_TRACE("No occlusion"); | 2088 SCOPED_TRACE("No occlusion"); |
2128 gfx::Rect occluded; | 2089 gfx::Rect occluded; |
2129 impl.AppendQuadsWithOcclusion(active_layer_, occluded); | 2090 impl.AppendQuadsWithOcclusion(active_layer_, occluded); |
2130 | 2091 |
2131 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | 2092 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2203 gfx::Size tile_size(100, 100); | 2164 gfx::Size tile_size(100, 100); |
2204 gfx::Size layer_bounds(1000, 1000); | 2165 gfx::Size layer_bounds(1000, 1000); |
2205 | 2166 |
2206 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2167 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2207 | 2168 |
2208 // Make sure some tiles are not shared. | 2169 // Make sure some tiles are not shared. |
2209 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 2170 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
2210 | 2171 |
2211 CreateHighLowResAndSetAllTilesVisible(); | 2172 CreateHighLowResAndSetAllTilesVisible(); |
2212 active_layer_->SetAllTilesReady(); | 2173 active_layer_->SetAllTilesReady(); |
2213 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2214 | 2174 |
2215 // All pending layer tiles required are not ready. | 2175 // All pending layer tiles required are not ready. |
2216 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2176 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2217 | 2177 |
2218 // Initialize all low-res tiles. | 2178 // Initialize all low-res tiles. |
2219 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 2179 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
2220 | 2180 |
2221 // Low-res tiles should not be enough. | 2181 // Low-res tiles should not be enough. |
2222 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2182 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2223 | 2183 |
2224 // Initialize remaining tiles. | 2184 // Initialize remaining tiles. |
2225 pending_layer_->SetAllTilesReady(); | 2185 pending_layer_->SetAllTilesReady(); |
2226 | 2186 |
2227 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2187 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2228 } | 2188 } |
2229 | 2189 |
2230 TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { | |
2231 gfx::Size tile_size(100, 100); | |
2232 gfx::Size layer_bounds(1000, 1000); | |
2233 | |
2234 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
2235 | |
2236 // Make sure some tiles are not shared. | |
2237 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | |
2238 | |
2239 CreateHighLowResAndSetAllTilesVisible(); | |
2240 active_layer_->SetAllTilesReady(); | |
2241 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2242 | |
2243 // All pending layer tiles required are not ready. | |
2244 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2245 | |
2246 // Initialize all high-res tiles. | |
2247 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | |
2248 | |
2249 // High-res tiles should not be enough. | |
2250 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2251 | |
2252 // Initialize remaining tiles. | |
2253 pending_layer_->SetAllTilesReady(); | |
2254 | |
2255 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2256 } | |
2257 | |
2258 class NoLowResTilingsSettings : public ImplSidePaintingSettings { | 2190 class NoLowResTilingsSettings : public ImplSidePaintingSettings { |
2259 public: | 2191 public: |
2260 NoLowResTilingsSettings() { create_low_res_tiling = false; } | 2192 NoLowResTilingsSettings() { create_low_res_tiling = false; } |
2261 }; | 2193 }; |
2262 | 2194 |
2263 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { | 2195 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { |
2264 public: | 2196 public: |
2265 NoLowResPictureLayerImplTest() | 2197 NoLowResPictureLayerImplTest() |
2266 : PictureLayerImplTest(NoLowResTilingsSettings()) {} | 2198 : PictureLayerImplTest(NoLowResTilingsSettings()) {} |
2267 }; | 2199 }; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2319 7.26f, // ideal contents scale | 2251 7.26f, // ideal contents scale |
2320 2.2f, // device scale | 2252 2.2f, // device scale |
2321 3.3f, // page scale | 2253 3.3f, // page scale |
2322 1.f, // maximum animation scale | 2254 1.f, // maximum animation scale |
2323 false); | 2255 false); |
2324 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 2256 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
2325 EXPECT_FLOAT_EQ(7.26f, | 2257 EXPECT_FLOAT_EQ(7.26f, |
2326 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2258 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
2327 } | 2259 } |
2328 | 2260 |
2329 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { | |
2330 gfx::Size tile_size(100, 100); | |
2331 gfx::Size layer_bounds(1000, 1000); | |
2332 | |
2333 scoped_refptr<FakePicturePileImpl> pending_pile = | |
2334 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
2335 // Layers with entirely empty piles can't get tilings. | |
2336 pending_pile->AddRecordingAt(0, 0); | |
2337 | |
2338 SetupPendingTree(pending_pile); | |
2339 | |
2340 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
2341 pending_layer_->AddTiling(1.0f); | |
2342 pending_layer_->AddTiling(2.0f); | |
2343 | |
2344 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
2345 // on a layer with no recordings. | |
2346 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2347 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2348 } | |
2349 | |
2350 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 2261 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
2351 gfx::Size layer_bounds(400, 400); | 2262 gfx::Size layer_bounds(400, 400); |
2352 gfx::Size tile_size(100, 100); | 2263 gfx::Size tile_size(100, 100); |
2353 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2264 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2354 | 2265 |
2355 CreateHighLowResAndSetAllTilesVisible(); | 2266 CreateHighLowResAndSetAllTilesVisible(); |
2356 | 2267 |
2357 Tile* some_active_tile = | 2268 Tile* some_active_tile = |
2358 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2269 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2359 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2270 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2360 | 2271 |
2361 // All tiles shared (no invalidation), so even though the active tree's | 2272 // All tiles shared (no invalidation), so even though the active tree's |
2362 // tiles aren't ready, there is nothing required. | 2273 // tiles aren't ready, there is nothing required. |
2363 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2364 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2274 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2365 if (host_impl_.settings().create_low_res_tiling) { | 2275 if (host_impl_.settings().create_low_res_tiling) { |
2366 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2276 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2367 } | 2277 } |
2368 } | 2278 } |
2369 | 2279 |
2370 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2280 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
2371 gfx::Size layer_bounds(400, 400); | 2281 gfx::Size layer_bounds(400, 400); |
2372 gfx::Size tile_size(100, 100); | 2282 gfx::Size tile_size(100, 100); |
2373 scoped_refptr<FakePicturePileImpl> pending_pile = | 2283 scoped_refptr<FakePicturePileImpl> pending_pile = |
(...skipping 12 matching lines...) Expand all Loading... | |
2386 CreateHighLowResAndSetAllTilesVisible(); | 2296 CreateHighLowResAndSetAllTilesVisible(); |
2387 | 2297 |
2388 // Active layer has tilings, but no tiles due to missing recordings. | 2298 // Active layer has tilings, but no tiles due to missing recordings. |
2389 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 2299 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
2390 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 2300 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
2391 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 2301 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
2392 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2302 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2393 | 2303 |
2394 // Since the active layer has no tiles at all, the pending layer doesn't | 2304 // Since the active layer has no tiles at all, the pending layer doesn't |
2395 // need content in order to activate. | 2305 // need content in order to activate. |
2396 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2397 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2306 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2398 if (host_impl_.settings().create_low_res_tiling) | 2307 if (host_impl_.settings().create_low_res_tiling) |
2399 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2308 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2400 } | 2309 } |
2401 | 2310 |
2402 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 2311 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
2403 base::TimeTicks time_ticks; | 2312 base::TimeTicks time_ticks; |
2404 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2313 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
2405 | 2314 |
2406 gfx::Size tile_size(100, 100); | 2315 gfx::Size tile_size(100, 100); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2954 layer1->SetBounds(layer_bounds); | 2863 layer1->SetBounds(layer_bounds); |
2955 layer1->SetContentBounds(layer_bounds); | 2864 layer1->SetContentBounds(layer_bounds); |
2956 layer1->SetDrawsContent(true); | 2865 layer1->SetDrawsContent(true); |
2957 layer1->SetContentsOpaque(true); | 2866 layer1->SetContentsOpaque(true); |
2958 layer1->SetPosition(occluding_layer_position); | 2867 layer1->SetPosition(occluding_layer_position); |
2959 | 2868 |
2960 host_impl_.pending_tree()->UpdateDrawProperties(); | 2869 host_impl_.pending_tree()->UpdateDrawProperties(); |
2961 | 2870 |
2962 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 2871 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
2963 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 2872 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
2873 tiling->CreateAllTilesForTesting(); | |
2964 | 2874 |
2965 occluded_tile_count = 0; | 2875 occluded_tile_count = 0; |
2966 for (PictureLayerTiling::CoverageIterator iter( | 2876 for (PictureLayerTiling::CoverageIterator iter( |
2967 tiling, | 2877 tiling, |
2968 pending_layer_->contents_scale_x(), | 2878 pending_layer_->contents_scale_x(), |
2969 gfx::Rect(layer_bounds)); | 2879 gfx::Rect(layer_bounds)); |
2970 iter; | 2880 iter; |
2971 ++iter) { | 2881 ++iter) { |
2972 if (!*iter) | 2882 if (!*iter) |
2973 continue; | 2883 continue; |
(...skipping 16 matching lines...) Expand all Loading... | |
2990 } | 2900 } |
2991 } | 2901 } |
2992 | 2902 |
2993 // Full occlusion. | 2903 // Full occlusion. |
2994 layer1->SetPosition(gfx::PointF(0, 0)); | 2904 layer1->SetPosition(gfx::PointF(0, 0)); |
2995 | 2905 |
2996 host_impl_.pending_tree()->UpdateDrawProperties(); | 2906 host_impl_.pending_tree()->UpdateDrawProperties(); |
2997 | 2907 |
2998 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 2908 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
2999 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 2909 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
2910 tiling->CreateAllTilesForTesting(); | |
3000 | 2911 |
3001 occluded_tile_count = 0; | 2912 occluded_tile_count = 0; |
3002 for (PictureLayerTiling::CoverageIterator iter( | 2913 for (PictureLayerTiling::CoverageIterator iter( |
3003 tiling, | 2914 tiling, |
3004 pending_layer_->contents_scale_x(), | 2915 pending_layer_->contents_scale_x(), |
3005 gfx::Rect(layer_bounds)); | 2916 gfx::Rect(layer_bounds)); |
3006 iter; | 2917 iter; |
3007 ++iter) { | 2918 ++iter) { |
3008 if (!*iter) | 2919 if (!*iter) |
3009 continue; | 2920 continue; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3059 | 2970 |
3060 host_impl_.SetViewportSize(viewport_size); | 2971 host_impl_.SetViewportSize(viewport_size); |
3061 host_impl_.pending_tree()->UpdateDrawProperties(); | 2972 host_impl_.pending_tree()->UpdateDrawProperties(); |
3062 | 2973 |
3063 int tiling_count = 0; | 2974 int tiling_count = 0; |
3064 int occluded_tile_count = 0; | 2975 int occluded_tile_count = 0; |
3065 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 2976 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
3066 tilings.begin(); | 2977 tilings.begin(); |
3067 tiling_iterator != tilings.end(); | 2978 tiling_iterator != tilings.end(); |
3068 ++tiling_iterator) { | 2979 ++tiling_iterator) { |
2980 (*tiling_iterator)->CreateAllTilesForTesting(); | |
3069 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 2981 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
3070 | 2982 |
3071 occluded_tile_count = 0; | 2983 occluded_tile_count = 0; |
3072 for (size_t i = 0; i < tiles.size(); ++i) { | 2984 for (size_t i = 0; i < tiles.size(); ++i) { |
3073 if (tiles[i]->is_occluded()) { | 2985 if (tiles[i]->is_occluded()) { |
3074 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 2986 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
3075 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); | 2987 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); |
3076 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 2988 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
3077 occluded_tile_count++; | 2989 occluded_tile_count++; |
3078 } | 2990 } |
(...skipping 16 matching lines...) Expand all Loading... | |
3095 NOTREACHED(); | 3007 NOTREACHED(); |
3096 } | 3008 } |
3097 | 3009 |
3098 tiling_count++; | 3010 tiling_count++; |
3099 } | 3011 } |
3100 | 3012 |
3101 EXPECT_EQ(tiling_count, 5); | 3013 EXPECT_EQ(tiling_count, 5); |
3102 } | 3014 } |
3103 } // namespace | 3015 } // namespace |
3104 } // namespace cc | 3016 } // namespace cc |
OLD | NEW |