Chromium Code Reviews| 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 "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/resources/resource_pool.h" | 9 #include "cc/resources/resource_pool.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 InitializeRenderer(); | 73 InitializeRenderer(); |
| 74 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 74 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void InitializeRenderer() { | 77 virtual void InitializeRenderer() { |
| 78 host_impl_.InitializeRenderer(output_surface_.get()); | 78 host_impl_.InitializeRenderer(output_surface_.get()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 81 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 82 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 82 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 83 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 83 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds); |
| 84 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | 84 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = |
| 85 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 85 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds); |
| 86 | 86 |
| 87 pending_raster_source->set_is_solid_color(false); | |
|
danakj
2015/09/28 18:26:43
Please leave a comment explaining this solid color
vmpstr
2015/09/28 20:23:20
Done.
| |
| 88 active_raster_source->set_is_solid_color(false); | |
| 87 SetupTrees(pending_raster_source, active_raster_source); | 89 SetupTrees(pending_raster_source, active_raster_source); |
| 88 } | 90 } |
| 89 | 91 |
| 90 // This matches picture_layer_impl_unittest's ActivateTree. | 92 // This matches picture_layer_impl_unittest's ActivateTree. |
| 91 void ActivateTree() { | 93 void ActivateTree() { |
| 92 host_impl_.ActivateSyncTree(); | 94 host_impl_.ActivateSyncTree(); |
| 93 CHECK(!host_impl_.pending_tree()); | 95 CHECK(!host_impl_.pending_tree()); |
| 94 pending_layer_ = NULL; | 96 pending_layer_ = NULL; |
| 95 active_layer_ = static_cast<FakePictureLayerImpl*>( | 97 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 96 host_impl_.active_tree()->LayerById(id_)); | 98 host_impl_.active_tree()->LayerById(id_)); |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 } | 1285 } |
| 1284 | 1286 |
| 1285 EXPECT_GT(eventually_bin_order_correct_count, | 1287 EXPECT_GT(eventually_bin_order_correct_count, |
| 1286 eventually_bin_order_incorrect_count); | 1288 eventually_bin_order_incorrect_count); |
| 1287 | 1289 |
| 1288 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1290 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1289 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1291 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1290 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1292 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 // TODO(vmpstr): Move these to LTHI tests, since they can't create real | 1295 TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADraw) { |
| 1294 // resources and so they don't work with non-solid raster sources. | |
| 1295 // crbug.com/534911 | |
| 1296 TEST_F(TileManagerTilePriorityQueueTest, DISABLED_SetIsLikelyToRequireADraw) { | |
| 1297 const gfx::Size layer_bounds(1000, 1000); | 1296 const gfx::Size layer_bounds(1000, 1000); |
| 1298 host_impl_.SetViewportSize(layer_bounds); | 1297 host_impl_.SetViewportSize(layer_bounds); |
| 1299 SetupDefaultTrees(layer_bounds); | 1298 SetupDefaultTrees(layer_bounds); |
| 1300 | 1299 |
| 1301 // Verify that the queue has a required for draw tile at Top. | 1300 // Verify that the queue has a required for draw tile at Top. |
| 1302 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1301 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1303 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1302 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1304 EXPECT_FALSE(queue->IsEmpty()); | 1303 EXPECT_FALSE(queue->IsEmpty()); |
| 1305 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1304 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1306 | 1305 |
| 1307 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1306 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1308 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); | 1307 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1309 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); | 1308 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); |
| 1310 } | 1309 } |
| 1311 | 1310 |
| 1312 // TODO(vmpstr): Move these to LTHI tests, since they can't create real | |
| 1313 // resources and so they don't work with non-solid raster sources. | |
| 1314 // crbug.com/534911 | |
| 1315 TEST_F(TileManagerTilePriorityQueueTest, | 1311 TEST_F(TileManagerTilePriorityQueueTest, |
| 1316 DISABLED_SetIsLikelyToRequireADrawOnZeroMemoryBudget) { | 1312 SetIsLikelyToRequireADrawOnZeroMemoryBudget) { |
| 1317 const gfx::Size layer_bounds(1000, 1000); | 1313 const gfx::Size layer_bounds(1000, 1000); |
| 1318 host_impl_.SetViewportSize(layer_bounds); | 1314 host_impl_.SetViewportSize(layer_bounds); |
| 1319 SetupDefaultTrees(layer_bounds); | 1315 SetupDefaultTrees(layer_bounds); |
| 1320 | 1316 |
| 1321 // Verify that the queue has a required for draw tile at Top. | 1317 // Verify that the queue has a required for draw tile at Top. |
| 1322 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1318 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1323 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1319 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1324 EXPECT_FALSE(queue->IsEmpty()); | 1320 EXPECT_FALSE(queue->IsEmpty()); |
| 1325 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1321 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1326 | 1322 |
| 1327 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); | 1323 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); |
| 1328 policy.bytes_limit_when_visible = 0; | 1324 policy.bytes_limit_when_visible = 0; |
| 1329 host_impl_.SetMemoryPolicy(policy); | 1325 host_impl_.SetMemoryPolicy(policy); |
| 1330 | 1326 |
| 1331 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1327 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1332 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); | 1328 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1333 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1329 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1334 } | 1330 } |
| 1335 | 1331 |
| 1336 // TODO(vmpstr): Move these to LTHI tests, since they can't create real | |
| 1337 // resources and so they don't work with non-solid raster sources. | |
| 1338 // crbug.com/534911 | |
| 1339 TEST_F(TileManagerTilePriorityQueueTest, | 1332 TEST_F(TileManagerTilePriorityQueueTest, |
| 1340 DISABLED_SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { | 1333 SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { |
| 1341 const gfx::Size layer_bounds(1000, 1000); | 1334 const gfx::Size layer_bounds(1000, 1000); |
| 1342 host_impl_.SetViewportSize(layer_bounds); | 1335 host_impl_.SetViewportSize(layer_bounds); |
| 1343 SetupDefaultTrees(layer_bounds); | 1336 SetupDefaultTrees(layer_bounds); |
| 1344 | 1337 |
| 1345 // Verify that the queue has a required for draw tile at Top. | 1338 // Verify that the queue has a required for draw tile at Top. |
| 1346 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1339 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1347 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1340 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1348 EXPECT_FALSE(queue->IsEmpty()); | 1341 EXPECT_FALSE(queue->IsEmpty()); |
| 1349 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1342 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1350 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); | 1343 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1562 // background is not visible. | 1555 // background is not visible. |
| 1563 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); | 1556 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); |
| 1564 } | 1557 } |
| 1565 } | 1558 } |
| 1566 } | 1559 } |
| 1567 } | 1560 } |
| 1568 } | 1561 } |
| 1569 | 1562 |
| 1570 } // namespace | 1563 } // namespace |
| 1571 } // namespace cc | 1564 } // namespace cc |
| OLD | NEW |