aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkColorSpacePriv.h
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-06-19 12:43:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-10 17:08:28 +0000
commita8565e502db3e4c0bcdac04be03751bd8ca99cb1 (patch)
treee0d199f10c1f8a3a5be657de948de943a7720874 /src/core/SkColorSpacePriv.h
parent742a3e298fda669006147e4a305bab8452369b1f (diff)
ICC: SkICCGetColorProfileTag supports special cases
Special cases: - "sRGB" - "AdobeRGB" - "DCI-P3" - "Linear Transfer with sRGB Gamut" - "2.2 Transfer with sRGB Gamut" - "sRGB Transfer with DCI-P3 Gamut" - "Linear Transfer with DCI-P3 Gamut" - "sRGB Transfer with Rec-BT-2020 Gamut" - "Linear Transfer with Rec-BT-2020 Gamut" tools/colorspaceinfo now prints out the Tag. Also: constants representing gSRGB_TransferFn, g2Dot2_TransferFn, and gLinear_TransferFn, gDCIP3_TransferFn. BUG=skia:6720 Change-Id: I92a3f9db9d744d3ec366e4e59afd759ba043c235 Reviewed-on: https://skia-review.googlesource.com/20225 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/core/SkColorSpacePriv.h')
-rw-r--r--src/core/SkColorSpacePriv.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/core/SkColorSpacePriv.h b/src/core/SkColorSpacePriv.h
index 4a63ddfa14..85c5afc36d 100644
--- a/src/core/SkColorSpacePriv.h
+++ b/src/core/SkColorSpacePriv.h
@@ -37,6 +37,20 @@ static constexpr float gRec2020_toXYZD50[] {
-0.00193139f, 0.0299794f, 0.797162f, // Rz, Gz, Bz
};
+static constexpr SkColorSpaceTransferFn gSRGB_TransferFn =
+ { 2.4f, 1.0f / 1.055f, 0.055f / 1.055f, 1.0f / 12.92f, 0.04045f, 0.0f, 0.0f };
+
+static constexpr SkColorSpaceTransferFn g2Dot2_TransferFn =
+ { 2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
+
+// gLinear_TransferFn.fD > 1.0f: Make sure that we use the linear segment of
+// the transfer function even when the x-value is 1.0f.
+static constexpr SkColorSpaceTransferFn gLinear_TransferFn =
+ { 0.0f, 0.0f, 0.0f, 1.0f, 1.0000001f, 0.0f, 0.0f };
+
+static constexpr SkColorSpaceTransferFn gDCIP3_TransferFn =
+ { 2.399994f, 0.947998047f, 0.0520019531f, 0.0769958496f, 0.0390014648f, 0.0f, 0.0f };
+
static inline void to_xyz_d50(SkMatrix44* toXYZD50, SkColorSpace::Gamut gamut) {
switch (gamut) {
case SkColorSpace::kSRGB_Gamut:
@@ -121,13 +135,13 @@ static inline bool is_valid_transfer_fn(const SkColorSpaceTransferFn& coeffs) {
}
static inline bool is_almost_srgb(const SkColorSpaceTransferFn& coeffs) {
- return transfer_fn_almost_equal(1.0f / 1.055f, coeffs.fA) &&
- transfer_fn_almost_equal(0.055f / 1.055f, coeffs.fB) &&
- transfer_fn_almost_equal(1.0f / 12.92f, coeffs.fC) &&
- transfer_fn_almost_equal(0.04045f, coeffs.fD) &&
- transfer_fn_almost_equal(0.00000f, coeffs.fE) &&
- transfer_fn_almost_equal(0.00000f, coeffs.fF) &&
- transfer_fn_almost_equal(2.40000f, coeffs.fG);
+ return transfer_fn_almost_equal(gSRGB_TransferFn.fA, coeffs.fA) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fB, coeffs.fB) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fC, coeffs.fC) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fD, coeffs.fD) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fE, coeffs.fE) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fF, coeffs.fF) &&
+ transfer_fn_almost_equal(gSRGB_TransferFn.fG, coeffs.fG);
}
static inline bool is_almost_2dot2(const SkColorSpaceTransferFn& coeffs) {
@@ -170,27 +184,13 @@ static inline bool named_to_parametric(SkColorSpaceTransferFn* coeffs,
SkGammaNamed gammaNamed) {
switch (gammaNamed) {
case kSRGB_SkGammaNamed:
- coeffs->fA = 1.0f / 1.055f;
- coeffs->fB = 0.055f / 1.055f;
- coeffs->fC = 1.0f / 12.92f;
- coeffs->fD = 0.04045f;
- coeffs->fE = 0.0f;
- coeffs->fF = 0.0f;
- coeffs->fG = 2.4f;
+ *coeffs = gSRGB_TransferFn;
return true;
case k2Dot2Curve_SkGammaNamed:
- value_to_parametric(coeffs, 2.2f);
+ *coeffs = g2Dot2_TransferFn;
return true;
case kLinear_SkGammaNamed:
- coeffs->fA = 0.0f;
- coeffs->fB = 0.0f;
- coeffs->fC = 1.0f;
- // Make sure that we use the linear segment of the transfer function even
- // when the x-value is 1.0f.
- coeffs->fD = nextafterf(1.0f, 2.0f);
- coeffs->fE = 0.0f;
- coeffs->fF = 0.0f;
- coeffs->fG = 0.0f;
+ *coeffs = gLinear_TransferFn;
return true;
default:
return false;