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

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

Issue 1837263005: cc: Rename DisplayListRasterSource to just RasterSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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_perftest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | 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 <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"
11 #include "cc/playback/display_list_recording_source.h" 10 #include "cc/playback/display_list_recording_source.h"
11 #include "cc/playback/raster_source.h"
12 #include "cc/raster/raster_buffer.h" 12 #include "cc/raster/raster_buffer.h"
13 #include "cc/resources/resource_pool.h" 13 #include "cc/resources/resource_pool.h"
14 #include "cc/test/begin_frame_args_test.h" 14 #include "cc/test/begin_frame_args_test.h"
15 #include "cc/test/fake_display_list_raster_source.h"
16 #include "cc/test/fake_display_list_recording_source.h" 15 #include "cc/test/fake_display_list_recording_source.h"
17 #include "cc/test/fake_impl_task_runner_provider.h" 16 #include "cc/test/fake_impl_task_runner_provider.h"
18 #include "cc/test/fake_layer_tree_host_impl.h" 17 #include "cc/test/fake_layer_tree_host_impl.h"
19 #include "cc/test/fake_output_surface.h" 18 #include "cc/test/fake_output_surface.h"
20 #include "cc/test/fake_output_surface_client.h" 19 #include "cc/test/fake_output_surface_client.h"
21 #include "cc/test/fake_picture_layer_impl.h" 20 #include "cc/test/fake_picture_layer_impl.h"
22 #include "cc/test/fake_picture_layer_tiling_client.h" 21 #include "cc/test/fake_picture_layer_tiling_client.h"
22 #include "cc/test/fake_raster_source.h"
23 #include "cc/test/fake_tile_manager.h" 23 #include "cc/test/fake_tile_manager.h"
24 #include "cc/test/test_gpu_memory_buffer_manager.h" 24 #include "cc/test/test_gpu_memory_buffer_manager.h"
25 #include "cc/test/test_shared_bitmap_manager.h" 25 #include "cc/test/test_shared_bitmap_manager.h"
26 #include "cc/test/test_task_graph_runner.h" 26 #include "cc/test/test_task_graph_runner.h"
27 #include "cc/test/test_tile_priorities.h" 27 #include "cc/test/test_tile_priorities.h"
28 #include "cc/tiles/eviction_tile_priority_queue.h" 28 #include "cc/tiles/eviction_tile_priority_queue.h"
29 #include "cc/tiles/raster_tile_priority_queue.h" 29 #include "cc/tiles/raster_tile_priority_queue.h"
30 #include "cc/tiles/tile.h" 30 #include "cc/tiles/tile.h"
31 #include "cc/tiles/tile_priority.h" 31 #include "cc/tiles/tile_priority.h"
32 #include "cc/tiles/tiling_set_raster_queue_all.h" 32 #include "cc/tiles/tiling_set_raster_queue_all.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 InitializeRenderer(); 81 InitializeRenderer();
82 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 82 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
83 } 83 }
84 84
85 virtual void InitializeRenderer() { 85 virtual void InitializeRenderer() {
86 host_impl_.SetVisible(true); 86 host_impl_.SetVisible(true);
87 host_impl_.InitializeRenderer(output_surface_.get()); 87 host_impl_.InitializeRenderer(output_surface_.get());
88 } 88 }
89 89
90 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 90 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
91 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 91 scoped_refptr<FakeRasterSource> pending_raster_source =
92 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 92 FakeRasterSource::CreateFilled(layer_bounds);
93 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 93 scoped_refptr<FakeRasterSource> active_raster_source =
94 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 94 FakeRasterSource::CreateFilled(layer_bounds);
95 95
96 SetupTrees(pending_raster_source, active_raster_source); 96 SetupTrees(pending_raster_source, active_raster_source);
97 } 97 }
98 98
99 // This matches picture_layer_impl_unittest's ActivateTree. 99 // This matches picture_layer_impl_unittest's ActivateTree.
100 void ActivateTree() { 100 void ActivateTree() {
101 host_impl_.ActivateSyncTree(); 101 host_impl_.ActivateSyncTree();
102 CHECK(!host_impl_.pending_tree()); 102 CHECK(!host_impl_.pending_tree());
103 pending_layer_ = NULL; 103 pending_layer_ = NULL;
104 active_layer_ = static_cast<FakePictureLayerImpl*>( 104 active_layer_ = static_cast<FakePictureLayerImpl*>(
105 host_impl_.active_tree()->LayerById(id_)); 105 host_impl_.active_tree()->LayerById(id_));
106 bool update_lcd_text = false; 106 bool update_lcd_text = false;
107 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 107 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
108 } 108 }
109 109
110 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 110 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
111 const gfx::Size& tile_size) { 111 const gfx::Size& tile_size) {
112 SetupDefaultTrees(layer_bounds); 112 SetupDefaultTrees(layer_bounds);
113 pending_layer_->set_fixed_tile_size(tile_size); 113 pending_layer_->set_fixed_tile_size(tile_size);
114 active_layer_->set_fixed_tile_size(tile_size); 114 active_layer_->set_fixed_tile_size(tile_size);
115 } 115 }
116 116
117 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source, 117 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source,
118 scoped_refptr<DisplayListRasterSource> active_raster_source) { 118 scoped_refptr<RasterSource> active_raster_source) {
119 SetupPendingTree(active_raster_source); 119 SetupPendingTree(active_raster_source);
120 ActivateTree(); 120 ActivateTree();
121 SetupPendingTree(pending_raster_source); 121 SetupPendingTree(pending_raster_source);
122 } 122 }
123 123
124 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { 124 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) {
125 host_impl_.CreatePendingTree(); 125 host_impl_.CreatePendingTree();
126 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 126 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
127 127
128 // Steal from the recycled tree. 128 // Steal from the recycled tree.
129 LayerImpl* old_pending_root = pending_tree->root_layer(); 129 LayerImpl* old_pending_root = pending_tree->root_layer();
130 DCHECK(!old_pending_root || old_pending_root->id() == id_); 130 DCHECK(!old_pending_root || old_pending_root->id() == id_);
131 131
132 FakePictureLayerImpl* pending_layer = nullptr; 132 FakePictureLayerImpl* pending_layer = nullptr;
133 if (old_pending_root) { 133 if (old_pending_root) {
134 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); 134 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root);
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 actual_required_for_activation_tiles); 670 actual_required_for_activation_tiles);
671 } 671 }
672 672
673 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { 673 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) {
674 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 674 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
675 675
676 gfx::Size layer_bounds(1000, 1000); 676 gfx::Size layer_bounds(1000, 1000);
677 SetupDefaultTrees(layer_bounds); 677 SetupDefaultTrees(layer_bounds);
678 678
679 // Create a pending child layer. 679 // Create a pending child layer.
680 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 680 scoped_refptr<FakeRasterSource> pending_raster_source =
681 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 681 FakeRasterSource::CreateFilled(layer_bounds);
682 scoped_ptr<FakePictureLayerImpl> pending_child = 682 scoped_ptr<FakePictureLayerImpl> pending_child =
683 FakePictureLayerImpl::CreateWithRasterSource( 683 FakePictureLayerImpl::CreateWithRasterSource(
684 host_impl_.pending_tree(), id_ + 1, pending_raster_source); 684 host_impl_.pending_tree(), id_ + 1, pending_raster_source);
685 FakePictureLayerImpl* pending_child_raw = pending_child.get(); 685 FakePictureLayerImpl* pending_child_raw = pending_child.get();
686 pending_child_raw->SetDrawsContent(true); 686 pending_child_raw->SetDrawsContent(true);
687 pending_layer_->AddChild(std::move(pending_child)); 687 pending_layer_->AddChild(std::move(pending_child));
688 688
689 // Set a small viewport, so we have soon and eventually tiles. 689 // Set a small viewport, so we have soon and eventually tiles.
690 host_impl_.SetViewportSize(gfx::Size(200, 200)); 690 host_impl_.SetViewportSize(gfx::Size(200, 200));
691 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 691 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 } 891 }
892 892
893 TEST_F(TileManagerTilePriorityQueueTest, 893 TEST_F(TileManagerTilePriorityQueueTest,
894 EvictionTilePriorityQueueWithOcclusion) { 894 EvictionTilePriorityQueueWithOcclusion) {
895 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 895 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
896 896
897 gfx::Size layer_bounds(1000, 1000); 897 gfx::Size layer_bounds(1000, 1000);
898 898
899 host_impl_.SetViewportSize(layer_bounds); 899 host_impl_.SetViewportSize(layer_bounds);
900 900
901 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 901 scoped_refptr<FakeRasterSource> pending_raster_source =
902 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 902 FakeRasterSource::CreateFilled(layer_bounds);
903 SetupPendingTree(pending_raster_source); 903 SetupPendingTree(pending_raster_source);
904 904
905 scoped_ptr<FakePictureLayerImpl> pending_child = 905 scoped_ptr<FakePictureLayerImpl> pending_child =
906 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, 906 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
907 pending_raster_source); 907 pending_raster_source);
908 pending_layer_->AddChild(std::move(pending_child)); 908 pending_layer_->AddChild(std::move(pending_child));
909 909
910 FakePictureLayerImpl* pending_child_layer = 910 FakePictureLayerImpl* pending_child_layer =
911 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); 911 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
912 pending_child_layer->SetDrawsContent(true); 912 pending_child_layer->SetDrawsContent(true);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 size_t expected_occluded_count = pending_child_high_res_tiles.size(); 1007 size_t expected_occluded_count = pending_child_high_res_tiles.size();
1008 EXPECT_EQ(expected_occluded_count, occluded_count); 1008 EXPECT_EQ(expected_occluded_count, occluded_count);
1009 } 1009 }
1010 1010
1011 TEST_F(TileManagerTilePriorityQueueTest, 1011 TEST_F(TileManagerTilePriorityQueueTest,
1012 EvictionTilePriorityQueueWithTransparentLayer) { 1012 EvictionTilePriorityQueueWithTransparentLayer) {
1013 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1013 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1014 1014
1015 gfx::Size layer_bounds(1000, 1000); 1015 gfx::Size layer_bounds(1000, 1000);
1016 1016
1017 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1017 scoped_refptr<FakeRasterSource> pending_raster_source =
1018 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1018 FakeRasterSource::CreateFilled(layer_bounds);
1019 SetupPendingTree(pending_raster_source); 1019 SetupPendingTree(pending_raster_source);
1020 1020
1021 scoped_ptr<FakePictureLayerImpl> pending_child = 1021 scoped_ptr<FakePictureLayerImpl> pending_child =
1022 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, 1022 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
1023 pending_raster_source); 1023 pending_raster_source);
1024 FakePictureLayerImpl* pending_child_layer = pending_child.get(); 1024 FakePictureLayerImpl* pending_child_layer = pending_child.get();
1025 pending_layer_->AddChild(std::move(pending_child)); 1025 pending_layer_->AddChild(std::move(pending_child));
1026 1026
1027 // Create a fully transparent child layer so that its tile priorities are not 1027 // Create a fully transparent child layer so that its tile priorities are not
1028 // considered to be valid. 1028 // considered to be valid.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 soon_rect.Inset(-inset, -inset); 1201 soon_rect.Inset(-inset, -inset);
1202 1202
1203 client.SetTileSize(gfx::Size(30, 30)); 1203 client.SetTileSize(gfx::Size(30, 30));
1204 LayerTreeSettings settings; 1204 LayerTreeSettings settings;
1205 1205
1206 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( 1206 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create(
1207 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, 1207 ACTIVE_TREE, &client, settings.tiling_interest_area_padding,
1208 settings.skewport_target_time_in_seconds, 1208 settings.skewport_target_time_in_seconds,
1209 settings.skewport_extrapolation_limit_in_content_pixels); 1209 settings.skewport_extrapolation_limit_in_content_pixels);
1210 1210
1211 scoped_refptr<FakeDisplayListRasterSource> raster_source = 1211 scoped_refptr<FakeRasterSource> raster_source =
1212 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1212 FakeRasterSource::CreateFilled(layer_bounds);
1213 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); 1213 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source);
1214 tiling->set_resolution(HIGH_RESOLUTION); 1214 tiling->set_resolution(HIGH_RESOLUTION);
1215 1215
1216 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); 1216 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true);
1217 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); 1217 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting();
1218 // Sanity check. 1218 // Sanity check.
1219 EXPECT_EQ(3364u, all_tiles.size()); 1219 EXPECT_EQ(3364u, all_tiles.size());
1220 1220
1221 // The explanation of each iteration is as follows: 1221 // The explanation of each iteration is as follows:
1222 // 1. First iteration tests that we can get all of the tiles correctly. 1222 // 1. First iteration tests that we can get all of the tiles correctly.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 gfx::Size layer_bounds(1000, 1000); 1310 gfx::Size layer_bounds(1000, 1000);
1311 1311
1312 client.SetTileSize(gfx::Size(30, 30)); 1312 client.SetTileSize(gfx::Size(30, 30));
1313 LayerTreeSettings settings; 1313 LayerTreeSettings settings;
1314 1314
1315 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( 1315 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create(
1316 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, 1316 ACTIVE_TREE, &client, settings.tiling_interest_area_padding,
1317 settings.skewport_target_time_in_seconds, 1317 settings.skewport_target_time_in_seconds,
1318 settings.skewport_extrapolation_limit_in_content_pixels); 1318 settings.skewport_extrapolation_limit_in_content_pixels);
1319 1319
1320 scoped_refptr<FakeDisplayListRasterSource> raster_source = 1320 scoped_refptr<FakeRasterSource> raster_source =
1321 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1321 FakeRasterSource::CreateFilled(layer_bounds);
1322 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); 1322 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source);
1323 tiling->set_resolution(HIGH_RESOLUTION); 1323 tiling->set_resolution(HIGH_RESOLUTION);
1324 1324
1325 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); 1325 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true);
1326 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(), 1326 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(),
1327 true); 1327 true);
1328 1328
1329 float inset = 1329 float inset =
1330 PictureLayerTiling::CalculateSoonBorderDistance(moved_viewport, 1.0f); 1330 PictureLayerTiling::CalculateSoonBorderDistance(moved_viewport, 1.0f);
1331 gfx::Rect soon_rect = moved_viewport; 1331 gfx::Rect soon_rect = moved_viewport;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 host_impl_.global_tile_state().memory_limit_policy); 1458 host_impl_.global_tile_state().memory_limit_policy);
1459 EXPECT_EQ(ManagedMemoryPolicy::kDefaultNumResourcesLimit, 1459 EXPECT_EQ(ManagedMemoryPolicy::kDefaultNumResourcesLimit,
1460 host_impl_.global_tile_state().num_resources_limit); 1460 host_impl_.global_tile_state().num_resources_limit);
1461 } 1461 }
1462 1462
1463 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { 1463 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) {
1464 // Verify that we use the real tile bounds when advancing phases during the 1464 // Verify that we use the real tile bounds when advancing phases during the
1465 // tile iteration. 1465 // tile iteration.
1466 gfx::Size layer_bounds(1, 1); 1466 gfx::Size layer_bounds(1, 1);
1467 1467
1468 scoped_refptr<FakeDisplayListRasterSource> raster_source = 1468 scoped_refptr<FakeRasterSource> raster_source =
1469 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1469 FakeRasterSource::CreateFilled(layer_bounds);
1470 1470
1471 FakePictureLayerTilingClient pending_client; 1471 FakePictureLayerTilingClient pending_client;
1472 pending_client.SetTileSize(gfx::Size(64, 64)); 1472 pending_client.SetTileSize(gfx::Size(64, 64));
1473 1473
1474 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( 1474 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create(
1475 WhichTree::ACTIVE_TREE, &pending_client, 1.0f, 1.0f, 1000); 1475 WhichTree::ACTIVE_TREE, &pending_client, 1.0f, 1.0f, 1000);
1476 pending_client.set_twin_tiling_set(tiling_set.get()); 1476 pending_client.set_twin_tiling_set(tiling_set.get());
1477 1477
1478 auto* tiling = tiling_set->AddTiling(1.0f, raster_source); 1478 auto* tiling = tiling_set->AddTiling(1.0f, raster_source);
1479 1479
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 1533
1534 // Create non solid tile as well, otherwise tilings wouldnt be created. 1534 // Create non solid tile as well, otherwise tilings wouldnt be created.
1535 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); 1535 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
1536 SkPaint non_solid_paint; 1536 SkPaint non_solid_paint;
1537 non_solid_paint.setColor(non_solid_color); 1537 non_solid_paint.setColor(non_solid_color);
1538 1538
1539 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 10, 10), 1539 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 10, 10),
1540 non_solid_paint); 1540 non_solid_paint);
1541 recording_source->Rerecord(); 1541 recording_source->Rerecord();
1542 1542
1543 scoped_refptr<DisplayListRasterSource> raster_source = 1543 scoped_refptr<RasterSource> raster_source =
1544 DisplayListRasterSource::CreateFromDisplayListRecordingSource( 1544 RasterSource::CreateFromDisplayListRecordingSource(recording_source.get(),
1545 recording_source.get(), false); 1545 false);
1546 1546
1547 FakePictureLayerTilingClient tiling_client; 1547 FakePictureLayerTilingClient tiling_client;
1548 tiling_client.SetTileSize(size); 1548 tiling_client.SetTileSize(size);
1549 1549
1550 scoped_ptr<PictureLayerImpl> layer_impl = 1550 scoped_ptr<PictureLayerImpl> layer_impl =
1551 PictureLayerImpl::Create(host_impl_.active_tree(), 1, false); 1551 PictureLayerImpl::Create(host_impl_.active_tree(), 1, false);
1552 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set(); 1552 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set();
1553 1553
1554 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); 1554 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source);
1555 tiling->set_resolution(HIGH_RESOLUTION); 1555 tiling->set_resolution(HIGH_RESOLUTION);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 LayerTreeSettings settings; 1588 LayerTreeSettings settings;
1589 CustomizeSettings(&settings); 1589 CustomizeSettings(&settings);
1590 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_, 1590 host_impl_.reset(new MockLayerTreeHostImpl(settings, &task_runner_provider_,
1591 &shared_bitmap_manager_, 1591 &shared_bitmap_manager_,
1592 &task_graph_runner_)); 1592 &task_graph_runner_));
1593 host_impl_->SetVisible(true); 1593 host_impl_->SetVisible(true);
1594 host_impl_->InitializeRenderer(output_surface_.get()); 1594 host_impl_->InitializeRenderer(output_surface_.get());
1595 } 1595 }
1596 1596
1597 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 1597 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
1598 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1598 scoped_refptr<FakeRasterSource> pending_raster_source =
1599 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1599 FakeRasterSource::CreateFilled(layer_bounds);
1600 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = 1600 scoped_refptr<FakeRasterSource> active_raster_source =
1601 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 1601 FakeRasterSource::CreateFilled(layer_bounds);
1602 1602
1603 SetupTrees(pending_raster_source, active_raster_source); 1603 SetupTrees(pending_raster_source, active_raster_source);
1604 } 1604 }
1605 1605
1606 // This matches picture_layer_impl_unittest's ActivateTree. 1606 // This matches picture_layer_impl_unittest's ActivateTree.
1607 void ActivateTree() { 1607 void ActivateTree() {
1608 host_impl_->ActivateSyncTree(); 1608 host_impl_->ActivateSyncTree();
1609 CHECK(!host_impl_->pending_tree()); 1609 CHECK(!host_impl_->pending_tree());
1610 bool update_lcd_text = false; 1610 bool update_lcd_text = false;
1611 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 1611 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
1612 } 1612 }
1613 1613
1614 void SetupTrees(scoped_refptr<DisplayListRasterSource> pending_raster_source, 1614 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source,
1615 scoped_refptr<DisplayListRasterSource> active_raster_source) { 1615 scoped_refptr<RasterSource> active_raster_source) {
1616 SetupPendingTree(active_raster_source); 1616 SetupPendingTree(active_raster_source);
1617 ActivateTree(); 1617 ActivateTree();
1618 SetupPendingTree(pending_raster_source); 1618 SetupPendingTree(pending_raster_source);
1619 } 1619 }
1620 1620
1621 void SetupPendingTree(scoped_refptr<DisplayListRasterSource> raster_source) { 1621 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) {
1622 host_impl_->CreatePendingTree(); 1622 host_impl_->CreatePendingTree();
1623 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 1623 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
1624 1624
1625 // Steal from the recycled tree. 1625 // Steal from the recycled tree.
1626 LayerImpl* old_pending_root = pending_tree->root_layer(); 1626 LayerImpl* old_pending_root = pending_tree->root_layer();
1627 FakePictureLayerImpl* pending_layer = nullptr; 1627 FakePictureLayerImpl* pending_layer = nullptr;
1628 if (old_pending_root) { 1628 if (old_pending_root) {
1629 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root); 1629 pending_layer = static_cast<FakePictureLayerImpl*>(old_pending_root);
1630 pending_layer->SetRasterSourceOnPending(raster_source, Region()); 1630 pending_layer->SetRasterSourceOnPending(raster_source, Region());
1631 } else { 1631 } else {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 } 1736 }
1737 } 1737 }
1738 1738
1739 TEST_F(TileManagerTest, LowResHasNoImage) { 1739 TEST_F(TileManagerTest, LowResHasNoImage) {
1740 gfx::Size size(10, 12); 1740 gfx::Size size(10, 12);
1741 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION}; 1741 TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION};
1742 1742
1743 for (size_t i = 0; i < arraysize(resolutions); ++i) { 1743 for (size_t i = 0; i < arraysize(resolutions); ++i) {
1744 SCOPED_TRACE(resolutions[i]); 1744 SCOPED_TRACE(resolutions[i]);
1745 1745
1746 // Make a DisplayListRasterSource that will draw a blue bitmap image. 1746 // Make a RasterSource that will draw a blue bitmap image.
1747 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 1747 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
1748 SkSurface::NewRasterN32Premul(size.width(), size.height())); 1748 SkSurface::NewRasterN32Premul(size.width(), size.height()));
1749 ASSERT_NE(surface, nullptr); 1749 ASSERT_NE(surface, nullptr);
1750 surface->getCanvas()->clear(SK_ColorBLUE); 1750 surface->getCanvas()->clear(SK_ColorBLUE);
1751 skia::RefPtr<SkImage> blue_image = 1751 skia::RefPtr<SkImage> blue_image =
1752 skia::AdoptRef(surface->newImageSnapshot()); 1752 skia::AdoptRef(surface->newImageSnapshot());
1753 1753
1754 scoped_ptr<FakeDisplayListRecordingSource> recording_source = 1754 scoped_ptr<FakeDisplayListRecordingSource> recording_source =
1755 FakeDisplayListRecordingSource::CreateFilledRecordingSource(size); 1755 FakeDisplayListRecordingSource::CreateFilledRecordingSource(size);
1756 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); 1756 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
1757 recording_source->SetRequiresClear(true); 1757 recording_source->SetRequiresClear(true);
1758 recording_source->SetClearCanvasWithDebugColor(false); 1758 recording_source->SetClearCanvasWithDebugColor(false);
1759 SkPaint paint; 1759 SkPaint paint;
1760 paint.setColor(SK_ColorGREEN); 1760 paint.setColor(SK_ColorGREEN);
1761 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); 1761 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint);
1762 recording_source->add_draw_image(blue_image.get(), gfx::Point()); 1762 recording_source->add_draw_image(blue_image.get(), gfx::Point());
1763 recording_source->Rerecord(); 1763 recording_source->Rerecord();
1764 scoped_refptr<DisplayListRasterSource> raster = 1764 scoped_refptr<RasterSource> raster =
1765 DisplayListRasterSource::CreateFromDisplayListRecordingSource( 1765 RasterSource::CreateFromDisplayListRecordingSource(
1766 recording_source.get(), false); 1766 recording_source.get(), false);
1767 1767
1768 FakePictureLayerTilingClient tiling_client; 1768 FakePictureLayerTilingClient tiling_client;
1769 tiling_client.SetTileSize(size); 1769 tiling_client.SetTileSize(size);
1770 1770
1771 scoped_ptr<PictureLayerImpl> layer = 1771 scoped_ptr<PictureLayerImpl> layer =
1772 PictureLayerImpl::Create(host_impl_->active_tree(), 1, false); 1772 PictureLayerImpl::Create(host_impl_->active_tree(), 1, false);
1773 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); 1773 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set();
1774 1774
1775 auto* tiling = tiling_set->AddTiling(1.0f, raster); 1775 auto* tiling = tiling_set->AddTiling(1.0f, raster);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 // Create a CancellingTaskRunner and set it on the tile manager so that all 1878 // Create a CancellingTaskRunner and set it on the tile manager so that all
1879 // scheduled work is immediately cancelled. 1879 // scheduled work is immediately cancelled.
1880 CancellingTileTaskRunner cancelling_runner; 1880 CancellingTileTaskRunner cancelling_runner;
1881 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner); 1881 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner);
1882 1882
1883 // Pick arbitrary IDs - they don't really matter as long as they're constant. 1883 // Pick arbitrary IDs - they don't really matter as long as they're constant.
1884 const int kLayerId = 7; 1884 const int kLayerId = 7;
1885 const uint64_t kInvalidatedId = 43; 1885 const uint64_t kInvalidatedId = 43;
1886 const gfx::Size kTileSize(128, 128); 1886 const gfx::Size kTileSize(128, 128);
1887 1887
1888 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1888 scoped_refptr<FakeRasterSource> pending_raster_source =
1889 FakeDisplayListRasterSource::CreateFilled(kTileSize); 1889 FakeRasterSource::CreateFilled(kTileSize);
1890 host_impl_->CreatePendingTree(); 1890 host_impl_->CreatePendingTree();
1891 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 1891 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
1892 1892
1893 // Steal from the recycled tree. 1893 // Steal from the recycled tree.
1894 scoped_ptr<FakePictureLayerImpl> pending_layer = 1894 scoped_ptr<FakePictureLayerImpl> pending_layer =
1895 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, 1895 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId,
1896 pending_raster_source); 1896 pending_raster_source);
1897 pending_layer->SetDrawsContent(true); 1897 pending_layer->SetDrawsContent(true);
1898 pending_layer->SetHasRenderSurface(true); 1898 pending_layer->SetHasRenderSurface(true);
1899 1899
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 // task we see is created with |kExpectedId|. 1971 // task we see is created with |kExpectedId|.
1972 VerifyResourceContentIdTileTaskRunner verifying_runner(kExpectedId); 1972 VerifyResourceContentIdTileTaskRunner verifying_runner(kExpectedId);
1973 host_impl->tile_manager()->SetTileTaskRunnerForTesting(&verifying_runner); 1973 host_impl->tile_manager()->SetTileTaskRunnerForTesting(&verifying_runner);
1974 1974
1975 // Ensure there's a resource with our |kInvalidatedId| in the resource pool. 1975 // Ensure there's a resource with our |kInvalidatedId| in the resource pool.
1976 host_impl->resource_pool()->ReleaseResource( 1976 host_impl->resource_pool()->ReleaseResource(
1977 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888), 1977 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888),
1978 kInvalidatedId); 1978 kInvalidatedId);
1979 host_impl->resource_pool()->CheckBusyResources(); 1979 host_impl->resource_pool()->CheckBusyResources();
1980 1980
1981 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = 1981 scoped_refptr<FakeRasterSource> pending_raster_source =
1982 FakeDisplayListRasterSource::CreateFilled(kTileSize); 1982 FakeRasterSource::CreateFilled(kTileSize);
1983 host_impl->CreatePendingTree(); 1983 host_impl->CreatePendingTree();
1984 LayerTreeImpl* pending_tree = host_impl->pending_tree(); 1984 LayerTreeImpl* pending_tree = host_impl->pending_tree();
1985 1985
1986 // Steal from the recycled tree. 1986 // Steal from the recycled tree.
1987 scoped_ptr<FakePictureLayerImpl> pending_layer = 1987 scoped_ptr<FakePictureLayerImpl> pending_layer =
1988 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, 1988 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId,
1989 pending_raster_source); 1989 pending_raster_source);
1990 pending_layer->SetDrawsContent(true); 1990 pending_layer->SetDrawsContent(true);
1991 pending_layer->SetHasRenderSurface(true); 1991 pending_layer->SetHasRenderSurface(true);
1992 1992
(...skipping 30 matching lines...) Expand all
2023 2023
2024 // Ensures that the tile manager does not attempt to reuse tiles when partial 2024 // Ensures that the tile manager does not attempt to reuse tiles when partial
2025 // raster is disabled. 2025 // raster is disabled.
2026 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 2026 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
2027 RunPartialRasterCheck(std::move(host_impl_), 2027 RunPartialRasterCheck(std::move(host_impl_),
2028 false /* partial_raster_enabled */); 2028 false /* partial_raster_enabled */);
2029 } 2029 }
2030 2030
2031 } // namespace 2031 } // namespace
2032 } // namespace cc 2032 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager_perftest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698