diff options
author | Matt Sarett <msarett@google.com> | 2017-04-11 09:51:32 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-11 14:27:28 +0000 |
commit | 68feef423dfa1f3e2e6e9b0f4df1027f6e8645b1 (patch) | |
tree | 39da66c24218258f5b8abb1c64a7a236ab1529e4 /src/codec | |
parent | 3fbca26e9c0e6e3c27c9dd437c9f790a31f20675 (diff) |
Allow BF and BRD clients to request an output color space
Bug: skia:
Change-Id: I0f0d3bfdd5c47544ab71167fd7984ee8e8ac5903
Reviewed-on: https://skia-review.googlesource.com/11601
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.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp index 6e1f4b853e..96ad72a259 100644 --- a/src/codec/SkAndroidCodec.cpp +++ b/src/codec/SkAndroidCodec.cpp @@ -169,13 +169,19 @@ SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) { return requestedUnpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType; } -sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputColorType) { +sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputColorType, + sk_sp<SkColorSpace> prefColorSpace) { switch (outputColorType) { case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: case kIndex_8_SkColorType: { - SkColorSpace* encodedSpace = fCodec->getInfo().colorSpace(); + // If |prefColorSpace| is supported, choose it. SkColorSpaceTransferFn fn; + if (prefColorSpace && prefColorSpace->isNumericalTransferFn(&fn)) { + return prefColorSpace; + } + + SkColorSpace* encodedSpace = fCodec->getInfo().colorSpace(); if (encodedSpace->isNumericalTransferFn(&fn)) { // Leave the pixels in the encoded color space. Color space conversion // will be handled after decode time. @@ -190,8 +196,10 @@ sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputCo return SkColorSpace::MakeSRGB(); } case kRGBA_F16_SkColorType: + // Note that |prefColorSpace| is ignored, F16 is always linear sRGB. return SkColorSpace::MakeSRGBLinear(); case kRGB_565_SkColorType: + // Note that |prefColorSpace| is ignored, 565 is always sRGB. return SkColorSpace::MakeSRGB(); default: // Color correction not supported for kGray. |