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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 kJPEG_SkYUVColorSpace, | 141 kJPEG_SkYUVColorSpace, |
142 /** SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color | 142 /** SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color |
143 range. See http://en.wikipedia.org/wiki/Rec._601 for details. */ | 143 range. See http://en.wikipedia.org/wiki/Rec._601 for details. */ |
144 kRec601_SkYUVColorSpace, | 144 kRec601_SkYUVColorSpace, |
145 | 145 |
146 kLastEnum_SkYUVColorSpace = kRec601_SkYUVColorSpace | 146 kLastEnum_SkYUVColorSpace = kRec601_SkYUVColorSpace |
147 }; | 147 }; |
148 | 148 |
149 /////////////////////////////////////////////////////////////////////////////// | 149 /////////////////////////////////////////////////////////////////////////////// |
150 | 150 |
| 151 enum SkColorProfileType { |
| 152 kLinear_SkColorProfileType, |
| 153 kSRGB_SkColorProfileType, |
| 154 |
| 155 kLastEnum_SkColorProfileType = kSRGB_SkColorProfileType |
| 156 }; |
| 157 |
151 /** | 158 /** |
152 * Describe an image's dimensions and pixel type. | 159 * Describe an image's dimensions and pixel type. |
| 160 * Used for both src images and render-targets (surfaces). |
153 */ | 161 */ |
154 struct SkImageInfo { | 162 struct SkImageInfo { |
155 public: | 163 public: |
156 SkImageInfo() | 164 SkImageInfo() |
157 : fWidth(0) | 165 : fWidth(0) |
158 , fHeight(0) | 166 , fHeight(0) |
159 , fColorType(kUnknown_SkColorType) | 167 , fColorType(kUnknown_SkColorType) |
160 , fAlphaType(kIgnore_SkAlphaType) | 168 , fAlphaType(kIgnore_SkAlphaType) |
| 169 , fProfileType(kLinear_SkColorProfileType) |
161 {} | 170 {} |
162 | 171 |
163 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t) { | 172 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a
t, |
164 return SkImageInfo(width, height, ct, at); | 173 SkColorProfileType pt = kLinear_SkColorProfileType)
{ |
| 174 return SkImageInfo(width, height, ct, at, pt); |
165 } | 175 } |
166 | 176 |
167 /** | 177 /** |
168 * Sets colortype to the native ARGB32 type. | 178 * Sets colortype to the native ARGB32 type. |
169 */ | 179 */ |
170 static SkImageInfo MakeN32(int width, int height, SkAlphaType at) { | 180 static SkImageInfo MakeN32(int width, int height, SkAlphaType at, |
171 return SkImageInfo(width, height, kN32_SkColorType, at); | 181 SkColorProfileType pt = kLinear_SkColorProfileTyp
e) { |
| 182 return SkImageInfo(width, height, kN32_SkColorType, at, pt); |
172 } | 183 } |
173 | 184 |
174 /** | 185 /** |
175 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 186 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
176 */ | 187 */ |
177 static SkImageInfo MakeN32Premul(int width, int height) { | 188 static SkImageInfo MakeN32Premul(int width, int height, |
178 return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType)
; | 189 SkColorProfileType pt = kLinear_SkColorProf
ileType) { |
| 190 return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType,
pt); |
179 } | 191 } |
180 | 192 |
181 /** | 193 /** |
182 * Sets colortype to the native ARGB32 type, and the alphatype to premul. | 194 * Sets colortype to the native ARGB32 type, and the alphatype to premul. |
183 */ | 195 */ |
184 static SkImageInfo MakeN32Premul(const SkISize& size) { | 196 static SkImageInfo MakeN32Premul(const SkISize& size, |
185 return MakeN32Premul(size.width(), size.height()); | 197 SkColorProfileType pt = kLinear_SkColorProf
ileType) { |
| 198 return MakeN32Premul(size.width(), size.height(), pt); |
186 } | 199 } |
187 | 200 |
188 static SkImageInfo MakeA8(int width, int height) { | 201 static SkImageInfo MakeA8(int width, int height) { |
189 return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaT
ype); | 202 return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaT
ype, |
| 203 kLinear_SkColorProfileType); |
190 } | 204 } |
191 | 205 |
192 static SkImageInfo MakeUnknown(int width, int height) { | 206 static SkImageInfo MakeUnknown(int width, int height) { |
193 return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaT
ype); | 207 return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaT
ype, |
| 208 kLinear_SkColorProfileType); |
194 } | 209 } |
195 | 210 |
196 static SkImageInfo MakeUnknown() { | 211 static SkImageInfo MakeUnknown() { |
197 return SkImageInfo(); | 212 return SkImageInfo(); |
198 } | 213 } |
199 | 214 |
200 int width() const { return fWidth; } | 215 int width() const { return fWidth; } |
201 int height() const { return fHeight; } | 216 int height() const { return fHeight; } |
202 SkColorType colorType() const { return fColorType; } | 217 SkColorType colorType() const { return fColorType; } |
203 SkAlphaType alphaType() const { return fAlphaType; } | 218 SkAlphaType alphaType() const { return fAlphaType; } |
| 219 SkColorProfileType profileType() const { return fProfileType; } |
204 | 220 |
205 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } | 221 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } |
206 | 222 |
207 bool isOpaque() const { | 223 bool isOpaque() const { |
208 return SkAlphaTypeIsOpaque(fAlphaType); | 224 return SkAlphaTypeIsOpaque(fAlphaType); |
209 } | 225 } |
210 | 226 |
| 227 bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; } |
| 228 bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; } |
| 229 |
| 230 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } |
211 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } | 231 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } |
212 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } | |
213 | 232 |
214 /** | 233 /** |
215 * Return a new ImageInfo with the same colortype and alphatype as this inf
o, | 234 * Return a new ImageInfo with the same colortype and alphatype as this inf
o, |
216 * but with the specified width and height. | 235 * but with the specified width and height. |
217 */ | 236 */ |
218 SkImageInfo makeWH(int newWidth, int newHeight) const { | 237 SkImageInfo makeWH(int newWidth, int newHeight) const { |
219 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType); | 238 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fP
rofileType); |
220 } | 239 } |
221 | 240 |
222 SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const { | 241 SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const { |
223 return SkImageInfo::Make(fWidth, fHeight, fColorType, newAlphaType); | 242 return SkImageInfo::Make(fWidth, fHeight, fColorType, newAlphaType, fPro
fileType); |
224 } | 243 } |
225 | 244 |
226 SkImageInfo makeColorType(SkColorType newColorType) const { | 245 SkImageInfo makeColorType(SkColorType newColorType) const { |
227 return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType); | 246 return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType, fPro
fileType); |
228 } | 247 } |
229 | 248 |
230 int bytesPerPixel() const { | 249 int bytesPerPixel() const { |
231 return SkColorTypeBytesPerPixel(fColorType); | 250 return SkColorTypeBytesPerPixel(fColorType); |
232 } | 251 } |
233 | 252 |
234 uint64_t minRowBytes64() const { | 253 uint64_t minRowBytes64() const { |
235 return sk_64_mul(fWidth, this->bytesPerPixel()); | 254 return sk_64_mul(fWidth, this->bytesPerPixel()); |
236 } | 255 } |
237 | 256 |
238 size_t minRowBytes() const { | 257 size_t minRowBytes() const { |
239 return (size_t)this->minRowBytes64(); | 258 return (size_t)this->minRowBytes64(); |
(...skipping 25 matching lines...) Expand all Loading... |
265 return rowBytes >= rb; | 284 return rowBytes >= rb; |
266 } | 285 } |
267 | 286 |
268 SkDEBUGCODE(void validate() const;) | 287 SkDEBUGCODE(void validate() const;) |
269 | 288 |
270 #ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS | 289 #ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS |
271 public: | 290 public: |
272 #else | 291 #else |
273 private: | 292 private: |
274 #endif | 293 #endif |
275 int fWidth; | 294 int fWidth; |
276 int fHeight; | 295 int fHeight; |
277 SkColorType fColorType; | 296 SkColorType fColorType; |
278 SkAlphaType fAlphaType; | 297 SkAlphaType fAlphaType; |
279 | 298 |
280 private: | 299 private: |
281 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at) | 300 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr
ofileType pt) |
282 : fWidth(width) | 301 : fWidth(width) |
283 , fHeight(height) | 302 , fHeight(height) |
284 , fColorType(ct) | 303 , fColorType(ct) |
285 , fAlphaType(at) | 304 , fAlphaType(at) |
| 305 , fProfileType(pt) |
286 {} | 306 {} |
| 307 |
| 308 SkColorProfileType fProfileType; |
287 }; | 309 }; |
288 | 310 |
289 #endif | 311 #endif |
OLD | NEW |