| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RunUpdateTilePrioritiesStationaryTest(const std::string& test_name, |
| 72 const gfx::Transform& transform) { | 72 const gfx::Transform& transform) { |
| 73 gfx::Rect viewport_rect(0, 0, 1024, 768); | 73 gfx::Rect viewport_rect(0, 0, 1024, 768); |
| 74 | 74 |
| 75 timer_.Reset(); | 75 timer_.Reset(); |
| 76 do { | 76 do { |
| 77 picture_layer_tiling_->UpdateTilePriorities( | 77 picture_layer_tiling_->UpdateTilePriorities(PENDING_TREE, |
| 78 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 78 viewport_rect, |
| 79 1.f, |
| 80 timer_.NumLaps() + 1, |
| 81 NULL, |
| 82 NULL, |
| 83 gfx::Transform()); |
| 79 timer_.NextLap(); | 84 timer_.NextLap(); |
| 80 } while (!timer_.HasTimeLimitExpired()); | 85 } while (!timer_.HasTimeLimitExpired()); |
| 81 | 86 |
| 82 perf_test::PrintResult("update_tile_priorities_stationary", | 87 perf_test::PrintResult("update_tile_priorities_stationary", |
| 83 "", | 88 "", |
| 84 test_name, | 89 test_name, |
| 85 timer_.LapsPerSecond(), | 90 timer_.LapsPerSecond(), |
| 86 "runs/s", | 91 "runs/s", |
| 87 true); | 92 true); |
| 88 } | 93 } |
| 89 | 94 |
| 90 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, | 95 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, |
| 91 const gfx::Transform& transform) { | 96 const gfx::Transform& transform) { |
| 92 gfx::Size viewport_size(1024, 768); | 97 gfx::Size viewport_size(1024, 768); |
| 93 gfx::Rect viewport_rect(viewport_size); | 98 gfx::Rect viewport_rect(viewport_size); |
| 94 int xoffsets[] = {10, 0, -10, 0}; | 99 int xoffsets[] = {10, 0, -10, 0}; |
| 95 int yoffsets[] = {0, 10, 0, -10}; | 100 int yoffsets[] = {0, 10, 0, -10}; |
| 96 int offsetIndex = 0; | 101 int offsetIndex = 0; |
| 97 int offsetCount = 0; | 102 int offsetCount = 0; |
| 98 const int maxOffsetCount = 1000; | 103 const int maxOffsetCount = 1000; |
| 99 | 104 |
| 100 timer_.Reset(); | 105 timer_.Reset(); |
| 101 do { | 106 do { |
| 102 picture_layer_tiling_->UpdateTilePriorities( | 107 picture_layer_tiling_->UpdateTilePriorities(PENDING_TREE, |
| 103 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 108 viewport_rect, |
| 109 1.f, |
| 110 timer_.NumLaps() + 1, |
| 111 NULL, |
| 112 NULL, |
| 113 gfx::Transform()); |
| 104 | 114 |
| 105 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], | 115 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], |
| 106 viewport_rect.y() + yoffsets[offsetIndex], | 116 viewport_rect.y() + yoffsets[offsetIndex], |
| 107 viewport_rect.width(), | 117 viewport_rect.width(), |
| 108 viewport_rect.height()); | 118 viewport_rect.height()); |
| 109 | 119 |
| 110 if (++offsetCount > maxOffsetCount) { | 120 if (++offsetCount > maxOffsetCount) { |
| 111 offsetCount = 0; | 121 offsetCount = 0; |
| 112 offsetIndex = (offsetIndex + 1) % 4; | 122 offsetIndex = (offsetIndex + 1) % 4; |
| 113 } | 123 } |
| 114 timer_.NextLap(); | 124 timer_.NextLap(); |
| 115 } while (!timer_.HasTimeLimitExpired()); | 125 } while (!timer_.HasTimeLimitExpired()); |
| 116 | 126 |
| 117 perf_test::PrintResult("update_tile_priorities_scrolling", | 127 perf_test::PrintResult("update_tile_priorities_scrolling", |
| 118 "", | 128 "", |
| 119 test_name, | 129 test_name, |
| 120 timer_.LapsPerSecond(), | 130 timer_.LapsPerSecond(), |
| 121 "runs/s", | 131 "runs/s", |
| 122 true); | 132 true); |
| 123 } | 133 } |
| 124 | 134 |
| 125 void RunRasterIteratorConstructTest(const std::string& test_name, | 135 void RunRasterIteratorConstructTest(const std::string& test_name, |
| 126 const gfx::Rect& viewport) { | 136 const gfx::Rect& viewport) { |
| 127 gfx::Size bounds(viewport.size()); | 137 gfx::Size bounds(viewport.size()); |
| 128 picture_layer_tiling_ = | 138 picture_layer_tiling_ = |
| 129 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 139 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 130 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 140 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 131 picture_layer_tiling_->UpdateTilePriorities( | 141 picture_layer_tiling_->UpdateTilePriorities( |
| 132 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 142 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| 133 | 143 |
| 134 timer_.Reset(); | 144 timer_.Reset(); |
| 135 do { | 145 do { |
| 136 PictureLayerTiling::TilingRasterTileIterator it( | 146 PictureLayerTiling::TilingRasterTileIterator it( |
| 137 picture_layer_tiling_.get(), ACTIVE_TREE); | 147 picture_layer_tiling_.get(), ACTIVE_TREE); |
| 138 timer_.NextLap(); | 148 timer_.NextLap(); |
| 139 } while (!timer_.HasTimeLimitExpired()); | 149 } while (!timer_.HasTimeLimitExpired()); |
| 140 | 150 |
| 141 perf_test::PrintResult("tiling_raster_tile_iterator_construct", | 151 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
| 142 "", | 152 "", |
| 143 test_name, | 153 test_name, |
| 144 timer_.LapsPerSecond(), | 154 timer_.LapsPerSecond(), |
| 145 "runs/s", | 155 "runs/s", |
| 146 true); | 156 true); |
| 147 } | 157 } |
| 148 | 158 |
| 149 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, | 159 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
| 150 int num_tiles, | 160 int num_tiles, |
| 151 const gfx::Rect& viewport) { | 161 const gfx::Rect& viewport) { |
| 152 gfx::Size bounds(10000, 10000); | 162 gfx::Size bounds(10000, 10000); |
| 153 picture_layer_tiling_ = | 163 picture_layer_tiling_ = |
| 154 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 164 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 155 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 165 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 156 picture_layer_tiling_->UpdateTilePriorities( | 166 picture_layer_tiling_->UpdateTilePriorities( |
| 157 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 167 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| 158 | 168 |
| 159 timer_.Reset(); | 169 timer_.Reset(); |
| 160 do { | 170 do { |
| 161 int count = num_tiles; | 171 int count = num_tiles; |
| 162 PictureLayerTiling::TilingRasterTileIterator it( | 172 PictureLayerTiling::TilingRasterTileIterator it( |
| 163 picture_layer_tiling_.get(), ACTIVE_TREE); | 173 picture_layer_tiling_.get(), ACTIVE_TREE); |
| 164 while (count--) { | 174 while (count--) { |
| 165 ASSERT_TRUE(it) << "count: " << count; | 175 ASSERT_TRUE(it) << "count: " << count; |
| 166 ASSERT_TRUE(*it != NULL) << "count: " << count; | 176 ASSERT_TRUE(*it != NULL) << "count: " << count; |
| 167 ++it; | 177 ++it; |
| 168 } | 178 } |
| 169 timer_.NextLap(); | 179 timer_.NextLap(); |
| 170 } while (!timer_.HasTimeLimitExpired()); | 180 } while (!timer_.HasTimeLimitExpired()); |
| 171 | 181 |
| 172 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", | 182 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", |
| 173 "", | 183 "", |
| 174 test_name, | 184 test_name, |
| 175 timer_.LapsPerSecond(), | 185 timer_.LapsPerSecond(), |
| 176 "runs/s", | 186 "runs/s", |
| 177 true); | 187 true); |
| 178 } | 188 } |
| 179 | 189 |
| 180 void RunEvictionIteratorConstructTest(const std::string& test_name, | 190 void RunEvictionIteratorConstructTest(const std::string& test_name, |
| 181 const gfx::Rect& viewport) { | 191 const gfx::Rect& viewport) { |
| 182 gfx::Size bounds(viewport.size()); | 192 gfx::Size bounds(viewport.size()); |
| 183 picture_layer_tiling_ = | 193 picture_layer_tiling_ = |
| 184 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 194 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 185 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 195 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 186 picture_layer_tiling_->UpdateTilePriorities( | 196 picture_layer_tiling_->UpdateTilePriorities( |
| 187 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 197 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| 188 | 198 |
| 189 timer_.Reset(); | 199 timer_.Reset(); |
| 190 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 200 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 191 SMOOTHNESS_TAKES_PRIORITY, | 201 SMOOTHNESS_TAKES_PRIORITY, |
| 192 NEW_CONTENT_TAKES_PRIORITY}; | 202 NEW_CONTENT_TAKES_PRIORITY}; |
| 193 int priority_count = 0; | 203 int priority_count = 0; |
| 194 do { | 204 do { |
| 195 PictureLayerTiling::TilingEvictionTileIterator it( | 205 PictureLayerTiling::TilingEvictionTileIterator it( |
| 196 picture_layer_tiling_.get(), | 206 picture_layer_tiling_.get(), |
| 197 priorities[priority_count], | 207 priorities[priority_count], |
| (...skipping 11 matching lines...) Expand all Loading... |
| 209 } | 219 } |
| 210 | 220 |
| 211 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, | 221 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
| 212 int num_tiles, | 222 int num_tiles, |
| 213 const gfx::Rect& viewport) { | 223 const gfx::Rect& viewport) { |
| 214 gfx::Size bounds(10000, 10000); | 224 gfx::Size bounds(10000, 10000); |
| 215 picture_layer_tiling_ = | 225 picture_layer_tiling_ = |
| 216 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 226 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 217 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 227 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 218 picture_layer_tiling_->UpdateTilePriorities( | 228 picture_layer_tiling_->UpdateTilePriorities( |
| 219 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 229 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| 220 | 230 |
| 221 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 231 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 222 SMOOTHNESS_TAKES_PRIORITY, | 232 SMOOTHNESS_TAKES_PRIORITY, |
| 223 NEW_CONTENT_TAKES_PRIORITY}; | 233 NEW_CONTENT_TAKES_PRIORITY}; |
| 224 | 234 |
| 225 // Ensure all tiles have resources. | 235 // Ensure all tiles have resources. |
| 226 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); | 236 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); |
| 227 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 237 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
| 228 tile_it != all_tiles.end(); | 238 tile_it != all_tiles.end(); |
| 229 ++tile_it) { | 239 ++tile_it) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 361 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 352 RunEvictionIteratorConstructAndIterateTest( | 362 RunEvictionIteratorConstructAndIterateTest( |
| 353 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 363 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 354 RunEvictionIteratorConstructAndIterateTest( | 364 RunEvictionIteratorConstructAndIterateTest( |
| 355 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 365 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| 356 } | 366 } |
| 357 | 367 |
| 358 } // namespace | 368 } // namespace |
| 359 | 369 |
| 360 } // namespace cc | 370 } // namespace cc |
| OLD | NEW |