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

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
« no previous file with comments | « include/core/SkColorSpace.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
230 236
231 static SkImageInfo MakeUnknown() { 237 static SkImageInfo MakeUnknown() {
232 return SkImageInfo(); 238 return SkImageInfo();
233 } 239 }
234 240
235 int width() const { return fWidth; } 241 int width() const { return fWidth; }
236 int height() const { return fHeight; } 242 int height() const { return fHeight; }
237 SkColorType colorType() const { return fColorType; } 243 SkColorType colorType() const { return fColorType; }
238 SkAlphaType alphaType() const { return fAlphaType; } 244 SkAlphaType alphaType() const { return fAlphaType; }
239 SkColorProfileType profileType() const { return fProfileType; } 245 SkColorProfileType profileType() const { return fProfileType; }
246 sk_sp<SkColorSpace> colorSpace() const { return fColorSpace; }
herb_g 2016/05/20 21:19:13 Can we avoid including this call until we have to.
msarett 2016/05/23 18:29:36 Yes I think that's a good idea! I've added checks
240 247
241 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } 248 bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; }
242 249
243 bool isOpaque() const { 250 bool isOpaque() const {
244 return SkAlphaTypeIsOpaque(fAlphaType); 251 return SkAlphaTypeIsOpaque(fAlphaType);
245 } 252 }
246 253
247 bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; } 254 bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; }
248 bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; } 255 bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; }
249 256
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 322 }
316 323
317 SkDEBUGCODE(void validate() const;) 324 SkDEBUGCODE(void validate() const;)
318 325
319 private: 326 private:
320 int fWidth; 327 int fWidth;
321 int fHeight; 328 int fHeight;
322 SkColorType fColorType; 329 SkColorType fColorType;
323 SkAlphaType fAlphaType; 330 SkAlphaType fAlphaType;
324 SkColorProfileType fProfileType; 331 SkColorProfileType fProfileType;
332 sk_sp<SkColorSpace> fColorSpace;
325 333
326 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt) 334 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt,
335 sk_sp<SkColorSpace> cs = nullptr)
327 : fWidth(width) 336 : fWidth(width)
328 , fHeight(height) 337 , fHeight(height)
329 , fColorType(ct) 338 , fColorType(ct)
330 , fAlphaType(at) 339 , fAlphaType(at)
331 , fProfileType(pt) 340 , fProfileType(pt)
341 , fColorSpace(cs)
332 {} 342 {}
333 }; 343 };
334 344
335 /////////////////////////////////////////////////////////////////////////////// 345 ///////////////////////////////////////////////////////////////////////////////
336 346
337 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) { 347 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) {
338 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; 348 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct;
339 } 349 }
340 350
341 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { 351 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) {
342 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() ); 352 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() );
343 } 353 }
344 354
345 #endif 355 #endif
OLDNEW
« no previous file with comments | « include/core/SkColorSpace.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698