Reland "Remove support for decoding to kIndex_8"
Original change's description:
> > Remove support for decoding to kIndex_8
> >
> > Fix up callsites, and remove tests that no longer make sense.
> >
> > Bug: skia:6828
> > Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295
> > Reviewed-on: https://skia-review.googlesource.com/21664
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Leon Scroggins <scroggo@google.com>
>
> TBR=djsollen@google.com,scroggo@google.com
>
> Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:6828
> Reviewed-on: https://skia-review.googlesource.com/22120
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>
TBR=djsollen@google.com,scroggo@google.com
Bug: skia:6828
Change-Id: I36ff5a11c529d29e8adc95f43b8edc6fd1dbf5b8
Reviewed-on: https://skia-review.googlesource.com/22320
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 26b31ae..4bd3917 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -167,19 +167,6 @@
return this->onRewind();
}
-#define CHECK_COLOR_TABLE \
- if (kIndex_8_SkColorType == info.colorType()) { \
- if (nullptr == ctable || nullptr == ctableCount) { \
- return SkCodec::kInvalidParameters; \
- } \
- } else { \
- if (ctableCount) { \
- *ctableCount = 0; \
- } \
- ctableCount = nullptr; \
- ctable = nullptr; \
- }
-
static void zero_rect(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes,
SkIRect frameRect) {
if (!frameRect.intersect(dstInfo.bounds())) {
@@ -205,11 +192,6 @@
return kInvalidParameters;
}
- // index 8 is not supported beyond the first frame.
- if (index < 0 || info.colorType() == kIndex_8_SkColorType) {
- return kInvalidParameters;
- }
-
if (index >= this->onGetFrameCount()) {
return kIncompleteInput;
}
@@ -252,8 +234,7 @@
Options prevFrameOptions(options);
prevFrameOptions.fFrameIndex = requiredFrame;
prevFrameOptions.fZeroInitialized = kNo_ZeroInitialized;
- const Result result = this->getPixels(info, pixels, rowBytes, &prevFrameOptions,
- nullptr, nullptr);
+ const Result result = this->getPixels(info, pixels, rowBytes, &prevFrameOptions);
if (result == kSuccess) {
const auto* prevFrame = frameHolder->getFrame(requiredFrame);
const auto disposalMethod = prevFrame->getDisposalMethod();
@@ -266,7 +247,7 @@
}
SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const Options* options, SkPMColor ctable[], int* ctableCount) {
+ const Options* options) {
if (kUnknown_SkColorType == info.colorType()) {
return kInvalidConversion;
}
@@ -277,8 +258,6 @@
return kInvalidParameters;
}
- CHECK_COLOR_TABLE;
-
if (!this->rewindIfNeeded()) {
return kCouldNotRewind;
}
@@ -314,14 +293,7 @@
// On an incomplete decode, the subclass will specify the number of scanlines that it decoded
// successfully.
int rowsDecoded = 0;
- const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount,
- &rowsDecoded);
-
- if (ctableCount) {
- if (kIncompleteInput == result || kSuccess == result || kErrorInInput == result) {
- SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
- }
- }
+ const Result result = this->onGetPixels(info, pixels, rowBytes, *options, &rowsDecoded);
// A return value of kIncompleteInput indicates a truncated image stream.
// In this case, we will fill any uninitialized memory with a default value.
@@ -342,12 +314,8 @@
return result;
}
-SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
- return this->getPixels(info, pixels, rowBytes, nullptr, nullptr, nullptr);
-}
-
SkCodec::Result SkCodec::startIncrementalDecode(const SkImageInfo& info, void* pixels,
- size_t rowBytes, const SkCodec::Options* options, SkPMColor* ctable, int* ctableCount) {
+ size_t rowBytes, const SkCodec::Options* options) {
fStartedIncrementalDecode = false;
if (kUnknown_SkColorType == info.colorType()) {
@@ -357,9 +325,6 @@
return kInvalidParameters;
}
- // Ensure that valid color ptrs are passed in for kIndex8 color type
- CHECK_COLOR_TABLE;
-
// FIXME: If the rows come after the rows of a previous incremental decode,
// we might be able to skip the rewind, but only the implementation knows
// that. (e.g. PNG will always need to rewind, since we called longjmp, but
@@ -399,8 +364,7 @@
fDstInfo = info;
fOptions = *options;
- const Result result = this->onStartIncrementalDecode(info, pixels, rowBytes,
- fOptions, ctable, ctableCount);
+ const Result result = this->onStartIncrementalDecode(info, pixels, rowBytes, fOptions);
if (kSuccess == result) {
fStartedIncrementalDecode = true;
} else if (kUnimplemented == result) {
@@ -418,11 +382,9 @@
SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& info,
- const SkCodec::Options* options, SkPMColor ctable[], int* ctableCount) {
+ const SkCodec::Options* options) {
// Reset fCurrScanline in case of failure.
fCurrScanline = -1;
- // Ensure that valid color ptrs are passed in for kIndex8 color type
- CHECK_COLOR_TABLE;
if (!this->rewindIfNeeded()) {
return kCouldNotRewind;
@@ -450,7 +412,7 @@
return kInvalidScale;
}
- const Result result = this->onStartScanlineDecode(info, *options, ctable, ctableCount);
+ const Result result = this->onStartScanlineDecode(info, *options);
if (result != SkCodec::kSuccess) {
return result;
}
@@ -461,12 +423,6 @@
return kSuccess;
}
-#undef CHECK_COLOR_TABLE
-
-SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& info) {
- return this->startScanlineDecode(info, nullptr, nullptr, nullptr);
-}
-
int SkCodec::getScanlines(void* dst, int countLines, size_t rowBytes) {
if (fCurrScanline < 0) {
return 0;
@@ -530,7 +486,7 @@
return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ? opaqueColor : transparentColor;
}
default: {
- // This not only handles the kN32 case, but also k565, kGray8, kIndex8, since
+ // This not only handles the kN32 case, but also k565, kGray8, since
// the low bits are zeros.
return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ?
SK_ColorBLACK : SK_ColorTRANSPARENT;
@@ -583,7 +539,6 @@
case kBGRA_8888_SkColorType:
return SkColorSpaceXform::kBGRA_8888_ColorFormat;
case kRGB_565_SkColorType:
- case kIndex_8_SkColorType:
#ifdef SK_PMCOLOR_IS_RGBA
return SkColorSpaceXform::kRGBA_8888_ColorFormat;
#else