• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola */
2 /*
3  * Modifications done in-house at Motorola
4  *
5  * this is a clone of SkBitmapProcState_matrix.h
6  * and has been tuned to work with the NEON unit.
7  *
8  * Still going back and forth between whether this approach
9  * (clone the entire SkBitmapProcState_matrix.h file or
10  * if I should put just the modified routines in here and
11  * then use a construct like #define DONT_DO_THIS_FUNCTION or
12  * something like that...
13  *
14  * This is for the RepeatX_RepeatY part of the world
15  */
16 
17 
18 #if	!defined(__ARM_HAVE_NEON)
19 #error	this file can be used only when the NEON unit is enabled
20 #endif
21 
22 #include <arm_neon.h>
23 
24 /*
25  * This has been modified on the knowledge that (at the time)
26  * we had the following macro definitions in the parent file
27  *
28  * #define MAKENAME(suffix)        RepeatX_RepeatY ## suffix
29  * #define TILEX_PROCF(fx, max)    (((fx) & 0xFFFF) * ((max) + 1) >> 16)
30  * #define TILEY_PROCF(fy, max)    (((fy) & 0xFFFF) * ((max) + 1) >> 16)
31  * #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
32  * #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
33  */
34 
35 /* SkClampMax(val,max) -- bound to 0..max */
36 
37 #define SCALE_NOFILTER_NAME     MAKENAME(_nofilter_scale)
38 #define SCALE_FILTER_NAME       MAKENAME(_filter_scale)
39 #define AFFINE_NOFILTER_NAME    MAKENAME(_nofilter_affine)
40 #define AFFINE_FILTER_NAME      MAKENAME(_filter_affine)
41 #define PERSP_NOFILTER_NAME     MAKENAME(_nofilter_persp)
42 #define PERSP_FILTER_NAME       MAKENAME(_filter_persp)
43 
44 #define PACK_FILTER_X_NAME  MAKENAME(_pack_filter_x)
45 #define PACK_FILTER_Y_NAME  MAKENAME(_pack_filter_y)
46 
47 #ifndef PREAMBLE
48     #define PREAMBLE(state)
49     #define PREAMBLE_PARAM_X
50     #define PREAMBLE_PARAM_Y
51     #define PREAMBLE_ARG_X
52     #define PREAMBLE_ARG_Y
53 #endif
54 
SCALE_NOFILTER_NAME(const SkBitmapProcState & s,uint32_t xy[],int count,int x,int y)55 static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
56                                 uint32_t xy[], int count, int x, int y) {
57     SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
58                              SkMatrix::kScale_Mask)) == 0);
59 
60     PREAMBLE(s);
61     // we store y, x, x, x, x, x
62 
63     const unsigned maxX = s.fBitmap->width() - 1;
64     SkFixed fx;
65     {
66         SkPoint pt;
67         s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
68                                   SkIntToScalar(y) + SK_ScalarHalf, &pt);
69         fx = SkScalarToFixed(pt.fY);
70         const unsigned maxY = s.fBitmap->height() - 1;
71         *xy++ = TILEY_PROCF(fx, maxY);
72         fx = SkScalarToFixed(pt.fX);
73     }
74 
75     if (0 == maxX) {
76         // all of the following X values must be 0
77         memset(xy, 0, count * sizeof(uint16_t));
78         return;
79     }
80 
81     const SkFixed dx = s.fInvSx;
82 
83 #ifdef CHECK_FOR_DECAL
84     // test if we don't need to apply the tile proc
85     if ((unsigned)(fx >> 16) <= maxX &&
86         (unsigned)((fx + dx * (count - 1)) >> 16) <= maxX) {
87         decal_nofilter_scale(xy, fx, dx, count);
88     } else
89 #endif
90     {
91         int i;
92 
93 #if	defined(__ARM_HAVE_NEON)
94 	/* RBE: very much like done in decal_nofilter ,
95 	 * but some processing of the 'fx' information
96          * TILEX_PROCF(fx, max)    (((fx) & 0xFFFF) * ((max) + 1) >> 16)
97 	 */
98 	if (count >= 8)
99 	{
100 	    /* SkFixed is 16.16 fixed point */
101 	    SkFixed dx2 = dx+dx;
102 	    SkFixed dx4 = dx2+dx2;
103 	    SkFixed dx8 = dx4+dx4;
104 
105 	    /* now build fx/fx+dx/fx+2dx/fx+3dx */
106 	    SkFixed fx1, fx2, fx3;
107 	    int32x2_t lower, upper;
108 	    int32x4_t lbase, hbase;
109 	    int16_t *dst16 = (int16_t *)xy;
110 
111 	    fx1 = fx+dx;
112 	    fx2 = fx1+dx;
113 	    fx3 = fx2+dx;
114 
115 #if 1
116 	    /* avoid the 'lbase unitialized' warning */
117 	    lbase = vdupq_n_s32(fx);
118 #else
119 	    lbase = vsetq_lane_s32(fx, lbase, 0);
120 #endif
121 	    lbase = vsetq_lane_s32(fx1, lbase, 1);
122 	    lbase = vsetq_lane_s32(fx2, lbase, 2);
123 	    lbase = vsetq_lane_s32(fx3, lbase, 3);
124 	    hbase = vaddq_s32(lbase, vdupq_n_s32(dx4));
125 
126 	    /* store & bump */
127 	    do
128 	    {
129 	        int32x4_t lout;
130 		int32x4_t hout;
131 		int16x8_t hi16;
132 
133          	/* TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) */
134 		/* mask to low 16 [would like to use uzp tricks) */
135 	        lout = vandq_s32(lbase, vdupq_n_s32(0xffff));
136 	        hout = vandq_s32(hbase, vdupq_n_s32(0xffff));
137 		/* bare multiplication, not SkFixedMul */
138 		lout = vmulq_s32(lout, vdupq_n_s32(maxX+1));
139 		hout = vmulq_s32(hout, vdupq_n_s32(maxX+1));
140 
141 		/* extraction, using uzp */
142 		/* this is ok -- we want all hi(lout)s then all hi(hout)s */
143 		asm ("vuzpq.16 %q0, %q1" : "+w" (lout), "+w" (hout));
144 		hi16 = vreinterpretq_s16_s32(hout);
145 		vst1q_s16(dst16, hi16);
146 
147 		/* bump our base on to the next */
148 		lbase = vaddq_s32 (lbase, vdupq_n_s32(dx8));
149 		hbase = vaddq_s32 (hbase, vdupq_n_s32(dx8));
150 		dst16 += 8;
151 		count -= 8;
152 		fx += dx8;
153 	    } while (count >= 8);
154 	    xy = (uint32_t *) dst16;
155 	}
156 #else
157 	/* simple, portable way of looking at 4 at a crack;
158 	 * so gets some loop unrolling, but not full SIMD speed
159 	 */
160         for (i = (count >> 2); i > 0; --i) {
161             unsigned a, b;
162             a = TILEX_PROCF(fx, maxX); fx += dx;
163             b = TILEX_PROCF(fx, maxX); fx += dx;
164 #ifdef SK_CPU_BENDIAN
165             *xy++ = (a << 16) | b;
166 #else
167             *xy++ = (b << 16) | a;
168 #endif
169             a = TILEX_PROCF(fx, maxX); fx += dx;
170             b = TILEX_PROCF(fx, maxX); fx += dx;
171 #ifdef SK_CPU_BENDIAN
172             *xy++ = (a << 16) | b;
173 #else
174             *xy++ = (b << 16) | a;
175 #endif
176         }
177 	/* loop doesn't adjust count */
178 	count -= (count>>2);
179 #endif
180         uint16_t* xx = (uint16_t*)xy;
181         for (i = count; i > 0; --i) {
182             *xx++ = TILEX_PROCF(fx, maxX); fx += dx;
183         }
184     }
185 }
186 
187 // note: we could special-case on a matrix which is skewed in X but not Y.
188 // this would require a more general setup thatn SCALE does, but could use
189 // SCALE's inner loop that only looks at dx
190 
191 
AFFINE_NOFILTER_NAME(const SkBitmapProcState & s,uint32_t xy[],int count,int x,int y)192 static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
193                                  uint32_t xy[], int count, int x, int y) {
194     SkASSERT(s.fInvType & SkMatrix::kAffine_Mask);
195     SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
196                              SkMatrix::kScale_Mask |
197                              SkMatrix::kAffine_Mask)) == 0);
198 
199     PREAMBLE(s);
200     SkPoint srcPt;
201     s.fInvProc(*s.fInvMatrix,
202                SkIntToScalar(x) + SK_ScalarHalf,
203                SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
204 
205     SkFixed fx = SkScalarToFixed(srcPt.fX);
206     SkFixed fy = SkScalarToFixed(srcPt.fY);
207     SkFixed dx = s.fInvSx;
208     SkFixed dy = s.fInvKy;
209     int maxX = s.fBitmap->width() - 1;
210     int maxY = s.fBitmap->height() - 1;
211 
212 #if 1
213     int ocount = count;
214     uint32_t *oxy = xy;
215     SkFixed bfx = fx, bfy=fy, bdx=dx, bdy=dy;
216 #endif
217 
218 #if	defined(__ARM_HAVE_NEON)
219 
220 	if (0) { extern void rbe(void); rbe(); }
221 
222 	/* RBE: benchmarks show this eats up time; can we neonize it? */
223 	/* RBE: very much like done in decal_nofilter ,
224 	 * but some processing of the 'fx' information
225          * TILEX_PROCF(fx, max)    (((fx) & 0xFFFF) * ((max) + 1) >> 16)
226 	 */
227 	if (count >= 4)
228 	{
229 	    /* SkFixed is 16.16 fixed point */
230 	    SkFixed dx4 = dx*4;
231 	    SkFixed dy4 = dy*4;
232 
233 	    /* now build fx/fx+dx/fx+2dx/fx+3dx */
234 	    int32x2_t lower, upper;
235 	    int32x4_t xbase, ybase;
236 	    int16_t *dst16 = (int16_t *)xy;
237 
238 	    /* synthesize 4x for both X and Y */
239 #if 1
240 	    /* avoid the xbase unitialized warning */
241 	    xbase = vdupq_n_s32(fx);
242 #else
243 	    xbase = vsetq_lane_s32(fx, xbase, 0);
244 #endif
245 	    xbase = vsetq_lane_s32(fx+dx, xbase, 1);
246 	    xbase = vsetq_lane_s32(fx+dx+dx, xbase, 2);
247 	    xbase = vsetq_lane_s32(fx+dx+dx+dx, xbase, 3);
248 
249 #if 1
250 	    /* avoid the xbase unitialized warning */
251 	    ybase = vdupq_n_s32(fy);
252 #else
253 	    ybase = vsetq_lane_s32(fy, ybase, 0);
254 #endif
255 	    ybase = vsetq_lane_s32(fy+dy, ybase, 1);
256 	    ybase = vsetq_lane_s32(fy+dy+dy, ybase, 2);
257 	    ybase = vsetq_lane_s32(fy+dy+dy+dy, ybase, 3);
258 
259 	    /* store & bump */
260 	    do
261 	    {
262 	        int32x4_t xout;
263 		int32x4_t yout;
264 		int16x8_t hi16;
265 
266          	/* TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) */
267 		/* mask to low 16 [would like to use uzp tricks) */
268 	        xout = vandq_s32(xbase, vdupq_n_s32(0xffff));
269 	        yout = vandq_s32(ybase, vdupq_n_s32(0xffff));
270 		/* bare multiplication, not SkFixedMul */
271 		xout = vmulq_s32(xout, vdupq_n_s32(maxX+1));
272 		yout = vmulq_s32(yout, vdupq_n_s32(maxY+1));
273 
274 		/* put hi16 from xout over low16 from yout */
275 		yout = vsriq_n_s32(yout, xout, 16);
276 
277 		/* and then yout has the interleaved upper 16's */
278 		hi16 = vreinterpretq_s16_s32(yout);
279 		vst1q_s16(dst16, hi16);
280 
281 		/* bump preserved base & on to the next */
282 		xbase = vaddq_s32 (xbase, vdupq_n_s32(dx4));
283 		ybase = vaddq_s32 (ybase, vdupq_n_s32(dy4));
284 		dst16 += 8;	/* 8 x16 aka 4x32 */
285 		count -= 4;
286 		fx += dx4;
287 		fy += dy4;
288 	    } while (count >= 4);
289 	    xy = (uint32_t *) dst16;
290 	}
291 #if 0
292     /* diagnostics... see whether we agree with the NEON code */
293     int bad = 0;
294     uint32_t *myxy = oxy;
295     int myi = (-1);
296     SkFixed ofx = bfx, ofy= bfy, odx= bdx, ody= bdy;
297     for (myi = ocount; myi > 0; --myi) {
298 	uint32_t val = (TILEY_PROCF(ofy, maxY) << 16) | TILEX_PROCF(ofx, maxX);
299 	if (val != *myxy++) {
300 		bad++;
301 		break;
302 	}
303         ofx += odx; ofy += ody;
304     }
305     if (bad) {
306 	SkDebugf("repeat-nofilter-affine fails\n");
307 	SkDebugf("count %d myi %d\n", ocount, myi);
308 	SkDebugf(" bfx %08x, bdx %08x, bfy %08x bdy %08x\n",
309 			bfx, bdx, bfy, bdy);
310 	SkDebugf("maxX %08x maxY %08x\n", maxX, maxY);
311     }
312 #endif
313 #endif
314 
315     for (int i = count; i > 0; --i) {
316 	/* fx, fy, dx, dy are all 32 bit 16.16 fixed point */
317 	/* (((fx) & 0xFFFF) * ((max) + 1) >> 16) */
318         *xy++ = (TILEY_PROCF(fy, maxY) << 16) | TILEX_PROCF(fx, maxX);
319         fx += dx; fy += dy;
320     }
321 }
322 
PERSP_NOFILTER_NAME(const SkBitmapProcState & s,uint32_t * SK_RESTRICT xy,int count,int x,int y)323 static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
324                                 uint32_t* SK_RESTRICT xy,
325                                 int count, int x, int y) {
326     SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
327 
328     PREAMBLE(s);
329     int maxX = s.fBitmap->width() - 1;
330     int maxY = s.fBitmap->height() - 1;
331 
332     SkPerspIter   iter(*s.fInvMatrix,
333                        SkIntToScalar(x) + SK_ScalarHalf,
334                        SkIntToScalar(y) + SK_ScalarHalf, count);
335 
336     while ((count = iter.next()) != 0) {
337         const SkFixed* SK_RESTRICT srcXY = iter.getXY();
338 
339 #if	defined(__ARM_HAVE_NEON)
340 	/* RBE: */
341 	/* TILEX_PROCF(fx, max) (((fx) & 0xFFFF) * ((max) + 1) >> 16) */
342 	/* it's a little more complicated than what I did for the
343 	 * clamp case -- where I could immediately snip to the top
344 	 * 16 bits and do my min/max games there.
345 	 * ... might only be able to get 4x unrolling here
346 	 */
347 
348 	/* vld2 to get a set of 32x4's ... */
349 	/* do the tile[xy]_procf operations */
350 	/* which includes doing vuzp to get hi16's */
351 	/* store it */
352 	/* -- inner loop (other than vld2) can be had from above */
353 
354 	/* srcXY is a batch of 32 bit numbers X0,Y0,X1,Y1...
355 	 * but we immediately discard the low 16 bits...
356 	 * so what we're going to do is vld4, which will give us
357 	 * xlo,xhi,ylo,yhi distribution and we can ignore the 'lo'
358 	 * parts....
359 	 */
360 	if (0) { extern void rbe(void); rbe(); }
361 	if (count >= 8) {
362 	    int32_t *mysrc = (int32_t *) srcXY;
363 	    int16_t *mydst = (int16_t *) xy;
364 	    do {
365 	    	register int32x4_t x asm("q0");
366 	    	register int32x4_t y asm("q1");
367 	    	register int32x4_t x2 asm("q2");
368 	    	register int32x4_t y2 asm("q3");
369 
370 		int16x8_t hi;
371 		int16x8_t hi2;
372 
373 		/* read array of x,y,x,y,x,y */
374 	        /* vld2 does the de-interleaving for us */
375 	        /* dependent on register assignments above */
376     	        asm ("vld2.32	{q0-q1},[%2]  /* x=%q0 y=%q1 */"
377 		    : "=w" (x), "=w" (y)
378 		    : "r" (mysrc)
379 		    );
380 
381 		/* offset == 256 bits == 32 bytes == 8 longs */
382     	        asm ("vld2.32	{q2-q3},[%2,#32]  /* x=%q0 y=%q1 */"
383 		    : "=w" (x2), "=w" (y2)
384 		    : "r" (mysrc)
385 		    );
386 
387          	/* TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) */
388 		/* mask to low 16 [would like to use uzp tricks) */
389 		/* bare multiplication, not SkFixedMul */
390 	        x = vandq_s32(x, vdupq_n_s32(0xffff));
391 		x = vmulq_s32(x, vdupq_n_s32(maxX+1));
392 	        y = vandq_s32(y, vdupq_n_s32(0xffff));
393 		y = vmulq_s32(y, vdupq_n_s32(maxY+1));
394 
395 	        x2 = vandq_s32(x2, vdupq_n_s32(0xffff));
396 		x2 = vmulq_s32(x2, vdupq_n_s32(maxX+1));
397 	        y2 = vandq_s32(y2, vdupq_n_s32(0xffff));
398 		y2 = vmulq_s32(y2, vdupq_n_s32(maxY+1));
399 
400 		/* now collect interleaved high 16's */
401 		/* (hi-x, hi-y)4  (hi-x2; hi-y2)4 */
402 
403 		/* extraction, using uzp, leaves hi16's in y */
404 		y = vsriq_n_s32(y, x, 16);
405 		hi = vreinterpretq_s16_s32(y);
406 		vst1q_s16(mydst, hi);
407 
408 		/* and get second 8 bytes out */
409 		y2 = vsriq_n_s32(y2, x2, 16);
410 		hi2 = vreinterpretq_s16_s32(y2);
411 		vst1q_s16(mydst+8, hi2);
412 
413 		/* XXX: gcc isn't interleaving these with the NEON ops
414 		 * but i think that all the scoreboarding works out */
415 		count -= 8;	/* 8 iterations */
416 		mysrc += 16;	/* 16 longs */
417 		mydst += 16;	/* 16 shorts, aka 8 longs */
418 	    } while (count >= 8);
419 	    /* get xy and srcXY fixed up */
420 	    srcXY = (const SkFixed *) mysrc;
421 	    xy = (uint32_t *) mydst;
422 	}
423 #endif
424         while (--count >= 0) {
425             *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) |
426                      TILEX_PROCF(srcXY[0], maxX);
427             srcXY += 2;
428         }
429     }
430 }
431 
432 //////////////////////////////////////////////////////////////////////////////
433 
PACK_FILTER_Y_NAME(SkFixed f,unsigned max,SkFixed one PREAMBLE_PARAM_Y)434 static inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max,
435                                           SkFixed one PREAMBLE_PARAM_Y) {
436     unsigned i = TILEY_PROCF(f, max);
437     i = (i << 4) | TILEY_LOW_BITS(f, max);
438     return (i << 14) | (TILEY_PROCF((f + one), max));
439 }
440 
PACK_FILTER_X_NAME(SkFixed f,unsigned max,SkFixed one PREAMBLE_PARAM_X)441 static inline uint32_t PACK_FILTER_X_NAME(SkFixed f, unsigned max,
442                                           SkFixed one PREAMBLE_PARAM_X) {
443     unsigned i = TILEX_PROCF(f, max);
444     i = (i << 4) | TILEX_LOW_BITS(f, max);
445     return (i << 14) | (TILEX_PROCF((f + one), max));
446 }
447 
SCALE_FILTER_NAME(const SkBitmapProcState & s,uint32_t xy[],int count,int x,int y)448 static void SCALE_FILTER_NAME(const SkBitmapProcState& s,
449                               uint32_t xy[], int count, int x, int y) {
450     SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
451                              SkMatrix::kScale_Mask)) == 0);
452     SkASSERT(s.fInvKy == 0);
453 
454     PREAMBLE(s);
455 
456     const unsigned maxX = s.fBitmap->width() - 1;
457     const SkFixed one = s.fFilterOneX;
458     const SkFixed dx = s.fInvSx;
459     SkFixed fx;
460 
461     {
462         SkPoint pt;
463         s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
464                                   SkIntToScalar(y) + SK_ScalarHalf, &pt);
465         const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
466         const unsigned maxY = s.fBitmap->height() - 1;
467         // compute our two Y values up front
468         *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
469         // now initialize fx
470         fx = SkScalarToFixed(pt.fX) - (one >> 1);
471     }
472 
473 #ifdef CHECK_FOR_DECAL
474     // test if we don't need to apply the tile proc
475     if (dx > 0 &&
476             (unsigned)(fx >> 16) <= maxX &&
477             (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) {
478         decal_filter_scale(xy, fx, dx, count);
479     } else
480 #endif
481     {
482         do {
483             *xy++ = PACK_FILTER_X_NAME(fx, maxX, one PREAMBLE_ARG_X);
484             fx += dx;
485         } while (--count != 0);
486     }
487 }
488 
AFFINE_FILTER_NAME(const SkBitmapProcState & s,uint32_t xy[],int count,int x,int y)489 static void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
490                                uint32_t xy[], int count, int x, int y) {
491     SkASSERT(s.fInvType & SkMatrix::kAffine_Mask);
492     SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
493                              SkMatrix::kScale_Mask |
494                              SkMatrix::kAffine_Mask)) == 0);
495 
496     PREAMBLE(s);
497     SkPoint srcPt;
498     s.fInvProc(*s.fInvMatrix,
499                SkIntToScalar(x) + SK_ScalarHalf,
500                SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
501 
502     SkFixed oneX = s.fFilterOneX;
503     SkFixed oneY = s.fFilterOneY;
504     SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1);
505     SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
506     SkFixed dx = s.fInvSx;
507     SkFixed dy = s.fInvKy;
508     unsigned maxX = s.fBitmap->width() - 1;
509     unsigned maxY = s.fBitmap->height() - 1;
510 
511     do {
512         *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y);
513         fy += dy;
514         *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X);
515         fx += dx;
516     } while (--count != 0);
517 }
518 
PERSP_FILTER_NAME(const SkBitmapProcState & s,uint32_t * SK_RESTRICT xy,int count,int x,int y)519 static void PERSP_FILTER_NAME(const SkBitmapProcState& s,
520                               uint32_t* SK_RESTRICT xy, int count,
521                               int x, int y) {
522     SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
523 
524     extern void rbe(void);
525 
526     PREAMBLE(s);
527     unsigned maxX = s.fBitmap->width() - 1;
528     unsigned maxY = s.fBitmap->height() - 1;
529     SkFixed oneX = s.fFilterOneX;
530     SkFixed oneY = s.fFilterOneY;
531 
532 
533 
534     SkPerspIter   iter(*s.fInvMatrix,
535                        SkIntToScalar(x) + SK_ScalarHalf,
536                        SkIntToScalar(y) + SK_ScalarHalf, count);
537 
538     while ((count = iter.next()) != 0) {
539         const SkFixed* SK_RESTRICT srcXY = iter.getXY();
540         do {
541             *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY,
542                                        oneY PREAMBLE_ARG_Y);
543             *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX,
544                                        oneX PREAMBLE_ARG_X);
545             srcXY += 2;
546         } while (--count != 0);
547     }
548 }
549 
550 static SkBitmapProcState::MatrixProc MAKENAME(_Procs)[] = {
551     SCALE_NOFILTER_NAME,
552     SCALE_FILTER_NAME,
553     AFFINE_NOFILTER_NAME,
554     AFFINE_FILTER_NAME,
555     PERSP_NOFILTER_NAME,
556     PERSP_FILTER_NAME
557 };
558 
559 #undef MAKENAME
560 #undef TILEX_PROCF
561 #undef TILEY_PROCF
562 #ifdef CHECK_FOR_DECAL
563     #undef CHECK_FOR_DECAL
564 #endif
565 
566 #undef SCALE_NOFILTER_NAME
567 #undef SCALE_FILTER_NAME
568 #undef AFFINE_NOFILTER_NAME
569 #undef AFFINE_FILTER_NAME
570 #undef PERSP_NOFILTER_NAME
571 #undef PERSP_FILTER_NAME
572 
573 #undef PREAMBLE
574 #undef PREAMBLE_PARAM_X
575 #undef PREAMBLE_PARAM_Y
576 #undef PREAMBLE_ARG_X
577 #undef PREAMBLE_ARG_Y
578 
579 #undef TILEX_LOW_BITS
580 #undef TILEY_LOW_BITS
581