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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 | 1234 |
1235 AppendQuadsData data; | 1235 AppendQuadsData data; |
1236 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); | 1236 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); |
1237 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 1237 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
1238 active_layer_->DidDraw(NULL); | 1238 active_layer_->DidDraw(NULL); |
1239 | 1239 |
1240 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1240 ASSERT_EQ(1U, render_pass->quad_list.size()); |
1241 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); | 1241 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, render_pass->quad_list[0]->material); |
1242 } | 1242 } |
1243 | 1243 |
1244 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { | |
1245 gfx::Size tile_size(100, 100); | |
1246 gfx::Size layer_bounds(1000, 1000); | |
1247 | |
1248 scoped_refptr<FakePicturePileImpl> pending_pile = | |
1249 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
1250 // Layers with entirely empty piles can't get tilings. | |
1251 pending_pile->AddRecordingAt(0, 0); | |
1252 | |
1253 SetupPendingTree(pending_pile); | |
1254 | |
1255 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
1256 pending_layer_->AddTiling(1.0f); | |
1257 pending_layer_->AddTiling(2.0f); | |
1258 | |
1259 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
1260 // on a layer with no recordings. | |
1261 host_impl_.pending_tree()->UpdateDrawProperties(); | |
1262 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1263 } | |
1264 | |
1265 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1244 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
1266 gfx::Size tile_size(100, 100); | 1245 gfx::Size tile_size(100, 100); |
1267 gfx::Size layer_bounds(200, 200); | 1246 gfx::Size layer_bounds(200, 200); |
1268 | 1247 |
1269 scoped_refptr<FakePicturePileImpl> pending_pile = | 1248 scoped_refptr<FakePicturePileImpl> pending_pile = |
1270 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1249 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1271 SetupPendingTree(pending_pile); | 1250 SetupPendingTree(pending_pile); |
1272 | 1251 |
1273 pending_layer_->set_fixed_tile_size(tile_size); | 1252 pending_layer_->set_fixed_tile_size(tile_size); |
1274 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1253 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
1275 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1254 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
1276 host_impl_.pending_tree()->UpdateDrawProperties(); | 1255 host_impl_.pending_tree()->UpdateDrawProperties(); |
1277 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | |
1278 | |
1279 pending_layer_->draw_properties().visible_content_rect = | 1256 pending_layer_->draw_properties().visible_content_rect = |
1280 gfx::Rect(0, 0, 100, 200); | 1257 gfx::Rect(0, 0, 100, 200); |
| 1258 pending_layer_->UpdateTiles(NULL); |
1281 | 1259 |
1282 // Fake set priorities. | 1260 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
1283 for (PictureLayerTiling::CoverageIterator iter( | |
1284 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | |
1285 iter; | |
1286 ++iter) { | |
1287 if (!*iter) | |
1288 continue; | |
1289 Tile* tile = *iter; | |
1290 TilePriority priority; | |
1291 priority.resolution = HIGH_RESOLUTION; | |
1292 gfx::Rect tile_bounds = iter.geometry_rect(); | |
1293 if (pending_layer_->visible_content_rect().Intersects(tile_bounds)) { | |
1294 priority.priority_bin = TilePriority::NOW; | |
1295 priority.distance_to_visible = 0.f; | |
1296 } else { | |
1297 priority.priority_bin = TilePriority::SOON; | |
1298 priority.distance_to_visible = 1.f; | |
1299 } | |
1300 tile->SetPriority(PENDING_TREE, priority); | |
1301 } | |
1302 | |
1303 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1304 | 1261 |
1305 int num_visible = 0; | 1262 int num_visible = 0; |
1306 int num_offscreen = 0; | 1263 int num_offscreen = 0; |
1307 | 1264 |
1308 for (PictureLayerTiling::CoverageIterator iter( | 1265 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling, PENDING_TREE); |
1309 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | |
1310 iter; | 1266 iter; |
1311 ++iter) { | 1267 ++iter) { |
1312 if (!*iter) | |
1313 continue; | |
1314 const Tile* tile = *iter; | 1268 const Tile* tile = *iter; |
1315 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1269 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
1316 EXPECT_TRUE(tile->required_for_activation()); | 1270 EXPECT_TRUE(tile->required_for_activation()); |
1317 num_visible++; | 1271 num_visible++; |
1318 } else { | 1272 } else { |
1319 EXPECT_FALSE(tile->required_for_activation()); | 1273 EXPECT_FALSE(tile->required_for_activation()); |
1320 num_offscreen++; | 1274 num_offscreen++; |
1321 } | 1275 } |
1322 } | 1276 } |
1323 | 1277 |
1324 EXPECT_GT(num_visible, 0); | 1278 EXPECT_GT(num_visible, 0); |
1325 EXPECT_GT(num_offscreen, 0); | 1279 EXPECT_GT(num_offscreen, 0); |
1326 } | 1280 } |
1327 | 1281 // |
1328 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 1282 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
1329 gfx::Size layer_bounds(400, 400); | 1283 gfx::Size layer_bounds(400, 400); |
1330 gfx::Size tile_size(100, 100); | 1284 gfx::Size tile_size(100, 100); |
1331 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1285 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1332 | 1286 |
1333 // No tiles shared. | 1287 // No tiles shared. |
1334 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); | 1288 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); |
1335 | 1289 |
1336 CreateHighLowResAndSetAllTilesVisible(); | 1290 CreateHighLowResAndSetAllTilesVisible(); |
1337 | 1291 |
1338 active_layer_->SetAllTilesReady(); | 1292 active_layer_->SetAllTilesReady(); |
1339 | 1293 |
1340 // No shared tiles and all active tiles ready, so pending can only | 1294 // No shared tiles and all active tiles ready, so pending can only |
1341 // activate with all high res tiles. | 1295 // activate with all high res tiles. |
1342 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1343 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1296 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1344 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1297 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1345 } | 1298 } |
1346 | 1299 |
1347 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 1300 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
1348 gfx::Size layer_bounds(400, 400); | 1301 gfx::Size layer_bounds(400, 400); |
1349 gfx::Size tile_size(100, 100); | 1302 gfx::Size tile_size(100, 100); |
1350 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1303 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1351 | 1304 |
| 1305 host_impl_.active_tree()->SetRequiresHighResToDraw(); |
| 1306 |
1352 // All tiles shared (no invalidation). | 1307 // All tiles shared (no invalidation). |
1353 CreateHighLowResAndSetAllTilesVisible(); | 1308 CreateHighLowResAndSetAllTilesVisible(); |
1354 | 1309 |
1355 // Verify active tree not ready. | 1310 // Verify active tree not ready. |
1356 Tile* some_active_tile = | 1311 Tile* some_active_tile = |
1357 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1312 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1358 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1313 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1359 | 1314 |
1360 // When high res are required, even if the active tree is not ready, | 1315 // When high res are required, even if the active tree is not ready, |
1361 // the high res tiles must be ready. | 1316 // the high res tiles must be ready. |
1362 host_impl_.active_tree()->SetRequiresHighResToDraw(); | |
1363 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1364 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1317 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1365 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1318 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1366 } | 1319 } |
1367 | 1320 |
1368 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 1321 TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
1369 gfx::Size layer_bounds(400, 400); | 1322 gfx::Size layer_bounds(400, 400); |
1370 gfx::Size tile_size(100, 100); | 1323 gfx::Size tile_size(100, 100); |
1371 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1324 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1372 | 1325 |
1373 CreateHighLowResAndSetAllTilesVisible(); | 1326 CreateHighLowResAndSetAllTilesVisible(); |
1374 | 1327 |
1375 Tile* some_active_tile = | 1328 Tile* some_active_tile = |
1376 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1329 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1377 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1330 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1378 | 1331 |
1379 // All tiles shared (no invalidation), so even though the active tree's | 1332 // All tiles shared (no invalidation), so even though the active tree's |
1380 // tiles aren't ready, there is nothing required. | 1333 // tiles aren't ready, there is nothing required. |
1381 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1382 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1334 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1383 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1335 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1384 } | 1336 } |
1385 | 1337 |
1386 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1338 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1387 gfx::Size layer_bounds(400, 400); | 1339 gfx::Size layer_bounds(400, 400); |
1388 gfx::Size tile_size(100, 100); | 1340 gfx::Size tile_size(100, 100); |
1389 scoped_refptr<FakePicturePileImpl> pending_pile = | 1341 scoped_refptr<FakePicturePileImpl> pending_pile = |
1390 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1342 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1391 // This pile will create tilings, but has no recordings so will not create any | 1343 // This pile will create tilings, but has no recordings so will not create any |
1392 // tiles. This is attempting to simulate scrolling past the end of recorded | 1344 // tiles. This is attempting to simulate scrolling past the end of recorded |
1393 // content on the active layer, where the recordings are so far away that | 1345 // content on the active layer, where the recordings are so far away that |
1394 // no tiles are created. | 1346 // no tiles are created. |
1395 scoped_refptr<FakePicturePileImpl> active_pile = | 1347 scoped_refptr<FakePicturePileImpl> active_pile = |
1396 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1348 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1397 tile_size, layer_bounds); | 1349 tile_size, layer_bounds); |
1398 SetupTrees(pending_pile, active_pile); | 1350 SetupTrees(pending_pile, active_pile); |
1399 pending_layer_->set_fixed_tile_size(tile_size); | 1351 pending_layer_->set_fixed_tile_size(tile_size); |
1400 active_layer_->set_fixed_tile_size(tile_size); | 1352 active_layer_->set_fixed_tile_size(tile_size); |
1401 | 1353 |
1402 CreateHighLowResAndSetAllTilesVisible(); | 1354 CreateHighLowResAndSetAllTilesVisible(); |
1403 | 1355 |
1404 // Active layer has tilings, but no tiles due to missing recordings. | 1356 // Active layer has tilings, but no tiles due to missing recordings. |
1405 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1357 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1406 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1358 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
1407 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1359 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
1408 | 1360 |
1409 // Since the active layer has no tiles at all, the pending layer doesn't | 1361 // Since the active layer has no tiles at all, the pending layer doesn't |
1410 // need content in order to activate. | 1362 // need content in order to activate. |
1411 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1412 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1363 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1413 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1364 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1414 } | 1365 } |
1415 | 1366 |
1416 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1367 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
1417 gfx::Size layer_bounds(400, 400); | 1368 gfx::Size layer_bounds(400, 400); |
1418 gfx::Size tile_size(100, 100); | 1369 gfx::Size tile_size(100, 100); |
1419 scoped_refptr<FakePicturePileImpl> pending_pile = | 1370 scoped_refptr<FakePicturePileImpl> pending_pile = |
1420 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1371 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1421 scoped_refptr<FakePicturePileImpl> active_pile = | 1372 scoped_refptr<FakePicturePileImpl> active_pile = |
1422 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1373 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
1423 SetupTrees(pending_pile, active_pile); | 1374 SetupTrees(pending_pile, active_pile); |
1424 pending_layer_->set_fixed_tile_size(tile_size); | 1375 pending_layer_->set_fixed_tile_size(tile_size); |
1425 active_layer_->set_fixed_tile_size(tile_size); | 1376 active_layer_->set_fixed_tile_size(tile_size); |
1426 | 1377 |
1427 CreateHighLowResAndSetAllTilesVisible(); | 1378 CreateHighLowResAndSetAllTilesVisible(); |
1428 | 1379 |
1429 // Active layer can't have tiles. | 1380 // Active layer can't have tiles. |
1430 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1381 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
1431 | 1382 |
1432 // All high res tiles required. This should be considered identical | 1383 // All high res tiles required. This should be considered identical |
1433 // to the case where there is no active layer, to avoid flashing content. | 1384 // to the case where there is no active layer, to avoid flashing content. |
1434 // This can happen if a layer exists for a while and switches from | 1385 // This can happen if a layer exists for a while and switches from |
1435 // not being able to have content to having content. | 1386 // not being able to have content to having content. |
1436 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1437 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1387 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1438 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1388 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1439 } | 1389 } |
1440 | 1390 |
1441 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 1391 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
1442 gfx::Size layer_bounds(200, 200); | 1392 gfx::Size layer_bounds(200, 200); |
1443 gfx::Size tile_size(100, 100); | 1393 gfx::Size tile_size(100, 100); |
1444 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1394 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
1445 | 1395 |
1446 gfx::Size pending_layer_bounds(400, 400); | 1396 gfx::Size pending_layer_bounds(400, 400); |
1447 pending_layer_->SetBounds(pending_layer_bounds); | 1397 pending_layer_->SetBounds(pending_layer_bounds); |
1448 | 1398 |
1449 CreateHighLowResAndSetAllTilesVisible(); | 1399 CreateHighLowResAndSetAllTilesVisible(); |
| 1400 pending_layer_->HighResTiling()->UpdateTilePriorities( |
| 1401 PENDING_TREE, |
| 1402 gfx::Rect(pending_layer_bounds), |
| 1403 1.f, |
| 1404 1.f, |
| 1405 NULL, |
| 1406 NULL, |
| 1407 gfx::Transform()); |
| 1408 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
1450 | 1409 |
1451 active_layer_->SetAllTilesReady(); | 1410 active_layer_->SetAllTilesReady(); |
1452 | 1411 |
1453 // Since the active layer has different bounds, the pending layer needs all | 1412 // Since the active layer has different bounds, the pending layer needs all |
1454 // high res tiles in order to activate. | 1413 // high res tiles in order to activate. |
1455 pending_layer_->MarkVisibleResourcesAsRequired(); | |
1456 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1414 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1457 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1415 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1458 } | 1416 } |
1459 | 1417 |
1460 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 1418 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
1461 gfx::Size tile_size(100, 100); | 1419 gfx::Size tile_size(100, 100); |
1462 gfx::Size layer_bounds(400, 400); | 1420 gfx::Size layer_bounds(400, 400); |
1463 scoped_refptr<FakePicturePileImpl> pending_pile = | 1421 scoped_refptr<FakePicturePileImpl> pending_pile = |
1464 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1422 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1465 | 1423 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 EXPECT_EQ(3u, active_layer_->num_tilings()); | 1507 EXPECT_EQ(3u, active_layer_->num_tilings()); |
1550 EXPECT_EQ(3u, pending_layer_->num_tilings()); | 1508 EXPECT_EQ(3u, pending_layer_->num_tilings()); |
1551 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 1509 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
1552 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); | 1510 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); |
1553 PictureLayerTiling* pending_tiling = | 1511 PictureLayerTiling* pending_tiling = |
1554 pending_layer_->tilings()->tiling_at(i); | 1512 pending_layer_->tilings()->tiling_at(i); |
1555 | 1513 |
1556 ASSERT_TRUE(active_tiling); | 1514 ASSERT_TRUE(active_tiling); |
1557 ASSERT_TRUE(pending_tiling); | 1515 ASSERT_TRUE(pending_tiling); |
1558 | 1516 |
| 1517 active_tiling->CreateAllTilesForTesting(); |
| 1518 pending_tiling->CreateAllTilesForTesting(); |
| 1519 |
1559 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1520 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1560 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 1521 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
1561 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 1522 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
1562 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 1523 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
1563 | 1524 |
1564 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 1525 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
1565 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 1526 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); |
1566 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 1527 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); |
1567 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 1528 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
1568 | 1529 |
1569 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 1530 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
1570 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 1531 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
1571 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 1532 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
1572 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 1533 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
1573 } | 1534 } |
1574 } | 1535 } |
1575 | 1536 |
1576 TEST_F(PictureLayerImplTest, RemoveInvalidPendingTreeTilesOnSync) { | 1537 TEST_F(PictureLayerImplTest, RemoveInvalidPendingTreeTilesOnSync) { |
1577 SetupDefaultTrees(gfx::Size(1500, 1500)); | 1538 SetupDefaultTrees(gfx::Size(1500, 1500)); |
1578 AddDefaultTilingsWithInvalidation(gfx::Rect()); | 1539 AddDefaultTilingsWithInvalidation(gfx::Rect()); |
1579 | 1540 |
(...skipping 13 matching lines...) Expand all Loading... |
1593 EXPECT_EQ(3u, active_layer_->num_tilings()); | 1554 EXPECT_EQ(3u, active_layer_->num_tilings()); |
1594 EXPECT_EQ(3u, pending_layer_->num_tilings()); | 1555 EXPECT_EQ(3u, pending_layer_->num_tilings()); |
1595 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 1556 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
1596 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); | 1557 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); |
1597 PictureLayerTiling* pending_tiling = | 1558 PictureLayerTiling* pending_tiling = |
1598 pending_layer_->tilings()->tiling_at(i); | 1559 pending_layer_->tilings()->tiling_at(i); |
1599 | 1560 |
1600 ASSERT_TRUE(active_tiling); | 1561 ASSERT_TRUE(active_tiling); |
1601 ASSERT_TRUE(pending_tiling); | 1562 ASSERT_TRUE(pending_tiling); |
1602 | 1563 |
| 1564 active_tiling->CreateAllTilesForTesting(); |
| 1565 pending_tiling->CreateAllTilesForTesting(); |
| 1566 |
1603 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1567 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1604 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 1568 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
1605 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 1569 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
1606 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 1570 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
1607 | 1571 |
1608 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 1572 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
1609 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 1573 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); |
1610 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 1574 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); |
1611 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 1575 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
1612 | 1576 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 tilings.push_back(pending_layer_->AddTiling(2.0f)); | 2023 tilings.push_back(pending_layer_->AddTiling(2.0f)); |
2060 | 2024 |
2061 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 2025 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
2062 host_impl_.pending_tree()->UpdateDrawProperties(); | 2026 host_impl_.pending_tree()->UpdateDrawProperties(); |
2063 | 2027 |
2064 std::vector<Tile*> all_tiles; | 2028 std::vector<Tile*> all_tiles; |
2065 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 2029 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
2066 tilings.begin(); | 2030 tilings.begin(); |
2067 tiling_iterator != tilings.end(); | 2031 tiling_iterator != tilings.end(); |
2068 ++tiling_iterator) { | 2032 ++tiling_iterator) { |
| 2033 (*tiling_iterator)->CreateAllTilesForTesting(); |
2069 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 2034 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
2070 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 2035 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
2071 } | 2036 } |
2072 | 2037 |
2073 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 2038 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
2074 | 2039 |
2075 bool mark_required = false; | 2040 bool mark_required = false; |
2076 size_t number_of_marked_tiles = 0u; | 2041 size_t number_of_marked_tiles = 0u; |
2077 size_t number_of_unmarked_tiles = 0u; | 2042 size_t number_of_unmarked_tiles = 0u; |
2078 for (size_t i = 0; i < tilings.size(); ++i) { | 2043 for (size_t i = 0; i < tilings.size(); ++i) { |
2079 PictureLayerTiling* tiling = tilings.at(i); | 2044 PictureLayerTiling* tiling = tilings.at(i); |
2080 for (PictureLayerTiling::CoverageIterator iter( | 2045 for (PictureLayerTiling::CoverageIterator iter( |
2081 tiling, | 2046 tiling, |
2082 pending_layer_->contents_scale_x(), | 2047 pending_layer_->contents_scale_x(), |
2083 pending_layer_->visible_content_rect()); | 2048 pending_layer_->visible_content_rect()); |
2084 iter; | 2049 iter; |
2085 ++iter) { | 2050 ++iter) { |
2086 if (mark_required) { | 2051 if (mark_required) { |
2087 number_of_marked_tiles++; | 2052 number_of_marked_tiles++; |
2088 iter->MarkRequiredForActivation(); | 2053 iter->set_required_for_activation(true); |
2089 } else { | 2054 } else { |
2090 number_of_unmarked_tiles++; | 2055 number_of_unmarked_tiles++; |
2091 } | 2056 } |
2092 mark_required = !mark_required; | 2057 mark_required = !mark_required; |
2093 } | 2058 } |
2094 } | 2059 } |
2095 | 2060 |
2096 // Sanity checks. | 2061 // Sanity checks. |
2097 EXPECT_EQ(91u, all_tiles.size()); | 2062 EXPECT_EQ(91u, all_tiles.size()); |
2098 EXPECT_EQ(91u, all_tiles_set.size()); | 2063 EXPECT_EQ(91u, all_tiles_set.size()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 scoped_refptr<FakePicturePileImpl> pending_pile = | 2167 scoped_refptr<FakePicturePileImpl> pending_pile = |
2203 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); | 2168 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); |
2204 SetupPendingTree(pending_pile); | 2169 SetupPendingTree(pending_pile); |
2205 pending_layer_->SetBounds(layer_bounds); | 2170 pending_layer_->SetBounds(layer_bounds); |
2206 ActivateTree(); | 2171 ActivateTree(); |
2207 active_layer_->set_fixed_tile_size(tile_size); | 2172 active_layer_->set_fixed_tile_size(tile_size); |
2208 | 2173 |
2209 host_impl_.SetViewportSize(viewport_size); | 2174 host_impl_.SetViewportSize(viewport_size); |
2210 host_impl_.active_tree()->UpdateDrawProperties(); | 2175 host_impl_.active_tree()->UpdateDrawProperties(); |
2211 | 2176 |
| 2177 active_layer_->HighResTiling()->CreateAllTilesForTesting(); |
2212 std::vector<Tile*> tiles = | 2178 std::vector<Tile*> tiles = |
2213 active_layer_->HighResTiling()->AllTilesForTesting(); | 2179 active_layer_->HighResTiling()->AllTilesForTesting(); |
2214 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 2180 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
2215 | 2181 |
2216 { | 2182 { |
2217 SCOPED_TRACE("No occlusion"); | 2183 SCOPED_TRACE("No occlusion"); |
2218 gfx::Rect occluded; | 2184 gfx::Rect occluded; |
2219 impl.AppendQuadsWithOcclusion(active_layer_, occluded); | 2185 impl.AppendQuadsWithOcclusion(active_layer_, occluded); |
2220 | 2186 |
2221 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | 2187 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 gfx::Size tile_size(100, 100); | 2259 gfx::Size tile_size(100, 100); |
2294 gfx::Size layer_bounds(1000, 1000); | 2260 gfx::Size layer_bounds(1000, 1000); |
2295 | 2261 |
2296 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2262 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2297 | 2263 |
2298 // Make sure some tiles are not shared. | 2264 // Make sure some tiles are not shared. |
2299 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 2265 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
2300 | 2266 |
2301 CreateHighLowResAndSetAllTilesVisible(); | 2267 CreateHighLowResAndSetAllTilesVisible(); |
2302 active_layer_->SetAllTilesReady(); | 2268 active_layer_->SetAllTilesReady(); |
2303 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2304 | 2269 |
2305 // All pending layer tiles required are not ready. | 2270 // All pending layer tiles required are not ready. |
2306 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2271 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2307 | 2272 |
2308 // Initialize all low-res tiles. | 2273 // Initialize all low-res tiles. |
2309 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 2274 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
2310 | 2275 |
2311 // Low-res tiles should not be enough. | 2276 // Low-res tiles should not be enough. |
2312 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2277 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2313 | 2278 |
2314 // Initialize remaining tiles. | 2279 // Initialize remaining tiles. |
2315 pending_layer_->SetAllTilesReady(); | 2280 pending_layer_->SetAllTilesReady(); |
2316 | 2281 |
2317 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2282 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2318 } | 2283 } |
2319 | 2284 |
2320 TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { | |
2321 gfx::Size tile_size(100, 100); | |
2322 gfx::Size layer_bounds(1000, 1000); | |
2323 | |
2324 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
2325 | |
2326 // Make sure some tiles are not shared. | |
2327 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | |
2328 | |
2329 CreateHighLowResAndSetAllTilesVisible(); | |
2330 active_layer_->SetAllTilesReady(); | |
2331 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2332 | |
2333 // All pending layer tiles required are not ready. | |
2334 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2335 | |
2336 // Initialize all high-res tiles. | |
2337 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | |
2338 | |
2339 // High-res tiles should not be enough. | |
2340 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2341 | |
2342 // Initialize remaining tiles. | |
2343 pending_layer_->SetAllTilesReady(); | |
2344 | |
2345 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2346 } | |
2347 | |
2348 class NoLowResTilingsSettings : public ImplSidePaintingSettings { | 2285 class NoLowResTilingsSettings : public ImplSidePaintingSettings { |
2349 public: | 2286 public: |
2350 NoLowResTilingsSettings() { create_low_res_tiling = false; } | 2287 NoLowResTilingsSettings() { create_low_res_tiling = false; } |
2351 }; | 2288 }; |
2352 | 2289 |
2353 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { | 2290 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { |
2354 public: | 2291 public: |
2355 NoLowResPictureLayerImplTest() | 2292 NoLowResPictureLayerImplTest() |
2356 : PictureLayerImplTest(NoLowResTilingsSettings()) {} | 2293 : PictureLayerImplTest(NoLowResTilingsSettings()) {} |
2357 }; | 2294 }; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 7.26f, // ideal contents scale | 2346 7.26f, // ideal contents scale |
2410 2.2f, // device scale | 2347 2.2f, // device scale |
2411 3.3f, // page scale | 2348 3.3f, // page scale |
2412 1.f, // maximum animation scale | 2349 1.f, // maximum animation scale |
2413 false); | 2350 false); |
2414 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 2351 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
2415 EXPECT_FLOAT_EQ(7.26f, | 2352 EXPECT_FLOAT_EQ(7.26f, |
2416 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 2353 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
2417 } | 2354 } |
2418 | 2355 |
2419 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredNullTiles) { | |
2420 gfx::Size tile_size(100, 100); | |
2421 gfx::Size layer_bounds(1000, 1000); | |
2422 | |
2423 scoped_refptr<FakePicturePileImpl> pending_pile = | |
2424 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
2425 // Layers with entirely empty piles can't get tilings. | |
2426 pending_pile->AddRecordingAt(0, 0); | |
2427 | |
2428 SetupPendingTree(pending_pile); | |
2429 | |
2430 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
2431 pending_layer_->AddTiling(1.0f); | |
2432 pending_layer_->AddTiling(2.0f); | |
2433 | |
2434 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
2435 // on a layer with no recordings. | |
2436 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2437 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2438 } | |
2439 | |
2440 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { | 2356 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { |
2441 gfx::Size layer_bounds(400, 400); | 2357 gfx::Size layer_bounds(400, 400); |
2442 gfx::Size tile_size(100, 100); | 2358 gfx::Size tile_size(100, 100); |
2443 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2359 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2444 | 2360 |
2445 CreateHighLowResAndSetAllTilesVisible(); | 2361 CreateHighLowResAndSetAllTilesVisible(); |
2446 | 2362 |
2447 Tile* some_active_tile = | 2363 Tile* some_active_tile = |
2448 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 2364 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
2449 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 2365 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
2450 | 2366 |
2451 // All tiles shared (no invalidation), so even though the active tree's | 2367 // All tiles shared (no invalidation), so even though the active tree's |
2452 // tiles aren't ready, there is nothing required. | 2368 // tiles aren't ready, there is nothing required. |
2453 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2454 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2369 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2455 if (host_impl_.settings().create_low_res_tiling) { | 2370 if (host_impl_.settings().create_low_res_tiling) { |
2456 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2371 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2457 } | 2372 } |
2458 } | 2373 } |
2459 | 2374 |
2460 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2375 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
2461 gfx::Size layer_bounds(400, 400); | 2376 gfx::Size layer_bounds(400, 400); |
2462 gfx::Size tile_size(100, 100); | 2377 gfx::Size tile_size(100, 100); |
2463 scoped_refptr<FakePicturePileImpl> pending_pile = | 2378 scoped_refptr<FakePicturePileImpl> pending_pile = |
(...skipping 12 matching lines...) Expand all Loading... |
2476 CreateHighLowResAndSetAllTilesVisible(); | 2391 CreateHighLowResAndSetAllTilesVisible(); |
2477 | 2392 |
2478 // Active layer has tilings, but no tiles due to missing recordings. | 2393 // Active layer has tilings, but no tiles due to missing recordings. |
2479 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 2394 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
2480 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 2395 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
2481 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 2396 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
2482 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2397 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2483 | 2398 |
2484 // Since the active layer has no tiles at all, the pending layer doesn't | 2399 // Since the active layer has no tiles at all, the pending layer doesn't |
2485 // need content in order to activate. | 2400 // need content in order to activate. |
2486 pending_layer_->MarkVisibleResourcesAsRequired(); | |
2487 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 2401 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2488 if (host_impl_.settings().create_low_res_tiling) | 2402 if (host_impl_.settings().create_low_res_tiling) |
2489 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2403 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2490 } | 2404 } |
2491 | 2405 |
2492 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 2406 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
2493 base::TimeTicks time_ticks; | 2407 base::TimeTicks time_ticks; |
2494 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 2408 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
2495 | 2409 |
2496 gfx::Size tile_size(100, 100); | 2410 gfx::Size tile_size(100, 100); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3046 layer1->SetBounds(layer_bounds); | 2960 layer1->SetBounds(layer_bounds); |
3047 layer1->SetContentBounds(layer_bounds); | 2961 layer1->SetContentBounds(layer_bounds); |
3048 layer1->SetDrawsContent(true); | 2962 layer1->SetDrawsContent(true); |
3049 layer1->SetContentsOpaque(true); | 2963 layer1->SetContentsOpaque(true); |
3050 layer1->SetPosition(occluding_layer_position); | 2964 layer1->SetPosition(occluding_layer_position); |
3051 | 2965 |
3052 host_impl_.pending_tree()->UpdateDrawProperties(); | 2966 host_impl_.pending_tree()->UpdateDrawProperties(); |
3053 | 2967 |
3054 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 2968 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3055 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 2969 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 2970 tiling->CreateAllTilesForTesting(); |
3056 | 2971 |
3057 occluded_tile_count = 0; | 2972 occluded_tile_count = 0; |
3058 for (PictureLayerTiling::CoverageIterator iter( | 2973 for (PictureLayerTiling::CoverageIterator iter( |
3059 tiling, | 2974 tiling, |
3060 pending_layer_->contents_scale_x(), | 2975 pending_layer_->contents_scale_x(), |
3061 gfx::Rect(layer_bounds)); | 2976 gfx::Rect(layer_bounds)); |
3062 iter; | 2977 iter; |
3063 ++iter) { | 2978 ++iter) { |
3064 if (!*iter) | 2979 if (!*iter) |
3065 continue; | 2980 continue; |
(...skipping 16 matching lines...) Expand all Loading... |
3082 } | 2997 } |
3083 } | 2998 } |
3084 | 2999 |
3085 // Full occlusion. | 3000 // Full occlusion. |
3086 layer1->SetPosition(gfx::PointF(0, 0)); | 3001 layer1->SetPosition(gfx::PointF(0, 0)); |
3087 | 3002 |
3088 host_impl_.pending_tree()->UpdateDrawProperties(); | 3003 host_impl_.pending_tree()->UpdateDrawProperties(); |
3089 | 3004 |
3090 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3005 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3091 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3006 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
| 3007 tiling->CreateAllTilesForTesting(); |
3092 | 3008 |
3093 occluded_tile_count = 0; | 3009 occluded_tile_count = 0; |
3094 for (PictureLayerTiling::CoverageIterator iter( | 3010 for (PictureLayerTiling::CoverageIterator iter( |
3095 tiling, | 3011 tiling, |
3096 pending_layer_->contents_scale_x(), | 3012 pending_layer_->contents_scale_x(), |
3097 gfx::Rect(layer_bounds)); | 3013 gfx::Rect(layer_bounds)); |
3098 iter; | 3014 iter; |
3099 ++iter) { | 3015 ++iter) { |
3100 if (!*iter) | 3016 if (!*iter) |
3101 continue; | 3017 continue; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3151 | 3067 |
3152 host_impl_.SetViewportSize(viewport_size); | 3068 host_impl_.SetViewportSize(viewport_size); |
3153 host_impl_.pending_tree()->UpdateDrawProperties(); | 3069 host_impl_.pending_tree()->UpdateDrawProperties(); |
3154 | 3070 |
3155 int tiling_count = 0; | 3071 int tiling_count = 0; |
3156 int occluded_tile_count = 0; | 3072 int occluded_tile_count = 0; |
3157 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 3073 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
3158 tilings.begin(); | 3074 tilings.begin(); |
3159 tiling_iterator != tilings.end(); | 3075 tiling_iterator != tilings.end(); |
3160 ++tiling_iterator) { | 3076 ++tiling_iterator) { |
| 3077 (*tiling_iterator)->CreateAllTilesForTesting(); |
3161 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 3078 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
3162 | 3079 |
3163 occluded_tile_count = 0; | 3080 occluded_tile_count = 0; |
3164 for (size_t i = 0; i < tiles.size(); ++i) { | 3081 for (size_t i = 0; i < tiles.size(); ++i) { |
3165 if (tiles[i]->is_occluded(PENDING_TREE)) { | 3082 if (tiles[i]->is_occluded(PENDING_TREE)) { |
3166 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 3083 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
3167 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); | 3084 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); |
3168 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 3085 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
3169 occluded_tile_count++; | 3086 occluded_tile_count++; |
3170 } | 3087 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3291 // Unshared tiles are occluded on the active tree iff they lie beneath | 3208 // Unshared tiles are occluded on the active tree iff they lie beneath |
3292 // the occluding layer. | 3209 // the occluding layer. |
3293 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | 3210 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), |
3294 scaled_content_rect.x() >= occluding_layer_position.x()); | 3211 scaled_content_rect.x() >= occluding_layer_position.x()); |
3295 } | 3212 } |
3296 } | 3213 } |
3297 } | 3214 } |
3298 } | 3215 } |
3299 } // namespace | 3216 } // namespace |
3300 } // namespace cc | 3217 } // namespace cc |
OLD | NEW |