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/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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 int max_tiles_; | 152 int max_tiles_; |
153 bool ready_to_activate_; | 153 bool ready_to_activate_; |
154 std::vector<PictureLayerImpl*> picture_layers_; | 154 std::vector<PictureLayerImpl*> picture_layers_; |
155 }; | 155 }; |
156 | 156 |
157 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { | 157 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { |
158 // A few tiles of each type of priority, with enough memory for all tiles. | 158 // A few tiles of each type of priority, with enough memory for all tiles. |
159 | 159 |
160 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 160 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
161 TileVector active_now = | 161 TileVector active_now = |
162 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 162 CreateTiles(3, TilePriorityForUnoccludedNowBin(), TilePriority()); |
163 TileVector pending_now = | 163 TileVector pending_now = |
164 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 164 CreateTiles(3, TilePriority(), TilePriorityForUnoccludedNowBin()); |
165 TileVector active_pending_soon = | 165 TileVector active_pending_soon = |
166 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 166 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
167 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 167 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
168 | 168 |
169 tile_manager()->AssignMemoryToTiles(global_state_); | 169 tile_manager()->AssignMemoryToTiles(global_state_); |
170 | 170 |
171 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 171 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
172 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 172 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
173 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); | 173 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); |
174 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 174 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
175 } | 175 } |
176 | 176 |
177 TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { | 177 TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { |
178 // A few tiles of each type of priority, with enough memory for all tiles, | 178 // A few tiles of each type of priority, with enough memory for all tiles, |
179 // with the exception of never bin. | 179 // with the exception of never bin. |
180 | 180 |
181 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); | 181 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); |
182 TileVector active_now = | 182 TileVector active_now = |
183 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 183 CreateTiles(3, TilePriorityForUnoccludedNowBin(), TilePriority()); |
184 TileVector pending_now = | 184 TileVector pending_now = |
185 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 185 CreateTiles(3, TilePriority(), TilePriorityForUnoccludedNowBin()); |
186 TileVector active_pending_soon = | 186 TileVector active_pending_soon = |
187 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 187 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
188 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 188 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
189 | 189 |
190 tile_manager()->AssignMemoryToTiles(global_state_); | 190 tile_manager()->AssignMemoryToTiles(global_state_); |
191 | 191 |
192 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 192 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
193 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 193 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
194 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); | 194 EXPECT_EQ(3, AssignedMemoryCount(active_pending_soon)); |
195 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 195 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
196 } | 196 } |
197 | 197 |
198 TEST_P(TileManagerTest, EnoughMemoryPendingLowResAllowAbsoluteMinimum) { | 198 TEST_P(TileManagerTest, EnoughMemoryPendingLowResAllowAbsoluteMinimum) { |
199 // A few low-res tiles required for activation, with enough memory for all | 199 // A few low-res tiles required for activation, with enough memory for all |
200 // tiles. | 200 // tiles. |
201 | 201 |
202 Initialize(5, ALLOW_ABSOLUTE_MINIMUM, SAME_PRIORITY_FOR_BOTH_TREES); | 202 Initialize(5, ALLOW_ABSOLUTE_MINIMUM, SAME_PRIORITY_FOR_BOTH_TREES); |
203 TileVector pending_low_res = | 203 TileVector pending_low_res = |
204 CreateTiles(5, TilePriority(), TilePriorityLowRes()); | 204 CreateTiles(5, TilePriority(), TilePriorityUnoccludedLowRes()); |
205 | 205 |
206 tile_manager()->AssignMemoryToTiles(global_state_); | 206 tile_manager()->AssignMemoryToTiles(global_state_); |
207 | 207 |
208 EXPECT_EQ(5, AssignedMemoryCount(pending_low_res)); | 208 EXPECT_EQ(5, AssignedMemoryCount(pending_low_res)); |
209 } | 209 } |
210 | 210 |
211 TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { | 211 TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { |
212 // A few tiles of each type of priority, with enough memory for all tiles, | 212 // A few tiles of each type of priority, with enough memory for all tiles, |
213 // with the exception of never and soon bins. | 213 // with the exception of never and soon bins. |
214 | 214 |
215 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); | 215 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); |
216 TileVector active_now = | 216 TileVector active_now = |
217 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 217 CreateTiles(3, TilePriorityForUnoccludedNowBin(), TilePriority()); |
218 TileVector pending_now = | 218 TileVector pending_now = |
219 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 219 CreateTiles(3, TilePriority(), TilePriorityForUnoccludedNowBin()); |
220 TileVector active_pending_soon = | 220 TileVector active_pending_soon = |
221 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 221 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
222 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 222 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
223 | 223 |
224 tile_manager()->AssignMemoryToTiles(global_state_); | 224 tile_manager()->AssignMemoryToTiles(global_state_); |
225 | 225 |
226 EXPECT_EQ(3, AssignedMemoryCount(active_now)); | 226 EXPECT_EQ(3, AssignedMemoryCount(active_now)); |
227 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); | 227 EXPECT_EQ(3, AssignedMemoryCount(pending_now)); |
228 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); | 228 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); |
229 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 229 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
230 } | 230 } |
231 | 231 |
232 TEST_P(TileManagerTest, EnoughMemoryAllowNothing) { | 232 TEST_P(TileManagerTest, EnoughMemoryAllowNothing) { |
233 // A few tiles of each type of priority, with enough memory for all tiles, | 233 // A few tiles of each type of priority, with enough memory for all tiles, |
234 // but allow nothing should not assign any memory. | 234 // but allow nothing should not assign any memory. |
235 | 235 |
236 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); | 236 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); |
237 TileVector active_now = | 237 TileVector active_now = |
238 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 238 CreateTiles(3, TilePriorityForUnoccludedNowBin(), TilePriority()); |
239 TileVector pending_now = | 239 TileVector pending_now = |
240 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 240 CreateTiles(3, TilePriority(), TilePriorityForUnoccludedNowBin()); |
241 TileVector active_pending_soon = | 241 TileVector active_pending_soon = |
242 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 242 CreateTiles(3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
243 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 243 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
244 | 244 |
245 tile_manager()->AssignMemoryToTiles(global_state_); | 245 tile_manager()->AssignMemoryToTiles(global_state_); |
246 | 246 |
247 EXPECT_EQ(0, AssignedMemoryCount(active_now)); | 247 EXPECT_EQ(0, AssignedMemoryCount(active_now)); |
248 EXPECT_EQ(0, AssignedMemoryCount(pending_now)); | 248 EXPECT_EQ(0, AssignedMemoryCount(pending_now)); |
249 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); | 249 EXPECT_EQ(0, AssignedMemoryCount(active_pending_soon)); |
250 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); | 250 EXPECT_EQ(0, AssignedMemoryCount(never_bin)); |
251 } | 251 } |
252 | 252 |
253 TEST_P(TileManagerTest, PartialOOMMemoryToPending) { | 253 TEST_P(TileManagerTest, PartialOOMMemoryToPending) { |
254 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are | 254 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
255 // required for activation, but only enough memory for 8 tiles. The result | 255 // required for activation, but only enough memory for 8 tiles. The result |
256 // is all pending tree tiles get memory, and 3 of the active tree tiles | 256 // is all pending tree tiles get memory, and 3 of the active tree tiles |
257 // get memory. None of these tiles is needed to avoid calimity (flickering or | 257 // get memory. None of these tiles is needed to avoid calimity (flickering or |
258 // raster-on-demand) so the soft memory limit is used. | 258 // raster-on-demand) so the soft memory limit is used. |
259 | 259 |
260 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 260 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
261 TileVector active_tree_tiles = | 261 TileVector active_tree_tiles = |
262 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); | 262 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
263 TileVector pending_tree_tiles = | 263 TileVector pending_tree_tiles = CreateTiles( |
264 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); | 264 5, TilePriority(), TilePriorityUnoccludedRequiredForActivation()); |
265 tile_manager()->AssignMemoryToTiles(global_state_); | 265 tile_manager()->AssignMemoryToTiles(global_state_); |
266 | 266 |
267 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); | 267 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); |
268 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); | 268 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); |
269 | 269 |
270 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 270 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
271 tile_manager()->AssignMemoryToTiles(global_state_); | 271 tile_manager()->AssignMemoryToTiles(global_state_); |
272 | 272 |
273 EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles)); | 273 EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles)); |
274 EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles)); | 274 EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles)); |
275 } | 275 } |
276 | 276 |
277 TEST_P(TileManagerTest, PartialOOMMemoryToActive) { | 277 TEST_P(TileManagerTest, PartialOOMMemoryToActive) { |
278 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, | 278 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
279 // but only enough memory for 8 tiles. The result is all active tree tiles | 279 // but only enough memory for 8 tiles. The result is all active tree tiles |
280 // get memory, and 3 of the pending tree tiles get memory. | 280 // get memory, and 3 of the pending tree tiles get memory. |
281 // The pending tiles are not needed to avoid calimity (flickering or | 281 // The pending tiles are not needed to avoid calimity (flickering or |
282 // raster-on-demand) and the active tiles fit, so the soft limit is used. | 282 // raster-on-demand) and the active tiles fit, so the soft limit is used. |
283 | 283 |
284 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 284 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
285 TileVector active_tree_tiles = | 285 TileVector active_tree_tiles = |
286 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); | 286 CreateTiles(5, TilePriorityForUnoccludedNowBin(), TilePriority()); |
287 TileVector pending_tree_tiles = | 287 TileVector pending_tree_tiles = |
288 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); | 288 CreateTiles(5, TilePriority(), TilePriorityForUnoccludedNowBin()); |
289 | 289 |
290 tile_manager()->AssignMemoryToTiles(global_state_); | 290 tile_manager()->AssignMemoryToTiles(global_state_); |
291 | 291 |
292 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); | 292 EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles)); |
293 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); | 293 EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles)); |
294 } | 294 } |
295 | 295 |
296 TEST_P(TileManagerTest, TotalOOMMemoryToPending) { | 296 TEST_P(TileManagerTest, TotalOOMMemoryToPending) { |
297 // 10 tiles on active tree eventually bin, 10 tiles on pending tree that are | 297 // 10 tiles on active tree eventually bin, 10 tiles on pending tree that are |
298 // required for activation, but only enough tiles for 4 tiles. The result | 298 // required for activation, but only enough tiles for 4 tiles. The result |
299 // is 4 pending tree tiles get memory, and none of the active tree tiles | 299 // is 4 pending tree tiles get memory, and none of the active tree tiles |
300 // get memory. | 300 // get memory. |
301 | 301 |
302 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 302 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
303 TileVector active_tree_tiles = | 303 TileVector active_tree_tiles = |
304 CreateTiles(10, TilePriorityForEventualBin(), TilePriority()); | 304 CreateTiles(10, TilePriorityForEventualBin(), TilePriority()); |
305 TileVector pending_tree_tiles = | 305 TileVector pending_tree_tiles = CreateTiles( |
306 CreateTiles(10, TilePriority(), TilePriorityRequiredForActivation()); | 306 10, TilePriority(), TilePriorityUnoccludedRequiredForActivation()); |
307 | 307 |
308 tile_manager()->AssignMemoryToTiles(global_state_); | 308 tile_manager()->AssignMemoryToTiles(global_state_); |
309 | 309 |
310 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); | 310 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); |
311 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 311 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
312 | 312 |
313 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 313 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
314 tile_manager()->AssignMemoryToTiles(global_state_); | 314 tile_manager()->AssignMemoryToTiles(global_state_); |
315 | 315 |
316 if (UsingResourceLimit()) { | 316 if (UsingResourceLimit()) { |
317 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 317 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
318 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); | 318 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); |
319 } else { | 319 } else { |
320 // Pending tiles are now required to avoid calimity (flickering or | 320 // Pending tiles are now required to avoid calimity (flickering or |
321 // raster-on-demand). Hard-limit is used and double the tiles fit. | 321 // raster-on-demand). Hard-limit is used and double the tiles fit. |
322 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 322 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
323 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); | 323 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { | 327 TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { |
328 // 10 tiles on active tree soon bin, 10 tiles on pending tree that are | 328 // 10 tiles on active tree soon bin, 10 tiles on pending tree that are |
329 // required for activation, but only enough tiles for 4 tiles. The result | 329 // required for activation, but only enough tiles for 4 tiles. The result |
330 // is 4 pending tree tiles get memory, and none of the active tree tiles | 330 // is 4 pending tree tiles get memory, and none of the active tree tiles |
331 // get memory. | 331 // get memory. |
332 | 332 |
333 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 333 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
334 TileVector active_tree_tiles = | 334 TileVector active_tree_tiles = |
335 CreateTiles(10, TilePriorityForSoonBin(), TilePriority()); | 335 CreateTiles(10, TilePriorityForSoonBin(), TilePriority()); |
336 TileVector pending_tree_tiles = | 336 TileVector pending_tree_tiles = CreateTiles( |
337 CreateTiles(10, TilePriority(), TilePriorityRequiredForActivation()); | 337 10, TilePriority(), TilePriorityUnoccludedRequiredForActivation()); |
338 | 338 |
339 tile_manager()->AssignMemoryToTiles(global_state_); | 339 tile_manager()->AssignMemoryToTiles(global_state_); |
340 | 340 |
341 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); | 341 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); |
342 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 342 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
343 | 343 |
344 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 344 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
345 tile_manager()->AssignMemoryToTiles(global_state_); | 345 tile_manager()->AssignMemoryToTiles(global_state_); |
346 | 346 |
347 if (UsingResourceLimit()) { | 347 if (UsingResourceLimit()) { |
348 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 348 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
349 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); | 349 EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles)); |
350 } else { | 350 } else { |
351 // Pending tiles are now required to avoid calimity (flickering or | 351 // Pending tiles are now required to avoid calimity (flickering or |
352 // raster-on-demand). Hard-limit is used and double the tiles fit. | 352 // raster-on-demand). Hard-limit is used and double the tiles fit. |
353 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); | 353 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); |
354 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); | 354 EXPECT_EQ(8, AssignedMemoryCount(pending_tree_tiles)); |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 TEST_P(TileManagerTest, TotalOOMMemoryToActive) { | 358 TEST_P(TileManagerTest, TotalOOMMemoryToActive) { |
359 // 10 tiles on active tree eventually bin, 10 tiles on pending tree now bin, | 359 // 10 tiles on active tree eventually bin, 10 tiles on pending tree now bin, |
360 // but only enough memory for 4 tiles. The result is 4 active tree tiles | 360 // but only enough memory for 4 tiles. The result is 4 active tree tiles |
361 // get memory, and none of the pending tree tiles get memory. | 361 // get memory, and none of the pending tree tiles get memory. |
362 | 362 |
363 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 363 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
364 TileVector active_tree_tiles = | 364 TileVector active_tree_tiles = |
365 CreateTiles(10, TilePriorityForNowBin(), TilePriority()); | 365 CreateTiles(10, TilePriorityForUnoccludedNowBin(), TilePriority()); |
366 TileVector pending_tree_tiles = | 366 TileVector pending_tree_tiles = |
367 CreateTiles(10, TilePriority(), TilePriorityForNowBin()); | 367 CreateTiles(10, TilePriority(), TilePriorityForUnoccludedNowBin()); |
368 | 368 |
369 tile_manager()->AssignMemoryToTiles(global_state_); | 369 tile_manager()->AssignMemoryToTiles(global_state_); |
370 | 370 |
371 if (UsingResourceLimit()) { | 371 if (UsingResourceLimit()) { |
372 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); | 372 EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles)); |
373 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 373 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
374 } else { | 374 } else { |
375 // Active tiles are required to avoid calimity (flickering or | 375 // Active tiles are required to avoid calimity (flickering or |
376 // raster-on-demand). Hard-limit is used and double the tiles fit. | 376 // raster-on-demand). Hard-limit is used and double the tiles fit. |
377 EXPECT_EQ(8, AssignedMemoryCount(active_tree_tiles)); | 377 EXPECT_EQ(8, AssignedMemoryCount(active_tree_tiles)); |
378 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 378 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { | 382 TEST_P(TileManagerTest, TotalOOMMemoryToNewContent) { |
383 // 10 tiles on active tree now bin, 10 tiles on pending tree now bin, | 383 // 10 tiles on active tree now bin, 10 tiles on pending tree now bin, |
384 // but only enough memory for 8 tiles. Any tile missing would cause | 384 // but only enough memory for 8 tiles. Any tile missing would cause |
385 // a calamity (flickering or raster-on-demand). Depending on mode, | 385 // a calamity (flickering or raster-on-demand). Depending on mode, |
386 // we should use varying amounts of the higher hard memory limit. | 386 // we should use varying amounts of the higher hard memory limit. |
387 if (UsingResourceLimit()) | 387 if (UsingResourceLimit()) |
388 return; | 388 return; |
389 | 389 |
390 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 390 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
391 TileVector active_tree_tiles = | 391 TileVector active_tree_tiles = |
392 CreateTiles(10, TilePriorityForNowBin(), TilePriority()); | 392 CreateTiles(10, TilePriorityForUnoccludedNowBin(), TilePriority()); |
393 TileVector pending_tree_tiles = | 393 TileVector pending_tree_tiles = |
394 CreateTiles(10, TilePriority(), TilePriorityForNowBin()); | 394 CreateTiles(10, TilePriority(), TilePriorityForUnoccludedNowBin()); |
395 | 395 |
396 // Active tiles are required to avoid calimity. The hard-limit is used and all | 396 // Active tiles are required to avoid calimity. The hard-limit is used and all |
397 // active-tiles fit. No pending tiles are needed to avoid calamity so only 10 | 397 // active-tiles fit. No pending tiles are needed to avoid calamity so only 10 |
398 // tiles total are used. | 398 // tiles total are used. |
399 tile_manager()->AssignMemoryToTiles(global_state_); | 399 tile_manager()->AssignMemoryToTiles(global_state_); |
400 EXPECT_EQ(10, AssignedMemoryCount(active_tree_tiles)); | 400 EXPECT_EQ(10, AssignedMemoryCount(active_tree_tiles)); |
401 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); | 401 EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles)); |
402 | 402 |
403 // Even the hard-limit won't save us now. All tiles are required to avoid | 403 // Even the hard-limit won't save us now. All tiles are required to avoid |
404 // a clamity but we only have 16. The tiles will be distribted randomly | 404 // a clamity but we only have 16. The tiles will be distribted randomly |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 950 |
951 last_tile = tile; | 951 last_tile = tile; |
952 new_content_tiles.insert(tile); | 952 new_content_tiles.insert(tile); |
953 } | 953 } |
954 | 954 |
955 EXPECT_EQ(tile_count, new_content_tiles.size()); | 955 EXPECT_EQ(tile_count, new_content_tiles.size()); |
956 EXPECT_EQ(all_tiles, new_content_tiles); | 956 EXPECT_EQ(all_tiles, new_content_tiles); |
957 } | 957 } |
958 } // namespace | 958 } // namespace |
959 } // namespace cc | 959 } // namespace cc |
OLD | NEW |