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

Side by Side Diff: include/core/SkPixelRef.h

Issue 960563002: only notify bitmaps that have been added to the cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address reviewer comments 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
« no previous file with comments | « no previous file | src/core/SkBitmapCache.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 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
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 #ifndef SkPixelRef_DEFINED 8 #ifndef SkPixelRef_DEFINED
9 #define SkPixelRef_DEFINED 9 #define SkPixelRef_DEFINED
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // 238 //
239 // This can be used to invalidate caches keyed by SkPixelRef generation ID. 239 // This can be used to invalidate caches keyed by SkPixelRef generation ID.
240 struct GenIDChangeListener { 240 struct GenIDChangeListener {
241 virtual ~GenIDChangeListener() {} 241 virtual ~GenIDChangeListener() {}
242 virtual void onChange() = 0; 242 virtual void onChange() = 0;
243 }; 243 };
244 244
245 // Takes ownership of listener. 245 // Takes ownership of listener.
246 void addGenIDChangeListener(GenIDChangeListener* listener); 246 void addGenIDChangeListener(GenIDChangeListener* listener);
247 247
248 // Call when this pixelref is part of the key to a resourcecache entry. This allows the cache
249 // to know automatically those entries can be purged when this pixelref is c hanged or deleted.
250 void notifyAddedToCache() {
251 fAddedToCache.store(true);
252 }
253
248 protected: 254 protected:
249 /** 255 /**
250 * On success, returns true and fills out the LockRec for the pixels. On 256 * On success, returns true and fills out the LockRec for the pixels. On
251 * failure returns false and ignores the LockRec parameter. 257 * failure returns false and ignores the LockRec parameter.
252 * 258 *
253 * The caller will have already acquired a mutex for thread safety, so this 259 * The caller will have already acquired a mutex for thread safety, so this
254 * method need not do that. 260 * method need not do that.
255 */ 261 */
256 virtual bool onNewLockPixels(LockRec*) = 0; 262 virtual bool onNewLockPixels(LockRec*) = 0;
257 263
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 314
309 // mostly const. fInfo.fAlpahType can be changed at runtime. 315 // mostly const. fInfo.fAlpahType can be changed at runtime.
310 const SkImageInfo fInfo; 316 const SkImageInfo fInfo;
311 317
312 // LockRec is only valid if we're in a locked state (isLocked()) 318 // LockRec is only valid if we're in a locked state (isLocked())
313 LockRec fRec; 319 LockRec fRec;
314 int fLockCount; 320 int fLockCount;
315 321
316 mutable SkAtomic<uint32_t> fGenerationID; 322 mutable SkAtomic<uint32_t> fGenerationID;
317 mutable SkAtomic<bool> fUniqueGenerationID; 323 mutable SkAtomic<bool> fUniqueGenerationID;
324 SkAtomic<bool> fAddedToCache;
318 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 325 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
319 const uint32_t fStableID; 326 const uint32_t fStableID;
320 #endif 327 #endif
321 328
322 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d 329 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d
323 330
324 SkString fURI; 331 SkString fURI;
325 332
326 // can go from false to true, but never from true to false 333 // can go from false to true, but never from true to false
327 bool fIsImmutable; 334 bool fIsImmutable;
(...skipping 18 matching lines...) Expand all
346 /** 353 /**
347 * Allocate a new pixelref matching the specified ImageInfo, allocating 354 * Allocate a new pixelref matching the specified ImageInfo, allocating
348 * the memory for the pixels. If the ImageInfo requires a ColorTable, 355 * the memory for the pixels. If the ImageInfo requires a ColorTable,
349 * the pixelref will ref() the colortable. 356 * the pixelref will ref() the colortable.
350 * On failure return NULL. 357 * On failure return NULL.
351 */ 358 */
352 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0; 359 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0;
353 }; 360 };
354 361
355 #endif 362 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698