OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkBlitRow.h" | 8 #include "SkBlitRow.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkDither.h" | 10 #include "SkDither.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 *dst = SkPackRGB16(dr, dg, db); | 197 *dst = SkPackRGB16(dr, dg, db); |
198 } | 198 } |
199 dst += 1; | 199 dst += 1; |
200 DITHER_INC_X(x); | 200 DITHER_INC_X(x); |
201 } while (--count != 0); | 201 } while (--count != 0); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 /////////////////////////////////////////////////////////////////////////////// | 205 /////////////////////////////////////////////////////////////////////////////// |
206 | 206 |
207 static uint32_t pmcolor_to_expand16(SkPMColor c) { | 207 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y
) { |
208 unsigned r = SkGetPackedR32(c); | 208 for (int i = 0; i < count; i++) { |
209 unsigned g = SkGetPackedG32(c); | 209 dst[i] = SkSrcOver32To16(src, dst[i]); |
210 unsigned b = SkGetPackedB32(c); | 210 } |
211 return (g << 24) | (r << 13) | (b << 2); | |
212 } | 211 } |
213 | 212 |
214 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y
) { | |
215 SkASSERT(count > 0); | |
216 uint32_t src_expand = pmcolor_to_expand16(src); | |
217 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3; | |
218 do { | |
219 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale; | |
220 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5); | |
221 dst += 1; | |
222 } while (--count != 0); | |
223 } | |
224 | |
225 /////////////////////////////////////////////////////////////////////////////// | |
226 /////////////////////////////////////////////////////////////////////////////// | |
227 | |
228 static const SkBlitRow::Proc16 gDefault_565_Procs[] = { | 213 static const SkBlitRow::Proc16 gDefault_565_Procs[] = { |
229 // no dither | 214 // no dither |
230 S32_D565_Opaque, | 215 S32_D565_Opaque, |
231 S32_D565_Blend, | 216 S32_D565_Blend, |
232 | 217 |
233 S32A_D565_Opaque, | 218 S32A_D565_Opaque, |
234 S32A_D565_Blend, | 219 S32A_D565_Blend, |
235 | 220 |
236 // dither | 221 // dither |
237 S32_D565_Opaque_Dither, | 222 S32_D565_Opaque_Dither, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 flags >>= 1; | 261 flags >>= 1; |
277 | 262 |
278 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs)); | 263 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs)); |
279 | 264 |
280 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags); | 265 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags); |
281 if (NULL == proc) { | 266 if (NULL == proc) { |
282 proc = gDefault_565_ColorProcs[flags]; | 267 proc = gDefault_565_ColorProcs[flags]; |
283 } | 268 } |
284 return proc; | 269 return proc; |
285 } | 270 } |
OLD | NEW |