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

Side by Side Diff: include/codec/SkEncodedInfo.h

Issue 1918873002: Remove SkEncodedInfo kUnknown_Color and kUnknown_Alpha from public API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix errors 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 | « no previous file | src/codec/SkJpegCodec.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 2016 Google Inc. 2 * Copyright 2016 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 SkEncodedInfo_DEFINED 8 #ifndef SkEncodedInfo_DEFINED
9 #define SkEncodedInfo_DEFINED 9 #define SkEncodedInfo_DEFINED
10 10
11 #include "SkImageInfo.h" 11 #include "SkImageInfo.h"
12 #include "../private/SkImageInfoPriv.h" 12 #include "../private/SkImageInfoPriv.h"
13 13
14 struct SkEncodedInfo { 14 struct SkEncodedInfo {
15 public: 15 public:
16 16
17 enum Alpha { 17 enum Alpha {
18 kOpaque_Alpha, 18 kOpaque_Alpha,
19 kUnpremul_Alpha, 19 kUnpremul_Alpha,
20 20
21 // Each pixel is either fully opaque or fully transparent. 21 // Each pixel is either fully opaque or fully transparent.
22 // There is no difference between requesting kPremul or kUnpremul. 22 // There is no difference between requesting kPremul or kUnpremul.
23 kBinary_Alpha, 23 kBinary_Alpha,
24
25 // Allows us to have a default constructor. Should be treated as
26 // invalid.
27 kUnknown_Alpha,
28 }; 24 };
29 25
30 /* 26 /*
31 * We strive to make the number of components per pixel obvious through 27 * We strive to make the number of components per pixel obvious through
32 * our naming conventions. 28 * our naming conventions.
33 * Ex: kRGB has 3 components. kRGBA has 4 components. 29 * Ex: kRGB has 3 components. kRGBA has 4 components.
34 * 30 *
35 * This sometimes results in redundant Alpha and Color information. 31 * This sometimes results in redundant Alpha and Color information.
36 * Ex: kRGB images must also be kOpaque. 32 * Ex: kRGB images must also be kOpaque.
37 */ 33 */
(...skipping 27 matching lines...) Expand all
65 // represents 100% ink coverage. For this reason, we treat CMYK JPEGs 61 // represents 100% ink coverage. For this reason, we treat CMYK JPEGs
66 // as having inverted CMYK. libjpeg-turbo warns that this may break 62 // as having inverted CMYK. libjpeg-turbo warns that this may break
67 // other applications, but the CMYK JPEGs we see on the web expect to 63 // other applications, but the CMYK JPEGs we see on the web expect to
68 // be treated as inverted CMYK. 64 // be treated as inverted CMYK.
69 kInvertedCMYK_Color, 65 kInvertedCMYK_Color,
70 kYCCK_Color, 66 kYCCK_Color,
71 67
72 // Used internally to indicate that the decoding library has 68 // Used internally to indicate that the decoding library has
73 // pre-swizzled to the desired output format. 69 // pre-swizzled to the desired output format.
74 kPreSwizzled_Color, 70 kPreSwizzled_Color,
75
76 // Allows us to have a default constructor. Should be treated as
77 // invalid.
78 kUnknown_Color,
79 }; 71 };
80 72
81 static SkEncodedInfo Make(Color color, Alpha alpha, int bitsPerComponent) { 73 static SkEncodedInfo Make(Color color, Alpha alpha, int bitsPerComponent) {
82 SkASSERT(1 == bitsPerComponent || 74 SkASSERT(1 == bitsPerComponent ||
83 2 == bitsPerComponent || 75 2 == bitsPerComponent ||
84 4 == bitsPerComponent || 76 4 == bitsPerComponent ||
85 8 == bitsPerComponent || 77 8 == bitsPerComponent ||
86 16 == bitsPerComponent); 78 16 == bitsPerComponent);
87 79
88 switch (color) { 80 switch (color) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 case kYUVA_Color: 180 case kYUVA_Color:
189 case kInvertedCMYK_Color: 181 case kInvertedCMYK_Color:
190 case kYCCK_Color: 182 case kYCCK_Color:
191 return 4 * fBitsPerComponent; 183 return 4 * fBitsPerComponent;
192 default: 184 default:
193 SkASSERT(false); 185 SkASSERT(false);
194 return 0; 186 return 0;
195 } 187 }
196 } 188 }
197 189
198 SkEncodedInfo()
199 : fColor(kUnknown_Color)
200 , fAlpha(kUnknown_Alpha)
201 , fBitsPerComponent(0)
202 {}
203
204 private: 190 private:
205 191
206 SkEncodedInfo(Color color, Alpha alpha, uint8_t bitsPerComponent) 192 SkEncodedInfo(Color color, Alpha alpha, uint8_t bitsPerComponent)
207 : fColor(color) 193 : fColor(color)
208 , fAlpha(alpha) 194 , fAlpha(alpha)
209 , fBitsPerComponent(bitsPerComponent) 195 , fBitsPerComponent(bitsPerComponent)
210 {} 196 {}
211 197
212 void setColor(Color color) { 198 void setColor(Color color) {
213 fColor = color; 199 fColor = color;
214 } 200 }
215 201
216 Color fColor; 202 Color fColor;
217 Alpha fAlpha; 203 Alpha fAlpha;
218 uint8_t fBitsPerComponent; 204 uint8_t fBitsPerComponent;
219 205
220 friend class SkJpegCodec; 206 friend class SkJpegCodec;
221 }; 207 };
222 208
223 #endif 209 #endif
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkJpegCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698