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 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const uint32_t pixelsPerByte = 8 / bitsPerPixel; | 125 const uint32_t pixelsPerByte = 8 / bitsPerPixel; |
126 return compute_row_bytes_ppb(width, pixelsPerByte); | 126 return compute_row_bytes_ppb(width, pixelsPerByte); |
127 } else { | 127 } else { |
128 SkASSERT(0 == bitsPerPixel % 8); | 128 SkASSERT(0 == bitsPerPixel % 8); |
129 const uint32_t bytesPerPixel = bitsPerPixel / 8; | 129 const uint32_t bytesPerPixel = bitsPerPixel / 8; |
130 return compute_row_bytes_bpp(width, bytesPerPixel); | 130 return compute_row_bytes_bpp(width, bytesPerPixel); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 /* | 134 /* |
| 135 * On incomplete images, get the color to fill with |
| 136 */ |
| 137 static inline SkPMColor get_fill_color_or_index(SkAlphaType alphaType) { |
| 138 // This condition works properly for all supported output color types. |
| 139 // kIndex8: The low 8-bits of both possible return values is 0, which is |
| 140 // our desired default index. |
| 141 // kGray8: The low 8-bits of both possible return values is 0, which is |
| 142 // black, our desired fill value. |
| 143 // kRGB565: The low 16-bits of both possible return values is 0, which is |
| 144 // black, our desired fill value. |
| 145 // kN32: Return black for opaque images and transparent for non-opaque |
| 146 // images. |
| 147 return kOpaque_SkAlphaType == alphaType ? |
| 148 SK_ColorBLACK : SK_ColorTRANSPARENT; |
| 149 } |
| 150 |
| 151 /* |
135 * Get a byte from a buffer | 152 * Get a byte from a buffer |
136 * This method is unsafe, the caller is responsible for performing a check | 153 * This method is unsafe, the caller is responsible for performing a check |
137 */ | 154 */ |
138 static inline uint8_t get_byte(uint8_t* buffer, uint32_t i) { | 155 static inline uint8_t get_byte(uint8_t* buffer, uint32_t i) { |
139 return buffer[i]; | 156 return buffer[i]; |
140 } | 157 } |
141 | 158 |
142 /* | 159 /* |
143 * Get a short from a buffer | 160 * Get a short from a buffer |
144 * This method is unsafe, the caller is responsible for performing a check | 161 * This method is unsafe, the caller is responsible for performing a check |
(...skipping 22 matching lines...) Expand all Loading... |
167 #endif | 184 #endif |
168 } | 185 } |
169 | 186 |
170 #ifdef SK_PRINT_CODEC_MESSAGES | 187 #ifdef SK_PRINT_CODEC_MESSAGES |
171 #define SkCodecPrintf SkDebugf | 188 #define SkCodecPrintf SkDebugf |
172 #else | 189 #else |
173 #define SkCodecPrintf(...) | 190 #define SkCodecPrintf(...) |
174 #endif | 191 #endif |
175 | 192 |
176 #endif // SkCodecPriv_DEFINED | 193 #endif // SkCodecPriv_DEFINED |
OLD | NEW |