OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkMallocPixelRef_DEFINED | 10 #ifndef SkMallocPixelRef_DEFINED |
11 #define SkMallocPixelRef_DEFINED | 11 #define SkMallocPixelRef_DEFINED |
12 | 12 |
13 #include "SkPixelRef.h" | 13 #include "SkPixelRef.h" |
14 | 14 |
15 /** We explicitly use the same allocator for our pixels that SkMask does, | 15 /** We explicitly use the same allocator for our pixels that SkMask does, |
16 so that we can freely assign memory allocated by one class to the other. | 16 so that we can freely assign memory allocated by one class to the other. |
17 */ | 17 */ |
18 class SkMallocPixelRef : public SkPixelRef { | 18 class SkMallocPixelRef : public SkPixelRef { |
| 19 typedef SkPixelRef INHERITED; |
| 20 |
19 public: | 21 public: |
20 /** Allocate the specified buffer for pixels. The memory is freed when the | 22 /** Allocate the specified buffer for pixels. The memory is freed when the |
21 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw() | 23 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw() |
22 is called to allocate it. | 24 is called to allocate it. |
23 */ | 25 */ |
24 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe
ls = true); | 26 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe
ls = true); |
25 virtual ~SkMallocPixelRef(); | 27 virtual ~SkMallocPixelRef(); |
26 | 28 |
27 //! Return the allocation size for the pixels | 29 //! Return the allocation size for the pixels |
28 size_t getSize() const { return fSize; } | 30 size_t getSize() const { return fSize; } |
29 void* getAddr() const { return fStorage; } | 31 void* getAddr() const { return fStorage; } |
30 | 32 |
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) | 33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) |
32 | 34 |
33 protected: | 35 protected: |
34 // overrides from SkPixelRef | 36 // overrides from SkPixelRef |
35 virtual void* onLockPixels(SkColorTable**); | 37 virtual void* onLockPixels(SkColorTable**); |
36 virtual void onUnlockPixels(); | 38 virtual void onUnlockPixels(); |
37 | 39 |
38 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); | 40 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); |
39 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 41 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
40 | 42 |
41 private: | 43 private: |
42 void* fStorage; | 44 void* fStorage; |
43 size_t fSize; | 45 size_t fSize; |
44 SkColorTable* fCTable; | 46 SkColorTable* fCTable; |
45 bool fOwnPixels; | 47 bool fOwnPixels; |
46 | |
47 typedef SkPixelRef INHERITED; | |
48 }; | 48 }; |
49 | 49 |
50 | 50 |
51 #endif | 51 #endif |
OLD | NEW |