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

Side by Side Diff: src/codec/SkCodecPriv.h

Issue 2339233003: Support Float32 output from SkColorSpaceXform (Closed)
Patch Set: Remove gpu changes Created 4 years, 3 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 | « gyp/bench.gyp ('k') | 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 2015 The Android Open Source Project 2 * Copyright 2015 The Android Open Source Project
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 SkCodecPriv_DEFINED 8 #ifndef SkCodecPriv_DEFINED
9 #define SkCodecPriv_DEFINED 9 #define SkCodecPriv_DEFINED
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 } 138 }
139 139
140 /* 140 /*
141 * If there is a color table, get a pointer to the colors, otherwise return null ptr 141 * If there is a color table, get a pointer to the colors, otherwise return null ptr
142 */ 142 */
143 static inline const SkPMColor* get_color_ptr(SkColorTable* colorTable) { 143 static inline const SkPMColor* get_color_ptr(SkColorTable* colorTable) {
144 return nullptr != colorTable ? colorTable->readColors() : nullptr; 144 return nullptr != colorTable ? colorTable->readColors() : nullptr;
145 } 145 }
146 146
147 static inline SkColorSpaceXform::ColorFormat select_xform_format(SkColorType col orType) {
148 switch (colorType) {
149 case kRGBA_8888_SkColorType:
150 return SkColorSpaceXform::kRGBA_8888_ColorFormat;
151 case kBGRA_8888_SkColorType:
152 return SkColorSpaceXform::kBGRA_8888_ColorFormat;
153 case kRGBA_F16_SkColorType:
154 return SkColorSpaceXform::kRGBA_F16_ColorFormat;
155 default:
156 SkASSERT(false);
157 return SkColorSpaceXform::kRGBA_8888_ColorFormat;
158 }
159 }
160
147 /* 161 /*
148 * Given that the encoded image uses a color table, return the fill value 162 * Given that the encoded image uses a color table, return the fill value
149 */ 163 */
150 static inline uint64_t get_color_table_fill_value(SkColorType colorType, SkAlpha Type alphaType, 164 static inline uint64_t get_color_table_fill_value(SkColorType colorType, SkAlpha Type alphaType,
151 const SkPMColor* colorPtr, uint8_t fillIndex, SkColorSpaceXform* colorXf orm) { 165 const SkPMColor* colorPtr, uint8_t fillIndex, SkColorSpaceXform* colorXf orm) {
152 SkASSERT(nullptr != colorPtr); 166 SkASSERT(nullptr != colorPtr);
153 switch (colorType) { 167 switch (colorType) {
154 case kRGBA_8888_SkColorType: 168 case kRGBA_8888_SkColorType:
155 case kBGRA_8888_SkColorType: 169 case kBGRA_8888_SkColorType:
156 return colorPtr[fillIndex]; 170 return colorPtr[fillIndex];
157 case kRGB_565_SkColorType: 171 case kRGB_565_SkColorType:
158 return SkPixel32ToPixel16(colorPtr[fillIndex]); 172 return SkPixel32ToPixel16(colorPtr[fillIndex]);
159 case kIndex_8_SkColorType: 173 case kIndex_8_SkColorType:
160 return fillIndex; 174 return fillIndex;
161 case kRGBA_F16_SkColorType: { 175 case kRGBA_F16_SkColorType: {
162 SkASSERT(colorXform); 176 SkASSERT(colorXform);
163 uint64_t dstColor; 177 uint64_t dstColor;
164 uint32_t srcColor = colorPtr[fillIndex]; 178 uint32_t srcColor = colorPtr[fillIndex];
165 colorXform->apply(&dstColor, &srcColor, 1, colorType, alphaType); 179 colorXform->apply(&dstColor, &srcColor, 1, select_xform_format(color Type), alphaType);
166 return dstColor; 180 return dstColor;
167 } 181 }
168 default: 182 default:
169 SkASSERT(false); 183 SkASSERT(false);
170 return 0; 184 return 0;
171 } 185 }
172 } 186 }
173 187
174 /* 188 /*
175 * 189 *
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 350
337 // Need a color xform when dst space does not match the src. 351 // Need a color xform when dst space does not match the src.
338 bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.co lorSpace()); 352 bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.co lorSpace());
339 353
340 // We never perform a color xform in legacy mode. 354 // We never perform a color xform in legacy mode.
341 bool isLegacy = nullptr == dstInfo.colorSpace(); 355 bool isLegacy = nullptr == dstInfo.colorSpace();
342 356
343 return !isLegacy && (needsPremul || isF16 || srcDstNotEqual); 357 return !isLegacy && (needsPremul || isF16 || srcDstNotEqual);
344 } 358 }
345 359
346 static inline SkAlphaType select_alpha_xform(SkAlphaType dstAlphaType, SkAlphaTy pe srcAlphaType) { 360 static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaTy pe srcAlphaType) {
347 return (kOpaque_SkAlphaType == srcAlphaType) ? kOpaque_SkAlphaType : dstAlph aType; 361 return (kOpaque_SkAlphaType == srcAlphaType) ? kOpaque_SkAlphaType : dstAlph aType;
348 } 362 }
349 363
350 /* 364 /*
351 * Alpha Type Conversions 365 * Alpha Type Conversions
352 * - kOpaque to kOpaque, kUnpremul, kPremul is valid 366 * - kOpaque to kOpaque, kUnpremul, kPremul is valid
353 * - kUnpremul to kUnpremul, kPremul is valid 367 * - kUnpremul to kUnpremul, kPremul is valid
354 * 368 *
355 * Color Type Conversions 369 * Color Type Conversions
356 * - Always support kRGBA_8888, kBGRA_8888 370 * - Always support kRGBA_8888, kBGRA_8888
(...skipping 21 matching lines...) Expand all
378 return kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform( dst, src); 392 return kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform( dst, src);
379 case kGray_8_SkColorType: 393 case kGray_8_SkColorType:
380 return kGray_8_SkColorType == src.colorType() && 394 return kGray_8_SkColorType == src.colorType() &&
381 kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform( dst, src); 395 kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform( dst, src);
382 default: 396 default:
383 return false; 397 return false;
384 } 398 }
385 } 399 }
386 400
387 #endif // SkCodecPriv_DEFINED 401 #endif // SkCodecPriv_DEFINED
OLDNEW
« no previous file with comments | « gyp/bench.gyp ('k') | src/codec/SkJpegCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698