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

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

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 12 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
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 "cc/resources/eviction_tile_priority_queue.h" 5 #include "cc/resources/eviction_tile_priority_queue.h"
6 #include "cc/resources/raster_tile_priority_queue.h" 6 #include "cc/resources/raster_tile_priority_queue.h"
7 #include "cc/resources/tile.h" 7 #include "cc/resources/tile.h"
8 #include "cc/resources/tile_priority.h" 8 #include "cc/resources/tile_priority.h"
9 #include "cc/test/begin_frame_args_test.h"
9 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/fake_output_surface.h" 12 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_output_surface_client.h" 13 #include "cc/test/fake_output_surface_client.h"
13 #include "cc/test/fake_picture_layer_impl.h" 14 #include "cc/test/fake_picture_layer_impl.h"
14 #include "cc/test/fake_picture_pile_impl.h" 15 #include "cc/test/fake_picture_pile_impl.h"
15 #include "cc/test/fake_tile_manager.h" 16 #include "cc/test/fake_tile_manager.h"
16 #include "cc/test/impl_side_painting_settings.h" 17 #include "cc/test/impl_side_painting_settings.h"
17 #include "cc/test/test_shared_bitmap_manager.h" 18 #include "cc/test/test_shared_bitmap_manager.h"
18 #include "cc/test/test_tile_priorities.h" 19 #include "cc/test/test_tile_priorities.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 pending_layer = 115 pending_layer =
115 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); 116 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile);
116 pending_layer->SetDrawsContent(true); 117 pending_layer->SetDrawsContent(true);
117 } 118 }
118 // The bounds() just mirror the pile size. 119 // The bounds() just mirror the pile size.
119 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); 120 pending_layer->SetBounds(pending_layer->raster_source()->GetSize());
120 pending_tree->SetRootLayer(pending_layer.Pass()); 121 pending_tree->SetRootLayer(pending_layer.Pass());
121 122
122 pending_layer_ = static_cast<FakePictureLayerImpl*>( 123 pending_layer_ = static_cast<FakePictureLayerImpl*>(
123 host_impl_.pending_tree()->LayerById(id_)); 124 host_impl_.pending_tree()->LayerById(id_));
125
126 // Add tilings/tiles for the layer.
127 host_impl_.pending_tree()->UpdateDrawProperties();
124 } 128 }
125 129
126 TileManager* tile_manager() { return host_impl_.tile_manager(); } 130 TileManager* tile_manager() { return host_impl_.tile_manager(); }
127 131
128 protected: 132 protected:
129 GlobalStateThatImpactsTilePriority global_state_; 133 GlobalStateThatImpactsTilePriority global_state_;
130 134
131 TestSharedBitmapManager shared_bitmap_manager_; 135 TestSharedBitmapManager shared_bitmap_manager_;
132 TileMemoryLimitPolicy memory_limit_policy_; 136 TileMemoryLimitPolicy memory_limit_policy_;
133 int max_tiles_; 137 int max_tiles_;
134 bool ready_to_activate_; 138 bool ready_to_activate_;
135 int id_; 139 int id_;
136 FakeImplProxy proxy_; 140 FakeImplProxy proxy_;
137 FakeLayerTreeHostImpl host_impl_; 141 FakeLayerTreeHostImpl host_impl_;
138 FakePictureLayerImpl* pending_layer_; 142 FakePictureLayerImpl* pending_layer_;
139 FakePictureLayerImpl* active_layer_; 143 FakePictureLayerImpl* active_layer_;
140 }; 144 };
141 145
142 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { 146 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) {
143 const gfx::Size layer_bounds(1000, 1000); 147 const gfx::Size layer_bounds(1000, 1000);
144 host_impl_.SetViewportSize(layer_bounds); 148 host_impl_.SetViewportSize(layer_bounds);
145 SetupDefaultTrees(layer_bounds); 149 SetupDefaultTrees(layer_bounds);
146 150
147 active_layer_->CreateDefaultTilingsAndTiles();
148 pending_layer_->CreateDefaultTilingsAndTiles();
149
150 RasterTilePriorityQueue queue; 151 RasterTilePriorityQueue queue;
151 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 152 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
152 EXPECT_FALSE(queue.IsEmpty()); 153 EXPECT_FALSE(queue.IsEmpty());
153 154
154 size_t tile_count = 0; 155 size_t tile_count = 0;
155 std::set<Tile*> all_tiles; 156 std::set<Tile*> all_tiles;
156 while (!queue.IsEmpty()) { 157 while (!queue.IsEmpty()) {
157 EXPECT_TRUE(queue.Top()); 158 EXPECT_TRUE(queue.Top());
158 all_tiles.insert(queue.Top()); 159 all_tiles.insert(queue.Top());
159 ++tile_count; 160 ++tile_count;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 319 }
319 320
320 EXPECT_EQ(tile_count, new_content_tiles.size()); 321 EXPECT_EQ(tile_count, new_content_tiles.size());
321 EXPECT_EQ(high_res_tiles, new_content_tiles); 322 EXPECT_EQ(high_res_tiles, new_content_tiles);
322 // Since we don't guarantee increasing distance due to spiral iterator, we 323 // Since we don't guarantee increasing distance due to spiral iterator, we
323 // should check that we're _mostly_ right. 324 // should check that we're _mostly_ right.
324 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); 325 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4);
325 } 326 }
326 327
327 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { 328 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) {
328 SetupDefaultTrees(gfx::Size(1000, 1000)); 329 base::TimeTicks time_ticks;
330 time_ticks += base::TimeDelta::FromMilliseconds(1);
331 host_impl_.SetCurrentBeginFrameArgs(
332 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
329 333
330 active_layer_->CreateDefaultTilingsAndTiles(); 334 gfx::Size layer_bounds(1000, 1000);
331 pending_layer_->CreateDefaultTilingsAndTiles(); 335 SetupDefaultTrees(layer_bounds);
332 336
333 // Create a pending child layer. 337 // Create a pending child layer.
334 gfx::Size tile_size(256, 256); 338 gfx::Size tile_size(256, 256);
335 scoped_refptr<FakePicturePileImpl> pending_pile = 339 scoped_refptr<FakePicturePileImpl> pending_pile =
336 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); 340 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
337 scoped_ptr<FakePictureLayerImpl> pending_child = 341 scoped_ptr<FakePictureLayerImpl> pending_child =
338 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 342 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(),
339 id_ + 1, pending_pile); 343 id_ + 1, pending_pile);
344 FakePictureLayerImpl* pending_child_raw = pending_child.get();
345 pending_child_raw->SetDrawsContent(true);
340 pending_layer_->AddChild(pending_child.Pass()); 346 pending_layer_->AddChild(pending_child.Pass());
341 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>(
342 host_impl_.pending_tree()->LayerById(id_ + 1));
343 ASSERT_TRUE(pending_child_raw);
344
345 pending_child_raw->SetDrawsContent(true);
346 pending_child_raw->CreateDefaultTilingsAndTiles();
347 ASSERT_TRUE(pending_child_raw->HighResTiling());
348 347
349 // Set a small viewport, so we have soon and eventually tiles. 348 // Set a small viewport, so we have soon and eventually tiles.
350 gfx::Rect viewport(200, 200); 349 host_impl_.SetViewportSize(gfx::Size(200, 200));
351 active_layer_->draw_properties().visible_content_rect = viewport; 350 time_ticks += base::TimeDelta::FromMilliseconds(1);
352 active_layer_->UpdateTiles(Occlusion(), false); 351 host_impl_.SetCurrentBeginFrameArgs(
353 pending_layer_->draw_properties().visible_content_rect = viewport; 352 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
354 pending_layer_->UpdateTiles(Occlusion(), false); 353 host_impl_.pending_tree()->UpdateDrawProperties();
355 pending_child_raw->draw_properties().visible_content_rect = viewport;
356 pending_child_raw->UpdateTiles(Occlusion(), false);
357 354
358 RasterTilePriorityQueue queue; 355 RasterTilePriorityQueue queue;
359 host_impl_.SetRequiresHighResToDraw(); 356 host_impl_.SetRequiresHighResToDraw();
360 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); 357 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY);
361 EXPECT_FALSE(queue.IsEmpty()); 358 EXPECT_FALSE(queue.IsEmpty());
362 359
363 // Get all the tiles that are NOW or SOON and make sure they are ready to 360 // Get all the tiles that are NOW or SOON and make sure they are ready to
364 // draw. 361 // draw.
365 std::vector<Tile*> all_tiles; 362 std::vector<Tile*> all_tiles;
366 while (!queue.IsEmpty()) { 363 while (!queue.IsEmpty()) {
(...skipping 11 matching lines...) Expand all
378 // Ensure we can activate. 375 // Ensure we can activate.
379 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 376 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
380 EXPECT_TRUE(pending_child_raw->AllTilesRequiredForActivationAreReadyToDraw()); 377 EXPECT_TRUE(pending_child_raw->AllTilesRequiredForActivationAreReadyToDraw());
381 } 378 }
382 379
383 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { 380 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
384 const gfx::Size layer_bounds(1000, 1000); 381 const gfx::Size layer_bounds(1000, 1000);
385 host_impl_.SetViewportSize(layer_bounds); 382 host_impl_.SetViewportSize(layer_bounds);
386 SetupDefaultTrees(layer_bounds); 383 SetupDefaultTrees(layer_bounds);
387 384
388 active_layer_->CreateDefaultTilingsAndTiles();
389 pending_layer_->CreateDefaultTilingsAndTiles();
390
391 EvictionTilePriorityQueue empty_queue; 385 EvictionTilePriorityQueue empty_queue;
392 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES); 386 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES);
393 EXPECT_TRUE(empty_queue.IsEmpty()); 387 EXPECT_TRUE(empty_queue.IsEmpty());
394 std::set<Tile*> all_tiles; 388 std::set<Tile*> all_tiles;
395 size_t tile_count = 0; 389 size_t tile_count = 0;
396 390
397 RasterTilePriorityQueue raster_queue; 391 RasterTilePriorityQueue raster_queue;
398 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); 392 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES);
399 while (!raster_queue.IsEmpty()) { 393 while (!raster_queue.IsEmpty()) {
400 ++tile_count; 394 ++tile_count;
(...skipping 12 matching lines...) Expand all
413 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); 407 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY);
414 EXPECT_FALSE(queue.IsEmpty()); 408 EXPECT_FALSE(queue.IsEmpty());
415 409
416 // Sanity check, all tiles should be visible. 410 // Sanity check, all tiles should be visible.
417 std::set<Tile*> smoothness_tiles; 411 std::set<Tile*> smoothness_tiles;
418 while (!queue.IsEmpty()) { 412 while (!queue.IsEmpty()) {
419 Tile* tile = queue.Top(); 413 Tile* tile = queue.Top();
420 EXPECT_TRUE(tile); 414 EXPECT_TRUE(tile);
421 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); 415 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin);
422 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin); 416 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin);
423 EXPECT_TRUE(tile->HasResources()); 417 EXPECT_TRUE(tile->HasResource());
424 smoothness_tiles.insert(tile); 418 smoothness_tiles.insert(tile);
425 queue.Pop(); 419 queue.Pop();
426 } 420 }
427 EXPECT_EQ(all_tiles, smoothness_tiles); 421 EXPECT_EQ(all_tiles, smoothness_tiles);
428 422
429 tile_manager()->ReleaseTileResourcesForTesting( 423 tile_manager()->ReleaseTileResourcesForTesting(
430 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); 424 std::vector<Tile*>(all_tiles.begin(), all_tiles.end()));
431 425
432 Region invalidation(gfx::Rect(0, 0, 500, 500)); 426 Region invalidation(gfx::Rect(0, 0, 500, 500));
433 427
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 smoothness_tiles.clear(); 473 smoothness_tiles.clear();
480 tile_count = 0; 474 tile_count = 0;
481 // Here we expect to get increasing ACTIVE_TREE priority_bin. 475 // Here we expect to get increasing ACTIVE_TREE priority_bin.
482 queue.Reset(); 476 queue.Reset();
483 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); 477 host_impl_.BuildEvictionQueue(&queue, SMOOTHNESS_TAKES_PRIORITY);
484 int distance_increasing = 0; 478 int distance_increasing = 0;
485 int distance_decreasing = 0; 479 int distance_decreasing = 0;
486 while (!queue.IsEmpty()) { 480 while (!queue.IsEmpty()) {
487 Tile* tile = queue.Top(); 481 Tile* tile = queue.Top();
488 EXPECT_TRUE(tile); 482 EXPECT_TRUE(tile);
489 EXPECT_TRUE(tile->HasResources()); 483 EXPECT_TRUE(tile->HasResource());
490 484
491 if (!last_tile) 485 if (!last_tile)
492 last_tile = tile; 486 last_tile = tile;
493 487
494 EXPECT_GE(last_tile->priority(ACTIVE_TREE).priority_bin, 488 EXPECT_GE(last_tile->priority(ACTIVE_TREE).priority_bin,
495 tile->priority(ACTIVE_TREE).priority_bin); 489 tile->priority(ACTIVE_TREE).priority_bin);
496 if (last_tile->priority(ACTIVE_TREE).priority_bin == 490 if (last_tile->priority(ACTIVE_TREE).priority_bin ==
497 tile->priority(ACTIVE_TREE).priority_bin) { 491 tile->priority(ACTIVE_TREE).priority_bin) {
498 EXPECT_LE(last_tile->required_for_activation(), 492 EXPECT_LE(last_tile->required_for_activation(),
499 tile->required_for_activation()); 493 tile->required_for_activation());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 548 }
555 549
556 EXPECT_EQ(3, distance_increasing); 550 EXPECT_EQ(3, distance_increasing);
557 EXPECT_EQ(16, distance_decreasing); 551 EXPECT_EQ(16, distance_decreasing);
558 EXPECT_EQ(tile_count, new_content_tiles.size()); 552 EXPECT_EQ(tile_count, new_content_tiles.size());
559 EXPECT_EQ(all_tiles, new_content_tiles); 553 EXPECT_EQ(all_tiles, new_content_tiles);
560 } 554 }
561 555
562 TEST_F(TileManagerTilePriorityQueueTest, 556 TEST_F(TileManagerTilePriorityQueueTest,
563 EvictionTilePriorityQueueWithOcclusion) { 557 EvictionTilePriorityQueueWithOcclusion) {
558 base::TimeTicks time_ticks;
559 time_ticks += base::TimeDelta::FromMilliseconds(1);
560 host_impl_.SetCurrentBeginFrameArgs(
561 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
562
564 gfx::Size tile_size(102, 102); 563 gfx::Size tile_size(102, 102);
565 gfx::Size layer_bounds(1000, 1000); 564 gfx::Size layer_bounds(1000, 1000);
566 565
567 host_impl_.SetViewportSize(layer_bounds); 566 host_impl_.SetViewportSize(layer_bounds);
568 567
569 scoped_refptr<FakePicturePileImpl> pending_pile = 568 scoped_refptr<FakePicturePileImpl> pending_pile =
570 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 569 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
571 SetupPendingTree(pending_pile); 570 SetupPendingTree(pending_pile);
572 pending_layer_->CreateDefaultTilingsAndTiles();
573 571
574 scoped_ptr<FakePictureLayerImpl> pending_child = 572 scoped_ptr<FakePictureLayerImpl> pending_child =
575 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, 573 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
576 pending_pile); 574 pending_pile);
577 pending_layer_->AddChild(pending_child.Pass()); 575 pending_layer_->AddChild(pending_child.Pass());
578 576
579 FakePictureLayerImpl* pending_child_layer = 577 FakePictureLayerImpl* pending_child_layer =
580 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); 578 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
581 pending_child_layer->SetDrawsContent(true); 579 pending_child_layer->SetDrawsContent(true);
582 pending_child_layer->CreateDefaultTilingsAndTiles(); 580
581 time_ticks += base::TimeDelta::FromMilliseconds(1);
582 host_impl_.SetCurrentBeginFrameArgs(
583 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
584 host_impl_.pending_tree()->UpdateDrawProperties();
583 585
584 std::set<Tile*> all_tiles; 586 std::set<Tile*> all_tiles;
585 size_t tile_count = 0; 587 size_t tile_count = 0;
586 RasterTilePriorityQueue raster_queue; 588 RasterTilePriorityQueue raster_queue;
587 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); 589 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES);
588 while (!raster_queue.IsEmpty()) { 590 while (!raster_queue.IsEmpty()) {
589 ++tile_count; 591 ++tile_count;
590 EXPECT_TRUE(raster_queue.Top()); 592 EXPECT_TRUE(raster_queue.Top());
591 all_tiles.insert(raster_queue.Top()); 593 all_tiles.insert(raster_queue.Top());
592 raster_queue.Pop(); 594 raster_queue.Pop();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 last_tile = tile; 671 last_tile = tile;
670 queue.Pop(); 672 queue.Pop();
671 } 673 }
672 size_t expected_occluded_count = 674 size_t expected_occluded_count =
673 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); 675 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size();
674 EXPECT_EQ(expected_occluded_count, occluded_count); 676 EXPECT_EQ(expected_occluded_count, occluded_count);
675 } 677 }
676 678
677 TEST_F(TileManagerTilePriorityQueueTest, 679 TEST_F(TileManagerTilePriorityQueueTest,
678 EvictionTilePriorityQueueWithTransparentLayer) { 680 EvictionTilePriorityQueueWithTransparentLayer) {
681 base::TimeTicks time_ticks;
682 time_ticks += base::TimeDelta::FromMilliseconds(1);
683 host_impl_.SetCurrentBeginFrameArgs(
684 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
685
679 gfx::Size tile_size(102, 102); 686 gfx::Size tile_size(102, 102);
680 gfx::Size layer_bounds(1000, 1000); 687 gfx::Size layer_bounds(1000, 1000);
681 688
682 scoped_refptr<FakePicturePileImpl> pending_pile = 689 scoped_refptr<FakePicturePileImpl> pending_pile =
683 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 690 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
684 SetupPendingTree(pending_pile); 691 SetupPendingTree(pending_pile);
685 pending_layer_->CreateDefaultTilingsAndTiles();
686 692
687 scoped_ptr<FakePictureLayerImpl> pending_child = 693 scoped_ptr<FakePictureLayerImpl> pending_child =
688 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, 694 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
689 pending_pile); 695 pending_pile);
696 FakePictureLayerImpl* pending_child_layer = pending_child.get();
690 pending_layer_->AddChild(pending_child.Pass()); 697 pending_layer_->AddChild(pending_child.Pass());
691 698
692 // Create a fully transparent child layer so that its tile priorities are not 699 // Create a fully transparent child layer so that its tile priorities are not
693 // considered to be valid. 700 // considered to be valid.
694 FakePictureLayerImpl* pending_child_layer =
695 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
696 pending_child_layer->SetDrawsContent(true); 701 pending_child_layer->SetDrawsContent(true);
697 pending_child_layer->CreateDefaultTilingsAndTiles(); 702
703 time_ticks += base::TimeDelta::FromMilliseconds(1);
704 host_impl_.SetCurrentBeginFrameArgs(
705 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
706 host_impl_.pending_tree()->UpdateDrawProperties();
707
698 pending_child_layer->SetOpacity(0.0); 708 pending_child_layer->SetOpacity(0.0);
699 pending_child_layer->layer_tree_impl()->UpdateDrawProperties(); 709
710 time_ticks += base::TimeDelta::FromMilliseconds(1);
711 host_impl_.SetCurrentBeginFrameArgs(
712 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks));
713 host_impl_.pending_tree()->UpdateDrawProperties();
700 714
701 // Renew all of the tile priorities. 715 // Renew all of the tile priorities.
702 gfx::Rect viewport(layer_bounds); 716 gfx::Rect viewport(layer_bounds);
703 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, 717 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
704 Occlusion()); 718 Occlusion());
705 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, 719 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
706 Occlusion()); 720 Occlusion());
707 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( 721 pending_child_layer->HighResTiling()->ComputeTilePriorityRects(
708 viewport, 1.0f, 1.0, Occlusion()); 722 viewport, 1.0f, 1.0, Occlusion());
709 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( 723 pending_child_layer->LowResTiling()->ComputeTilePriorityRects(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 } 783 }
770 EXPECT_EQ(tile_count, new_content_tiles.size()); 784 EXPECT_EQ(tile_count, new_content_tiles.size());
771 EXPECT_EQ(all_tiles, new_content_tiles); 785 EXPECT_EQ(all_tiles, new_content_tiles);
772 } 786 }
773 787
774 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { 788 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) {
775 const gfx::Size layer_bounds(1000, 1000); 789 const gfx::Size layer_bounds(1000, 1000);
776 host_impl_.SetViewportSize(layer_bounds); 790 host_impl_.SetViewportSize(layer_bounds);
777 SetupDefaultTrees(layer_bounds); 791 SetupDefaultTrees(layer_bounds);
778 792
779 active_layer_->CreateDefaultTilingsAndTiles();
780 pending_layer_->CreateDefaultTilingsAndTiles();
781
782 RasterTilePriorityQueue queue; 793 RasterTilePriorityQueue queue;
783 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 794 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
784 EXPECT_FALSE(queue.IsEmpty()); 795 EXPECT_FALSE(queue.IsEmpty());
785 796
786 size_t tile_count = 0; 797 size_t tile_count = 0;
787 std::set<Tile*> all_tiles; 798 std::set<Tile*> all_tiles;
788 while (!queue.IsEmpty()) { 799 while (!queue.IsEmpty()) {
789 EXPECT_TRUE(queue.Top()); 800 EXPECT_TRUE(queue.Top());
790 all_tiles.insert(queue.Top()); 801 all_tiles.insert(queue.Top());
791 ++tile_count; 802 ++tile_count;
(...skipping 25 matching lines...) Expand all
817 } 828 }
818 EXPECT_EQ(tile_count, all_tiles.size()); 829 EXPECT_EQ(tile_count, all_tiles.size());
819 EXPECT_EQ(16u, tile_count); 830 EXPECT_EQ(16u, tile_count);
820 } 831 }
821 832
822 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { 833 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) {
823 const gfx::Size layer_bounds(1000, 1000); 834 const gfx::Size layer_bounds(1000, 1000);
824 host_impl_.SetViewportSize(layer_bounds); 835 host_impl_.SetViewportSize(layer_bounds);
825 SetupDefaultTrees(layer_bounds); 836 SetupDefaultTrees(layer_bounds);
826 837
827 active_layer_->CreateDefaultTilingsAndTiles();
828 pending_layer_->CreateDefaultTilingsAndTiles();
829
830 RasterTilePriorityQueue raster_queue; 838 RasterTilePriorityQueue raster_queue;
831 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); 839 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES);
832 EXPECT_FALSE(raster_queue.IsEmpty()); 840 EXPECT_FALSE(raster_queue.IsEmpty());
833 841
834 size_t tile_count = 0; 842 size_t tile_count = 0;
835 std::set<Tile*> all_tiles; 843 std::set<Tile*> all_tiles;
836 while (!raster_queue.IsEmpty()) { 844 while (!raster_queue.IsEmpty()) {
837 EXPECT_TRUE(raster_queue.Top()); 845 EXPECT_TRUE(raster_queue.Top());
838 all_tiles.insert(raster_queue.Top()); 846 all_tiles.insert(raster_queue.Top());
839 ++tile_count; 847 ++tile_count;
(...skipping 24 matching lines...) Expand all
864 all_tiles.insert(queue.Top()); 872 all_tiles.insert(queue.Top());
865 ++tile_count; 873 ++tile_count;
866 queue.Pop(); 874 queue.Pop();
867 } 875 }
868 EXPECT_EQ(tile_count, all_tiles.size()); 876 EXPECT_EQ(tile_count, all_tiles.size());
869 EXPECT_EQ(16u, tile_count); 877 EXPECT_EQ(16u, tile_count);
870 } 878 }
871 879
872 } // namespace 880 } // namespace
873 } // namespace cc 881 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698