aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-11-03 16:15:20 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-03 20:58:13 +0000
commit1b96c6f91377431cd407c43fedac613fff21c2ed (patch)
tree0a4d5899f2cae7573aa85d56866ad7613338b6f2 /src/codec/SkBmpCodec.cpp
parent6e437b7d177cabdb9822b437ed2caefebe6b469b (diff)
Add F16, SkColorSpaceXform support to SkBmpCodec
BUG=skia:4895 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4390 Change-Id: I9cb727e7f13816b0ac882f62ec635a4528c3a524 Reviewed-on: https://skia-review.googlesource.com/4390 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkBmpCodec.cpp')
-rw-r--r--src/codec/SkBmpCodec.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index b3a8010d84..7cd1dfe6c1 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -587,6 +587,7 @@ SkBmpCodec::SkBmpCodec(int width, int height, const SkEncodedInfo& info, SkStrea
, fBitsPerPixel(bitsPerPixel)
, fRowOrder(rowOrder)
, fSrcRowBytes(SkAlign4(compute_row_bytes(width, fBitsPerPixel)))
+ , fXformBuffer(nullptr)
{}
bool SkBmpCodec::onRewind() {
@@ -601,13 +602,17 @@ int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const {
return height - y - 1;
}
-SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
+SkCodec::Result SkBmpCodec::prepareToDecode(const SkImageInfo& dstInfo,
const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
- if (!conversion_possible_ignore_color_space(dstInfo, this->getInfo())) {
- SkCodecPrintf("Error: cannot convert input type to output type.\n");
+ if (!conversion_possible(dstInfo, this->getInfo()) || !this->initializeColorXform(dstInfo)) {
return kInvalidConversion;
}
+ return this->onPrepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
+}
+
+SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
+ const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
}
@@ -627,3 +632,15 @@ bool SkBmpCodec::skipRows(int count) {
bool SkBmpCodec::onSkipScanlines(int count) {
return this->skipRows(count);
}
+
+void SkBmpCodec::applyColorXform(const SkImageInfo& dstInfo, void* dst, void* src) const {
+ SkColorSpaceXform* xform = this->colorXform();
+ if (xform) {
+ SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
+ SkColorSpaceXform::ColorFormat srcFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
+ SkAlphaType alphaType = select_xform_alpha(dstInfo.alphaType(),
+ this->getInfo().alphaType());
+ SkAssertResult(xform->apply(dstFormat, dst, srcFormat, src, dstInfo.width(),
+ alphaType));
+ }
+}