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

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

Issue 16959022: cc: Make tiles that are not required by trees NEVER_BIN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « no previous file | cc/resources/tile_manager_unittest.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_manager.h" 5 #include "cc/resources/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits>
8 #include <string> 9 #include <string>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "cc/debug/devtools_instrumentation.h" 15 #include "cc/debug/devtools_instrumentation.h"
15 #include "cc/debug/traced_value.h" 16 #include "cc/debug/traced_value.h"
16 #include "cc/resources/image_raster_worker_pool.h" 17 #include "cc/resources/image_raster_worker_pool.h"
17 #include "cc/resources/pixel_buffer_raster_worker_pool.h" 18 #include "cc/resources/pixel_buffer_raster_worker_pool.h"
(...skipping 11 matching lines...) Expand all
29 TreePriority tree_priority) { 30 TreePriority tree_priority) {
30 // The amount of time for which we want to have prepainting coverage. 31 // The amount of time for which we want to have prepainting coverage.
31 const float kPrepaintingWindowTimeSeconds = 1.0f; 32 const float kPrepaintingWindowTimeSeconds = 1.0f;
32 const float kBackflingGuardDistancePixels = 314.0f; 33 const float kBackflingGuardDistancePixels = 314.0f;
33 34
34 // Don't let low res tiles be in the now bin unless we're in a mode where 35 // Don't let low res tiles be in the now bin unless we're in a mode where
35 // we're prioritizing checkerboard prevention. 36 // we're prioritizing checkerboard prevention.
36 bool can_be_in_now_bin = tree_priority == SMOOTHNESS_TAKES_PRIORITY || 37 bool can_be_in_now_bin = tree_priority == SMOOTHNESS_TAKES_PRIORITY ||
37 prio.resolution != LOW_RESOLUTION; 38 prio.resolution != LOW_RESOLUTION;
38 39
40 if (prio.distance_to_visible_in_pixels ==
41 std::numeric_limits<float>::infinity())
42 return NEVER_BIN;
43
39 if (can_be_in_now_bin && prio.time_to_visible_in_seconds == 0) 44 if (can_be_in_now_bin && prio.time_to_visible_in_seconds == 0)
40 return NOW_BIN; 45 return NOW_BIN;
41 46
42 if (prio.resolution == NON_IDEAL_RESOLUTION) 47 if (prio.resolution == NON_IDEAL_RESOLUTION)
43 return EVENTUALLY_BIN; 48 return EVENTUALLY_BIN;
44 49
45 if (prio.distance_to_visible_in_pixels < kBackflingGuardDistancePixels || 50 if (prio.distance_to_visible_in_pixels < kBackflingGuardDistancePixels ||
46 prio.time_to_visible_in_seconds < kPrepaintingWindowTimeSeconds) 51 prio.time_to_visible_in_seconds < kPrepaintingWindowTimeSeconds)
47 return SOON_BIN; 52 return SOON_BIN;
48 53
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 510 }
506 } 511 }
507 512
508 // In OOM situation, we iterate tiles_, remove the memory for active tree 513 // In OOM situation, we iterate tiles_, remove the memory for active tree
509 // and not the now bin. And give them to bytes_oom_in_now_bin_on_pending_tree 514 // and not the now bin. And give them to bytes_oom_in_now_bin_on_pending_tree
510 if (!tiles_requiring_memory_but_oomed.empty()) { 515 if (!tiles_requiring_memory_but_oomed.empty()) {
511 size_t bytes_freed = 0; 516 size_t bytes_freed = 0;
512 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 517 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
513 Tile* tile = *it; 518 Tile* tile = *it;
514 ManagedTileState& mts = tile->managed_state(); 519 ManagedTileState& mts = tile->managed_state();
520 ManagedTileState::TileVersion& tile_version =
521 mts.tile_versions[mts.raster_mode];
515 if (mts.tree_bin[PENDING_TREE] == NEVER_BIN && 522 if (mts.tree_bin[PENDING_TREE] == NEVER_BIN &&
516 mts.tree_bin[ACTIVE_TREE] != NOW_BIN) { 523 mts.tree_bin[ACTIVE_TREE] != NOW_BIN) {
517 size_t bytes_that_can_be_freed = 0; 524 size_t bytes_that_can_be_freed = 0;
525
526 // If the tile is in the to-rasterize list, but it has no task,
527 // then it means that we have assigned memory for it.
528 TileVector::iterator raster_it =
529 std::find(tiles_that_need_to_be_rasterized_.begin(),
530 tiles_that_need_to_be_rasterized_.end(),
531 tile);
532 if (raster_it != tiles_that_need_to_be_rasterized_.end() &&
533 tile_version.raster_task_.is_null()) {
534 bytes_that_can_be_freed += tile->bytes_consumed_if_allocated();
535 }
536
537 // Also consider all of the completed resources for freeing.
518 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { 538 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) {
519 ManagedTileState::TileVersion& tile_version = 539 ManagedTileState::TileVersion& tile_version =
520 mts.tile_versions[mode]; 540 mts.tile_versions[mode];
521 if (tile_version.resource_) { 541 if (tile_version.resource_) {
522 DCHECK(!tile->required_for_activation()); 542 DCHECK(!tile->required_for_activation());
523 bytes_that_can_be_freed += tile->bytes_consumed_if_allocated(); 543 bytes_that_can_be_freed += tile->bytes_consumed_if_allocated();
524 } 544 }
525 } 545 }
526 546
547 // If we can free anything, then do so.
527 if (bytes_that_can_be_freed > 0) { 548 if (bytes_that_can_be_freed > 0) {
528 FreeResourcesForTile(tile); 549 FreeResourcesForTile(tile);
529 bytes_freed += bytes_that_can_be_freed; 550 bytes_freed += bytes_that_can_be_freed;
530 mts.tile_versions[mts.raster_mode].set_rasterize_on_demand(); 551 mts.tile_versions[mts.raster_mode].set_rasterize_on_demand();
531 TileVector::iterator it = std::find( 552 if (raster_it != tiles_that_need_to_be_rasterized_.end())
532 tiles_that_need_to_be_rasterized_.begin(), 553 tiles_that_need_to_be_rasterized_.erase(raster_it);
533 tiles_that_need_to_be_rasterized_.end(),
534 tile);
535 if (it != tiles_that_need_to_be_rasterized_.end())
536 tiles_that_need_to_be_rasterized_.erase(it);
537 } 554 }
538 } 555 }
539 556
540 if (bytes_oom_in_now_bin_on_pending_tree <= bytes_freed) 557 if (bytes_oom_in_now_bin_on_pending_tree <= bytes_freed)
541 break; 558 break;
542 } 559 }
543 560
544 for (TileVector::iterator it = tiles_requiring_memory_but_oomed.begin(); 561 for (TileVector::iterator it = tiles_requiring_memory_but_oomed.begin();
545 it != tiles_requiring_memory_but_oomed.end() && bytes_freed > 0; 562 it != tiles_requiring_memory_but_oomed.end() && bytes_freed > 0;
546 ++it) { 563 ++it) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 } 817 }
801 818
802 void TileManager::DidTileTreeBinChange(Tile* tile, 819 void TileManager::DidTileTreeBinChange(Tile* tile,
803 TileManagerBin new_tree_bin, 820 TileManagerBin new_tree_bin,
804 WhichTree tree) { 821 WhichTree tree) {
805 ManagedTileState& mts = tile->managed_state(); 822 ManagedTileState& mts = tile->managed_state();
806 mts.tree_bin[tree] = new_tree_bin; 823 mts.tree_bin[tree] = new_tree_bin;
807 } 824 }
808 825
809 } // namespace cc 826 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698