SkBlitRow_opts_arm_neon.cpp revision a111e492b84c312a6bd5d5d9ef100dca48f4941d
1a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com/*
2a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * Copyright 2012 The Android Open Source Project
3a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com *
4a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * Use of this source code is governed by a BSD-style license that can be
5a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * found in the LICENSE file.
6a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com */
7a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
8a111e492b84c312a6bd5d5d9ef100dca48f4941ddjsollen@google.com#include "SkBlitRow_opts_arm_neon.h"
9a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
10a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkBlitMask.h"
11a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkBlitRow.h"
12a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkColorPriv.h"
13a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkDither.h"
14a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkMathPriv.h"
15a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkUtils.h"
16a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
17a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include "SkCachePreload_arm.h"
18a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
19a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#include <arm_neon.h>
20a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
21a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32A_D565_Opaque_neon(uint16_t* SK_RESTRICT dst,
22a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                           const SkPMColor* SK_RESTRICT src, int count,
23a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                           U8CPU alpha, int /*x*/, int /*y*/) {
24a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    SkASSERT(255 == alpha);
25a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
26a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count >= 8) {
27efbe8e9bedda21a3e061ebf3d96431a0f250a654djsollen@google.com        uint16_t* SK_RESTRICT keep_dst = 0;
28fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
29a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        asm volatile (
30a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "ands       ip, %[count], #7            \n\t"
31a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmov.u8    d31, #1<<7                  \n\t"
32a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.16    {q12}, [%[dst]]             \n\t"
33a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld4.8     {d0-d3}, [%[src]]           \n\t"
34a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // Thumb does not support the standard ARM conditional
35a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // instructions but instead requires the 'it' instruction
36a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // to signal conditional execution
37a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "it eq                                  \n\t"
38a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "moveq      ip, #8                      \n\t"
39a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "mov        %[keep_dst], %[dst]         \n\t"
40fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
41a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "add        %[src], %[src], ip, LSL#2   \n\t"
42a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "add        %[dst], %[dst], ip, LSL#1   \n\t"
43a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "subs       %[count], %[count], ip      \n\t"
44a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "b          9f                          \n\t"
45a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // LOOP
46a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "2:                                         \n\t"
47fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
48a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.16    {q12}, [%[dst]]!            \n\t"
49a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld4.8     {d0-d3}, [%[src]]!          \n\t"
50a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vst1.16    {q10}, [%[keep_dst]]        \n\t"
51a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "sub        %[keep_dst], %[dst], #8*2   \n\t"
52a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "subs       %[count], %[count], #8      \n\t"
53a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "9:                                         \n\t"
54a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "pld        [%[dst],#32]                \n\t"
55a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // expand 0565 q12 to 8888 {d4-d7}
56a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d4, q12                     \n\t"
57a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q11, q12, #5                \n\t"
58a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q10, q12, #6+5              \n\t"
59a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d5, q11                     \n\t"
60a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d6, q10                     \n\t"
61a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d4, d4, #3                  \n\t"
62a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d5, d5, #2                  \n\t"
63a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d6, d6, #3                  \n\t"
64fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
65a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q14, d31                    \n\t"
66a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q13, d31                    \n\t"
67a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q12, d31                    \n\t"
68fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
69a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // duplicate in 4/2/1 & 8pix vsns
70a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmvn.8     d30, d3                     \n\t"
71a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q14, d30, d6                \n\t"
72a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q13, d30, d5                \n\t"
73a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q12, d30, d4                \n\t"
74a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q8, q14, #5                 \n\t"
75a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q9, q13, #6                 \n\t"
76a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d6, q14, q8                 \n\t"
77a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q8, q12, #5                 \n\t"
78a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d5, q13, q9                 \n\t"
79a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d6, d6, d0                  \n\t"  // moved up
80a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d4, q12, q8                 \n\t"
81a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // intentionally don't calculate alpha
82a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // result in d4-d6
83fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
84a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d5, d5, d1                  \n\t"
85a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d4, d4, d2                  \n\t"
86fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
87a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // pack 8888 {d4-d6} to 0565 q10
88a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q10, d6, #8                 \n\t"
89a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q3, d5, #8                  \n\t"
90a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q2, d4, #8                  \n\t"
91a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vsri.u16   q10, q3, #5                 \n\t"
92a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vsri.u16   q10, q2, #11                \n\t"
93fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
94a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "bne        2b                          \n\t"
95fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
96a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "1:                                         \n\t"
97a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vst1.16      {q10}, [%[keep_dst]]      \n\t"
98a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      : [count] "+r" (count)
99fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                      : [dst] "r" (dst), [keep_dst] "r" (keep_dst), [src] "r" (src)
100a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      : "ip", "cc", "memory", "d0","d1","d2","d3","d4","d5","d6","d7",
101a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "d16","d17","d18","d19","d20","d21","d22","d23","d24","d25","d26","d27","d28","d29",
102a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "d30","d31"
103a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      );
104a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
105fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    else
106a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    {   // handle count < 8
107efbe8e9bedda21a3e061ebf3d96431a0f250a654djsollen@google.com        uint16_t* SK_RESTRICT keep_dst = 0;
108fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
109a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        asm volatile (
110a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmov.u8    d31, #1<<7                  \n\t"
111a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "mov        %[keep_dst], %[dst]         \n\t"
112fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
113a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #4                \n\t"
114a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        14f                         \n\t"
115a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.16    {d25}, [%[dst]]!            \n\t"
116a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.32    {q1}, [%[src]]!             \n\t"
117fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
118a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "14:                                        \n\t"
119a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #2                \n\t"
120a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        12f                         \n\t"
121a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.32    {d24[1]}, [%[dst]]!         \n\t"
122a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.32    {d1}, [%[src]]!             \n\t"
123fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
124a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "12:                                        \n\t"
125a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #1                \n\t"
126a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        11f                         \n\t"
127a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.16    {d24[1]}, [%[dst]]!         \n\t"
128a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vld1.32    {d0[1]}, [%[src]]!          \n\t"
129fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
130a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "11:                                        \n\t"
131a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // unzips achieve the same as a vld4 operation
132a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vuzpq.u16  q0, q1                      \n\t"
133a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vuzp.u8    d0, d1                      \n\t"
134a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vuzp.u8    d2, d3                      \n\t"
135a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // expand 0565 q12 to 8888 {d4-d7}
136a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d4, q12                     \n\t"
137a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q11, q12, #5                \n\t"
138a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q10, q12, #6+5              \n\t"
139a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d5, q11                     \n\t"
140a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovn.u16  d6, q10                     \n\t"
141a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d4, d4, #3                  \n\t"
142a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d5, d5, #2                  \n\t"
143a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshl.u8    d6, d6, #3                  \n\t"
144fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
145a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q14, d31                    \n\t"
146a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q13, d31                    \n\t"
147a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmovl.u8   q12, d31                    \n\t"
148fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
149a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // duplicate in 4/2/1 & 8pix vsns
150a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmvn.8     d30, d3                     \n\t"
151a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q14, d30, d6                \n\t"
152a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q13, d30, d5                \n\t"
153a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vmlal.u8   q12, d30, d4                \n\t"
154a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q8, q14, #5                 \n\t"
155a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q9, q13, #6                 \n\t"
156a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d6, q14, q8                 \n\t"
157a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshr.u16   q8, q12, #5                 \n\t"
158a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d5, q13, q9                 \n\t"
159a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d6, d6, d0                  \n\t"  // moved up
160a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vaddhn.u16 d4, q12, q8                 \n\t"
161a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // intentionally don't calculate alpha
162a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // result in d4-d6
163fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
164a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d5, d5, d1                  \n\t"
165a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vqadd.u8   d4, d4, d2                  \n\t"
166fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
167a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // pack 8888 {d4-d6} to 0565 q10
168a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q10, d6, #8                 \n\t"
169a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q3, d5, #8                  \n\t"
170a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vshll.u8   q2, d4, #8                  \n\t"
171a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vsri.u16   q10, q3, #5                 \n\t"
172a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vsri.u16   q10, q2, #11                \n\t"
173fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
174a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      // store
175a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #4                \n\t"
176a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        24f                         \n\t"
177a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vst1.16    {d21}, [%[keep_dst]]!       \n\t"
178fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
179a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "24:                                        \n\t"
180a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #2                \n\t"
181a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        22f                         \n\t"
182a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vst1.32    {d20[1]}, [%[keep_dst]]!    \n\t"
183fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
184a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "22:                                        \n\t"
185a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "tst        %[count], #1                \n\t"
186a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "beq        21f                         \n\t"
187a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "vst1.16    {d20[1]}, [%[keep_dst]]!    \n\t"
188fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
189a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "21:                                        \n\t"
190a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      : [count] "+r" (count)
191a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      : [dst] "r" (dst), [keep_dst] "r" (keep_dst), [src] "r" (src)
192a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      : "ip", "cc", "memory", "d0","d1","d2","d3","d4","d5","d6","d7",
193a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "d16","d17","d18","d19","d20","d21","d22","d23","d24","d25","d26","d27","d28","d29",
194a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      "d30","d31"
195a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      );
196a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
197a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
198a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
199a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32A_D565_Blend_neon(uint16_t* SK_RESTRICT dst,
200a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                          const SkPMColor* SK_RESTRICT src, int count,
201a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                          U8CPU alpha, int /*x*/, int /*y*/) {
202a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
203a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    U8CPU alpha_for_asm = alpha;
204a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
205a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    asm volatile (
206a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    /* This code implements a Neon version of S32A_D565_Blend. The output differs from
207a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     * the original in two respects:
208a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *  1. The results have a few mismatches compared to the original code. These mismatches
209a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     never exceed 1. It's possible to improve accuracy vs. a floating point
210a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     implementation by introducing rounding right shifts (vrshr) for the final stage.
211a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     Rounding is not present in the code below, because although results would be closer
212fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     *     to a floating point implementation, the number of mismatches compared to the
213a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     original code would be far greater.
214a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *  2. On certain inputs, the original code can overflow, causing colour channels to
215a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     mix. Although the Neon code can also overflow, it doesn't allow one colour channel
216a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     *     to affect another.
217a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com     */
218fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
219a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#if 1
220fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* reflects SkAlpha255To256()'s change from a+a>>7 to a+1 */
221a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "add        %[alpha], %[alpha], #1         \n\t"   // adjust range of alpha 0-256
222a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
223a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "add        %[alpha], %[alpha], %[alpha], lsr #7    \n\t"   // adjust range of alpha 0-256
224a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
225a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmov.u16   q3, #255                        \n\t"   // set up constant
226a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "movs       r4, %[count], lsr #3            \n\t"   // calc. count>>3
227a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmov.u16   d2[0], %[alpha]                 \n\t"   // move alpha to Neon
228a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "beq        2f                              \n\t"   // if count8 == 0, exit
229a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmov.u16   q15, #0x1f                      \n\t"   // set up blue mask
230fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
231a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "1:                                             \n\t"
232a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vld1.u16   {d0, d1}, [%[dst]]              \n\t"   // load eight dst RGB565 pixels
233a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "subs       r4, r4, #1                      \n\t"   // decrement loop counter
234a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vld4.u8    {d24, d25, d26, d27}, [%[src]]! \n\t"   // load eight src ABGR32 pixels
235a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  //  and deinterleave
236fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
237a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshl.u16   q9, q0, #5                      \n\t"   // shift green to top of lanes
238a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vand       q10, q0, q15                    \n\t"   // extract blue
239a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q8, q0, #11                     \n\t"   // extract red
240a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q9, q9, #10                     \n\t"   // extract green
241a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // dstrgb = {q8, q9, q10}
242fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
243a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8    d24, d24, #3                    \n\t"   // shift red to 565 range
244a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8    d25, d25, #2                    \n\t"   // shift green to 565 range
245a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8    d26, d26, #3                    \n\t"   // shift blue to 565 range
246fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
247a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovl.u8   q11, d24                        \n\t"   // widen red to 16 bits
248a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovl.u8   q12, d25                        \n\t"   // widen green to 16 bits
249a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovl.u8   q14, d27                        \n\t"   // widen alpha to 16 bits
250a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovl.u8   q13, d26                        \n\t"   // widen blue to 16 bits
251a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // srcrgba = {q11, q12, q13, q14}
252fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
253a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.u16   q2, q14, d2[0]                  \n\t"   // sa * src_scale
254a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.u16   q11, q11, d2[0]                 \n\t"   // red result = src_red * src_scale
255a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.u16   q12, q12, d2[0]                 \n\t"   // grn result = src_grn * src_scale
256a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.u16   q13, q13, d2[0]                 \n\t"   // blu result = src_blu * src_scale
257fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
258a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q2, q2, #8                      \n\t"   // sa * src_scale >> 8
259a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsub.u16   q2, q3, q2                      \n\t"   // 255 - (sa * src_scale >> 8)
260a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // dst_scale = q2
261fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
262a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmla.u16   q11, q8, q2                     \n\t"   // red result += dst_red * dst_scale
263a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmla.u16   q12, q9, q2                     \n\t"   // grn result += dst_grn * dst_scale
264a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmla.u16   q13, q10, q2                    \n\t"   // blu result += dst_blu * dst_scale
265a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
266a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#if 1
267fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    // trying for a better match with SkDiv255Round(a)
268fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    // C alg is:  a+=128; (a+a>>8)>>8
269fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    // we'll use just a rounding shift [q2 is available for scratch]
270a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vrshr.u16   q11, q11, #8                    \n\t"   // shift down red
271a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vrshr.u16   q12, q12, #8                    \n\t"   // shift down green
272a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vrshr.u16   q13, q13, #8                    \n\t"   // shift down blue
273a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
274fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    // arm's original "truncating divide by 256"
275a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q11, q11, #8                    \n\t"   // shift down red
276a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q12, q12, #8                    \n\t"   // shift down green
277a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16   q13, q13, #8                    \n\t"   // shift down blue
278a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
279fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
280a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsli.u16   q13, q12, #5                    \n\t"   // insert green into blue
281a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsli.u16   q13, q11, #11                   \n\t"   // insert red into green/blue
282a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vst1.16    {d26, d27}, [%[dst]]!           \n\t"   // write pixel back to dst, update ptr
283fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
284a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "bne        1b                              \n\t"   // if counter != 0, loop
285a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "2:                                             \n\t"   // exit
286fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
287a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  : [src] "+r" (src), [dst] "+r" (dst), [count] "+r" (count), [alpha] "+r" (alpha_for_asm)
288a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  :
289a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  : "cc", "memory", "r4", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"
290a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  );
291a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
292a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    count &= 7;
293a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count > 0) {
294a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        do {
295a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColor sc = *src++;
296a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            if (sc) {
297a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                uint16_t dc = *dst;
298a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
299a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned dr = SkMulS16(SkPacked32ToR16(sc), alpha) + SkMulS16(SkGetPackedR16(dc), dst_scale);
300a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned dg = SkMulS16(SkPacked32ToG16(sc), alpha) + SkMulS16(SkGetPackedG16(dc), dst_scale);
301a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned db = SkMulS16(SkPacked32ToB16(sc), alpha) + SkMulS16(SkGetPackedB16(dc), dst_scale);
302a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                *dst = SkPackRGB16(SkDiv255Round(dr), SkDiv255Round(dg), SkDiv255Round(db));
303a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            }
304a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            dst += 1;
305a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        } while (--count != 0);
306a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
307a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
308a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
309a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com/* dither matrix for Neon, derived from gDitherMatrix_3Bit_16.
310a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * each dither value is spaced out into byte lanes, and repeated
311a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * to allow an 8-byte load from offsets 0, 1, 2 or 3 from the
312a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * start of each row.
313a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com */
314a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comstatic const uint8_t gDitherMatrix_Neon[48] = {
315a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    0, 4, 1, 5, 0, 4, 1, 5, 0, 4, 1, 5,
316a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    6, 2, 7, 3, 6, 2, 7, 3, 6, 2, 7, 3,
317a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    1, 5, 0, 4, 1, 5, 0, 4, 1, 5, 0, 4,
318a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    7, 3, 6, 2, 7, 3, 6, 2, 7, 3, 6, 2,
319fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
320a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com};
321a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
322a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32_D565_Blend_Dither_neon(uint16_t *dst, const SkPMColor *src,
323a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                int count, U8CPU alpha, int x, int y)
324a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com{
325a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    /* select row and offset for dither array */
326a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    const uint8_t *dstart = &gDitherMatrix_Neon[(y&3)*12 + (x&3)];
327fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
328a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    /* rescale alpha to range 0 - 256 */
329a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    int scale = SkAlpha255To256(alpha);
330fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
331a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    asm volatile (
332a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vld1.8         {d31}, [%[dstart]]              \n\t"   // load dither values
333a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8        d30, d31, #1                    \n\t"   // calc. green dither values
334a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vdup.16        d6, %[scale]                    \n\t"   // duplicate scale into neon reg
335a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmov.i8        d29, #0x3f                      \n\t"   // set up green mask
336a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmov.i8        d28, #0x1f                      \n\t"   // set up blue mask
337a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "1:                                                 \n\t"
338a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vld4.8         {d0, d1, d2, d3}, [%[src]]!     \n\t"   // load 8 pixels and split into argb
339a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8        d22, d0, #5                     \n\t"   // calc. red >> 5
340a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8        d23, d1, #6                     \n\t"   // calc. green >> 6
341a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u8        d24, d2, #5                     \n\t"   // calc. blue >> 5
342a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.u8       q8, d0, d31                     \n\t"   // add in dither to red and widen
343a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.u8       q9, d1, d30                     \n\t"   // add in dither to green and widen
344a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.u8       q10, d2, d31                    \n\t"   // add in dither to blue and widen
345a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubw.u8       q8, q8, d22                     \n\t"   // sub shifted red from result
346a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubw.u8       q9, q9, d23                     \n\t"   // sub shifted green from result
347a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubw.u8       q10, q10, d24                   \n\t"   // sub shifted blue from result
348a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d22, q8, #3                     \n\t"   // shift right and narrow to 5 bits
349a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d23, q9, #2                     \n\t"   // shift right and narrow to 6 bits
350a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d24, q10, #3                    \n\t"   // shift right and narrow to 5 bits
351a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // load 8 pixels from dst, extract rgb
352a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vld1.16        {d0, d1}, [%[dst]]              \n\t"   // load 8 pixels
353a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d17, q0, #5                     \n\t"   // shift green down to bottom 6 bits
354a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovn.i16      d18, q0                         \n\t"   // narrow to get blue as bytes
355a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshr.u16       q0, q0, #11                     \n\t"   // shift down to extract red
356a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vand           d17, d17, d29                   \n\t"   // and green with green mask
357a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vand           d18, d18, d28                   \n\t"   // and blue with blue mask
358a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmovn.i16      d16, q0                         \n\t"   // narrow to get red as bytes
359a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // src = {d22 (r), d23 (g), d24 (b)}
360a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // dst = {d16 (r), d17 (g), d18 (b)}
361a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // subtract dst from src and widen
362a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubl.s8       q0, d22, d16                    \n\t"   // subtract red src from dst
363a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubl.s8       q1, d23, d17                    \n\t"   // subtract green src from dst
364a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsubl.s8       q2, d24, d18                    \n\t"   // subtract blue src from dst
365a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // multiply diffs by scale and shift
366a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.i16       q0, q0, d6[0]                   \n\t"   // multiply red by scale
367a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.i16       q1, q1, d6[0]                   \n\t"   // multiply blue by scale
368a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vmul.i16       q2, q2, d6[0]                   \n\t"   // multiply green by scale
369a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "subs           %[count], %[count], #8          \n\t"   // decrement loop counter
370a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d0, q0, #8                      \n\t"   // shift down red by 8 and narrow
371a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d2, q1, #8                      \n\t"   // shift down green by 8 and narrow
372a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vshrn.i16      d4, q2, #8                      \n\t"   // shift down blue by 8 and narrow
373a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // add dst to result
374a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.s8       q0, d0, d16                     \n\t"   // add dst to red
375a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.s8       q1, d2, d17                     \n\t"   // add dst to green
376a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vaddl.s8       q2, d4, d18                     \n\t"   // add dst to blue
377a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  // put result into 565 format
378a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsli.i16       q2, q1, #5                      \n\t"   // shift up green and insert into blue
379a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vsli.i16       q2, q0, #11                     \n\t"   // shift up red and insert into blue
380a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "vst1.16        {d4, d5}, [%[dst]]!             \n\t"   // store result
381a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "bgt            1b                              \n\t"   // loop if count > 0
382a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  : [src] "+r" (src), [dst] "+r" (dst), [count] "+r" (count)
383a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  : [dstart] "r" (dstart), [scale] "r" (scale)
384a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  : "cc", "memory", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d28", "d29", "d30", "d31"
385a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  );
386fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
387a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    DITHER_565_SCAN(y);
388fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
389a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    while((count & 7) > 0)
390a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    {
391a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        SkPMColor c = *src++;
392fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
393a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        int dither = DITHER_VALUE(x);
394a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        int sr = SkGetPackedR32(c);
395a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        int sg = SkGetPackedG32(c);
396a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        int sb = SkGetPackedB32(c);
397a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        sr = SkDITHER_R32To565(sr, dither);
398a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        sg = SkDITHER_G32To565(sg, dither);
399a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        sb = SkDITHER_B32To565(sb, dither);
400fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
401a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        uint16_t d = *dst;
402a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        *dst++ = SkPackRGB16(SkAlphaBlend(sr, SkGetPackedR16(d), scale),
403a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                             SkAlphaBlend(sg, SkGetPackedG16(d), scale),
404a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                             SkAlphaBlend(sb, SkGetPackedB16(d), scale));
405a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        DITHER_INC_X(x);
406a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        count--;
407a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
408a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
409a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
410a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32A_Opaque_BlitRow32_neon(SkPMColor* SK_RESTRICT dst,
411a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                const SkPMColor* SK_RESTRICT src,
412a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                int count, U8CPU alpha) {
413a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
414a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    SkASSERT(255 == alpha);
415a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count > 0) {
416a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
417a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
418fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint8x8_t alpha_mask;
419a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
420fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    static const uint8_t alpha_mask_setup[] = {3,3,3,3,7,7,7,7};
421fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    alpha_mask = vld1_u8(alpha_mask_setup);
422a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
423fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* do the NEON unrolled code */
424fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#define    UNROLL    4
425fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    while (count >= UNROLL) {
426fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t src_raw, dst_raw, dst_final;
427fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t src_raw_2, dst_raw_2, dst_final_2;
428a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
4290a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org        /* The two prefetches below may make the code slighlty
4300a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org         * slower for small values of count but are worth having
4310a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org         * in the general case.
4320a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org         */
4330a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org        __builtin_prefetch(src+32);
4340a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org        __builtin_prefetch(dst+32);
4350a5699ee482c3b5ef1e857de8a2de06c6a1fa298commit-bot@chromium.org
436fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* get the source */
437fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src_raw = vreinterpret_u8_u32(vld1_u32(src));
438fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    UNROLL > 2
439fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src_raw_2 = vreinterpret_u8_u32(vld1_u32(src+2));
440a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
441a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
442fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* get and hold the dst too */
443fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_raw = vreinterpret_u8_u32(vld1_u32(dst));
444fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    UNROLL > 2
445fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_raw_2 = vreinterpret_u8_u32(vld1_u32(dst+2));
446a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
447a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
448fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* 1st and 2nd bits of the unrolling */
449fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    {
450fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t dst_cooked;
451fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t dst_wide;
452fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t alpha_narrow;
453fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t alpha_wide;
454a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
455fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* get the alphas spread out properly */
456fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha_narrow = vtbl1_u8(src_raw, alpha_mask);
457fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha_wide = vsubw_u8(vdupq_n_u16(256), alpha_narrow);
458a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
459fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* spread the dest */
460fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmovl_u8(dst_raw);
461a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
462fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* alpha mul the dest */
463fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmulq_u16 (dst_wide, alpha_wide);
464fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_cooked = vshrn_n_u16(dst_wide, 8);
465a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
466fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sum -- ignoring any byte lane overflows */
467fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_final = vadd_u8(src_raw, dst_cooked);
468fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
469a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
470fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    UNROLL > 2
471fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* the 3rd and 4th bits of our unrolling */
472fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    {
473fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t dst_cooked;
474fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t dst_wide;
475fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t alpha_narrow;
476fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t alpha_wide;
477a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
478fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha_narrow = vtbl1_u8(src_raw_2, alpha_mask);
479fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha_wide = vsubw_u8(vdupq_n_u16(256), alpha_narrow);
480a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
481fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* spread the dest */
482fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmovl_u8(dst_raw_2);
483a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
484fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* alpha mul the dest */
485fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmulq_u16 (dst_wide, alpha_wide);
486fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_cooked = vshrn_n_u16(dst_wide, 8);
487a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
488fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sum -- ignoring any byte lane overflows */
489fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_final_2 = vadd_u8(src_raw_2, dst_cooked);
490fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
491a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
492a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
493fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        vst1_u32(dst, vreinterpret_u32_u8(dst_final));
494fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    UNROLL > 2
495fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        vst1_u32(dst+2, vreinterpret_u32_u8(dst_final_2));
496a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
497a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
498fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src += UNROLL;
499fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst += UNROLL;
500fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        count -= UNROLL;
501fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
502fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    UNROLL
503a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
504fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* do any residual iterations */
505a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        while (--count >= 0) {
506a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            *dst = SkPMSrcOver(*src, *dst);
507a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            src += 1;
508a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            dst += 1;
509a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        }
510a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
511a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
512a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
513c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.comvoid S32A_Opaque_BlitRow32_neon_src_alpha(SkPMColor* SK_RESTRICT dst,
514c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com                                const SkPMColor* SK_RESTRICT src,
515c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com                                int count, U8CPU alpha) {
516c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    SkASSERT(255 == alpha);
517c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
518c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if (count <= 0)
519c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    return;
520c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
521c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* Use these to check if src is transparent or opaque */
522c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    const unsigned int ALPHA_OPAQ  = 0xFF000000;
523c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    const unsigned int ALPHA_TRANS = 0x00FFFFFF;
524c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
525c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com#define UNROLL  4
526c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    const SkPMColor* SK_RESTRICT src_end = src + count - (UNROLL + 1);
527c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    const SkPMColor* SK_RESTRICT src_temp = src;
528c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
529c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* set up the NEON variables */
530c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint8x8_t alpha_mask;
531c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    static const uint8_t alpha_mask_setup[] = {3,3,3,3,7,7,7,7};
532c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    alpha_mask = vld1_u8(alpha_mask_setup);
533c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
534c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint8x8_t src_raw, dst_raw, dst_final;
535c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint8x8_t src_raw_2, dst_raw_2, dst_final_2;
536c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint8x8_t dst_cooked;
537c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint16x8_t dst_wide;
538c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint8x8_t alpha_narrow;
539c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    uint16x8_t alpha_wide;
540c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
541c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* choose the first processing type */
542c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if( src >= src_end)
543c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto TAIL;
544c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(*src <= ALPHA_TRANS)
545c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_0;
546c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(*src >= ALPHA_OPAQ)
547c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_255;
548c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* fall-thru */
549c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
550c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.comALPHA_1_TO_254:
551c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    do {
552c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
553c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* get the source */
554c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        src_raw = vreinterpret_u8_u32(vld1_u32(src));
555c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        src_raw_2 = vreinterpret_u8_u32(vld1_u32(src+2));
556c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
557c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* get and hold the dst too */
558c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_raw = vreinterpret_u8_u32(vld1_u32(dst));
559c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_raw_2 = vreinterpret_u8_u32(vld1_u32(dst+2));
560c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
561c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
562c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* get the alphas spread out properly */
563c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        alpha_narrow = vtbl1_u8(src_raw, alpha_mask);
564c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* reflect SkAlpha255To256() semantics a+1 vs a+a>>7 */
565c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* we collapsed (255-a)+1 ... */
566c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        alpha_wide = vsubw_u8(vdupq_n_u16(256), alpha_narrow);
567c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
568c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* spread the dest */
569c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_wide = vmovl_u8(dst_raw);
570c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
571c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* alpha mul the dest */
572c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_wide = vmulq_u16 (dst_wide, alpha_wide);
573c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_cooked = vshrn_n_u16(dst_wide, 8);
574c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
575c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* sum -- ignoring any byte lane overflows */
576c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_final = vadd_u8(src_raw, dst_cooked);
577c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
578c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        alpha_narrow = vtbl1_u8(src_raw_2, alpha_mask);
579c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* reflect SkAlpha255To256() semantics a+1 vs a+a>>7 */
580c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* we collapsed (255-a)+1 ... */
581c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        alpha_wide = vsubw_u8(vdupq_n_u16(256), alpha_narrow);
582c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
583c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* spread the dest */
584c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_wide = vmovl_u8(dst_raw_2);
585c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
586c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* alpha mul the dest */
587c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_wide = vmulq_u16 (dst_wide, alpha_wide);
588c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_cooked = vshrn_n_u16(dst_wide, 8);
589c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
590c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* sum -- ignoring any byte lane overflows */
591c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst_final_2 = vadd_u8(src_raw_2, dst_cooked);
592c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
593c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        vst1_u32(dst, vreinterpret_u32_u8(dst_final));
594c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        vst1_u32(dst+2, vreinterpret_u32_u8(dst_final_2));
595c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
596c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        src += UNROLL;
597c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst += UNROLL;
598c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
599c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        /* if 2 of the next pixels aren't between 1 and 254
600c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        it might make sense to go to the optimized loops */
601c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if((src[0] <= ALPHA_TRANS && src[1] <= ALPHA_TRANS) || (src[0] >= ALPHA_OPAQ && src[1] >= ALPHA_OPAQ))
602c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            break;
603c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
604c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    } while(src < src_end);
605c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
606c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if (src >= src_end)
607c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto TAIL;
608c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
609c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(src[0] >= ALPHA_OPAQ && src[1] >= ALPHA_OPAQ)
610c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_255;
611c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
612c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /*fall-thru*/
613c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
614c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.comALPHA_0:
615c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
616c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /*In this state, we know the current alpha is 0 and
617c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     we optimize for the next alpha also being zero. */
618c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    src_temp = src;  //so we don't have to increment dst every time
619c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    do {
620c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(*(++src) > ALPHA_TRANS)
621c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            break;
622c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(*(++src) > ALPHA_TRANS)
623c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            break;
624c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(*(++src) > ALPHA_TRANS)
625c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            break;
626c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(*(++src) > ALPHA_TRANS)
627c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            break;
628c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    } while(src < src_end);
629c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
630c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    dst += (src - src_temp);
631c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
632c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* no longer alpha 0, so determine where to go next. */
633c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if( src >= src_end)
634c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto TAIL;
635c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(*src >= ALPHA_OPAQ)
636c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_255;
637c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    else
638c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_1_TO_254;
639c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
640c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.comALPHA_255:
641c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    while((src[0] & src[1] & src[2] & src[3]) >= ALPHA_OPAQ) {
642c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst[0]=src[0];
643c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst[1]=src[1];
644c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst[2]=src[2];
645c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst[3]=src[3];
646c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        src+=UNROLL;
647c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst+=UNROLL;
648c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(src >= src_end)
649c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            goto TAIL;
650c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    }
651c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
652c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    //Handle remainder.
653c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(*src >= ALPHA_OPAQ) { *dst++ = *src++;
654c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if(*src >= ALPHA_OPAQ) { *dst++ = *src++;
655c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            if(*src >= ALPHA_OPAQ) { *dst++ = *src++; }
656c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        }
657c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    }
658c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
659c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if( src >= src_end)
660c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto TAIL;
661c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    if(*src <= ALPHA_TRANS)
662c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_0;
663c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    else
664c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        goto ALPHA_1_TO_254;
665c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
666c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.comTAIL:
667c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /* do any residual iterations */
668c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    src_end += UNROLL + 1;  //goto the real end
669c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    while(src != src_end) {
670c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        if( *src != 0 ) {
671c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            if( *src >= ALPHA_OPAQ ) {
672c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com                *dst = *src;
673c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            }
674c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            else {
675c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com                *dst = SkPMSrcOver(*src, *dst);
676c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com            }
677c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        }
678c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        src++;
679c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com        dst++;
680c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    }
681c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com
682c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com#undef    UNROLL
683c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    return;
684c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com}
685a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
686a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com/* Neon version of S32_Blend_BlitRow32()
687a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * portable version is in src/core/SkBlitRow_D32.cpp
688a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com */
689a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32_Blend_BlitRow32_neon(SkPMColor* SK_RESTRICT dst,
690a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                              const SkPMColor* SK_RESTRICT src,
691a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                              int count, U8CPU alpha) {
692a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    SkASSERT(alpha <= 255);
693a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count > 0) {
694a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        uint16_t src_scale = SkAlpha255To256(alpha);
695a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        uint16_t dst_scale = 256 - src_scale;
696a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
697fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* run them N at a time through the NEON unit */
698fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* note that each 1 is 4 bytes, each treated exactly the same,
699fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * so we can work under that guise. We *do* know that the src&dst
700fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * will be 32-bit aligned quantities, so we can specify that on
701fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * the load/store ops and do a neon 'reinterpret' to get us to
702fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * byte-sized (pun intended) pieces that we widen/multiply/shift
703fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * we're limited at 128 bits in the wide ops, which is 8x16bits
704fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * or a pair of 32 bit src/dsts.
705fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     */
706fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* we *could* manually unroll this loop so that we load 128 bits
707fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * (as a pair of 64s) from each of src and dst, processing them
708fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * in pieces. This might give us a little better management of
709fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * the memory latency, but my initial attempts here did not
710fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * produce an instruction stream that looked all that nice.
711fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     */
712fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#define    UNROLL    2
713fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    while (count >= UNROLL) {
714fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t  src_raw, dst_raw, dst_final;
715fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t  src_wide, dst_wide;
716fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
717fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* get 64 bits of src, widen it, multiply by src_scale */
718fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src_raw = vreinterpret_u8_u32(vld1_u32(src));
719fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src_wide = vmovl_u8(src_raw);
720fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* gcc hoists vdupq_n_u16(), better than using vmulq_n_u16() */
721fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src_wide = vmulq_u16 (src_wide, vdupq_n_u16(src_scale));
722fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
723fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* ditto with dst */
724fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_raw = vreinterpret_u8_u32(vld1_u32(dst));
725fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmovl_u8(dst_raw);
726fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
727fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* combine add with dst multiply into mul-accumulate */
728fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_wide = vmlaq_u16(src_wide, dst_wide, vdupq_n_u16(dst_scale));
729fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
730fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_final = vshrn_n_u16(dst_wide, 8);
731fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        vst1_u32(dst, vreinterpret_u32_u8(dst_final));
732fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
733fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src += UNROLL;
734fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst += UNROLL;
735fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        count -= UNROLL;
736fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
737fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* RBE: well, i don't like how gcc manages src/dst across the above
738fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * loop it's constantly calculating src+bias, dst+bias and it only
739fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * adjusts the real ones when we leave the loop. Not sure why
740fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * it's "hoisting down" (hoisting implies above in my lexicon ;))
741fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * the adjustments to src/dst/count, but it does...
742fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * (might be SSA-style internal logic...
743fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     */
744fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
745fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    UNROLL == 2
746fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    if (count == 1) {
747a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            *dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale);
748fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
749a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
750fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    if (count > 0) {
751a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            do {
752a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                *dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale);
753a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                src += 1;
754a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                dst += 1;
755a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            } while (--count > 0);
756fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
757a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
758a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
759fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    UNROLL
760a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
761a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
762a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
7631fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.orgvoid S32A_Blend_BlitRow32_neon(SkPMColor* SK_RESTRICT dst,
7641fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org                         const SkPMColor* SK_RESTRICT src,
7651fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org                         int count, U8CPU alpha) {
7661fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7671fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    SkASSERT(255 >= alpha);
7681fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7691fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    if (count <= 0) {
7701fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        return;
7711fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    }
7721fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7731fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    unsigned alpha256 = SkAlpha255To256(alpha);
7741fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7751fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    // First deal with odd counts
7761fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    if (count & 1) {
7771fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        uint8x8_t vsrc = vdup_n_u8(0), vdst = vdup_n_u8(0), vres;
7781fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        uint16x8_t vdst_wide, vsrc_wide;
7791fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        unsigned dst_scale;
7801fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7811fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        // Load
7821fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vsrc = vreinterpret_u8_u32(vld1_lane_u32(src, vreinterpret_u32_u8(vsrc), 0));
7831fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vdst = vreinterpret_u8_u32(vld1_lane_u32(dst, vreinterpret_u32_u8(vdst), 0));
7841fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7851fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        // Calc dst_scale
7861fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        dst_scale = vget_lane_u8(vsrc, 3);
7871fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        dst_scale *= alpha256;
7881fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        dst_scale >>= 8;
7891fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        dst_scale = 256 - dst_scale;
7901fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7911fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        // Process src
7921fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vsrc_wide = vmovl_u8(vsrc);
7931fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vsrc_wide = vmulq_n_u16(vsrc_wide, alpha256);
7941fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7951fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        // Process dst
7961fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vdst_wide = vmovl_u8(vdst);
7971fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vdst_wide = vmulq_n_u16(vdst_wide, dst_scale);
7981fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
7991fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        // Combine
8001fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vres = vshrn_n_u16(vdst_wide, 8) + vshrn_n_u16(vsrc_wide, 8);
8011fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8021fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        vst1_lane_u32(dst, vreinterpret_u32_u8(vres), 0);
8031fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        dst++;
8041fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        src++;
8051fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        count--;
8061fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    }
8071fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8081fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    if (count) {
8091fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        uint8x8_t alpha_mask;
8101fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        static const uint8_t alpha_mask_setup[] = {3,3,3,3,7,7,7,7};
8111fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        alpha_mask = vld1_u8(alpha_mask_setup);
8121fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8131fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        do {
8141fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8151fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            uint8x8_t vsrc, vdst, vres, vsrc_alphas;
8161fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            uint16x8_t vdst_wide, vsrc_wide, vsrc_scale, vdst_scale;
8171fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8181fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            __builtin_prefetch(src+32);
8191fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            __builtin_prefetch(dst+32);
8201fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8211fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Load
8221fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vsrc = vreinterpret_u8_u32(vld1_u32(src));
8231fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst = vreinterpret_u8_u32(vld1_u32(dst));
8241fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8251fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Prepare src_scale
8261fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vsrc_scale = vdupq_n_u16(alpha256);
8271fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8281fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Calc dst_scale
8291fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vsrc_alphas = vtbl1_u8(vsrc, alpha_mask);
8301fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_scale = vmovl_u8(vsrc_alphas);
8311fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_scale *= vsrc_scale;
8321fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_scale = vshrq_n_u16(vdst_scale, 8);
8331fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_scale = vsubq_u16(vdupq_n_u16(256), vdst_scale);
8341fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8351fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Process src
8361fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vsrc_wide = vmovl_u8(vsrc);
8371fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vsrc_wide *= vsrc_scale;
8381fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8391fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Process dst
8401fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_wide = vmovl_u8(vdst);
8411fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vdst_wide *= vdst_scale;
8421fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8431fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            // Combine
8441fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vres = vshrn_n_u16(vdst_wide, 8) + vshrn_n_u16(vsrc_wide, 8);
8451fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8461fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            vst1_u32(dst, vreinterpret_u32_u8(vres));
8471fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
8481fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            src += 2;
8491fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            dst += 2;
8501fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org            count -= 2;
8511fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org        } while(count);
8521fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    }
8531fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org}
8541fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org
855a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com///////////////////////////////////////////////////////////////////////////////
856a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
857fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    DEBUG_OPAQUE_DITHER
858a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
859fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    defined(DEBUG_OPAQUE_DITHER)
860a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comstatic void showme8(char *str, void *p, int len)
861a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com{
862fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    static char buf[256];
863fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    char tbuf[32];
864fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int i;
865fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    char *pc = (char*) p;
866fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    sprintf(buf,"%8s:", str);
867fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    for(i=0;i<len;i++) {
868fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sprintf(tbuf, "   %02x", pc[i]);
869fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        strcat(buf, tbuf);
870fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
871fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    SkDebugf("%s\n", buf);
872a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
873a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comstatic void showme16(char *str, void *p, int len)
874a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com{
875fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    static char buf[256];
876fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    char tbuf[32];
877fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int i;
878fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint16_t *pc = (uint16_t*) p;
879fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    sprintf(buf,"%8s:", str);
880fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    len = (len / sizeof(uint16_t));    /* passed as bytes */
881fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    for(i=0;i<len;i++) {
882fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sprintf(tbuf, " %04x", pc[i]);
883fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        strcat(buf, tbuf);
884fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
885fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    SkDebugf("%s\n", buf);
886a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
887a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
888a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
889a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32A_D565_Opaque_Dither_neon (uint16_t * SK_RESTRICT dst,
890a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                   const SkPMColor* SK_RESTRICT src,
891a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                   int count, U8CPU alpha, int x, int y) {
892a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    SkASSERT(255 == alpha);
893a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
894fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#define    UNROLL    8
895a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
896a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count >= UNROLL) {
897fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint8x8_t dbase;
898fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
899fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    defined(DEBUG_OPAQUE_DITHER)
900fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint16_t tmpbuf[UNROLL];
901fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int td[UNROLL];
902fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int tdv[UNROLL];
903fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int ta[UNROLL];
904fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int tap[UNROLL];
905fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint16_t in_dst[UNROLL];
906fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int offset = 0;
907fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    int noisy = 0;
908a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
909a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
910fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    const uint8_t *dstart = &gDitherMatrix_Neon[(y&3)*12 + (x&3)];
911fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    dbase = vld1_u8(dstart);
912a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
913a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        do {
914fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint8x8_t sr, sg, sb, sa, d;
915fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t dst8, scale8, alpha8;
916fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t dst_r, dst_g, dst_b;
917fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
918fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    defined(DEBUG_OPAQUE_DITHER)
919fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /* calculate 8 elements worth into a temp buffer */
920fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    {
921fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com      int my_y = y;
922fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com      int my_x = x;
923fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com      SkPMColor* my_src = (SkPMColor*)src;
924fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com      uint16_t* my_dst = dst;
925fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com      int i;
926a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
927a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com          DITHER_565_SCAN(my_y);
928a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com          for(i=0;i<UNROLL;i++) {
929a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColor c = *my_src++;
930a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColorAssert(c);
931a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            if (c) {
932a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned a = SkGetPackedA32(c);
933fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
934a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                int d = SkAlphaMul(DITHER_VALUE(my_x), SkAlpha255To256(a));
935fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        tdv[i] = DITHER_VALUE(my_x);
936fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        ta[i] = a;
937fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        tap[i] = SkAlpha255To256(a);
938fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        td[i] = d;
939fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
940a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sr = SkGetPackedR32(c);
941a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sg = SkGetPackedG32(c);
942a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sb = SkGetPackedB32(c);
943a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sr = SkDITHER_R32_FOR_565(sr, d);
944a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sg = SkDITHER_G32_FOR_565(sg, d);
945a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sb = SkDITHER_B32_FOR_565(sb, d);
946fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
947a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                uint32_t src_expanded = (sg << 24) | (sr << 13) | (sb << 2);
948a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                uint32_t dst_expanded = SkExpand_rgb_16(*my_dst);
949a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                dst_expanded = dst_expanded * (SkAlpha255To256(255 - a) >> 3);
950a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // now src and dst expanded are in g:11 r:10 x:1 b:10
951a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                tmpbuf[i] = SkCompact_rgb_16((src_expanded + dst_expanded) >> 5);
952fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        td[i] = d;
953a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
954a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            } else {
955fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        tmpbuf[i] = *my_dst;
956fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        ta[i] = tdv[i] = td[i] = 0xbeef;
957fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        }
958fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        in_dst[i] = *my_dst;
959a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            my_dst += 1;
960a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            DITHER_INC_X(my_x);
961a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com          }
962fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
963a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
964a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
965fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* source is in ABGR */
966fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        {
967fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d0 asm("d0");
968fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d1 asm("d1");
969fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d2 asm("d2");
970fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d3 asm("d3");
971a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
972fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        asm ("vld4.8    {d0-d3},[%4]  /* r=%P0 g=%P1 b=%P2 a=%P3 */"
973fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            : "=w" (d0), "=w" (d1), "=w" (d2), "=w" (d3)
974fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            : "r" (src)
975a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                    );
976fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            sr = d0; sg = d1; sb = d2; sa = d3;
977fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        }
978a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
979fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* calculate 'd', which will be 0..7 */
980fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* dbase[] is 0..7; alpha is 0..256; 16 bits suffice */
981a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#if defined(SK_BUILD_FOR_ANDROID)
982fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* SkAlpha255To256() semantic a+1 vs a+a>>7 */
983fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha8 = vaddw_u8(vmovl_u8(sa), vdup_n_u8(1));
984a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
985fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha8 = vaddw_u8(vmovl_u8(sa), vshr_n_u8(sa, 7));
986a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
987fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        alpha8 = vmulq_u16(alpha8, vmovl_u8(dbase));
988fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        d = vshrn_n_u16(alpha8, 8);    /* narrowing too */
989fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
990fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sr = sr - (sr>>5) + d */
991fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* watching for 8-bit overflow.  d is 0..7; risky range of
992fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         * sr is >248; and then (sr>>5) is 7 so it offsets 'd';
993fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         * safe  as long as we do ((sr-sr>>5) + d) */
994fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sr = vsub_u8(sr, vshr_n_u8(sr, 5));
995fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sr = vadd_u8(sr, d);
996fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
997fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sb = sb - (sb>>5) + d */
998fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sb = vsub_u8(sb, vshr_n_u8(sb, 5));
999fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sb = vadd_u8(sb, d);
1000fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1001fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sg = sg - (sg>>6) + d>>1; similar logic for overflows */
1002fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sg = vsub_u8(sg, vshr_n_u8(sg, 6));
1003fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sg = vadd_u8(sg, vshr_n_u8(d,1));
1004fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1005fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* need to pick up 8 dst's -- at 16 bits each, 128 bits */
1006fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vld1q_u16(dst);
1007fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_b = vandq_u16(dst8, vdupq_n_u16(0x001F));
1008fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_g = vandq_u16(vshrq_n_u16(dst8,5), vdupq_n_u16(0x003F));
1009fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_r = vshrq_n_u16(dst8,11);    /* clearing hi bits */
1010fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1011fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* blend */
1012a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#if 1
1013fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* SkAlpha255To256() semantic a+1 vs a+a>>7 */
1014fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* originally 255-sa + 1 */
1015fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        scale8 = vsubw_u8(vdupq_n_u16(256), sa);
1016a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
1017fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        scale8 = vsubw_u8(vdupq_n_u16(255), sa);
1018fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        scale8 = vaddq_u16(scale8, vshrq_n_u16(scale8, 7));
1019a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
1020a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1021a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#if 1
1022fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* combine the addq and mul, save 3 insns */
1023fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        scale8 = vshrq_n_u16(scale8, 3);
1024fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_b = vmlaq_u16(vshll_n_u8(sb,2), dst_b, scale8);
1025fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_g = vmlaq_u16(vshll_n_u8(sg,3), dst_g, scale8);
1026fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_r = vmlaq_u16(vshll_n_u8(sr,2), dst_r, scale8);
1027a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#else
1028fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* known correct, but +3 insns over above */
1029fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        scale8 = vshrq_n_u16(scale8, 3);
1030fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_b = vmulq_u16(dst_b, scale8);
1031fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_g = vmulq_u16(dst_g, scale8);
1032fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_r = vmulq_u16(dst_r, scale8);
1033fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1034fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* combine */
1035fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* NB: vshll widens, need to preserve those bits */
1036fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_b = vaddq_u16(dst_b, vshll_n_u8(sb,2));
1037fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_g = vaddq_u16(dst_g, vshll_n_u8(sg,3));
1038fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst_r = vaddq_u16(dst_r, vshll_n_u8(sr,2));
1039a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
1040a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1041fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* repack to store */
1042fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vandq_u16(vshrq_n_u16(dst_b, 5), vdupq_n_u16(0x001F));
1043fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vsliq_n_u16(dst8, vshrq_n_u16(dst_g, 5), 5);
1044fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vsliq_n_u16(dst8, vshrq_n_u16(dst_r,5), 11);
1045fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1046fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        vst1q_u16(dst, dst8);
1047fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1048fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    defined(DEBUG_OPAQUE_DITHER)
1049fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* verify my 8 elements match the temp buffer */
1050fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    {
1051fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       int i, bad=0;
1052fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       static int invocation;
1053fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1054fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       for (i=0;i<UNROLL;i++)
1055fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        if (tmpbuf[i] != dst[i]) bad=1;
1056fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       if (bad) {
1057fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        SkDebugf("BAD S32A_D565_Opaque_Dither_neon(); invocation %d offset %d\n",
1058fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            invocation, offset);
1059fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        SkDebugf("  alpha 0x%x\n", alpha);
1060fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        for (i=0;i<UNROLL;i++)
1061fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            SkDebugf("%2d: %s %04x w %04x id %04x s %08x d %04x %04x %04x %04x\n",
1062fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            i, ((tmpbuf[i] != dst[i])?"BAD":"got"),
1063fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            dst[i], tmpbuf[i], in_dst[i], src[i], td[i], tdv[i], tap[i], ta[i]);
1064fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1065fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("alpha8", &alpha8, sizeof(alpha8));
1066fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("scale8", &scale8, sizeof(scale8));
1067fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme8("d", &d, sizeof(d));
1068fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("dst8", &dst8, sizeof(dst8));
1069fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("dst_b", &dst_b, sizeof(dst_b));
1070fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("dst_g", &dst_g, sizeof(dst_g));
1071fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme16("dst_r", &dst_r, sizeof(dst_r));
1072fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme8("sb", &sb, sizeof(sb));
1073fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme8("sg", &sg, sizeof(sg));
1074fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        showme8("sr", &sr, sizeof(sr));
1075fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1076fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* cop out */
1077fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        return;
1078fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       }
1079fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       offset += UNROLL;
1080fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com       invocation++;
1081fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
1082a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
1083a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1084a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            dst += UNROLL;
1085fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src += UNROLL;
1086fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        count -= UNROLL;
1087fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* skip x += UNROLL, since it's unchanged mod-4 */
1088a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        } while (count >= UNROLL);
1089a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1090fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    UNROLL
1091a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1092a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    /* residuals */
1093a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count > 0) {
1094a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        DITHER_565_SCAN(y);
1095a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        do {
1096a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColor c = *src++;
1097a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColorAssert(c);
1098a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            if (c) {
1099a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned a = SkGetPackedA32(c);
1100fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1101a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // dither and alpha are just temporary variables to work-around
1102a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // an ICE in debug.
1103a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned dither = DITHER_VALUE(x);
1104a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned alpha = SkAlpha255To256(a);
1105a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                int d = SkAlphaMul(dither, alpha);
1106fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1107a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sr = SkGetPackedR32(c);
1108a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sg = SkGetPackedG32(c);
1109a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                unsigned sb = SkGetPackedB32(c);
1110a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sr = SkDITHER_R32_FOR_565(sr, d);
1111a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sg = SkDITHER_G32_FOR_565(sg, d);
1112a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                sb = SkDITHER_B32_FOR_565(sb, d);
1113fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1114a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                uint32_t src_expanded = (sg << 24) | (sr << 13) | (sb << 2);
1115a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                uint32_t dst_expanded = SkExpand_rgb_16(*dst);
1116a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                dst_expanded = dst_expanded * (SkAlpha255To256(255 - a) >> 3);
1117a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // now src and dst expanded are in g:11 r:10 x:1 b:10
1118a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                *dst = SkCompact_rgb_16((src_expanded + dst_expanded) >> 5);
1119a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            }
1120a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            dst += 1;
1121a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            DITHER_INC_X(x);
1122a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        } while (--count != 0);
1123a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1124a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
1125a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1126a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com///////////////////////////////////////////////////////////////////////////////
1127a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1128a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com/* 2009/10/27: RBE says "a work in progress"; debugging says ok;
1129a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * speedup untested, but ARM version is 26 insns/iteration and
1130a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * this NEON version is 21 insns/iteration-of-8 (2.62insns/element)
1131a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * which is 10x the native version; that's pure instruction counts,
1132a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com * not accounting for any instruction or memory latencies.
1133a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com */
1134a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1135fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    DEBUG_S32_OPAQUE_DITHER
1136a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1137a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid S32_D565_Opaque_Dither_neon(uint16_t* SK_RESTRICT dst,
1138a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                 const SkPMColor* SK_RESTRICT src,
1139a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                                 int count, U8CPU alpha, int x, int y) {
1140a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    SkASSERT(255 == alpha);
1141a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1142fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#define    UNROLL    8
1143a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count >= UNROLL) {
1144fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    uint8x8_t d;
1145fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    const uint8_t *dstart = &gDitherMatrix_Neon[(y&3)*12 + (x&3)];
1146fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    d = vld1_u8(dstart);
1147fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1148fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    while (count >= UNROLL) {
1149efbe8e9bedda21a3e061ebf3d96431a0f250a654djsollen@google.com        uint8x8_t sr, sg, sb;
1150efbe8e9bedda21a3e061ebf3d96431a0f250a654djsollen@google.com        uint16x8_t dr, dg, db;
1151fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        uint16x8_t dst8;
1152fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1153fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* source is in ABGR ordering (R == lsb) */
1154fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        {
1155fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d0 asm("d0");
1156fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d1 asm("d1");
1157fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d2 asm("d2");
1158fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        register uint8x8_t d3 asm("d3");
1159fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1160fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        asm ("vld4.8    {d0-d3},[%4]  /* r=%P0 g=%P1 b=%P2 a=%P3 */"
1161fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            : "=w" (d0), "=w" (d1), "=w" (d2), "=w" (d3)
1162fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            : "r" (src)
1163a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                    );
1164efbe8e9bedda21a3e061ebf3d96431a0f250a654djsollen@google.com            sr = d0; sg = d1; sb = d2;
1165fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        }
1166fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* XXX: if we want to prefetch, hide it in the above asm()
1167fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         * using the gcc __builtin_prefetch(), the prefetch will
1168fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         * fall to the bottom of the loop -- it won't stick up
1169fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         * at the top of the loop, just after the vld4.
1170fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         */
1171fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1172fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sr = sr - (sr>>5) + d */
1173fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sr = vsub_u8(sr, vshr_n_u8(sr, 5));
1174fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dr = vaddl_u8(sr, d);
1175fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1176fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sb = sb - (sb>>5) + d */
1177fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sb = vsub_u8(sb, vshr_n_u8(sb, 5));
1178fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        db = vaddl_u8(sb, d);
1179fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1180fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* sg = sg - (sg>>6) + d>>1; similar logic for overflows */
1181fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        sg = vsub_u8(sg, vshr_n_u8(sg, 6));
1182fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dg = vaddl_u8(sg, vshr_n_u8(d,1));
1183fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* XXX: check that the "d>>1" here is hoisted */
1184fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1185fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* pack high bits of each into 565 format  (rgb, b is lsb) */
1186fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vshrq_n_u16(db, 3);
1187fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vsliq_n_u16(dst8, vshrq_n_u16(dg, 2), 5);
1188fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst8 = vsliq_n_u16(dst8, vshrq_n_u16(dr,3), 11);
1189fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1190fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* store it */
1191fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        vst1q_u16(dst, dst8);
1192fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1193fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#if    defined(DEBUG_S32_OPAQUE_DITHER)
1194fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        /* always good to know if we generated good results */
1195fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        {
1196fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        int i, myx = x, myy = y;
1197fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        DITHER_565_SCAN(myy);
1198fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        for (i=0;i<UNROLL;i++) {
1199fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            SkPMColor c = src[i];
1200fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            unsigned dither = DITHER_VALUE(myx);
1201fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            uint16_t val = SkDitherRGB32To565(c, dither);
1202fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            if (val != dst[i]) {
1203fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            SkDebugf("RBE: src %08x dither %02x, want %04x got %04x dbas[i] %02x\n",
1204fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                c, dither, val, dst[i], dstart[i]);
1205fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            }
1206fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            DITHER_INC_X(myx);
1207fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        }
1208fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        }
1209a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com#endif
1210a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1211fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        dst += UNROLL;
1212fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        src += UNROLL;
1213fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        count -= UNROLL;
1214fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        x += UNROLL;        /* probably superfluous */
1215fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    }
1216a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1217fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com#undef    UNROLL
1218a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1219a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    /* residuals */
1220a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count > 0) {
1221a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        DITHER_565_SCAN(y);
1222a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        do {
1223a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColor c = *src++;
1224a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkPMColorAssert(c);
1225a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            SkASSERT(SkGetPackedA32(c) == 255);
1226a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1227a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            unsigned dither = DITHER_VALUE(x);
1228a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            *dst++ = SkDitherRGB32To565(c, dither);
1229a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            DITHER_INC_X(x);
1230a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        } while (--count != 0);
1231a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1232a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
1233a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1234a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comvoid Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count,
1235a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                      SkPMColor color) {
1236a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (count <= 0) {
1237a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        return;
1238a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1239a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1240a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (0 == color) {
1241a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        if (src != dst) {
1242a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            memcpy(dst, src, count * sizeof(SkPMColor));
1243a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        }
1244a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        return;
1245a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1246a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1247a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    unsigned colorA = SkGetPackedA32(color);
1248a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    if (255 == colorA) {
1249a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        sk_memset32(dst, color, count);
1250a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    } else {
1251a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        unsigned scale = 256 - SkAlpha255To256(colorA);
1252a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1253a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        if (count >= 8) {
1254a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // at the end of this assembly, count will have been decremented
1255a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // to a negative value. That is, if count mod 8 = x, it will be
1256a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // -8 +x coming out.
1257a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            asm volatile (
1258a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                PLD128(src, 0)
1259a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1260a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vdup.32    q0, %[color]                \n\t"
1261a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1262a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                PLD128(src, 128)
1263a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1264a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // scale numerical interval [0-255], so load as 8 bits
1265a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vdup.8     d2, %[scale]                \n\t"
1266a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1267a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                PLD128(src, 256)
1268a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1269a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "subs       %[count], %[count], #8      \n\t"
1270a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1271a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                PLD128(src, 384)
1272a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1273a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "Loop_Color32:                          \n\t"
1274a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1275a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // load src color, 8 pixels, 4 64 bit registers
1276a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // (and increment src).
1277a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vld1.32    {d4-d7}, [%[src]]!          \n\t"
1278a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1279a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                PLD128(src, 384)
1280a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1281a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // multiply long by scale, 64 bits at a time,
1282a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // destination into a 128 bit register.
1283a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vmull.u8   q4, d4, d2                  \n\t"
1284a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vmull.u8   q5, d5, d2                  \n\t"
1285a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vmull.u8   q6, d6, d2                  \n\t"
1286a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vmull.u8   q7, d7, d2                  \n\t"
1287a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1288a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // shift the 128 bit registers, containing the 16
1289a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // bit scaled values back to 8 bits, narrowing the
1290a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // results to 64 bit registers.
1291a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vshrn.i16  d8, q4, #8                  \n\t"
1292a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vshrn.i16  d9, q5, #8                  \n\t"
1293a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vshrn.i16  d10, q6, #8                 \n\t"
1294a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vshrn.i16  d11, q7, #8                 \n\t"
1295a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1296a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // adding back the color, using 128 bit registers.
1297a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vadd.i8    q6, q4, q0                  \n\t"
1298a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vadd.i8    q7, q5, q0                  \n\t"
1299a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1300a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // store back the 8 calculated pixels (2 128 bit
1301a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                // registers), and increment dst.
1302a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "vst1.32    {d12-d15}, [%[dst]]!        \n\t"
1303a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1304a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "subs       %[count], %[count], #8      \n\t"
1305a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                "bge        Loop_Color32                \n\t"
1306a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                : [src] "+r" (src), [dst] "+r" (dst), [count] "+r" (count)
1307a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                : [color] "r" (color), [scale] "r" (scale)
1308a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                : "cc", "memory",
1309a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
1310a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                  "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"
1311a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com                          );
1312a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // At this point, if we went through the inline assembly, count is
1313a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // a negative value:
1314a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // if the value is -8, there is no pixel left to process.
1315a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // if the value is -7, there is one pixel left to process
1316a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // ...
1317a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // And'ing it with 7 will give us the number of pixels
1318a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            // left to process.
1319a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            count = count & 0x7;
1320a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        }
1321a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1322a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        while (count > 0) {
1323a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            *dst = color + SkAlphaMulQ(*src, scale);
1324a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            src += 1;
1325a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            dst += 1;
1326a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com            count--;
1327a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com        }
1328a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    }
1329a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com}
1330a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1331a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com///////////////////////////////////////////////////////////////////////////////
1332a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1333a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comconst SkBlitRow::Proc sk_blitrow_platform_565_procs_arm_neon[] = {
1334a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    // no dither
1335a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    // NOTE: For the two functions below, we don't have a special version
1336a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    //       that assumes that each source pixel is opaque. But our S32A is
1337a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    //       still faster than the default, so use it.
1338a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32A_D565_Opaque_neon,  // really S32_D565_Opaque
1339a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32A_D565_Blend_neon,   // really S32_D565_Blend
1340a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32A_D565_Opaque_neon,
1341a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32A_D565_Blend_neon,
1342a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1343a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    // dither
1344a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32_D565_Opaque_Dither_neon,
1345a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32_D565_Blend_Dither_neon,
1346a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    S32A_D565_Opaque_Dither_neon,
1347a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    NULL,   // S32A_D565_Blend_Dither
1348a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com};
1349a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com
1350a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.comconst SkBlitRow::Proc32 sk_blitrow_platform_32_procs_arm_neon[] = {
1351a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com    NULL,   // S32_Opaque,
1352fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    S32_Blend_BlitRow32_neon,        // S32_Blend,
1353c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    /*
1354c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * We have two choices for S32A_Opaque procs. The one reads the src alpha
1355c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * value and attempts to optimize accordingly.  The optimization is
1356c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * sensitive to the source content and is not a win in all cases. For
1357c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * example, if there are a lot of transitions between the alpha states,
1358c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * the performance will almost certainly be worse.  However, for many
1359c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * common cases the performance is equivalent or better than the standard
1360c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     * case where we do not inspect the src alpha.
1361c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com     */
1362c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com#if SK_A32_SHIFT == 24
1363c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    // This proc assumes the alpha value occupies bits 24-32 of each SkPMColor
1364c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    S32A_Opaque_BlitRow32_neon_src_alpha,   // S32A_Opaque,
1365c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com#else
1366c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com    S32A_Opaque_BlitRow32_neon,     // S32A_Opaque,
1367c2532dd0b89e03ed158229872cb1ee06ae7f10fedjsollen@google.com#endif
13681fdc6774280ffc18dd7e1247e430931aa2f58790commit-bot@chromium.org    S32A_Blend_BlitRow32_neon        // S32A_Blend
1369a8dd1ce930811a51cc841f583424d507d95e7e78digit@google.com};
1370