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/debug/lap_timer.h" | 5 #include "cc/debug/lap_timer.h" |
6 #include "cc/resources/picture_layer_tiling.h" | 6 #include "cc/resources/picture_layer_tiling.h" |
7 #include "cc/resources/resource_provider.h" | 7 #include "cc/resources/resource_provider.h" |
8 #include "cc/resources/scoped_resource.h" | 8 #include "cc/resources/scoped_resource.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 25 matching lines...) Expand all Loading... |
36 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 36 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
37 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 37 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
38 shared_bitmap_manager_.get(), | 38 shared_bitmap_manager_.get(), |
39 NULL, | 39 NULL, |
40 NULL, | 40 NULL, |
41 0, | 41 0, |
42 false, | 42 false, |
43 1).Pass(); | 43 1).Pass(); |
44 } | 44 } |
45 | 45 |
46 virtual void SetUp() override { | 46 void SetUp() override { |
47 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); | 47 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
48 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); | 48 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); |
49 picture_layer_tiling_client_.set_tree(PENDING_TREE); | 49 picture_layer_tiling_client_.set_tree(PENDING_TREE); |
50 picture_layer_tiling_ = PictureLayerTiling::Create( | 50 picture_layer_tiling_ = PictureLayerTiling::Create( |
51 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); | 51 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); |
52 picture_layer_tiling_->CreateAllTilesForTesting(); | 52 picture_layer_tiling_->CreateAllTilesForTesting(); |
53 } | 53 } |
54 | 54 |
55 virtual void TearDown() override { | 55 void TearDown() override { picture_layer_tiling_.reset(NULL); } |
56 picture_layer_tiling_.reset(NULL); | |
57 } | |
58 | 56 |
59 void RunInvalidateTest(const std::string& test_name, const Region& region) { | 57 void RunInvalidateTest(const std::string& test_name, const Region& region) { |
60 timer_.Reset(); | 58 timer_.Reset(); |
61 do { | 59 do { |
62 picture_layer_tiling_->UpdateTilesToCurrentRasterSource( | 60 picture_layer_tiling_->UpdateTilesToCurrentRasterSource( |
63 region, picture_layer_tiling_->tiling_size()); | 61 picture_layer_tiling_client_.raster_source(), region, |
| 62 picture_layer_tiling_->tiling_size()); |
64 timer_.NextLap(); | 63 timer_.NextLap(); |
65 } while (!timer_.HasTimeLimitExpired()); | 64 } while (!timer_.HasTimeLimitExpired()); |
66 | 65 |
67 perf_test::PrintResult( | 66 perf_test::PrintResult( |
68 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 67 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true); |
69 } | 68 } |
70 | 69 |
71 void RunComputeTilePriorityRectsStationaryTest( | 70 void RunComputeTilePriorityRectsStationaryTest( |
72 const std::string& test_name, | 71 const std::string& test_name, |
73 const gfx::Transform& transform) { | 72 const gfx::Transform& transform) { |
74 gfx::Rect viewport_rect(0, 0, 1024, 768); | 73 gfx::Rect viewport_rect(0, 0, 1024, 768); |
75 | 74 |
76 timer_.Reset(); | 75 timer_.Reset(); |
77 do { | 76 do { |
78 picture_layer_tiling_->ComputeTilePriorityRects( | 77 picture_layer_tiling_->ComputeTilePriorityRects( |
79 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 78 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); |
80 timer_.NextLap(); | 79 timer_.NextLap(); |
81 } while (!timer_.HasTimeLimitExpired()); | 80 } while (!timer_.HasTimeLimitExpired()); |
82 | 81 |
83 perf_test::PrintResult("compute_tile_priority_rects_stationary", | 82 perf_test::PrintResult("compute_tile_priority_rects_stationary", |
84 "", | 83 "", |
85 test_name, | 84 test_name, |
86 timer_.LapsPerSecond(), | 85 timer_.LapsPerSecond(), |
87 "runs/s", | 86 "runs/s", |
88 true); | 87 true); |
89 } | 88 } |
90 | 89 |
91 void RunComputeTilePriorityRectsScrollingTest( | 90 void RunComputeTilePriorityRectsScrollingTest( |
92 const std::string& test_name, | 91 const std::string& test_name, |
93 const gfx::Transform& transform) { | 92 const gfx::Transform& transform) { |
94 gfx::Size viewport_size(1024, 768); | 93 gfx::Size viewport_size(1024, 768); |
95 gfx::Rect viewport_rect(viewport_size); | 94 gfx::Rect viewport_rect(viewport_size); |
96 int xoffsets[] = {10, 0, -10, 0}; | 95 int xoffsets[] = {10, 0, -10, 0}; |
97 int yoffsets[] = {0, 10, 0, -10}; | 96 int yoffsets[] = {0, 10, 0, -10}; |
98 int offsetIndex = 0; | 97 int offsetIndex = 0; |
99 int offsetCount = 0; | 98 int offsetCount = 0; |
100 const int maxOffsetCount = 1000; | 99 const int maxOffsetCount = 1000; |
101 | 100 |
102 timer_.Reset(); | 101 timer_.Reset(); |
103 do { | 102 do { |
104 picture_layer_tiling_->ComputeTilePriorityRects( | 103 picture_layer_tiling_->ComputeTilePriorityRects( |
105 PENDING_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); | 104 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion()); |
106 | 105 |
107 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], | 106 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex], |
108 viewport_rect.y() + yoffsets[offsetIndex], | 107 viewport_rect.y() + yoffsets[offsetIndex], |
109 viewport_rect.width(), | 108 viewport_rect.width(), |
110 viewport_rect.height()); | 109 viewport_rect.height()); |
111 | 110 |
112 if (++offsetCount > maxOffsetCount) { | 111 if (++offsetCount > maxOffsetCount) { |
113 offsetCount = 0; | 112 offsetCount = 0; |
114 offsetIndex = (offsetIndex + 1) % 4; | 113 offsetIndex = (offsetIndex + 1) % 4; |
115 } | 114 } |
116 timer_.NextLap(); | 115 timer_.NextLap(); |
117 } while (!timer_.HasTimeLimitExpired()); | 116 } while (!timer_.HasTimeLimitExpired()); |
118 | 117 |
119 perf_test::PrintResult("compute_tile_priority_rects_scrolling", | 118 perf_test::PrintResult("compute_tile_priority_rects_scrolling", |
120 "", | 119 "", |
121 test_name, | 120 test_name, |
122 timer_.LapsPerSecond(), | 121 timer_.LapsPerSecond(), |
123 "runs/s", | 122 "runs/s", |
124 true); | 123 true); |
125 } | 124 } |
126 | 125 |
127 void RunRasterIteratorConstructTest(const std::string& test_name, | 126 void RunRasterIteratorConstructTest(const std::string& test_name, |
128 const gfx::Rect& viewport) { | 127 const gfx::Rect& viewport) { |
129 gfx::Size bounds(viewport.size()); | 128 gfx::Size bounds(viewport.size()); |
130 picture_layer_tiling_ = | 129 picture_layer_tiling_ = |
131 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 130 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
132 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 131 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
133 picture_layer_tiling_->ComputeTilePriorityRects( | 132 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
134 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 133 Occlusion()); |
135 | 134 |
136 timer_.Reset(); | 135 timer_.Reset(); |
137 do { | 136 do { |
138 PictureLayerTiling::TilingRasterTileIterator it( | 137 PictureLayerTiling::TilingRasterTileIterator it( |
139 picture_layer_tiling_.get()); | 138 picture_layer_tiling_.get()); |
140 timer_.NextLap(); | 139 timer_.NextLap(); |
141 } while (!timer_.HasTimeLimitExpired()); | 140 } while (!timer_.HasTimeLimitExpired()); |
142 | 141 |
143 perf_test::PrintResult("tiling_raster_tile_iterator_construct", | 142 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
144 "", | 143 "", |
145 test_name, | 144 test_name, |
146 timer_.LapsPerSecond(), | 145 timer_.LapsPerSecond(), |
147 "runs/s", | 146 "runs/s", |
148 true); | 147 true); |
149 } | 148 } |
150 | 149 |
151 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, | 150 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
152 int num_tiles, | 151 int num_tiles, |
153 const gfx::Rect& viewport) { | 152 const gfx::Rect& viewport) { |
154 gfx::Size bounds(10000, 10000); | 153 gfx::Size bounds(10000, 10000); |
155 picture_layer_tiling_ = | 154 picture_layer_tiling_ = |
156 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 155 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
157 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 156 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
158 picture_layer_tiling_->ComputeTilePriorityRects( | 157 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
159 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 158 Occlusion()); |
160 | 159 |
161 timer_.Reset(); | 160 timer_.Reset(); |
162 do { | 161 do { |
163 int count = num_tiles; | 162 int count = num_tiles; |
164 PictureLayerTiling::TilingRasterTileIterator it( | 163 PictureLayerTiling::TilingRasterTileIterator it( |
165 picture_layer_tiling_.get()); | 164 picture_layer_tiling_.get()); |
166 while (count--) { | 165 while (count--) { |
167 ASSERT_TRUE(it) << "count: " << count; | 166 ASSERT_TRUE(it) << "count: " << count; |
168 ASSERT_TRUE(*it != NULL) << "count: " << count; | 167 ASSERT_TRUE(*it != NULL) << "count: " << count; |
169 ++it; | 168 ++it; |
170 } | 169 } |
171 timer_.NextLap(); | 170 timer_.NextLap(); |
172 } while (!timer_.HasTimeLimitExpired()); | 171 } while (!timer_.HasTimeLimitExpired()); |
173 | 172 |
174 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", | 173 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", |
175 "", | 174 "", |
176 test_name, | 175 test_name, |
177 timer_.LapsPerSecond(), | 176 timer_.LapsPerSecond(), |
178 "runs/s", | 177 "runs/s", |
179 true); | 178 true); |
180 } | 179 } |
181 | 180 |
182 void RunEvictionIteratorConstructTest(const std::string& test_name, | 181 void RunEvictionIteratorConstructTest(const std::string& test_name, |
183 const gfx::Rect& viewport) { | 182 const gfx::Rect& viewport) { |
184 gfx::Size bounds(viewport.size()); | 183 gfx::Size bounds(viewport.size()); |
185 picture_layer_tiling_ = | 184 picture_layer_tiling_ = |
186 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 185 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
187 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 186 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
188 picture_layer_tiling_->ComputeTilePriorityRects( | 187 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
189 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 188 Occlusion()); |
190 | 189 |
191 timer_.Reset(); | 190 timer_.Reset(); |
192 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 191 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
193 SMOOTHNESS_TAKES_PRIORITY, | 192 SMOOTHNESS_TAKES_PRIORITY, |
194 NEW_CONTENT_TAKES_PRIORITY}; | 193 NEW_CONTENT_TAKES_PRIORITY}; |
195 int priority_count = 0; | 194 int priority_count = 0; |
196 do { | 195 do { |
197 PictureLayerTiling::TilingEvictionTileIterator it( | 196 PictureLayerTiling::TilingEvictionTileIterator it( |
198 picture_layer_tiling_.get(), | 197 picture_layer_tiling_.get(), |
199 priorities[priority_count], | 198 priorities[priority_count], |
(...skipping 10 matching lines...) Expand all Loading... |
210 true); | 209 true); |
211 } | 210 } |
212 | 211 |
213 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, | 212 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
214 int num_tiles, | 213 int num_tiles, |
215 const gfx::Rect& viewport) { | 214 const gfx::Rect& viewport) { |
216 gfx::Size bounds(10000, 10000); | 215 gfx::Size bounds(10000, 10000); |
217 picture_layer_tiling_ = | 216 picture_layer_tiling_ = |
218 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 217 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
219 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 218 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
220 picture_layer_tiling_->ComputeTilePriorityRects( | 219 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
221 ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); | 220 Occlusion()); |
222 | 221 |
223 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 222 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
224 SMOOTHNESS_TAKES_PRIORITY, | 223 SMOOTHNESS_TAKES_PRIORITY, |
225 NEW_CONTENT_TAKES_PRIORITY}; | 224 NEW_CONTENT_TAKES_PRIORITY}; |
226 | 225 |
227 // Ensure all tiles have resources. | 226 // Ensure all tiles have resources. |
228 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); | 227 std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting(); |
229 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); | 228 for (std::vector<Tile*>::iterator tile_it = all_tiles.begin(); |
230 tile_it != all_tiles.end(); | 229 tile_it != all_tiles.end(); |
231 ++tile_it) { | 230 ++tile_it) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 350 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
352 RunEvictionIteratorConstructAndIterateTest( | 351 RunEvictionIteratorConstructAndIterateTest( |
353 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 352 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
354 RunEvictionIteratorConstructAndIterateTest( | 353 RunEvictionIteratorConstructAndIterateTest( |
355 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 354 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
356 } | 355 } |
357 | 356 |
358 } // namespace | 357 } // namespace |
359 | 358 |
360 } // namespace cc | 359 } // namespace cc |
OLD | NEW |