Remove SkEncodedInfo kPreSwizzled_Color from public API

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1918943002

Review URL: https://codereview.chromium.org/1918943002
This commit is contained in:
msarett 2016-04-25 11:41:15 -07:00 committed by Commit bot
parent 7bedaf5606
commit 68758aed88
4 changed files with 305 additions and 295 deletions

View File

@ -64,10 +64,6 @@ public:
// be treated as inverted CMYK.
kInvertedCMYK_Color,
kYCCK_Color,
// Used internally to indicate that the decoding library has
// pre-swizzled to the desired output format.
kPreSwizzled_Color,
};
static SkEncodedInfo Make(Color color, Alpha alpha, int bitsPerComponent) {

View File

@ -518,15 +518,17 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
// libjpeg-turbo may have already performed color conversion. We must indicate the
// appropriate format to the swizzler.
SkEncodedInfo swizzlerInfo = this->getEncodedInfo();
bool preSwizzled = true;
switch (fDecoderMgr->dinfo()->out_color_space) {
case JCS_RGB:
preSwizzled = false;
swizzlerInfo.setColor(SkEncodedInfo::kRGB_Color);
break;
case JCS_CMYK:
preSwizzled = false;
swizzlerInfo.setColor(SkEncodedInfo::kInvertedCMYK_Color);
break;
default:
swizzlerInfo.setColor(SkEncodedInfo::kPreSwizzled_Color);
break;
}
@ -539,7 +541,8 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
fSwizzlerSubset.width() == options.fSubset->width());
swizzlerOptions.fSubset = &fSwizzlerSubset;
}
fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, swizzlerOptions));
fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, swizzlerOptions,
nullptr, preSwizzled));
SkASSERT(fSwizzler);
fStorage.reset(get_row_bytes(fDecoderMgr->dinfo()));
fSrcRow = fStorage.get();

View File

@ -651,16 +651,37 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
const SkPMColor* ctable,
const SkImageInfo& dstInfo,
const SkCodec::Options& options,
const SkIRect* frame) {
const SkIRect* frame,
bool preSwizzled) {
if (SkEncodedInfo::kPalette_Color == encodedInfo.color() && nullptr == ctable) {
return nullptr;
}
RowProc fastProc = nullptr;
RowProc proc = nullptr;
if (preSwizzled) {
switch (dstInfo.colorType()) {
case kGray_8_SkColorType:
proc = &sample1;
fastProc = ©
break;
case kRGB_565_SkColorType:
proc = &sample2;
fastProc = ©
break;
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
proc = &sample4;
fastProc = ©
break;
default:
return nullptr;
}
} else {
SkCodec::ZeroInitialized zeroInit = options.fZeroInitialized;
const bool premultiply = (SkEncodedInfo::kOpaque_Alpha != encodedInfo.alpha()) &&
(kPremul_SkAlphaType == dstInfo.alphaType());
switch (encodedInfo.color()) {
case SkEncodedInfo::kGray_Color:
switch (encodedInfo.bitsPerComponent()) {
@ -711,7 +732,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
case kBGRA_8888_SkColorType:
if (premultiply) {
if (SkCodec::kYes_ZeroInitialized == zeroInit) {
proc = &SkipLeadingGrayAlphaZerosThen<swizzle_grayalpha_to_n32_premul>;
proc = &SkipLeadingGrayAlphaZerosThen
<swizzle_grayalpha_to_n32_premul>;
fastProc = &SkipLeadingGrayAlphaZerosThen
<fast_swizzle_grayalpha_to_n32_premul>;
} else {
@ -804,7 +826,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
if (premultiply) {
if (SkCodec::kYes_ZeroInitialized == zeroInit) {
proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_rgba_premul>;
fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rgba_to_rgba_premul>;
fastProc = &SkipLeading8888ZerosThen
<fast_swizzle_rgba_to_rgba_premul>;
} else {
proc = &swizzle_rgba_to_rgba_premul;
fastProc = &fast_swizzle_rgba_to_rgba_premul;
@ -823,7 +846,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
if (premultiply) {
if (SkCodec::kYes_ZeroInitialized == zeroInit) {
proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgra_premul>;
fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rgba_to_bgra_premul>;
fastProc = &SkipLeading8888ZerosThen
<fast_swizzle_rgba_to_bgra_premul>;
} else {
proc = &swizzle_rgba_to_bgra_premul;
fastProc = &fast_swizzle_rgba_to_bgra_premul;
@ -881,7 +905,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
if (premultiply) {
if (SkCodec::kYes_ZeroInitialized == zeroInit) {
proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_rgba_premul>;
fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rgba_to_rgba_premul>;
fastProc = &SkipLeading8888ZerosThen
<fast_swizzle_rgba_to_rgba_premul>;
} else {
proc = &swizzle_rgba_to_rgba_premul;
fastProc = &fast_swizzle_rgba_to_rgba_premul;
@ -900,7 +925,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
if (premultiply) {
if (SkCodec::kYes_ZeroInitialized == zeroInit) {
proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgra_premul>;
fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rgba_to_bgra_premul>;
fastProc = &SkipLeading8888ZerosThen
<fast_swizzle_rgba_to_bgra_premul>;
} else {
proc = &swizzle_rgba_to_bgra_premul;
fastProc = &fast_swizzle_rgba_to_bgra_premul;
@ -937,32 +963,14 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
return nullptr;
}
break;
case SkEncodedInfo::kPreSwizzled_Color:
switch (dstInfo.colorType()) {
case kGray_8_SkColorType:
proc = &sample1;
fastProc = &copy;
break;
case kRGB_565_SkColorType:
proc = &sample2;
fastProc = &copy;
break;
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
proc = &sample4;
fastProc = &copy;
break;
default:
return nullptr;
}
break;
default:
return nullptr;
}
int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType());
int srcBPP;
if (SkEncodedInfo::kPreSwizzled_Color == encodedInfo.color()) {
const int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType());
if (preSwizzled) {
srcBPP = dstBPP;
} else {
// Store bpp in bytes if it is an even multiple, otherwise use bits

View File

@ -27,6 +27,9 @@ public:
* Contains partial scanline information.
* @param frame Is non-NULL if the source pixels are part of an image
* frame that is a subset of the full image.
* @param preSwizzled Indicates that the codec has already swizzled to the
* destination format. The swizzler only needs to sample
* and/or subset.
*
* Note that a deeper discussion of partial scanline subsets and image frame
* subsets is below. Currently, we do not support both simultaneously. If
@ -36,7 +39,7 @@ public:
*/
static SkSwizzler* CreateSwizzler(const SkEncodedInfo& encodedInfo, const SkPMColor* ctable,
const SkImageInfo& dstInfo, const SkCodec::Options&,
const SkIRect* frame = nullptr);
const SkIRect* frame = nullptr, bool preSwizzled = false);
/**
* Swizzle a line. Generally this will be called height times, once