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

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

Issue 22292004: revise SkTDynamicHash and add unit tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | « gyp/tests.gyp ('k') | src/core/SkTDynamicHash.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 /* 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 "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 Key key; 243 Key key;
244 if (!key.init(orig, scaleX, scaleY)) { 244 if (!key.init(orig, scaleX, scaleY)) {
245 return NULL; 245 return NULL;
246 } 246 }
247 247
248 Rec* rec = SkNEW_ARGS(Rec, (key, scaled)); 248 Rec* rec = SkNEW_ARGS(Rec, (key, scaled));
249 this->addToHead(rec); 249 this->addToHead(rec);
250 SkASSERT(1 == rec->fLockCount); 250 SkASSERT(1 == rec->fLockCount);
251 251
252 #ifdef USE_HASH 252 #ifdef USE_HASH
253 fHash->add(key, rec); 253 fHash->add(rec);
254 #endif 254 #endif
255 255
256 // We may (now) be overbudget, so see if we need to purge something. 256 // We may (now) be overbudget, so see if we need to purge something.
257 this->purgeAsNeeded(); 257 this->purgeAsNeeded();
258 return (ID*)rec; 258 return (ID*)rec;
259 } 259 }
260 260
261 SkScaledImageCache::ID* SkScaledImageCache::addAndLockMip(const SkBitmap& orig, 261 SkScaledImageCache::ID* SkScaledImageCache::addAndLockMip(const SkBitmap& orig,
262 const SkMipMap* mip) { 262 const SkMipMap* mip) {
263 Key key; 263 Key key;
264 if (!key.init(orig, 0, 0)) { 264 if (!key.init(orig, 0, 0)) {
265 return NULL; 265 return NULL;
266 } 266 }
267 267
268 Rec* rec = SkNEW_ARGS(Rec, (key, mip)); 268 Rec* rec = SkNEW_ARGS(Rec, (key, mip));
269 this->addToHead(rec); 269 this->addToHead(rec);
270 SkASSERT(1 == rec->fLockCount); 270 SkASSERT(1 == rec->fLockCount);
271 271
272 #ifdef USE_HASH 272 #ifdef USE_HASH
273 fHash->add(key, rec); 273 fHash->add(rec);
274 #endif 274 #endif
275 275
276 // We may (now) be overbudget, so see if we need to purge something. 276 // We may (now) be overbudget, so see if we need to purge something.
277 this->purgeAsNeeded(); 277 this->purgeAsNeeded();
278 return (ID*)rec; 278 return (ID*)rec;
279 } 279 }
280 280
281 void SkScaledImageCache::unlock(SkScaledImageCache::ID* id) { 281 void SkScaledImageCache::unlock(SkScaledImageCache::ID* id) {
282 SkASSERT(id); 282 SkASSERT(id);
283 283
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 return SkScaledImageCache::GetBytesUsed(); 516 return SkScaledImageCache::GetBytesUsed();
517 } 517 }
518 518
519 size_t SkGraphics::GetImageCacheByteLimit() { 519 size_t SkGraphics::GetImageCacheByteLimit() {
520 return SkScaledImageCache::GetByteLimit(); 520 return SkScaledImageCache::GetByteLimit();
521 } 521 }
522 522
523 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { 523 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) {
524 return SkScaledImageCache::SetByteLimit(newLimit); 524 return SkScaledImageCache::SetByteLimit(newLimit);
525 } 525 }
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkTDynamicHash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698