Index: src/core/SkData.cpp |
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp |
index a7a3d8d559681bf661cb90e4bbaf9a144f26ded7..11cab7e98be73388c67bfecc2845dd8c1278ea92 100644 |
--- a/src/core/SkData.cpp |
+++ b/src/core/SkData.cpp |
@@ -9,6 +9,7 @@ |
#include "SkLazyPtr.h" |
#include "SkOSFile.h" |
#include "SkReadBuffer.h" |
+#include "SkStream.h" |
#include "SkWriteBuffer.h" |
static void sk_inplace_sentinel_releaseproc(const void*, size_t, void*) { |
@@ -198,3 +199,14 @@ SkData* SkData::NewWithCString(const char cstr[]) { |
} |
return NewWithCopy(cstr, size); |
} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+SkData* SkData::NewFromStream(SkStream* stream, size_t size) { |
+ SkAutoDataUnref data(SkData::NewUninitialized(size)); |
+ if (stream->read(data->writable_data(), size) != size) { |
+ return NULL; |
+ } |
+ return data.detach(); |
+} |
+ |