Make haveDecodedRow return void

The method already always returns true, except in a single case after
asserting.

Change-Id: Icf241a8af04220d459c0782ffd9b74c34c753236
Reviewed-on: https://skia-review.googlesource.com/37161
Reviewed-by: Chris Blume <cblume@chromium.org>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Leon Scroggins III 2017-08-22 14:13:15 -04:00 committed by Skia Commit-Bot
parent 267641a90c
commit 223ec293ef
4 changed files with 12 additions and 18 deletions

View File

@ -421,7 +421,7 @@ void SkGifCodec::applyXformRow(const SkImageInfo& dstInfo, void* dst, const uint
}
}
bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
void SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
int rowNumber, int repeatCount, bool writeTransparentPixels)
{
const SkGIFFrameContext* frameContext = fReader->frameContext(frameIndex);
@ -439,7 +439,7 @@ bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
// FIXME: No need to make the checks on width/xBegin/xEnd for every row. We could instead do
// this once in prepareToDecode.
if (!width || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin))
return true;
return;
// yBegin is the first row in the non-sampled image. dstRow will be the row in the output,
// after potentially scaling it.
@ -456,7 +456,7 @@ bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
dstRow = potentialRow / sampleY;
const int scaledHeight = get_scaled_dimension(this->dstInfo().height(), sampleY);
if (dstRow >= scaledHeight) {
return true;
return;
}
foundNecessaryRow = true;
@ -474,7 +474,7 @@ bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
}
if (!foundNecessaryRow) {
return true;
return;
}
} else {
// Make sure the repeatCount does not take us beyond the end of the dst
@ -536,8 +536,7 @@ bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
break;
default:
SkASSERT(false);
return false;
break;
return;
}
p.append(SkRasterPipeline::srcover);
p.append(storeDst, &dst);
@ -555,6 +554,4 @@ bool SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
memcpy(dst, copiedLine, bytesToCopy);
}
}
return true;
}

View File

@ -32,7 +32,7 @@ public:
static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
// Callback for SkGifImageReader when a row is available.
bool haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
void haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
int rowNumber, int repeatCount, bool writeTransparentPixels);
protected:
/*

View File

@ -97,7 +97,7 @@ mailing address.
#define GETINT16(p) ((p)[1]<<8|(p)[0])
// Send the data to the display front-end.
bool SkGIFLZWContext::outputRow(const unsigned char* rowBegin)
void SkGIFLZWContext::outputRow(const unsigned char* rowBegin)
{
int drowStart = irow;
int drowEnd = irow;
@ -144,13 +144,12 @@ bool SkGIFLZWContext::outputRow(const unsigned char* rowBegin)
// Protect against too much image data.
if (drowStart >= m_frameContext->height())
return true;
return;
// CALLBACK: Let the client know we have decoded a row.
const bool writeTransparentPixels = (SkCodec::kNone == m_frameContext->getRequiredFrame());
if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin,
drowStart, drowEnd - drowStart + 1, writeTransparentPixels))
return false;
m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin,
drowStart, drowEnd - drowStart + 1, writeTransparentPixels);
if (!m_frameContext->interlaced())
irow++;
@ -194,7 +193,6 @@ bool SkGIFLZWContext::outputRow(const unsigned char* rowBegin)
}
} while (irow > (unsigned) (m_frameContext->height() - 1));
}
return true;
}
// Perform Lempel-Ziv-Welch decoding.
@ -287,8 +285,7 @@ bool SkGIFLZWContext::doLZW(const unsigned char* block, size_t bytesInBlock)
// Output as many rows as possible.
unsigned char* rowBegin = rowBuffer.begin();
for (; rowBegin + width <= rowIter; rowBegin += width) {
if (!outputRow(rowBegin))
return false;
outputRow(rowBegin);
rowsRemaining--;
if (!rowsRemaining)
return true;

View File

@ -110,7 +110,7 @@ public:
{ }
bool prepareToDecode();
bool outputRow(const unsigned char* rowBegin);
void outputRow(const unsigned char* rowBegin);
bool doLZW(const unsigned char* block, size_t bytesInBlock);
bool hasRemainingRows() { return SkToBool(rowsRemaining); }