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

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

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