OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class LowResTilingsSettings : public ImplSidePaintingSettings { | 25 class LowResTilingsSettings : public ImplSidePaintingSettings { |
26 public: | 26 public: |
27 LowResTilingsSettings() { create_low_res_tiling = true; } | 27 LowResTilingsSettings() { create_low_res_tiling = true; } |
28 }; | 28 }; |
29 | 29 |
30 class TileManagerTilePriorityQueueTest : public testing::Test { | 30 class TileManagerTilePriorityQueueTest : public testing::Test { |
31 public: | 31 public: |
32 TileManagerTilePriorityQueueTest() | 32 TileManagerTilePriorityQueueTest() |
33 : memory_limit_policy_(ALLOW_ANYTHING), | 33 : memory_limit_policy_(ALLOW_ANYTHING), |
34 max_tiles_(10000), | |
35 ready_to_activate_(false), | 34 ready_to_activate_(false), |
36 id_(7), | 35 id_(7), |
37 proxy_(base::MessageLoopProxy::current()), | 36 proxy_(base::MessageLoopProxy::current()), |
38 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_) {} | 37 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_) {} |
39 | 38 |
40 void SetTreePriority(TreePriority tree_priority) { | 39 void SetTreePriority(TreePriority tree_priority) { |
41 GlobalStateThatImpactsTilePriority state; | 40 GlobalStateThatImpactsTilePriority state; |
42 gfx::Size tile_size(256, 256); | 41 gfx::Size tile_size(256, 256); |
43 | 42 |
44 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; | 43 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; |
45 state.num_resources_limit = max_tiles_; | |
46 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; | 44 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; |
47 state.memory_limit_policy = memory_limit_policy_; | 45 state.memory_limit_policy = memory_limit_policy_; |
48 state.tree_priority = tree_priority; | 46 state.tree_priority = tree_priority; |
49 | 47 |
50 global_state_ = state; | 48 global_state_ = state; |
51 host_impl_.resource_pool()->SetResourceUsageLimits( | 49 host_impl_.resource_pool()->SetResourceUsageLimits( |
52 state.soft_memory_limit_in_bytes, | 50 state.soft_memory_limit_in_bytes, state.soft_memory_limit_in_bytes); |
53 state.soft_memory_limit_in_bytes, | |
54 state.num_resources_limit); | |
55 host_impl_.tile_manager()->SetGlobalStateForTesting(state); | 51 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
56 } | 52 } |
57 | 53 |
58 virtual void SetUp() override { | 54 virtual void SetUp() override { |
59 InitializeRenderer(); | 55 InitializeRenderer(); |
60 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 56 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
61 } | 57 } |
62 | 58 |
63 virtual void InitializeRenderer() { | 59 virtual void InitializeRenderer() { |
64 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 60 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 pending_layer_->SetAllTilesVisible(); | 128 pending_layer_->SetAllTilesVisible(); |
133 } | 129 } |
134 | 130 |
135 TileManager* tile_manager() { return host_impl_.tile_manager(); } | 131 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
136 | 132 |
137 protected: | 133 protected: |
138 GlobalStateThatImpactsTilePriority global_state_; | 134 GlobalStateThatImpactsTilePriority global_state_; |
139 | 135 |
140 TestSharedBitmapManager shared_bitmap_manager_; | 136 TestSharedBitmapManager shared_bitmap_manager_; |
141 TileMemoryLimitPolicy memory_limit_policy_; | 137 TileMemoryLimitPolicy memory_limit_policy_; |
142 int max_tiles_; | |
143 bool ready_to_activate_; | 138 bool ready_to_activate_; |
144 int id_; | 139 int id_; |
145 FakeImplProxy proxy_; | 140 FakeImplProxy proxy_; |
146 FakeLayerTreeHostImpl host_impl_; | 141 FakeLayerTreeHostImpl host_impl_; |
147 FakePictureLayerImpl* pending_layer_; | 142 FakePictureLayerImpl* pending_layer_; |
148 FakePictureLayerImpl* active_layer_; | 143 FakePictureLayerImpl* active_layer_; |
149 }; | 144 }; |
150 | 145 |
151 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 146 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
152 SetupDefaultTrees(gfx::Size(1000, 1000)); | 147 SetupDefaultTrees(gfx::Size(1000, 1000)); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 all_tiles.insert(queue.Top()); | 755 all_tiles.insert(queue.Top()); |
761 ++tile_count; | 756 ++tile_count; |
762 queue.Pop(); | 757 queue.Pop(); |
763 } | 758 } |
764 EXPECT_EQ(tile_count, all_tiles.size()); | 759 EXPECT_EQ(tile_count, all_tiles.size()); |
765 EXPECT_EQ(16u, tile_count); | 760 EXPECT_EQ(16u, tile_count); |
766 } | 761 } |
767 | 762 |
768 } // namespace | 763 } // namespace |
769 } // namespace cc | 764 } // namespace cc |
OLD | NEW |