Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1124)

Side by Side Diff: cc/tiles/tile_manager_unittest.cc

Issue 1430313002: cc: Make sure to issue IsReadyToDraw when we're out of memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/thread_task_runner_handle.h" 6 #include "base/thread_task_runner_handle.h"
7 #include "cc/playback/display_list_raster_source.h" 7 #include "cc/playback/display_list_raster_source.h"
8 #include "cc/playback/display_list_recording_source.h" 8 #include "cc/playback/display_list_recording_source.h"
9 #include "cc/raster/raster_buffer.h" 9 #include "cc/raster/raster_buffer.h"
10 #include "cc/resources/resource_pool.h" 10 #include "cc/resources/resource_pool.h"
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 non_intersecting_rect, // Visible rect. 1441 non_intersecting_rect, // Visible rect.
1442 non_intersecting_rect, // Skewport rect. 1442 non_intersecting_rect, // Skewport rect.
1443 non_intersecting_rect, // Soon rect. 1443 non_intersecting_rect, // Soon rect.
1444 intersecting_rect); // Eventually rect. 1444 intersecting_rect); // Eventually rect.
1445 scoped_ptr<TilingSetRasterQueueAll> queue( 1445 scoped_ptr<TilingSetRasterQueueAll> queue(
1446 new TilingSetRasterQueueAll(tiling_set.get(), false)); 1446 new TilingSetRasterQueueAll(tiling_set.get(), false));
1447 EXPECT_FALSE(queue->IsEmpty()); 1447 EXPECT_FALSE(queue->IsEmpty());
1448 } 1448 }
1449 } 1449 }
1450 1450
1451 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest.
1451 class TileManagerTest : public testing::Test { 1452 class TileManagerTest : public testing::Test {
1452 public: 1453 public:
1453 TileManagerTest() 1454 TileManagerTest()
1454 : output_surface_(FakeOutputSurface::CreateSoftware( 1455 : output_surface_(FakeOutputSurface::CreateSoftware(
1455 make_scoped_ptr(new SoftwareOutputDevice))) {} 1456 make_scoped_ptr(new SoftwareOutputDevice))) {}
1456 1457
1457 void SetUp() override { 1458 void SetUp() override {
1458 LayerTreeSettings settings; 1459 LayerTreeSettings settings;
1459 CustomizeSettings(&settings); 1460 CustomizeSettings(&settings);
1460 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_, 1461 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_,
1461 &shared_bitmap_manager_, 1462 &shared_bitmap_manager_,
1462 &task_graph_runner_)); 1463 &task_graph_runner_));
1463 host_impl_->SetVisible(true); 1464 host_impl_->SetVisible(true);
1464 host_impl_->InitializeRenderer(output_surface_.get()); 1465 host_impl_->InitializeRenderer(output_surface_.get());
1465 } 1466 }
1466 1467
1468 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
1469 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1470 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1471 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1472 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1473
1474 SetupTrees(pending_raster_source, active_raster_source);
1475 }
1476
1477 // This matches picture_layer_impl_unittest's ActivateTree.
1478 void ActivateTree() {
1479 host_impl_->ActivateSyncTree();
1480 CHECK(!host_impl_->pending_tree());
1481 bool update_lcd_text = false;
1482 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
1483 }
1484
1485 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source,
1486 scoped_refptr<DisplayListRasterSource> active_raster_source) {
1487 SetupPendingTree(active_raster_source);
1488 ActivateTree();
1489 SetupPendingTree(pending_raster_source);
1490 }
1491
1492 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) {
1493 host_impl_->CreatePendingTree();
1494 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
1495
1496 // Steal from the recycled tree.
1497 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree();
1498 scoped_ptr<FakePictureLayerImpl> pending_layer;
1499 if (old_pending_root) {
1500 pending_layer.reset(
1501 static_cast<FakePictureLayerImpl*>(old_pending_root.release()));
1502 pending_layer->SetRasterSourceOnPending(raster_source, Region());
1503 } else {
1504 int id = 7;
1505 pending_layer = FakePictureLayerImpl::CreateWithRasterSource(
1506 pending_tree, id, raster_source);
1507 pending_layer->SetDrawsContent(true);
1508 pending_layer->SetHasRenderSurface(true);
1509 }
1510 // The bounds() just mirror the raster source size.
1511 pending_layer->SetBounds(pending_layer->raster_source()->GetSize());
1512 pending_tree->SetRootLayer(pending_layer.Pass());
1513
1514 // Add tilings/tiles for the layer.
1515 bool update_lcd_text = false;
1516 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
1517 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text);
1518 }
1519
1467 protected: 1520 protected:
1468 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. 1521 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks.
1469 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { 1522 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl {
1470 public: 1523 public:
1471 MockLayerTreeHostImpl(const LayerTreeSettings& settings, 1524 MockLayerTreeHostImpl(const LayerTreeSettings& settings,
1472 TaskRunnerProvider* task_runner_provider, 1525 TaskRunnerProvider* task_runner_provider,
1473 SharedBitmapManager* manager, 1526 SharedBitmapManager* manager,
1474 TaskGraphRunner* task_graph_runner) 1527 TaskGraphRunner* task_graph_runner)
1475 : FakeLayerTreeHostImpl(settings, 1528 : FakeLayerTreeHostImpl(settings,
1476 task_runner_provider, 1529 task_runner_provider,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); 1564 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting());
1512 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) 1565 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted())
1513 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); 1566 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); }));
1514 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); 1567 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state());
1515 host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); 1568 host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting();
1516 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); 1569 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting());
1517 run_loop.Run(); 1570 run_loop.Run();
1518 } 1571 }
1519 } 1572 }
1520 1573
1574 TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) {
1575 SetupDefaultTrees(gfx::Size(1000, 1000));
1576
1577 auto global_state = host_impl_->global_tile_state();
1578 global_state.hard_memory_limit_in_bytes = 1u;
1579 global_state.soft_memory_limit_in_bytes = 1u;
1580
1581 base::RunLoop run_loop;
1582 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting());
1583 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted())
1584 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); }));
1585 host_impl_->tile_manager()->PrepareTiles(global_state);
1586 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting());
1587 run_loop.Run();
1588
1589 EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToDraw());
1590 EXPECT_TRUE(host_impl_->tile_manager()->IsReadyToActivate());
1591 }
1592
1521 TEST_F(TileManagerTest, LowResHasNoImage) { 1593 TEST_F(TileManagerTest, LowResHasNoImage) {
1522 gfx::Size size(10, 12); 1594 gfx::Size size(10, 12);
1523 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION}; 1595 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION};
1524 1596
1525 for (size_t i = 0; i < arraysize(resolutions); ++i) { 1597 for (size_t i = 0; i < arraysize(resolutions); ++i) {
1526 SCOPED_TRACE(resolutions[i]); 1598 SCOPED_TRACE(resolutions[i]);
1527 1599
1528 // Make a DisplayListRasterSource that will draw a blue bitmap image. 1600 // Make a DisplayListRasterSource that will draw a blue bitmap image.
1529 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 1601 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
1530 SkSurface::NewRasterN32Premul(size.width(), size.height())); 1602 SkSurface::NewRasterN32Premul(size.width(), size.height()));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 } 1875 }
1804 1876
1805 // Ensures that the tile manager does not attempt to reuse tiles when partial 1877 // Ensures that the tile manager does not attempt to reuse tiles when partial
1806 // raster is disabled. 1878 // raster is disabled.
1807 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 1879 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1808 RunPartialRasterCheck(host_impl_.Pass(), false /* partial_raster_enabled */); 1880 RunPartialRasterCheck(host_impl_.Pass(), false /* partial_raster_enabled */);
1809 } 1881 }
1810 1882
1811 } // namespace 1883 } // namespace
1812 } // namespace cc 1884 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698