| 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 "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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void RunEvictionIteratorConstructTest(const std::string& test_name, | 182 void RunEvictionIteratorConstructTest(const std::string& test_name, |
| 183 const gfx::Rect& viewport) { | 183 const gfx::Rect& viewport) { |
| 184 gfx::Size bounds(viewport.size()); | 184 gfx::Size bounds(viewport.size()); |
| 185 picture_layer_tiling_ = | 185 picture_layer_tiling_ = |
| 186 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 186 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 187 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 187 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 188 picture_layer_tiling_->ComputeTilePriorityRects( | 188 picture_layer_tiling_->ComputeTilePriorityRects( |
| 189 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 189 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 190 | 190 |
| 191 timer_.Reset(); | 191 timer_.Reset(); |
| 192 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | |
| 193 SMOOTHNESS_TAKES_PRIORITY, | |
| 194 NEW_CONTENT_TAKES_PRIORITY}; | |
| 195 int priority_count = 0; | |
| 196 do { | 192 do { |
| 197 PictureLayerTiling::TilingEvictionTileIterator it( | 193 PictureLayerTiling::TilingEvictionTileIterator it( |
| 198 picture_layer_tiling_.get(), | 194 picture_layer_tiling_.get(), |
| 199 priorities[priority_count], | |
| 200 PictureLayerTiling::NOW); | 195 PictureLayerTiling::NOW); |
| 201 priority_count = (priority_count + 1) % arraysize(priorities); | |
| 202 timer_.NextLap(); | 196 timer_.NextLap(); |
| 203 } while (!timer_.HasTimeLimitExpired()); | 197 } while (!timer_.HasTimeLimitExpired()); |
| 204 | 198 |
| 205 perf_test::PrintResult("tiling_eviction_tile_iterator_construct", | 199 perf_test::PrintResult("tiling_eviction_tile_iterator_construct", |
| 206 "", | 200 "", |
| 207 test_name, | 201 test_name, |
| 208 timer_.LapsPerSecond(), | 202 timer_.LapsPerSecond(), |
| 209 "runs/s", | 203 "runs/s", |
| 210 true); | 204 true); |
| 211 } | 205 } |
| 212 | 206 |
| 213 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, | 207 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
| 214 int num_tiles, | 208 int num_tiles, |
| 215 const gfx::Rect& viewport) { | 209 const gfx::Rect& viewport) { |
| 216 gfx::Size bounds(10000, 10000); | 210 gfx::Size bounds(10000, 10000); |
| 217 picture_layer_tiling_ = | 211 picture_layer_tiling_ = |
| 218 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 212 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 219 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 213 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 220 picture_layer_tiling_->ComputeTilePriorityRects( | 214 picture_layer_tiling_->ComputeTilePriorityRects( |
| 221 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 215 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 222 | 216 |
| 223 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | |
| 224 SMOOTHNESS_TAKES_PRIORITY, | |
| 225 NEW_CONTENT_TAKES_PRIORITY}; | |
| 226 | |
| 227 // Ensure all tiles have resources. | 217 // Ensure all tiles have resources. |
| 228 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); | 218 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); |
| 229 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 219 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
| 230 tile_it != all_tiles.end(); | 220 tile_it != all_tiles.end(); |
| 231 ++tile_it) { | 221 ++tile_it) { |
| 232 Tile* tile = *tile_it; | 222 Tile* tile = *tile_it; |
| 233 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); | 223 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
| 234 draw_info.SetResourceForTesting( | 224 draw_info.SetResourceForTesting( |
| 235 ScopedResource::Create(resource_provider_.get()).Pass()); | 225 ScopedResource::Create(resource_provider_.get()).Pass()); |
| 236 } | 226 } |
| 237 | 227 |
| 238 int priority_count = 0; | |
| 239 timer_.Reset(); | 228 timer_.Reset(); |
| 240 do { | 229 do { |
| 241 int count = num_tiles; | 230 int count = num_tiles; |
| 242 PictureLayerTiling::TilingEvictionTileIterator it( | 231 PictureLayerTiling::TilingEvictionTileIterator it( |
| 243 picture_layer_tiling_.get(), | 232 picture_layer_tiling_.get(), |
| 244 priorities[priority_count], | |
| 245 PictureLayerTiling::EVENTUALLY); | 233 PictureLayerTiling::EVENTUALLY); |
| 246 while (count--) { | 234 while (count--) { |
| 247 ASSERT_TRUE(it) << "count: " << count; | 235 ASSERT_TRUE(it) << "count: " << count; |
| 248 ASSERT_TRUE(*it != NULL) << "count: " << count; | 236 ASSERT_TRUE(*it != NULL) << "count: " << count; |
| 249 ++it; | 237 ++it; |
| 250 } | 238 } |
| 251 priority_count = (priority_count + 1) % arraysize(priorities); | |
| 252 timer_.NextLap(); | 239 timer_.NextLap(); |
| 253 } while (!timer_.HasTimeLimitExpired()); | 240 } while (!timer_.HasTimeLimitExpired()); |
| 254 | 241 |
| 255 // Remove all resources from tiles to make sure the tile version destructor | 242 // Remove all resources from tiles to make sure the tile version destructor |
| 256 // doesn't complain. | 243 // doesn't complain. |
| 257 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 244 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
| 258 tile_it != all_tiles.end(); | 245 tile_it != all_tiles.end(); |
| 259 ++tile_it) { | 246 ++tile_it) { |
| 260 Tile* tile = *tile_it; | 247 Tile* tile = *tile_it; |
| 261 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); | 248 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 338 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 352 RunEvictionIteratorConstructAndIterateTest( | 339 RunEvictionIteratorConstructAndIterateTest( |
| 353 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 340 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 354 RunEvictionIteratorConstructAndIterateTest( | 341 RunEvictionIteratorConstructAndIterateTest( |
| 355 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 342 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| 356 } | 343 } |
| 357 | 344 |
| 358 } // namespace | 345 } // namespace |
| 359 | 346 |
| 360 } // namespace cc | 347 } // namespace cc |
| OLD | NEW |