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 #ifdef SK_DEBUG | |
23 /** | |
24 * Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref | |
25 * subclasses to correctly handle lock/unlock pixels. For performance | |
26 * reasons, simple malloc-based subclasses call setPreLocked() to skip | |
27 * the overhead of implementing these calls. | |
28 * | |
29 * This build-flag disables that optimization, to add in debugging our | |
30 * call-sites, to ensure that they correctly balance their calls of | |
31 * lock and unlock. | |
32 */ | |
33 // #define SK_IGNORE_PIXELREF_SETPRELOCKED | |
34 #endif | |
35 | |
36 class SkColorTable; | 22 class SkColorTable; |
37 class SkData; | 23 class SkData; |
38 struct SkIRect; | 24 struct SkIRect; |
39 | 25 |
40 class GrTexture; | 26 class GrTexture; |
41 | 27 |
42 /** \class SkPixelRef | 28 /** \class SkPixelRef |
43 | 29 |
44 This class is the smart container for pixel memory, and is used with | 30 This class is the smart container for pixel memory, and is used with |
45 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can | 31 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 364 |
379 void needsNewGenID(); | 365 void needsNewGenID(); |
380 void callGenIDChangeListeners(); | 366 void callGenIDChangeListeners(); |
381 | 367 |
382 void setMutex(SkBaseMutex* mutex); | 368 void setMutex(SkBaseMutex* mutex); |
383 | 369 |
384 void setTemporarilyImmutable(); | 370 void setTemporarilyImmutable(); |
385 void restoreMutability(); | 371 void restoreMutability(); |
386 friend class SkSurface_Raster; // For the two methods above. | 372 friend class SkSurface_Raster; // For the two methods above. |
387 | 373 |
| 374 bool isPreLocked() const { return fPreLocked; } |
| 375 friend class SkImage_Raster; |
| 376 |
388 // When copying a bitmap to another with the same shape and config, we can s
afely | 377 // When copying a bitmap to another with the same shape and config, we can s
afely |
389 // clone the pixelref generation ID too, which makes them equivalent under c
aching. | 378 // clone the pixelref generation ID too, which makes them equivalent under c
aching. |
390 friend class SkBitmap; // only for cloneGenID | 379 friend class SkBitmap; // only for cloneGenID |
391 void cloneGenID(const SkPixelRef&); | 380 void cloneGenID(const SkPixelRef&); |
392 | 381 |
393 typedef SkRefCnt INHERITED; | 382 typedef SkRefCnt INHERITED; |
394 }; | 383 }; |
395 | 384 |
396 class SkPixelRefFactory : public SkRefCnt { | 385 class SkPixelRefFactory : public SkRefCnt { |
397 public: | 386 public: |
398 /** | 387 /** |
399 * Allocate a new pixelref matching the specified ImageInfo, allocating | 388 * Allocate a new pixelref matching the specified ImageInfo, allocating |
400 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 389 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
401 * the pixelref will ref() the colortable. | 390 * the pixelref will ref() the colortable. |
402 * On failure return NULL. | 391 * On failure return NULL. |
403 */ | 392 */ |
404 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 393 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
405 }; | 394 }; |
406 | 395 |
407 #endif | 396 #endif |
OLD | NEW |