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

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

Issue 366113002: cc: Do not cleanup tiles with raster tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits updated. Created 6 years, 4 months 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/prioritized_tile_set.cc ('k') | cc/resources/tile.h » ('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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "cc/resources/managed_tile_state.h" 8 #include "cc/resources/managed_tile_state.h"
9 #include "cc/resources/prioritized_tile_set.h" 9 #include "cc/resources/prioritized_tile_set.h"
10 #include "cc/resources/tile.h" 10 #include "cc/resources/tile.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 scoped_refptr<Tile> CreateTile() { 70 scoped_refptr<Tile> CreateTile() {
71 return tile_manager_->CreateTile(picture_pile_.get(), 71 return tile_manager_->CreateTile(picture_pile_.get(),
72 settings_.default_tile_size, 72 settings_.default_tile_size,
73 gfx::Rect(), 73 gfx::Rect(),
74 gfx::Rect(), 74 gfx::Rect(),
75 1.0, 75 1.0,
76 0, 76 0,
77 0, 77 0,
78 0); 78 0);
79 } 79 }
80 void ReleaseTiles(std::vector<scoped_refptr<Tile> >* tiles) {
81 for (std::vector<scoped_refptr<Tile> >::iterator it = tiles->begin();
82 it != tiles->end();
83 it++) {
84 Tile* tile = *it;
85 tile->SetPriority(ACTIVE_TREE, TilePriority());
86 tile->SetPriority(PENDING_TREE, TilePriority());
87 }
88 }
80 89
81 private: 90 private:
82 LayerTreeSettings settings_; 91 LayerTreeSettings settings_;
83 FakeOutputSurfaceClient output_surface_client_; 92 FakeOutputSurfaceClient output_surface_client_;
84 scoped_ptr<FakeOutputSurface> output_surface_; 93 scoped_ptr<FakeOutputSurface> output_surface_;
85 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 94 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
86 scoped_ptr<ResourceProvider> resource_provider_; 95 scoped_ptr<ResourceProvider> resource_provider_;
87 scoped_ptr<ResourcePool> resource_pool_; 96 scoped_ptr<ResourcePool> resource_pool_;
88 FakeTileManagerClient tile_manager_client_; 97 FakeTileManagerClient tile_manager_client_;
89 scoped_ptr<FakeTileManager> tile_manager_; 98 scoped_ptr<FakeTileManager> tile_manager_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 144
136 // Tiles should appear in the same order as inserted. 145 // Tiles should appear in the same order as inserted.
137 int i = 0; 146 int i = 0;
138 for (PrioritizedTileSet::Iterator it(&set, true); 147 for (PrioritizedTileSet::Iterator it(&set, true);
139 it; 148 it;
140 ++it) { 149 ++it) {
141 EXPECT_TRUE(*it == tiles[i].get()); 150 EXPECT_TRUE(*it == tiles[i].get());
142 ++i; 151 ++i;
143 } 152 }
144 EXPECT_EQ(20, i); 153 EXPECT_EQ(20, i);
154
155 ReleaseTiles(&tiles);
145 } 156 }
146 157
147 TEST_F(PrioritizedTileSetTest, NowBin) { 158 TEST_F(PrioritizedTileSetTest, NowBin) {
148 // Ensure that tiles in NOW_BIN are sorted according to BinComparator. 159 // Ensure that tiles in NOW_BIN are sorted according to BinComparator.
149 160
150 PrioritizedTileSet set; 161 PrioritizedTileSet set;
151 TilePriority priorities[4] = { 162 TilePriority priorities[4] = {
152 TilePriorityForEventualBin(), 163 TilePriorityForEventualBin(),
153 TilePriorityForNowBin(), 164 TilePriorityForNowBin(),
154 TilePriority(), 165 TilePriority(),
(...skipping 14 matching lines...) Expand all
169 std::sort(tiles.begin(), tiles.end(), BinComparator()); 180 std::sort(tiles.begin(), tiles.end(), BinComparator());
170 181
171 int i = 0; 182 int i = 0;
172 for (PrioritizedTileSet::Iterator it(&set, true); 183 for (PrioritizedTileSet::Iterator it(&set, true);
173 it; 184 it;
174 ++it) { 185 ++it) {
175 EXPECT_TRUE(*it == tiles[i].get()); 186 EXPECT_TRUE(*it == tiles[i].get());
176 ++i; 187 ++i;
177 } 188 }
178 EXPECT_EQ(20, i); 189 EXPECT_EQ(20, i);
190
191 ReleaseTiles(&tiles);
179 } 192 }
180 193
181 TEST_F(PrioritizedTileSetTest, SoonBin) { 194 TEST_F(PrioritizedTileSetTest, SoonBin) {
182 // Ensure that tiles in SOON_BIN are sorted according to BinComparator. 195 // Ensure that tiles in SOON_BIN are sorted according to BinComparator.
183 196
184 PrioritizedTileSet set; 197 PrioritizedTileSet set;
185 TilePriority priorities[4] = { 198 TilePriority priorities[4] = {
186 TilePriorityForEventualBin(), 199 TilePriorityForEventualBin(),
187 TilePriorityForNowBin(), 200 TilePriorityForNowBin(),
188 TilePriority(), 201 TilePriority(),
(...skipping 14 matching lines...) Expand all
203 std::sort(tiles.begin(), tiles.end(), BinComparator()); 216 std::sort(tiles.begin(), tiles.end(), BinComparator());
204 217
205 int i = 0; 218 int i = 0;
206 for (PrioritizedTileSet::Iterator it(&set, true); 219 for (PrioritizedTileSet::Iterator it(&set, true);
207 it; 220 it;
208 ++it) { 221 ++it) {
209 EXPECT_TRUE(*it == tiles[i].get()); 222 EXPECT_TRUE(*it == tiles[i].get());
210 ++i; 223 ++i;
211 } 224 }
212 EXPECT_EQ(20, i); 225 EXPECT_EQ(20, i);
226
227 ReleaseTiles(&tiles);
213 } 228 }
214 229
215 TEST_F(PrioritizedTileSetTest, SoonBinNoPriority) { 230 TEST_F(PrioritizedTileSetTest, SoonBinNoPriority) {
216 // Ensure that when not using priority iterator, SOON_BIN tiles 231 // Ensure that when not using priority iterator, SOON_BIN tiles
217 // are not sorted. 232 // are not sorted.
218 233
219 PrioritizedTileSet set; 234 PrioritizedTileSet set;
220 TilePriority priorities[4] = { 235 TilePriority priorities[4] = {
221 TilePriorityForEventualBin(), 236 TilePriorityForEventualBin(),
222 TilePriorityForNowBin(), 237 TilePriorityForNowBin(),
(...skipping 12 matching lines...) Expand all
235 } 250 }
236 251
237 int i = 0; 252 int i = 0;
238 for (PrioritizedTileSet::Iterator it(&set, false); 253 for (PrioritizedTileSet::Iterator it(&set, false);
239 it; 254 it;
240 ++it) { 255 ++it) {
241 EXPECT_TRUE(*it == tiles[i].get()); 256 EXPECT_TRUE(*it == tiles[i].get());
242 ++i; 257 ++i;
243 } 258 }
244 EXPECT_EQ(20, i); 259 EXPECT_EQ(20, i);
260
261 ReleaseTiles(&tiles);
245 } 262 }
246 263
247 TEST_F(PrioritizedTileSetTest, EventuallyAndActiveBin) { 264 TEST_F(PrioritizedTileSetTest, EventuallyAndActiveBin) {
248 // Ensure that EVENTUALLY_AND_ACTIVE_BIN tiles are sorted. 265 // Ensure that EVENTUALLY_AND_ACTIVE_BIN tiles are sorted.
249 266
250 PrioritizedTileSet set; 267 PrioritizedTileSet set;
251 TilePriority priorities[4] = { 268 TilePriority priorities[4] = {
252 TilePriorityForEventualBin(), 269 TilePriorityForEventualBin(),
253 TilePriorityForNowBin(), 270 TilePriorityForNowBin(),
254 TilePriority(), 271 TilePriority(),
(...skipping 14 matching lines...) Expand all
269 std::sort(tiles.begin(), tiles.end(), BinComparator()); 286 std::sort(tiles.begin(), tiles.end(), BinComparator());
270 287
271 int i = 0; 288 int i = 0;
272 for (PrioritizedTileSet::Iterator it(&set, true); 289 for (PrioritizedTileSet::Iterator it(&set, true);
273 it; 290 it;
274 ++it) { 291 ++it) {
275 EXPECT_TRUE(*it == tiles[i].get()); 292 EXPECT_TRUE(*it == tiles[i].get());
276 ++i; 293 ++i;
277 } 294 }
278 EXPECT_EQ(20, i); 295 EXPECT_EQ(20, i);
296
297 ReleaseTiles(&tiles);
279 } 298 }
280 299
281 TEST_F(PrioritizedTileSetTest, EventuallyBin) { 300 TEST_F(PrioritizedTileSetTest, EventuallyBin) {
282 // Ensure that EVENTUALLY_BIN tiles are sorted. 301 // Ensure that EVENTUALLY_BIN tiles are sorted.
283 302
284 PrioritizedTileSet set; 303 PrioritizedTileSet set;
285 TilePriority priorities[4] = { 304 TilePriority priorities[4] = {
286 TilePriorityForEventualBin(), 305 TilePriorityForEventualBin(),
287 TilePriorityForNowBin(), 306 TilePriorityForNowBin(),
288 TilePriority(), 307 TilePriority(),
(...skipping 14 matching lines...) Expand all
303 std::sort(tiles.begin(), tiles.end(), BinComparator()); 322 std::sort(tiles.begin(), tiles.end(), BinComparator());
304 323
305 int i = 0; 324 int i = 0;
306 for (PrioritizedTileSet::Iterator it(&set, true); 325 for (PrioritizedTileSet::Iterator it(&set, true);
307 it; 326 it;
308 ++it) { 327 ++it) {
309 EXPECT_TRUE(*it == tiles[i].get()); 328 EXPECT_TRUE(*it == tiles[i].get());
310 ++i; 329 ++i;
311 } 330 }
312 EXPECT_EQ(20, i); 331 EXPECT_EQ(20, i);
332
333 ReleaseTiles(&tiles);
313 } 334 }
314 335
315 TEST_F(PrioritizedTileSetTest, AtLastAndActiveBin) { 336 TEST_F(PrioritizedTileSetTest, AtLastAndActiveBin) {
316 // Ensure that AT_LAST_AND_ACTIVE_BIN tiles are sorted. 337 // Ensure that AT_LAST_AND_ACTIVE_BIN tiles are sorted.
317 338
318 PrioritizedTileSet set; 339 PrioritizedTileSet set;
319 TilePriority priorities[4] = { 340 TilePriority priorities[4] = {
320 TilePriorityForEventualBin(), 341 TilePriorityForEventualBin(),
321 TilePriorityForNowBin(), 342 TilePriorityForNowBin(),
322 TilePriority(), 343 TilePriority(),
(...skipping 14 matching lines...) Expand all
337 std::sort(tiles.begin(), tiles.end(), BinComparator()); 358 std::sort(tiles.begin(), tiles.end(), BinComparator());
338 359
339 int i = 0; 360 int i = 0;
340 for (PrioritizedTileSet::Iterator it(&set, true); 361 for (PrioritizedTileSet::Iterator it(&set, true);
341 it; 362 it;
342 ++it) { 363 ++it) {
343 EXPECT_TRUE(*it == tiles[i].get()); 364 EXPECT_TRUE(*it == tiles[i].get());
344 ++i; 365 ++i;
345 } 366 }
346 EXPECT_EQ(20, i); 367 EXPECT_EQ(20, i);
368
369 ReleaseTiles(&tiles);
347 } 370 }
348 371
349 TEST_F(PrioritizedTileSetTest, AtLastBin) { 372 TEST_F(PrioritizedTileSetTest, AtLastBin) {
350 // Ensure that AT_LAST_BIN tiles are sorted. 373 // Ensure that AT_LAST_BIN tiles are sorted.
351 374
352 PrioritizedTileSet set; 375 PrioritizedTileSet set;
353 TilePriority priorities[4] = { 376 TilePriority priorities[4] = {
354 TilePriorityForEventualBin(), 377 TilePriorityForEventualBin(),
355 TilePriorityForNowBin(), 378 TilePriorityForNowBin(),
356 TilePriority(), 379 TilePriority(),
(...skipping 14 matching lines...) Expand all
371 std::sort(tiles.begin(), tiles.end(), BinComparator()); 394 std::sort(tiles.begin(), tiles.end(), BinComparator());
372 395
373 int i = 0; 396 int i = 0;
374 for (PrioritizedTileSet::Iterator it(&set, true); 397 for (PrioritizedTileSet::Iterator it(&set, true);
375 it; 398 it;
376 ++it) { 399 ++it) {
377 EXPECT_TRUE(*it == tiles[i].get()); 400 EXPECT_TRUE(*it == tiles[i].get());
378 ++i; 401 ++i;
379 } 402 }
380 EXPECT_EQ(20, i); 403 EXPECT_EQ(20, i);
404
405 ReleaseTiles(&tiles);
381 } 406 }
382 407
383 TEST_F(PrioritizedTileSetTest, TilesForEachBin) { 408 TEST_F(PrioritizedTileSetTest, TilesForEachBin) {
384 // Aggregate test with one tile for each of the bins, which 409 // Aggregate test with one tile for each of the bins, which
385 // should appear in order of the bins. 410 // should appear in order of the bins.
386 411
387 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); 412 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile();
388 scoped_refptr<Tile> now_bin = CreateTile(); 413 scoped_refptr<Tile> now_bin = CreateTile();
389 scoped_refptr<Tile> soon_bin = CreateTile(); 414 scoped_refptr<Tile> soon_bin = CreateTile();
390 scoped_refptr<Tile> eventually_and_active_bin = CreateTile(); 415 scoped_refptr<Tile> eventually_and_active_bin = CreateTile();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 546
522 // At last bins are sorted. 547 // At last bins are sorted.
523 std::sort(at_last_bins.begin(), at_last_bins.end(), BinComparator()); 548 std::sort(at_last_bins.begin(), at_last_bins.end(), BinComparator());
524 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); 549 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end();
525 ++vector_it) { 550 ++vector_it) {
526 EXPECT_TRUE(*vector_it == *it); 551 EXPECT_TRUE(*vector_it == *it);
527 ++it; 552 ++it;
528 } 553 }
529 554
530 EXPECT_FALSE(it); 555 EXPECT_FALSE(it);
556
557 ReleaseTiles(&now_and_ready_to_draw_bins);
558 ReleaseTiles(&now_bins);
559 ReleaseTiles(&soon_bins);
560 ReleaseTiles(&eventually_and_active_bins);
561 ReleaseTiles(&eventually_bins);
562 ReleaseTiles(&at_last_bins);
563 ReleaseTiles(&at_last_and_active_bins);
531 } 564 }
532 565
533 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { 566 TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) {
534 // Aggregate test with many tiles for each of the bins. Tiles should 567 // Aggregate test with many tiles for each of the bins. Tiles should
535 // appear in order, until DisablePriorityOrdering is called. After that 568 // appear in order, until DisablePriorityOrdering is called. After that
536 // tiles should appear in the order they were inserted. 569 // tiles should appear in the order they were inserted.
537 570
538 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins; 571 std::vector<scoped_refptr<Tile> > now_and_ready_to_draw_bins;
539 std::vector<scoped_refptr<Tile> > now_bins; 572 std::vector<scoped_refptr<Tile> > now_bins;
540 std::vector<scoped_refptr<Tile> > soon_bins; 573 std::vector<scoped_refptr<Tile> > soon_bins;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 663 }
631 664
632 // At last bins are not sorted. 665 // At last bins are not sorted.
633 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); 666 for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end();
634 ++vector_it) { 667 ++vector_it) {
635 EXPECT_TRUE(*vector_it == *it); 668 EXPECT_TRUE(*vector_it == *it);
636 ++it; 669 ++it;
637 } 670 }
638 671
639 EXPECT_FALSE(it); 672 EXPECT_FALSE(it);
673
674 ReleaseTiles(&now_and_ready_to_draw_bins);
675 ReleaseTiles(&now_bins);
676 ReleaseTiles(&soon_bins);
677 ReleaseTiles(&eventually_and_active_bins);
678 ReleaseTiles(&eventually_bins);
679 ReleaseTiles(&at_last_bins);
680 ReleaseTiles(&at_last_and_active_bins);
640 } 681 }
641 682
642 TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) { 683 TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) {
643 // Make sure that if we have empty lists between two non-empty lists, 684 // Make sure that if we have empty lists between two non-empty lists,
644 // we just get two tiles from the iterator. 685 // we just get two tiles from the iterator.
645 686
646 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile(); 687 scoped_refptr<Tile> now_and_ready_to_draw_bin = CreateTile();
647 scoped_refptr<Tile> at_last_bin = CreateTile(); 688 scoped_refptr<Tile> at_last_bin = CreateTile();
648 689
649 PrioritizedTileSet set; 690 PrioritizedTileSet set;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 764
724 set.Clear(); 765 set.Clear();
725 766
726 PrioritizedTileSet::Iterator empty_it(&set, true); 767 PrioritizedTileSet::Iterator empty_it(&set, true);
727 EXPECT_FALSE(empty_it); 768 EXPECT_FALSE(empty_it);
728 } 769 }
729 770
730 } // namespace 771 } // namespace
731 } // namespace cc 772 } // namespace cc
732 773
OLDNEW
« no previous file with comments | « cc/resources/prioritized_tile_set.cc ('k') | cc/resources/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698