aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-06-16 07:37:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-16 07:37:41 -0700
commitc4ce6b592487305de251bbebaf8eeee38371b877 (patch)
tree8715df359e6f40c6eff5603abe43d9ac0dc2b724 /include/core
parentded0f26a93a115fdb8f2eb99841b85cc16baf400 (diff)
Differentiate between sRGBGamma and 2Dot2Gamma
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkColorSpace.h47
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);