OLD | NEW |
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 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. | 249 // to know automatically those entries can be purged when this pixelref is c
hanged or deleted. |
250 void notifyAddedToCache() { | 250 void notifyAddedToCache() { |
251 fAddedToCache = true; | 251 fAddedToCache.store(true); |
252 } | 252 } |
253 | 253 |
254 protected: | 254 protected: |
255 /** | 255 /** |
256 * 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 |
257 * failure returns false and ignores the LockRec parameter. | 257 * failure returns false and ignores the LockRec parameter. |
258 * | 258 * |
259 * 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 |
260 * method need not do that. | 260 * method need not do that. |
261 */ | 261 */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 // mostly const. fInfo.fAlpahType can be changed at runtime. | 315 // mostly const. fInfo.fAlpahType can be changed at runtime. |
316 const SkImageInfo fInfo; | 316 const SkImageInfo fInfo; |
317 | 317 |
318 // 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()) |
319 LockRec fRec; | 319 LockRec fRec; |
320 int fLockCount; | 320 int fLockCount; |
321 | 321 |
322 mutable SkAtomic<uint32_t> fGenerationID; | 322 mutable SkAtomic<uint32_t> fGenerationID; |
323 mutable SkAtomic<bool> fUniqueGenerationID; | 323 mutable SkAtomic<bool> fUniqueGenerationID; |
324 bool fAddedToCache; | 324 SkAtomic<bool> fAddedToCache; |
325 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 325 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
326 const uint32_t fStableID; | 326 const uint32_t fStableID; |
327 #endif | 327 #endif |
328 | 328 |
329 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d | 329 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne
d |
330 | 330 |
331 SkString fURI; | 331 SkString fURI; |
332 | 332 |
333 // 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 |
334 bool fIsImmutable; | 334 bool fIsImmutable; |
(...skipping 18 matching lines...) Expand all Loading... |
353 /** | 353 /** |
354 * Allocate a new pixelref matching the specified ImageInfo, allocating | 354 * Allocate a new pixelref matching the specified ImageInfo, allocating |
355 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 355 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
356 * the pixelref will ref() the colortable. | 356 * the pixelref will ref() the colortable. |
357 * On failure return NULL. | 357 * On failure return NULL. |
358 */ | 358 */ |
359 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 359 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
360 }; | 360 }; |
361 | 361 |
362 #endif | 362 #endif |
OLD | NEW |