| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const Region& invalidation) { | 222 const Region& invalidation) { |
| 223 host_impl_.CreatePendingTree(); | 223 host_impl_.CreatePendingTree(); |
| 224 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, | 224 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.00001f, |
| 225 100000.f); | 225 100000.f); |
| 226 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 226 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 227 pending_tree->SetDeviceScaleFactor( | 227 pending_tree->SetDeviceScaleFactor( |
| 228 host_impl_.active_tree()->device_scale_factor()); | 228 host_impl_.active_tree()->device_scale_factor()); |
| 229 | 229 |
| 230 // Steal from the recycled tree if possible. | 230 // Steal from the recycled tree if possible. |
| 231 LayerImpl* pending_root = pending_tree->root_layer(); | 231 LayerImpl* pending_root = pending_tree->root_layer(); |
| 232 scoped_ptr<FakePictureLayerImpl> pending_layer; | 232 std::unique_ptr<FakePictureLayerImpl> pending_layer; |
| 233 DCHECK(!pending_root || pending_root->id() == root_id_); | 233 DCHECK(!pending_root || pending_root->id() == root_id_); |
| 234 if (!pending_root) { | 234 if (!pending_root) { |
| 235 scoped_ptr<LayerImpl> new_pending_root = | 235 std::unique_ptr<LayerImpl> new_pending_root = |
| 236 LayerImpl::Create(pending_tree, root_id_); | 236 LayerImpl::Create(pending_tree, root_id_); |
| 237 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); | 237 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); |
| 238 if (!tile_size.IsEmpty()) | 238 if (!tile_size.IsEmpty()) |
| 239 pending_layer->set_fixed_tile_size(tile_size); | 239 pending_layer->set_fixed_tile_size(tile_size); |
| 240 pending_layer->SetDrawsContent(true); | 240 pending_layer->SetDrawsContent(true); |
| 241 pending_layer->SetScrollClipLayer(new_pending_root->id()); | 241 pending_layer->SetScrollClipLayer(new_pending_root->id()); |
| 242 pending_root = new_pending_root.get(); | 242 pending_root = new_pending_root.get(); |
| 243 pending_tree->SetRootLayer(std::move(new_pending_root)); | 243 pending_tree->SetRootLayer(std::move(new_pending_root)); |
| 244 } else { | 244 } else { |
| 245 pending_layer.reset(static_cast<FakePictureLayerImpl*>( | 245 pending_layer.reset(static_cast<FakePictureLayerImpl*>( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // copy this over to the pending tree inside SetupPendingTreeInternal. | 386 // copy this over to the pending tree inside SetupPendingTreeInternal. |
| 387 host_impl_.active_tree()->SetDeviceScaleFactor(device_scale_factor); | 387 host_impl_.active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| 388 } | 388 } |
| 389 | 389 |
| 390 protected: | 390 protected: |
| 391 void TestQuadsForSolidColor(bool test_for_solid); | 391 void TestQuadsForSolidColor(bool test_for_solid); |
| 392 | 392 |
| 393 FakeImplTaskRunnerProvider task_runner_provider_; | 393 FakeImplTaskRunnerProvider task_runner_provider_; |
| 394 TestSharedBitmapManager shared_bitmap_manager_; | 394 TestSharedBitmapManager shared_bitmap_manager_; |
| 395 TestTaskGraphRunner task_graph_runner_; | 395 TestTaskGraphRunner task_graph_runner_; |
| 396 scoped_ptr<OutputSurface> output_surface_; | 396 std::unique_ptr<OutputSurface> output_surface_; |
| 397 FakeLayerTreeHostImpl host_impl_; | 397 FakeLayerTreeHostImpl host_impl_; |
| 398 int root_id_; | 398 int root_id_; |
| 399 int id_; | 399 int id_; |
| 400 FakePictureLayerImpl* pending_layer_; | 400 FakePictureLayerImpl* pending_layer_; |
| 401 FakePictureLayerImpl* old_pending_layer_; | 401 FakePictureLayerImpl* old_pending_layer_; |
| 402 FakePictureLayerImpl* active_layer_; | 402 FakePictureLayerImpl* active_layer_; |
| 403 | 403 |
| 404 private: | 404 private: |
| 405 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 405 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
| 406 }; | 406 }; |
| 407 | 407 |
| 408 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { | 408 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { |
| 409 public: | 409 public: |
| 410 NoLowResPictureLayerImplTest() | 410 NoLowResPictureLayerImplTest() |
| 411 : PictureLayerImplTest(NoLowResTilingsSettings()) {} | 411 : PictureLayerImplTest(NoLowResTilingsSettings()) {} |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 TEST_F(PictureLayerImplTest, TileGridAlignment) { | 414 TEST_F(PictureLayerImplTest, TileGridAlignment) { |
| 415 // Layer to span 4 raster tiles in x and in y | 415 // Layer to span 4 raster tiles in x and in y |
| 416 LayerTreeSettings settings; | 416 LayerTreeSettings settings; |
| 417 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, | 417 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, |
| 418 settings.default_tile_size.height() * 7 / 2); | 418 settings.default_tile_size.height() * 7 / 2); |
| 419 | 419 |
| 420 scoped_refptr<FakeRasterSource> pending_raster_source = | 420 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 421 FakeRasterSource::CreateFilled(layer_size); | 421 FakeRasterSource::CreateFilled(layer_size); |
| 422 | 422 |
| 423 // Create an active recording source, but make sure it's not solid. | 423 // Create an active recording source, but make sure it's not solid. |
| 424 scoped_ptr<FakeRecordingSource> active_recording_source = | 424 std::unique_ptr<FakeRecordingSource> active_recording_source = |
| 425 FakeRecordingSource::CreateFilledRecordingSource(layer_size); | 425 FakeRecordingSource::CreateFilledRecordingSource(layer_size); |
| 426 active_recording_source->SetLayerBounds(layer_size); | 426 active_recording_source->SetLayerBounds(layer_size); |
| 427 active_recording_source->add_draw_rect(gfx::Rect(layer_size)); | 427 active_recording_source->add_draw_rect(gfx::Rect(layer_size)); |
| 428 active_recording_source->add_draw_rect( | 428 active_recording_source->add_draw_rect( |
| 429 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1)); | 429 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1)); |
| 430 active_recording_source->Rerecord(); | 430 active_recording_source->Rerecord(); |
| 431 scoped_refptr<FakeRasterSource> active_raster_source = | 431 scoped_refptr<FakeRasterSource> active_raster_source = |
| 432 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(), | 432 FakeRasterSource::CreateFromRecordingSource(active_recording_source.get(), |
| 433 false); | 433 false); |
| 434 | 434 |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 maximum_animation_scale, | 1287 maximum_animation_scale, |
| 1288 starting_animation_scale, animating_transform); | 1288 starting_animation_scale, animating_transform); |
| 1289 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1289 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1290 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), | 1290 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), |
| 1291 contents_scale * low_res_factor); | 1291 contents_scale * low_res_factor); |
| 1292 EXPECT_FALSE(pending_layer_->LowResTiling()); | 1292 EXPECT_FALSE(pending_layer_->LowResTiling()); |
| 1293 EXPECT_EQ(active_layer_->num_tilings(), 2u); | 1293 EXPECT_EQ(active_layer_->num_tilings(), 2u); |
| 1294 EXPECT_EQ(pending_layer_->num_tilings(), 1u); | 1294 EXPECT_EQ(pending_layer_->num_tilings(), 1u); |
| 1295 | 1295 |
| 1296 // Mask layers dont create low res since they always fit on one tile. | 1296 // Mask layers dont create low res since they always fit on one tile. |
| 1297 scoped_ptr<FakePictureLayerImpl> mask = | 1297 std::unique_ptr<FakePictureLayerImpl> mask = |
| 1298 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1298 FakePictureLayerImpl::CreateMaskWithRasterSource( |
| 1299 host_impl_.pending_tree(), 3, pending_raster_source); | 1299 host_impl_.pending_tree(), 3, pending_raster_source); |
| 1300 mask->SetBounds(layer_bounds); | 1300 mask->SetBounds(layer_bounds); |
| 1301 mask->SetDrawsContent(true); | 1301 mask->SetDrawsContent(true); |
| 1302 pending_layer_->SetMaskLayer(std::move(mask)); | 1302 pending_layer_->SetMaskLayer(std::move(mask)); |
| 1303 pending_layer_->SetHasRenderSurface(true); | 1303 pending_layer_->SetHasRenderSurface(true); |
| 1304 RebuildPropertyTreesOnPendingTree(); | 1304 RebuildPropertyTreesOnPendingTree(); |
| 1305 host_impl_.pending_tree()->UpdateDrawProperties(false); | 1305 host_impl_.pending_tree()->UpdateDrawProperties(false); |
| 1306 | 1306 |
| 1307 FakePictureLayerImpl* mask_raw = | 1307 FakePictureLayerImpl* mask_raw = |
| 1308 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1308 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
| 1309 SetupDrawPropertiesAndUpdateTiles( | 1309 SetupDrawPropertiesAndUpdateTiles( |
| 1310 mask_raw, contents_scale, device_scale, page_scale, | 1310 mask_raw, contents_scale, device_scale, page_scale, |
| 1311 maximum_animation_scale, starting_animation_scale, animating_transform); | 1311 maximum_animation_scale, starting_animation_scale, animating_transform); |
| 1312 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); | 1312 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); |
| 1313 EXPECT_EQ(mask_raw->num_tilings(), 1u); | 1313 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1316 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
| 1317 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1317 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1318 | 1318 |
| 1319 gfx::Size layer_bounds(1000, 1000); | 1319 gfx::Size layer_bounds(1000, 1000); |
| 1320 | 1320 |
| 1321 scoped_refptr<FakeRasterSource> valid_raster_source = | 1321 scoped_refptr<FakeRasterSource> valid_raster_source = |
| 1322 FakeRasterSource::CreateFilled(layer_bounds); | 1322 FakeRasterSource::CreateFilled(layer_bounds); |
| 1323 SetupPendingTree(valid_raster_source); | 1323 SetupPendingTree(valid_raster_source); |
| 1324 | 1324 |
| 1325 scoped_ptr<FakePictureLayerImpl> mask_ptr = | 1325 std::unique_ptr<FakePictureLayerImpl> mask_ptr = |
| 1326 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1326 FakePictureLayerImpl::CreateMaskWithRasterSource( |
| 1327 host_impl_.pending_tree(), 3, valid_raster_source); | 1327 host_impl_.pending_tree(), 3, valid_raster_source); |
| 1328 mask_ptr->SetBounds(layer_bounds); | 1328 mask_ptr->SetBounds(layer_bounds); |
| 1329 mask_ptr->SetDrawsContent(true); | 1329 mask_ptr->SetDrawsContent(true); |
| 1330 pending_layer_->SetMaskLayer(std::move(mask_ptr)); | 1330 pending_layer_->SetMaskLayer(std::move(mask_ptr)); |
| 1331 pending_layer_->SetForceRenderSurface(true); | 1331 pending_layer_->SetForceRenderSurface(true); |
| 1332 | 1332 |
| 1333 RebuildPropertyTreesOnPendingTree(); | 1333 RebuildPropertyTreesOnPendingTree(); |
| 1334 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1334 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1335 bool update_lcd_text = false; | 1335 bool update_lcd_text = false; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1444 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1445 | 1445 |
| 1446 gfx::Size layer_bounds(1000, 1000); | 1446 gfx::Size layer_bounds(1000, 1000); |
| 1447 | 1447 |
| 1448 SetInitialDeviceScaleFactor(1.3f); | 1448 SetInitialDeviceScaleFactor(1.3f); |
| 1449 | 1449 |
| 1450 scoped_refptr<FakeRasterSource> valid_raster_source = | 1450 scoped_refptr<FakeRasterSource> valid_raster_source = |
| 1451 FakeRasterSource::CreateFilled(layer_bounds); | 1451 FakeRasterSource::CreateFilled(layer_bounds); |
| 1452 SetupPendingTree(valid_raster_source); | 1452 SetupPendingTree(valid_raster_source); |
| 1453 | 1453 |
| 1454 scoped_ptr<FakePictureLayerImpl> mask_ptr = | 1454 std::unique_ptr<FakePictureLayerImpl> mask_ptr = |
| 1455 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1455 FakePictureLayerImpl::CreateMaskWithRasterSource( |
| 1456 host_impl_.pending_tree(), 3, valid_raster_source); | 1456 host_impl_.pending_tree(), 3, valid_raster_source); |
| 1457 mask_ptr->SetBounds(layer_bounds); | 1457 mask_ptr->SetBounds(layer_bounds); |
| 1458 mask_ptr->SetDrawsContent(true); | 1458 mask_ptr->SetDrawsContent(true); |
| 1459 pending_layer_->SetMaskLayer(std::move(mask_ptr)); | 1459 pending_layer_->SetMaskLayer(std::move(mask_ptr)); |
| 1460 pending_layer_->SetForceRenderSurface(true); | 1460 pending_layer_->SetForceRenderSurface(true); |
| 1461 | 1461 |
| 1462 RebuildPropertyTreesOnPendingTree(); | 1462 RebuildPropertyTreesOnPendingTree(); |
| 1463 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1463 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1464 bool update_lcd_text = false; | 1464 bool update_lcd_text = false; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1532 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1533 host_impl_.settings().default_tile_size.ToString()); | 1533 host_impl_.settings().default_tile_size.ToString()); |
| 1534 | 1534 |
| 1535 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1535 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1536 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1536 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1537 tile->content_rect().size().ToString()); | 1537 tile->content_rect().size().ToString()); |
| 1538 | 1538 |
| 1539 ResetTilingsAndRasterScales(); | 1539 ResetTilingsAndRasterScales(); |
| 1540 | 1540 |
| 1541 // Change the max texture size on the output surface context. | 1541 // Change the max texture size on the output surface context. |
| 1542 scoped_ptr<TestWebGraphicsContext3D> context = | 1542 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 1543 TestWebGraphicsContext3D::Create(); | 1543 TestWebGraphicsContext3D::Create(); |
| 1544 context->set_max_texture_size(140); | 1544 context->set_max_texture_size(140); |
| 1545 host_impl_.DidLoseOutputSurface(); | 1545 host_impl_.DidLoseOutputSurface(); |
| 1546 scoped_ptr<OutputSurface> new_output_surface = | 1546 std::unique_ptr<OutputSurface> new_output_surface = |
| 1547 FakeOutputSurface::Create3d(std::move(context)); | 1547 FakeOutputSurface::Create3d(std::move(context)); |
| 1548 host_impl_.SetVisible(true); | 1548 host_impl_.SetVisible(true); |
| 1549 host_impl_.InitializeRenderer(new_output_surface.get()); | 1549 host_impl_.InitializeRenderer(new_output_surface.get()); |
| 1550 output_surface_ = std::move(new_output_surface); | 1550 output_surface_ = std::move(new_output_surface); |
| 1551 | 1551 |
| 1552 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 1552 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1553 false); | 1553 false); |
| 1554 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1554 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 1555 | 1555 |
| 1556 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1556 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1572 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1572 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1573 host_impl_.settings().max_untiled_layer_size.ToString()); | 1573 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1574 | 1574 |
| 1575 // There should be a single tile since the layer is small. | 1575 // There should be a single tile since the layer is small. |
| 1576 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); | 1576 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1577 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1577 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1578 | 1578 |
| 1579 ResetTilingsAndRasterScales(); | 1579 ResetTilingsAndRasterScales(); |
| 1580 | 1580 |
| 1581 // Change the max texture size on the output surface context. | 1581 // Change the max texture size on the output surface context. |
| 1582 scoped_ptr<TestWebGraphicsContext3D> context = | 1582 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 1583 TestWebGraphicsContext3D::Create(); | 1583 TestWebGraphicsContext3D::Create(); |
| 1584 context->set_max_texture_size(140); | 1584 context->set_max_texture_size(140); |
| 1585 host_impl_.DidLoseOutputSurface(); | 1585 host_impl_.DidLoseOutputSurface(); |
| 1586 scoped_ptr<OutputSurface> new_output_surface = | 1586 std::unique_ptr<OutputSurface> new_output_surface = |
| 1587 FakeOutputSurface::Create3d(std::move(context)); | 1587 FakeOutputSurface::Create3d(std::move(context)); |
| 1588 host_impl_.SetVisible(true); | 1588 host_impl_.SetVisible(true); |
| 1589 host_impl_.InitializeRenderer(new_output_surface.get()); | 1589 host_impl_.InitializeRenderer(new_output_surface.get()); |
| 1590 output_surface_ = std::move(new_output_surface); | 1590 output_surface_ = std::move(new_output_surface); |
| 1591 | 1591 |
| 1592 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 1592 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1593 false); | 1593 false); |
| 1594 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); | 1594 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); |
| 1595 | 1595 |
| 1596 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1596 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1597 | 1597 |
| 1598 // There should be more than one tile since the max texture size won't cover | 1598 // There should be more than one tile since the max texture size won't cover |
| 1599 // the layer. | 1599 // the layer. |
| 1600 high_res_tiling = active_layer_->tilings()->tiling_at(0); | 1600 high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1601 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1601 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1602 | 1602 |
| 1603 // Verify the tiles are not larger than the context's max texture size. | 1603 // Verify the tiles are not larger than the context's max texture size. |
| 1604 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1604 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1605 EXPECT_GE(140, tile->content_rect().width()); | 1605 EXPECT_GE(140, tile->content_rect().width()); |
| 1606 EXPECT_GE(140, tile->content_rect().height()); | 1606 EXPECT_GE(140, tile->content_rect().height()); |
| 1607 } | 1607 } |
| 1608 | 1608 |
| 1609 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { | 1609 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
| 1610 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1610 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1611 | 1611 |
| 1612 gfx::Size layer_bounds(1300, 1900); | 1612 gfx::Size layer_bounds(1300, 1900); |
| 1613 gfx::Rect layer_rect(layer_bounds); | 1613 gfx::Rect layer_rect(layer_bounds); |
| 1614 | 1614 |
| 1615 gfx::Rect layer_invalidation(150, 200, 30, 180); | 1615 gfx::Rect layer_invalidation(150, 200, 30, 180); |
| 1616 SetupDefaultTreesWithInvalidation(layer_bounds, layer_invalidation); | 1616 SetupDefaultTreesWithInvalidation(layer_bounds, layer_invalidation); |
| 1617 | 1617 |
| 1618 active_layer_->SetContentsOpaque(true); | 1618 active_layer_->SetContentsOpaque(true); |
| 1619 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); | 1619 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); |
| 1620 | 1620 |
| 1621 AppendQuadsData data; | 1621 AppendQuadsData data; |
| 1622 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); | 1622 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); |
| 1623 active_layer_->AppendQuads(render_pass.get(), &data); | 1623 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1624 active_layer_->DidDraw(nullptr); | 1624 active_layer_->DidDraw(nullptr); |
| 1625 | 1625 |
| 1626 ASSERT_EQ(1u, render_pass->quad_list.size()); | 1626 ASSERT_EQ(1u, render_pass->quad_list.size()); |
| 1627 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, | 1627 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, |
| 1628 render_pass->quad_list.front()->material); | 1628 render_pass->quad_list.front()->material); |
| 1629 EXPECT_EQ(render_pass->quad_list.front()->rect, layer_rect); | 1629 EXPECT_EQ(render_pass->quad_list.front()->rect, layer_rect); |
| 1630 EXPECT_EQ(render_pass->quad_list.front()->opaque_rect, layer_rect); | 1630 EXPECT_EQ(render_pass->quad_list.front()->opaque_rect, layer_rect); |
| 1631 EXPECT_EQ(render_pass->quad_list.front()->visible_rect, layer_rect); | 1631 EXPECT_EQ(render_pass->quad_list.front()->visible_rect, layer_rect); |
| 1632 } | 1632 } |
| 1633 | 1633 |
| 1634 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) { | 1634 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) { |
| 1635 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1635 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1636 | 1636 |
| 1637 gfx::Size tile_size(400, 400); | 1637 gfx::Size tile_size(400, 400); |
| 1638 gfx::Size layer_bounds(700, 650); | 1638 gfx::Size layer_bounds(700, 650); |
| 1639 gfx::Rect layer_rect(layer_bounds); | 1639 gfx::Rect layer_rect(layer_bounds); |
| 1640 SetInitialDeviceScaleFactor(2.f); | 1640 SetInitialDeviceScaleFactor(2.f); |
| 1641 | 1641 |
| 1642 gfx::Rect recorded_viewport(20, 30, 40, 50); | 1642 gfx::Rect recorded_viewport(20, 30, 40, 50); |
| 1643 scoped_refptr<FakeRasterSource> active_raster_source = | 1643 scoped_refptr<FakeRasterSource> active_raster_source = |
| 1644 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport); | 1644 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport); |
| 1645 | 1645 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1662 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1662 ASSERT_EQ(1U, render_pass->quad_list.size()); |
| 1663 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, | 1663 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, |
| 1664 render_pass->quad_list.front()->material); | 1664 render_pass->quad_list.front()->material); |
| 1665 const DrawQuad* quad = render_pass->quad_list.front(); | 1665 const DrawQuad* quad = render_pass->quad_list.front(); |
| 1666 EXPECT_EQ(quad_visible, quad->rect); | 1666 EXPECT_EQ(quad_visible, quad->rect); |
| 1667 EXPECT_EQ(quad_visible, quad->opaque_rect); | 1667 EXPECT_EQ(quad_visible, quad->opaque_rect); |
| 1668 EXPECT_EQ(quad_visible, quad->visible_rect); | 1668 EXPECT_EQ(quad_visible, quad->visible_rect); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) { | 1671 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) { |
| 1672 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1672 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1673 | 1673 |
| 1674 gfx::Size layer_bounds(700, 650); | 1674 gfx::Size layer_bounds(700, 650); |
| 1675 scoped_refptr<FakeRasterSource> active_raster_source = | 1675 scoped_refptr<FakeRasterSource> active_raster_source = |
| 1676 FakeRasterSource::CreatePartiallyFilled(layer_bounds, gfx::Rect()); | 1676 FakeRasterSource::CreatePartiallyFilled(layer_bounds, gfx::Rect()); |
| 1677 SetupPendingTree(active_raster_source); | 1677 SetupPendingTree(active_raster_source); |
| 1678 ActivateTree(); | 1678 ActivateTree(); |
| 1679 | 1679 |
| 1680 active_layer_->SetContentsOpaque(true); | 1680 active_layer_->SetContentsOpaque(true); |
| 1681 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); | 1681 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); |
| 1682 | 1682 |
| 1683 AppendQuadsData data; | 1683 AppendQuadsData data; |
| 1684 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); | 1684 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); |
| 1685 active_layer_->AppendQuads(render_pass.get(), &data); | 1685 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1686 active_layer_->DidDraw(nullptr); | 1686 active_layer_->DidDraw(nullptr); |
| 1687 | 1687 |
| 1688 EXPECT_EQ(0U, render_pass->quad_list.size()); | 1688 EXPECT_EQ(0U, render_pass->quad_list.size()); |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { | 1691 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { |
| 1692 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1692 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1693 | 1693 |
| 1694 gfx::Size layer_bounds(1500, 1500); | 1694 gfx::Size layer_bounds(1500, 1500); |
| 1695 gfx::Rect visible_rect(250, 250, 1000, 1000); | 1695 gfx::Rect visible_rect(250, 250, 1000, 1000); |
| 1696 | 1696 |
| 1697 scoped_refptr<FakeRasterSource> pending_raster_source = | 1697 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1698 FakeRasterSource::CreateFilledSolidColor(layer_bounds); | 1698 FakeRasterSource::CreateFilledSolidColor(layer_bounds); |
| 1699 scoped_refptr<FakeRasterSource> active_raster_source = | 1699 scoped_refptr<FakeRasterSource> active_raster_source = |
| 1700 FakeRasterSource::CreateFilledSolidColor(layer_bounds); | 1700 FakeRasterSource::CreateFilledSolidColor(layer_bounds); |
| 1701 | 1701 |
| 1702 SetupTrees(pending_raster_source, active_raster_source); | 1702 SetupTrees(pending_raster_source, active_raster_source); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 EXPECT_EQ(viewport, | 1753 EXPECT_EQ(viewport, |
| 1754 pending_layer_->viewport_rect_for_tile_priority_in_content_space()); | 1754 pending_layer_->viewport_rect_for_tile_priority_in_content_space()); |
| 1755 | 1755 |
| 1756 base::TimeTicks time_ticks; | 1756 base::TimeTicks time_ticks; |
| 1757 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1757 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1758 pending_layer_->UpdateTiles(); | 1758 pending_layer_->UpdateTiles(); |
| 1759 | 1759 |
| 1760 int num_visible = 0; | 1760 int num_visible = 0; |
| 1761 int num_offscreen = 0; | 1761 int num_offscreen = 0; |
| 1762 | 1762 |
| 1763 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1763 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 1764 pending_layer_->picture_layer_tiling_set(), false)); | 1764 pending_layer_->picture_layer_tiling_set(), false)); |
| 1765 for (; !queue->IsEmpty(); queue->Pop()) { | 1765 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1766 const PrioritizedTile& prioritized_tile = queue->Top(); | 1766 const PrioritizedTile& prioritized_tile = queue->Top(); |
| 1767 DCHECK(prioritized_tile.tile()); | 1767 DCHECK(prioritized_tile.tile()); |
| 1768 if (prioritized_tile.priority().distance_to_visible == 0.f) { | 1768 if (prioritized_tile.priority().distance_to_visible == 0.f) { |
| 1769 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); | 1769 EXPECT_TRUE(prioritized_tile.tile()->required_for_activation()); |
| 1770 num_visible++; | 1770 num_visible++; |
| 1771 } else { | 1771 } else { |
| 1772 EXPECT_FALSE(prioritized_tile.tile()->required_for_activation()); | 1772 EXPECT_FALSE(prioritized_tile.tile()->required_for_activation()); |
| 1773 num_offscreen++; | 1773 num_offscreen++; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 EXPECT_GT(num_inside, 0); | 1838 EXPECT_GT(num_inside, 0); |
| 1839 EXPECT_GT(num_outside, 0); | 1839 EXPECT_GT(num_outside, 0); |
| 1840 | 1840 |
| 1841 // Activate and draw active layer. | 1841 // Activate and draw active layer. |
| 1842 host_impl_.ActivateSyncTree(); | 1842 host_impl_.ActivateSyncTree(); |
| 1843 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 1843 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 1844 active_layer_->draw_properties().visible_layer_rect = visible_layer_rect; | 1844 active_layer_->draw_properties().visible_layer_rect = visible_layer_rect; |
| 1845 | 1845 |
| 1846 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1846 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1847 AppendQuadsData data; | 1847 AppendQuadsData data; |
| 1848 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1848 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1849 active_layer_->AppendQuads(render_pass.get(), &data); | 1849 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1850 active_layer_->DidDraw(nullptr); | 1850 active_layer_->DidDraw(nullptr); |
| 1851 | 1851 |
| 1852 // All tiles in activation rect is ready to draw. | 1852 // All tiles in activation rect is ready to draw. |
| 1853 EXPECT_EQ(0u, data.num_missing_tiles); | 1853 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1854 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1854 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1855 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1855 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 1856 } | 1856 } |
| 1857 | 1857 |
| 1858 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { | 1858 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { |
| 1859 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1859 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1860 | 1860 |
| 1861 gfx::Size tile_size(100, 100); | 1861 gfx::Size tile_size(100, 100); |
| 1862 gfx::Size layer_bounds(200, 200); | 1862 gfx::Size layer_bounds(200, 200); |
| 1863 | 1863 |
| 1864 scoped_refptr<FakeRasterSource> pending_raster_source = | 1864 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1865 FakeRasterSource::CreateFilled(layer_bounds); | 1865 FakeRasterSource::CreateFilled(layer_bounds); |
| 1866 | 1866 |
| 1867 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 1867 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 1868 ActivateTree(); | 1868 ActivateTree(); |
| 1869 | 1869 |
| 1870 // All high res tiles have resources. | 1870 // All high res tiles have resources. |
| 1871 std::vector<Tile*> tiles = | 1871 std::vector<Tile*> tiles = |
| 1872 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 1872 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 1873 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 1873 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 1874 | 1874 |
| 1875 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1875 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1876 AppendQuadsData data; | 1876 AppendQuadsData data; |
| 1877 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1877 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1878 active_layer_->AppendQuads(render_pass.get(), &data); | 1878 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1879 active_layer_->DidDraw(nullptr); | 1879 active_layer_->DidDraw(nullptr); |
| 1880 | 1880 |
| 1881 // All high res tiles drew, nothing was incomplete. | 1881 // All high res tiles drew, nothing was incomplete. |
| 1882 EXPECT_EQ(9u, render_pass->quad_list.size()); | 1882 EXPECT_EQ(9u, render_pass->quad_list.size()); |
| 1883 EXPECT_EQ(0u, data.num_missing_tiles); | 1883 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1884 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1884 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1885 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1885 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 1886 } | 1886 } |
| 1887 | 1887 |
| 1888 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { | 1888 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { |
| 1889 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1889 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1890 | 1890 |
| 1891 gfx::Size tile_size(100, 100); | 1891 gfx::Size tile_size(100, 100); |
| 1892 gfx::Size layer_bounds(200, 200); | 1892 gfx::Size layer_bounds(200, 200); |
| 1893 | 1893 |
| 1894 scoped_refptr<FakeRasterSource> pending_raster_source = | 1894 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1895 FakeRasterSource::CreateFilled(layer_bounds); | 1895 FakeRasterSource::CreateFilled(layer_bounds); |
| 1896 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 1896 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 1897 ActivateTree(); | 1897 ActivateTree(); |
| 1898 | 1898 |
| 1899 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1899 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1900 AppendQuadsData data; | 1900 AppendQuadsData data; |
| 1901 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1901 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1902 active_layer_->AppendQuads(render_pass.get(), &data); | 1902 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1903 active_layer_->DidDraw(nullptr); | 1903 active_layer_->DidDraw(nullptr); |
| 1904 | 1904 |
| 1905 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1905 EXPECT_EQ(1u, render_pass->quad_list.size()); |
| 1906 EXPECT_EQ(1u, data.num_missing_tiles); | 1906 EXPECT_EQ(1u, data.num_missing_tiles); |
| 1907 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1907 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1908 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1908 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
| 1909 } | 1909 } |
| 1910 | 1910 |
| 1911 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { | 1911 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { |
| 1912 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1912 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1913 | 1913 |
| 1914 gfx::Size tile_size(100, 100); | 1914 gfx::Size tile_size(100, 100); |
| 1915 gfx::Size layer_bounds(200, 200); | 1915 gfx::Size layer_bounds(200, 200); |
| 1916 | 1916 |
| 1917 scoped_refptr<FakeRasterSource> pending_raster_source = | 1917 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1918 FakeRasterSource::CreateFilled(layer_bounds); | 1918 FakeRasterSource::CreateFilled(layer_bounds); |
| 1919 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 1919 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 1920 ActivateTree(); | 1920 ActivateTree(); |
| 1921 | 1921 |
| 1922 std::vector<Tile*> low_tiles = | 1922 std::vector<Tile*> low_tiles = |
| 1923 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1923 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
| 1924 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1924 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
| 1925 | 1925 |
| 1926 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1926 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1927 AppendQuadsData data; | 1927 AppendQuadsData data; |
| 1928 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1928 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1929 active_layer_->AppendQuads(render_pass.get(), &data); | 1929 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1930 active_layer_->DidDraw(nullptr); | 1930 active_layer_->DidDraw(nullptr); |
| 1931 | 1931 |
| 1932 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1932 EXPECT_EQ(1u, render_pass->quad_list.size()); |
| 1933 EXPECT_EQ(0u, data.num_missing_tiles); | 1933 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1934 EXPECT_EQ(1u, data.num_incomplete_tiles); | 1934 EXPECT_EQ(1u, data.num_incomplete_tiles); |
| 1935 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1935 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
| 1936 } | 1936 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1950 std::vector<Tile*> high_tiles = | 1950 std::vector<Tile*> high_tiles = |
| 1951 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 1951 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 1952 high_tiles.erase(high_tiles.begin()); | 1952 high_tiles.erase(high_tiles.begin()); |
| 1953 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 1953 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
| 1954 | 1954 |
| 1955 // All low res tiles have resources. | 1955 // All low res tiles have resources. |
| 1956 std::vector<Tile*> low_tiles = | 1956 std::vector<Tile*> low_tiles = |
| 1957 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1957 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
| 1958 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1958 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
| 1959 | 1959 |
| 1960 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1960 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1961 AppendQuadsData data; | 1961 AppendQuadsData data; |
| 1962 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1962 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1963 active_layer_->AppendQuads(render_pass.get(), &data); | 1963 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1964 active_layer_->DidDraw(nullptr); | 1964 active_layer_->DidDraw(nullptr); |
| 1965 | 1965 |
| 1966 // The missing high res tile was replaced by a low res tile. | 1966 // The missing high res tile was replaced by a low res tile. |
| 1967 EXPECT_EQ(9u, render_pass->quad_list.size()); | 1967 EXPECT_EQ(9u, render_pass->quad_list.size()); |
| 1968 EXPECT_EQ(0u, data.num_missing_tiles); | 1968 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1969 EXPECT_EQ(1u, data.num_incomplete_tiles); | 1969 EXPECT_EQ(1u, data.num_incomplete_tiles); |
| 1970 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1970 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2003 // Both tilings still exist. | 2003 // Both tilings still exist. |
| 2004 ASSERT_GE(active_layer_->tilings()->num_tilings(), 2u); | 2004 ASSERT_GE(active_layer_->tilings()->num_tilings(), 2u); |
| 2005 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); | 2005 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2006 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); | 2006 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 2007 | 2007 |
| 2008 // All high res tiles have resources. | 2008 // All high res tiles have resources. |
| 2009 std::vector<Tile*> high_tiles = | 2009 std::vector<Tile*> high_tiles = |
| 2010 active_layer_->HighResTiling()->AllTilesForTesting(); | 2010 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 2011 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 2011 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
| 2012 | 2012 |
| 2013 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 2013 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 2014 AppendQuadsData data; | 2014 AppendQuadsData data; |
| 2015 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 2015 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 2016 active_layer_->AppendQuads(render_pass.get(), &data); | 2016 active_layer_->AppendQuads(render_pass.get(), &data); |
| 2017 active_layer_->DidDraw(nullptr); | 2017 active_layer_->DidDraw(nullptr); |
| 2018 | 2018 |
| 2019 // All high res tiles drew, and the one ideal res tile drew. | 2019 // All high res tiles drew, and the one ideal res tile drew. |
| 2020 ASSERT_GT(render_pass->quad_list.size(), 9u); | 2020 ASSERT_GT(render_pass->quad_list.size(), 9u); |
| 2021 EXPECT_EQ(gfx::SizeF(99.f, 99.f), | 2021 EXPECT_EQ(gfx::SizeF(99.f, 99.f), |
| 2022 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) | 2022 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) |
| 2023 ->tex_coord_rect.size()); | 2023 ->tex_coord_rect.size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2036 | 2036 |
| 2037 gfx::Size tile_size(100, 100); | 2037 gfx::Size tile_size(100, 100); |
| 2038 gfx::Size layer_bounds(200, 200); | 2038 gfx::Size layer_bounds(200, 200); |
| 2039 gfx::Rect recorded_viewport(0, 0, 150, 150); | 2039 gfx::Rect recorded_viewport(0, 0, 150, 150); |
| 2040 | 2040 |
| 2041 scoped_refptr<FakeRasterSource> pending_raster_source = | 2041 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 2042 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport); | 2042 FakeRasterSource::CreatePartiallyFilled(layer_bounds, recorded_viewport); |
| 2043 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 2043 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 2044 ActivateTree(); | 2044 ActivateTree(); |
| 2045 | 2045 |
| 2046 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 2046 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 2047 AppendQuadsData data; | 2047 AppendQuadsData data; |
| 2048 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 2048 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 2049 active_layer_->AppendQuads(render_pass.get(), &data); | 2049 active_layer_->AppendQuads(render_pass.get(), &data); |
| 2050 active_layer_->DidDraw(nullptr); | 2050 active_layer_->DidDraw(nullptr); |
| 2051 | 2051 |
| 2052 EXPECT_EQ(1u, render_pass->quad_list.size()); | 2052 EXPECT_EQ(1u, render_pass->quad_list.size()); |
| 2053 EXPECT_EQ(1u, data.num_missing_tiles); | 2053 EXPECT_EQ(1u, data.num_missing_tiles); |
| 2054 EXPECT_EQ(0u, data.num_incomplete_tiles); | 2054 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 2055 EXPECT_EQ(40000, data.checkerboarded_visible_content_area); | 2055 EXPECT_EQ(40000, data.checkerboarded_visible_content_area); |
| 2056 EXPECT_EQ(17500, data.checkerboarded_no_recording_content_area); | 2056 EXPECT_EQ(17500, data.checkerboarded_no_recording_content_area); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 } | 2225 } |
| 2226 | 2226 |
| 2227 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { | 2227 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { |
| 2228 gfx::Size layer_bounds(400, 400); | 2228 gfx::Size layer_bounds(400, 400); |
| 2229 scoped_refptr<FakeRasterSource> pending_raster_source = | 2229 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 2230 FakeRasterSource::CreateFilled(layer_bounds); | 2230 FakeRasterSource::CreateFilled(layer_bounds); |
| 2231 | 2231 |
| 2232 host_impl_.CreatePendingTree(); | 2232 host_impl_.CreatePendingTree(); |
| 2233 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 2233 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 2234 | 2234 |
| 2235 scoped_ptr<FakePictureLayerImpl> pending_layer = | 2235 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 2236 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, | 2236 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
| 2237 pending_raster_source); | 2237 pending_raster_source); |
| 2238 pending_layer->SetDrawsContent(true); | 2238 pending_layer->SetDrawsContent(true); |
| 2239 pending_tree->SetRootLayer(std::move(pending_layer)); | 2239 pending_tree->SetRootLayer(std::move(pending_layer)); |
| 2240 | 2240 |
| 2241 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 2241 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 2242 host_impl_.pending_tree()->LayerById(id_)); | 2242 host_impl_.pending_tree()->LayerById(id_)); |
| 2243 | 2243 |
| 2244 // Set some state on the pending layer, make sure it is not clobbered | 2244 // Set some state on the pending layer, make sure it is not clobbered |
| 2245 // by a sync from the active layer. This could happen because if the | 2245 // by a sync from the active layer. This could happen because if the |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2888 | 2888 |
| 2889 SetupPendingTree(pending_raster_source); | 2889 SetupPendingTree(pending_raster_source); |
| 2890 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 2890 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 2891 | 2891 |
| 2892 std::set<Tile*> unique_tiles; | 2892 std::set<Tile*> unique_tiles; |
| 2893 bool reached_prepaint = false; | 2893 bool reached_prepaint = false; |
| 2894 int non_ideal_tile_count = 0u; | 2894 int non_ideal_tile_count = 0u; |
| 2895 int low_res_tile_count = 0u; | 2895 int low_res_tile_count = 0u; |
| 2896 int high_res_tile_count = 0u; | 2896 int high_res_tile_count = 0u; |
| 2897 int high_res_now_tiles = 0u; | 2897 int high_res_now_tiles = 0u; |
| 2898 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 2898 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 2899 pending_layer_->picture_layer_tiling_set(), false)); | 2899 pending_layer_->picture_layer_tiling_set(), false)); |
| 2900 while (!queue->IsEmpty()) { | 2900 while (!queue->IsEmpty()) { |
| 2901 PrioritizedTile prioritized_tile = queue->Top(); | 2901 PrioritizedTile prioritized_tile = queue->Top(); |
| 2902 TilePriority priority = prioritized_tile.priority(); | 2902 TilePriority priority = prioritized_tile.priority(); |
| 2903 | 2903 |
| 2904 EXPECT_TRUE(prioritized_tile.tile()); | 2904 EXPECT_TRUE(prioritized_tile.tile()); |
| 2905 | 2905 |
| 2906 // Non-high res tiles only get visible tiles. Also, prepaint should only | 2906 // Non-high res tiles only get visible tiles. Also, prepaint should only |
| 2907 // come at the end of the iteration. | 2907 // come at the end of the iteration. |
| 2908 if (priority.resolution != HIGH_RESOLUTION) { | 2908 if (priority.resolution != HIGH_RESOLUTION) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2927 EXPECT_EQ(0, non_ideal_tile_count); | 2927 EXPECT_EQ(0, non_ideal_tile_count); |
| 2928 EXPECT_EQ(0, low_res_tile_count); | 2928 EXPECT_EQ(0, low_res_tile_count); |
| 2929 | 2929 |
| 2930 // With layer size being 1000x1000 and default tile size 256x256, we expect to | 2930 // With layer size being 1000x1000 and default tile size 256x256, we expect to |
| 2931 // see 4 now tiles out of 16 total high res tiles. | 2931 // see 4 now tiles out of 16 total high res tiles. |
| 2932 EXPECT_EQ(16, high_res_tile_count); | 2932 EXPECT_EQ(16, high_res_tile_count); |
| 2933 EXPECT_EQ(4, high_res_now_tiles); | 2933 EXPECT_EQ(4, high_res_now_tiles); |
| 2934 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, | 2934 EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count, |
| 2935 static_cast<int>(unique_tiles.size())); | 2935 static_cast<int>(unique_tiles.size())); |
| 2936 | 2936 |
| 2937 scoped_ptr<TilingSetRasterQueueRequired> required_queue( | 2937 std::unique_ptr<TilingSetRasterQueueRequired> required_queue( |
| 2938 new TilingSetRasterQueueRequired( | 2938 new TilingSetRasterQueueRequired( |
| 2939 pending_layer_->picture_layer_tiling_set(), | 2939 pending_layer_->picture_layer_tiling_set(), |
| 2940 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 2940 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 2941 EXPECT_TRUE(required_queue->IsEmpty()); | 2941 EXPECT_TRUE(required_queue->IsEmpty()); |
| 2942 | 2942 |
| 2943 required_queue.reset(new TilingSetRasterQueueRequired( | 2943 required_queue.reset(new TilingSetRasterQueueRequired( |
| 2944 pending_layer_->picture_layer_tiling_set(), | 2944 pending_layer_->picture_layer_tiling_set(), |
| 2945 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 2945 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 2946 EXPECT_FALSE(required_queue->IsEmpty()); | 2946 EXPECT_FALSE(required_queue->IsEmpty()); |
| 2947 int required_for_activation_count = 0; | 2947 int required_for_activation_count = 0; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3015 | 3015 |
| 3016 gfx::Size layer_bounds(1000, 1000); | 3016 gfx::Size layer_bounds(1000, 1000); |
| 3017 | 3017 |
| 3018 scoped_refptr<FakeRasterSource> pending_raster_source = | 3018 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 3019 FakeRasterSource::CreateFilled(layer_bounds); | 3019 FakeRasterSource::CreateFilled(layer_bounds); |
| 3020 | 3020 |
| 3021 SetupPendingTree(pending_raster_source); | 3021 SetupPendingTree(pending_raster_source); |
| 3022 ActivateTree(); | 3022 ActivateTree(); |
| 3023 EXPECT_EQ(2u, active_layer_->num_tilings()); | 3023 EXPECT_EQ(2u, active_layer_->num_tilings()); |
| 3024 | 3024 |
| 3025 scoped_ptr<TilingSetRasterQueueRequired> queue( | 3025 std::unique_ptr<TilingSetRasterQueueRequired> queue( |
| 3026 new TilingSetRasterQueueRequired( | 3026 new TilingSetRasterQueueRequired( |
| 3027 active_layer_->picture_layer_tiling_set(), | 3027 active_layer_->picture_layer_tiling_set(), |
| 3028 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 3028 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 3029 EXPECT_FALSE(queue->IsEmpty()); | 3029 EXPECT_FALSE(queue->IsEmpty()); |
| 3030 while (!queue->IsEmpty()) { | 3030 while (!queue->IsEmpty()) { |
| 3031 PrioritizedTile prioritized_tile = queue->Top(); | 3031 PrioritizedTile prioritized_tile = queue->Top(); |
| 3032 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); | 3032 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); |
| 3033 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw()); | 3033 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw()); |
| 3034 queue->Pop(); | 3034 queue->Pop(); |
| 3035 } | 3035 } |
| 3036 | 3036 |
| 3037 queue.reset(new TilingSetRasterQueueRequired( | 3037 queue.reset(new TilingSetRasterQueueRequired( |
| 3038 active_layer_->picture_layer_tiling_set(), | 3038 active_layer_->picture_layer_tiling_set(), |
| 3039 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3039 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 3040 EXPECT_TRUE(queue->IsEmpty()); | 3040 EXPECT_TRUE(queue->IsEmpty()); |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { | 3043 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { |
| 3044 scoped_refptr<FakeRasterSource> pending_raster_source = | 3044 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 3045 FakeRasterSource::CreateFilledSolidColor(gfx::Size(1024, 1024)); | 3045 FakeRasterSource::CreateFilledSolidColor(gfx::Size(1024, 1024)); |
| 3046 | 3046 |
| 3047 SetupPendingTree(pending_raster_source); | 3047 SetupPendingTree(pending_raster_source); |
| 3048 EXPECT_FALSE( | 3048 EXPECT_FALSE( |
| 3049 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( | 3049 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( |
| 3050 HIGH_RESOLUTION)); | 3050 HIGH_RESOLUTION)); |
| 3051 | 3051 |
| 3052 scoped_ptr<TilingSetRasterQueueRequired> queue( | 3052 std::unique_ptr<TilingSetRasterQueueRequired> queue( |
| 3053 new TilingSetRasterQueueRequired( | 3053 new TilingSetRasterQueueRequired( |
| 3054 pending_layer_->picture_layer_tiling_set(), | 3054 pending_layer_->picture_layer_tiling_set(), |
| 3055 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3055 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 3056 EXPECT_TRUE(queue->IsEmpty()); | 3056 EXPECT_TRUE(queue->IsEmpty()); |
| 3057 } | 3057 } |
| 3058 | 3058 |
| 3059 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { | 3059 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { |
| 3060 gfx::Size layer_bounds(1000, 1000); | 3060 gfx::Size layer_bounds(1000, 1000); |
| 3061 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3061 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 3062 | 3062 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 } | 3097 } |
| 3098 } | 3098 } |
| 3099 | 3099 |
| 3100 // Sanity checks. | 3100 // Sanity checks. |
| 3101 EXPECT_EQ(16u, all_tiles.size()); | 3101 EXPECT_EQ(16u, all_tiles.size()); |
| 3102 EXPECT_EQ(16u, all_tiles_set.size()); | 3102 EXPECT_EQ(16u, all_tiles_set.size()); |
| 3103 EXPECT_GT(number_of_marked_tiles, 1u); | 3103 EXPECT_GT(number_of_marked_tiles, 1u); |
| 3104 EXPECT_GT(number_of_unmarked_tiles, 1u); | 3104 EXPECT_GT(number_of_unmarked_tiles, 1u); |
| 3105 | 3105 |
| 3106 // Tiles don't have resources yet. | 3106 // Tiles don't have resources yet. |
| 3107 scoped_ptr<TilingSetEvictionQueue> queue( | 3107 std::unique_ptr<TilingSetEvictionQueue> queue( |
| 3108 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); | 3108 new TilingSetEvictionQueue(pending_layer_->picture_layer_tiling_set())); |
| 3109 EXPECT_TRUE(queue->IsEmpty()); | 3109 EXPECT_TRUE(queue->IsEmpty()); |
| 3110 | 3110 |
| 3111 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3111 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 3112 | 3112 |
| 3113 std::set<Tile*> unique_tiles; | 3113 std::set<Tile*> unique_tiles; |
| 3114 float expected_scales[] = {low_res_factor, 1.f}; | 3114 float expected_scales[] = {low_res_factor, 1.f}; |
| 3115 size_t scale_index = 0; | 3115 size_t scale_index = 0; |
| 3116 bool reached_visible = false; | 3116 bool reached_visible = false; |
| 3117 PrioritizedTile last_tile; | 3117 PrioritizedTile last_tile; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3657 1.3f, // ideal contents scale | 3657 1.3f, // ideal contents scale |
| 3658 2.7f, // device scale | 3658 2.7f, // device scale |
| 3659 3.2f, // page scale | 3659 3.2f, // page scale |
| 3660 1.f, // maximum animation scale | 3660 1.f, // maximum animation scale |
| 3661 0.f, // starting animation scale | 3661 0.f, // starting animation scale |
| 3662 false); | 3662 false); |
| 3663 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3663 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3664 } | 3664 } |
| 3665 | 3665 |
| 3666 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { | 3666 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
| 3667 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 3667 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 3668 | 3668 |
| 3669 gfx::Size layer_bounds(1000, 2000); | 3669 gfx::Size layer_bounds(1000, 2000); |
| 3670 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); | 3670 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); |
| 3671 SetupDefaultTrees(layer_bounds); | 3671 SetupDefaultTrees(layer_bounds); |
| 3672 | 3672 |
| 3673 ResetTilingsAndRasterScales(); | 3673 ResetTilingsAndRasterScales(); |
| 3674 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, | 3674 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, |
| 3675 false); | 3675 false); |
| 3676 | 3676 |
| 3677 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 3677 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3742 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 3742 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
| 3743 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); | 3743 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); |
| 3744 size_t resource_limit = max_tiles; | 3744 size_t resource_limit = max_tiles; |
| 3745 ManagedMemoryPolicy policy(memory_limit, | 3745 ManagedMemoryPolicy policy(memory_limit, |
| 3746 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 3746 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 3747 resource_limit); | 3747 resource_limit); |
| 3748 host_impl_.SetMemoryPolicy(policy); | 3748 host_impl_.SetMemoryPolicy(policy); |
| 3749 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 3749 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 3750 host_impl_.PrepareTiles(); | 3750 host_impl_.PrepareTiles(); |
| 3751 | 3751 |
| 3752 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 3752 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 3753 AppendQuadsData data; | 3753 AppendQuadsData data; |
| 3754 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr); | 3754 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr); |
| 3755 active_layer_->AppendQuads(render_pass.get(), &data); | 3755 active_layer_->AppendQuads(render_pass.get(), &data); |
| 3756 active_layer_->DidDraw(nullptr); | 3756 active_layer_->DidDraw(nullptr); |
| 3757 | 3757 |
| 3758 // Even when OOM, quads should be produced, and should be different material | 3758 // Even when OOM, quads should be produced, and should be different material |
| 3759 // from quads with resource. | 3759 // from quads with resource. |
| 3760 EXPECT_LT(max_tiles, render_pass->quad_list.size()); | 3760 EXPECT_LT(max_tiles, render_pass->quad_list.size()); |
| 3761 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, | 3761 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, |
| 3762 render_pass->quad_list.front()->material); | 3762 render_pass->quad_list.front()->material); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3774 OcclusionTrackingPictureLayerImplTest() | 3774 OcclusionTrackingPictureLayerImplTest() |
| 3775 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3775 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3776 | 3776 |
| 3777 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, | 3777 void VerifyEvictionConsidersOcclusion(FakePictureLayerImpl* layer, |
| 3778 WhichTree tree, | 3778 WhichTree tree, |
| 3779 size_t expected_occluded_tile_count, | 3779 size_t expected_occluded_tile_count, |
| 3780 int source_line) { | 3780 int source_line) { |
| 3781 size_t occluded_tile_count = 0u; | 3781 size_t occluded_tile_count = 0u; |
| 3782 PrioritizedTile last_tile; | 3782 PrioritizedTile last_tile; |
| 3783 | 3783 |
| 3784 scoped_ptr<TilingSetEvictionQueue> queue( | 3784 std::unique_ptr<TilingSetEvictionQueue> queue( |
| 3785 new TilingSetEvictionQueue(layer->picture_layer_tiling_set())); | 3785 new TilingSetEvictionQueue(layer->picture_layer_tiling_set())); |
| 3786 while (!queue->IsEmpty()) { | 3786 while (!queue->IsEmpty()) { |
| 3787 PrioritizedTile prioritized_tile = queue->Top(); | 3787 PrioritizedTile prioritized_tile = queue->Top(); |
| 3788 Tile* tile = prioritized_tile.tile(); | 3788 Tile* tile = prioritized_tile.tile(); |
| 3789 if (!last_tile.tile()) | 3789 if (!last_tile.tile()) |
| 3790 last_tile = prioritized_tile; | 3790 last_tile = prioritized_tile; |
| 3791 | 3791 |
| 3792 // The only way we will encounter an occluded tile after an unoccluded | 3792 // The only way we will encounter an occluded tile after an unoccluded |
| 3793 // tile is if the priorty bin decreased, the tile is required for | 3793 // tile is if the priorty bin decreased, the tile is required for |
| 3794 // activation, or the scale changed. | 3794 // activation, or the scale changed. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3828 gfx::PointF occluding_layer_position(310.f, 0.f); | 3828 gfx::PointF occluding_layer_position(310.f, 0.f); |
| 3829 | 3829 |
| 3830 host_impl_.SetViewportSize(viewport_size); | 3830 host_impl_.SetViewportSize(viewport_size); |
| 3831 | 3831 |
| 3832 scoped_refptr<FakeRasterSource> pending_raster_source = | 3832 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 3833 FakeRasterSource::CreateFilled(layer_bounds); | 3833 FakeRasterSource::CreateFilled(layer_bounds); |
| 3834 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); | 3834 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
| 3835 | 3835 |
| 3836 // No occlusion. | 3836 // No occlusion. |
| 3837 int unoccluded_tile_count = 0; | 3837 int unoccluded_tile_count = 0; |
| 3838 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 3838 std::unique_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 3839 pending_layer_->picture_layer_tiling_set(), false)); | 3839 pending_layer_->picture_layer_tiling_set(), false)); |
| 3840 while (!queue->IsEmpty()) { | 3840 while (!queue->IsEmpty()) { |
| 3841 PrioritizedTile prioritized_tile = queue->Top(); | 3841 PrioritizedTile prioritized_tile = queue->Top(); |
| 3842 Tile* tile = prioritized_tile.tile(); | 3842 Tile* tile = prioritized_tile.tile(); |
| 3843 | 3843 |
| 3844 // Occluded tiles should not be iterated over. | 3844 // Occluded tiles should not be iterated over. |
| 3845 EXPECT_FALSE(prioritized_tile.is_occluded()); | 3845 EXPECT_FALSE(prioritized_tile.is_occluded()); |
| 3846 | 3846 |
| 3847 // Some tiles may not be visible (i.e. outside the viewport). The rest are | 3847 // Some tiles may not be visible (i.e. outside the viewport). The rest are |
| 3848 // visible and at least partially unoccluded, verified by the above expect. | 3848 // visible and at least partially unoccluded, verified by the above expect. |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4374 | 4374 |
| 4375 gfx::Size tile_size(100, 100); | 4375 gfx::Size tile_size(100, 100); |
| 4376 gfx::Size layer_bounds(200, 200); | 4376 gfx::Size layer_bounds(200, 200); |
| 4377 gfx::Rect layer_rect(layer_bounds); | 4377 gfx::Rect layer_rect(layer_bounds); |
| 4378 | 4378 |
| 4379 FakeContentLayerClient client; | 4379 FakeContentLayerClient client; |
| 4380 client.set_bounds(layer_bounds); | 4380 client.set_bounds(layer_bounds); |
| 4381 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4381 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4382 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4382 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 4383 TestTaskGraphRunner task_graph_runner; | 4383 TestTaskGraphRunner task_graph_runner; |
| 4384 scoped_ptr<FakeLayerTreeHost> host = | 4384 std::unique_ptr<FakeLayerTreeHost> host = |
| 4385 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4385 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4386 host->SetRootLayer(layer); | 4386 host->SetRootLayer(layer); |
| 4387 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4387 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4388 | 4388 |
| 4389 int frame_number = 0; | 4389 int frame_number = 0; |
| 4390 | 4390 |
| 4391 client.set_fill_with_nonsolid_color(!test_for_solid); | 4391 client.set_fill_with_nonsolid_color(!test_for_solid); |
| 4392 | 4392 |
| 4393 Region invalidation(layer_rect); | 4393 Region invalidation(layer_rect); |
| 4394 recording_source->UpdateAndExpandInvalidation( | 4394 recording_source->UpdateAndExpandInvalidation( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4405 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4405 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4406 } else { | 4406 } else { |
| 4407 ASSERT_TRUE(active_layer_->tilings()); | 4407 ASSERT_TRUE(active_layer_->tilings()); |
| 4408 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4408 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
| 4409 std::vector<Tile*> tiles = | 4409 std::vector<Tile*> tiles = |
| 4410 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 4410 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 4411 EXPECT_FALSE(tiles.empty()); | 4411 EXPECT_FALSE(tiles.empty()); |
| 4412 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4412 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4413 } | 4413 } |
| 4414 | 4414 |
| 4415 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 4415 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 4416 AppendQuadsData data; | 4416 AppendQuadsData data; |
| 4417 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 4417 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 4418 active_layer_->AppendQuads(render_pass.get(), &data); | 4418 active_layer_->AppendQuads(render_pass.get(), &data); |
| 4419 active_layer_->DidDraw(nullptr); | 4419 active_layer_->DidDraw(nullptr); |
| 4420 | 4420 |
| 4421 DrawQuad::Material expected = test_for_solid | 4421 DrawQuad::Material expected = test_for_solid |
| 4422 ? DrawQuad::Material::SOLID_COLOR | 4422 ? DrawQuad::Material::SOLID_COLOR |
| 4423 : DrawQuad::Material::TILED_CONTENT; | 4423 : DrawQuad::Material::TILED_CONTENT; |
| 4424 EXPECT_EQ(expected, render_pass->quad_list.front()->material); | 4424 EXPECT_EQ(expected, render_pass->quad_list.front()->material); |
| 4425 } | 4425 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4437 | 4437 |
| 4438 gfx::Size tile_size(100, 100); | 4438 gfx::Size tile_size(100, 100); |
| 4439 gfx::Size layer_bounds(200, 200); | 4439 gfx::Size layer_bounds(200, 200); |
| 4440 gfx::Rect layer_rect(layer_bounds); | 4440 gfx::Rect layer_rect(layer_bounds); |
| 4441 | 4441 |
| 4442 FakeContentLayerClient client; | 4442 FakeContentLayerClient client; |
| 4443 client.set_bounds(layer_bounds); | 4443 client.set_bounds(layer_bounds); |
| 4444 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4444 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 4445 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4445 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 4446 TestTaskGraphRunner task_graph_runner; | 4446 TestTaskGraphRunner task_graph_runner; |
| 4447 scoped_ptr<FakeLayerTreeHost> host = | 4447 std::unique_ptr<FakeLayerTreeHost> host = |
| 4448 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 4448 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 4449 host->SetRootLayer(layer); | 4449 host->SetRootLayer(layer); |
| 4450 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4450 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 4451 | 4451 |
| 4452 int frame_number = 0; | 4452 int frame_number = 0; |
| 4453 | 4453 |
| 4454 client.set_fill_with_nonsolid_color(true); | 4454 client.set_fill_with_nonsolid_color(true); |
| 4455 | 4455 |
| 4456 recording_source->SetNeedsDisplayRect(layer_rect); | 4456 recording_source->SetNeedsDisplayRect(layer_rect); |
| 4457 Region invalidation1; | 4457 Region invalidation1; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4773 | 4773 |
| 4774 class TileSizeTest : public PictureLayerImplTest { | 4774 class TileSizeTest : public PictureLayerImplTest { |
| 4775 public: | 4775 public: |
| 4776 TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {} | 4776 TileSizeTest() : PictureLayerImplTest(TileSizeSettings()) {} |
| 4777 }; | 4777 }; |
| 4778 | 4778 |
| 4779 TEST_F(TileSizeTest, TileSizes) { | 4779 TEST_F(TileSizeTest, TileSizes) { |
| 4780 host_impl_.CreatePendingTree(); | 4780 host_impl_.CreatePendingTree(); |
| 4781 | 4781 |
| 4782 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 4782 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 4783 scoped_ptr<FakePictureLayerImpl> layer = | 4783 std::unique_ptr<FakePictureLayerImpl> layer = |
| 4784 FakePictureLayerImpl::Create(pending_tree, id_); | 4784 FakePictureLayerImpl::Create(pending_tree, id_); |
| 4785 | 4785 |
| 4786 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); | 4786 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
| 4787 gfx::Size result; | 4787 gfx::Size result; |
| 4788 | 4788 |
| 4789 host_impl_.SetContentIsSuitableForGpuRasterization(true); | 4789 host_impl_.SetContentIsSuitableForGpuRasterization(true); |
| 4790 host_impl_.SetHasGpuRasterizationTrigger(false); | 4790 host_impl_.SetHasGpuRasterizationTrigger(false); |
| 4791 EXPECT_EQ(host_impl_.gpu_rasterization_status(), | 4791 EXPECT_EQ(host_impl_.gpu_rasterization_status(), |
| 4792 GpuRasterizationStatus::OFF_VIEWPORT); | 4792 GpuRasterizationStatus::OFF_VIEWPORT); |
| 4793 | 4793 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4916 // New low res tiling. | 4916 // New low res tiling. |
| 4917 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 4917 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 4918 | 4918 |
| 4919 // This tiling will be high res now, it won't contain low res content since it | 4919 // This tiling will be high res now, it won't contain low res content since it |
| 4920 // was all destroyed. | 4920 // was all destroyed. |
| 4921 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 4921 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 4922 } | 4922 } |
| 4923 | 4923 |
| 4924 } // namespace | 4924 } // namespace |
| 4925 } // namespace cc | 4925 } // namespace cc |
| OLD | NEW |