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/src@10990 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/ports/SkImageDecoder_CG.cpp b/ports/SkImageDecoder_CG.cpp
index 7734ea5..b1d1613 100644
--- a/ports/SkImageDecoder_CG.cpp
+++ b/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);
 }