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

View File

@ -32,7 +32,7 @@ public:
static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*); static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
// Callback for SkGifImageReader when a row is available. // 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); int rowNumber, int repeatCount, bool writeTransparentPixels);
protected: protected:
/* /*

View File

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

View File

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