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

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: Check for 2.2 or linear gamma 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/codec/SkEncodedInfo.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 22 matching lines...) Expand all
229 } 235 }
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; }
reed1 2016/05/24 16:06:33 would this guy be deprecated?
msarett 2016/05/24 19:01:47 Yes, though I think there is plenty of work to do
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 isLinearGamma() const {
257 return SkColorSpace::kLinear_GammaNamed == fColorSpace->gammaNamed();
258 }
259
260 bool is2Dot2Gamma() const {
261 return SkColorSpace::k2Dot2Curve_GammaNamed == fColorSpace->gammaNamed() ;
reed1 2016/05/24 16:06:33 Must there be a colorspace object, or could it be
msarett 2016/05/24 19:01:47 Ahhh yes this is a bug. It could definitely be nu
262 }
263
250 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } 264 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); }
251 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } 265 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); }
252 266
253 /** 267 /**
254 * Return a new ImageInfo with the same colortype and alphatype as this inf o, 268 * Return a new ImageInfo with the same colortype and alphatype as this inf o,
255 * but with the specified width and height. 269 * but with the specified width and height.
256 */ 270 */
257 SkImageInfo makeWH(int newWidth, int newHeight) const { 271 SkImageInfo makeWH(int newWidth, int newHeight) const {
258 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fP rofileType); 272 return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fP rofileType);
259 } 273 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 329 }
316 330
317 SkDEBUGCODE(void validate() const;) 331 SkDEBUGCODE(void validate() const;)
318 332
319 private: 333 private:
320 int fWidth; 334 int fWidth;
321 int fHeight; 335 int fHeight;
322 SkColorType fColorType; 336 SkColorType fColorType;
323 SkAlphaType fAlphaType; 337 SkAlphaType fAlphaType;
324 SkColorProfileType fProfileType; 338 SkColorProfileType fProfileType;
339 sk_sp<SkColorSpace> fColorSpace;
325 340
326 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt) 341 SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorPr ofileType pt,
342 sk_sp<SkColorSpace> cs = nullptr)
327 : fWidth(width) 343 : fWidth(width)
328 , fHeight(height) 344 , fHeight(height)
329 , fColorType(ct) 345 , fColorType(ct)
330 , fAlphaType(at) 346 , fAlphaType(at)
331 , fProfileType(pt) 347 , fProfileType(pt)
348 , fColorSpace(cs)
332 {} 349 {}
333 }; 350 };
334 351
335 /////////////////////////////////////////////////////////////////////////////// 352 ///////////////////////////////////////////////////////////////////////////////
336 353
337 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) { 354 static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfi leType pt) {
338 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct; 355 return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct;
339 } 356 }
340 357
341 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) { 358 static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) {
342 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() ); 359 return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType() );
343 } 360 }
344 361
345 #endif 362 #endif
OLDNEW
« no previous file with comments | « include/codec/SkEncodedInfo.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698