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

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

Issue 202763002: Switch to use SharedBitmapManager all the time in cc_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_manager_perftest.cc ('k') | cc/resources/video_resource_updater_unittest.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/tile.h" 5 #include "cc/resources/tile.h"
6 #include "cc/resources/tile_priority.h" 6 #include "cc/resources/tile_priority.h"
7 #include "cc/test/fake_impl_proxy.h" 7 #include "cc/test/fake_impl_proxy.h"
8 #include "cc/test/fake_layer_tree_host_impl.h" 8 #include "cc/test/fake_layer_tree_host_impl.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"
11 #include "cc/test/fake_picture_layer_impl.h" 11 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_picture_pile_impl.h" 12 #include "cc/test/fake_picture_pile_impl.h"
13 #include "cc/test/fake_tile_manager.h" 13 #include "cc/test/fake_tile_manager.h"
14 #include "cc/test/test_shared_bitmap_manager.h"
14 #include "cc/test/test_tile_priorities.h" 15 #include "cc/test/test_tile_priorities.h"
15 #include "cc/trees/layer_tree_impl.h" 16 #include "cc/trees/layer_tree_impl.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
20 21
21 class TileManagerTest : public testing::TestWithParam<bool>, 22 class TileManagerTest : public testing::TestWithParam<bool>,
22 public TileManagerClient { 23 public TileManagerClient {
23 public: 24 public:
24 typedef std::vector<scoped_refptr<Tile> > TileVector; 25 typedef std::vector<scoped_refptr<Tile> > TileVector;
25 26
26 TileManagerTest() 27 TileManagerTest()
27 : memory_limit_policy_(ALLOW_ANYTHING), 28 : memory_limit_policy_(ALLOW_ANYTHING),
28 max_tiles_(0), 29 max_tiles_(0),
29 ready_to_activate_(false) {} 30 ready_to_activate_(false) {}
30 31
31 void Initialize(int max_tiles, 32 void Initialize(int max_tiles,
32 TileMemoryLimitPolicy memory_limit_policy, 33 TileMemoryLimitPolicy memory_limit_policy,
33 TreePriority tree_priority, 34 TreePriority tree_priority,
34 bool allow_on_demand_raster = true) { 35 bool allow_on_demand_raster = true) {
35 output_surface_ = FakeOutputSurface::Create3d(); 36 output_surface_ = FakeOutputSurface::Create3d();
36 CHECK(output_surface_->BindToClient(&output_surface_client_)); 37 CHECK(output_surface_->BindToClient(&output_surface_client_));
37 38
38 resource_provider_ = 39 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
39 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); 40 resource_provider_ = ResourceProvider::Create(
41 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1);
40 tile_manager_ = make_scoped_ptr(new FakeTileManager( 42 tile_manager_ = make_scoped_ptr(new FakeTileManager(
41 this, resource_provider_.get(), allow_on_demand_raster)); 43 this, resource_provider_.get(), allow_on_demand_raster));
42 44
43 memory_limit_policy_ = memory_limit_policy; 45 memory_limit_policy_ = memory_limit_policy;
44 max_tiles_ = max_tiles; 46 max_tiles_ = max_tiles;
45 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); 47 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile();
46 48
47 SetTreePriority(tree_priority); 49 SetTreePriority(tree_priority);
48 } 50 }
49 51
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 protected: 140 protected:
139 GlobalStateThatImpactsTilePriority global_state_; 141 GlobalStateThatImpactsTilePriority global_state_;
140 142
141 private: 143 private:
142 LayerTreeSettings settings_; 144 LayerTreeSettings settings_;
143 scoped_ptr<FakeTileManager> tile_manager_; 145 scoped_ptr<FakeTileManager> tile_manager_;
144 scoped_refptr<FakePicturePileImpl> picture_pile_; 146 scoped_refptr<FakePicturePileImpl> picture_pile_;
145 FakeOutputSurfaceClient output_surface_client_; 147 FakeOutputSurfaceClient output_surface_client_;
146 scoped_ptr<FakeOutputSurface> output_surface_; 148 scoped_ptr<FakeOutputSurface> output_surface_;
149 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
147 scoped_ptr<ResourceProvider> resource_provider_; 150 scoped_ptr<ResourceProvider> resource_provider_;
148 TileMemoryLimitPolicy memory_limit_policy_; 151 TileMemoryLimitPolicy memory_limit_policy_;
149 int max_tiles_; 152 int max_tiles_;
150 bool ready_to_activate_; 153 bool ready_to_activate_;
151 }; 154 };
152 155
153 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { 156 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) {
154 // A few tiles of each type of priority, with enough memory for all tiles. 157 // A few tiles of each type of priority, with enough memory for all tiles.
155 158
156 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); 159 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 624
622 EXPECT_TRUE(ready_to_activate()); 625 EXPECT_TRUE(ready_to_activate());
623 for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it) 626 for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it)
624 EXPECT_FALSE((*it)->IsReadyToDraw()); 627 EXPECT_FALSE((*it)->IsReadyToDraw());
625 } 628 }
626 629
627 TEST_P(TileManagerTest, PairedPictureLayers) { 630 TEST_P(TileManagerTest, PairedPictureLayers) {
628 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); 631 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY);
629 632
630 FakeImplProxy proxy; 633 FakeImplProxy proxy;
631 FakeLayerTreeHostImpl host_impl(&proxy); 634 TestSharedBitmapManager shared_bitmap_manager;
635 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
632 host_impl.CreatePendingTree(); 636 host_impl.CreatePendingTree();
633 host_impl.ActivatePendingTree(); 637 host_impl.ActivatePendingTree();
634 host_impl.CreatePendingTree(); 638 host_impl.CreatePendingTree();
635 639
636 LayerTreeImpl* active_tree = host_impl.active_tree(); 640 LayerTreeImpl* active_tree = host_impl.active_tree();
637 LayerTreeImpl* pending_tree = host_impl.pending_tree(); 641 LayerTreeImpl* pending_tree = host_impl.pending_tree();
638 EXPECT_NE(active_tree, pending_tree); 642 EXPECT_NE(active_tree, pending_tree);
639 643
640 scoped_ptr<FakePictureLayerImpl> active_layer = 644 scoped_ptr<FakePictureLayerImpl> active_layer =
641 FakePictureLayerImpl::Create(active_tree, 10); 645 FakePictureLayerImpl::Create(active_tree, 10);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 686 }
683 687
684 // If true, the max tile limit should be applied as bytes; if false, 688 // If true, the max tile limit should be applied as bytes; if false,
685 // as num_resources_limit. 689 // as num_resources_limit.
686 INSTANTIATE_TEST_CASE_P(TileManagerTests, 690 INSTANTIATE_TEST_CASE_P(TileManagerTests,
687 TileManagerTest, 691 TileManagerTest,
688 ::testing::Values(true, false)); 692 ::testing::Values(true, false));
689 693
690 } // namespace 694 } // namespace
691 } // namespace cc 695 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_perftest.cc ('k') | cc/resources/video_resource_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698