SkStream/Priv cleanups
Replace all callers of SkCopyStreamToStorage with SkCopyStreamToData,
which is simpler and does the same thing.
Remove SkStreamRewindableFromSkStream, which is unused.
BUG=skia:4788
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1604963002
Review URL: https://codereview.chromium.org/1604963002
diff --git a/src/images/SkImageDecoder_libbmp.cpp b/src/images/SkImageDecoder_libbmp.cpp
index 1791623..4a6f71c 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 @@
// 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 @@
{
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 @@
// 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();