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

Side by Side Diff: cc/layers/picture_layer_impl_perftest.cc

Issue 1344373002: cc: Fix PictureLayerImplPerfTest DCHECK failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to ToT. Created 5 years, 2 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/debug/lap_timer.h" 8 #include "cc/debug/lap_timer.h"
9 #include "cc/test/fake_display_list_raster_source.h" 9 #include "cc/test/fake_display_list_raster_source.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 &shared_bitmap_manager_, 47 &shared_bitmap_manager_,
48 &task_graph_runner_), 48 &task_graph_runner_),
49 timer_(kWarmupRuns, 49 timer_(kWarmupRuns,
50 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 50 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
51 kTimeCheckInterval) {} 51 kTimeCheckInterval) {}
52 52
53 void SetUp() override { 53 void SetUp() override {
54 host_impl_.InitializeRenderer(output_surface_.get()); 54 host_impl_.InitializeRenderer(output_surface_.get());
55 } 55 }
56 56
57 void SetupActiveTree(const gfx::Size& layer_bounds) { 57 void SetupPendingTree(const gfx::Size& layer_bounds) {
58 scoped_refptr<FakeDisplayListRasterSource> raster_source = 58 scoped_refptr<FakeDisplayListRasterSource> raster_source =
59 FakeDisplayListRasterSource::CreateFilled(layer_bounds); 59 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
60 LayerTreeImpl* active_tree = host_impl_.active_tree(); 60 host_impl_.CreatePendingTree();
61 active_tree->DetachLayerTree(); 61 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
62 pending_tree->DetachLayerTree();
62 63
63 scoped_ptr<FakePictureLayerImpl> active_layer = 64 scoped_ptr<FakePictureLayerImpl> pending_layer =
64 FakePictureLayerImpl::CreateWithRasterSource(active_tree, 7, 65 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7,
65 raster_source); 66 raster_source);
66 active_layer->SetDrawsContent(true); 67 pending_layer->SetDrawsContent(true);
67 active_layer->SetHasRenderSurface(true); 68 pending_layer->SetHasRenderSurface(true);
68 active_tree->SetRootLayer(active_layer.Pass()); 69 pending_tree->SetRootLayer(pending_layer.Pass());
69 70
70 active_layer_ = static_cast<FakePictureLayerImpl*>( 71 pending_layer_ = static_cast<FakePictureLayerImpl*>(
71 host_impl_.active_tree()->LayerById(7)); 72 host_impl_.pending_tree()->LayerById(7));
72 } 73 }
73 74
74 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, 75 void RunRasterQueueConstructAndIterateTest(const std::string& test_name,
75 int num_tiles, 76 int num_tiles,
76 const gfx::Size& viewport_size) { 77 const gfx::Size& viewport_size) {
77 host_impl_.SetViewportSize(viewport_size); 78 host_impl_.SetViewportSize(viewport_size);
78 bool update_lcd_text = false; 79 bool update_lcd_text = false;
79 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 80 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
80 81
81 timer_.Reset(); 82 timer_.Reset();
82 do { 83 do {
83 int count = num_tiles; 84 int count = num_tiles;
84 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 85 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
85 active_layer_->picture_layer_tiling_set(), false)); 86 pending_layer_->picture_layer_tiling_set(), false));
86 while (count--) { 87 while (count--) {
87 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; 88 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
88 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; 89 ASSERT_TRUE(queue->Top().tile()) << "count: " << count;
89 queue->Pop(); 90 queue->Pop();
90 } 91 }
91 timer_.NextLap(); 92 timer_.NextLap();
92 } while (!timer_.HasTimeLimitExpired()); 93 } while (!timer_.HasTimeLimitExpired());
93 94
94 perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "", 95 perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "",
95 test_name, timer_.LapsPerSecond(), "runs/s", true); 96 test_name, timer_.LapsPerSecond(), "runs/s", true);
96 } 97 }
97 98
98 void RunRasterQueueConstructTest(const std::string& test_name, 99 void RunRasterQueueConstructTest(const std::string& test_name,
99 const gfx::Rect& viewport) { 100 const gfx::Rect& viewport) {
100 host_impl_.SetViewportSize(viewport.size()); 101 host_impl_.SetViewportSize(viewport.size());
101 active_layer_->PushScrollOffsetFromMainThreadAndClobberActiveValue( 102 pending_layer_->PushScrollOffsetFromMainThread(
102 gfx::ScrollOffset(viewport.x(), viewport.y())); 103 gfx::ScrollOffset(viewport.x(), viewport.y()));
103 bool update_lcd_text = false; 104 bool update_lcd_text = false;
104 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 105 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
105 106
106 timer_.Reset(); 107 timer_.Reset();
107 do { 108 do {
108 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 109 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
109 active_layer_->picture_layer_tiling_set(), false)); 110 pending_layer_->picture_layer_tiling_set(), false));
110 timer_.NextLap(); 111 timer_.NextLap();
111 } while (!timer_.HasTimeLimitExpired()); 112 } while (!timer_.HasTimeLimitExpired());
112 113
113 perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name, 114 perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name,
114 timer_.LapsPerSecond(), "runs/s", true); 115 timer_.LapsPerSecond(), "runs/s", true);
115 } 116 }
116 117
117 void RunEvictionQueueConstructAndIterateTest( 118 void RunEvictionQueueConstructAndIterateTest(
118 const std::string& test_name, 119 const std::string& test_name,
119 int num_tiles, 120 int num_tiles,
120 const gfx::Size& viewport_size) { 121 const gfx::Size& viewport_size) {
121 host_impl_.SetViewportSize(viewport_size); 122 host_impl_.SetViewportSize(viewport_size);
122 active_layer_->MarkAllTilingsUsed();
123 bool update_lcd_text = false; 123 bool update_lcd_text = false;
124 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 124 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
125 125
126 timer_.Reset(); 126 timer_.Reset();
127 do { 127 do {
128 int count = num_tiles; 128 int count = num_tiles;
129 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( 129 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
130 active_layer_->picture_layer_tiling_set())); 130 pending_layer_->picture_layer_tiling_set()));
131 while (count--) { 131 while (count--) {
132 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; 132 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
133 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; 133 ASSERT_TRUE(queue->Top().tile()) << "count: " << count;
134 queue->Pop(); 134 queue->Pop();
135 } 135 }
136 timer_.NextLap(); 136 timer_.NextLap();
137 } while (!timer_.HasTimeLimitExpired()); 137 } while (!timer_.HasTimeLimitExpired());
138 138
139 perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate", 139 perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate",
140 "", test_name, timer_.LapsPerSecond(), "runs/s", 140 "", test_name, timer_.LapsPerSecond(), "runs/s",
141 true); 141 true);
142 } 142 }
143 143
144 void RunEvictionQueueConstructTest(const std::string& test_name, 144 void RunEvictionQueueConstructTest(const std::string& test_name,
145 const gfx::Rect& viewport) { 145 const gfx::Rect& viewport) {
146 host_impl_.SetViewportSize(viewport.size()); 146 host_impl_.SetViewportSize(viewport.size());
147 active_layer_->PushScrollOffsetFromMainThreadAndClobberActiveValue( 147 pending_layer_->PushScrollOffsetFromMainThread(
148 gfx::ScrollOffset(viewport.x(), viewport.y())); 148 gfx::ScrollOffset(viewport.x(), viewport.y()));
149 active_layer_->MarkAllTilingsUsed();
150 bool update_lcd_text = false; 149 bool update_lcd_text = false;
151 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 150 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
152 151
153 timer_.Reset(); 152 timer_.Reset();
154 do { 153 do {
155 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( 154 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
156 active_layer_->picture_layer_tiling_set())); 155 pending_layer_->picture_layer_tiling_set()));
157 timer_.NextLap(); 156 timer_.NextLap();
158 } while (!timer_.HasTimeLimitExpired()); 157 } while (!timer_.HasTimeLimitExpired());
159 158
160 perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name, 159 perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name,
161 timer_.LapsPerSecond(), "runs/s", true); 160 timer_.LapsPerSecond(), "runs/s", true);
162 } 161 }
163 162
164 protected: 163 protected:
165 TestSharedBitmapManager shared_bitmap_manager_; 164 TestSharedBitmapManager shared_bitmap_manager_;
166 TestTaskGraphRunner task_graph_runner_; 165 TestTaskGraphRunner task_graph_runner_;
167 FakeImplProxy proxy_; 166 FakeImplProxy proxy_;
168 scoped_ptr<OutputSurface> output_surface_; 167 scoped_ptr<OutputSurface> output_surface_;
169 FakeLayerTreeHostImpl host_impl_; 168 FakeLayerTreeHostImpl host_impl_;
170 FakePictureLayerImpl* active_layer_; 169 FakePictureLayerImpl* pending_layer_;
171 LapTimer timer_; 170 LapTimer timer_;
172 171
173 private: 172 private:
174 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); 173 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest);
175 }; 174 };
176 175
177 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { 176 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) {
178 SetupActiveTree(gfx::Size(10000, 10000)); 177 SetupPendingTree(gfx::Size(10000, 10000));
179 178
180 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 179 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
181 180
182 active_layer_->AddTiling(low_res_factor); 181 pending_layer_->AddTiling(low_res_factor);
183 active_layer_->AddTiling(0.3f); 182 pending_layer_->AddTiling(0.3f);
184 active_layer_->AddTiling(0.7f); 183 pending_layer_->AddTiling(0.7f);
185 active_layer_->AddTiling(1.0f); 184 pending_layer_->AddTiling(1.0f);
186 active_layer_->AddTiling(2.0f); 185 pending_layer_->AddTiling(2.0f);
187 186
188 RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100)); 187 RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100));
189 RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500)); 188 RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500));
190 RunRasterQueueConstructAndIterateTest("64_100x100", 64, gfx::Size(100, 100)); 189 RunRasterQueueConstructAndIterateTest("64_100x100", 64, gfx::Size(100, 100));
191 RunRasterQueueConstructAndIterateTest("64_500x500", 64, gfx::Size(500, 500)); 190 RunRasterQueueConstructAndIterateTest("64_500x500", 64, gfx::Size(500, 500));
192 } 191 }
193 192
194 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) { 193 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) {
195 SetupActiveTree(gfx::Size(10000, 10000)); 194 SetupPendingTree(gfx::Size(10000, 10000));
196 195
197 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 196 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
198 197
199 active_layer_->AddTiling(low_res_factor); 198 pending_layer_->AddTiling(low_res_factor);
200 active_layer_->AddTiling(0.3f); 199 pending_layer_->AddTiling(0.3f);
201 active_layer_->AddTiling(0.7f); 200 pending_layer_->AddTiling(0.7f);
202 active_layer_->AddTiling(1.0f); 201 pending_layer_->AddTiling(1.0f);
203 active_layer_->AddTiling(2.0f); 202 pending_layer_->AddTiling(2.0f);
204 203
205 RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); 204 RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
206 RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); 205 RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100));
207 RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); 206 RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100));
208 } 207 }
209 208
210 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { 209 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) {
211 SetupActiveTree(gfx::Size(10000, 10000)); 210 SetupPendingTree(gfx::Size(10000, 10000));
212 211
213 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 212 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
214 213
215 std::vector<Tile*> all_tiles; 214 std::vector<Tile*> all_tiles;
216 AddTiling(low_res_factor, active_layer_, &all_tiles); 215 AddTiling(low_res_factor, pending_layer_, &all_tiles);
217 AddTiling(0.3f, active_layer_, &all_tiles); 216 AddTiling(0.3f, pending_layer_, &all_tiles);
218 AddTiling(0.7f, active_layer_, &all_tiles); 217 AddTiling(0.7f, pending_layer_, &all_tiles);
219 AddTiling(1.0f, active_layer_, &all_tiles); 218 AddTiling(1.0f, pending_layer_, &all_tiles);
220 AddTiling(2.0f, active_layer_, &all_tiles); 219 AddTiling(2.0f, pending_layer_, &all_tiles);
221 220
222 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); 221 ASSERT_TRUE(host_impl_.tile_manager() != nullptr);
223 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 222 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
224 223
225 RunEvictionQueueConstructAndIterateTest( 224 RunEvictionQueueConstructAndIterateTest(
226 "32_100x100", 32, gfx::Size(100, 100)); 225 "32_100x100", 32, gfx::Size(100, 100));
227 RunEvictionQueueConstructAndIterateTest( 226 RunEvictionQueueConstructAndIterateTest(
228 "32_500x500", 32, gfx::Size(500, 500)); 227 "32_500x500", 32, gfx::Size(500, 500));
229 RunEvictionQueueConstructAndIterateTest( 228 RunEvictionQueueConstructAndIterateTest(
230 "64_100x100", 64, gfx::Size(100, 100)); 229 "64_100x100", 64, gfx::Size(100, 100));
231 RunEvictionQueueConstructAndIterateTest( 230 RunEvictionQueueConstructAndIterateTest(
232 "64_500x500", 64, gfx::Size(500, 500)); 231 "64_500x500", 64, gfx::Size(500, 500));
233 } 232 }
234 233
235 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) { 234 TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) {
236 SetupActiveTree(gfx::Size(10000, 10000)); 235 SetupPendingTree(gfx::Size(10000, 10000));
237 236
238 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 237 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
239 238
240 std::vector<Tile*> all_tiles; 239 std::vector<Tile*> all_tiles;
241 AddTiling(low_res_factor, active_layer_, &all_tiles); 240 AddTiling(low_res_factor, pending_layer_, &all_tiles);
242 AddTiling(0.3f, active_layer_, &all_tiles); 241 AddTiling(0.3f, pending_layer_, &all_tiles);
243 AddTiling(0.7f, active_layer_, &all_tiles); 242 AddTiling(0.7f, pending_layer_, &all_tiles);
244 AddTiling(1.0f, active_layer_, &all_tiles); 243 AddTiling(1.0f, pending_layer_, &all_tiles);
245 AddTiling(2.0f, active_layer_, &all_tiles); 244 AddTiling(2.0f, pending_layer_, &all_tiles);
246 245
247 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); 246 ASSERT_TRUE(host_impl_.tile_manager() != nullptr);
248 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 247 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
249 248
250 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); 249 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
251 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); 250 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100));
252 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); 251 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100));
253 } 252 }
254 253
255 } // namespace 254 } // namespace
256 } // namespace cc 255 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698