| Index: src/codec/SkCodec_libpng.cpp
|
| diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp
|
| index 744bca41fae4d0a4b255d5681789e1af2f1c4ff4..3086a365991a70c9649761beb7d4f784ee72e722 100644
|
| --- a/src/codec/SkCodec_libpng.cpp
|
| +++ b/src/codec/SkCodec_libpng.cpp
|
| @@ -14,6 +14,7 @@
|
| #include "SkSize.h"
|
| #include "SkStream.h"
|
| #include "SkSwizzler.h"
|
| +#include "SkTemplates.h"
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // Helper macros
|
| @@ -503,7 +504,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
|
| // error?
|
| int row = 0;
|
| // This must be declared above the call to setjmp to avoid memory leaks on incomplete images.
|
| - SkAutoMalloc storage;
|
| + SkAutoTMalloc<uint8_t> storage;
|
| if (setjmp(png_jmpbuf(fPng_ptr))) {
|
| // Assume that any error that occurs while reading rows is caused by an incomplete input.
|
| if (fNumberPasses > 1) {
|
| @@ -535,7 +536,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
|
| const size_t srcRowBytes = width * bpp;
|
|
|
| storage.reset(width * height * bpp);
|
| - uint8_t* const base = static_cast<uint8_t*>(storage.get());
|
| + uint8_t* const base = storage.get();
|
|
|
| for (int i = 0; i < fNumberPasses; i++) {
|
| uint8_t* srcRow = base;
|
| @@ -555,7 +556,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
|
| }
|
| } else {
|
| storage.reset(requestedInfo.width() * SkSwizzler::BytesPerPixel(fSrcConfig));
|
| - uint8_t* srcRow = static_cast<uint8_t*>(storage.get());
|
| + uint8_t* srcRow = storage.get();
|
| for (; row < requestedInfo.height(); row++) {
|
| png_read_rows(fPng_ptr, &srcRow, png_bytepp_NULL, 1);
|
| // FIXME: Only call IsOpaque once, outside the loop. Same for onGetScanlines.
|
| @@ -642,7 +643,7 @@ public:
|
|
|
| fAlphaState = kUnknown_AlphaState;
|
| fStorage.reset(this->getInfo().width() * SkSwizzler::BytesPerPixel(this->srcConfig()));
|
| - fSrcRow = static_cast<uint8_t*>(fStorage.get());
|
| + fSrcRow = fStorage.get();
|
|
|
| return kSuccess;
|
| }
|
| @@ -696,7 +697,7 @@ public:
|
|
|
| private:
|
| AlphaState fAlphaState;
|
| - SkAutoMalloc fStorage;
|
| + SkAutoTMalloc<uint8_t> fStorage;
|
| uint8_t* fSrcRow;
|
|
|
| typedef SkPngCodec INHERITED;
|
| @@ -769,8 +770,8 @@ public:
|
| // fail on the first pass, we can still report than some scanlines are initialized.
|
| return 0;
|
| }
|
| - SkAutoMalloc storage(count * fSrcRowBytes);
|
| - uint8_t* storagePtr = static_cast<uint8_t*>(storage.get());
|
| + SkAutoTMalloc<uint8_t> storage(count * fSrcRowBytes);
|
| + uint8_t* storagePtr = storage.get();
|
| uint8_t* srcRow;
|
| const int startRow = this->nextScanline();
|
| for (int i = 0; i < this->numberPasses(); i++) {
|
|
|