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

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

Issue 950363002: Notify resource caches when pixelref genID goes stale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use a sharedID for purging Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkPixelRef.h" 9 #include "SkPixelRef.h"
9 #include "SkThread.h" 10 #include "SkThread.h"
10 11
11 #ifdef SK_BUILD_FOR_WIN32 12 #ifdef SK_BUILD_FOR_WIN32
12 // We don't have SK_BASE_MUTEX_INIT on Windows. 13 // We don't have SK_BASE_MUTEX_INIT on Windows.
13 14
14 // must be a power-of-2. undef to just use 1 mutex 15 // must be a power-of-2. undef to just use 1 mutex
15 #define PIXELREF_MUTEX_RING_COUNT 32 16 #define PIXELREF_MUTEX_RING_COUNT 32
16 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT]; 17 static SkBaseMutex gPixelRefMutexRing[PIXELREF_MUTEX_RING_COUNT];
17 18
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 208
208 void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) { 209 void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) {
209 if (NULL == listener || !fUniqueGenerationID) { 210 if (NULL == listener || !fUniqueGenerationID) {
210 // No point in tracking this if we're not going to call it. 211 // No point in tracking this if we're not going to call it.
211 SkDELETE(listener); 212 SkDELETE(listener);
212 return; 213 return;
213 } 214 }
214 *fGenIDChangeListeners.append() = listener; 215 *fGenIDChangeListeners.append() = listener;
215 } 216 }
216 217
218 // we need to be called *before* the genID gets changed or zerod
217 void SkPixelRef::callGenIDChangeListeners() { 219 void SkPixelRef::callGenIDChangeListeners() {
218 // We don't invalidate ourselves if we think another SkPixelRef is sharing o ur genID. 220 // We don't invalidate ourselves if we think another SkPixelRef is sharing o ur genID.
219 if (fUniqueGenerationID) { 221 if (fUniqueGenerationID) {
220 for (int i = 0; i < fGenIDChangeListeners.count(); i++) { 222 for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
221 fGenIDChangeListeners[i]->onChange(); 223 fGenIDChangeListeners[i]->onChange();
222 } 224 }
223 } 225 }
224 // Listeners get at most one shot, so whether these triggered or not, blow t hem away. 226 // Listeners get at most one shot, so whether these triggered or not, blow t hem away.
225 fGenIDChangeListeners.deleteAll(); 227 fGenIDChangeListeners.deleteAll();
228
229 // if fGenerationID is 0, then perhaps we never had one, and we are in the d estructor
230 if (fGenerationID) {
231 SkNotifyBitmapGenIDIsStale(fGenerationID);
mtklein 2015/02/24 16:43:39 Just noticed.... this should probably go inside th
reed2 2015/02/24 17:44:52 Ah, thanks. I didn't really know what fUniqueGener
232 }
226 } 233 }
227 234
228 void SkPixelRef::notifyPixelsChanged() { 235 void SkPixelRef::notifyPixelsChanged() {
229 #ifdef SK_DEBUG 236 #ifdef SK_DEBUG
230 if (fIsImmutable) { 237 if (fIsImmutable) {
231 SkDebugf("========== notifyPixelsChanged called on immutable pixelref"); 238 SkDebugf("========== notifyPixelsChanged called on immutable pixelref");
232 } 239 }
233 #endif 240 #endif
234 this->callGenIDChangeListeners(); 241 this->callGenIDChangeListeners();
235 this->needsNewGenID(); 242 this->needsNewGenID();
(...skipping 21 matching lines...) Expand all
257 264
258 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 265 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
259 SkYUVColorSpace* colorSpace) { 266 SkYUVColorSpace* colorSpace) {
260 return false; 267 return false;
261 } 268 }
262 269
263 size_t SkPixelRef::getAllocatedSizeInBytes() const { 270 size_t SkPixelRef::getAllocatedSizeInBytes() const {
264 return 0; 271 return 0;
265 } 272 }
266 273
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698