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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "cc/playback/display_list_raster_source.h" | 10 #include "cc/playback/display_list_raster_source.h" |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1445 non_intersecting_rect, // Visible rect. | 1445 non_intersecting_rect, // Visible rect. |
1446 non_intersecting_rect, // Skewport rect. | 1446 non_intersecting_rect, // Skewport rect. |
1447 non_intersecting_rect, // Soon rect. | 1447 non_intersecting_rect, // Soon rect. |
1448 intersecting_rect); // Eventually rect. | 1448 intersecting_rect); // Eventually rect. |
1449 scoped_ptr<TilingSetRasterQueueAll> queue( | 1449 scoped_ptr<TilingSetRasterQueueAll> queue( |
1450 new TilingSetRasterQueueAll(tiling_set.get(), false)); | 1450 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
1451 EXPECT_FALSE(queue->IsEmpty()); | 1451 EXPECT_FALSE(queue->IsEmpty()); |
1452 } | 1452 } |
1453 } | 1453 } |
1454 | 1454 |
1455 TEST_F(TileManagerTilePriorityQueueTest, NoRasterTasksforSolidColorTiles) { | |
1456 gfx::Size size(10, 10); | |
1457 const gfx::Size layer_bounds(10, 10); | |
1458 | |
1459 scoped_ptr<FakeDisplayListRecordingSource> recording_source = | |
1460 FakeDisplayListRecordingSource::CreateFilledRecordingSource(layer_bounds); | |
1461 | |
1462 SkPaint solid_paint; | |
1463 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | |
1464 solid_paint.setColor(solid_color); | |
1465 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), | |
1466 solid_paint); | |
1467 recording_source->Rerecord(); | |
1468 | |
1469 scoped_refptr<DisplayListRasterSource> raster_source = | |
1470 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | |
1471 recording_source.get(), false); | |
1472 | |
1473 FakePictureLayerTilingClient tiling_client; | |
1474 tiling_client.SetTileSize(size); | |
1475 | |
1476 scoped_ptr<PictureLayerImpl> layer_impl = | |
1477 PictureLayerImpl::Create(host_impl_.active_tree(), 1, false, nullptr); | |
1478 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set(); | |
1479 | |
1480 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); | |
1481 tiling->set_resolution(HIGH_RESOLUTION); | |
1482 tiling->CreateAllTilesForTesting(); | |
1483 tiling->SetTilePriorityRectsForTesting(gfx::Rect(size), // Visible rect. | |
1484 gfx::Rect(size), // Skewport rect. | |
1485 gfx::Rect(size), // Soon rect. | |
1486 gfx::Rect(size)); // Eventually rect. | |
1487 | |
1488 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); | |
1489 | |
1490 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | |
1491 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { | |
1492 Tile* tile = tiles[tile_idx]; | |
1493 EXPECT_FALSE(tile->HasRasterTask()); | |
1494 EXPECT_EQ(TileDrawInfo::SOLID_COLOR_MODE, tile->draw_info().mode()); | |
1495 EXPECT_EQ(solid_color, tile->draw_info().solid_color()); | |
1496 } | |
1497 } | |
1498 | |
1455 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest. | 1499 // TODO(vmpstr): Merge TileManagerTest and TileManagerTilePriorityQueueTest. |
1456 class TileManagerTest : public testing::Test { | 1500 class TileManagerTest : public testing::Test { |
1457 public: | 1501 public: |
1458 TileManagerTest() | 1502 TileManagerTest() |
1459 : output_surface_(FakeOutputSurface::CreateSoftware( | 1503 : output_surface_(FakeOutputSurface::CreateSoftware( |
1460 make_scoped_ptr(new SoftwareOutputDevice))) {} | 1504 make_scoped_ptr(new SoftwareOutputDevice))) {} |
1461 | 1505 |
1462 void SetUp() override { | 1506 void SetUp() override { |
1463 LayerTreeSettingsForTesting settings; | 1507 LayerTreeSettingsForTesting settings; |
1464 CustomizeSettings(&settings); | 1508 CustomizeSettings(&settings); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1568 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); | 1612 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
1569 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) | 1613 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
1570 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1614 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
1571 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); | 1615 host_impl_->tile_manager()->PrepareTiles(host_impl_->global_tile_state()); |
1572 host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); | 1616 host_impl_->tile_manager()->SetMoreTilesNeedToBeRasterizedForTesting(); |
1573 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); | 1617 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
1574 run_loop.Run(); | 1618 run_loop.Run(); |
1575 } | 1619 } |
1576 } | 1620 } |
1577 | 1621 |
1578 TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) { | 1622 TEST_F(TileManagerTest, ActivateAndDrawWhenOOM) { |
vmpstr
2016/01/07 22:36:02
It's actually kind of nice that this fails now, si
sohanjg
2016/01/08 11:47:56
OK. i will remove these changes to draw a non-soli
| |
1579 SetupDefaultTrees(gfx::Size(1000, 1000)); | 1623 gfx::Size size(10, 10); |
1624 const gfx::Size layer_bounds(10, 10); | |
1580 | 1625 |
1581 auto global_state = host_impl_->global_tile_state(); | 1626 auto global_state = host_impl_->global_tile_state(); |
1582 global_state.hard_memory_limit_in_bytes = 1u; | 1627 global_state.hard_memory_limit_in_bytes = 1u; |
1583 global_state.soft_memory_limit_in_bytes = 1u; | 1628 global_state.soft_memory_limit_in_bytes = 1u; |
1584 | 1629 |
1630 scoped_ptr<FakeDisplayListRecordingSource> recording_source = | |
1631 FakeDisplayListRecordingSource::CreateFilledRecordingSource(layer_bounds); | |
1632 | |
1633 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | |
1634 SkPaint non_solid_paint; | |
1635 non_solid_paint.setColor(non_solid_color); | |
1636 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), | |
1637 non_solid_paint); | |
1638 recording_source->Rerecord(); | |
1639 | |
1640 scoped_refptr<DisplayListRasterSource> raster_source = | |
1641 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | |
1642 recording_source.get(), false); | |
1643 | |
1644 FakePictureLayerTilingClient tiling_client; | |
1645 tiling_client.SetTileSize(size); | |
1646 | |
1647 scoped_ptr<PictureLayerImpl> layer = | |
1648 PictureLayerImpl::Create(host_impl_->active_tree(), 1, false, nullptr); | |
1649 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); | |
1650 | |
1651 auto* tiling = tiling_set->AddTiling(1.0f, raster_source); | |
1652 tiling->set_resolution(HIGH_RESOLUTION); | |
1653 tiling->CreateAllTilesForTesting(); | |
1654 tiling->SetTilePriorityRectsForTesting(gfx::Rect(size), // Visible rect. | |
1655 gfx::Rect(size), // Skewport rect. | |
1656 gfx::Rect(size), // Soon rect. | |
1657 gfx::Rect(size)); // Eventually rect. | |
1658 | |
1585 { | 1659 { |
1586 base::RunLoop run_loop; | 1660 base::RunLoop run_loop; |
1587 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); | 1661 EXPECT_FALSE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
1588 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) | 1662 EXPECT_CALL(*host_impl_, NotifyAllTileTasksCompleted()) |
1589 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1663 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
1590 host_impl_->tile_manager()->PrepareTiles(global_state); | 1664 host_impl_->tile_manager()->PrepareTiles(global_state); |
1591 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); | 1665 EXPECT_TRUE(host_impl_->tile_manager()->HasScheduledTileTasksForTesting()); |
1592 run_loop.Run(); | 1666 run_loop.Run(); |
1593 } | 1667 } |
1594 | 1668 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1896 | 1970 |
1897 // Ensures that the tile manager does not attempt to reuse tiles when partial | 1971 // Ensures that the tile manager does not attempt to reuse tiles when partial |
1898 // raster is disabled. | 1972 // raster is disabled. |
1899 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 1973 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
1900 RunPartialRasterCheck(std::move(host_impl_), | 1974 RunPartialRasterCheck(std::move(host_impl_), |
1901 false /* partial_raster_enabled */); | 1975 false /* partial_raster_enabled */); |
1902 } | 1976 } |
1903 | 1977 |
1904 } // namespace | 1978 } // namespace |
1905 } // namespace cc | 1979 } // namespace cc |
OLD | NEW |