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

Unified Diff: cc/resources/prioritized_resource_manager.cc

Issue 1154393003: cc: Use CheckedNumeric for resource size calculations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: initialize var Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/prioritized_resource.cc ('k') | cc/resources/prioritized_resource_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/prioritized_resource_manager.cc
diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc
index dc1786212370d55502c55e5494d53eb9d52a6a5b..924012172b906bad3a7b1fcc959cf58555fce141 100644
--- a/cc/resources/prioritized_resource_manager.cc
+++ b/cc/resources/prioritized_resource_manager.cc
@@ -256,8 +256,7 @@ void PrioritizedResourceManager::AcquireBackingTextureIfNeeded(
if (!backing) {
EvictBackingsToReduceMemory(memory_available_bytes_ - texture->bytes(),
PriorityCalculator::AllowEverythingCutoff(),
- EVICT_ONLY_RECYCLABLE,
- DO_NOT_UNLINK_BACKINGS,
+ EVICT_ONLY_RECYCLABLE, DO_NOT_UNLINK_BACKINGS,
resource_provider);
backing =
CreateBacking(texture->size(), texture->format(), resource_provider);
@@ -323,7 +322,8 @@ void PrioritizedResourceManager::ReduceWastedMemory(
break;
if ((*it)->in_parent_compositor())
continue;
- wasted_memory += (*it)->bytes();
+ wasted_memory +=
+ Resource::UncheckedMemorySizeBytes((*it)->size(), (*it)->format());
}
size_t wasted_memory_to_allow = memory_available_bytes_ / 10;
// If the external priority cutoff indicates that unused memory should be
@@ -454,7 +454,8 @@ PrioritizedResource::Backing* PrioritizedResourceManager::CreateBacking(
ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(
resource_id, resource_provider, size, format);
- memory_use_bytes_ += backing->bytes();
+ memory_use_bytes_ +=
+ Resource::UncheckedMemorySizeBytes(backing->size(), backing->format());
return backing;
}
@@ -470,7 +471,8 @@ void PrioritizedResourceManager::EvictFirstBackingResource(
// we can delete the resource while the main thread is running, but we cannot
// unlink backings while the main thread is running.
backing->DeleteResource(resource_provider);
- memory_use_bytes_ -= backing->bytes();
+ memory_use_bytes_ -=
+ Resource::UncheckedMemorySizeBytes(backing->size(), backing->format());
backings_.pop_front();
base::AutoLock scoped_lock(evicted_backings_lock_);
evicted_backings_.push_back(backing);
« no previous file with comments | « cc/resources/prioritized_resource.cc ('k') | cc/resources/prioritized_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698