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

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: update dox Created 5 years, 10 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 | « src/core/SkPictureShader.cpp ('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 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 }
225
226 // If we can flag the pixelref somehow whenever it was actually added to the cache,
227 // perhaps it would be nice to only call this notifier in that case. For now we always
228 // call it, since we don't know if it was cached or not.
229 SkNotifyBitmapGenIDIsStale(fGenerationID);
223 } 230 }
224 // Listeners get at most one shot, so whether these triggered or not, blow t hem away. 231 // Listeners get at most one shot, so whether these triggered or not, blow t hem away.
225 fGenIDChangeListeners.deleteAll(); 232 fGenIDChangeListeners.deleteAll();
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 }
(...skipping 24 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
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/core/SkResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698