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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 pending_layer_->SetAllTilesVisible(); | 117 pending_layer_->SetAllTilesVisible(); |
122 } | 118 } |
123 | 119 |
124 TileManager* tile_manager() { return host_impl_.tile_manager(); } | 120 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
125 | 121 |
126 protected: | 122 protected: |
127 GlobalStateThatImpactsTilePriority global_state_; | 123 GlobalStateThatImpactsTilePriority global_state_; |
128 | 124 |
129 TestSharedBitmapManager shared_bitmap_manager_; | 125 TestSharedBitmapManager shared_bitmap_manager_; |
130 TileMemoryLimitPolicy memory_limit_policy_; | 126 TileMemoryLimitPolicy memory_limit_policy_; |
131 int max_tiles_; | |
132 bool ready_to_activate_; | 127 bool ready_to_activate_; |
133 int id_; | 128 int id_; |
134 FakeImplProxy proxy_; | 129 FakeImplProxy proxy_; |
135 FakeLayerTreeHostImpl host_impl_; | 130 FakeLayerTreeHostImpl host_impl_; |
136 FakePictureLayerImpl* pending_layer_; | 131 FakePictureLayerImpl* pending_layer_; |
137 FakePictureLayerImpl* active_layer_; | 132 FakePictureLayerImpl* active_layer_; |
138 }; | 133 }; |
139 | 134 |
140 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 135 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
141 SetupDefaultTrees(gfx::Size(1000, 1000)); | 136 SetupDefaultTrees(gfx::Size(1000, 1000)); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 all_tiles.insert(queue.Top()); | 744 all_tiles.insert(queue.Top()); |
750 ++tile_count; | 745 ++tile_count; |
751 queue.Pop(); | 746 queue.Pop(); |
752 } | 747 } |
753 EXPECT_EQ(tile_count, all_tiles.size()); | 748 EXPECT_EQ(tile_count, all_tiles.size()); |
754 EXPECT_EQ(16u, tile_count); | 749 EXPECT_EQ(16u, tile_count); |
755 } | 750 } |
756 | 751 |
757 } // namespace | 752 } // namespace |
758 } // namespace cc | 753 } // namespace cc |
OLD | NEW |