OLD | NEW |
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 |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkColorSpaceXform.h" |
12 #include "SkColorTable.h" | 13 #include "SkColorTable.h" |
13 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
14 #include "SkTypes.h" | 15 #include "SkTypes.h" |
15 | 16 |
16 #ifdef SK_PRINT_CODEC_MESSAGES | 17 #ifdef SK_PRINT_CODEC_MESSAGES |
17 #define SkCodecPrintf SkDebugf | 18 #define SkCodecPrintf SkDebugf |
18 #else | 19 #else |
19 #define SkCodecPrintf(...) | 20 #define SkCodecPrintf(...) |
20 #endif | 21 #endif |
21 | 22 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 /* | 140 /* |
140 * 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 |
141 */ | 142 */ |
142 static inline const SkPMColor* get_color_ptr(SkColorTable* colorTable) { | 143 static inline const SkPMColor* get_color_ptr(SkColorTable* colorTable) { |
143 return nullptr != colorTable ? colorTable->readColors() : nullptr; | 144 return nullptr != colorTable ? colorTable->readColors() : nullptr; |
144 } | 145 } |
145 | 146 |
146 /* | 147 /* |
147 * Given that the encoded image uses a color table, return the fill value | 148 * Given that the encoded image uses a color table, return the fill value |
148 */ | 149 */ |
149 static inline uint32_t get_color_table_fill_value(SkColorType colorType, const S
kPMColor* colorPtr, | 150 static inline uint64_t get_color_table_fill_value(SkColorType colorType, SkAlpha
Type alphaType, |
150 uint8_t fillIndex) { | 151 const SkPMColor* colorPtr, uint8_t fillIndex, SkColorSpaceXform* colorXf
orm) { |
151 SkASSERT(nullptr != colorPtr); | 152 SkASSERT(nullptr != colorPtr); |
152 switch (colorType) { | 153 switch (colorType) { |
153 case kRGBA_8888_SkColorType: | 154 case kRGBA_8888_SkColorType: |
154 case kBGRA_8888_SkColorType: | 155 case kBGRA_8888_SkColorType: |
155 return colorPtr[fillIndex]; | 156 return colorPtr[fillIndex]; |
156 case kRGB_565_SkColorType: | 157 case kRGB_565_SkColorType: |
157 return SkPixel32ToPixel16(colorPtr[fillIndex]); | 158 return SkPixel32ToPixel16(colorPtr[fillIndex]); |
158 case kIndex_8_SkColorType: | 159 case kIndex_8_SkColorType: |
159 return fillIndex; | 160 return fillIndex; |
| 161 case kRGBA_F16_SkColorType: { |
| 162 SkASSERT(colorXform); |
| 163 uint64_t dstColor; |
| 164 uint32_t srcColor = colorPtr[fillIndex]; |
| 165 colorXform->apply(&dstColor, &srcColor, 1, colorType, alphaType); |
| 166 return dstColor; |
| 167 } |
160 default: | 168 default: |
161 SkASSERT(false); | 169 SkASSERT(false); |
162 return 0; | 170 return 0; |
163 } | 171 } |
164 } | 172 } |
165 | 173 |
166 /* | 174 /* |
167 * | 175 * |
168 * Copy the codec color table back to the client when kIndex8 color type is requ
ested | 176 * Copy the codec color table back to the client when kIndex8 color type is requ
ested |
169 */ | 177 */ |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform(
dst, src); | 378 return kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform(
dst, src); |
371 case kGray_8_SkColorType: | 379 case kGray_8_SkColorType: |
372 return kGray_8_SkColorType == src.colorType() && | 380 return kGray_8_SkColorType == src.colorType() && |
373 kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform(
dst, src); | 381 kOpaque_SkAlphaType == src.alphaType() && !needs_color_xform(
dst, src); |
374 default: | 382 default: |
375 return false; | 383 return false; |
376 } | 384 } |
377 } | 385 } |
378 | 386 |
379 #endif // SkCodecPriv_DEFINED | 387 #endif // SkCodecPriv_DEFINED |
OLD | NEW |