SkCodec: Always use 0 for filling
This is a behavior change and a simplification.
When an image is incomplete or subset, we fill the remaining/all rows
with the fill color. A virtual method chose the fill color. Here were
the implementations:
- SkGifCodec:
Use transparent. This was changed previously to match Chromium.
- SkPngCodec/SkBmpStandardCodec:
Use the first color in the color table. This made sense when we had to
support kIndex_8, when we had to use an index from the color table.
Using that color for other types ensured that the image looked the same
in e.g. kN32 as kIndex_8. Removing this arbitrary choice simplifies the
code and moves the behavior toward Chromium's.
- SkCodec (default):
Use black for opaque images and transparent for images with alpha. A
theoretical advantage to this decision was that an incomplete image
would look the same in k565 and kN32. I don't think this is a good
enough reason to behave differently from Chromium.
Consolidate them all to just use 0. This results in transparent where
that is something we can specify. For 565 and Gray, this results in
black.
Only change to include headers is the removal of protected methods.
TBR=hcm@google.com
Change-Id: I9a7224b4e91b5c4988f3a87381653e99e40e10a5
Reviewed-on: https://skia-review.googlesource.com/145378
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index d534be0..8bfaae8 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -237,7 +237,7 @@
const size_t bpp = dstInfo.bytesPerPixel();
const size_t offset = prevRect.x() * bpp + prevRect.y() * rowBytes;
void* eraseDst = SkTAddOffset<void>(pixels, offset);
- SkSampler::Fill(info, eraseDst, rowBytes, 0, SkCodec::kNo_ZeroInitialized);
+ SkSampler::Fill(info, eraseDst, rowBytes, SkCodec::kNo_ZeroInitialized);
return true;
}
@@ -575,28 +575,12 @@
}
}
-uint64_t SkCodec::onGetFillValue(const SkImageInfo& dstInfo) const {
- switch (dstInfo.colorType()) {
- case kRGBA_F16_SkColorType: {
- static constexpr uint64_t transparentColor = 0;
- static constexpr uint64_t opaqueColor = ((uint64_t) SK_Half1) << 48;
- return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ? opaqueColor : transparentColor;
- }
- default: {
- // 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;
- }
- }
-}
-
static void fill_proc(const SkImageInfo& info, void* dst, size_t rowBytes,
- uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sampler) {
+ SkCodec::ZeroInitialized zeroInit, SkSampler* sampler) {
if (sampler) {
- sampler->fill(info, dst, rowBytes, colorOrIndex, zeroInit);
+ sampler->fill(info, dst, rowBytes, zeroInit);
} else {
- SkSampler::Fill(info, dst, rowBytes, colorOrIndex, zeroInit);
+ SkSampler::Fill(info, dst, rowBytes, zeroInit);
}
}
@@ -604,7 +588,6 @@
ZeroInitialized zeroInit, int linesRequested, int linesDecoded) {
void* fillDst;
- const uint64_t fillValue = this->getFillValue(info);
const int linesRemaining = linesRequested - linesDecoded;
SkSampler* sampler = this->getSampler(false);
@@ -617,13 +600,13 @@
case kTopDown_SkScanlineOrder: {
const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes);
- fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
+ fill_proc(fillInfo, fillDst, rowBytes, zeroInit, sampler);
break;
}
case kBottomUp_SkScanlineOrder: {
fillDst = dst;
const SkImageInfo fillInfo = info.makeWH(fillWidth, linesRemaining);
- fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
+ fill_proc(fillInfo, fillDst, rowBytes, zeroInit, sampler);
break;
}
}