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

Side by Side Diff: cc/resources/picture_layer_tiling_perftest.cc

Issue 741683003: cc: Move LayerEvictionTileIterator to a separate file and make it a queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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/resources/picture_layer_tiling.cc ('k') | cc/resources/picture_layer_tiling_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 "cc/debug/lap_timer.h" 5 #include "cc/debug/lap_timer.h"
6 #include "cc/resources/picture_layer_tiling.h" 6 #include "cc/resources/picture_layer_tiling.h"
7 #include "cc/resources/resource_provider.h" 7 #include "cc/resources/resource_provider.h"
8 #include "cc/resources/scoped_resource.h" 8 #include "cc/resources/scoped_resource.h"
9 #include "cc/test/fake_output_surface.h" 9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_output_surface_client.h" 10 #include "cc/test/fake_output_surface_client.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } while (!timer_.HasTimeLimitExpired()); 171 } while (!timer_.HasTimeLimitExpired());
172 172
173 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", 173 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate",
174 "", 174 "",
175 test_name, 175 test_name,
176 timer_.LapsPerSecond(), 176 timer_.LapsPerSecond(),
177 "runs/s", 177 "runs/s",
178 true); 178 true);
179 } 179 }
180 180
181 void RunEvictionIteratorConstructTest(const std::string& test_name,
182 const gfx::Rect& viewport) {
183 gfx::Size bounds(viewport.size());
184 picture_layer_tiling_ =
185 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
186 picture_layer_tiling_client_.set_tree(ACTIVE_TREE);
187 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
188 Occlusion());
189
190 timer_.Reset();
191 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
192 SMOOTHNESS_TAKES_PRIORITY,
193 NEW_CONTENT_TAKES_PRIORITY};
194 int priority_count = 0;
195 do {
196 PictureLayerTiling::TilingEvictionTileIterator it(
197 picture_layer_tiling_.get(),
198 priorities[priority_count],
199 PictureLayerTiling::NOW);
200 priority_count = (priority_count + 1) % arraysize(priorities);
201 timer_.NextLap();
202 } while (!timer_.HasTimeLimitExpired());
203
204 perf_test::PrintResult("tiling_eviction_tile_iterator_construct",
205 "",
206 test_name,
207 timer_.LapsPerSecond(),
208 "runs/s",
209 true);
210 }
211
212 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name,
213 int num_tiles,
214 const gfx::Rect& viewport) {
215 gfx::Size bounds(10000, 10000);
216 picture_layer_tiling_ =
217 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
218 picture_layer_tiling_client_.set_tree(ACTIVE_TREE);
219 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
220 Occlusion());
221
222 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
223 SMOOTHNESS_TAKES_PRIORITY,
224 NEW_CONTENT_TAKES_PRIORITY};
225
226 // Ensure all tiles have resources.
227 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting();
228 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin();
229 tile_it != all_tiles.end();
230 ++tile_it) {
231 Tile* tile = *tile_it;
232 ManagedTileState::DrawInfo& draw_info = tile->draw_info();
233 draw_info.SetResourceForTesting(
234 ScopedResource::Create(resource_provider_.get()).Pass());
235 }
236
237 int priority_count = 0;
238 timer_.Reset();
239 do {
240 int count = num_tiles;
241 PictureLayerTiling::TilingEvictionTileIterator it(
242 picture_layer_tiling_.get(),
243 priorities[priority_count],
244 PictureLayerTiling::EVENTUALLY);
245 while (count--) {
246 ASSERT_TRUE(it) << "count: " << count;
247 ASSERT_TRUE(*it != NULL) << "count: " << count;
248 ++it;
249 }
250 priority_count = (priority_count + 1) % arraysize(priorities);
251 timer_.NextLap();
252 } while (!timer_.HasTimeLimitExpired());
253
254 // Remove all resources from tiles to make sure the tile version destructor
255 // doesn't complain.
256 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin();
257 tile_it != all_tiles.end();
258 ++tile_it) {
259 Tile* tile = *tile_it;
260 ManagedTileState::DrawInfo& draw_info = tile->draw_info();
261 draw_info.SetResourceForTesting(nullptr);
262 }
263
264 perf_test::PrintResult(
265 "tiling_eviction_tile_iterator_construct_and_iterate",
266 "",
267 test_name,
268 timer_.LapsPerSecond(),
269 "runs/s",
270 true);
271 }
272
273 private: 181 private:
274 FakePictureLayerTilingClient picture_layer_tiling_client_; 182 FakePictureLayerTilingClient picture_layer_tiling_client_;
275 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; 183 scoped_ptr<PictureLayerTiling> picture_layer_tiling_;
276 184
277 LapTimer timer_; 185 LapTimer timer_;
278 186
279 scoped_refptr<ContextProvider> context_provider_; 187 scoped_refptr<ContextProvider> context_provider_;
280 FakeOutputSurfaceClient output_surface_client_; 188 FakeOutputSurfaceClient output_surface_client_;
281 scoped_ptr<FakeOutputSurface> output_surface_; 189 scoped_ptr<FakeOutputSurface> output_surface_;
282 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 190 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 RunRasterIteratorConstructAndIterateTest( 234 RunRasterIteratorConstructAndIterateTest(
327 "32_100x100", 32, gfx::Rect(0, 0, 100, 100)); 235 "32_100x100", 32, gfx::Rect(0, 0, 100, 100));
328 RunRasterIteratorConstructAndIterateTest( 236 RunRasterIteratorConstructAndIterateTest(
329 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); 237 "32_500x500", 32, gfx::Rect(0, 0, 500, 500));
330 RunRasterIteratorConstructAndIterateTest( 238 RunRasterIteratorConstructAndIterateTest(
331 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); 239 "64_100x100", 64, gfx::Rect(0, 0, 100, 100));
332 RunRasterIteratorConstructAndIterateTest( 240 RunRasterIteratorConstructAndIterateTest(
333 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); 241 "64_500x500", 64, gfx::Rect(0, 0, 500, 500));
334 } 242 }
335 243
336 TEST_F(PictureLayerTilingPerfTest, TilingEvictionTileIteratorConstruct) {
337 RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
338 RunEvictionIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100));
339 RunEvictionIteratorConstructTest("100_0_100x100",
340 gfx::Rect(100, 0, 100, 100));
341 RunEvictionIteratorConstructTest("150_0_100x100",
342 gfx::Rect(150, 0, 100, 100));
343 }
344
345 TEST_F(PictureLayerTilingPerfTest,
346 TilingEvictionTileIteratorConstructAndIterate) {
347 RunEvictionIteratorConstructAndIterateTest(
348 "32_100x100", 32, gfx::Rect(0, 0, 100, 100));
349 RunEvictionIteratorConstructAndIterateTest(
350 "32_500x500", 32, gfx::Rect(0, 0, 500, 500));
351 RunEvictionIteratorConstructAndIterateTest(
352 "64_100x100", 64, gfx::Rect(0, 0, 100, 100));
353 RunEvictionIteratorConstructAndIterateTest(
354 "64_500x500", 64, gfx::Rect(0, 0, 500, 500));
355 }
356
357 } // namespace 244 } // namespace
358 245
359 } // namespace cc 246 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | cc/resources/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698