Skip to content

Commit

Permalink
Renamed some cache size constants that shared names.
Browse files Browse the repository at this point in the history
Both the GPU image cache and the software image cache
used the same name for its cache size constants. This caused
collisions in jumbo builds where the cc files were
compiled together in the same translation unit.

Bug: 786956
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ic6a66f45daacc94040e1cc11410b85d674651548
Reviewed-on: https://chromium-review.googlesource.com/779401
Reviewed-by: enne <enne@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#518228}
  • Loading branch information
bratell-at-opera authored and Commit Bot committed Nov 21, 2017
1 parent 4e14dc3 commit 5040a36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions cc/tiles/gpu_image_decode_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace {
// The number or entries to keep in the cache, depending on the memory state of
// the system. This limit can be breached by in-use cache items, which cannot
// be deleted.
static const int kNormalMaxItemsInCache = 2000;
static const int kThrottledMaxItemsInCache = 100;
static const int kSuspendedMaxItemsInCache = 0;
static const int kNormalMaxItemsInCacheForGpu = 2000;
static const int kThrottledMaxItemsInCacheForGpu = 100;
static const int kSuspendedMaxItemsInCacheForGpu = 0;

// lock_count │ used │ result state
// ═══════════╪═══════╪══════════════════
Expand Down Expand Up @@ -1182,14 +1182,14 @@ bool GpuImageDecodeCache::ExceedsPreferredCount() const {

size_t items_limit;
if (aggressively_freeing_resources_) {
items_limit = kSuspendedMaxItemsInCache;
items_limit = kSuspendedMaxItemsInCacheForGpu;
} else if (memory_state_ == base::MemoryState::NORMAL) {
items_limit = kNormalMaxItemsInCache;
items_limit = kNormalMaxItemsInCacheForGpu;
} else if (memory_state_ == base::MemoryState::THROTTLED) {
items_limit = kThrottledMaxItemsInCache;
items_limit = kThrottledMaxItemsInCacheForGpu;
} else {
DCHECK_EQ(base::MemoryState::SUSPENDED, memory_state_);
items_limit = kSuspendedMaxItemsInCache;
items_limit = kSuspendedMaxItemsInCacheForGpu;
}

return persistent_cache_.size() > items_limit;
Expand Down
14 changes: 7 additions & 7 deletions cc/tiles/software_image_decode_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace {
// if more items are locked. That is, locked items ignore this limit.
// Depending on the memory state of the system, we limit the amount of items
// differently.
const size_t kNormalMaxItemsInCache = 1000;
const size_t kThrottledMaxItemsInCache = 100;
const size_t kSuspendedMaxItemsInCache = 0;
const size_t kNormalMaxItemsInCacheForSoftware = 1000;
const size_t kThrottledMaxItemsInCacheForSoftware = 100;
const size_t kSuspendedMaxItemsInCacheForSoftware = 0;

// If the size of the original sized image breaches kMemoryRatioToSubrect but we
// don't need to scale the image, consider caching only the needed subrect.
Expand Down Expand Up @@ -197,7 +197,7 @@ SoftwareImageDecodeCache::SoftwareImageDecodeCache(
at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT),
locked_images_budget_(locked_memory_limit_bytes),
color_type_(color_type),
max_items_in_cache_(kNormalMaxItemsInCache) {
max_items_in_cache_(kNormalMaxItemsInCacheForSoftware) {
// In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
// Don't register a dump provider in these cases.
if (base::ThreadTaskRunnerHandle::IsSet()) {
Expand Down Expand Up @@ -1221,13 +1221,13 @@ void SoftwareImageDecodeCache::OnMemoryStateChange(base::MemoryState state) {
base::AutoLock hold(lock_);
switch (state) {
case base::MemoryState::NORMAL:
max_items_in_cache_ = kNormalMaxItemsInCache;
max_items_in_cache_ = kNormalMaxItemsInCacheForSoftware;
break;
case base::MemoryState::THROTTLED:
max_items_in_cache_ = kThrottledMaxItemsInCache;
max_items_in_cache_ = kThrottledMaxItemsInCacheForSoftware;
break;
case base::MemoryState::SUSPENDED:
max_items_in_cache_ = kSuspendedMaxItemsInCache;
max_items_in_cache_ = kSuspendedMaxItemsInCacheForSoftware;
break;
case base::MemoryState::UNKNOWN:
NOTREACHED();
Expand Down

0 comments on commit 5040a36

Please sign in to comment.