SkAndroidCodec: Leave pixels in encoded colorspace when tf is numerical
Color space conversion will be deferred until later. Change-Id: I0fbade9bb374fe2ee9328f87284a2d86a199f7b4 Reviewed-on: https://skia-review.googlesource.com/9080 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
1ac8fd2538
commit
9341c98113
@ -173,8 +173,16 @@ sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputCo
|
||||
switch (outputColorType) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
case kBGRA_8888_SkColorType:
|
||||
case kIndex_8_SkColorType:
|
||||
if (is_wide_gamut(fCodec->getInfo().colorSpace())) {
|
||||
case kIndex_8_SkColorType: {
|
||||
SkColorSpace* encodedSpace = fCodec->getInfo().colorSpace();
|
||||
SkColorSpaceTransferFn fn;
|
||||
if (encodedSpace->isNumericalTransferFn(&fn)) {
|
||||
// Leave the pixels in the encoded color space. Color space conversion
|
||||
// will be handled after decode time.
|
||||
return as_CSB(encodedSpace)->makeWithNonLinearBlending();
|
||||
}
|
||||
|
||||
if (is_wide_gamut(encodedSpace)) {
|
||||
return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
|
||||
SkColorSpace::kDCIP3_D65_Gamut,
|
||||
SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
|
||||
@ -183,6 +191,7 @@ sk_sp<SkColorSpace> SkAndroidCodec::computeOutputColorSpace(SkColorType outputCo
|
||||
return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
|
||||
SkColorSpace::kSRGB_Gamut,
|
||||
SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
|
||||
}
|
||||
case kRGBA_F16_SkColorType:
|
||||
return SkColorSpace::MakeSRGBLinear();
|
||||
default:
|
||||
|
@ -312,6 +312,21 @@ sk_sp<SkColorSpace> SkColorSpace_Base::makeWithoutFlags() {
|
||||
return SkColorSpace::MakeRGB(fn, *this->toXYZD50(), 0);
|
||||
}
|
||||
|
||||
sk_sp<SkColorSpace> SkColorSpace_Base::makeWithNonLinearBlending() {
|
||||
if (SkToBool(SkColorSpace::kNonLinearBlending_ColorSpaceFlag & fFlags)) {
|
||||
return sk_ref_sp(this);
|
||||
}
|
||||
|
||||
// This should only be called on XYZ color spaces. A2B color spaces are never
|
||||
// allowed to be destinations - which means that this flag does not make any
|
||||
// sense for them.
|
||||
SkASSERT(Type::kXYZ == this->type());
|
||||
SkColorSpaceTransferFn fn;
|
||||
SkAssertResult(this->onIsNumericalTransferFn(&fn));
|
||||
return SkColorSpace::MakeRGB(fn, *this->toXYZD50(),
|
||||
SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum Version {
|
||||
|
@ -181,6 +181,7 @@ public:
|
||||
virtual sk_sp<SkColorSpace> makeSRGBGamma() = 0;
|
||||
|
||||
sk_sp<SkColorSpace> makeWithoutFlags();
|
||||
sk_sp<SkColorSpace> makeWithNonLinearBlending();
|
||||
|
||||
enum class Type : uint8_t {
|
||||
kXYZ,
|
||||
|
Loading…
Reference in New Issue
Block a user