Index: src/opts/SkColor_opts_neon.h |
diff --git a/src/opts/SkColor_opts_neon.h b/src/opts/SkColor_opts_neon.h |
index cd9e8133e20658a7698d3c471f2689691e6a30e0..f81239712ab5bba90fb21b6896f7edbb4e658044 100644 |
--- a/src/opts/SkColor_opts_neon.h |
+++ b/src/opts/SkColor_opts_neon.h |
@@ -29,4 +29,40 @@ static inline uint8x8x4_t SkAlphaMulQ_neon8(uint8x8x4_t color, uint16x8_t scale) |
return ret; |
} |
+/* This function expands 8 pixels from RGB565 (R, G, B from high to low) to |
+ * SkPMColor (all possible configurations supported) in the exact same way as |
+ * SkPixel16ToPixel32. |
+ */ |
+static inline uint8x8x4_t SkPixel16ToPixel32_neon8(uint16x8_t vsrc) { |
+ |
+ uint8x8x4_t ret; |
+ uint8x8_t vr, vg, vb; |
+ |
+ vr = vmovn_u16(vshrq_n_u16(vsrc, SK_R16_SHIFT)); |
+ vg = vmovn_u16(vshrq_n_u16(vshlq_n_u16(vsrc, SK_R16_BITS), SK_R16_BITS + SK_B16_BITS)); |
+ vb = vmovn_u16(vsrc & vdupq_n_u16(SK_B16_MASK)); |
+ |
+ ret.val[NEON_A] = vdup_n_u8(0xFF); |
+ ret.val[NEON_R] = vshl_n_u8(vr, 8 - SK_R16_BITS) | vshr_n_u8(vr, 2 * SK_R16_BITS - 8); |
+ ret.val[NEON_G] = vshl_n_u8(vg, 8 - SK_G16_BITS) | vshr_n_u8(vg, 2 * SK_G16_BITS - 8); |
+ ret.val[NEON_B] = vshl_n_u8(vb, 8 - SK_B16_BITS) | vshr_n_u8(vb, 2 * SK_B16_BITS - 8); |
+ |
+ return ret; |
+} |
+ |
+/* This function packs 8 pixels from SkPMColor (all possible configurations |
+ * supported) to RGB565 (R, G, B from high to low) in the exact same way as |
+ * SkPixel32ToPixel16. |
+ */ |
+static inline uint16x8_t SkPixel32ToPixel16_neon8(uint8x8x4_t vsrc) { |
+ |
+ uint16x8_t ret; |
+ |
+ ret = vshll_n_u8(vsrc.val[NEON_R], 8); |
+ ret = vsriq_n_u16(ret, vshll_n_u8(vsrc.val[NEON_G], 8), SK_R16_BITS); |
+ ret = vsriq_n_u16(ret, vshll_n_u8(vsrc.val[NEON_B], 8), SK_R16_BITS + SK_G16_BITS); |
+ |
+ return ret; |
+} |
+ |
#endif /* #ifndef SkColor_opts_neon_DEFINED */ |