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

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

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/tile_manager_perftest.cc ('k') | cc/resources/tiling_set_eviction_queue.cc » ('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 "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/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 pending_layer = 114 pending_layer =
115 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); 115 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile);
116 pending_layer->SetDrawsContent(true); 116 pending_layer->SetDrawsContent(true);
117 } 117 }
118 // The bounds() just mirror the pile size. 118 // The bounds() just mirror the pile size.
119 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); 119 pending_layer->SetBounds(pending_layer->raster_source()->GetSize());
120 pending_tree->SetRootLayer(pending_layer.Pass()); 120 pending_tree->SetRootLayer(pending_layer.Pass());
121 121
122 pending_layer_ = static_cast<FakePictureLayerImpl*>( 122 pending_layer_ = static_cast<FakePictureLayerImpl*>(
123 host_impl_.pending_tree()->LayerById(id_)); 123 host_impl_.pending_tree()->LayerById(id_));
124 pending_layer_->DoPostCommitInitializationIfNeeded();
125 } 124 }
126 125
127 TileManager* tile_manager() { return host_impl_.tile_manager(); } 126 TileManager* tile_manager() { return host_impl_.tile_manager(); }
128 127
129 protected: 128 protected:
130 GlobalStateThatImpactsTilePriority global_state_; 129 GlobalStateThatImpactsTilePriority global_state_;
131 130
132 TestSharedBitmapManager shared_bitmap_manager_; 131 TestSharedBitmapManager shared_bitmap_manager_;
133 TileMemoryLimitPolicy memory_limit_policy_; 132 TileMemoryLimitPolicy memory_limit_policy_;
134 int max_tiles_; 133 int max_tiles_;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); 336 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000));
338 scoped_ptr<FakePictureLayerImpl> pending_child = 337 scoped_ptr<FakePictureLayerImpl> pending_child =
339 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 338 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(),
340 id_ + 1, pending_pile); 339 id_ + 1, pending_pile);
341 pending_layer_->AddChild(pending_child.Pass()); 340 pending_layer_->AddChild(pending_child.Pass());
342 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>( 341 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>(
343 host_impl_.pending_tree()->LayerById(id_ + 1)); 342 host_impl_.pending_tree()->LayerById(id_ + 1));
344 ASSERT_TRUE(pending_child_raw); 343 ASSERT_TRUE(pending_child_raw);
345 344
346 pending_child_raw->SetDrawsContent(true); 345 pending_child_raw->SetDrawsContent(true);
347 pending_child_raw->DoPostCommitInitializationIfNeeded();
348 pending_child_raw->CreateDefaultTilingsAndTiles(); 346 pending_child_raw->CreateDefaultTilingsAndTiles();
349 ASSERT_TRUE(pending_child_raw->HighResTiling()); 347 ASSERT_TRUE(pending_child_raw->HighResTiling());
350 348
351 // Set a small viewport, so we have soon and eventually tiles. 349 // Set a small viewport, so we have soon and eventually tiles.
352 gfx::Rect viewport(200, 200); 350 gfx::Rect viewport(200, 200);
353 active_layer_->draw_properties().visible_content_rect = viewport; 351 active_layer_->draw_properties().visible_content_rect = viewport;
354 active_layer_->UpdateTiles(Occlusion(), false); 352 active_layer_->UpdateTiles(Occlusion(), false);
355 pending_layer_->draw_properties().visible_content_rect = viewport; 353 pending_layer_->draw_properties().visible_content_rect = viewport;
356 pending_layer_->UpdateTiles(Occlusion(), false); 354 pending_layer_->UpdateTiles(Occlusion(), false);
357 pending_child_raw->draw_properties().visible_content_rect = viewport; 355 pending_child_raw->draw_properties().visible_content_rect = viewport;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 pending_layer_->CreateDefaultTilingsAndTiles(); 572 pending_layer_->CreateDefaultTilingsAndTiles();
575 573
576 scoped_ptr<FakePictureLayerImpl> pending_child = 574 scoped_ptr<FakePictureLayerImpl> pending_child =
577 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, 575 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
578 pending_pile); 576 pending_pile);
579 pending_layer_->AddChild(pending_child.Pass()); 577 pending_layer_->AddChild(pending_child.Pass());
580 578
581 FakePictureLayerImpl* pending_child_layer = 579 FakePictureLayerImpl* pending_child_layer =
582 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); 580 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
583 pending_child_layer->SetDrawsContent(true); 581 pending_child_layer->SetDrawsContent(true);
584 pending_child_layer->DoPostCommitInitializationIfNeeded();
585 pending_child_layer->CreateDefaultTilingsAndTiles(); 582 pending_child_layer->CreateDefaultTilingsAndTiles();
586 583
587 std::set<Tile*> all_tiles; 584 std::set<Tile*> all_tiles;
588 size_t tile_count = 0; 585 size_t tile_count = 0;
589 RasterTilePriorityQueue raster_queue; 586 RasterTilePriorityQueue raster_queue;
590 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); 587 host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES);
591 while (!raster_queue.IsEmpty()) { 588 while (!raster_queue.IsEmpty()) {
592 ++tile_count; 589 ++tile_count;
593 EXPECT_TRUE(raster_queue.Top()); 590 EXPECT_TRUE(raster_queue.Top());
594 all_tiles.insert(raster_queue.Top()); 591 all_tiles.insert(raster_queue.Top());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 pending_layer_->AddChild(pending_child.Pass()); 690 pending_layer_->AddChild(pending_child.Pass());
694 691
695 // Create a fully transparent child layer so that its tile priorities are not 692 // Create a fully transparent child layer so that its tile priorities are not
696 // considered to be valid. 693 // considered to be valid.
697 FakePictureLayerImpl* pending_child_layer = 694 FakePictureLayerImpl* pending_child_layer =
698 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); 695 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
699 pending_child_layer->SetDrawsContent(true); 696 pending_child_layer->SetDrawsContent(true);
700 pending_child_layer->CreateDefaultTilingsAndTiles(); 697 pending_child_layer->CreateDefaultTilingsAndTiles();
701 pending_child_layer->SetOpacity(0.0); 698 pending_child_layer->SetOpacity(0.0);
702 pending_child_layer->layer_tree_impl()->UpdateDrawProperties(); 699 pending_child_layer->layer_tree_impl()->UpdateDrawProperties();
703 pending_child_layer->DoPostCommitInitializationIfNeeded();
704 700
705 // Renew all of the tile priorities. 701 // Renew all of the tile priorities.
706 gfx::Rect viewport(layer_bounds); 702 gfx::Rect viewport(layer_bounds);
707 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, 703 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
708 Occlusion()); 704 Occlusion());
709 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, 705 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
710 Occlusion()); 706 Occlusion());
711 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( 707 pending_child_layer->HighResTiling()->ComputeTilePriorityRects(
712 viewport, 1.0f, 1.0, Occlusion()); 708 viewport, 1.0f, 1.0, Occlusion());
713 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( 709 pending_child_layer->LowResTiling()->ComputeTilePriorityRects(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 793 }
798 794
799 EXPECT_EQ(tile_count, all_tiles.size()); 795 EXPECT_EQ(tile_count, all_tiles.size());
800 EXPECT_EQ(16u, tile_count); 796 EXPECT_EQ(16u, tile_count);
801 797
802 queue.Reset(); 798 queue.Reset();
803 for (int i = 1; i < 10; ++i) { 799 for (int i = 1; i < 10; ++i) {
804 scoped_ptr<FakePictureLayerImpl> pending_layer = 800 scoped_ptr<FakePictureLayerImpl> pending_layer =
805 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); 801 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i);
806 pending_layer->SetDrawsContent(true); 802 pending_layer->SetDrawsContent(true);
807 pending_layer->DoPostCommitInitializationIfNeeded();
808 pending_layer->set_has_valid_tile_priorities(true); 803 pending_layer->set_has_valid_tile_priorities(true);
809 pending_layer_->AddChild(pending_layer.Pass()); 804 pending_layer_->AddChild(pending_layer.Pass());
810 } 805 }
811 806
812 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 807 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
813 EXPECT_FALSE(queue.IsEmpty()); 808 EXPECT_FALSE(queue.IsEmpty());
814 809
815 tile_count = 0; 810 tile_count = 0;
816 all_tiles.clear(); 811 all_tiles.clear();
817 while (!queue.IsEmpty()) { 812 while (!queue.IsEmpty()) {
(...skipping 30 matching lines...) Expand all
848 EXPECT_EQ(16u, tile_count); 843 EXPECT_EQ(16u, tile_count);
849 844
850 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); 845 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end());
851 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 846 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
852 847
853 EvictionTilePriorityQueue queue; 848 EvictionTilePriorityQueue queue;
854 for (int i = 1; i < 10; ++i) { 849 for (int i = 1; i < 10; ++i) {
855 scoped_ptr<FakePictureLayerImpl> pending_layer = 850 scoped_ptr<FakePictureLayerImpl> pending_layer =
856 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); 851 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i);
857 pending_layer->SetDrawsContent(true); 852 pending_layer->SetDrawsContent(true);
858 pending_layer->DoPostCommitInitializationIfNeeded();
859 pending_layer->set_has_valid_tile_priorities(true); 853 pending_layer->set_has_valid_tile_priorities(true);
860 pending_layer_->AddChild(pending_layer.Pass()); 854 pending_layer_->AddChild(pending_layer.Pass());
861 } 855 }
862 856
863 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 857 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
864 EXPECT_FALSE(queue.IsEmpty()); 858 EXPECT_FALSE(queue.IsEmpty());
865 859
866 tile_count = 0; 860 tile_count = 0;
867 all_tiles.clear(); 861 all_tiles.clear();
868 while (!queue.IsEmpty()) { 862 while (!queue.IsEmpty()) {
869 EXPECT_TRUE(queue.Top()); 863 EXPECT_TRUE(queue.Top());
870 all_tiles.insert(queue.Top()); 864 all_tiles.insert(queue.Top());
871 ++tile_count; 865 ++tile_count;
872 queue.Pop(); 866 queue.Pop();
873 } 867 }
874 EXPECT_EQ(tile_count, all_tiles.size()); 868 EXPECT_EQ(tile_count, all_tiles.size());
875 EXPECT_EQ(16u, tile_count); 869 EXPECT_EQ(16u, tile_count);
876 } 870 }
877 871
878 } // namespace 872 } // namespace
879 } // namespace cc 873 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_perftest.cc ('k') | cc/resources/tiling_set_eviction_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698