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

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

Issue 342483007: Removed ManagedMemoryStats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/test/fake_layer_tree_host_impl_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 // The pending tree is now more important. Active tiles will take higher 412 // The pending tree is now more important. Active tiles will take higher
413 // priority if they are ready-to-draw in practice. Importantly though, 413 // priority if they are ready-to-draw in practice. Importantly though,
414 // pending tiles also utilize the hard-limit. 414 // pending tiles also utilize the hard-limit.
415 SetTreePriority(NEW_CONTENT_TAKES_PRIORITY); 415 SetTreePriority(NEW_CONTENT_TAKES_PRIORITY);
416 tile_manager()->AssignMemoryToTiles(global_state_); 416 tile_manager()->AssignMemoryToTiles(global_state_);
417 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles)); 417 EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles));
418 EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles)); 418 EXPECT_EQ(10, AssignedMemoryCount(pending_tree_tiles));
419 } 419 }
420 420
421 TEST_P(TileManagerTest, RespectMemoryLimit) {
422 if (UsingResourceLimit())
423 return;
424
425 Initialize(5, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY);
426
427 // We use double the tiles since the hard-limit is double.
428 TileVector large_tiles =
429 CreateTiles(10, TilePriorityForNowBin(), TilePriority());
430
431 size_t memory_required_bytes;
432 size_t memory_nice_to_have_bytes;
433 size_t memory_allocated_bytes;
434 size_t memory_used_bytes;
435
436 tile_manager()->AssignMemoryToTiles(global_state_);
437 tile_manager()->GetMemoryStats(&memory_required_bytes,
438 &memory_nice_to_have_bytes,
439 &memory_allocated_bytes,
440 &memory_used_bytes);
441 // Allocated bytes should never be more than the memory limit.
442 EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes);
443
444 // Finish raster of large tiles.
445 tile_manager()->UpdateVisibleTiles();
446
447 // Remove all large tiles. This will leave the memory currently
448 // used by these tiles as unused when AssignMemoryToTiles() is called.
449 large_tiles.clear();
450
451 // Create a new set of tiles using a different size. These tiles
452 // can use the memory currently assigned to the large tiles but
453 // they can't use the same resources as the size doesn't match.
454 TileVector small_tiles = CreateTilesWithSize(
455 10, TilePriorityForNowBin(), TilePriority(), gfx::Size(128, 128));
456
457 tile_manager()->AssignMemoryToTiles(global_state_);
458 tile_manager()->GetMemoryStats(&memory_required_bytes,
459 &memory_nice_to_have_bytes,
460 &memory_allocated_bytes,
461 &memory_used_bytes);
462 // Allocated bytes should never be more than the memory limit.
463 EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes);
464 }
465
466 // If true, the max tile limit should be applied as bytes; if false, 421 // If true, the max tile limit should be applied as bytes; if false,
467 // as num_resources_limit. 422 // as num_resources_limit.
468 INSTANTIATE_TEST_CASE_P(TileManagerTests, 423 INSTANTIATE_TEST_CASE_P(TileManagerTests,
469 TileManagerTest, 424 TileManagerTest,
470 ::testing::Values(true, false)); 425 ::testing::Values(true, false));
471 426
472 class TileManagerTileIteratorTest : public testing::Test { 427 class TileManagerTileIteratorTest : public testing::Test {
473 public: 428 public:
474 TileManagerTileIteratorTest() 429 TileManagerTileIteratorTest()
475 : memory_limit_policy_(ALLOW_ANYTHING), 430 : memory_limit_policy_(ALLOW_ANYTHING),
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 902
948 last_tile = tile; 903 last_tile = tile;
949 new_content_tiles.insert(tile); 904 new_content_tiles.insert(tile);
950 } 905 }
951 906
952 EXPECT_EQ(tile_count, new_content_tiles.size()); 907 EXPECT_EQ(tile_count, new_content_tiles.size());
953 EXPECT_EQ(all_tiles, new_content_tiles); 908 EXPECT_EQ(all_tiles, new_content_tiles);
954 } 909 }
955 } // namespace 910 } // namespace
956 } // namespace cc 911 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/test/fake_layer_tree_host_impl_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698