diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-06-05 15:53:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-05 20:14:57 +0000 |
commit | c6e6a5f45e54006e861275a6d5c165830f403dcd (patch) | |
tree | 3d4bc3a0c43d6c2986728a3dffdec43e8547f43f /src/codec/SkPngCodec.cpp | |
parent | 348060fa820e1ee7a4fd246afe517a80a9ef311d (diff) |
Simplify SkCodecs' call to SkColorSpaceXform::apply
Most SkCodec subclasses did the following to apply their
SkColorSpaceXform:
dstFormat = select_xform_format(dstInfo.colorType());
srcFormat = select_xform_format(<something that doesn't change>);
xformAlphaType = select_xform_alpha(dstInfo.alphaType(),
this->getInfo().alphaType());
this->colorXform()->apply(dstFormat, dst, srcFormat, src, width,
xformAlphaType);
Consolidate the computation of these parameters into SkCodec and add a
new method to SkCodec that calls apply() with those parameters.
Add a SkColorSpaceXform::ColorFormat to SkCodec. This allows the new
method SkCodec::applyColorXform to supply the ColorFormat.
TBR=reed@google.com
(No change to public API.)
Change-Id: I8ea7ba4c0024be827a9f9359796c778744330f6e
Reviewed-on: https://skia-review.googlesource.com/18523
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkPngCodec.cpp')
-rw-r--r-- | src/codec/SkPngCodec.cpp | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index 1c5f821c65..29057cb298 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -296,15 +296,8 @@ bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo, int* ctableCount) } } - if (this->colorXform() && - !apply_xform_on_decode(dstInfo.colorType(), this->getEncodedInfo().color())) { - const SkColorSpaceXform::ColorFormat dstFormat = - select_xform_format_ct(dstInfo.colorType()); - const SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(kXformSrcColorType); - const SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(), - this->getInfo().alphaType()); - SkAssertResult(this->colorXform()->apply(dstFormat, colorTable, srcFormat, colorTable, - numColors, xformAlphaType)); + if (this->colorXform() && !this->xformOnDecode()) { + this->applyColorXform(colorTable, colorTable, numColors); } // Pad the color table with the last color in the table (or black) in the case that @@ -476,20 +469,16 @@ static SkColorSpaceXform::ColorFormat png_select_xform_format(const SkEncodedInf } void SkPngCodec::applyXformRow(void* dst, const void* src) { - const SkColorSpaceXform::ColorFormat srcColorFormat = - png_select_xform_format(this->getEncodedInfo()); switch (fXformMode) { case kSwizzleOnly_XformMode: fSwizzler->swizzle(dst, (const uint8_t*) src); break; case kColorOnly_XformMode: - SkAssertResult(this->colorXform()->apply(fXformColorFormat, dst, srcColorFormat, src, - fXformWidth, fXformAlphaType)); + this->applyColorXform(dst, src, fXformWidth); break; case kSwizzleColor_XformMode: fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); - SkAssertResult(this->colorXform()->apply(fXformColorFormat, dst, srcColorFormat, - fColorXformSrcRow, fXformWidth, fXformAlphaType)); + this->applyColorXform(dst, fColorXformSrcRow, fXformWidth); break; } } @@ -958,7 +947,7 @@ void AutoCleanPng::infoCallback(size_t idatLength) { SkPngCodec::SkPngCodec(const SkEncodedInfo& encodedInfo, const SkImageInfo& imageInfo, SkStream* stream, SkPngChunkReader* chunkReader, void* png_ptr, void* info_ptr, int bitDepth) - : INHERITED(encodedInfo, imageInfo, stream) + : INHERITED(encodedInfo, imageInfo, png_select_xform_format(encodedInfo), stream) , fPngChunkReader(SkSafeRef(chunkReader)) , fPng_ptr(png_ptr) , fInfo_ptr(info_ptr) @@ -1039,15 +1028,9 @@ SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const O void SkPngCodec::initializeXformParams() { switch (fXformMode) { case kColorOnly_XformMode: - fXformColorFormat = select_xform_format(this->dstInfo().colorType()); - fXformAlphaType = select_xform_alpha(this->dstInfo().alphaType(), - this->getInfo().alphaType()); fXformWidth = this->dstInfo().width(); break; case kSwizzleColor_XformMode: - fXformColorFormat = select_xform_format(this->dstInfo().colorType()); - fXformAlphaType = select_xform_alpha(this->dstInfo().alphaType(), - this->getInfo().alphaType()); fXformWidth = this->swizzler()->swizzleWidth(); break; default: @@ -1060,9 +1043,7 @@ void SkPngCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& o SkImageInfo swizzlerInfo = dstInfo; Options swizzlerOptions = options; fXformMode = kSwizzleOnly_XformMode; - if (this->colorXform() && - apply_xform_on_decode(dstInfo.colorType(), this->getEncodedInfo().color())) - { + if (this->colorXform() && this->xformOnDecode()) { swizzlerInfo = swizzlerInfo.makeColorType(kXformSrcColorType); if (kPremul_SkAlphaType == dstInfo.alphaType()) { swizzlerInfo = swizzlerInfo.makeAlphaType(kUnpremul_SkAlphaType); |