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

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

Issue 287643004: Re-land: cc: Examine layers to determine if we're ready to activate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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"
(...skipping 14 matching lines...) Expand all
25 public: 25 public:
26 typedef std::vector<scoped_refptr<Tile> > TileVector; 26 typedef std::vector<scoped_refptr<Tile> > TileVector;
27 27
28 TileManagerTest() 28 TileManagerTest()
29 : memory_limit_policy_(ALLOW_ANYTHING), 29 : memory_limit_policy_(ALLOW_ANYTHING),
30 max_tiles_(0), 30 max_tiles_(0),
31 ready_to_activate_(false) {} 31 ready_to_activate_(false) {}
32 32
33 void Initialize(int max_tiles, 33 void Initialize(int max_tiles,
34 TileMemoryLimitPolicy memory_limit_policy, 34 TileMemoryLimitPolicy memory_limit_policy,
35 TreePriority tree_priority, 35 TreePriority tree_priority) {
36 bool allow_on_demand_raster = true) {
37 output_surface_ = FakeOutputSurface::Create3d(); 36 output_surface_ = FakeOutputSurface::Create3d();
38 CHECK(output_surface_->BindToClient(&output_surface_client_)); 37 CHECK(output_surface_->BindToClient(&output_surface_client_));
39 38
40 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 39 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
41 resource_provider_ = ResourceProvider::Create( 40 resource_provider_ = ResourceProvider::Create(
42 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, 41 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1,
43 false); 42 false);
44 resource_pool_ = ResourcePool::Create( 43 resource_pool_ = ResourcePool::Create(
45 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); 44 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888);
46 tile_manager_ = make_scoped_ptr(new FakeTileManager( 45 tile_manager_ =
47 this, resource_pool_.get(), allow_on_demand_raster)); 46 make_scoped_ptr(new FakeTileManager(this, resource_pool_.get()));
48 47
49 memory_limit_policy_ = memory_limit_policy; 48 memory_limit_policy_ = memory_limit_policy;
50 max_tiles_ = max_tiles; 49 max_tiles_ = max_tiles;
51 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); 50 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile();
52 51
53 SetTreePriority(tree_priority); 52 SetTreePriority(tree_priority);
54 } 53 }
55 54
56 void SetTreePriority(TreePriority tree_priority) { 55 void SetTreePriority(TreePriority tree_priority) {
57 GlobalStateThatImpactsTilePriority state; 56 GlobalStateThatImpactsTilePriority state;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 593
595 tile_manager()->AssignMemoryToTiles(global_state_); 594 tile_manager()->AssignMemoryToTiles(global_state_);
596 tile_manager()->GetMemoryStats(&memory_required_bytes, 595 tile_manager()->GetMemoryStats(&memory_required_bytes,
597 &memory_nice_to_have_bytes, 596 &memory_nice_to_have_bytes,
598 &memory_allocated_bytes, 597 &memory_allocated_bytes,
599 &memory_used_bytes); 598 &memory_used_bytes);
600 // Allocated bytes should never be more than the memory limit. 599 // Allocated bytes should never be more than the memory limit.
601 EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes); 600 EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes);
602 } 601 }
603 602
604 TEST_P(TileManagerTest, AllowRasterizeOnDemand) {
605 // Not enough memory to initialize tiles required for activation.
606 Initialize(0, ALLOW_ANYTHING, SAME_PRIORITY_FOR_BOTH_TREES);
607 TileVector tiles =
608 CreateTiles(2, TilePriority(), TilePriorityRequiredForActivation());
609
610 tile_manager()->AssignMemoryToTiles(global_state_);
611
612 // This should make required tiles ready to draw by marking them as
613 // required tiles for on-demand raster.
614 tile_manager()->DidFinishRunningTasksForTesting();
615
616 EXPECT_TRUE(ready_to_activate());
617 for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it)
618 EXPECT_TRUE((*it)->IsReadyToDraw());
619 }
620
621 TEST_P(TileManagerTest, PreventRasterizeOnDemand) {
622 // Not enough memory to initialize tiles required for activation.
623 Initialize(0, ALLOW_ANYTHING, SAME_PRIORITY_FOR_BOTH_TREES, false);
624 TileVector tiles =
625 CreateTiles(2, TilePriority(), TilePriorityRequiredForActivation());
626
627 tile_manager()->AssignMemoryToTiles(global_state_);
628
629 // This should make required tiles ready to draw by marking them as
630 // required tiles for on-demand raster.
631 tile_manager()->DidFinishRunningTasksForTesting();
632
633 EXPECT_TRUE(ready_to_activate());
634 for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it)
635 EXPECT_FALSE((*it)->IsReadyToDraw());
636 }
637
638 // If true, the max tile limit should be applied as bytes; if false, 603 // If true, the max tile limit should be applied as bytes; if false,
639 // as num_resources_limit. 604 // as num_resources_limit.
640 INSTANTIATE_TEST_CASE_P(TileManagerTests, 605 INSTANTIATE_TEST_CASE_P(TileManagerTests,
641 TileManagerTest, 606 TileManagerTest,
642 ::testing::Values(true, false)); 607 ::testing::Values(true, false));
643 608
644 class TileManagerTileIteratorTest : public testing::Test, 609 class TileManagerTileIteratorTest : public testing::Test,
645 public TileManagerClient { 610 public TileManagerClient {
646 public: 611 public:
647 TileManagerTileIteratorTest() 612 TileManagerTileIteratorTest()
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1098
1134 last_tile = tile; 1099 last_tile = tile;
1135 new_content_tiles.insert(tile); 1100 new_content_tiles.insert(tile);
1136 } 1101 }
1137 1102
1138 EXPECT_EQ(tile_count, new_content_tiles.size()); 1103 EXPECT_EQ(tile_count, new_content_tiles.size());
1139 EXPECT_EQ(all_tiles, new_content_tiles); 1104 EXPECT_EQ(all_tiles, new_content_tiles);
1140 } 1105 }
1141 } // namespace 1106 } // namespace
1142 } // namespace cc 1107 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698