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
This commit is contained in:
parent
0ba4bf427a
commit
12d588a7f2
@ -143,10 +143,10 @@ void SkDebuggerGUI::showDeletes() {
|
||||
// offsets to individual commands.
|
||||
class SkTimedPicturePlayback : public SkPicturePlayback {
|
||||
public:
|
||||
SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info, bool* isValid,
|
||||
SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info,
|
||||
SkPicture::InstallPixelRefProc proc, const SkTDArray<size_t>& offsets,
|
||||
const SkTDArray<bool>& deletedCommands)
|
||||
: INHERITED(stream, info, isValid, proc)
|
||||
: INHERITED(stream, info, proc)
|
||||
, fOffsets(offsets)
|
||||
, fSkipCommands(deletedCommands)
|
||||
, fTot(0.0)
|
||||
@ -270,14 +270,8 @@ public:
|
||||
}
|
||||
|
||||
if (stream->readBool()) {
|
||||
bool isValid = false;
|
||||
fPlayback = SkNEW_ARGS(SkTimedPicturePlayback,
|
||||
(stream, info, &isValid, proc, offsets, deletedCommands));
|
||||
if (!isValid) {
|
||||
SkDELETE(fPlayback);
|
||||
fPlayback = NULL;
|
||||
return;
|
||||
}
|
||||
(stream, info, proc, offsets, deletedCommands));
|
||||
}
|
||||
|
||||
// do this at the end, so that they will be zero if we hit an error.
|
||||
@ -924,9 +918,9 @@ void SkDebuggerGUI::setupDirectoryWidget(const QString& path) {
|
||||
// These are needed by the profiling system.
|
||||
class SkOffsetPicturePlayback : public SkPicturePlayback {
|
||||
public:
|
||||
SkOffsetPicturePlayback(SkStream* stream, const SkPictInfo& info, bool* isValid,
|
||||
SkOffsetPicturePlayback(SkStream* stream, const SkPictInfo& info,
|
||||
SkPicture::InstallPixelRefProc proc)
|
||||
: INHERITED(stream, info, isValid, proc) {
|
||||
: INHERITED(stream, info, proc) {
|
||||
}
|
||||
|
||||
const SkTDArray<size_t>& offsets() const { return fOffsets; }
|
||||
@ -964,13 +958,7 @@ public:
|
||||
}
|
||||
|
||||
if (stream->readBool()) {
|
||||
bool isValid = false;
|
||||
fPlayback = SkNEW_ARGS(SkOffsetPicturePlayback, (stream, info, &isValid, proc));
|
||||
if (!isValid) {
|
||||
SkDELETE(fPlayback);
|
||||
fPlayback = NULL;
|
||||
return;
|
||||
}
|
||||
fPlayback = SkNEW_ARGS(SkOffsetPicturePlayback, (stream, info, proc));
|
||||
}
|
||||
|
||||
// do this at the end, so that they will be zero if we hit an error.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user