aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-11-02 16:18:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-03 16:33:33 +0000
commitd851795e7992565c1eb2b9474ee5ad01d1a01fad (patch)
treea7293bc7bf6609e882092ded278956f58852a981 /src/codec/SkBmpCodec.cpp
parenteea7c16d59a163bd5b858891bc916c49063ed8ac (diff)
Add F16, SkColorSpaceXform support to SkBmpCodec
BUG=skia:4895 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4300 Change-Id: I2f2b8d3854ea3a8c5904dd3c5bea0342e2be9789 Reviewed-on: https://skia-review.googlesource.com/4300 Reviewed-by: Leon Scroggins <scroggo@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 b0ef8ad1d8..d99ba3ae43 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));
+ }
+}