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

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

Issue 964613002: replace kIgnore_SkAlphaType with kUnknown_SkAlphaType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/SkCanvas.h ('k') | src/core/SkBitmap.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 "SkMath.h" 11 #include "SkMath.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 #include "SkSize.h" 13 #include "SkSize.h"
14 14
15 class SkReadBuffer; 15 class SkReadBuffer;
16 class SkWriteBuffer; 16 class SkWriteBuffer;
17 17
18 /** 18 /**
19 * Describes how to interpret the alpha compoent of a pixel. 19 * Describes how to interpret the alpha compoent of a pixel.
20 */ 20 */
21 enum SkAlphaType { 21 enum SkAlphaType {
22 /** 22 kUnknown_SkAlphaType,
23 * All pixels should be treated as opaque, regardless of the value stored
24 * in their alpha field. Used for legacy images that wrote 0 or garbarge
25 * in their alpha field, but intended the RGB to be treated as opaque.
26 */
27 kIgnore_SkAlphaType,
28 23
29 /** 24 /**
30 * All pixels are stored as opaque. This differs slightly from kIgnore in 25 * All pixels are stored as opaque. This differs slightly from kIgnore in
31 * that kOpaque has correct "opaque" values stored in the pixels, while 26 * that kOpaque has correct "opaque" values stored in the pixels, while
32 * kIgnore may not, but in both cases the caller should treat the pixels 27 * kIgnore may not, but in both cases the caller should treat the pixels
33 * as opaque. 28 * as opaque.
34 */ 29 */
35 kOpaque_SkAlphaType, 30 kOpaque_SkAlphaType,
36 31
37 /** 32 /**
38 * All pixels have their alpha premultiplied in their color components. 33 * All pixels have their alpha premultiplied in their color components.
39 * This is the natural format for the rendering target pixels. 34 * This is the natural format for the rendering target pixels.
40 */ 35 */
41 kPremul_SkAlphaType, 36 kPremul_SkAlphaType,
42 37
43 /** 38 /**
44 * All pixels have their color components stored without any regard to the 39 * All pixels have their color components stored without any regard to the
45 * alpha. e.g. this is the default configuration for PNG images. 40 * alpha. e.g. this is the default configuration for PNG images.
46 * 41 *
47 * This alpha-type is ONLY supported for input images. Rendering cannot 42 * This alpha-type is ONLY supported for input images. Rendering cannot
48 * generate this on output. 43 * generate this on output.
49 */ 44 */
50 kUnpremul_SkAlphaType, 45 kUnpremul_SkAlphaType,
51 46
52 kLastEnum_SkAlphaType = kUnpremul_SkAlphaType 47 kLastEnum_SkAlphaType = kUnpremul_SkAlphaType
53 }; 48 };
54 49
55 static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) { 50 static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
56 SK_COMPILE_ASSERT(kIgnore_SkAlphaType < kOpaque_SkAlphaType, bad_alphatype_o rder); 51 return kOpaque_SkAlphaType == at;
57 SK_COMPILE_ASSERT(kPremul_SkAlphaType > kOpaque_SkAlphaType, bad_alphatype_o rder);
58 SK_COMPILE_ASSERT(kUnpremul_SkAlphaType > kOpaque_SkAlphaType, bad_alphatype _order);
59
60 return (unsigned)at <= kOpaque_SkAlphaType;
61 } 52 }
62 53
63 static inline bool SkAlphaTypeIsValid(unsigned value) { 54 static inline bool SkAlphaTypeIsValid(unsigned value) {
64 return value <= kLastEnum_SkAlphaType; 55 return value <= kLastEnum_SkAlphaType;
65 } 56 }
66 57
67 /////////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////////
68 59
69 /** 60 /**
70 * Describes how to interpret the components of a pixel. 61 * Describes how to interpret the components of a pixel.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 /** 145 /**
155 * Describe an image's dimensions and pixel type. 146 * Describe an image's dimensions and pixel type.
156 * Used for both src images and render-targets (surfaces). 147 * Used for both src images and render-targets (surfaces).
157 */ 148 */
158 struct SK_API SkImageInfo { 149 struct SK_API SkImageInfo {
159 public: 150 public:
160 SkImageInfo() 151 SkImageInfo()
161 : fWidth(0) 152 : fWidth(0)
162 , fHeight(0) 153 , fHeight(0)
163 , fColorType(kUnknown_SkColorType) 154 , fColorType(kUnknown_SkColorType)
164 , fAlphaType(kIgnore_SkAlphaType) 155 , fAlphaType(kUnknown_SkAlphaType)
165 , fProfileType(kLinear_SkColorProfileType) 156 , fProfileType(kLinear_SkColorProfileType)
166 {} 157 {}
167 158
168 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t, 159 static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType a t,
169 SkColorProfileType pt = kLinear_SkColorProfileType) { 160 SkColorProfileType pt = kLinear_SkColorProfileType) {
170 return SkImageInfo(width, height, ct, at, pt); 161 return SkImageInfo(width, height, ct, at, pt);
171 } 162 }
172 163
173 /** 164 /**
174 * Sets colortype to the native ARGB32 type. 165 * Sets colortype to the native ARGB32 type.
(...skipping 18 matching lines...) Expand all
193 SkColorProfileType pt = kLinear_SkColorProf ileType) { 184 SkColorProfileType pt = kLinear_SkColorProf ileType) {
194 return MakeN32Premul(size.width(), size.height(), pt); 185 return MakeN32Premul(size.width(), size.height(), pt);
195 } 186 }
196 187
197 static SkImageInfo MakeA8(int width, int height) { 188 static SkImageInfo MakeA8(int width, int height) {
198 return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaT ype, 189 return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaT ype,
199 kLinear_SkColorProfileType); 190 kLinear_SkColorProfileType);
200 } 191 }
201 192
202 static SkImageInfo MakeUnknown(int width, int height) { 193 static SkImageInfo MakeUnknown(int width, int height) {
203 return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaT ype, 194 return SkImageInfo(width, height, kUnknown_SkColorType, kUnknown_SkAlpha Type,
204 kLinear_SkColorProfileType); 195 kLinear_SkColorProfileType);
205 } 196 }
206 197
207 static SkImageInfo MakeUnknown() { 198 static SkImageInfo MakeUnknown() {
208 return SkImageInfo(); 199 return SkImageInfo();
209 } 200 }
210 201
211 int width() const { return fWidth; } 202 int width() const { return fWidth; }
212 int height() const { return fHeight; } 203 int height() const { return fHeight; }
213 SkColorType colorType() const { return fColorType; } 204 SkColorType colorType() const { return fColorType; }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 , fHeight(height) 289 , fHeight(height)
299 , fColorType(ct) 290 , fColorType(ct)
300 , fAlphaType(at) 291 , fAlphaType(at)
301 , fProfileType(pt) 292 , fProfileType(pt)
302 {} 293 {}
303 294
304 SkColorProfileType fProfileType; 295 SkColorProfileType fProfileType;
305 }; 296 };
306 297
307 #endif 298 #endif
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698