Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkColorSpace_DEFINED | 8 #ifndef SkColorSpace_DEFINED |
| 9 #define SkColorSpace_DEFINED | 9 #define SkColorSpace_DEFINED |
| 10 | 10 |
| 11 #include "SkMatrix44.h" | 11 #include "SkMatrix44.h" |
| 12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
| 13 | 13 |
| 14 class SkData; | 14 class SkData; |
| 15 | 15 |
| 16 /** | |
| 17 * Describes a color gamut with primaries and a white point. | |
| 18 */ | |
| 19 struct SK_API SkPrimaries { | |
| 20 float fRX, fRY; | |
| 21 float fGX, fGY; | |
| 22 float fBX, fBY; | |
| 23 float fWX, fWY; | |
| 24 | |
| 25 /** | |
| 26 * Convert primaries and a white point to a toXYZD50 matrix, the preferred color gamut | |
| 27 * representation of SkColorSpace. | |
| 28 */ | |
| 29 // TODO: Implement this. | |
| 30 static bool PrimariesToXYZD50(SkMatrix44* toXYZD50, const SkPrimaries& prima ries); | |
|
reed1
2016/09/07 22:50:45
nit: doesn't need to be static:
bool toXYZD50(SkM
msarett
2016/09/08 02:24:08
Done.
| |
| 31 }; | |
| 32 | |
| 33 /** | |
| 34 * Contains the coefficients for a common transfer function equation, specified as | |
| 35 * a transformation from a curved space to linear. | |
| 36 * | |
| 37 * LinearVal = E*InputVal + F , for 0.0f <= InputVal < D | |
| 38 * LinearVal = (A*InputVal + B)^G + C, for D <= InputVal <= 1.0f | |
| 39 * | |
| 40 * Function is undefined if InputVal is not in [ 0.0f, 1.0f ]. | |
| 41 * Resulting LinearVals must be in [ 0.0f, 1.0f ]. | |
| 42 * Function must be increasing. | |
| 43 */ | |
| 44 struct SK_API SkTransferFn { | |
| 45 float fG; | |
| 46 float fA; | |
| 47 float fB; | |
| 48 float fC; | |
| 49 float fD; | |
| 50 float fE; | |
| 51 float fF; | |
| 52 }; | |
| 53 | |
| 16 class SK_API SkColorSpace : public SkRefCnt { | 54 class SK_API SkColorSpace : public SkRefCnt { |
| 17 public: | 55 public: |
| 18 | 56 |
| 19 /** | 57 /** |
| 20 * Common, named profiles that we can recognize. | 58 * Common, named profiles that we can recognize. |
| 21 */ | 59 */ |
| 22 enum Named : uint8_t { | 60 enum Named : uint8_t { |
| 23 /** | 61 /** |
| 24 * By far the most common color space. | 62 * By far the most common color space. |
| 25 * This is the default space for images, unmarked content, and monitors . | 63 * This is the default space for images, unmarked content, and monitors . |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 37 kLinear_RenderTargetGamma, | 75 kLinear_RenderTargetGamma, |
| 38 | 76 |
| 39 /** | 77 /** |
| 40 * Transfer function is the canonical sRGB curve, which has a short lin ear segment | 78 * Transfer function is the canonical sRGB curve, which has a short lin ear segment |
| 41 * followed by a 2.4f exponential. | 79 * followed by a 2.4f exponential. |
| 42 */ | 80 */ |
| 43 kSRGB_RenderTargetGamma, | 81 kSRGB_RenderTargetGamma, |
| 44 }; | 82 }; |
| 45 | 83 |
| 46 /** | 84 /** |
| 47 * Create an SkColorSpace from a transfer function and a color gamut transf orm to D50 XYZ. | 85 * Create an SkColorSpace from a transfer function and a color gamut. |
| 86 * | |
| 87 * Transfer function can be specified as a render target or as the coeffici ents to an equation. | |
| 88 * Gamut is specified using the matrix transformation to XYZ D50. | |
| 48 */ | 89 */ |
| 49 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50); | 90 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50); |
| 91 static sk_sp<SkColorSpace> NewRGB(const SkTransferFn& coeffs, const SkMatrix 44& toXYZD50); | |
| 50 | 92 |
| 51 /** | 93 /** |
| 52 * Create a common, named SkColorSpace. | 94 * Create a common, named SkColorSpace. |
| 53 */ | 95 */ |
| 54 static sk_sp<SkColorSpace> NewNamed(Named); | 96 static sk_sp<SkColorSpace> NewNamed(Named); |
| 55 | 97 |
| 56 /** | 98 /** |
| 57 * Create an SkColorSpace from an ICC profile. | 99 * Create an SkColorSpace from an ICC profile. |
| 58 */ | 100 */ |
| 59 static sk_sp<SkColorSpace> NewICC(const void*, size_t); | 101 static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 */ | 140 */ |
| 99 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); | 141 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); |
| 100 | 142 |
| 101 protected: | 143 protected: |
| 102 SkColorSpace(const SkMatrix44& toXYZD50); | 144 SkColorSpace(const SkMatrix44& toXYZD50); |
| 103 | 145 |
| 104 const SkMatrix44 fToXYZD50; | 146 const SkMatrix44 fToXYZD50; |
| 105 }; | 147 }; |
| 106 | 148 |
| 107 #endif | 149 #endif |
| OLD | NEW |