Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: include/core/SkImageInfo.h

Issue 2000713003: Add SkColorSpace to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@public
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "SkColorSpace.h"
11 #include "SkMath.h" 12 #include "SkMath.h"
12 #include "SkRect.h" 13 #include "SkRect.h"
13 #include "SkSize.h" 14 #include "SkSize.h"
14 15
15 class SkReadBuffer; 16 class SkReadBuffer;
16 class SkWriteBuffer; 17 class SkWriteBuffer;
17 18
18 /** 19 /**
19 * Describes how to interpret the alpha component of a pixel. 20 * Describes how to interpret the alpha component of a pixel.
20 */ 21 */
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 , fColorType(kUnknown_SkColorType) 188 , fColorType(kUnknown_SkColorType)
188 , fAlphaType(kUnknown_SkAlphaType) 189 , fAlphaType(kUnknown_SkAlphaType)
189 , fProfileType(kLinear_SkColorProfileType) 190 , fProfileType(kLinear_SkColorProfileType)
190 {} 191 {}
191 192
192 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t, 193 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t,
193 SkColorProfileType pt = kLinear_SkColorProfileType) { 194 SkColorProfileType pt = kLinear_SkColorProfileType) {
194 return SkImageInfo(width, height, ct, at, pt); 195 return SkImageInfo(width, height, ct, at, pt);
195 } 196 }
196 197
198 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t,
199 sk_sp<SkColorSpace> cs) {
200 return SkImageInfo(width, height, ct, at, kLinear_SkColorProfileType, cs );
201 }
202
197 /** 203 /**
198 * Sets colortype to the native ARGB32 type. 204 * Sets colortype to the native ARGB32 type.
199 */ 205 */
200 static SkImageInfo MakeN32(int width, int height, SkAlphaType at, 206 static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
201 SkColorProfileType pt = kLinear_SkColorProfileTyp e) { 207 SkColorProfileType pt = kLinear_SkColorProfileTyp e) {
202 return SkImageInfo(width, height, kN32_SkColorType, at, pt); 208 return SkImageInfo(width, height, kN32_SkColorType, at, pt);
203 } 209 }
204 210
205 /** 211 /**
206 * Sets colortype to the native ARGB32 type, and the alphatype to premul. 212 * Sets colortype to the native ARGB32 type, and the alphatype to premul.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 246
241 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } 247 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; }
242 248
243 bool isOpaque() const { 249 bool isOpaque() const {
244 return SkAlphaTypeIsOpaque(fAlphaType); 250 return SkAlphaTypeIsOpaque(fAlphaType);
245 } 251 }
246 252
247 bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; } 253 bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; }
248 bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; } 254 bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; }
249 255
256 bool isSRGBGamma() const {
msarett 2016/05/20 16:55:37 I don't like these... I think they are too limiti
257 if (fColorSpace) {
258 return SkColorSpace::kSRGBCurve_GammaNamed == fColorSpace->gammaName d();
259 }
260
261 // Treat unmarked images as sRGB.
262 return true;
263 }
264
265 bool isSRGBGamut() const {
266 if (fColorSpace) {
267 return SkColorSpace::kSRGB_Named == fColorSpace->named();
268 }
269
270 // Treat unmarked images as sRGB.
271 return true;
272 }
273
250 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } 274 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); }
251 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } 275 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); }
252 276
253 /** 277 /**
254 * Return a new ImageInfo with the same colortype and alphatype as this inf o, 278 * Return a new ImageInfo with the same colortype and alphatype as this inf o,
255 * but with the specified width and height. 279 * but with the specified width and height.
256 */ 280 */
257 SkImageInfo makeWH(int newWidth, int newHeight) const { 281 SkImageInfo makeWH(int newWidth, int newHeight) const {
258 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fP rofileType); 282 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fP rofileType);
259 } 283 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 339 }
316 340
317 SkDEBUGCODE(void validate() const;) 341 SkDEBUGCODE(void validate() const;)
318 342
319 private: 343 private:
320 int fWidth; 344 int fWidth;
321 int fHeight; 345 int fHeight;
322 SkColorType fColorType; 346 SkColorType fColorType;
323 SkAlphaType fAlphaType; 347 SkAlphaType fAlphaType;
324 SkColorProfileType fProfileType; 348 SkColorProfileType fProfileType;
349 sk_sp<SkColorSpace> fColorSpace;
325 350
326 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt) 351 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt,
352 sk_sp<SkColorSpace> cs = nullptr)
327 : fWidth(width) 353 : fWidth(width)
328 , fHeight(height) 354 , fHeight(height)
329 , fColorType(ct) 355 , fColorType(ct)
330 , fAlphaType(at) 356 , fAlphaType(at)
331 , fProfileType(pt) 357 , fProfileType(pt)
358 , fColorSpace(cs)
332 {} 359 {}
333 }; 360 };
334 361
335 /////////////////////////////////////////////////////////////////////////////// 362 ///////////////////////////////////////////////////////////////////////////////
336 363
337 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) { 364 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) {
338 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; 365 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct;
339 } 366 }
340 367
341 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { 368 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) {
342 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() ); 369 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() );
343 } 370 }
344 371
345 #endif 372 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698