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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 17113004: Replace SkPicture(SkStream) constructors with a factory. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove dead function declaration. Created 7 years, 6 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
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 898d37957811392393f4f7e756422e991ab5cc32..1a5e517498f72699ac4bdd88c49d40118ac8ca1a 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -520,15 +520,20 @@ void SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
case PICT_PICTURE_TAG: {
fPictureCount = size;
fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
- bool success;
for (int i = 0; i < fPictureCount; i++) {
- fPictureRefs[i] = SkNEW_ARGS(SkPicture, (stream, &success, proc));
- // Success can only be false if PICTURE_VERSION does not match
+ fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc);
robertphillips 2013/06/24 17:22:09 I don't think this comment is true.
scroggo 2013/06/24 18:22:19 How else can it fail?
+ // CreateFromStream can only fail if PICTURE_VERSION does not match
// (which should never happen from here, since a sub picture will
// have the same PICTURE_VERSION as its parent) or if stream->read
// returns 0. In the latter case, we have a bug when writing the
// picture to begin with, which will be alerted to here.
- SkASSERT(success);
+ SkASSERT(fPictureRefs[i] != NULL);
+ if (NULL == fPictureRefs[i]) {
+ // Delete the array
robertphillips 2013/06/24 17:22:09 Don't we need to also loop backwards across the ar
scroggo 2013/06/24 18:22:19 Yes. Done.
+ SkDELETE_ARRAY(fPictureRefs);
+ fPictureCount = 0;
+ return;
+ }
}
} break;
case PICT_BUFFER_SIZE_TAG: {
« src/core/SkPicture.cpp ('K') | « src/core/SkPicture.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698