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

Unified Diff: src/core/SkData.cpp

Issue 565803005: use SkData::NewUninitialized (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: readInData -> NewFromStream Created 6 years, 3 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 | « include/core/SkData.h ('k') | src/core/SkPictureData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+}
+
« no previous file with comments | « include/core/SkData.h ('k') | src/core/SkPictureData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698