make make{SRGB,Linear}Gamma() const

Change-Id: If20a43a905ae65643d071978b345d9ff09c04cf1
Reviewed-on: https://skia-review.googlesource.com/19541
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-06-12 15:20:33 -04:00 committed by Skia Commit-Bot
parent 9bada5475f
commit b1e6cfdb28
4 changed files with 10 additions and 10 deletions

View File

@ -54,13 +54,13 @@ public:
bool onIsCMYK() const override { return kCMYK_ICCTypeFlag == fICCType; }
sk_sp<SkColorSpace> makeLinearGamma() override {
sk_sp<SkColorSpace> makeLinearGamma() const override {
// TODO: Analyze the extrema of our projection into XYZ and use suitable primaries?
// For now, just fall back to a default, because we don't have a good answer.
return SkColorSpace::MakeSRGBLinear();
}
sk_sp<SkColorSpace> makeSRGBGamma() override {
sk_sp<SkColorSpace> makeSRGBGamma() const override {
// See comment in makeLinearGamma
return SkColorSpace::MakeSRGB();
}

View File

@ -171,14 +171,14 @@ public:
* For color spaces whose gamut can not be described in terms of XYZ D50, returns
* linear sRGB.
*/
virtual sk_sp<SkColorSpace> makeLinearGamma() = 0;
virtual sk_sp<SkColorSpace> makeLinearGamma() const = 0;
/**
* Returns a color space with the same gamut as this one, with with the sRGB transfer
* function. For color spaces whose gamut can not be described in terms of XYZ D50, returns
* sRGB.
*/
virtual sk_sp<SkColorSpace> makeSRGBGamma() = 0;
virtual sk_sp<SkColorSpace> makeSRGBGamma() const = 0;
enum class Type : uint8_t {
kXYZ,

View File

@ -82,16 +82,16 @@ bool SkColorSpace_XYZ::onIsNumericalTransferFn(SkColorSpaceTransferFn* coeffs) c
return false;
}
sk_sp<SkColorSpace> SkColorSpace_XYZ::makeLinearGamma() {
sk_sp<SkColorSpace> SkColorSpace_XYZ::makeLinearGamma() const {
if (this->gammaIsLinear()) {
return sk_ref_sp(this);
return sk_ref_sp(const_cast<SkColorSpace_XYZ*>(this));
}
return SkColorSpace_Base::MakeRGB(kLinear_SkGammaNamed, fToXYZD50);
}
sk_sp<SkColorSpace> SkColorSpace_XYZ::makeSRGBGamma() {
sk_sp<SkColorSpace> SkColorSpace_XYZ::makeSRGBGamma() const {
if (this->gammaCloseToSRGB()) {
return sk_ref_sp(this);
return sk_ref_sp(const_cast<SkColorSpace_XYZ*>(this));
}
return SkColorSpace_Base::MakeRGB(kSRGB_SkGammaNamed, fToXYZD50);
}

View File

@ -27,8 +27,8 @@ public:
Type type() const override { return Type::kXYZ; }
sk_sp<SkColorSpace> makeLinearGamma() override;
sk_sp<SkColorSpace> makeSRGBGamma() override;
sk_sp<SkColorSpace> makeLinearGamma() const override;
sk_sp<SkColorSpace> makeSRGBGamma() const override;
SkGammaNamed gammaNamed() const { return fGammaNamed; }