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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 unsigned g = SkGetPackedG32(c); | 209 unsigned g = SkGetPackedG32(c); |
210 unsigned b = SkGetPackedB32(c); | 210 unsigned b = SkGetPackedB32(c); |
211 return (g << 24) | (r << 13) | (b << 2); | 211 return (g << 24) | (r << 13) | (b << 2); |
212 } | 212 } |
213 | 213 |
214 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y
) { | 214 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y
) { |
215 SkASSERT(count > 0); | 215 SkASSERT(count > 0); |
216 uint32_t src_expand = pmcolor_to_expand16(src); | 216 uint32_t src_expand = pmcolor_to_expand16(src); |
217 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3; | 217 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3; |
218 do { | 218 do { |
219 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale; | 219 *dst = SkBlend32_RGB16(src_expand, *dst, scale); |
220 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5); | |
221 dst += 1; | 220 dst += 1; |
222 } while (--count != 0); | 221 } while (--count != 0); |
223 } | 222 } |
224 | 223 |
225 /////////////////////////////////////////////////////////////////////////////// | 224 /////////////////////////////////////////////////////////////////////////////// |
226 /////////////////////////////////////////////////////////////////////////////// | 225 /////////////////////////////////////////////////////////////////////////////// |
227 | 226 |
228 static const SkBlitRow::Proc16 gDefault_565_Procs[] = { | 227 static const SkBlitRow::Proc16 gDefault_565_Procs[] = { |
229 // no dither | 228 // no dither |
230 S32_D565_Opaque, | 229 S32_D565_Opaque, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 Color32A_D565, | 261 Color32A_D565, |
263 Color32A_D565, | 262 Color32A_D565, |
264 #endif | 263 #endif |
265 }; | 264 }; |
266 | 265 |
267 SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) { | 266 SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) { |
268 SkASSERT((flags & ~kFlags16_Mask) == 0); | 267 SkASSERT((flags & ~kFlags16_Mask) == 0); |
269 // just so we don't crash | 268 // just so we don't crash |
270 flags &= kFlags16_Mask; | 269 flags &= kFlags16_Mask; |
271 // we ignore both kGlobalAlpha_Flag and kSrcPixelAlpha_Flag, so shift down | 270 // we ignore both kGlobalAlpha_Flag and kSrcPixelAlpha_Flag, so shift down |
272 // since this factory is only used for transparent source alphas | 271 // no need for the additional code specializing on opaque alpha at this time |
273 flags >>= 2; | 272 flags >>= 2; |
274 | 273 |
275 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs)); | 274 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs)); |
276 | 275 |
277 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags); | 276 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags); |
278 if (NULL == proc) { | 277 if (NULL == proc) { |
279 proc = gDefault_565_ColorProcs[flags]; | 278 proc = gDefault_565_ColorProcs[flags]; |
280 } | 279 } |
281 return proc; | 280 return proc; |
282 } | 281 } |
OLD | NEW |