Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: src/images/SkImageDecoder_libbmp.cpp

Issue 1604963002: SkStream/Priv cleanups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update header description Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder_astc.cpp ('k') | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libbmp.cpp
diff --git a/src/images/SkImageDecoder_libbmp.cpp b/src/images/SkImageDecoder_libbmp.cpp
index 179162356aec980067ee6548c228d13d967b0cc0..4a6f71c82db06a383009343825dca99838a56d5a 100644
--- a/src/images/SkImageDecoder_libbmp.cpp
+++ b/src/images/SkImageDecoder_libbmp.cpp
@@ -9,6 +9,7 @@
#include "bmpdecoderhelper.h"
#include "SkColorPriv.h"
+#include "SkData.h"
#include "SkImageDecoder.h"
#include "SkScaledBitmapSampler.h"
#include "SkStream.h"
@@ -96,10 +97,13 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
// First read the entire stream, so that all of the data can be passed to
// the BmpDecoderHelper.
- // Allocated space used to hold the data.
- SkAutoMalloc storage;
+ SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
+ if (!data) {
+ return kFailure;
+ }
+
// Byte length of all of the data.
- const size_t length = SkCopyStreamToStorage(&storage, stream);
+ const size_t length = data->size();
if (0 == length) {
return kFailure;
}
@@ -111,7 +115,7 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
{
image_codec::BmpDecoderHelper helper;
const int max_pixels = 16383*16383; // max width*height
- if (!helper.DecodeImage((const char*)storage.get(), length,
+ if (!helper.DecodeImage((const char*) data->data(), length,
max_pixels, &callback)) {
return kFailure;
}
@@ -119,7 +123,7 @@ SkImageDecoder::Result SkBMPImageDecoder::onDecode(SkStream* stream, SkBitmap* b
// we don't need this anymore, so free it now (before we try to allocate
// the bitmap's pixels) rather than waiting for its destructor
- storage.free();
+ data.reset(nullptr);
int width = callback.width();
int height = callback.height();
« no previous file with comments | « src/images/SkImageDecoder_astc.cpp ('k') | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698