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

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

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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/tile_manager_perftest.cc ('k') | cc/resources/ui_resource_request.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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 state.num_resources_limit); 513 state.num_resources_limit);
514 host_impl_.tile_manager()->SetGlobalStateForTesting(state); 514 host_impl_.tile_manager()->SetGlobalStateForTesting(state);
515 } 515 }
516 516
517 virtual void SetUp() OVERRIDE { 517 virtual void SetUp() OVERRIDE {
518 InitializeRenderer(); 518 InitializeRenderer();
519 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 519 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
520 } 520 }
521 521
522 virtual void InitializeRenderer() { 522 virtual void InitializeRenderer() {
523 host_impl_.InitializeRenderer( 523 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d());
524 FakeOutputSurface::Create3d().PassAs<OutputSurface>());
525 } 524 }
526 525
527 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 526 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
528 gfx::Size tile_size(100, 100); 527 gfx::Size tile_size(100, 100);
529 528
530 scoped_refptr<FakePicturePileImpl> pending_pile = 529 scoped_refptr<FakePicturePileImpl> pending_pile =
531 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 530 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
532 scoped_refptr<FakePicturePileImpl> active_pile = 531 scoped_refptr<FakePicturePileImpl> active_pile =
533 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 532 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
534 533
(...skipping 24 matching lines...) Expand all
559 558
560 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { 559 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) {
561 host_impl_.CreatePendingTree(); 560 host_impl_.CreatePendingTree();
562 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 561 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
563 // Clear recycled tree. 562 // Clear recycled tree.
564 pending_tree->DetachLayerTree(); 563 pending_tree->DetachLayerTree();
565 564
566 scoped_ptr<FakePictureLayerImpl> pending_layer = 565 scoped_ptr<FakePictureLayerImpl> pending_layer =
567 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); 566 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile);
568 pending_layer->SetDrawsContent(true); 567 pending_layer->SetDrawsContent(true);
569 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); 568 pending_tree->SetRootLayer(pending_layer.Pass());
570 569
571 pending_layer_ = static_cast<FakePictureLayerImpl*>( 570 pending_layer_ = static_cast<FakePictureLayerImpl*>(
572 host_impl_.pending_tree()->LayerById(id_)); 571 host_impl_.pending_tree()->LayerById(id_));
573 pending_layer_->DoPostCommitInitializationIfNeeded(); 572 pending_layer_->DoPostCommitInitializationIfNeeded();
574 } 573 }
575 574
576 void CreateHighLowResAndSetAllTilesVisible() { 575 void CreateHighLowResAndSetAllTilesVisible() {
577 // Active layer must get updated first so pending layer can share from it. 576 // Active layer must get updated first so pending layer can share from it.
578 active_layer_->CreateDefaultTilingsAndTiles(); 577 active_layer_->CreateDefaultTilingsAndTiles();
579 active_layer_->SetAllTilesVisible(); 578 active_layer_->SetAllTilesVisible();
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 gfx::Size layer_bounds(1000, 1000); 933 gfx::Size layer_bounds(1000, 1000);
935 934
936 scoped_refptr<FakePicturePileImpl> pending_pile = 935 scoped_refptr<FakePicturePileImpl> pending_pile =
937 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 936 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
938 SetupPendingTree(pending_pile); 937 SetupPendingTree(pending_pile);
939 pending_layer_->CreateDefaultTilingsAndTiles(); 938 pending_layer_->CreateDefaultTilingsAndTiles();
940 939
941 scoped_ptr<FakePictureLayerImpl> pending_child = 940 scoped_ptr<FakePictureLayerImpl> pending_child =
942 FakePictureLayerImpl::CreateWithPile( 941 FakePictureLayerImpl::CreateWithPile(
943 host_impl_.pending_tree(), 2, pending_pile); 942 host_impl_.pending_tree(), 2, pending_pile);
944 pending_layer_->AddChild(pending_child.PassAs<LayerImpl>()); 943 pending_layer_->AddChild(pending_child.Pass());
945 944
946 FakePictureLayerImpl* pending_child_layer = 945 FakePictureLayerImpl* pending_child_layer =
947 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); 946 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
948 pending_child_layer->SetDrawsContent(true); 947 pending_child_layer->SetDrawsContent(true);
949 pending_child_layer->DoPostCommitInitializationIfNeeded(); 948 pending_child_layer->DoPostCommitInitializationIfNeeded();
950 pending_child_layer->CreateDefaultTilingsAndTiles(); 949 pending_child_layer->CreateDefaultTilingsAndTiles();
951 950
952 std::set<Tile*> all_tiles; 951 std::set<Tile*> all_tiles;
953 size_t tile_count = 0; 952 size_t tile_count = 0;
954 RasterTilePriorityQueue raster_queue; 953 RasterTilePriorityQueue raster_queue;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 EXPECT_EQ(tile_count, all_tiles.size()); 1066 EXPECT_EQ(tile_count, all_tiles.size());
1068 EXPECT_EQ(17u, tile_count); 1067 EXPECT_EQ(17u, tile_count);
1069 1068
1070 queue.Reset(); 1069 queue.Reset();
1071 for (int i = 1; i < 10; ++i) { 1070 for (int i = 1; i < 10; ++i) {
1072 scoped_ptr<FakePictureLayerImpl> pending_layer = 1071 scoped_ptr<FakePictureLayerImpl> pending_layer =
1073 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); 1072 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i);
1074 pending_layer->SetDrawsContent(true); 1073 pending_layer->SetDrawsContent(true);
1075 pending_layer->DoPostCommitInitializationIfNeeded(); 1074 pending_layer->DoPostCommitInitializationIfNeeded();
1076 pending_layer->set_has_valid_tile_priorities(true); 1075 pending_layer->set_has_valid_tile_priorities(true);
1077 pending_layer_->AddChild(pending_layer.PassAs<LayerImpl>()); 1076 pending_layer_->AddChild(pending_layer.Pass());
1078 } 1077 }
1079 1078
1080 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 1079 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
1081 EXPECT_FALSE(queue.IsEmpty()); 1080 EXPECT_FALSE(queue.IsEmpty());
1082 1081
1083 tile_count = 0; 1082 tile_count = 0;
1084 all_tiles.clear(); 1083 all_tiles.clear();
1085 while (!queue.IsEmpty()) { 1084 while (!queue.IsEmpty()) {
1086 EXPECT_TRUE(queue.Top()); 1085 EXPECT_TRUE(queue.Top());
1087 all_tiles.insert(queue.Top()); 1086 all_tiles.insert(queue.Top());
(...skipping 28 matching lines...) Expand all
1116 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); 1115 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end());
1117 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1116 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1118 1117
1119 EvictionTilePriorityQueue queue; 1118 EvictionTilePriorityQueue queue;
1120 for (int i = 1; i < 10; ++i) { 1119 for (int i = 1; i < 10; ++i) {
1121 scoped_ptr<FakePictureLayerImpl> pending_layer = 1120 scoped_ptr<FakePictureLayerImpl> pending_layer =
1122 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); 1121 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i);
1123 pending_layer->SetDrawsContent(true); 1122 pending_layer->SetDrawsContent(true);
1124 pending_layer->DoPostCommitInitializationIfNeeded(); 1123 pending_layer->DoPostCommitInitializationIfNeeded();
1125 pending_layer->set_has_valid_tile_priorities(true); 1124 pending_layer->set_has_valid_tile_priorities(true);
1126 pending_layer_->AddChild(pending_layer.PassAs<LayerImpl>()); 1125 pending_layer_->AddChild(pending_layer.Pass());
1127 } 1126 }
1128 1127
1129 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); 1128 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES);
1130 EXPECT_FALSE(queue.IsEmpty()); 1129 EXPECT_FALSE(queue.IsEmpty());
1131 1130
1132 tile_count = 0; 1131 tile_count = 0;
1133 all_tiles.clear(); 1132 all_tiles.clear();
1134 while (!queue.IsEmpty()) { 1133 while (!queue.IsEmpty()) {
1135 EXPECT_TRUE(queue.Top()); 1134 EXPECT_TRUE(queue.Top());
1136 all_tiles.insert(queue.Top()); 1135 all_tiles.insert(queue.Top());
1137 ++tile_count; 1136 ++tile_count;
1138 queue.Pop(); 1137 queue.Pop();
1139 } 1138 }
1140 EXPECT_EQ(tile_count, all_tiles.size()); 1139 EXPECT_EQ(tile_count, all_tiles.size());
1141 EXPECT_EQ(17u, tile_count); 1140 EXPECT_EQ(17u, tile_count);
1142 } 1141 }
1143 1142
1144 } // namespace 1143 } // namespace
1145 } // namespace cc 1144 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_perftest.cc ('k') | cc/resources/ui_resource_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698