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 |
11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 #include "SkFilterQuality.h" | 13 #include "SkFilterQuality.h" |
14 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
15 #include "SkMutex.h" | 15 #include "SkMutex.h" |
16 #include "SkPixmap.h" | 16 #include "SkPixmap.h" |
17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
18 #include "SkSize.h" | 18 #include "SkSize.h" |
19 #include "SkString.h" | 19 #include "SkString.h" |
20 #include "SkTDArray.h" | 20 #include "SkTDArray.h" |
21 | 21 |
22 class SkColorTable; | 22 class SkColorTable; |
23 class SkData; | 23 class SkData; |
24 struct SkIRect; | 24 struct SkIRect; |
25 | 25 |
26 class GrTexture; | 26 class GrTexture; |
| 27 class SkDiscardableMemory; |
27 | 28 |
28 /** \class SkPixelRef | 29 /** \class SkPixelRef |
29 | 30 |
30 This class is the smart container for pixel memory, and is used with | 31 This class is the smart container for pixel memory, and is used with |
31 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can | 32 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can |
32 access the actual pixel memory by calling lockPixels/unlockPixels. | 33 access the actual pixel memory by calling lockPixels/unlockPixels. |
33 | 34 |
34 This class can be shared/accessed between multiple threads. | 35 This class can be shared/accessed between multiple threads. |
35 */ | 36 */ |
36 class SK_API SkPixelRef : public SkRefCnt { | 37 class SK_API SkPixelRef : public SkRefCnt { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 257 |
257 // Takes ownership of listener. | 258 // Takes ownership of listener. |
258 void addGenIDChangeListener(GenIDChangeListener* listener); | 259 void addGenIDChangeListener(GenIDChangeListener* listener); |
259 | 260 |
260 // Call when this pixelref is part of the key to a resourcecache entry. This
allows the cache | 261 // Call when this pixelref is part of the key to a resourcecache entry. This
allows the cache |
261 // to know automatically those entries can be purged when this pixelref is c
hanged or deleted. | 262 // to know automatically those entries can be purged when this pixelref is c
hanged or deleted. |
262 void notifyAddedToCache() { | 263 void notifyAddedToCache() { |
263 fAddedToCache.store(true); | 264 fAddedToCache.store(true); |
264 } | 265 } |
265 | 266 |
| 267 virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return
NULL; } |
| 268 |
266 protected: | 269 protected: |
267 /** | 270 /** |
268 * On success, returns true and fills out the LockRec for the pixels. On | 271 * On success, returns true and fills out the LockRec for the pixels. On |
269 * failure returns false and ignores the LockRec parameter. | 272 * failure returns false and ignores the LockRec parameter. |
270 * | 273 * |
271 * The caller will have already acquired a mutex for thread safety, so this | 274 * The caller will have already acquired a mutex for thread safety, so this |
272 * method need not do that. | 275 * method need not do that. |
273 */ | 276 */ |
274 virtual bool onNewLockPixels(LockRec*) = 0; | 277 virtual bool onNewLockPixels(LockRec*) = 0; |
275 | 278 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 /** | 393 /** |
391 * Allocate a new pixelref matching the specified ImageInfo, allocating | 394 * Allocate a new pixelref matching the specified ImageInfo, allocating |
392 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 395 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
393 * the pixelref will ref() the colortable. | 396 * the pixelref will ref() the colortable. |
394 * On failure return NULL. | 397 * On failure return NULL. |
395 */ | 398 */ |
396 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 399 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
397 }; | 400 }; |
398 | 401 |
399 #endif | 402 #endif |
OLD | NEW |