Don't require getLength on Mac.
For consistency with our other image decoders, do not depend on getLength
in Mac specific decoder.
BUG=skia:1570
R=djsollen@google.com
Review URL: https://codereview.chromium.org/23004008
git-svn-id: http://skia.googlecode.com/svn/trunk@10990 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/images.gyp b/gyp/images.gyp
index 7abaac2..7ead87e 100644
--- a/gyp/images.gyp
+++ b/gyp/images.gyp
@@ -22,6 +22,8 @@
'../src/core/',
# for access to SkImagePriv.h
'../src/image/',
+ # So src/ports/SkImageDecoder_CG can access SkStreamHelpers.h
+ '../src/images/',
],
'sources': [
'../include/images/SkForceLinking.h',
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index 7734ea5..b1d1613 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -11,6 +11,7 @@
#include "SkImageEncoder.h"
#include "SkMovie.h"
#include "SkStream.h"
+#include "SkStreamHelpers.h"
#include "SkTemplates.h"
#include "SkUnPreMultiply.h"
@@ -30,9 +31,9 @@
static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) {
// TODO: use callbacks, so we don't have to load all the data into RAM
- size_t len = stream->getLength();
- void* data = sk_malloc_throw(len);
- stream->read(data, len);
+ SkAutoMalloc storage;
+ const size_t len = CopyStreamToStorage(&storage, stream);
+ void* data = storage.detach();
return CGDataProviderCreateWithData(data, data, len, malloc_release_proc);
}