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

Side by Side Diff: src/core/SkScaledImageCache.cpp

Issue 185263009: Replace scaled bitmap if entry already exist in cache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unit test Created 6 years, 9 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 | tests/ImageCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkScaledImageCache.h" 8 #include "SkScaledImageCache.h"
9 #include "SkMipMap.h" 9 #include "SkMipMap.h"
10 #include "SkOnce.h" 10 #include "SkOnce.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 /** 418 /**
419 This private method is the fully general record adder. All other 419 This private method is the fully general record adder. All other
420 record adders should call this funtion. */ 420 record adders should call this funtion. */
421 SkScaledImageCache::ID* SkScaledImageCache::addAndLock(SkScaledImageCache::Rec* rec) { 421 SkScaledImageCache::ID* SkScaledImageCache::addAndLock(SkScaledImageCache::Rec* rec) {
422 SkASSERT(rec); 422 SkASSERT(rec);
423 // See if we already have this key (racy inserts, etc.) 423 // See if we already have this key (racy inserts, etc.)
424 Rec* existing = this->findAndLock(rec->fKey); 424 Rec* existing = this->findAndLock(rec->fKey);
425 if (NULL != existing) { 425 if (NULL != existing) {
426 // Since we already have a matching entry, just delete the new one and r eturn. 426 // Since we already have a matching entry, just delete the new one and r eturn.
427 // Call sites cannot assume the passed in object will live past this cal l. 427 // Call sites cannot assume the passed in object will live past this cal l.
428 existing->fBitmap = rec->fBitmap;
428 SkDELETE(rec); 429 SkDELETE(rec);
429 return rec_to_id(existing); 430 return rec_to_id(existing);
430 } 431 }
431 432
432 this->addToHead(rec); 433 this->addToHead(rec);
433 SkASSERT(1 == rec->fLockCount); 434 SkASSERT(1 == rec->fLockCount);
434 #ifdef USE_HASH 435 #ifdef USE_HASH
435 SkASSERT(fHash); 436 SkASSERT(fHash);
436 fHash->add(rec); 437 fHash->add(rec);
437 #endif 438 #endif
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return SkScaledImageCache::GetBytesUsed(); 789 return SkScaledImageCache::GetBytesUsed();
789 } 790 }
790 791
791 size_t SkGraphics::GetImageCacheByteLimit() { 792 size_t SkGraphics::GetImageCacheByteLimit() {
792 return SkScaledImageCache::GetByteLimit(); 793 return SkScaledImageCache::GetByteLimit();
793 } 794 }
794 795
795 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { 796 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) {
796 return SkScaledImageCache::SetByteLimit(newLimit); 797 return SkScaledImageCache::SetByteLimit(newLimit);
797 } 798 }
OLDNEW
« no previous file with comments | « no previous file | tests/ImageCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698