| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 do { | 61 do { |
| 62 picture_layer_tiling_->UpdateTilesToCurrentPile( | 62 picture_layer_tiling_->UpdateTilesToCurrentPile( |
| 63 region, picture_layer_tiling_->tiling_size()); | 63 region, picture_layer_tiling_->tiling_size()); |
| 64 timer_.NextLap(); | 64 timer_.NextLap(); |
| 65 } while (!timer_.HasTimeLimitExpired()); | 65 } while (!timer_.HasTimeLimitExpired()); |
| 66 | 66 |
| 67 perf_test::PrintResult( | 67 perf_test::PrintResult( |
| 68 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 68 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void RunUpdateTilePrioritiesStationaryTest(const std::string& test_name, | 71 void RunComputeTilePriorityRectsStationaryTest( |
| 72 const gfx::Transform& transform) { | 72 const std::string& test_name, |
| 73 const gfx::Transform& transform) { |
| 73 gfx::Rect viewport_rect(0, 0, 1024, 768); | 74 gfx::Rect viewport_rect(0, 0, 1024, 768); |
| 74 | 75 |
| 75 timer_.Reset(); | 76 timer_.Reset(); |
| 76 do { | 77 do { |
| 77 picture_layer_tiling_->UpdateTilePriorities( | 78 picture_layer_tiling_->ComputeTilePriorityRects( |
| 78 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 79 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); |
| 79 timer_.NextLap(); | 80 timer_.NextLap(); |
| 80 } while (!timer_.HasTimeLimitExpired()); | 81 } while (!timer_.HasTimeLimitExpired()); |
| 81 | 82 |
| 82 perf_test::PrintResult("update_tile_priorities_stationary", | 83 perf_test::PrintResult("compute_tile_priority_rects_stationary", |
| 83 "", | 84 "", |
| 84 test_name, | 85 test_name, |
| 85 timer_.LapsPerSecond(), | 86 timer_.LapsPerSecond(), |
| 86 "runs/s", | 87 "runs/s", |
| 87 true); | 88 true); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, | 91 void RunComputeTilePriorityRectsScrollingTest( |
| 91 const gfx::Transform& transform) { | 92 const std::string& test_name, |
| 93 const gfx::Transform& transform) { |
| 92 gfx::Size viewport_size(1024, 768); | 94 gfx::Size viewport_size(1024, 768); |
| 93 gfx::Rect viewport_rect(viewport_size); | 95 gfx::Rect viewport_rect(viewport_size); |
| 94 int xoffsets[] = {10, 0, -10, 0}; | 96 int xoffsets[] = {10, 0, -10, 0}; |
| 95 int yoffsets[] = {0, 10, 0, -10}; | 97 int yoffsets[] = {0, 10, 0, -10}; |
| 96 int offsetIndex = 0; | 98 int offsetIndex = 0; |
| 97 int offsetCount = 0; | 99 int offsetCount = 0; |
| 98 const int maxOffsetCount = 1000; | 100 const int maxOffsetCount = 1000; |
| 99 | 101 |
| 100 timer_.Reset(); | 102 timer_.Reset(); |
| 101 do { | 103 do { |
| 102 picture_layer_tiling_->UpdateTilePriorities( | 104 picture_layer_tiling_->ComputeTilePriorityRects( |
| 103 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 105 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); |
| 104 | 106 |
| 105 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], | 107 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], |
| 106 viewport_rect.y() + yoffsets[offsetIndex], | 108 viewport_rect.y() + yoffsets[offsetIndex], |
| 107 viewport_rect.width(), | 109 viewport_rect.width(), |
| 108 viewport_rect.height()); | 110 viewport_rect.height()); |
| 109 | 111 |
| 110 if (++offsetCount > maxOffsetCount) { | 112 if (++offsetCount > maxOffsetCount) { |
| 111 offsetCount = 0; | 113 offsetCount = 0; |
| 112 offsetIndex = (offsetIndex + 1) % 4; | 114 offsetIndex = (offsetIndex + 1) % 4; |
| 113 } | 115 } |
| 114 timer_.NextLap(); | 116 timer_.NextLap(); |
| 115 } while (!timer_.HasTimeLimitExpired()); | 117 } while (!timer_.HasTimeLimitExpired()); |
| 116 | 118 |
| 117 perf_test::PrintResult("update_tile_priorities_scrolling", | 119 perf_test::PrintResult("compute_tile_priority_rects_scrolling", |
| 118 "", | 120 "", |
| 119 test_name, | 121 test_name, |
| 120 timer_.LapsPerSecond(), | 122 timer_.LapsPerSecond(), |
| 121 "runs/s", | 123 "runs/s", |
| 122 true); | 124 true); |
| 123 } | 125 } |
| 124 | 126 |
| 125 void RunRasterIteratorConstructTest(const std::string& test_name, | 127 void RunRasterIteratorConstructTest(const std::string& test_name, |
| 126 const gfx::Rect& viewport) { | 128 const gfx::Rect& viewport) { |
| 127 gfx::Size bounds(viewport.size()); | 129 gfx::Size bounds(viewport.size()); |
| 128 picture_layer_tiling_ = | 130 picture_layer_tiling_ = |
| 129 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 131 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 130 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 132 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 131 picture_layer_tiling_->UpdateTilePriorities( | 133 picture_layer_tiling_->ComputeTilePriorityRects( |
| 132 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 134 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 133 | 135 |
| 134 timer_.Reset(); | 136 timer_.Reset(); |
| 135 do { | 137 do { |
| 136 PictureLayerTiling::TilingRasterTileIterator it( | 138 PictureLayerTiling::TilingRasterTileIterator it( |
| 137 picture_layer_tiling_.get(), ACTIVE_TREE); | 139 picture_layer_tiling_.get()); |
| 138 timer_.NextLap(); | 140 timer_.NextLap(); |
| 139 } while (!timer_.HasTimeLimitExpired()); | 141 } while (!timer_.HasTimeLimitExpired()); |
| 140 | 142 |
| 141 perf_test::PrintResult("tiling_raster_tile_iterator_construct", | 143 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
| 142 "", | 144 "", |
| 143 test_name, | 145 test_name, |
| 144 timer_.LapsPerSecond(), | 146 timer_.LapsPerSecond(), |
| 145 "runs/s", | 147 "runs/s", |
| 146 true); | 148 true); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, | 151 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
| 150 int num_tiles, | 152 int num_tiles, |
| 151 const gfx::Rect& viewport) { | 153 const gfx::Rect& viewport) { |
| 152 gfx::Size bounds(10000, 10000); | 154 gfx::Size bounds(10000, 10000); |
| 153 picture_layer_tiling_ = | 155 picture_layer_tiling_ = |
| 154 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 156 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 155 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 157 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 156 picture_layer_tiling_->UpdateTilePriorities( | 158 picture_layer_tiling_->ComputeTilePriorityRects( |
| 157 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 159 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 158 | 160 |
| 159 timer_.Reset(); | 161 timer_.Reset(); |
| 160 do { | 162 do { |
| 161 int count = num_tiles; | 163 int count = num_tiles; |
| 162 PictureLayerTiling::TilingRasterTileIterator it( | 164 PictureLayerTiling::TilingRasterTileIterator it( |
| 163 picture_layer_tiling_.get(), ACTIVE_TREE); | 165 picture_layer_tiling_.get()); |
| 164 while (count--) { | 166 while (count--) { |
| 165 ASSERT_TRUE(it) << "count: " << count; | 167 ASSERT_TRUE(it) << "count: " << count; |
| 166 ASSERT_TRUE(*it != NULL) << "count: " << count; | 168 ASSERT_TRUE(*it != NULL) << "count: " << count; |
| 167 ++it; | 169 ++it; |
| 168 } | 170 } |
| 169 timer_.NextLap(); | 171 timer_.NextLap(); |
| 170 } while (!timer_.HasTimeLimitExpired()); | 172 } while (!timer_.HasTimeLimitExpired()); |
| 171 | 173 |
| 172 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", | 174 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", |
| 173 "", | 175 "", |
| 174 test_name, | 176 test_name, |
| 175 timer_.LapsPerSecond(), | 177 timer_.LapsPerSecond(), |
| 176 "runs/s", | 178 "runs/s", |
| 177 true); | 179 true); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void RunEvictionIteratorConstructTest(const std::string& test_name, | 182 void RunEvictionIteratorConstructTest(const std::string& test_name, |
| 181 const gfx::Rect& viewport) { | 183 const gfx::Rect& viewport) { |
| 182 gfx::Size bounds(viewport.size()); | 184 gfx::Size bounds(viewport.size()); |
| 183 picture_layer_tiling_ = | 185 picture_layer_tiling_ = |
| 184 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 186 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 185 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 187 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 186 picture_layer_tiling_->UpdateTilePriorities( | 188 picture_layer_tiling_->ComputeTilePriorityRects( |
| 187 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 189 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 188 | 190 |
| 189 timer_.Reset(); | 191 timer_.Reset(); |
| 190 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 192 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 191 SMOOTHNESS_TAKES_PRIORITY, | 193 SMOOTHNESS_TAKES_PRIORITY, |
| 192 NEW_CONTENT_TAKES_PRIORITY}; | 194 NEW_CONTENT_TAKES_PRIORITY}; |
| 193 int priority_count = 0; | 195 int priority_count = 0; |
| 194 do { | 196 do { |
| 195 PictureLayerTiling::TilingEvictionTileIterator it( | 197 PictureLayerTiling::TilingEvictionTileIterator it( |
| 196 picture_layer_tiling_.get(), | 198 picture_layer_tiling_.get(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 true); | 210 true); |
| 209 } | 211 } |
| 210 | 212 |
| 211 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, | 213 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
| 212 int num_tiles, | 214 int num_tiles, |
| 213 const gfx::Rect& viewport) { | 215 const gfx::Rect& viewport) { |
| 214 gfx::Size bounds(10000, 10000); | 216 gfx::Size bounds(10000, 10000); |
| 215 picture_layer_tiling_ = | 217 picture_layer_tiling_ = |
| 216 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 218 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 217 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 219 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 218 picture_layer_tiling_->UpdateTilePriorities( | 220 picture_layer_tiling_->ComputeTilePriorityRects( |
| 219 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 221 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 220 | 222 |
| 221 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 223 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 222 SMOOTHNESS_TAKES_PRIORITY, | 224 SMOOTHNESS_TAKES_PRIORITY, |
| 223 NEW_CONTENT_TAKES_PRIORITY}; | 225 NEW_CONTENT_TAKES_PRIORITY}; |
| 224 | 226 |
| 225 // Ensure all tiles have resources. | 227 // Ensure all tiles have resources. |
| 226 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); | 228 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); |
| 227 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 229 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
| 228 tile_it != all_tiles.end(); | 230 tile_it != all_tiles.end(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 290 |
| 289 Region half_region(gfx::Rect(25 * 256, 50 * 256)); | 291 Region half_region(gfx::Rect(25 * 256, 50 * 256)); |
| 290 RunInvalidateTest("25x50", half_region); | 292 RunInvalidateTest("25x50", half_region); |
| 291 | 293 |
| 292 Region full_region(gfx::Rect(50 * 256, 50 * 256)); | 294 Region full_region(gfx::Rect(50 * 256, 50 * 256)); |
| 293 RunInvalidateTest("50x50", full_region); | 295 RunInvalidateTest("50x50", full_region); |
| 294 } | 296 } |
| 295 | 297 |
| 296 #if defined(OS_ANDROID) | 298 #if defined(OS_ANDROID) |
| 297 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220). | 299 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220). |
| 298 TEST_F(PictureLayerTilingPerfTest, DISABLED_UpdateTilePriorities) { | 300 TEST_F(PictureLayerTilingPerfTest, DISABLED_ComputeTilePriorityRects) { |
| 299 #else | 301 #else |
| 300 TEST_F(PictureLayerTilingPerfTest, UpdateTilePriorities) { | 302 TEST_F(PictureLayerTilingPerfTest, ComputeTilePriorityRects) { |
| 301 #endif // defined(OS_ANDROID) | 303 #endif // defined(OS_ANDROID) |
| 302 gfx::Transform transform; | 304 gfx::Transform transform; |
| 303 | 305 |
| 304 RunUpdateTilePrioritiesStationaryTest("no_transform", transform); | 306 RunComputeTilePriorityRectsStationaryTest("no_transform", transform); |
| 305 RunUpdateTilePrioritiesScrollingTest("no_transform", transform); | 307 RunComputeTilePriorityRectsScrollingTest("no_transform", transform); |
| 306 | 308 |
| 307 transform.Rotate(10); | 309 transform.Rotate(10); |
| 308 RunUpdateTilePrioritiesStationaryTest("rotation", transform); | 310 RunComputeTilePriorityRectsStationaryTest("rotation", transform); |
| 309 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 311 RunComputeTilePriorityRectsScrollingTest("rotation", transform); |
| 310 | 312 |
| 311 transform.ApplyPerspectiveDepth(10); | 313 transform.ApplyPerspectiveDepth(10); |
| 312 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 314 RunComputeTilePriorityRectsStationaryTest("perspective", transform); |
| 313 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 315 RunComputeTilePriorityRectsScrollingTest("perspective", transform); |
| 314 } | 316 } |
| 315 | 317 |
| 316 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIteratorConstruct) { | 318 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIteratorConstruct) { |
| 317 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 319 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
| 318 RunRasterIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100)); | 320 RunRasterIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100)); |
| 319 RunRasterIteratorConstructTest("100_0_100x100", gfx::Rect(100, 0, 100, 100)); | 321 RunRasterIteratorConstructTest("100_0_100x100", gfx::Rect(100, 0, 100, 100)); |
| 320 RunRasterIteratorConstructTest("150_0_100x100", gfx::Rect(150, 0, 100, 100)); | 322 RunRasterIteratorConstructTest("150_0_100x100", gfx::Rect(150, 0, 100, 100)); |
| 321 } | 323 } |
| 322 | 324 |
| 323 TEST_F(PictureLayerTilingPerfTest, | 325 TEST_F(PictureLayerTilingPerfTest, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 349 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 351 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 350 RunEvictionIteratorConstructAndIterateTest( | 352 RunEvictionIteratorConstructAndIterateTest( |
| 351 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 353 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 352 RunEvictionIteratorConstructAndIterateTest( | 354 RunEvictionIteratorConstructAndIterateTest( |
| 353 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 355 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| 354 } | 356 } |
| 355 | 357 |
| 356 } // namespace | 358 } // namespace |
| 357 | 359 |
| 358 } // namespace cc | 360 } // namespace cc |
| OLD | NEW |