OLD | NEW |
| (Empty) |
1 | |
2 #if DSTSIZE==32 | |
3 #define DSTTYPE SkPMColor | |
4 #elif DSTSIZE==16 | |
5 #define DSTTYPE uint16_t | |
6 #else | |
7 #error "need DSTSIZE to be 32 or 16" | |
8 #endif | |
9 | |
10 static void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s, | |
11 const uint32_t* SK_RESTRICT xy, | |
12 int count, DSTTYPE* SK_RESTRICT colors) { | |
13 SkASSERT(count > 0 && colors != NULL); | |
14 SkASSERT(s.fDoFilter == false); | |
15 SkDEBUGCODE(CHECKSTATE(s);) | |
16 | |
17 #ifdef PREAMBLE | |
18 PREAMBLE(s); | |
19 #endif | |
20 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); | |
21 int i, rb = s.fBitmap->rowBytes(); | |
22 | |
23 uint32_t XY; | |
24 SRCTYPE src; | |
25 | |
26 for (i = (count >> 1); i > 0; --i) { | |
27 XY = *xy++; | |
28 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && | |
29 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); | |
30 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; | |
31 *colors++ = RETURNDST(src); | |
32 | |
33 XY = *xy++; | |
34 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && | |
35 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); | |
36 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; | |
37 *colors++ = RETURNDST(src); | |
38 } | |
39 if (count & 1) { | |
40 XY = *xy++; | |
41 SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() && | |
42 (XY & 0xFFFF) < (unsigned)s.fBitmap->width()); | |
43 src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF]; | |
44 *colors++ = RETURNDST(src); | |
45 } | |
46 | |
47 #ifdef POSTAMBLE | |
48 POSTAMBLE(s); | |
49 #endif | |
50 } | |
51 | |
52 static void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, | |
53 const uint32_t* SK_RESTRICT xy, | |
54 int count, DSTTYPE* SK_RESTRICT colors) { | |
55 SkASSERT(count > 0 && colors != NULL); | |
56 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); | |
57 SkASSERT(s.fDoFilter == false); | |
58 SkDEBUGCODE(CHECKSTATE(s);) | |
59 | |
60 #ifdef PREAMBLE | |
61 PREAMBLE(s); | |
62 #endif | |
63 const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fBitmap->getPixels(); | |
64 int i; | |
65 | |
66 // bump srcAddr to the proper row, since we're told Y never changes | |
67 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); | |
68 srcAddr = (const SRCTYPE*)((const char*)srcAddr + | |
69 xy[0] * s.fBitmap->rowBytes()); | |
70 // buffer is y32, x16, x16, x16, x16, x16 | |
71 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1); | |
72 | |
73 SRCTYPE src; | |
74 | |
75 for (i = (count >> 2); i > 0; --i) { | |
76 SkASSERT(*xx < (unsigned)s.fBitmap->width()); | |
77 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); | |
78 | |
79 SkASSERT(*xx < (unsigned)s.fBitmap->width()); | |
80 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); | |
81 | |
82 SkASSERT(*xx < (unsigned)s.fBitmap->width()); | |
83 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); | |
84 | |
85 SkASSERT(*xx < (unsigned)s.fBitmap->width()); | |
86 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); | |
87 } | |
88 for (i = (count & 3); i > 0; --i) { | |
89 SkASSERT(*xx < (unsigned)s.fBitmap->width()); | |
90 src = srcAddr[*xx++]; *colors++ = RETURNDST(src); | |
91 } | |
92 | |
93 #ifdef POSTAMBLE | |
94 POSTAMBLE(s); | |
95 #endif | |
96 } | |
97 | |
98 /////////////////////////////////////////////////////////////////////////////// | |
99 | |
100 static void MAKENAME(_filter_DX)(const SkBitmapProcState& s, | |
101 const uint32_t* SK_RESTRICT xy, | |
102 int count, DSTTYPE* SK_RESTRICT colors) { | |
103 SkASSERT(count > 0 && colors != NULL); | |
104 SkASSERT(s.fDoFilter); | |
105 SkDEBUGCODE(CHECKSTATE(s);) | |
106 | |
107 #ifdef PREAMBLE | |
108 PREAMBLE(s); | |
109 #endif | |
110 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); | |
111 unsigned rb = s.fBitmap->rowBytes(); | |
112 unsigned subY; | |
113 const SRCTYPE* SK_RESTRICT row0; | |
114 const SRCTYPE* SK_RESTRICT row1; | |
115 | |
116 // setup row ptrs and update proc_table | |
117 { | |
118 uint32_t XY = *xy++; | |
119 unsigned y0 = XY >> 14; | |
120 row0 = (const SRCTYPE*)(srcAddr + (y0 >> 4) * rb); | |
121 row1 = (const SRCTYPE*)(srcAddr + (XY & 0x3FFF) * rb); | |
122 subY = y0 & 0xF; | |
123 } | |
124 | |
125 do { | |
126 uint32_t XX = *xy++; // x0:14 | 4 | x1:14 | |
127 unsigned x0 = XX >> 14; | |
128 unsigned x1 = XX & 0x3FFF; | |
129 unsigned subX = x0 & 0xF; | |
130 x0 >>= 4; | |
131 | |
132 uint32_t c = FILTER_PROC(subX, subY, | |
133 SRC_TO_FILTER(row0[x0]), | |
134 SRC_TO_FILTER(row0[x1]), | |
135 SRC_TO_FILTER(row1[x0]), | |
136 SRC_TO_FILTER(row1[x1])); | |
137 *colors++ = FILTER_TO_DST(c); | |
138 | |
139 } while (--count != 0); | |
140 | |
141 #ifdef POSTAMBLE | |
142 POSTAMBLE(s); | |
143 #endif | |
144 } | |
145 static void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, | |
146 const uint32_t* SK_RESTRICT xy, | |
147 int count, DSTTYPE* SK_RESTRICT colors) { | |
148 SkASSERT(count > 0 && colors != NULL); | |
149 SkASSERT(s.fDoFilter); | |
150 SkDEBUGCODE(CHECKSTATE(s);) | |
151 | |
152 #ifdef PREAMBLE | |
153 PREAMBLE(s); | |
154 #endif | |
155 const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels(); | |
156 int rb = s.fBitmap->rowBytes(); | |
157 | |
158 do { | |
159 uint32_t data = *xy++; | |
160 unsigned y0 = data >> 14; | |
161 unsigned y1 = data & 0x3FFF; | |
162 unsigned subY = y0 & 0xF; | |
163 y0 >>= 4; | |
164 | |
165 data = *xy++; | |
166 unsigned x0 = data >> 14; | |
167 unsigned x1 = data & 0x3FFF; | |
168 unsigned subX = x0 & 0xF; | |
169 x0 >>= 4; | |
170 | |
171 const SRCTYPE* SK_RESTRICT row0 = (const SRCTYPE*)(srcAddr + y0 * rb); | |
172 const SRCTYPE* SK_RESTRICT row1 = (const SRCTYPE*)(srcAddr + y1 * rb); | |
173 | |
174 uint32_t c = FILTER_PROC(subX, subY, | |
175 SRC_TO_FILTER(row0[x0]), | |
176 SRC_TO_FILTER(row0[x1]), | |
177 SRC_TO_FILTER(row1[x0]), | |
178 SRC_TO_FILTER(row1[x1])); | |
179 *colors++ = FILTER_TO_DST(c); | |
180 } while (--count != 0); | |
181 | |
182 #ifdef POSTAMBLE | |
183 POSTAMBLE(s); | |
184 #endif | |
185 } | |
186 | |
187 #undef MAKENAME | |
188 #undef DSTSIZE | |
189 #undef DSTTYPE | |
190 #undef SRCTYPE | |
191 #undef CHECKSTATE | |
192 #undef RETURNDST | |
193 #undef SRC_TO_FILTER | |
194 #undef FILTER_TO_DST | |
195 | |
196 #ifdef PREAMBLE | |
197 #undef PREAMBLE | |
198 #endif | |
199 #ifdef POSTAMBLE | |
200 #undef POSTAMBLE | |
201 #endif | |
202 | |
203 #undef FILTER_PROC_TYPE | |
204 #undef GET_FILTER_TABLE | |
205 #undef GET_FILTER_ROW | |
206 #undef GET_FILTER_ROW_PROC | |
207 #undef GET_FILTER_PROC | |
OLD | NEW |