1a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
2a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#include <arm_neon.h>
3a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
4a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
5a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define SCALE_NOFILTER_NAME     MAKENAME(_nofilter_scale)
6a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define SCALE_FILTER_NAME       MAKENAME(_filter_scale)
7a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define AFFINE_NOFILTER_NAME    MAKENAME(_nofilter_affine)
8a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define AFFINE_FILTER_NAME      MAKENAME(_filter_affine)
9a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PERSP_NOFILTER_NAME     MAKENAME(_nofilter_persp)
10a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PERSP_FILTER_NAME       MAKENAME(_filter_persp)
11a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
12a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PACK_FILTER_X_NAME  MAKENAME(_pack_filter_x)
13a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PACK_FILTER_Y_NAME  MAKENAME(_pack_filter_y)
14a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PACK_FILTER_X4_NAME MAKENAME(_pack_filter_x4)
15a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#define PACK_FILTER_Y4_NAME MAKENAME(_pack_filter_y4)
16a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
17a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#ifndef PREAMBLE
18a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #define PREAMBLE(state)
19a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #define PREAMBLE_PARAM_X
20a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #define PREAMBLE_PARAM_Y
21a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #define PREAMBLE_ARG_X
22a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #define PREAMBLE_ARG_Y
23a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#endif
24a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
25a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
26a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                uint32_t xy[], int count, int x, int y) {
27a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
28a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kScale_Mask)) == 0);
29a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
30a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
31a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
32a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // we store y, x, x, x, x, x
33a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    const unsigned maxX = s.fBitmap->width() - 1;
344012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt fx;
35a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    {
36a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        SkPoint pt;
37a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
38a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                 SkIntToScalar(y) + SK_ScalarHalf, &pt);
394012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        fx = SkScalarToFractionalInt(pt.fY);
40a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        const unsigned maxY = s.fBitmap->height() - 1;
414012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY);
424012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        fx = SkScalarToFractionalInt(pt.fX);
43a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
44a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
45a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (0 == maxX) {
46a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // all of the following X values must be 0
47a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        memset(xy, 0, count * sizeof(uint16_t));
48a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        return;
49a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
50a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
514012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    const SkFractionalInt dx = s.fInvSxFractionalInt;
52a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
53a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#ifdef CHECK_FOR_DECAL
54a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // test if we don't need to apply the tile proc
55a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
564012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        decal_nofilter_scale_neon(xy, SkFractionalIntToFixed(fx),
574012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org                             SkFractionalIntToFixed(dx), count);
58a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        return;
59a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
60a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#endif
61a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
62a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (count >= 8) {
634012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dx2 = dx+dx;
644012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dx4 = dx2+dx2;
654012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dx8 = dx4+dx4;
66a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
67a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // now build fx/fx+dx/fx+2dx/fx+3dx
684012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt fx1, fx2, fx3;
69a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int32x4_t lbase, hbase;
70a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int16_t *dst16 = (int16_t *)xy;
71a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
72a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx1 = fx+dx;
73a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx2 = fx1+dx;
74a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx3 = fx2+dx;
75a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
764012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        lbase = vdupq_n_s32(SkFractionalIntToFixed(fx));
774012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        lbase = vsetq_lane_s32(SkFractionalIntToFixed(fx1), lbase, 1);
784012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        lbase = vsetq_lane_s32(SkFractionalIntToFixed(fx2), lbase, 2);
794012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        lbase = vsetq_lane_s32(SkFractionalIntToFixed(fx3), lbase, 3);
804012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        hbase = vaddq_s32(lbase, vdupq_n_s32(SkFractionalIntToFixed(dx4)));
81a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
82a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // store & bump
83a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (count >= 8) {
84a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
85a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int16x8_t fx8;
86a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
87a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fx8 = TILEX_PROCF_NEON8(lbase, hbase, maxX);
88a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
89a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vst1q_s16(dst16, fx8);
90a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
91a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // but preserving base & on to the next
924012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            lbase = vaddq_s32 (lbase, vdupq_n_s32(SkFractionalIntToFixed(dx8)));
934012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            hbase = vaddq_s32 (hbase, vdupq_n_s32(SkFractionalIntToFixed(dx8)));
94a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            dst16 += 8;
95a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            count -= 8;
96a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fx += dx8;
97a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        };
98a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        xy = (uint32_t *) dst16;
99a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
100a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
101a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    uint16_t* xx = (uint16_t*)xy;
102a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    for (int i = count; i > 0; --i) {
1034012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        *xx++ = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX);
104a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx += dx;
105a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
106a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
107a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
108a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
109a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                 uint32_t xy[], int count, int x, int y) {
110a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT(s.fInvType & SkMatrix::kAffine_Mask);
111a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
112a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kScale_Mask |
113a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kAffine_Mask)) == 0);
114a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
115a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
116a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkPoint srcPt;
117a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    s.fInvProc(s.fInvMatrix,
118a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org               SkIntToScalar(x) + SK_ScalarHalf,
119a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org               SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
120a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
1214012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX);
1224012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
1234012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt dx = s.fInvSxFractionalInt;
1244012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt dy = s.fInvKyFractionalInt;
125a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int maxX = s.fBitmap->width() - 1;
126a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int maxY = s.fBitmap->height() - 1;
127a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
128a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (count >= 8) {
1294012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dx4 = dx * 4;
1304012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dy4 = dy * 4;
1314012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dx8 = dx * 8;
1324012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        SkFractionalInt dy8 = dy * 8;
133a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
134a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int32x4_t xbase, ybase;
135a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int32x4_t x2base, y2base;
136a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int16_t *dst16 = (int16_t *) xy;
137a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
138a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // now build fx, fx+dx, fx+2dx, fx+3dx
1394012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        xbase = vdupq_n_s32(SkFractionalIntToFixed(fx));
1404012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        xbase = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx), xbase, 1);
1414012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        xbase = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx+dx), xbase, 2);
1424012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        xbase = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx+dx+dx), xbase, 3);
143a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
144a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // same for fy
1454012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        ybase = vdupq_n_s32(SkFractionalIntToFixed(fy));
1464012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        ybase = vsetq_lane_s32(SkFractionalIntToFixed(fy+dy), ybase, 1);
1474012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        ybase = vsetq_lane_s32(SkFractionalIntToFixed(fy+dy+dy), ybase, 2);
1484012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        ybase = vsetq_lane_s32(SkFractionalIntToFixed(fy+dy+dy+dy), ybase, 3);
149a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
1504012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        x2base = vaddq_s32(xbase, vdupq_n_s32(SkFractionalIntToFixed(dx4)));
1514012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        y2base = vaddq_s32(ybase, vdupq_n_s32(SkFractionalIntToFixed(dy4)));
152a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
153a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // store & bump
154a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        do {
155a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int16x8x2_t hi16;
156a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
157a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            hi16.val[0] = TILEX_PROCF_NEON8(xbase, x2base, maxX);
158a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            hi16.val[1] = TILEY_PROCF_NEON8(ybase, y2base, maxY);
159a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
160a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vst2q_s16(dst16, hi16);
161a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
162a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // moving base and on to the next
1634012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            xbase = vaddq_s32(xbase, vdupq_n_s32(SkFractionalIntToFixed(dx8)));
1644012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            ybase = vaddq_s32(ybase, vdupq_n_s32(SkFractionalIntToFixed(dy8)));
1654012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            x2base = vaddq_s32(x2base, vdupq_n_s32(SkFractionalIntToFixed(dx8)));
1664012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            y2base = vaddq_s32(y2base, vdupq_n_s32(SkFractionalIntToFixed(dy8)));
167a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
168a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            dst16 += 16; // 8x32 aka 16x16
169a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            count -= 8;
170a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fx += dx8;
171a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fy += dy8;
172a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        } while (count >= 8);
173a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        xy = (uint32_t *) dst16;
174a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
175a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
176a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    for (int i = count; i > 0; --i) {
1774012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fy), maxY) << 16) |
1784012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org                 TILEX_PROCF(SkFractionalIntToFixed(fx), maxX);
179a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx += dx; fy += dy;
180a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
181a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
182a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
183a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
184a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                uint32_t* SK_RESTRICT xy,
185a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                int count, int x, int y) {
186a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
187a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
188a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
189a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // max{X,Y} are int here, but later shown/assumed to fit in 16 bits
190a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int maxX = s.fBitmap->width() - 1;
191a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int maxY = s.fBitmap->height() - 1;
192a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
193a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkPerspIter iter(s.fInvMatrix,
194a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                     SkIntToScalar(x) + SK_ScalarHalf,
195a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                     SkIntToScalar(y) + SK_ScalarHalf, count);
196a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
197a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    while ((count = iter.next()) != 0) {
198a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
199a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
200a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        if (count >= 8) {
201a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int32_t *mysrc = (int32_t *) srcXY;
202a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int16_t *mydst = (int16_t *) xy;
203a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            do {
204a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                int16x8x2_t hi16;
205a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                int32x4x2_t xy1, xy2;
206a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
207a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                xy1 = vld2q_s32(mysrc);
208a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                xy2 = vld2q_s32(mysrc+8);
209a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
210a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                hi16.val[0] = TILEX_PROCF_NEON8(xy1.val[0], xy2.val[0], maxX);
211a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                hi16.val[1] = TILEY_PROCF_NEON8(xy1.val[1], xy2.val[1], maxY);
212a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
213a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                vst2q_s16(mydst, hi16);
214a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
215a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                count -= 8;  // 8 iterations
216a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                mysrc += 16; // 16 longs
217a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                mydst += 16; // 16 shorts, aka 8 longs
218a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            } while (count >= 8);
219a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // get xy and srcXY fixed up
220a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            srcXY = (const SkFixed *) mysrc;
221a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            xy = (uint32_t *) mydst;
222a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
223a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
224a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (--count >= 0) {
225a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) |
226a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                     TILEX_PROCF(srcXY[0], maxX);
227a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            srcXY += 2;
228a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
229a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
230a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
231a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
232a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max,
233a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                          SkFixed one PREAMBLE_PARAM_Y) {
234a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned i = TILEY_PROCF(f, max);
235a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    i = (i << 4) | TILEY_LOW_BITS(f, max);
236a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    return (i << 14) | (TILEY_PROCF((f + one), max));
237a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
238a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
239a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic inline uint32_t PACK_FILTER_X_NAME(SkFixed f, unsigned max,
240a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                          SkFixed one PREAMBLE_PARAM_X) {
241a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned i = TILEX_PROCF(f, max);
242a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    i = (i << 4) | TILEX_LOW_BITS(f, max);
243a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    return (i << 14) | (TILEX_PROCF((f + one), max));
244a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
245a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
246a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic inline int32x4_t PACK_FILTER_X4_NAME(int32x4_t f, unsigned max,
247a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                          SkFixed one PREAMBLE_PARAM_X) {
248a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int32x4_t ret, res, wide_one;
249a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
250a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Prepare constants
251a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    wide_one = vdupq_n_s32(one);
252a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
253a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 1
254a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    res = TILEX_PROCF_NEON4(f, max);
255a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
256a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 2
257a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = TILEX_LOW_BITS_NEON4(f, max);
258a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = vsliq_n_s32(ret, res, 4);
259a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
260a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 3
261a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    res = TILEX_PROCF_NEON4(f + wide_one, max);
262a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = vorrq_s32(vshlq_n_s32(ret, 14), res);
263a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
264a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    return ret;
265a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
266a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
267a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic inline int32x4_t PACK_FILTER_Y4_NAME(int32x4_t f, unsigned max,
268a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                          SkFixed one PREAMBLE_PARAM_X) {
269a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    int32x4_t ret, res, wide_one;
270a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
271a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Prepare constants
272a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    wide_one = vdupq_n_s32(one);
273a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
274a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 1
275a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    res = TILEY_PROCF_NEON4(f, max);
276a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
277a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 2
278a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = TILEY_LOW_BITS_NEON4(f, max);
279a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = vsliq_n_s32(ret, res, 4);
280a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
281a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // Step 3
282a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    res = TILEY_PROCF_NEON4(f + wide_one, max);
283a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    ret = vorrq_s32(vshlq_n_s32(ret, 14), res);
284a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
285a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    return ret;
286a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
287a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
288a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void SCALE_FILTER_NAME(const SkBitmapProcState& s,
289a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                              uint32_t xy[], int count, int x, int y) {
290a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
291a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kScale_Mask)) == 0);
292a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT(s.fInvKy == 0);
293a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
294a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
295a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
296a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    const unsigned maxX = s.fBitmap->width() - 1;
297a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    const SkFixed one = s.fFilterOneX;
2984012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    const SkFractionalInt dx = s.fInvSxFractionalInt;
2994012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org    SkFractionalInt fx;
300a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
301a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    {
302a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        SkPoint pt;
303a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
304a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                 SkIntToScalar(y) + SK_ScalarHalf, &pt);
305a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
306a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        const unsigned maxY = s.fBitmap->height() - 1;
307a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // compute our two Y values up front
308a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
309a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // now initialize fx
3104012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1);
311a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
312a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
313a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#ifdef CHECK_FOR_DECAL
314a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    // test if we don't need to apply the tile proc
315a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
3164012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        decal_filter_scale_neon(xy, SkFractionalIntToFixed(fx),
3174012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org                             SkFractionalIntToFixed(dx), count);
318a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        return;
319a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
320a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#endif
321a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    {
322a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
323a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (count >= 4) {
324a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int32x4_t wide_fx;
325a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
3264012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        wide_fx = vdupq_n_s32(SkFractionalIntToFixed(fx));
3274012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx), wide_fx, 1);
3284012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx+dx), wide_fx, 2);
3294012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(SkFractionalIntToFixed(fx+dx+dx+dx), wide_fx, 3);
330a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
331a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (count >= 4) {
332a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int32x4_t res;
333a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
334a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            res = PACK_FILTER_X4_NAME(wide_fx, maxX, one PREAMBLE_ARG_X);
335a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
336a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vst1q_u32(xy, vreinterpretq_u32_s32(res));
337a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
3384012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org            wide_fx += vdupq_n_s32(SkFractionalIntToFixed(dx+dx+dx+dx));
339a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fx += dx+dx+dx+dx;
340a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            xy += 4;
341a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            count -= 4;
342a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
343a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
344a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
345a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    while (--count >= 0) {
3464012ba51a218883daef6c9be142f970b8ef5d0d2commit-bot@chromium.org        *xy++ = PACK_FILTER_X_NAME(SkFractionalIntToFixed(fx), maxX, one PREAMBLE_ARG_X);
347a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx += dx;
348a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
349a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
350a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
351a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
352a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
353a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
354a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                               uint32_t xy[], int count, int x, int y) {
355a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT(s.fInvType & SkMatrix::kAffine_Mask);
356a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
357a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kScale_Mask |
358a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                             SkMatrix::kAffine_Mask)) == 0);
359a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
360a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
361a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkPoint srcPt;
362a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    s.fInvProc(s.fInvMatrix,
363a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org               SkIntToScalar(x) + SK_ScalarHalf,
364a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org               SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
365a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
366a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed oneX = s.fFilterOneX;
367a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed oneY = s.fFilterOneY;
368a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1);
369a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
370a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed dx = s.fInvSx;
371a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed dy = s.fInvKy;
372a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned maxX = s.fBitmap->width() - 1;
373a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned maxY = s.fBitmap->height() - 1;
374a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
375a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    if (count >= 4) {
376a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        int32x4_t wide_fy, wide_fx;
377a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
378a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fx = vdupq_n_s32(fx);
379a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(fx+dx, wide_fx, 1);
380a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(fx+dx+dx, wide_fx, 2);
381a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fx = vsetq_lane_s32(fx+dx+dx+dx, wide_fx, 3);
382a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
383a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fy = vdupq_n_s32(fy);
384a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fy = vsetq_lane_s32(fy+dy, wide_fy, 1);
385a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fy = vsetq_lane_s32(fy+dy+dy, wide_fy, 2);
386a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        wide_fy = vsetq_lane_s32(fy+dy+dy+dy, wide_fy, 3);
387a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
388a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (count >= 4) {
389a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int32x4x2_t vxy;
390a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
391a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // do the X side, then the Y side, then interleave them
392a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vxy.val[0] = PACK_FILTER_Y4_NAME(wide_fy, maxY, oneY PREAMBLE_ARG_Y);
393a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vxy.val[1] = PACK_FILTER_X4_NAME(wide_fx, maxX, oneX PREAMBLE_ARG_X);
394a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
395a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // interleave as YXYXYXYX as part of the storing
396a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vst2q_s32((int32_t*)xy, vxy);
397a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
398a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // prepare next iteration
399a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            wide_fx += vdupq_n_s32(dx+dx+dx+dx);
400a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fx += dx + dx + dx + dx;
401a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            wide_fy += vdupq_n_s32(dy+dy+dy+dy);
402a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            fy += dy+dy+dy+dy;
403a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            xy += 8; // 4 x's, 4 y's
404a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            count -= 4;
405a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
406a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
407a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
408a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    while (--count >= 0) {
409a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        // NB: writing Y/X
410a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y);
411a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fy += dy;
412a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X);
413a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        fx += dx;
414a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
415a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
416a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
417a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgstatic void PERSP_FILTER_NAME(const SkBitmapProcState& s,
418a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                              uint32_t* SK_RESTRICT xy, int count,
419a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                              int x, int y) {
420a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
421a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
422a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PREAMBLE(s);
423a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned maxX = s.fBitmap->width() - 1;
424a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    unsigned maxY = s.fBitmap->height() - 1;
425a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed oneX = s.fFilterOneX;
426a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkFixed oneY = s.fFilterOneY;
427a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
428a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SkPerspIter iter(s.fInvMatrix,
429a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                     SkIntToScalar(x) + SK_ScalarHalf,
430a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                     SkIntToScalar(y) + SK_ScalarHalf, count);
431a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
432a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    while ((count = iter.next()) != 0) {
433a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
434a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
435a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (count >= 4) {
436a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int32x4_t wide_x, wide_y;
437a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            int32x4x2_t vxy, vresyx;
438a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
439a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // load src:  x-y-x-y-x-y-x-y
440a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vxy = vld2q_s32(srcXY);
441a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
442a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // do the X side, then the Y side, then interleave them
443a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            wide_x = vsubq_s32(vxy.val[0], vdupq_n_s32(oneX>>1));
444a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            wide_y = vsubq_s32(vxy.val[1], vdupq_n_s32(oneY>>1));
445a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
446a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vresyx.val[0] = PACK_FILTER_Y4_NAME(wide_y, maxY, oneY PREAMBLE_ARG_Y);
447a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vresyx.val[1] = PACK_FILTER_X4_NAME(wide_x, maxX, oneX PREAMBLE_ARG_X);
448a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
449a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // store interleaved as y-x-y-x-y-x-y-x (NB != read order)
450a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            vst2q_s32((int32_t*)xy, vresyx);
451a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
452a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // on to the next iteration
453a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            srcXY += 2*4;
454a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            count -= 4;
455a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            xy += 2*4;
456a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
457a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
458a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        while (--count >= 0) {
459a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            // NB: we read x/y, we write y/x
460a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY,
461a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                       oneY PREAMBLE_ARG_Y);
462a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX,
463a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org                                       oneX PREAMBLE_ARG_X);
464a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org            srcXY += 2;
465a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org        }
466a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    }
467a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org}
468a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
469a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.orgconst SkBitmapProcState::MatrixProc MAKENAME(_Procs)[] = {
470a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SCALE_NOFILTER_NAME,
471a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    SCALE_FILTER_NAME,
472a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    AFFINE_NOFILTER_NAME,
473a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    AFFINE_FILTER_NAME,
474a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PERSP_NOFILTER_NAME,
475a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    PERSP_FILTER_NAME
476a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org};
477a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
478a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEX_PROCF_NEON8
479a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEY_PROCF_NEON8
480a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEX_PROCF_NEON4
481a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEY_PROCF_NEON4
482a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEX_LOW_BITS_NEON4
483a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEY_LOW_BITS_NEON4
484a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
485a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef MAKENAME
486a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEX_PROCF
487a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEY_PROCF
488a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#ifdef CHECK_FOR_DECAL
489a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org    #undef CHECK_FOR_DECAL
490a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#endif
491a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
492a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef SCALE_NOFILTER_NAME
493a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef SCALE_FILTER_NAME
494a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef AFFINE_NOFILTER_NAME
495a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef AFFINE_FILTER_NAME
496a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PERSP_NOFILTER_NAME
497a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PERSP_FILTER_NAME
498a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
499a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PREAMBLE
500a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PREAMBLE_PARAM_X
501a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PREAMBLE_PARAM_Y
502a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PREAMBLE_ARG_X
503a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef PREAMBLE_ARG_Y
504a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org
505a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEX_LOW_BITS
506a96176dc0315d786c187bfa9be5dccf2f08feba2commit-bot@chromium.org#undef TILEY_LOW_BITS
507