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 /** 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 public: | 19 public: |
| 20 /** Allocate the specified buffer for pixels. The memory is freed when the | 20 /** 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() | 21 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw() |
| 22 is called to allocate it. | 22 is called to allocate it. |
| 23 */ | 23 */ |
| 24 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe ls = true); | 24 SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, |
|
scroggo
2013/11/19 18:17:09
We'll need to make sure we update Android to call
reed1
2013/11/20 20:21:36
The compiler will help :)
| |
| 25 SkColorTable* ctable, bool ownPixels); | |
|
scroggo
2013/11/19 18:17:09
This problem already existed, but it is strange to
reed1
2013/11/20 20:21:36
I have an assert in the impl, requiring false for
| |
| 25 virtual ~SkMallocPixelRef(); | 26 virtual ~SkMallocPixelRef(); |
| 26 | 27 |
| 27 //! Return the allocation size for the pixels | 28 //! Return the allocation size for the pixels |
| 28 size_t getSize() const { return fSize; } | 29 size_t computeSize() const { |
| 30 return fInfo.fHeight * fRB; | |
|
scroggo
2013/11/19 18:17:09
Instead of (fInfo.fHeight - 1) * fRB + fInfo.fWidt
reed1
2013/11/20 20:21:36
Good comment. Bitmap has both sizes. Not sure if w
| |
| 31 } | |
| 29 void* getAddr() const { return fStorage; } | 32 void* getAddr() const { return fStorage; } |
| 30 | 33 |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) | 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) |
| 32 | 35 |
| 33 protected: | 36 protected: |
| 34 // overrides from SkPixelRef | 37 // overrides from SkPixelRef |
| 35 virtual void* onLockPixels(SkColorTable**); | 38 virtual void* onLockPixels(SkImageInfo*, size_t*, SkColorTable**); |
| 36 virtual void onUnlockPixels(); | 39 virtual void onUnlockPixels(); |
| 37 | 40 |
| 38 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); | 41 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); |
| 39 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 42 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 void* fStorage; | 45 void* fStorage; |
| 43 size_t fSize; | |
| 44 SkColorTable* fCTable; | 46 SkColorTable* fCTable; |
| 47 size_t fRB; | |
|
scroggo
2013/11/19 18:17:09
Can these be const?
reed1
2013/11/20 20:21:36
Good idea.
| |
| 48 SkImageInfo fInfo; | |
| 45 bool fOwnPixels; | 49 bool fOwnPixels; |
| 46 | 50 |
| 47 typedef SkPixelRef INHERITED; | 51 typedef SkPixelRef INHERITED; |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 | 54 |
| 51 #endif | 55 #endif |
| OLD | NEW |