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 SkColorSpacePrimaries { |
| 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 bool toXYZD50(SkMatrix44* toXYZD50) const; |
| 30 }; |
| 31 |
16 class SK_API SkColorSpace : public SkRefCnt { | 32 class SK_API SkColorSpace : public SkRefCnt { |
17 public: | 33 public: |
18 | 34 |
19 /** | 35 /** |
20 * Common, named profiles that we can recognize. | 36 * Common, named profiles that we can recognize. |
21 */ | 37 */ |
22 enum Named : uint8_t { | 38 enum Named : uint8_t { |
23 /** | 39 /** |
24 * By far the most common color space. | 40 * By far the most common color space. |
25 * This is the default space for images, unmarked content, and monitors
. | 41 * This is the default space for images, unmarked content, and monitors
. |
(...skipping 17 matching lines...) Expand all Loading... |
43 kLinear_RenderTargetGamma, | 59 kLinear_RenderTargetGamma, |
44 | 60 |
45 /** | 61 /** |
46 * Transfer function is the canonical sRGB curve, which has a short lin
ear segment | 62 * Transfer function is the canonical sRGB curve, which has a short lin
ear segment |
47 * followed by a 2.4f exponential. | 63 * followed by a 2.4f exponential. |
48 */ | 64 */ |
49 kSRGB_RenderTargetGamma, | 65 kSRGB_RenderTargetGamma, |
50 }; | 66 }; |
51 | 67 |
52 /** | 68 /** |
53 * Create an SkColorSpace from a transfer function and a color gamut transf
orm to D50 XYZ. | 69 * Create an SkColorSpace from a transfer function and a color gamut. |
| 70 * |
| 71 * Transfer function is specified as linear or sRGB. |
| 72 * Gamut is specified using the matrix transformation to XYZ D50. |
54 */ | 73 */ |
55 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44&
toXYZD50); | 74 static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44&
toXYZD50); |
56 | 75 |
57 /** | 76 /** |
58 * Create a common, named SkColorSpace. | 77 * Create a common, named SkColorSpace. |
59 */ | 78 */ |
60 static sk_sp<SkColorSpace> NewNamed(Named); | 79 static sk_sp<SkColorSpace> NewNamed(Named); |
61 | 80 |
62 /** | 81 /** |
63 * Create an SkColorSpace from an ICC profile. | 82 * Create an SkColorSpace from an ICC profile. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 * If both are null, we return true. If one is null and the other is not,
we return false. | 116 * If both are null, we return true. If one is null and the other is not,
we return false. |
98 * If both are non-null, we do a deeper compare. | 117 * If both are non-null, we do a deeper compare. |
99 */ | 118 */ |
100 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); | 119 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); |
101 | 120 |
102 protected: | 121 protected: |
103 SkColorSpace() {} | 122 SkColorSpace() {} |
104 }; | 123 }; |
105 | 124 |
106 #endif | 125 #endif |
OLD | NEW |