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

Unified Diff: src/core/SkPictureData.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 | « src/core/SkData.cpp ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureData.cpp
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index a2d10e3b9b0e1f67ceea0300983c29584db7e9b5..656515830c850b73cebd64b56e94bd94791c7898 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -390,14 +390,13 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
SkDEBUGCODE(bool haveBuffer = false;)
switch (tag) {
- case SK_PICT_READER_TAG: {
- SkAutoMalloc storage(size);
- if (stream->read(storage.get(), size) != size) {
+ case SK_PICT_READER_TAG:
+ SkASSERT(NULL == fOpData);
+ fOpData = SkData::NewFromStream(stream, size);
+ if (!fOpData) {
return false;
}
- SkASSERT(NULL == fOpData);
- fOpData = SkData::NewFromMalloc(storage.detach(), size);
- } break;
+ break;
case SK_PICT_FACTORY_TAG: {
SkASSERT(!haveBuffer);
// Remove this code when v21 and below are no longer supported. At the
@@ -538,13 +537,13 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer,
}
} break;
case SK_PICT_READER_TAG: {
- SkAutoMalloc storage(size);
- if (!buffer.readByteArray(storage.get(), size) ||
+ SkAutoDataUnref data(SkData::NewUninitialized(size));
+ if (!buffer.readByteArray(data->writable_data(), size) ||
!buffer.validate(NULL == fOpData)) {
return false;
}
SkASSERT(NULL == fOpData);
- fOpData = SkData::NewFromMalloc(storage.detach(), size);
+ fOpData = data.detach();
} break;
case SK_PICT_PICTURE_TAG: {
if (!buffer.validate((0 == fPictureCount) && (NULL == fPictureRefs))) {
« no previous file with comments | « src/core/SkData.cpp ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698