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

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: too much, magic bus 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 }
225 SkNotifyBitmapGenIDIsStale(fGenerationID);
f(malita) 2015/02/24 20:31:36 IIUC, we're going to bombard the resource cache wi
mtklein 2015/02/24 20:48:37 Sort of. It's only visible changes. It's pretty
f(malita) 2015/02/24 20:54:55 Ah, I did not notice the lazy impl - thanks for ex
reed2 2015/02/24 20:56:28 Good thought. Perhaps we can have a flag on pixelr
mtklein 2015/02/24 21:24:59 Oh actually, this is a really good point, probably
223 } 226 }
224 // Listeners get at most one shot, so whether these triggered or not, blow t hem away. 227 // Listeners get at most one shot, so whether these triggered or not, blow t hem away.
225 fGenIDChangeListeners.deleteAll(); 228 fGenIDChangeListeners.deleteAll();
226 } 229 }
227 230
228 void SkPixelRef::notifyPixelsChanged() { 231 void SkPixelRef::notifyPixelsChanged() {
229 #ifdef SK_DEBUG 232 #ifdef SK_DEBUG
230 if (fIsImmutable) { 233 if (fIsImmutable) {
231 SkDebugf("========== notifyPixelsChanged called on immutable pixelref"); 234 SkDebugf("========== notifyPixelsChanged called on immutable pixelref");
232 } 235 }
(...skipping 24 matching lines...) Expand all
257 260
258 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], 261 bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
259 SkYUVColorSpace* colorSpace) { 262 SkYUVColorSpace* colorSpace) {
260 return false; 263 return false;
261 } 264 }
262 265
263 size_t SkPixelRef::getAllocatedSizeInBytes() const { 266 size_t SkPixelRef::getAllocatedSizeInBytes() const {
264 return 0; 267 return 0;
265 } 268 }
266 269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698