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

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

Issue 561953002: Make SkBitmapCache remove invalid bitmaps from the SkResourceCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cache: Created 6 years, 3 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 | « gyp/common.gypi ('k') | src/core/SkResourceCache.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 2014 Google Inc. 2 * Copyright 2014 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 static bool find_and_return(const BitmapKey& key, SkBitmap* result) { 64 static bool find_and_return(const BitmapKey& key, SkBitmap* result) {
65 const BitmapRec* rec = (BitmapRec*)SkResourceCache::FindAndLock(key); 65 const BitmapRec* rec = (BitmapRec*)SkResourceCache::FindAndLock(key);
66 if (rec) { 66 if (rec) {
67 *result = rec->fBitmap; 67 *result = rec->fBitmap;
68 SkResourceCache::Unlock(rec); 68 SkResourceCache::Unlock(rec);
69 69
70 result->lockPixels(); 70 result->lockPixels();
71 if (result->getPixels()) { 71 if (result->getPixels()) {
72 return true; 72 return true;
73 } 73 }
74 // todo: we should explicitly purge rec from the cache at this point, si nce 74
75 // it is effectively purged already (has no memory behind it) 75 SkResourceCache::Remove(rec);
76 result->reset(); 76 result->reset();
77 // fall-through to false 77 // fall-through to false
78 } 78 }
79 return false; 79 return false;
80 } 80 }
81 81
82 bool SkBitmapCache::Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invSc aleY, 82 bool SkBitmapCache::Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invSc aleY,
83 SkBitmap* result) { 83 SkBitmap* result) {
84 if (0 == invScaleX || 0 == invScaleY) { 84 if (0 == invScaleX || 0 == invScaleY) {
85 // degenerate, and the key we use for mipmaps 85 // degenerate, and the key we use for mipmaps
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 return result; 152 return result;
153 } 153 }
154 154
155 void SkMipMapCache::Add(const SkBitmap& src, const SkMipMap* result) { 155 void SkMipMapCache::Add(const SkBitmap& src, const SkMipMap* result) {
156 if (result) { 156 if (result) {
157 SkResourceCache::Add(SkNEW_ARGS(MipMapRec, (src, result))); 157 SkResourceCache::Add(SkNEW_ARGS(MipMapRec, (src, result)));
158 } 158 }
159 } 159 }
160 160
OLDNEW
« no previous file with comments | « gyp/common.gypi ('k') | src/core/SkResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698