| Index: src/images/SkDecodingImageGenerator.cpp
|
| diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
|
| index 1d91bcc0f98e359c95b59cac8ac73d79feacdecf..359eb370adc29c240f48338fc574fe33376c9017 100644
|
| --- a/src/images/SkDecodingImageGenerator.cpp
|
| +++ b/src/images/SkDecodingImageGenerator.cpp
|
| @@ -132,22 +132,20 @@ DecodingImageGenerator::~DecodingImageGenerator() {
|
| SkData* DecodingImageGenerator::onRefEncodedData() {
|
| // This functionality is used in `gm --serialize`
|
| // Does not encode options.
|
| - if (fData != NULL) {
|
| - return SkSafeRef(fData);
|
| - }
|
| - // TODO(halcanary): SkStreamRewindable needs a refData() function
|
| - // which returns a cheap copy of the underlying data.
|
| - if (!fStream->rewind()) {
|
| - return NULL;
|
| - }
|
| - size_t length = fStream->getLength();
|
| - if (0 == length) {
|
| - return NULL;
|
| + if (NULL == fData) {
|
| + // TODO(halcanary): SkStreamRewindable needs a refData() function
|
| + // which returns a cheap copy of the underlying data.
|
| + if (!fStream->rewind()) {
|
| + return NULL;
|
| + }
|
| + size_t length = fStream->getLength();
|
| + if (0 == length) {
|
| + return NULL;
|
| + }
|
| + fData = SkData::NewUninitialized(length);
|
| + SkCheckResult(fStream->read(fData->writable_data(), length), length);
|
| }
|
| - void* buffer = sk_malloc_flags(length, 0);
|
| - SkCheckResult(fStream->read(buffer, length), length);
|
| - fData = SkData::NewFromMalloc(buffer, length);
|
| - return SkSafeRef(fData);
|
| + return SkRef(fData);
|
| }
|
|
|
| bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
|
|
|