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 27 matching lines...) Expand all Loading... |
38 shared_bitmap_manager_.get(), | 38 shared_bitmap_manager_.get(), |
39 0, | 39 0, |
40 false, | 40 false, |
41 1, | 41 1, |
42 false).Pass(); | 42 false).Pass(); |
43 } | 43 } |
44 | 44 |
45 virtual void SetUp() OVERRIDE { | 45 virtual void SetUp() OVERRIDE { |
46 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); | 46 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
47 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); | 47 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); |
| 48 picture_layer_tiling_client_.set_tree(PENDING_TREE); |
48 picture_layer_tiling_ = PictureLayerTiling::Create( | 49 picture_layer_tiling_ = PictureLayerTiling::Create( |
49 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); | 50 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); |
50 picture_layer_tiling_->CreateAllTilesForTesting(); | 51 picture_layer_tiling_->CreateAllTilesForTesting(); |
51 } | 52 } |
52 | 53 |
53 virtual void TearDown() OVERRIDE { | 54 virtual void TearDown() OVERRIDE { |
54 picture_layer_tiling_.reset(NULL); | 55 picture_layer_tiling_.reset(NULL); |
55 } | 56 } |
56 | 57 |
57 void RunInvalidateTest(const std::string& test_name, const Region& region) { | 58 void RunInvalidateTest(const std::string& test_name, const Region& region) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 timer_.LapsPerSecond(), | 129 timer_.LapsPerSecond(), |
129 "runs/s", | 130 "runs/s", |
130 true); | 131 true); |
131 } | 132 } |
132 | 133 |
133 void RunRasterIteratorConstructTest(const std::string& test_name, | 134 void RunRasterIteratorConstructTest(const std::string& test_name, |
134 const gfx::Rect& viewport) { | 135 const gfx::Rect& viewport) { |
135 gfx::Size bounds(viewport.size()); | 136 gfx::Size bounds(viewport.size()); |
136 picture_layer_tiling_ = | 137 picture_layer_tiling_ = |
137 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 138 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 139 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
138 picture_layer_tiling_->UpdateTilePriorities( | 140 picture_layer_tiling_->UpdateTilePriorities( |
139 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 141 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
140 | 142 |
141 timer_.Reset(); | 143 timer_.Reset(); |
142 do { | 144 do { |
143 PictureLayerTiling::TilingRasterTileIterator it( | 145 PictureLayerTiling::TilingRasterTileIterator it( |
144 picture_layer_tiling_.get(), ACTIVE_TREE); | 146 picture_layer_tiling_.get(), ACTIVE_TREE); |
145 timer_.NextLap(); | 147 timer_.NextLap(); |
146 } while (!timer_.HasTimeLimitExpired()); | 148 } while (!timer_.HasTimeLimitExpired()); |
147 | 149 |
148 perf_test::PrintResult("tiling_raster_tile_iterator_construct", | 150 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
149 "", | 151 "", |
150 test_name, | 152 test_name, |
151 timer_.LapsPerSecond(), | 153 timer_.LapsPerSecond(), |
152 "runs/s", | 154 "runs/s", |
153 true); | 155 true); |
154 } | 156 } |
155 | 157 |
156 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, | 158 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
157 int num_tiles, | 159 int num_tiles, |
158 const gfx::Rect& viewport) { | 160 const gfx::Rect& viewport) { |
159 gfx::Size bounds(10000, 10000); | 161 gfx::Size bounds(10000, 10000); |
160 picture_layer_tiling_ = | 162 picture_layer_tiling_ = |
161 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 163 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 164 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
162 picture_layer_tiling_->UpdateTilePriorities( | 165 picture_layer_tiling_->UpdateTilePriorities( |
163 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 166 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
164 | 167 |
165 timer_.Reset(); | 168 timer_.Reset(); |
166 do { | 169 do { |
167 int count = num_tiles; | 170 int count = num_tiles; |
168 PictureLayerTiling::TilingRasterTileIterator it( | 171 PictureLayerTiling::TilingRasterTileIterator it( |
169 picture_layer_tiling_.get(), ACTIVE_TREE); | 172 picture_layer_tiling_.get(), ACTIVE_TREE); |
170 while (count--) { | 173 while (count--) { |
171 ASSERT_TRUE(it) << "count: " << count; | 174 ASSERT_TRUE(it) << "count: " << count; |
172 ASSERT_TRUE(*it != NULL) << "count: " << count; | 175 ASSERT_TRUE(*it != NULL) << "count: " << count; |
173 ++it; | 176 ++it; |
174 } | 177 } |
175 timer_.NextLap(); | 178 timer_.NextLap(); |
176 } while (!timer_.HasTimeLimitExpired()); | 179 } while (!timer_.HasTimeLimitExpired()); |
177 | 180 |
178 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", | 181 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", |
179 "", | 182 "", |
180 test_name, | 183 test_name, |
181 timer_.LapsPerSecond(), | 184 timer_.LapsPerSecond(), |
182 "runs/s", | 185 "runs/s", |
183 true); | 186 true); |
184 } | 187 } |
185 | 188 |
186 void RunEvictionIteratorConstructTest(const std::string& test_name, | 189 void RunEvictionIteratorConstructTest(const std::string& test_name, |
187 const gfx::Rect& viewport) { | 190 const gfx::Rect& viewport) { |
188 gfx::Size bounds(viewport.size()); | 191 gfx::Size bounds(viewport.size()); |
189 picture_layer_tiling_ = | 192 picture_layer_tiling_ = |
190 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 193 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 194 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
191 picture_layer_tiling_->UpdateTilePriorities( | 195 picture_layer_tiling_->UpdateTilePriorities( |
192 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 196 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
193 | 197 |
194 timer_.Reset(); | 198 timer_.Reset(); |
195 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 199 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
196 SMOOTHNESS_TAKES_PRIORITY, | 200 SMOOTHNESS_TAKES_PRIORITY, |
197 NEW_CONTENT_TAKES_PRIORITY}; | 201 NEW_CONTENT_TAKES_PRIORITY}; |
198 int priority_count = 0; | 202 int priority_count = 0; |
199 do { | 203 do { |
200 PictureLayerTiling::TilingEvictionTileIterator it( | 204 PictureLayerTiling::TilingEvictionTileIterator it( |
201 picture_layer_tiling_.get(), priorities[priority_count]); | 205 picture_layer_tiling_.get(), priorities[priority_count]); |
202 priority_count = (priority_count + 1) % arraysize(priorities); | 206 priority_count = (priority_count + 1) % arraysize(priorities); |
203 timer_.NextLap(); | 207 timer_.NextLap(); |
204 } while (!timer_.HasTimeLimitExpired()); | 208 } while (!timer_.HasTimeLimitExpired()); |
205 | 209 |
206 perf_test::PrintResult("tiling_eviction_tile_iterator_construct", | 210 perf_test::PrintResult("tiling_eviction_tile_iterator_construct", |
207 "", | 211 "", |
208 test_name, | 212 test_name, |
209 timer_.LapsPerSecond(), | 213 timer_.LapsPerSecond(), |
210 "runs/s", | 214 "runs/s", |
211 true); | 215 true); |
212 } | 216 } |
213 | 217 |
214 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, | 218 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
215 int num_tiles, | 219 int num_tiles, |
216 const gfx::Rect& viewport) { | 220 const gfx::Rect& viewport) { |
217 gfx::Size bounds(10000, 10000); | 221 gfx::Size bounds(10000, 10000); |
218 picture_layer_tiling_ = | 222 picture_layer_tiling_ = |
219 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 223 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 224 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
220 picture_layer_tiling_->UpdateTilePriorities( | 225 picture_layer_tiling_->UpdateTilePriorities( |
221 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 226 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
222 | 227 |
223 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 228 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
224 SMOOTHNESS_TAKES_PRIORITY, | 229 SMOOTHNESS_TAKES_PRIORITY, |
225 NEW_CONTENT_TAKES_PRIORITY}; | 230 NEW_CONTENT_TAKES_PRIORITY}; |
226 | 231 |
227 // Ensure all tiles have resources. | 232 // Ensure all tiles have resources. |
228 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); | 233 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); |
229 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 234 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 356 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
352 RunEvictionIteratorConstructAndIterateTest( | 357 RunEvictionIteratorConstructAndIterateTest( |
353 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 358 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
354 RunEvictionIteratorConstructAndIterateTest( | 359 RunEvictionIteratorConstructAndIterateTest( |
355 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 360 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
356 } | 361 } |
357 | 362 |
358 } // namespace | 363 } // namespace |
359 | 364 |
360 } // namespace cc | 365 } // namespace cc |
OLD | NEW |