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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 195223003: Fixing SkPicture serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed nits Created 6 years, 9 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/SkPicturePlayback.h ('k') | src/core/SkValidatingReadBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 08e53fab8c443152ad1fb5b708174b8689aa8109..05c2c4e56b3167a3088bb07105649578804acb35 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -270,7 +270,7 @@ void SkPicturePlayback::init() {
}
SkPicturePlayback::~SkPicturePlayback() {
- fOpData->unref();
+ SkSafeUnref(fOpData);
SkSafeUnref(fBitmaps);
SkSafeUnref(fPaints);
@@ -612,6 +612,41 @@ bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer)));
}
break;
+ case SK_PICT_READER_TAG: {
+ SkAutoMalloc storage(size);
+ if (!buffer.readByteArray(storage.get(), size) ||
+ !buffer.validate(NULL == fOpData)) {
+ return false;
+ }
+ SkASSERT(NULL == fOpData);
+ fOpData = SkData::NewFromMalloc(storage.detach(), size);
+ } break;
+ case SK_PICT_PICTURE_TAG: {
+ if (!buffer.validate((0 == fPictureCount) && (NULL == fPictureRefs))) {
+ return false;
+ }
+ fPictureCount = size;
+ fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
+ bool success = true;
+ int i = 0;
+ for ( ; i < fPictureCount; i++) {
+ fPictureRefs[i] = SkPicture::CreateFromBuffer(buffer);
+ if (NULL == fPictureRefs[i]) {
+ success = false;
+ break;
+ }
+ }
+ if (!success) {
+ // Delete all of the pictures that were already created (up to but excluding i):
+ for (int j = 0; j < i; j++) {
+ fPictureRefs[j]->unref();
+ }
+ // Delete the array
+ SkDELETE_ARRAY(fPictureRefs);
+ fPictureCount = 0;
+ return false;
+ }
+ } break;
default:
// The tag was invalid.
return false;
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkValidatingReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698