aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpStandardCodec.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-06-05 15:53:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-05 20:14:57 +0000
commitc6e6a5f45e54006e861275a6d5c165830f403dcd (patch)
tree3d4bc3a0c43d6c2986728a3dffdec43e8547f43f /src/codec/SkBmpStandardCodec.cpp
parent348060fa820e1ee7a4fd246afe517a80a9ef311d (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/SkBmpStandardCodec.cpp')
-rw-r--r--src/codec/SkBmpStandardCodec.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index c223678769..959e75ba5b 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -28,7 +28,6 @@ SkBmpStandardCodec::SkBmpStandardCodec(int width, int height, const SkEncodedInf
, fIsOpaque(isOpaque)
, fInIco(inIco)
, fAndMaskRowBytes(fInIco ? SkAlign4(compute_row_bytes(this->getInfo().width(), 1)) : 0)
- , fXformOnDecode(false)
{}
/*
@@ -123,13 +122,8 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
colorTable[i] = SkPackARGB32NoCheck(0xFF, 0, 0, 0);
}
- if (this->colorXform() && !fXformOnDecode) {
- SkColorSpaceXform::ColorFormat dstFormat = select_xform_format_ct(dstColorType);
- SkColorSpaceXform::ColorFormat srcFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
- SkAlphaType xformAlphaType = select_xform_alpha(dstAlphaType,
- this->getInfo().alphaType());
- SkAssertResult(this->colorXform()->apply(dstFormat, colorTable, srcFormat, colorTable,
- maxColors, xformAlphaType));
+ if (this->colorXform() && !this->xformOnDecode()) {
+ this->applyColorXform(colorTable, colorTable, maxColors);
}
// Set the color table
@@ -198,12 +192,8 @@ void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
SkCodec::Result SkBmpStandardCodec::onPrepareToDecode(const SkImageInfo& dstInfo,
const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
- fXformOnDecode = false;
- if (this->colorXform()) {
- fXformOnDecode = apply_xform_on_decode(dstInfo.colorType(), this->getEncodedInfo().color());
- if (fXformOnDecode) {
- this->resetXformBuffer(dstInfo.width());
- }
+ if (this->xformOnDecode()) {
+ this->resetXformBuffer(dstInfo.width());
}
// Create the color table if necessary and prepare the stream for decode
@@ -240,11 +230,10 @@ int SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, void* dst, size_t
void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes);
- if (fXformOnDecode) {
+ if (this->xformOnDecode()) {
SkASSERT(this->colorXform());
- SkImageInfo xformInfo = dstInfo.makeWH(fSwizzler->swizzleWidth(), dstInfo.height());
fSwizzler->swizzle(this->xformBuffer(), this->srcBuffer());
- this->applyColorXform(xformInfo, dstRow, this->xformBuffer());
+ this->applyColorXform(dstRow, this->xformBuffer(), fSwizzler->swizzleWidth());
} else {
fSwizzler->swizzle(dstRow, this->srcBuffer());
}