OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 */ | 129 */ |
130 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, | 130 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, |
131 SkAlphaType* canonical = NULL); | 131 SkAlphaType* canonical = NULL); |
132 | 132 |
133 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
134 | 134 |
135 /** | 135 /** |
136 * Describe an image's dimensions and pixel type. | 136 * Describe an image's dimensions and pixel type. |
137 */ | 137 */ |
138 struct SkImageInfo { | 138 struct SkImageInfo { |
139 public: | |
139 int fWidth; | 140 int fWidth; |
140 int fHeight; | 141 int fHeight; |
141 SkColorType fColorType; | 142 SkColorType fColorType; |
142 SkAlphaType fAlphaType; | 143 SkAlphaType fAlphaType; |
143 | 144 |
145 //private: | |
146 enum Profile { | |
147 kUnknown_Profile, | |
148 kSRGB_Profile, | |
149 kExponential_Profile, | |
150 }; | |
151 | |
152 uint32_t fProfile; | |
153 float fGamma; | |
154 | |
155 public: | |
156 static SkImageInfo MakeSRGB(int width, int height, SkColorType ct, SkAlphaTy pe at); | |
157 | |
158 static SkImageInfo MakeWithGamam(int width, int height, SkColorType ct, SkAl phaType at, | |
bsalomon
2014/08/27 17:11:30
typo, gamam
reed1
2014/08/27 18:52:49
Done.
| |
159 float gamma); | |
160 | |
144 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t) { | 161 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t) { |
145 SkImageInfo info = { | 162 SkImageInfo info = { |
146 width, height, ct, at | 163 width, height, ct, at, kUnknown_Profile, 0 |
147 }; | 164 }; |
148 return info; | 165 return info; |
149 } | 166 } |
150 | 167 |
151 /** | 168 /** |
152 * Sets colortype to the native ARGB32 type. | 169 * Sets colortype to the native ARGB32 type. |
153 */ | 170 */ |
154 static SkImageInfo MakeN32(int width, int height, SkAlphaType at) { | 171 static SkImageInfo MakeN32(int width, int height, SkAlphaType at) { |
155 SkImageInfo info = { | 172 SkImageInfo info = { |
156 width, height, kN32_SkColorType, at | 173 width, height, kN32_SkColorType, at, kUnknown_Profile, 0 |
157 }; | 174 }; |
158 return info; | 175 return info; |
159 } | 176 } |
160 | 177 |
161 /** | 178 /** |
162 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 179 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
163 */ | 180 */ |
164 static SkImageInfo MakeN32Premul(int width, int height) { | 181 static SkImageInfo MakeN32Premul(int width, int height) { |
165 SkImageInfo info = { | 182 SkImageInfo info = { |
166 width, height, kN32_SkColorType, kPremul_SkAlphaType | 183 width, height, kN32_SkColorType, kPremul_SkAlphaType, kUnknown_Profi le, 0 |
167 }; | 184 }; |
168 return info; | 185 return info; |
169 } | 186 } |
170 | 187 |
171 /** | 188 /** |
172 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 189 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
173 */ | 190 */ |
174 static SkImageInfo MakeN32Premul(const SkISize& size) { | 191 static SkImageInfo MakeN32Premul(const SkISize& size) { |
175 return MakeN32Premul(size.width(), size.height()); | 192 return MakeN32Premul(size.width(), size.height()); |
176 } | 193 } |
177 | 194 |
178 static SkImageInfo MakeA8(int width, int height) { | 195 static SkImageInfo MakeA8(int width, int height) { |
179 SkImageInfo info = { | 196 SkImageInfo info = { |
180 width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType | 197 width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType, kUnknown_P rofile, 0 |
181 }; | 198 }; |
182 return info; | 199 return info; |
183 } | 200 } |
184 | 201 |
185 static SkImageInfo MakeUnknown(int width, int height) { | 202 static SkImageInfo MakeUnknown(int width, int height) { |
186 SkImageInfo info = { | 203 SkImageInfo info = { |
187 width, height, kUnknown_SkColorType, kIgnore_SkAlphaType | 204 width, height, kUnknown_SkColorType, kIgnore_SkAlphaType, kUnknown_P rofile, 0 |
188 }; | 205 }; |
189 return info; | 206 return info; |
190 } | 207 } |
191 | 208 |
192 static SkImageInfo MakeUnknown() { | 209 static SkImageInfo MakeUnknown() { |
193 SkImageInfo info = { | 210 SkImageInfo info = { |
194 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType | 211 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType, kUnknown_Profile, 0 |
195 }; | 212 }; |
196 return info; | 213 return info; |
197 } | 214 } |
198 | 215 |
199 int width() const { return fWidth; } | 216 int width() const { return fWidth; } |
200 int height() const { return fHeight; } | 217 int height() const { return fHeight; } |
201 SkColorType colorType() const { return fColorType; } | 218 SkColorType colorType() const { return fColorType; } |
202 SkAlphaType alphaType() const { return fAlphaType; } | 219 SkAlphaType alphaType() const { return fAlphaType; } |
203 | 220 |
204 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } | 221 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 size_t getSafeSize(size_t rowBytes) const { | 266 size_t getSafeSize(size_t rowBytes) const { |
250 return (size_t)this->getSafeSize64(rowBytes); | 267 return (size_t)this->getSafeSize64(rowBytes); |
251 } | 268 } |
252 | 269 |
253 bool validRowBytes(size_t rowBytes) const { | 270 bool validRowBytes(size_t rowBytes) const { |
254 uint64_t rb = sk_64_mul(fWidth, this->bytesPerPixel()); | 271 uint64_t rb = sk_64_mul(fWidth, this->bytesPerPixel()); |
255 return rowBytes >= rb; | 272 return rowBytes >= rb; |
256 } | 273 } |
257 | 274 |
258 SkDEBUGCODE(void validate() const;) | 275 SkDEBUGCODE(void validate() const;) |
276 | |
277 /** | |
278 * If the Info was tagged to be sRGB, return true, else return false. | |
279 */ | |
280 bool isSRGB() const { return kSRGB_Profile == fProfile; } | |
281 | |
282 /** | |
283 * If this was tagged with an explicit gamma value, return that value, else return 0. | |
284 * If this was tagged as sRGB, return 0. | |
285 */ | |
286 float gamma() const { return fGamma; } | |
259 }; | 287 }; |
260 | 288 |
261 #endif | 289 #endif |
OLD | NEW |