diff options
author | msarett <msarett@google.com> | 2016-06-16 07:37:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-16 07:37:41 -0700 |
commit | c4ce6b592487305de251bbebaf8eeee38371b877 (patch) | |
tree | 8715df359e6f40c6eff5603abe43d9ac0dc2b724 /include/core | |
parent | ded0f26a93a115fdb8f2eb99841b85cc16baf400 (diff) |
Differentiate between sRGBGamma and 2Dot2Gamma
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2067833003
Review-Url: https://codereview.chromium.org/2067833003
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkColorSpace.h | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h index 0b3b9768ec..0f57b6d680 100644 --- a/include/core/SkColorSpace.h +++ b/include/core/SkColorSpace.h @@ -23,27 +23,18 @@ public: kAdobeRGB_Named, }; - /** - * Create an SkColorSpace from the src gamma and a transform from src gamut to D50 XYZ. - */ - static sk_sp<SkColorSpace> NewRGB(const float gammas[3], const SkMatrix44& toXYZD50); - - /** - * Create a common, named SkColorSpace. - */ - static sk_sp<SkColorSpace> NewNamed(Named); - - /** - * Create an SkColorSpace from an ICC profile. - */ - static sk_sp<SkColorSpace> NewICC(const void*, size_t); - enum GammaNamed { kLinear_GammaNamed, /** - * Gamma curve is a close match to the 2.2f exponential curve. This is by far - * the most common gamma, and is used by sRGB and Adobe RGB profiles. + * Gamma curve is a close match to the canonical sRGB curve, which has + * a short linear segment followed by a 2.4f exponential. + */ + kSRGB_GammaNamed, + + /** + * Gamma curve is a close match to the 2.2f exponential curve. This is + * used by Adobe RGB profiles and is common on monitors as well. */ k2Dot2Curve_GammaNamed, @@ -55,6 +46,21 @@ public: kNonStandard_GammaNamed, }; + /** + * Create an SkColorSpace from the src gamma and a transform from src gamut to D50 XYZ. + */ + static sk_sp<SkColorSpace> NewRGB(GammaNamed gammaNamed, const SkMatrix44& toXYZD50); + + /** + * Create a common, named SkColorSpace. + */ + static sk_sp<SkColorSpace> NewNamed(Named); + + /** + * Create an SkColorSpace from an ICC profile. + */ + static sk_sp<SkColorSpace> NewICC(const void*, size_t); + GammaNamed gammaNamed() const { return fGammaNamed; } /** @@ -62,6 +68,13 @@ public: */ const SkMatrix44& xyz() const { return fToXYZD50; } + /** + * Returns true if the color space gamma is near enough to be approximated as sRGB. + */ + bool gammaCloseToSRGB() const { + return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGammaNamed; + } + protected: SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named); |