aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-25 16:05:00 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-25 16:05:00 +0000
commit12d588a7f28e18f87f5f9a6eb57fc1f5137a8d28 (patch)
tree499ba7331524b98cb223c7af0a94e5a184e32276 /src
parent0ba4bf427acbd7707d04192a98c77ef194a0f25a (diff)
Remove bogus ability for creating an SkPicturePlayback to fail.
Change SkPicturePlayback::parseBufferTag to return void, since it can never return false. Change SkPicturePlayback::parseStreamTag to return void, since the only way it can return false is if parseBufferTag returns false, or if creating a sub picture failed, both of which are nonsensical. Due to the above, there is no reason for creating an SkPicturePlayback to fail, so remove the isValid parameter. Update subclasses in SkDebuggerGUI. Review URL: https://codereview.appspot.com/7388050 git-svn-id: http://skia.googlecode.com/svn/trunk@7844 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPicture.cpp8
-rw-r--r--src/core/SkPicturePlayback.cpp42
-rw-r--r--src/core/SkPicturePlayback.h6
3 files changed, 17 insertions, 39 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 381bbaec48..1ff5865651 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -290,13 +290,7 @@ void SkPicture::initFromStream(SkStream* stream, bool* success, InstallPixelRefP
}
if (stream->readBool()) {
- bool isValid = false;
- fPlayback = SkNEW_ARGS(SkPicturePlayback, (stream, info, &isValid, proc));
- if (!isValid) {
- SkDELETE(fPlayback);
- fPlayback = NULL;
- return;
- }
+ fPlayback = SkNEW_ARGS(SkPicturePlayback, (stream, info, proc));
}
// do this at the end, so that they will be zero if we hit an error.
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 9ab7b01e49..93e5cf17bf 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -473,7 +473,7 @@ static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) {
return rbMask;
}
-bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info, uint32_t tag,
+void SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info, uint32_t tag,
size_t size, SkPicture::InstallPixelRefProc proc) {
/*
* By the time we encounter BUFFER_SIZE_TAG, we need to have already seen
@@ -514,23 +514,15 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
case PICT_PICTURE_TAG: {
fPictureCount = size;
fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
- bool success = true;
- int i = 0;
- for ( ; i < fPictureCount; i++) {
+ bool success;
+ for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i] = SkNEW_ARGS(SkPicture, (stream, &success, proc));
- if (!success) {
- break;
- }
- }
- if (!success) {
- // Delete all of the pictures that were already created (up through i):
- for (int j = 0; j <= i; j++) {
- fPictureRefs[j]->unref();
- }
- // Delete the array
- SkDELETE_ARRAY(fPictureRefs);
- fPictureCount = 0;
- return false;
+ // Success can only be false 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);
}
} break;
case PICT_BUFFER_SIZE_TAG: {
@@ -547,17 +539,14 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
while (!buffer.eof()) {
tag = buffer.readUInt();
size = buffer.readUInt();
- if (!this->parseBufferTag(buffer, tag, size)) {
- return false;
- }
+ this->parseBufferTag(buffer, tag, size);
}
SkDEBUGCODE(haveBuffer = true;)
} break;
}
- return true; // success
}
-bool SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer,
+void SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer,
uint32_t tag, size_t size) {
switch (tag) {
case PICT_BITMAP_BUFFER_TAG: {
@@ -592,14 +581,12 @@ bool SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer,
}
} break;
}
- return true; // success
}
-SkPicturePlayback::SkPicturePlayback(SkStream* stream, const SkPictInfo& info, bool* isValid,
+SkPicturePlayback::SkPicturePlayback(SkStream* stream, const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc) {
this->init();
- *isValid = false; // wait until we're done parsing to mark as true
for (;;) {
uint32_t tag = stream->readU32();
if (PICT_EOF_TAG == tag) {
@@ -607,11 +594,8 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream, const SkPictInfo& info, b
}
uint32_t size = stream->readU32();
- if (!this->parseStreamTag(stream, info, tag, size, proc)) {
- return; // we're invalid
- }
+ this->parseStreamTag(stream, info, tag, size, proc);
}
- *isValid = true;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 92c099fe07..6acc0ae508 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -62,7 +62,7 @@ public:
SkPicturePlayback();
SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo = NULL);
explicit SkPicturePlayback(const SkPictureRecord& record, bool deepCopy = false);
- SkPicturePlayback(SkStream*, const SkPictInfo&, bool* isValid, SkPicture::InstallPixelRefProc);
+ SkPicturePlayback(SkStream*, const SkPictInfo&, SkPicture::InstallPixelRefProc);
virtual ~SkPicturePlayback();
@@ -189,9 +189,9 @@ public:
#endif
private: // these help us with reading/writing
- bool parseStreamTag(SkStream*, const SkPictInfo&, uint32_t tag, size_t size,
+ void parseStreamTag(SkStream*, const SkPictInfo&, uint32_t tag, size_t size,
SkPicture::InstallPixelRefProc);
- bool parseBufferTag(SkOrderedReadBuffer&, uint32_t tag, size_t size);
+ void parseBufferTag(SkOrderedReadBuffer&, uint32_t tag, size_t size);
void flattenToBuffer(SkOrderedWriteBuffer&) const;
private: