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

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

Issue 2000713003: Add SkColorSpace to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@public
Patch Set: Created 4 years, 6 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 | include/core/SkImageInfo.h » ('j') | include/core/SkImageInfo.h » ('J')
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
13 class SkColorSpace;
13 14
14 struct SkEncodedInfo { 15 struct SkEncodedInfo {
15 public: 16 public:
16 17
17 enum Alpha { 18 enum Alpha {
18 kOpaque_Alpha, 19 kOpaque_Alpha,
19 kUnpremul_Alpha, 20 kUnpremul_Alpha,
20 21
21 // Each pixel is either fully opaque or fully transparent. 22 // Each pixel is either fully opaque or fully transparent.
22 // There is no difference between requesting kPremul or kUnpremul. 23 // There is no difference between requesting kPremul or kUnpremul.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 break; 110 break;
110 } 111 }
111 112
112 return SkEncodedInfo(color, alpha, bitsPerComponent); 113 return SkEncodedInfo(color, alpha, bitsPerComponent);
113 } 114 }
114 115
115 /* 116 /*
116 * Returns an SkImageInfo with Skia color and alpha types that are the 117 * Returns an SkImageInfo with Skia color and alpha types that are the
117 * closest possible match to the encoded info. 118 * closest possible match to the encoded info.
118 */ 119 */
119 SkImageInfo makeImageInfo(int width, int height) const { 120 SkImageInfo makeImageInfo(int width, int height, const sk_sp<SkColorSpace>& colorSpace) const {
120 SkColorProfileType profileType = SkDefaultColorProfile();
121 switch (fColor) { 121 switch (fColor) {
122 case kGray_Color: 122 case kGray_Color:
123 SkASSERT(kOpaque_Alpha == fAlpha); 123 SkASSERT(kOpaque_Alpha == fAlpha);
124 return SkImageInfo::Make(width, height, kGray_8_SkColorType, 124 return SkImageInfo::Make(width, height, kGray_8_SkColorType,
125 kOpaque_SkAlphaType, profileType); 125 kOpaque_SkAlphaType, colorSpace);
126 case kGrayAlpha_Color: 126 case kGrayAlpha_Color:
127 SkASSERT(kOpaque_Alpha != fAlpha); 127 SkASSERT(kOpaque_Alpha != fAlpha);
128 return SkImageInfo::Make(width, height, kN32_SkColorType, 128 return SkImageInfo::Make(width, height, kN32_SkColorType,
129 kUnpremul_SkAlphaType, profileType); 129 kUnpremul_SkAlphaType, colorSpace);
130 case kPalette_Color: { 130 case kPalette_Color: {
131 SkAlphaType alphaType = (kOpaque_Alpha == fAlpha) ? kOpaque_SkAl phaType : 131 SkAlphaType alphaType = (kOpaque_Alpha == fAlpha) ? kOpaque_SkAl phaType :
132 kUnpremul_SkAlphaType; 132 kUnpremul_SkAlphaType;
133 return SkImageInfo::Make(width, height, kIndex_8_SkColorType, 133 return SkImageInfo::Make(width, height, kIndex_8_SkColorType,
134 alphaType, profileType); 134 alphaType, colorSpace);
135 } 135 }
136 case kRGB_Color: 136 case kRGB_Color:
137 case kBGR_Color: 137 case kBGR_Color:
138 case kBGRX_Color: 138 case kBGRX_Color:
139 case kYUV_Color: 139 case kYUV_Color:
140 case kInvertedCMYK_Color: 140 case kInvertedCMYK_Color:
141 case kYCCK_Color: 141 case kYCCK_Color:
142 SkASSERT(kOpaque_Alpha == fAlpha); 142 SkASSERT(kOpaque_Alpha == fAlpha);
143 return SkImageInfo::Make(width, height, kN32_SkColorType, 143 return SkImageInfo::Make(width, height, kN32_SkColorType,
144 kOpaque_SkAlphaType, profileType); 144 kOpaque_SkAlphaType, colorSpace);
145 case kRGBA_Color: 145 case kRGBA_Color:
146 case kBGRA_Color: 146 case kBGRA_Color:
147 case kYUVA_Color: 147 case kYUVA_Color:
148 SkASSERT(kOpaque_Alpha != fAlpha); 148 SkASSERT(kOpaque_Alpha != fAlpha);
149 return SkImageInfo::Make(width, height, kN32_SkColorType, 149 return SkImageInfo::Make(width, height, kN32_SkColorType,
150 kUnpremul_SkAlphaType, profileType); 150 kUnpremul_SkAlphaType, colorSpace);
151 default: 151 default:
152 SkASSERT(false); 152 SkASSERT(false);
153 return SkImageInfo::MakeUnknown(); 153 return SkImageInfo::MakeUnknown();
154 } 154 }
155 } 155 }
156 156
157 Color color() const { return fColor; } 157 Color color() const { return fColor; }
158 Alpha alpha() const { return fAlpha; } 158 Alpha alpha() const { return fAlpha; }
159 uint8_t bitsPerComponent() const { return fBitsPerComponent; } 159 uint8_t bitsPerComponent() const { return fBitsPerComponent; }
160 160
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 Color fColor; 198 Color fColor;
199 Alpha fAlpha; 199 Alpha fAlpha;
200 uint8_t fBitsPerComponent; 200 uint8_t fBitsPerComponent;
201 201
202 friend class SkJpegCodec; 202 friend class SkJpegCodec;
203 }; 203 };
204 204
205 #endif 205 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkImageInfo.h » ('j') | include/core/SkImageInfo.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698