Merge fCurrIncrementalCodec and fCurrScanlineCodec usage into single

variable

This patch merges fCurrIncrementalCodec and fCurrScanlineCodec usage
into single variable for SkIcoCodec.

Bug: skia: None
Change-Id: I6629f04fc27b8792c4cb1e6f494f8df7006c6b21
Reviewed-on: https://skia-review.googlesource.com/50520
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
nagarajan.n 2017-09-25 18:13:06 +05:30 committed by Skia Commit-Bot
parent f60c1a3ef9
commit 477e9d432a
2 changed files with 15 additions and 40 deletions

View File

@ -204,8 +204,7 @@ SkIcoCodec::SkIcoCodec(int width, int height, const SkEncodedInfo& info,
: INHERITED(width, height, info, SkColorSpaceXform::ColorFormat(), nullptr,
std::move(colorSpace))
, fEmbeddedCodecs(codecs)
, fCurrScanlineCodec(nullptr)
, fCurrIncrementalCodec(nullptr)
, fCurrCodec(nullptr)
{}
/*
@ -306,8 +305,7 @@ SkCodec::Result SkIcoCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index).get();
result = embeddedCodec->startScanlineDecode(dstInfo, &options);
if (kSuccess == result) {
fCurrScanlineCodec = embeddedCodec;
fCurrIncrementalCodec = nullptr;
fCurrCodec = embeddedCodec;
return result;
}
@ -319,13 +317,13 @@ SkCodec::Result SkIcoCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
}
int SkIcoCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
SkASSERT(fCurrScanlineCodec);
return fCurrScanlineCodec->getScanlines(dst, count, rowBytes);
SkASSERT(fCurrCodec);
return fCurrCodec->getScanlines(dst, count, rowBytes);
}
bool SkIcoCodec::onSkipScanlines(int count) {
SkASSERT(fCurrScanlineCodec);
return fCurrScanlineCodec->skipScanlines(count);
SkASSERT(fCurrCodec);
return fCurrCodec->skipScanlines(count);
}
SkCodec::Result SkIcoCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
@ -341,8 +339,7 @@ SkCodec::Result SkIcoCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
switch (embeddedCodec->startIncrementalDecode(dstInfo,
pixels, rowBytes, &options)) {
case kSuccess:
fCurrIncrementalCodec = embeddedCodec;
fCurrScanlineCodec = nullptr;
fCurrCodec = embeddedCodec;
return kSuccess;
case kUnimplemented:
// FIXME: embeddedCodec is a BMP. If scanline decoding would work,
@ -374,33 +371,23 @@ SkCodec::Result SkIcoCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
}
SkCodec::Result SkIcoCodec::onIncrementalDecode(int* rowsDecoded) {
SkASSERT(fCurrIncrementalCodec);
return fCurrIncrementalCodec->incrementalDecode(rowsDecoded);
SkASSERT(fCurrCodec);
return fCurrCodec->incrementalDecode(rowsDecoded);
}
SkCodec::SkScanlineOrder SkIcoCodec::onGetScanlineOrder() const {
// FIXME: This function will possibly return the wrong value if it is called
// before startScanlineDecode()/startIncrementalDecode().
if (fCurrScanlineCodec) {
SkASSERT(!fCurrIncrementalCodec);
return fCurrScanlineCodec->getScanlineOrder();
}
if (fCurrIncrementalCodec) {
return fCurrIncrementalCodec->getScanlineOrder();
if (fCurrCodec) {
return fCurrCodec->getScanlineOrder();
}
return INHERITED::onGetScanlineOrder();
}
SkSampler* SkIcoCodec::getSampler(bool createIfNecessary) {
if (fCurrScanlineCodec) {
SkASSERT(!fCurrIncrementalCodec);
return fCurrScanlineCodec->getSampler(createIfNecessary);
}
if (fCurrIncrementalCodec) {
return fCurrIncrementalCodec->getSampler(createIfNecessary);
if (fCurrCodec) {
return fCurrCodec->getSampler(createIfNecessary);
}
return nullptr;

View File

@ -92,21 +92,9 @@ private:
std::unique_ptr<SkTArray<std::unique_ptr<SkCodec>, true>> fEmbeddedCodecs;
// Only used by the scanline decoder. onStartScanlineDecode() will set
// fCurrScanlineCodec to one of the fEmbeddedCodecs, if it can find a
// codec of the appropriate size. We will use fCurrScanlineCodec for
// subsequent calls to onGetScanlines() or onSkipScanlines().
// fCurrScanlineCodec is owned by this class, but should not be an
// fCurrCodec is owned by this class, but should not be an
// std::unique_ptr. It will be deleted by the destructor of fEmbeddedCodecs.
SkCodec* fCurrScanlineCodec;
// Only used by incremental decoder. onStartIncrementalDecode() will set
// fCurrIncrementalCodec to one of the fEmbeddedCodecs, if it can find a
// codec of the appropriate size. We will use fCurrIncrementalCodec for
// subsequent calls to incrementalDecode().
// fCurrIncrementalCodec is owned by this class, but should not be an
// std::unique_ptr. It will be deleted by the destructor of fEmbeddedCodecs.
SkCodec* fCurrIncrementalCodec;
SkCodec* fCurrCodec;
typedef SkCodec INHERITED;
};