aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-12-12 16:30:13 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-12 22:19:05 +0000
commit966bb348a5bdeec44252ede4cb73ba907af2d92b (patch)
tree42f15254a018158a6a05d36c049d8160c48c1118 /src/codec
parent131c1fb96328ee00cb18f629eddfb665b36e9463 (diff)
Decode to sRGB on Android
I want to land this so we can start testing color space aware decoding on Android. In particular, it will be interesting to see how linear premultiplication will affect existing content. This will only modify BitmapRegionDecoder behavior. I'll follow up with a similar change to BitmapFactory.cpp in Android. This will cause image diffs on Gold. BUG=skia: Change-Id: Iffda5f035447f2608ce26945570b503f8971b735 Reviewed-on: https://skia-review.googlesource.com/5698 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkAndroidCodec.cpp14
-rw-r--r--src/codec/SkJpegCodec.cpp2
2 files changed, 15 insertions, 1 deletions
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp
index c315b032fb..5dddfe355e 100644
--- a/src/codec/SkAndroidCodec.cpp
+++ b/src/codec/SkAndroidCodec.cpp
@@ -114,6 +114,20 @@ SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {
return requestedUnpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
}
+sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputColorType) {
+ switch (outputColorType) {
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType:
+ case kIndex_8_SkColorType:
+ return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
+ case kRGBA_F16_SkColorType:
+ return SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named);
+ default:
+ // Color correction not supported for k565 and kGray.
+ return nullptr;
+ }
+}
+
SkISize SkAndroidCodec::getSampledDimensions(int sampleSize) const {
if (!is_valid_sample_size(sampleSize)) {
return SkISize::Make(0, 0);
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 7867fd0e8b..ad5ce5834d 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -503,7 +503,7 @@ int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes
uint32_t* swizzleDst = (uint32_t*) dst;
size_t decodeDstRowBytes = rowBytes;
size_t swizzleDstRowBytes = rowBytes;
- int dstWidth = dstInfo.width();
+ int dstWidth = this->options().fSubset ? this->options().fSubset->width() : dstInfo.width();
if (fSwizzleSrcRow && fColorXformSrcRow) {
decodeDst = (JSAMPLE*) fSwizzleSrcRow;
swizzleDst = fColorXformSrcRow;