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 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 /** | 68 /** |
69 * Create an SkColorSpace from an ICC profile. | 69 * Create an SkColorSpace from an ICC profile. |
70 */ | 70 */ |
71 static sk_sp<SkColorSpace> NewICC(const void*, size_t); | 71 static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
72 | 72 |
73 /** | 73 /** |
74 * Create an SkColorSpace with the same gamut as this color space, but with
linear gamma. | 74 * Create an SkColorSpace with the same gamut as this color space, but with
linear gamma. |
75 */ | 75 */ |
76 sk_sp<SkColorSpace> makeLinearGamma(); | 76 sk_sp<SkColorSpace> makeLinearGamma(); |
77 | 77 |
| 78 /** |
| 79 * DO NOT USE: Will be deleted. |
| 80 */ |
78 GammaNamed gammaNamed() const { return fGammaNamed; } | 81 GammaNamed gammaNamed() const { return fGammaNamed; } |
79 | 82 |
80 /** | 83 /** |
81 * Returns the matrix used to transform src gamut to XYZ D50. | 84 * Returns the matrix used to transform src gamut to XYZ D50. |
82 */ | 85 */ |
83 const SkMatrix44& xyz() const { return fToXYZD50; } | 86 const SkMatrix44& xyz() const { return fToXYZD50; } |
84 | 87 |
85 /** | 88 /** |
86 * Returns true if the color space gamma is near enough to be approximated
as sRGB. | 89 * Returns true if the color space gamma is near enough to be approximated
as sRGB. |
87 */ | 90 */ |
88 bool gammaCloseToSRGB() const { | 91 bool gammaCloseToSRGB() const { |
89 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam
maNamed; | 92 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam
maNamed; |
90 } | 93 } |
91 | 94 |
92 /** | 95 /** |
93 * To be used only by UMA code. | 96 * Returns true if the color space gamma is linear. |
94 */ | 97 */ |
95 bool gammasAreMatching() const; | 98 bool gammaIsLinear() const { |
96 bool gammasAreNamed() const; | 99 return kLinear_GammaNamed == fGammaNamed; |
97 bool gammasAreValues() const; | 100 } |
98 bool gammasAreTables() const; | |
99 bool gammasAreParams() const; | |
100 | 101 |
101 /** | 102 /** |
102 * Returns nullptr on failure. Fails when we fallback to serializing ICC d
ata and | 103 * Returns nullptr on failure. Fails when we fallback to serializing ICC d
ata and |
103 * the data is too large to serialize. | 104 * the data is too large to serialize. |
104 */ | 105 */ |
105 sk_sp<SkData> serialize() const; | 106 sk_sp<SkData> serialize() const; |
106 | 107 |
107 /** | 108 /** |
108 * If |memory| is nullptr, returns the size required to serialize. | 109 * If |memory| is nullptr, returns the size required to serialize. |
109 * Otherwise, serializes into |memory| and returns the size. | 110 * Otherwise, serializes into |memory| and returns the size. |
110 */ | 111 */ |
111 size_t writeToMemory(void* memory) const; | 112 size_t writeToMemory(void* memory) const; |
112 | 113 |
113 static sk_sp<SkColorSpace> Deserialize(const void* data, size_t length); | 114 static sk_sp<SkColorSpace> Deserialize(const void* data, size_t length); |
114 | 115 |
115 /** | 116 /** |
116 * If both are null, we return true. If one is null and the other is not,
we return false. | 117 * If both are null, we return true. If one is null and the other is not,
we return false. |
117 * If both are non-null, we do a deeper compare. | 118 * If both are non-null, we do a deeper compare. |
118 */ | 119 */ |
119 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); | 120 static bool Equals(const SkColorSpace* src, const SkColorSpace* dst); |
120 | 121 |
121 protected: | 122 protected: |
122 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50); | 123 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50); |
123 | 124 |
124 const GammaNamed fGammaNamed; | 125 const GammaNamed fGammaNamed; |
125 const SkMatrix44 fToXYZD50; | 126 const SkMatrix44 fToXYZD50; |
126 }; | 127 }; |
127 | 128 |
128 #endif | 129 #endif |
OLD | NEW |