Chromium Code Reviews| 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 class SkBitmap; | |
| 16 class SkImageGenerator; | |
| 17 | |
| 15 /** We explicitly use the same allocator for our pixels that SkMask does, | 18 /** 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. | 19 so that we can freely assign memory allocated by one class to the other. |
| 17 */ | 20 */ |
| 18 class SkMallocPixelRef : public SkPixelRef { | 21 class SkMallocPixelRef : public SkPixelRef { |
| 19 public: | 22 public: |
| 20 /** Allocate the specified buffer for pixels. The memory is freed when the | 23 /** 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() | 24 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw() |
| 22 is called to allocate it. | 25 is called to allocate it. |
| 23 */ | 26 */ |
| 24 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe ls = true); | 27 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe ls = true); |
| 25 virtual ~SkMallocPixelRef(); | 28 virtual ~SkMallocPixelRef(); |
| 26 | 29 |
| 27 //! Return the allocation size for the pixels | 30 /** |
| 31 * Create a new SkMallocPixelRef and install it in the destination | |
| 32 * bitmap, based on the SkImageGenerator. The SkImageGenerator | |
| 33 * will be deleted. | |
| 34 * | |
| 35 * @returns false on any error. | |
| 36 */ | |
| 37 static bool Install(SkImageGenerator* generator, SkBitmap* destination); | |
|
scroggo
2013/12/02 19:03:23
Is there a reason these changes aren't included in
| |
| 38 | |
| 39 /** | |
| 40 * Return the allocation size for the pixels | |
| 41 */ | |
| 28 size_t getSize() const { return fSize; } | 42 size_t getSize() const { return fSize; } |
| 29 void* getAddr() const { return fStorage; } | 43 void* getAddr() const { return fStorage; } |
| 30 | 44 |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) | 45 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) |
| 32 | 46 |
| 33 protected: | 47 protected: |
| 34 // overrides from SkPixelRef | 48 // overrides from SkPixelRef |
| 35 virtual void* onLockPixels(SkColorTable**); | 49 virtual void* onLockPixels(SkColorTable** colorTable); |
|
reed1
2013/11/25 18:06:56
It is ok to leave off these parameter variable nam
| |
| 36 virtual void onUnlockPixels(); | 50 virtual void onUnlockPixels(); |
| 37 | 51 |
| 38 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); | 52 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); |
| 39 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 53 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| 40 | 54 |
| 41 private: | 55 private: |
| 42 void* fStorage; | 56 void* fStorage; |
| 43 size_t fSize; | 57 size_t fSize; |
| 44 SkColorTable* fCTable; | 58 SkColorTable* fCTable; |
| 45 bool fOwnPixels; | 59 bool fOwnPixels; |
| 46 | 60 |
| 47 typedef SkPixelRef INHERITED; | 61 typedef SkPixelRef INHERITED; |
| 48 }; | 62 }; |
| 49 | 63 |
| 50 | 64 |
| 51 #endif | 65 #endif |
| OLD | NEW |