Rev 1891 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1891 | Rev 3931 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include |
32 | #include |
33 | #include |
33 | #include |
34 | #include |
34 | #include |
35 | #include "pixman-private.h" |
35 | #include "pixman-private.h" |
36 | #include "pixman-combine32.h" |
36 | #include "pixman-combine32.h" |
- | 37 | #include "pixman-inlines.h" |
|
Line 37... | Line 38... | ||
37 | 38 | ||
38 | /* Store functions */ |
- | |
39 | void |
39 | static uint32_t * |
40 | _pixman_image_store_scanline_32 (bits_image_t * image, |
- | |
41 | int x, |
- | |
42 | int y, |
- | |
43 | int width, |
40 | _pixman_image_get_scanline_generic_float (pixman_iter_t * iter, |
44 | const uint32_t *buffer) |
41 | const uint32_t *mask) |
45 | { |
42 | { |
- | 43 | pixman_iter_get_scanline_t fetch_32 = iter->data; |
|
Line 46... | Line 44... | ||
46 | image->store_scanline_32 (image, x, y, width, buffer); |
44 | uint32_t *buffer = iter->buffer; |
47 | - | ||
48 | if (image->common.alpha_map) |
- | |
49 | { |
- | |
Line 50... | Line -... | ||
50 | x -= image->common.alpha_origin_x; |
- | |
51 | y -= image->common.alpha_origin_y; |
45 | |
52 | - | ||
53 | image->common.alpha_map->store_scanline_32 ( |
- | |
Line 54... | Line -... | ||
54 | image->common.alpha_map, x, y, width, buffer); |
- | |
55 | } |
- | |
56 | } |
- | |
57 | - | ||
58 | void |
- | |
59 | _pixman_image_store_scanline_64 (bits_image_t * image, |
- | |
60 | int x, |
- | |
61 | int y, |
- | |
62 | int width, |
- | |
63 | const uint32_t *buffer) |
46 | fetch_32 (iter, NULL); |
64 | { |
- | |
65 | image->store_scanline_64 (image, x, y, width, buffer); |
- | |
66 | - | ||
67 | if (image->common.alpha_map) |
- | |
68 | { |
- | |
69 | x -= image->common.alpha_origin_x; |
- | |
70 | y -= image->common.alpha_origin_y; |
- | |
71 | 47 | ||
Line 72... | Line 48... | ||
72 | image->common.alpha_map->store_scanline_64 ( |
48 | pixman_expand_to_float ((argb_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width); |
Line 73... | Line 49... | ||
73 | image->common.alpha_map, x, y, width, buffer); |
49 | |
Line 90... | Line 66... | ||
90 | } |
66 | } |
Line 91... | Line 67... | ||
91 | 67 | ||
92 | typedef uint32_t (* get_pixel_t) (bits_image_t *image, |
68 | typedef uint32_t (* get_pixel_t) (bits_image_t *image, |
Line 93... | Line -... | ||
93 | int x, int y, pixman_bool_t check_bounds); |
- | |
94 | - | ||
95 | static force_inline void |
- | |
96 | repeat (pixman_repeat_t repeat, int size, int *coord) |
- | |
97 | { |
- | |
98 | switch (repeat) |
- | |
99 | { |
- | |
100 | case PIXMAN_REPEAT_NORMAL: |
- | |
101 | *coord = MOD (*coord, size); |
- | |
102 | break; |
- | |
103 | - | ||
104 | case PIXMAN_REPEAT_PAD: |
- | |
105 | *coord = CLIP (*coord, 0, size - 1); |
- | |
106 | break; |
- | |
107 | - | ||
108 | case PIXMAN_REPEAT_REFLECT: |
- | |
109 | *coord = MOD (*coord, size * 2); |
- | |
110 | - | ||
111 | if (*coord >= size) |
- | |
112 | *coord = size * 2 - *coord - 1; |
- | |
113 | break; |
- | |
114 | - | ||
115 | case PIXMAN_REPEAT_NONE: |
- | |
116 | break; |
- | |
117 | - | ||
118 | default: |
- | |
119 | break; |
- | |
120 | } |
- | |
121 | } |
69 | int x, int y, pixman_bool_t check_bounds); |
122 | 70 | ||
123 | static force_inline uint32_t |
71 | static force_inline uint32_t |
124 | bits_image_fetch_pixel_nearest (bits_image_t *image, |
72 | bits_image_fetch_pixel_nearest (bits_image_t *image, |
125 | pixman_fixed_t x, |
73 | pixman_fixed_t x, |
Line 129... | Line 77... | ||
129 | int x0 = pixman_fixed_to_int (x - pixman_fixed_e); |
77 | int x0 = pixman_fixed_to_int (x - pixman_fixed_e); |
130 | int y0 = pixman_fixed_to_int (y - pixman_fixed_e); |
78 | int y0 = pixman_fixed_to_int (y - pixman_fixed_e); |
Line 131... | Line 79... | ||
131 | 79 | ||
132 | if (image->common.repeat != PIXMAN_REPEAT_NONE) |
80 | if (image->common.repeat != PIXMAN_REPEAT_NONE) |
133 | { |
81 | { |
134 | repeat (image->common.repeat, image->width, &x0); |
82 | repeat (image->common.repeat, &x0, image->width); |
Line 135... | Line 83... | ||
135 | repeat (image->common.repeat, image->height, &y0); |
83 | repeat (image->common.repeat, &y0, image->height); |
136 | 84 | ||
137 | return get_pixel (image, x0, y0, FALSE); |
85 | return get_pixel (image, x0, y0, FALSE); |
138 | } |
86 | } |
139 | else |
87 | else |
140 | { |
88 | { |
141 | return get_pixel (image, x0, y0, TRUE); |
89 | return get_pixel (image, x0, y0, TRUE); |
Line 142... | Line -... | ||
142 | } |
- | |
143 | } |
- | |
144 | - | ||
145 | #if SIZEOF_LONG > 4 |
- | |
146 | - | ||
147 | static force_inline uint32_t |
- | |
148 | bilinear_interpolation (uint32_t tl, uint32_t tr, |
- | |
149 | uint32_t bl, uint32_t br, |
- | |
150 | int distx, int disty) |
- | |
151 | { |
- | |
152 | uint64_t distxy, distxiy, distixy, distixiy; |
- | |
153 | uint64_t tl64, tr64, bl64, br64; |
- | |
154 | uint64_t f, r; |
- | |
155 | - | ||
156 | distxy = distx * disty; |
- | |
157 | distxiy = distx * (256 - disty); |
- | |
158 | distixy = (256 - distx) * disty; |
- | |
159 | distixiy = (256 - distx) * (256 - disty); |
- | |
160 | - | ||
161 | /* Alpha and Blue */ |
- | |
162 | tl64 = tl & 0xff0000ff; |
- | |
163 | tr64 = tr & 0xff0000ff; |
- | |
164 | bl64 = bl & 0xff0000ff; |
- | |
165 | br64 = br & 0xff0000ff; |
- | |
166 | - | ||
167 | f = tl64 * distixiy + tr64 * distxiy + bl64 * distixy + br64 * distxy; |
- | |
168 | r = f & 0x0000ff0000ff0000ull; |
- | |
169 | - | ||
170 | /* Red and Green */ |
- | |
171 | tl64 = tl; |
- | |
172 | tl64 = ((tl64 << 16) & 0x000000ff00000000ull) | (tl64 & 0x0000ff00ull); |
- | |
173 | - | ||
174 | tr64 = tr; |
- | |
175 | tr64 = ((tr64 << 16) & 0x000000ff00000000ull) | (tr64 & 0x0000ff00ull); |
- | |
176 | - | ||
177 | bl64 = bl; |
- | |
178 | bl64 = ((bl64 << 16) & 0x000000ff00000000ull) | (bl64 & 0x0000ff00ull); |
- | |
179 | - | ||
180 | br64 = br; |
- | |
181 | br64 = ((br64 << 16) & 0x000000ff00000000ull) | (br64 & 0x0000ff00ull); |
- | |
182 | - | ||
183 | f = tl64 * distixiy + tr64 * distxiy + bl64 * distixy + br64 * distxy; |
- | |
184 | r |= ((f >> 16) & 0x000000ff00000000ull) | (f & 0xff000000ull); |
- | |
185 | - | ||
186 | return (uint32_t)(r >> 16); |
- | |
187 | } |
- | |
188 | - | ||
189 | #else |
- | |
190 | - | ||
191 | static force_inline uint32_t |
- | |
192 | bilinear_interpolation (uint32_t tl, uint32_t tr, |
- | |
193 | uint32_t bl, uint32_t br, |
- | |
194 | int distx, int disty) |
- | |
195 | { |
- | |
196 | int distxy, distxiy, distixy, distixiy; |
- | |
197 | uint32_t f, r; |
- | |
198 | - | ||
199 | distxy = distx * disty; |
- | |
200 | distxiy = (distx << 8) - distxy; /* distx * (256 - disty) */ |
- | |
201 | distixy = (disty << 8) - distxy; /* disty * (256 - distx) */ |
- | |
202 | distixiy = |
- | |
203 | 256 * 256 - (disty << 8) - |
- | |
204 | (distx << 8) + distxy; /* (256 - distx) * (256 - disty) */ |
- | |
205 | - | ||
206 | /* Blue */ |
- | |
207 | r = (tl & 0x000000ff) * distixiy + (tr & 0x000000ff) * distxiy |
- | |
208 | + (bl & 0x000000ff) * distixy + (br & 0x000000ff) * distxy; |
- | |
209 | - | ||
210 | /* Green */ |
- | |
211 | f = (tl & 0x0000ff00) * distixiy + (tr & 0x0000ff00) * distxiy |
- | |
212 | + (bl & 0x0000ff00) * distixy + (br & 0x0000ff00) * distxy; |
- | |
213 | r |= f & 0xff000000; |
- | |
214 | - | ||
215 | tl >>= 16; |
- | |
216 | tr >>= 16; |
- | |
217 | bl >>= 16; |
- | |
218 | br >>= 16; |
- | |
219 | r >>= 16; |
- | |
220 | - | ||
221 | /* Red */ |
- | |
222 | f = (tl & 0x000000ff) * distixiy + (tr & 0x000000ff) * distxiy |
- | |
223 | + (bl & 0x000000ff) * distixy + (br & 0x000000ff) * distxy; |
- | |
224 | r |= f & 0x00ff0000; |
- | |
225 | - | ||
226 | /* Alpha */ |
- | |
227 | f = (tl & 0x0000ff00) * distixiy + (tr & 0x0000ff00) * distxiy |
- | |
228 | + (bl & 0x0000ff00) * distixy + (br & 0x0000ff00) * distxy; |
- | |
229 | r |= f & 0xff000000; |
- | |
230 | - | ||
231 | return r; |
- | |
232 | } |
- | |
233 | 90 | } |
|
234 | #endif |
91 | } |
235 | 92 | ||
236 | static force_inline uint32_t |
93 | static force_inline uint32_t |
237 | bits_image_fetch_pixel_bilinear (bits_image_t *image, |
94 | bits_image_fetch_pixel_bilinear (bits_image_t *image, |
Line 247... | Line 104... | ||
247 | int32_t distx, disty; |
104 | int32_t distx, disty; |
Line 248... | Line 105... | ||
248 | 105 | ||
249 | x1 = x - pixman_fixed_1 / 2; |
106 | x1 = x - pixman_fixed_1 / 2; |
Line 250... | Line 107... | ||
250 | y1 = y - pixman_fixed_1 / 2; |
107 | y1 = y - pixman_fixed_1 / 2; |
251 | 108 | ||
Line 252... | Line 109... | ||
252 | distx = (x1 >> 8) & 0xff; |
109 | distx = pixman_fixed_to_bilinear_weight (x1); |
253 | disty = (y1 >> 8) & 0xff; |
110 | disty = pixman_fixed_to_bilinear_weight (y1); |
254 | 111 | ||
255 | x1 = pixman_fixed_to_int (x1); |
112 | x1 = pixman_fixed_to_int (x1); |
Line 256... | Line 113... | ||
256 | y1 = pixman_fixed_to_int (y1); |
113 | y1 = pixman_fixed_to_int (y1); |
257 | x2 = x1 + 1; |
114 | x2 = x1 + 1; |
258 | y2 = y1 + 1; |
115 | y2 = y1 + 1; |
259 | 116 | ||
260 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
117 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
261 | { |
118 | { |
Line 262... | Line 119... | ||
262 | repeat (repeat_mode, width, &x1); |
119 | repeat (repeat_mode, &x1, width); |
263 | repeat (repeat_mode, height, &y1); |
120 | repeat (repeat_mode, &y1, height); |
264 | repeat (repeat_mode, width, &x2); |
121 | repeat (repeat_mode, &x2, width); |
265 | repeat (repeat_mode, height, &y2); |
122 | repeat (repeat_mode, &y2, height); |
Line 278... | Line 135... | ||
278 | } |
135 | } |
Line 279... | Line 136... | ||
279 | 136 | ||
280 | return bilinear_interpolation (tl, tr, bl, br, distx, disty); |
137 | return bilinear_interpolation (tl, tr, bl, br, distx, disty); |
Line 281... | Line 138... | ||
281 | } |
138 | } |
282 | 139 | ||
283 | static void |
- | |
284 | bits_image_fetch_bilinear_no_repeat_8888 (pixman_image_t * ima, |
- | |
285 | int offset, |
- | |
286 | int line, |
- | |
287 | int width, |
140 | static uint32_t * |
288 | uint32_t * buffer, |
141 | bits_image_fetch_bilinear_no_repeat_8888 (pixman_iter_t *iter, |
- | 142 | const uint32_t *mask) |
|
- | 143 | { |
|
- | 144 | ||
- | 145 | pixman_image_t * ima = iter->image; |
|
- | 146 | int offset = iter->x; |
|
- | 147 | int line = iter->y++; |
|
- | 148 | int width = iter->width; |
|
289 | const uint32_t * mask) |
149 | uint32_t * buffer = iter->buffer; |
290 | { |
150 | |
291 | bits_image_t *bits = &ima->bits; |
151 | bits_image_t *bits = &ima->bits; |
292 | pixman_fixed_t x_top, x_bottom, x; |
152 | pixman_fixed_t x_top, x_bottom, x; |
293 | pixman_fixed_t ux_top, ux_bottom, ux; |
153 | pixman_fixed_t ux_top, ux_bottom, ux; |
Line 307... | Line 167... | ||
307 | v.vector[0] = pixman_int_to_fixed (offset) + pixman_fixed_1 / 2; |
167 | v.vector[0] = pixman_int_to_fixed (offset) + pixman_fixed_1 / 2; |
308 | v.vector[1] = pixman_int_to_fixed (line) + pixman_fixed_1 / 2; |
168 | v.vector[1] = pixman_int_to_fixed (line) + pixman_fixed_1 / 2; |
309 | v.vector[2] = pixman_fixed_1; |
169 | v.vector[2] = pixman_fixed_1; |
Line 310... | Line 170... | ||
310 | 170 | ||
311 | if (!pixman_transform_point_3d (bits->common.transform, &v)) |
171 | if (!pixman_transform_point_3d (bits->common.transform, &v)) |
Line 312... | Line 172... | ||
312 | return; |
172 | return iter->buffer; |
313 | 173 | ||
Line 314... | Line 174... | ||
314 | ux = ux_top = ux_bottom = bits->common.transform->matrix[0][0]; |
174 | ux = ux_top = ux_bottom = bits->common.transform->matrix[0][0]; |
315 | x = x_top = x_bottom = v.vector[0] - pixman_fixed_1/2; |
175 | x = x_top = x_bottom = v.vector[0] - pixman_fixed_1/2; |
Line 316... | Line 176... | ||
316 | 176 | ||
317 | y = v.vector[1] - pixman_fixed_1/2; |
177 | y = v.vector[1] - pixman_fixed_1/2; |
318 | disty = (y >> 8) & 0xff; |
178 | disty = pixman_fixed_to_bilinear_weight (y); |
319 | 179 | ||
Line 374... | Line 234... | ||
374 | 234 | ||
375 | /* If both are zero, then the whole thing is zero */ |
235 | /* If both are zero, then the whole thing is zero */ |
376 | if (top_row == zero && bottom_row == zero) |
236 | if (top_row == zero && bottom_row == zero) |
377 | { |
237 | { |
378 | memset (buffer, 0, width * sizeof (uint32_t)); |
238 | memset (buffer, 0, width * sizeof (uint32_t)); |
379 | return; |
239 | return iter->buffer; |
380 | } |
240 | } |
381 | else if (bits->format == PIXMAN_x8r8g8b8) |
241 | else if (bits->format == PIXMAN_x8r8g8b8) |
382 | { |
242 | { |
383 | if (top_row == zero) |
243 | if (top_row == zero) |
Line 422... | Line 282... | ||
422 | int32_t distx; |
282 | int32_t distx; |
Line 423... | Line 283... | ||
423 | 283 | ||
424 | tr = top_row[pixman_fixed_to_int (x_top) + 1] | top_mask; |
284 | tr = top_row[pixman_fixed_to_int (x_top) + 1] | top_mask; |
Line 425... | Line 285... | ||
425 | br = bottom_row[pixman_fixed_to_int (x_bottom) + 1] | bottom_mask; |
285 | br = bottom_row[pixman_fixed_to_int (x_bottom) + 1] | bottom_mask; |
Line 426... | Line 286... | ||
426 | 286 | ||
Line 427... | Line 287... | ||
427 | distx = (x >> 8) & 0xff; |
287 | distx = pixman_fixed_to_bilinear_weight (x); |
428 | 288 | ||
Line 447... | Line 307... | ||
447 | tl = top_row [pixman_fixed_to_int (x_top)] | top_mask; |
307 | tl = top_row [pixman_fixed_to_int (x_top)] | top_mask; |
448 | tr = top_row [pixman_fixed_to_int (x_top) + 1] | top_mask; |
308 | tr = top_row [pixman_fixed_to_int (x_top) + 1] | top_mask; |
449 | bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask; |
309 | bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask; |
450 | br = bottom_row [pixman_fixed_to_int (x_bottom) + 1] | bottom_mask; |
310 | br = bottom_row [pixman_fixed_to_int (x_bottom) + 1] | bottom_mask; |
Line 451... | Line 311... | ||
451 | 311 | ||
Line 452... | Line 312... | ||
452 | distx = (x >> 8) & 0xff; |
312 | distx = pixman_fixed_to_bilinear_weight (x); |
453 | 313 | ||
Line 454... | Line 314... | ||
454 | *buffer = bilinear_interpolation (tl, tr, bl, br, distx, disty); |
314 | *buffer = bilinear_interpolation (tl, tr, bl, br, distx, disty); |
Line 471... | Line 331... | ||
471 | int32_t distx; |
331 | int32_t distx; |
Line 472... | Line 332... | ||
472 | 332 | ||
473 | tl = top_row [pixman_fixed_to_int (x_top)] | top_mask; |
333 | tl = top_row [pixman_fixed_to_int (x_top)] | top_mask; |
Line 474... | Line 334... | ||
474 | bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask; |
334 | bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask; |
Line 475... | Line 335... | ||
475 | 335 | ||
476 | distx = (x >> 8) & 0xff; |
336 | distx = pixman_fixed_to_bilinear_weight (x); |
Line 477... | Line 337... | ||
477 | 337 | ||
Line 486... | Line 346... | ||
486 | } |
346 | } |
Line 487... | Line 347... | ||
487 | 347 | ||
488 | /* Zero fill to the left of the image */ |
348 | /* Zero fill to the left of the image */ |
489 | while (buffer < end) |
349 | while (buffer < end) |
- | 350 | *buffer++ = 0; |
|
- | 351 | ||
490 | *buffer++ = 0; |
352 | return iter->buffer; |
Line 491... | Line 353... | ||
491 | } |
353 | } |
492 | 354 | ||
493 | static force_inline uint32_t |
355 | static force_inline uint32_t |
Line 499... | Line 361... | ||
499 | pixman_fixed_t *params = image->common.filter_params; |
361 | pixman_fixed_t *params = image->common.filter_params; |
500 | int x_off = (params[0] - pixman_fixed_1) >> 1; |
362 | int x_off = (params[0] - pixman_fixed_1) >> 1; |
501 | int y_off = (params[1] - pixman_fixed_1) >> 1; |
363 | int y_off = (params[1] - pixman_fixed_1) >> 1; |
502 | int32_t cwidth = pixman_fixed_to_int (params[0]); |
364 | int32_t cwidth = pixman_fixed_to_int (params[0]); |
503 | int32_t cheight = pixman_fixed_to_int (params[1]); |
365 | int32_t cheight = pixman_fixed_to_int (params[1]); |
504 | int32_t srtot, sgtot, sbtot, satot; |
- | |
505 | int32_t i, j, x1, x2, y1, y2; |
366 | int32_t i, j, x1, x2, y1, y2; |
506 | pixman_repeat_t repeat_mode = image->common.repeat; |
367 | pixman_repeat_t repeat_mode = image->common.repeat; |
507 | int width = image->width; |
368 | int width = image->width; |
508 | int height = image->height; |
369 | int height = image->height; |
- | 370 | int srtot, sgtot, sbtot, satot; |
|
Line 509... | Line 371... | ||
509 | 371 | ||
Line 510... | Line 372... | ||
510 | params += 2; |
372 | params += 2; |
511 | 373 | ||
Line 529... | Line 391... | ||
529 | { |
391 | { |
530 | uint32_t pixel; |
392 | uint32_t pixel; |
Line 531... | Line 393... | ||
531 | 393 | ||
532 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
394 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
533 | { |
395 | { |
534 | repeat (repeat_mode, width, &rx); |
396 | repeat (repeat_mode, &rx, width); |
Line 535... | Line 397... | ||
535 | repeat (repeat_mode, height, &ry); |
397 | repeat (repeat_mode, &ry, height); |
536 | 398 | ||
537 | pixel = get_pixel (image, rx, ry, FALSE); |
399 | pixel = get_pixel (image, rx, ry, FALSE); |
538 | } |
400 | } |
539 | else |
401 | else |
540 | { |
402 | { |
Line 541... | Line 403... | ||
541 | pixel = get_pixel (image, rx, ry, TRUE); |
403 | pixel = get_pixel (image, rx, ry, TRUE); |
542 | } |
404 | } |
543 | 405 | ||
544 | srtot += RED_8 (pixel) * f; |
406 | srtot += (int)RED_8 (pixel) * f; |
545 | sgtot += GREEN_8 (pixel) * f; |
407 | sgtot += (int)GREEN_8 (pixel) * f; |
Line 546... | Line 408... | ||
546 | sbtot += BLUE_8 (pixel) * f; |
408 | sbtot += (int)BLUE_8 (pixel) * f; |
547 | satot += ALPHA_8 (pixel) * f; |
409 | satot += (int)ALPHA_8 (pixel) * f; |
548 | } |
410 | } |
Line -... | Line 411... | ||
- | 411 | ||
- | 412 | params++; |
|
- | 413 | } |
|
- | 414 | } |
|
- | 415 | ||
- | 416 | satot = (satot + 0x8000) >> 16; |
|
- | 417 | srtot = (srtot + 0x8000) >> 16; |
|
- | 418 | sgtot = (sgtot + 0x8000) >> 16; |
|
- | 419 | sbtot = (sbtot + 0x8000) >> 16; |
|
- | 420 | ||
- | 421 | satot = CLIP (satot, 0, 0xff); |
|
- | 422 | srtot = CLIP (srtot, 0, 0xff); |
|
- | 423 | sgtot = CLIP (sgtot, 0, 0xff); |
|
- | 424 | sbtot = CLIP (sbtot, 0, 0xff); |
|
- | 425 | ||
- | 426 | return ((satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot)); |
|
- | 427 | } |
|
- | 428 | ||
- | 429 | static uint32_t |
|
- | 430 | bits_image_fetch_pixel_separable_convolution (bits_image_t *image, |
|
- | 431 | pixman_fixed_t x, |
|
- | 432 | pixman_fixed_t y, |
|
- | 433 | get_pixel_t get_pixel) |
|
- | 434 | { |
|
- | 435 | pixman_fixed_t *params = image->common.filter_params; |
|
- | 436 | pixman_repeat_t repeat_mode = image->common.repeat; |
|
- | 437 | int width = image->width; |
|
- | 438 | int height = image->height; |
|
- | 439 | int cwidth = pixman_fixed_to_int (params[0]); |
|
- | 440 | int cheight = pixman_fixed_to_int (params[1]); |
|
- | 441 | int x_phase_bits = pixman_fixed_to_int (params[2]); |
|
- | 442 | int y_phase_bits = pixman_fixed_to_int (params[3]); |
|
- | 443 | int x_phase_shift = 16 - x_phase_bits; |
|
- | 444 | int y_phase_shift = 16 - y_phase_bits; |
|
549 | 445 | int x_off = ((cwidth << 16) - pixman_fixed_1) >> 1; |
|
550 | params++; |
446 | int y_off = ((cheight << 16) - pixman_fixed_1) >> 1; |
- | 447 | pixman_fixed_t *y_params; |
|
- | 448 | int srtot, sgtot, sbtot, satot; |
|
- | 449 | int32_t x1, x2, y1, y2; |
|
- | 450 | int32_t px, py; |
|
- | 451 | int i, j; |
|
- | 452 | ||
- | 453 | /* Round x and y to the middle of the closest phase before continuing. This |
|
- | 454 | * ensures that the convolution matrix is aligned right, since it was |
|
- | 455 | * positioned relative to a particular phase (and not relative to whatever |
|
- | 456 | * exact fraction we happen to get here). |
|
- | 457 | */ |
|
- | 458 | x = ((x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1); |
|
- | 459 | y = ((y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1); |
|
- | 460 | ||
- | 461 | px = (x & 0xffff) >> x_phase_shift; |
|
- | 462 | py = (y & 0xffff) >> y_phase_shift; |
|
- | 463 | ||
- | 464 | y_params = params + 4 + (1 << x_phase_bits) * cwidth + py * cheight; |
|
- | 465 | ||
- | 466 | x1 = pixman_fixed_to_int (x - pixman_fixed_e - x_off); |
|
- | 467 | y1 = pixman_fixed_to_int (y - pixman_fixed_e - y_off); |
|
- | 468 | x2 = x1 + cwidth; |
|
- | 469 | y2 = y1 + cheight; |
|
- | 470 | ||
- | 471 | srtot = sgtot = sbtot = satot = 0; |
|
- | 472 | ||
- | 473 | for (i = y1; i < y2; ++i) |
|
- | 474 | { |
|
- | 475 | pixman_fixed_48_16_t fy = *y_params++; |
|
- | 476 | pixman_fixed_t *x_params = params + 4 + px * cwidth; |
|
- | 477 | ||
- | 478 | if (fy) |
|
- | 479 | { |
|
- | 480 | for (j = x1; j < x2; ++j) |
|
- | 481 | { |
|
551 | } |
482 | pixman_fixed_t fx = *x_params++; |
- | 483 | int rx = j; |
|
- | 484 | int ry = i; |
|
- | 485 | ||
- | 486 | if (fx) |
|
- | 487 | { |
|
- | 488 | pixman_fixed_t f; |
|
- | 489 | uint32_t pixel; |
|
- | 490 | ||
- | 491 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
|
- | 492 | { |
|
- | 493 | repeat (repeat_mode, &rx, width); |
|
- | 494 | repeat (repeat_mode, &ry, height); |
|
- | 495 | ||
- | 496 | pixel = get_pixel (image, rx, ry, FALSE); |
|
- | 497 | } |
|
- | 498 | else |
|
- | 499 | { |
|
- | 500 | pixel = get_pixel (image, rx, ry, TRUE); |
|
- | 501 | } |
|
- | 502 | ||
- | 503 | f = (fy * fx + 0x8000) >> 16; |
|
552 | } |
504 | |
- | 505 | srtot += (int)RED_8 (pixel) * f; |
|
- | 506 | sgtot += (int)GREEN_8 (pixel) * f; |
|
- | 507 | sbtot += (int)BLUE_8 (pixel) * f; |
|
- | 508 | satot += (int)ALPHA_8 (pixel) * f; |
|
- | 509 | } |
|
- | 510 | } |
|
- | 511 | } |
|
- | 512 | } |
|
Line 553... | Line 513... | ||
553 | 513 | ||
554 | satot >>= 16; |
514 | satot = (satot + 0x8000) >> 16; |
555 | srtot >>= 16; |
515 | srtot = (srtot + 0x8000) >> 16; |
556 | sgtot >>= 16; |
516 | sgtot = (sgtot + 0x8000) >> 16; |
Line 585... | Line 545... | ||
585 | 545 | ||
586 | case PIXMAN_FILTER_CONVOLUTION: |
546 | case PIXMAN_FILTER_CONVOLUTION: |
587 | return bits_image_fetch_pixel_convolution (image, x, y, get_pixel); |
547 | return bits_image_fetch_pixel_convolution (image, x, y, get_pixel); |
Line -... | Line 548... | ||
- | 548 | break; |
|
- | 549 | ||
- | 550 | case PIXMAN_FILTER_SEPARABLE_CONVOLUTION: |
|
- | 551 | return bits_image_fetch_pixel_separable_convolution (image, x, y, get_pixel); |
|
588 | break; |
552 | break; |
589 | 553 | ||
590 | default: |
554 | default: |
Line 591... | Line 555... | ||
591 | break; |
555 | break; |
592 | } |
556 | } |
Line 593... | Line 557... | ||
593 | 557 | ||
594 | return 0; |
558 | return 0; |
595 | } |
- | |
596 | - | ||
597 | static void |
- | |
598 | bits_image_fetch_affine_no_alpha (pixman_image_t * image, |
- | |
599 | int offset, |
559 | } |
600 | int line, |
560 | |
- | 561 | static uint32_t * |
|
- | 562 | bits_image_fetch_affine_no_alpha (pixman_iter_t * iter, |
|
- | 563 | const uint32_t * mask) |
|
- | 564 | { |
|
- | 565 | pixman_image_t *image = iter->image; |
|
- | 566 | int offset = iter->x; |
|
601 | int width, |
567 | int line = iter->y++; |
602 | uint32_t * buffer, |
568 | int width = iter->width; |
603 | const uint32_t * mask) |
569 | uint32_t * buffer = iter->buffer; |
604 | { |
570 | |
Line 613... | Line 579... | ||
613 | v.vector[2] = pixman_fixed_1; |
579 | v.vector[2] = pixman_fixed_1; |
Line 614... | Line 580... | ||
614 | 580 | ||
615 | if (image->common.transform) |
581 | if (image->common.transform) |
616 | { |
582 | { |
617 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
583 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
Line 618... | Line 584... | ||
618 | return; |
584 | return iter->buffer; |
619 | 585 | ||
620 | ux = image->common.transform->matrix[0][0]; |
586 | ux = image->common.transform->matrix[0][0]; |
621 | uy = image->common.transform->matrix[1][0]; |
587 | uy = image->common.transform->matrix[1][0]; |
Line 638... | Line 604... | ||
638 | } |
604 | } |
Line 639... | Line 605... | ||
639 | 605 | ||
640 | x += ux; |
606 | x += ux; |
641 | y += uy; |
607 | y += uy; |
- | 608 | } |
|
- | 609 | ||
642 | } |
610 | return buffer; |
Line 643... | Line 611... | ||
643 | } |
611 | } |
644 | 612 | ||
645 | /* General fetcher */ |
613 | /* General fetcher */ |
Line 681... | Line 649... | ||
681 | } |
649 | } |
Line 682... | Line 650... | ||
682 | 650 | ||
683 | return pixel; |
651 | return pixel; |
Line 684... | Line 652... | ||
684 | } |
652 | } |
685 | 653 | ||
686 | static void |
- | |
687 | bits_image_fetch_general (pixman_image_t * image, |
- | |
688 | int offset, |
- | |
689 | int line, |
- | |
690 | int width, |
654 | static uint32_t * |
691 | uint32_t * buffer, |
655 | bits_image_fetch_general (pixman_iter_t *iter, |
- | 656 | const uint32_t *mask) |
|
- | 657 | { |
|
- | 658 | pixman_image_t *image = iter->image; |
|
- | 659 | int offset = iter->x; |
|
- | 660 | int line = iter->y++; |
|
- | 661 | int width = iter->width; |
|
692 | const uint32_t * mask) |
662 | uint32_t * buffer = iter->buffer; |
693 | { |
663 | |
694 | pixman_fixed_t x, y, w; |
664 | pixman_fixed_t x, y, w; |
695 | pixman_fixed_t ux, uy, uw; |
665 | pixman_fixed_t ux, uy, uw; |
Line 702... | Line 672... | ||
702 | v.vector[2] = pixman_fixed_1; |
672 | v.vector[2] = pixman_fixed_1; |
Line 703... | Line 673... | ||
703 | 673 | ||
704 | if (image->common.transform) |
674 | if (image->common.transform) |
705 | { |
675 | { |
706 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
676 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
Line 707... | Line 677... | ||
707 | return; |
677 | return buffer; |
708 | 678 | ||
709 | ux = image->common.transform->matrix[0][0]; |
679 | ux = image->common.transform->matrix[0][0]; |
710 | uy = image->common.transform->matrix[1][0]; |
680 | uy = image->common.transform->matrix[1][0]; |
Line 744... | Line 714... | ||
744 | 714 | ||
745 | x += ux; |
715 | x += ux; |
746 | y += uy; |
716 | y += uy; |
747 | w += uw; |
717 | w += uw; |
748 | } |
- | |
Line 749... | Line 718... | ||
749 | } |
718 | } |
- | 719 | ||
Line 750... | Line 720... | ||
750 | 720 | return buffer; |
|
Line 751... | Line 721... | ||
751 | static const uint8_t zero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
721 | } |
- | 722 | ||
- | 723 | typedef uint32_t (* convert_pixel_t) (const uint8_t *row, int x); |
|
- | 724 | ||
- | 725 | static force_inline void |
|
- | 726 | bits_image_fetch_separable_convolution_affine (pixman_image_t * image, |
|
- | 727 | int offset, |
|
- | 728 | int line, |
|
- | 729 | int width, |
|
- | 730 | uint32_t * buffer, |
|
- | 731 | const uint32_t * mask, |
|
- | 732 | ||
- | 733 | convert_pixel_t convert_pixel, |
|
- | 734 | pixman_format_code_t format, |
|
- | 735 | pixman_repeat_t repeat_mode) |
|
- | 736 | { |
|
- | 737 | bits_image_t *bits = &image->bits; |
|
- | 738 | pixman_fixed_t *params = image->common.filter_params; |
|
- | 739 | int cwidth = pixman_fixed_to_int (params[0]); |
|
- | 740 | int cheight = pixman_fixed_to_int (params[1]); |
|
- | 741 | int x_off = ((cwidth << 16) - pixman_fixed_1) >> 1; |
|
- | 742 | int y_off = ((cheight << 16) - pixman_fixed_1) >> 1; |
|
- | 743 | int x_phase_bits = pixman_fixed_to_int (params[2]); |
|
- | 744 | int y_phase_bits = pixman_fixed_to_int (params[3]); |
|
- | 745 | int x_phase_shift = 16 - x_phase_bits; |
|
- | 746 | int y_phase_shift = 16 - y_phase_bits; |
|
- | 747 | pixman_fixed_t vx, vy; |
|
- | 748 | pixman_fixed_t ux, uy; |
|
- | 749 | pixman_vector_t v; |
|
- | 750 | int k; |
|
- | 751 | ||
- | 752 | /* reference point is the center of the pixel */ |
|
- | 753 | v.vector[0] = pixman_int_to_fixed (offset) + pixman_fixed_1 / 2; |
|
- | 754 | v.vector[1] = pixman_int_to_fixed (line) + pixman_fixed_1 / 2; |
|
- | 755 | v.vector[2] = pixman_fixed_1; |
|
- | 756 | ||
- | 757 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
|
- | 758 | return; |
|
- | 759 | ||
- | 760 | ux = image->common.transform->matrix[0][0]; |
|
- | 761 | uy = image->common.transform->matrix[1][0]; |
|
- | 762 | ||
- | 763 | vx = v.vector[0]; |
|
- | 764 | vy = v.vector[1]; |
|
- | 765 | ||
- | 766 | for (k = 0; k < width; ++k) |
|
- | 767 | { |
|
- | 768 | pixman_fixed_t *y_params; |
|
- | 769 | int satot, srtot, sgtot, sbtot; |
|
- | 770 | pixman_fixed_t x, y; |
|
- | 771 | int32_t x1, x2, y1, y2; |
|
- | 772 | int32_t px, py; |
|
- | 773 | int i, j; |
|
- | 774 | ||
- | 775 | if (mask && !mask[k]) |
|
- | 776 | goto next; |
|
- | 777 | ||
- | 778 | /* Round x and y to the middle of the closest phase before continuing. This |
|
- | 779 | * ensures that the convolution matrix is aligned right, since it was |
|
- | 780 | * positioned relative to a particular phase (and not relative to whatever |
|
- | 781 | * exact fraction we happen to get here). |
|
- | 782 | */ |
|
- | 783 | x = ((vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1); |
|
- | 784 | y = ((vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1); |
|
- | 785 | ||
- | 786 | px = (x & 0xffff) >> x_phase_shift; |
|
- | 787 | py = (y & 0xffff) >> y_phase_shift; |
|
- | 788 | ||
- | 789 | x1 = pixman_fixed_to_int (x - pixman_fixed_e - x_off); |
|
- | 790 | y1 = pixman_fixed_to_int (y - pixman_fixed_e - y_off); |
|
- | 791 | x2 = x1 + cwidth; |
|
- | 792 | y2 = y1 + cheight; |
|
- | 793 | ||
- | 794 | satot = srtot = sgtot = sbtot = 0; |
|
- | 795 | ||
- | 796 | y_params = params + 4 + (1 << x_phase_bits) * cwidth + py * cheight; |
|
- | 797 | ||
- | 798 | for (i = y1; i < y2; ++i) |
|
- | 799 | { |
|
- | 800 | pixman_fixed_t fy = *y_params++; |
|
- | 801 | ||
- | 802 | if (fy) |
|
- | 803 | { |
|
- | 804 | pixman_fixed_t *x_params = params + 4 + px * cwidth; |
|
- | 805 | ||
- | 806 | for (j = x1; j < x2; ++j) |
|
- | 807 | { |
|
- | 808 | pixman_fixed_t fx = *x_params++; |
|
- | 809 | int rx = j; |
|
- | 810 | int ry = i; |
|
- | 811 | ||
- | 812 | if (fx) |
|
- | 813 | { |
|
- | 814 | pixman_fixed_t f; |
|
- | 815 | uint32_t pixel, mask; |
|
- | 816 | uint8_t *row; |
|
- | 817 | ||
- | 818 | mask = PIXMAN_FORMAT_A (format)? 0 : 0xff000000; |
|
- | 819 | ||
- | 820 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
|
- | 821 | { |
|
- | 822 | repeat (repeat_mode, &rx, bits->width); |
|
- | 823 | repeat (repeat_mode, &ry, bits->height); |
|
- | 824 | ||
- | 825 | row = (uint8_t *)bits->bits + bits->rowstride * 4 * ry; |
|
- | 826 | pixel = convert_pixel (row, rx) | mask; |
|
- | 827 | } |
|
- | 828 | else |
|
- | 829 | { |
|
- | 830 | if (rx < 0 || ry < 0 || rx >= bits->width || ry >= bits->height) |
|
- | 831 | { |
|
- | 832 | pixel = 0; |
|
- | 833 | } |
|
- | 834 | else |
|
- | 835 | { |
|
- | 836 | row = (uint8_t *)bits->bits + bits->rowstride * 4 * ry; |
|
- | 837 | pixel = convert_pixel (row, rx) | mask; |
|
- | 838 | } |
|
- | 839 | } |
|
- | 840 | ||
- | 841 | f = ((pixman_fixed_32_32_t)fx * fy + 0x8000) >> 16; |
|
- | 842 | srtot += (int)RED_8 (pixel) * f; |
|
- | 843 | sgtot += (int)GREEN_8 (pixel) * f; |
|
- | 844 | sbtot += (int)BLUE_8 (pixel) * f; |
|
- | 845 | satot += (int)ALPHA_8 (pixel) * f; |
|
- | 846 | } |
|
- | 847 | } |
|
- | 848 | } |
|
- | 849 | } |
|
- | 850 | ||
- | 851 | satot = (satot + 0x8000) >> 16; |
|
- | 852 | srtot = (srtot + 0x8000) >> 16; |
|
- | 853 | sgtot = (sgtot + 0x8000) >> 16; |
|
- | 854 | sbtot = (sbtot + 0x8000) >> 16; |
|
- | 855 | ||
- | 856 | satot = CLIP (satot, 0, 0xff); |
|
- | 857 | srtot = CLIP (srtot, 0, 0xff); |
|
- | 858 | sgtot = CLIP (sgtot, 0, 0xff); |
|
- | 859 | sbtot = CLIP (sbtot, 0, 0xff); |
|
- | 860 | ||
- | 861 | buffer[k] = (satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot << 0); |
|
- | 862 | ||
- | 863 | next: |
|
- | 864 | vx += ux; |
|
- | 865 | vy += uy; |
|
- | 866 | } |
|
- | 867 | } |
|
752 | 868 | ||
753 | typedef uint32_t (* convert_pixel_t) (const uint8_t *row, int x); |
869 | static const uint8_t zero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
754 | 870 | ||
755 | static force_inline void |
871 | static force_inline void |
756 | bits_image_fetch_bilinear_affine (pixman_image_t * image, |
872 | bits_image_fetch_bilinear_affine (pixman_image_t * image, |
Line 798... | Line 914... | ||
798 | goto next; |
914 | goto next; |
Line 799... | Line 915... | ||
799 | 915 | ||
800 | x1 = x - pixman_fixed_1 / 2; |
916 | x1 = x - pixman_fixed_1 / 2; |
Line 801... | Line 917... | ||
801 | y1 = y - pixman_fixed_1 / 2; |
917 | y1 = y - pixman_fixed_1 / 2; |
802 | 918 | ||
Line 803... | Line 919... | ||
803 | distx = (x1 >> 8) & 0xff; |
919 | distx = pixman_fixed_to_bilinear_weight (x1); |
804 | disty = (y1 >> 8) & 0xff; |
920 | disty = pixman_fixed_to_bilinear_weight (y1); |
805 | 921 | ||
806 | y1 = pixman_fixed_to_int (y1); |
922 | y1 = pixman_fixed_to_int (y1); |
Line 812... | Line 928... | ||
812 | { |
928 | { |
813 | uint32_t mask; |
929 | uint32_t mask; |
Line 814... | Line 930... | ||
814 | 930 | ||
Line 815... | Line 931... | ||
815 | mask = PIXMAN_FORMAT_A (format)? 0 : 0xff000000; |
931 | mask = PIXMAN_FORMAT_A (format)? 0 : 0xff000000; |
816 | 932 | ||
817 | repeat (repeat_mode, width, &x1); |
933 | repeat (repeat_mode, &x1, width); |
818 | repeat (repeat_mode, height, &y1); |
934 | repeat (repeat_mode, &y1, height); |
Line 819... | Line 935... | ||
819 | repeat (repeat_mode, width, &x2); |
935 | repeat (repeat_mode, &x2, width); |
820 | repeat (repeat_mode, height, &y2); |
936 | repeat (repeat_mode, &y2, height); |
Line 821... | Line 937... | ||
821 | 937 | ||
Line 904... | Line 1020... | ||
904 | x += ux; |
1020 | x += ux; |
905 | y += uy; |
1021 | y += uy; |
906 | } |
1022 | } |
907 | } |
1023 | } |
Line -... | Line 1024... | ||
- | 1024 | ||
- | 1025 | static force_inline void |
|
- | 1026 | bits_image_fetch_nearest_affine (pixman_image_t * image, |
|
- | 1027 | int offset, |
|
- | 1028 | int line, |
|
- | 1029 | int width, |
|
- | 1030 | uint32_t * buffer, |
|
- | 1031 | const uint32_t * mask, |
|
- | 1032 | ||
- | 1033 | convert_pixel_t convert_pixel, |
|
- | 1034 | pixman_format_code_t format, |
|
- | 1035 | pixman_repeat_t repeat_mode) |
|
- | 1036 | { |
|
- | 1037 | pixman_fixed_t x, y; |
|
- | 1038 | pixman_fixed_t ux, uy; |
|
- | 1039 | pixman_vector_t v; |
|
- | 1040 | bits_image_t *bits = &image->bits; |
|
- | 1041 | int i; |
|
- | 1042 | ||
- | 1043 | /* reference point is the center of the pixel */ |
|
- | 1044 | v.vector[0] = pixman_int_to_fixed (offset) + pixman_fixed_1 / 2; |
|
- | 1045 | v.vector[1] = pixman_int_to_fixed (line) + pixman_fixed_1 / 2; |
|
- | 1046 | v.vector[2] = pixman_fixed_1; |
|
- | 1047 | ||
- | 1048 | if (!pixman_transform_point_3d (image->common.transform, &v)) |
|
- | 1049 | return; |
|
- | 1050 | ||
- | 1051 | ux = image->common.transform->matrix[0][0]; |
|
- | 1052 | uy = image->common.transform->matrix[1][0]; |
|
- | 1053 | ||
- | 1054 | x = v.vector[0]; |
|
- | 1055 | y = v.vector[1]; |
|
- | 1056 | ||
- | 1057 | for (i = 0; i < width; ++i) |
|
- | 1058 | { |
|
- | 1059 | int width, height, x0, y0; |
|
- | 1060 | const uint8_t *row; |
|
- | 1061 | ||
- | 1062 | if (mask && !mask[i]) |
|
- | 1063 | goto next; |
|
- | 1064 | ||
- | 1065 | width = image->bits.width; |
|
- | 1066 | height = image->bits.height; |
|
- | 1067 | x0 = pixman_fixed_to_int (x - pixman_fixed_e); |
|
- | 1068 | y0 = pixman_fixed_to_int (y - pixman_fixed_e); |
|
- | 1069 | ||
- | 1070 | if (repeat_mode == PIXMAN_REPEAT_NONE && |
|
- | 1071 | (y0 < 0 || y0 >= height || x0 < 0 || x0 >= width)) |
|
- | 1072 | { |
|
- | 1073 | buffer[i] = 0; |
|
- | 1074 | } |
|
- | 1075 | else |
|
- | 1076 | { |
|
- | 1077 | uint32_t mask = PIXMAN_FORMAT_A (format)? 0 : 0xff000000; |
|
- | 1078 | ||
- | 1079 | if (repeat_mode != PIXMAN_REPEAT_NONE) |
|
- | 1080 | { |
|
- | 1081 | repeat (repeat_mode, &x0, width); |
|
- | 1082 | repeat (repeat_mode, &y0, height); |
|
- | 1083 | } |
|
- | 1084 | ||
- | 1085 | row = (uint8_t *)bits->bits + bits->rowstride * 4 * y0; |
|
- | 1086 | ||
- | 1087 | buffer[i] = convert_pixel (row, x0) | mask; |
|
- | 1088 | } |
|
- | 1089 | ||
- | 1090 | next: |
|
- | 1091 | x += ux; |
|
- | 1092 | y += uy; |
|
- | 1093 | } |
|
- | 1094 | } |
|
908 | 1095 | ||
909 | static force_inline uint32_t |
1096 | static force_inline uint32_t |
910 | convert_a8r8g8b8 (const uint8_t *row, int x) |
1097 | convert_a8r8g8b8 (const uint8_t *row, int x) |
911 | { |
1098 | { |
912 | return *(((uint32_t *)row) + x); |
1099 | return *(((uint32_t *)row) + x); |
Line 925... | Line 1112... | ||
925 | } |
1112 | } |
Line 926... | Line 1113... | ||
926 | 1113 | ||
927 | static force_inline uint32_t |
1114 | static force_inline uint32_t |
928 | convert_r5g6b5 (const uint8_t *row, int x) |
1115 | convert_r5g6b5 (const uint8_t *row, int x) |
929 | { |
1116 | { |
930 | return CONVERT_0565_TO_0888 (*((uint16_t *)row + x)); |
1117 | return convert_0565_to_0888 (*((uint16_t *)row + x)); |
Line -... | Line 1118... | ||
- | 1118 | } |
|
- | 1119 | ||
- | 1120 | #define MAKE_SEPARABLE_CONVOLUTION_FETCHER(name, format, repeat_mode) \ |
|
- | 1121 | static uint32_t * \ |
|
- | 1122 | bits_image_fetch_separable_convolution_affine_ ## name (pixman_iter_t *iter, \ |
|
- | 1123 | const uint32_t * mask) \ |
|
- | 1124 | { \ |
|
- | 1125 | bits_image_fetch_separable_convolution_affine ( \ |
|
- | 1126 | iter->image, \ |
|
- | 1127 | iter->x, iter->y++, \ |
|
- | 1128 | iter->width, \ |
|
- | 1129 | iter->buffer, mask, \ |
|
- | 1130 | convert_ ## format, \ |
|
- | 1131 | PIXMAN_ ## format, \ |
|
- | 1132 | repeat_mode); \ |
|
- | 1133 | \ |
|
- | 1134 | return iter->buffer; \ |
|
931 | } |
1135 | } |
932 | 1136 | ||
933 | #define MAKE_BILINEAR_FETCHER(name, format, repeat_mode) \ |
1137 | #define MAKE_BILINEAR_FETCHER(name, format, repeat_mode) \ |
934 | static void \ |
- | |
935 | bits_image_fetch_bilinear_affine_ ## name (pixman_image_t *image, \ |
- | |
936 | int offset, \ |
- | |
937 | int line, \ |
- | |
938 | int width, \ |
1138 | static uint32_t * \ |
939 | uint32_t * buffer, \ |
1139 | bits_image_fetch_bilinear_affine_ ## name (pixman_iter_t *iter, \ |
940 | const uint32_t * mask) \ |
1140 | const uint32_t * mask) \ |
- | 1141 | { \ |
|
- | 1142 | bits_image_fetch_bilinear_affine (iter->image, \ |
|
- | 1143 | iter->x, iter->y++, \ |
|
941 | { \ |
1144 | iter->width, \ |
942 | bits_image_fetch_bilinear_affine (image, offset, line, width, buffer, mask, \ |
1145 | iter->buffer, mask, \ |
943 | convert_ ## format, \ |
1146 | convert_ ## format, \ |
944 | PIXMAN_ ## format, \ |
1147 | PIXMAN_ ## format, \ |
945 | repeat_mode); \ |
1148 | repeat_mode); \ |
Line -... | Line 1149... | ||
- | 1149 | return iter->buffer; \ |
|
- | 1150 | } |
|
- | 1151 | ||
- | 1152 | #define MAKE_NEAREST_FETCHER(name, format, repeat_mode) \ |
|
- | 1153 | static uint32_t * \ |
|
- | 1154 | bits_image_fetch_nearest_affine_ ## name (pixman_iter_t *iter, \ |
|
- | 1155 | const uint32_t * mask) \ |
|
- | 1156 | { \ |
|
- | 1157 | bits_image_fetch_nearest_affine (iter->image, \ |
|
- | 1158 | iter->x, iter->y++, \ |
|
- | 1159 | iter->width, \ |
|
- | 1160 | iter->buffer, mask, \ |
|
- | 1161 | convert_ ## format, \ |
|
- | 1162 | PIXMAN_ ## format, \ |
|
- | 1163 | repeat_mode); \ |
|
- | 1164 | return iter->buffer; \ |
|
- | 1165 | } |
|
- | 1166 | ||
- | 1167 | #define MAKE_FETCHERS(name, format, repeat_mode) \ |
|
- | 1168 | MAKE_NEAREST_FETCHER (name, format, repeat_mode) \ |
|
946 | } \ |
1169 | MAKE_BILINEAR_FETCHER (name, format, repeat_mode) \ |
947 | extern int no_such_variable |
1170 | MAKE_SEPARABLE_CONVOLUTION_FETCHER (name, format, repeat_mode) |
948 | 1171 | ||
949 | MAKE_BILINEAR_FETCHER (pad_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_PAD); |
1172 | MAKE_FETCHERS (pad_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_PAD) |
950 | MAKE_BILINEAR_FETCHER (none_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_NONE); |
1173 | MAKE_FETCHERS (none_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_NONE) |
951 | MAKE_BILINEAR_FETCHER (reflect_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_REFLECT); |
1174 | MAKE_FETCHERS (reflect_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_REFLECT) |
952 | MAKE_BILINEAR_FETCHER (normal_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_NORMAL); |
1175 | MAKE_FETCHERS (normal_a8r8g8b8, a8r8g8b8, PIXMAN_REPEAT_NORMAL) |
953 | MAKE_BILINEAR_FETCHER (pad_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_PAD); |
1176 | MAKE_FETCHERS (pad_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_PAD) |
954 | MAKE_BILINEAR_FETCHER (none_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_NONE); |
1177 | MAKE_FETCHERS (none_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_NONE) |
955 | MAKE_BILINEAR_FETCHER (reflect_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_REFLECT); |
1178 | MAKE_FETCHERS (reflect_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_REFLECT) |
956 | MAKE_BILINEAR_FETCHER (normal_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_NORMAL); |
1179 | MAKE_FETCHERS (normal_x8r8g8b8, x8r8g8b8, PIXMAN_REPEAT_NORMAL) |
957 | MAKE_BILINEAR_FETCHER (pad_a8, a8, PIXMAN_REPEAT_PAD); |
1180 | MAKE_FETCHERS (pad_a8, a8, PIXMAN_REPEAT_PAD) |
958 | MAKE_BILINEAR_FETCHER (none_a8, a8, PIXMAN_REPEAT_NONE); |
1181 | MAKE_FETCHERS (none_a8, a8, PIXMAN_REPEAT_NONE) |
959 | MAKE_BILINEAR_FETCHER (reflect_a8, a8, PIXMAN_REPEAT_REFLECT); |
1182 | MAKE_FETCHERS (reflect_a8, a8, PIXMAN_REPEAT_REFLECT) |
960 | MAKE_BILINEAR_FETCHER (normal_a8, a8, PIXMAN_REPEAT_NORMAL); |
1183 | MAKE_FETCHERS (normal_a8, a8, PIXMAN_REPEAT_NORMAL) |
961 | MAKE_BILINEAR_FETCHER (pad_r5g6b5, r5g6b5, PIXMAN_REPEAT_PAD); |
1184 | MAKE_FETCHERS (pad_r5g6b5, r5g6b5, PIXMAN_REPEAT_PAD) |
Line 962... | Line 1185... | ||
962 | MAKE_BILINEAR_FETCHER (none_r5g6b5, r5g6b5, PIXMAN_REPEAT_NONE); |
1185 | MAKE_FETCHERS (none_r5g6b5, r5g6b5, PIXMAN_REPEAT_NONE) |
963 | MAKE_BILINEAR_FETCHER (reflect_r5g6b5, r5g6b5, PIXMAN_REPEAT_REFLECT); |
1186 | MAKE_FETCHERS (reflect_r5g6b5, r5g6b5, PIXMAN_REPEAT_REFLECT) |
964 | MAKE_BILINEAR_FETCHER (normal_r5g6b5, r5g6b5, PIXMAN_REPEAT_NORMAL); |
1187 | MAKE_FETCHERS (normal_r5g6b5, r5g6b5, PIXMAN_REPEAT_NORMAL) |
965 | 1188 | ||
966 | static void |
1189 | static void |
967 | bits_image_fetch_solid_32 (pixman_image_t * image, |
1190 | replicate_pixel_32 (bits_image_t * bits, |
968 | int x, |
- | |
969 | int y, |
1191 | int x, |
970 | int width, |
1192 | int y, |
971 | uint32_t * buffer, |
1193 | int width, |
Line 972... | Line 1194... | ||
972 | const uint32_t * mask) |
1194 | uint32_t * buffer) |
Line 973... | Line 1195... | ||
973 | { |
1195 | { |
974 | uint32_t color; |
1196 | uint32_t color; |
975 | uint32_t *end; |
1197 | uint32_t *end; |
976 | 1198 | ||
Line 977... | Line 1199... | ||
977 | color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); |
1199 | color = bits->fetch_pixel_32 (bits, x, y); |
978 | 1200 | ||
979 | end = buffer + width; |
1201 | end = buffer + width; |
980 | while (buffer < end) |
1202 | while (buffer < end) |
981 | *(buffer++) = color; |
1203 | *(buffer++) = color; |
982 | } |
1204 | } |
983 | - | ||
984 | static void |
1205 | |
985 | bits_image_fetch_solid_64 (pixman_image_t * image, |
1206 | static void |
986 | int x, |
1207 | replicate_pixel_float (bits_image_t * bits, |
987 | int y, |
1208 | int x, |
Line 988... | Line 1209... | ||
988 | int width, |
1209 | int y, |
Line 989... | Line 1210... | ||
989 | uint32_t * b, |
1210 | int width, |
990 | const uint32_t * unused) |
1211 | uint32_t * b) |
991 | { |
1212 | { |
992 | uint64_t color; |
1213 | argb_t color; |
Line 1010... | Line 1231... | ||
1010 | { |
1231 | { |
1011 | uint32_t w; |
1232 | uint32_t w; |
Line 1012... | Line 1233... | ||
1012 | 1233 | ||
1013 | if (y < 0 || y >= image->height) |
1234 | if (y < 0 || y >= image->height) |
1014 | { |
1235 | { |
1015 | memset (buffer, 0, width * (wide? 8 : 4)); |
1236 | memset (buffer, 0, width * (wide? sizeof (argb_t) : 4)); |
1016 | return; |
1237 | return; |
Line 1017... | Line 1238... | ||
1017 | } |
1238 | } |
1018 | 1239 | ||
1019 | if (x < 0) |
1240 | if (x < 0) |
Line 1020... | Line 1241... | ||
1020 | { |
1241 | { |
Line 1021... | Line 1242... | ||
1021 | w = MIN (width, -x); |
1242 | w = MIN (width, -x); |
1022 | 1243 | ||
1023 | memset (buffer, 0, w * (wide ? 8 : 4)); |
1244 | memset (buffer, 0, w * (wide ? sizeof (argb_t) : 4)); |
1024 | 1245 | ||
Line 1025... | Line 1246... | ||
1025 | width -= w; |
1246 | width -= w; |
1026 | buffer += w * (wide? 2 : 1); |
1247 | buffer += w * (wide? 4 : 1); |
1027 | x += w; |
1248 | x += w; |
Line 1028... | Line 1249... | ||
1028 | } |
1249 | } |
1029 | 1250 | ||
1030 | if (x < image->width) |
1251 | if (x < image->width) |
1031 | { |
1252 | { |
Line 1032... | Line 1253... | ||
1032 | w = MIN (width, image->width - x); |
1253 | w = MIN (width, image->width - x); |
1033 | 1254 | ||
1034 | if (wide) |
1255 | if (wide) |
1035 | image->fetch_scanline_64 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1256 | image->fetch_scanline_float ((pixman_image_t *)image, x, y, w, buffer, NULL); |
Line 1036... | Line 1257... | ||
1036 | else |
1257 | else |
1037 | image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1258 | image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
Line 1038... | Line 1259... | ||
1038 | 1259 | ||
1039 | width -= w; |
1260 | width -= w; |
1040 | buffer += w * (wide? 2 : 1); |
1261 | buffer += w * (wide? 4 : 1); |
Line 1058... | Line 1279... | ||
1058 | y += image->height; |
1279 | y += image->height; |
Line 1059... | Line 1280... | ||
1059 | 1280 | ||
1060 | while (y >= image->height) |
1281 | while (y >= image->height) |
Line -... | Line 1282... | ||
- | 1282 | y -= image->height; |
|
- | 1283 | ||
- | 1284 | if (image->width == 1) |
|
- | 1285 | { |
|
- | 1286 | if (wide) |
|
- | 1287 | replicate_pixel_float (image, 0, y, width, buffer); |
|
- | 1288 | else |
|
- | 1289 | replicate_pixel_32 (image, 0, y, width, buffer); |
|
- | 1290 | ||
- | 1291 | return; |
|
1061 | y -= image->height; |
1292 | } |
1062 | 1293 | ||
1063 | while (width) |
1294 | while (width) |
1064 | { |
1295 | { |
1065 | while (x < 0) |
1296 | while (x < 0) |
1066 | x += image->width; |
1297 | x += image->width; |
Line 1067... | Line 1298... | ||
1067 | while (x >= image->width) |
1298 | while (x >= image->width) |
Line 1068... | Line 1299... | ||
1068 | x -= image->width; |
1299 | x -= image->width; |
1069 | 1300 | ||
1070 | w = MIN (width, image->width - x); |
1301 | w = MIN (width, image->width - x); |
1071 | 1302 | ||
Line 1072... | Line 1303... | ||
1072 | if (wide) |
1303 | if (wide) |
1073 | image->fetch_scanline_64 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1304 | image->fetch_scanline_float ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1074 | else |
1305 | else |
1075 | image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1306 | image->fetch_scanline_32 ((pixman_image_t *)image, x, y, w, buffer, NULL); |
1076 | 1307 | ||
Line 1077... | Line 1308... | ||
1077 | buffer += w * (wide? 2 : 1); |
1308 | buffer += w * (wide? 4 : 1); |
1078 | x += w; |
1309 | x += w; |
1079 | width -= w; |
- | |
1080 | } |
- | |
1081 | } |
- | |
1082 | - | ||
1083 | static void |
1310 | width -= w; |
1084 | bits_image_fetch_untransformed_32 (pixman_image_t * image, |
1311 | } |
- | 1312 | } |
|
- | 1313 | ||
- | 1314 | static uint32_t * |
|
- | 1315 | bits_image_fetch_untransformed_32 (pixman_iter_t * iter, |
|
- | 1316 | const uint32_t *mask) |
|
- | 1317 | { |
|
1085 | int x, |
1318 | pixman_image_t *image = iter->image; |
1086 | int y, |
1319 | int x = iter->x; |
1087 | int width, |
1320 | int y = iter->y; |
1088 | uint32_t * buffer, |
1321 | int width = iter->width; |
1089 | const uint32_t * mask) |
1322 | uint32_t * buffer = iter->buffer; |
1090 | { |
1323 | |
1091 | if (image->common.repeat == PIXMAN_REPEAT_NONE) |
1324 | if (image->common.repeat == PIXMAN_REPEAT_NONE) |
1092 | { |
1325 | { |
1093 | bits_image_fetch_untransformed_repeat_none ( |
1326 | bits_image_fetch_untransformed_repeat_none ( |
1094 | &image->bits, FALSE, x, y, width, buffer); |
1327 | &image->bits, FALSE, x, y, width, buffer); |
- | 1328 | } |
|
- | 1329 | else |
|
- | 1330 | { |
|
1095 | } |
1331 | bits_image_fetch_untransformed_repeat_normal ( |
Line 1096... | Line 1332... | ||
1096 | else |
1332 | &image->bits, FALSE, x, y, width, buffer); |
1097 | { |
1333 | } |
1098 | bits_image_fetch_untransformed_repeat_normal ( |
- | |
1099 | &image->bits, FALSE, x, y, width, buffer); |
- | |
1100 | } |
- | |
1101 | } |
- | |
1102 | 1334 | ||
1103 | static void |
1335 | iter->y++; |
- | 1336 | return buffer; |
|
- | 1337 | } |
|
- | 1338 | ||
- | 1339 | static uint32_t * |
|
- | 1340 | bits_image_fetch_untransformed_float (pixman_iter_t * iter, |
|
- | 1341 | const uint32_t *mask) |
|
1104 | bits_image_fetch_untransformed_64 (pixman_image_t * image, |
1342 | { |
1105 | int x, |
1343 | pixman_image_t *image = iter->image; |
1106 | int y, |
1344 | int x = iter->x; |
1107 | int width, |
1345 | int y = iter->y; |
1108 | uint32_t * buffer, |
1346 | int width = iter->width; |
1109 | const uint32_t * unused) |
1347 | uint32_t * buffer = iter->buffer; |
1110 | { |
1348 | |
1111 | if (image->common.repeat == PIXMAN_REPEAT_NONE) |
1349 | if (image->common.repeat == PIXMAN_REPEAT_NONE) |
1112 | { |
1350 | { |
1113 | bits_image_fetch_untransformed_repeat_none ( |
1351 | bits_image_fetch_untransformed_repeat_none ( |
- | 1352 | &image->bits, TRUE, x, y, width, buffer); |
|
- | 1353 | } |
|
- | 1354 | else |
|
1114 | &image->bits, TRUE, x, y, width, buffer); |
1355 | { |
Line 1115... | Line 1356... | ||
1115 | } |
1356 | bits_image_fetch_untransformed_repeat_normal ( |
1116 | else |
1357 | &image->bits, TRUE, x, y, width, buffer); |
1117 | { |
1358 | } |
1118 | bits_image_fetch_untransformed_repeat_normal ( |
1359 | |
1119 | &image->bits, TRUE, x, y, width, buffer); |
1360 | iter->y++; |
1120 | } |
1361 | return buffer; |
1121 | } |
1362 | } |
Line 1122... | Line 1363... | ||
1122 | 1363 | ||
1123 | typedef struct |
1364 | typedef struct |
1124 | { |
- | |
1125 | pixman_format_code_t format; |
- | |
1126 | uint32_t flags; |
- | |
1127 | fetch_scanline_t fetch_32; |
- | |
1128 | fetch_scanline_t fetch_64; |
- | |
1129 | } fetcher_info_t; |
- | |
1130 | 1365 | { |
|
1131 | static const fetcher_info_t fetcher_info[] = |
1366 | pixman_format_code_t format; |
1132 | { |
1367 | uint32_t flags; |
1133 | { PIXMAN_solid, |
1368 | pixman_iter_get_scanline_t get_scanline_32; |
1134 | FAST_PATH_NO_ALPHA_MAP, |
1369 | pixman_iter_get_scanline_t get_scanline_float; |
1135 | bits_image_fetch_solid_32, |
1370 | } fetcher_info_t; |
1136 | bits_image_fetch_solid_64 |
1371 | |
1137 | }, |
1372 | static const fetcher_info_t fetcher_info[] = |
1138 | 1373 | { |
|
Line 1139... | Line 1374... | ||
1139 | { PIXMAN_any, |
1374 | { PIXMAN_any, |
1140 | (FAST_PATH_NO_ALPHA_MAP | |
1375 | (FAST_PATH_NO_ALPHA_MAP | |
1141 | FAST_PATH_ID_TRANSFORM | |
1376 | FAST_PATH_ID_TRANSFORM | |
Line 1157... | Line 1392... | ||
1157 | FAST_PATH_BILINEAR_FILTER) |
1392 | FAST_PATH_BILINEAR_FILTER) |
Line 1158... | Line 1393... | ||
1158 | 1393 | ||
1159 | { PIXMAN_a8r8g8b8, |
1394 | { PIXMAN_a8r8g8b8, |
1160 | FAST_BILINEAR_FLAGS, |
1395 | FAST_BILINEAR_FLAGS, |
1161 | bits_image_fetch_bilinear_no_repeat_8888, |
1396 | bits_image_fetch_bilinear_no_repeat_8888, |
1162 | _pixman_image_get_scanline_generic_64 |
1397 | _pixman_image_get_scanline_generic_float |
Line 1163... | Line 1398... | ||
1163 | }, |
1398 | }, |
1164 | 1399 | ||
1165 | { PIXMAN_x8r8g8b8, |
1400 | { PIXMAN_x8r8g8b8, |
1166 | FAST_BILINEAR_FLAGS, |
1401 | FAST_BILINEAR_FLAGS, |
1167 | bits_image_fetch_bilinear_no_repeat_8888, |
1402 | bits_image_fetch_bilinear_no_repeat_8888, |
Line 1168... | Line 1403... | ||
1168 | _pixman_image_get_scanline_generic_64 |
1403 | _pixman_image_get_scanline_generic_float |
1169 | }, |
1404 | }, |
1170 | 1405 | ||
1171 | #define GENERAL_BILINEAR_FLAGS \ |
1406 | #define GENERAL_BILINEAR_FLAGS \ |
1172 | (FAST_PATH_NO_ALPHA_MAP | \ |
1407 | (FAST_PATH_NO_ALPHA_MAP | \ |
1173 | FAST_PATH_NO_ACCESSORS | \ |
1408 | FAST_PATH_NO_ACCESSORS | \ |
Line -... | Line 1409... | ||
- | 1409 | FAST_PATH_HAS_TRANSFORM | \ |
|
- | 1410 | FAST_PATH_AFFINE_TRANSFORM | \ |
|
- | 1411 | FAST_PATH_BILINEAR_FILTER) |
|
- | 1412 | ||
- | 1413 | #define GENERAL_NEAREST_FLAGS \ |
|
- | 1414 | (FAST_PATH_NO_ALPHA_MAP | \ |
|
- | 1415 | FAST_PATH_NO_ACCESSORS | \ |
|
- | 1416 | FAST_PATH_HAS_TRANSFORM | \ |
|
- | 1417 | FAST_PATH_AFFINE_TRANSFORM | \ |
|
- | 1418 | FAST_PATH_NEAREST_FILTER) |
|
- | 1419 | ||
- | 1420 | #define GENERAL_SEPARABLE_CONVOLUTION_FLAGS \ |
|
- | 1421 | (FAST_PATH_NO_ALPHA_MAP | \ |
|
- | 1422 | FAST_PATH_NO_ACCESSORS | \ |
|
- | 1423 | FAST_PATH_HAS_TRANSFORM | \ |
|
- | 1424 | FAST_PATH_AFFINE_TRANSFORM | \ |
|
- | 1425 | FAST_PATH_SEPARABLE_CONVOLUTION_FILTER) |
|
- | 1426 | ||
- | 1427 | #define SEPARABLE_CONVOLUTION_AFFINE_FAST_PATH(name, format, repeat) \ |
|
- | 1428 | { PIXMAN_ ## format, \ |
|
- | 1429 | GENERAL_SEPARABLE_CONVOLUTION_FLAGS | FAST_PATH_ ## repeat ## _REPEAT, \ |
|
1174 | FAST_PATH_HAS_TRANSFORM | \ |
1430 | bits_image_fetch_separable_convolution_affine_ ## name, \ |
1175 | FAST_PATH_AFFINE_TRANSFORM | \ |
1431 | _pixman_image_get_scanline_generic_float \ |
1176 | FAST_PATH_BILINEAR_FILTER) |
1432 | }, |
1177 | 1433 | ||
1178 | #define BILINEAR_AFFINE_FAST_PATH(name, format, repeat) \ |
1434 | #define BILINEAR_AFFINE_FAST_PATH(name, format, repeat) \ |
- | 1435 | { PIXMAN_ ## format, \ |
|
- | 1436 | GENERAL_BILINEAR_FLAGS | FAST_PATH_ ## repeat ## _REPEAT, \ |
|
- | 1437 | bits_image_fetch_bilinear_affine_ ## name, \ |
|
- | 1438 | _pixman_image_get_scanline_generic_float \ |
|
- | 1439 | }, |
|
- | 1440 | ||
- | 1441 | #define NEAREST_AFFINE_FAST_PATH(name, format, repeat) \ |
|
1179 | { PIXMAN_ ## format, \ |
1442 | { PIXMAN_ ## format, \ |
Line -... | Line 1443... | ||
- | 1443 | GENERAL_NEAREST_FLAGS | FAST_PATH_ ## repeat ## _REPEAT, \ |
|
- | 1444 | bits_image_fetch_nearest_affine_ ## name, \ |
|
- | 1445 | _pixman_image_get_scanline_generic_float \ |
|
- | 1446 | }, |
|
- | 1447 | ||
1180 | GENERAL_BILINEAR_FLAGS | FAST_PATH_ ## repeat ## _REPEAT, \ |
1448 | #define AFFINE_FAST_PATHS(name, format, repeat) \ |
1181 | bits_image_fetch_bilinear_affine_ ## name, \ |
1449 | SEPARABLE_CONVOLUTION_AFFINE_FAST_PATH(name, format, repeat) \ |
1182 | _pixman_image_get_scanline_generic_64 \ |
1450 | BILINEAR_AFFINE_FAST_PATH(name, format, repeat) \ |
1183 | }, |
1451 | NEAREST_AFFINE_FAST_PATH(name, format, repeat) |
1184 | 1452 | ||
1185 | BILINEAR_AFFINE_FAST_PATH (pad_a8r8g8b8, a8r8g8b8, PAD) |
1453 | AFFINE_FAST_PATHS (pad_a8r8g8b8, a8r8g8b8, PAD) |
1186 | BILINEAR_AFFINE_FAST_PATH (none_a8r8g8b8, a8r8g8b8, NONE) |
1454 | AFFINE_FAST_PATHS (none_a8r8g8b8, a8r8g8b8, NONE) |
1187 | BILINEAR_AFFINE_FAST_PATH (reflect_a8r8g8b8, a8r8g8b8, REFLECT) |
1455 | AFFINE_FAST_PATHS (reflect_a8r8g8b8, a8r8g8b8, REFLECT) |
1188 | BILINEAR_AFFINE_FAST_PATH (normal_a8r8g8b8, a8r8g8b8, NORMAL) |
1456 | AFFINE_FAST_PATHS (normal_a8r8g8b8, a8r8g8b8, NORMAL) |
1189 | BILINEAR_AFFINE_FAST_PATH (pad_x8r8g8b8, x8r8g8b8, PAD) |
1457 | AFFINE_FAST_PATHS (pad_x8r8g8b8, x8r8g8b8, PAD) |
1190 | BILINEAR_AFFINE_FAST_PATH (none_x8r8g8b8, x8r8g8b8, NONE) |
1458 | AFFINE_FAST_PATHS (none_x8r8g8b8, x8r8g8b8, NONE) |
1191 | BILINEAR_AFFINE_FAST_PATH (reflect_x8r8g8b8, x8r8g8b8, REFLECT) |
1459 | AFFINE_FAST_PATHS (reflect_x8r8g8b8, x8r8g8b8, REFLECT) |
1192 | BILINEAR_AFFINE_FAST_PATH (normal_x8r8g8b8, x8r8g8b8, NORMAL) |
1460 | AFFINE_FAST_PATHS (normal_x8r8g8b8, x8r8g8b8, NORMAL) |
1193 | BILINEAR_AFFINE_FAST_PATH (pad_a8, a8, PAD) |
1461 | AFFINE_FAST_PATHS (pad_a8, a8, PAD) |
1194 | BILINEAR_AFFINE_FAST_PATH (none_a8, a8, NONE) |
1462 | AFFINE_FAST_PATHS (none_a8, a8, NONE) |
1195 | BILINEAR_AFFINE_FAST_PATH (reflect_a8, a8, REFLECT) |
1463 | AFFINE_FAST_PATHS (reflect_a8, a8, REFLECT) |
Line 1196... | Line 1464... | ||
1196 | BILINEAR_AFFINE_FAST_PATH (normal_a8, a8, NORMAL) |
1464 | AFFINE_FAST_PATHS (normal_a8, a8, NORMAL) |
1197 | BILINEAR_AFFINE_FAST_PATH (pad_r5g6b5, r5g6b5, PAD) |
1465 | AFFINE_FAST_PATHS (pad_r5g6b5, r5g6b5, PAD) |
1198 | BILINEAR_AFFINE_FAST_PATH (none_r5g6b5, r5g6b5, NONE) |
1466 | AFFINE_FAST_PATHS (none_r5g6b5, r5g6b5, NONE) |
1199 | BILINEAR_AFFINE_FAST_PATH (reflect_r5g6b5, r5g6b5, REFLECT) |
1467 | AFFINE_FAST_PATHS (reflect_r5g6b5, r5g6b5, REFLECT) |
1200 | BILINEAR_AFFINE_FAST_PATH (normal_r5g6b5, r5g6b5, NORMAL) |
1468 | AFFINE_FAST_PATHS (normal_r5g6b5, r5g6b5, NORMAL) |
1201 | 1469 | ||
Line 1202... | Line 1470... | ||
1202 | /* Affine, no alpha */ |
1470 | /* Affine, no alpha */ |
- | 1471 | { PIXMAN_any, |
|
- | 1472 | (FAST_PATH_NO_ALPHA_MAP | FAST_PATH_HAS_TRANSFORM | FAST_PATH_AFFINE_TRANSFORM), |
|
- | 1473 | bits_image_fetch_affine_no_alpha, |
|
1203 | { PIXMAN_any, |
1474 | _pixman_image_get_scanline_generic_float |
- | 1475 | }, |
|
Line 1204... | Line 1476... | ||
1204 | (FAST_PATH_NO_ALPHA_MAP | FAST_PATH_HAS_TRANSFORM | FAST_PATH_AFFINE_TRANSFORM), |
1476 | |
1205 | bits_image_fetch_affine_no_alpha, |
1477 | /* General */ |
Line 1206... | Line 1478... | ||
1206 | _pixman_image_get_scanline_generic_64 |
1478 | { PIXMAN_any, |
1207 | }, |
1479 | 0, |
1208 | 1480 | bits_image_fetch_general, |
|
1209 | /* General */ |
1481 | _pixman_image_get_scanline_generic_float |
- | 1482 | }, |
|
- | 1483 | ||
- | 1484 | { PIXMAN_null }, |
|
- | 1485 | }; |
|
- | 1486 | ||
1210 | { PIXMAN_any, 0, bits_image_fetch_general, _pixman_image_get_scanline_generic_64 }, |
1487 | static void |
- | 1488 | bits_image_property_changed (pixman_image_t *image) |
|
1211 | 1489 | { |
|
Line 1212... | Line -... | ||
1212 | { PIXMAN_null }, |
- | |
1213 | }; |
- | |
1214 | - | ||
1215 | static void |
1490 | _pixman_bits_image_setup_accessors (&image->bits); |
1216 | bits_image_property_changed (pixman_image_t *image) |
1491 | } |
1217 | { |
1492 | |
1218 | uint32_t flags = image->common.flags; |
1493 | void |
1219 | pixman_format_code_t format = image->common.extended_format_code; |
1494 | _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter) |
- | 1495 | { |
|
- | 1496 | pixman_format_code_t format = image->common.extended_format_code; |
|
1220 | const fetcher_info_t *info; |
1497 | uint32_t flags = image->common.flags; |
- | 1498 | const fetcher_info_t *info; |
|
- | 1499 | ||
- | 1500 | for (info = fetcher_info; info->format != PIXMAN_null; ++info) |
|
- | 1501 | { |
|
- | 1502 | if ((info->format == format || info->format == PIXMAN_any) && |
|
- | 1503 | (info->flags & flags) == info->flags) |
|
- | 1504 | { |
|
- | 1505 | if (iter->iter_flags & ITER_NARROW) |
|
- | 1506 | { |
|
- | 1507 | iter->get_scanline = info->get_scanline_32; |
|
- | 1508 | } |
|
- | 1509 | else |
|
- | 1510 | { |
|
- | 1511 | iter->data = info->get_scanline_32; |
|
- | 1512 | iter->get_scanline = info->get_scanline_float; |
|
- | 1513 | } |
|
- | 1514 | return; |
|
- | 1515 | } |
|
- | 1516 | } |
|
- | 1517 | ||
- | 1518 | /* Just in case we somehow didn't find a scanline function */ |
|
- | 1519 | iter->get_scanline = _pixman_iter_get_scanline_noop; |
|
- | 1520 | } |
|
- | 1521 | ||
- | 1522 | static uint32_t * |
|
- | 1523 | dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask) |
|
- | 1524 | { |
|
- | 1525 | pixman_image_t *image = iter->image; |
|
- | 1526 | int x = iter->x; |
|
- | 1527 | int y = iter->y; |
|
- | 1528 | int width = iter->width; |
|
- | 1529 | uint32_t * buffer = iter->buffer; |
|
- | 1530 | ||
- | 1531 | image->bits.fetch_scanline_32 (image, x, y, width, buffer, mask); |
|
- | 1532 | if (image->common.alpha_map) |
|
1221 | 1533 | { |
|
- | 1534 | uint32_t *alpha; |
|
- | 1535 | ||
- | 1536 | if ((alpha = malloc (width * sizeof (uint32_t)))) |
|
- | 1537 | { |
|
- | 1538 | int i; |
|
- | 1539 | ||
- | 1540 | x -= image->common.alpha_origin_x; |
|
- | 1541 | y -= image->common.alpha_origin_y; |
|
- | 1542 | ||
- | 1543 | image->common.alpha_map->fetch_scanline_32 ( |
|
- | 1544 | (pixman_image_t *)image->common.alpha_map, |
|
- | 1545 | x, y, width, alpha, mask); |
|
- | 1546 | ||
- | 1547 | for (i = 0; i < width; ++i) |
|
- | 1548 | { |
|
- | 1549 | buffer[i] &= ~0xff000000; |
|
- | 1550 | buffer[i] |= (alpha[i] & 0xff000000); |
|
- | 1551 | } |
|
- | 1552 | ||
- | 1553 | free (alpha); |
|
- | 1554 | } |
|
- | 1555 | } |
|
- | 1556 | ||
- | 1557 | return iter->buffer; |
|
- | 1558 | } |
|
- | 1559 | ||
- | 1560 | static uint32_t * |
|
- | 1561 | dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask) |
|
- | 1562 | { |
|
- | 1563 | bits_image_t * image = &iter->image->bits; |
|
- | 1564 | int x = iter->x; |
|
- | 1565 | int y = iter->y; |
|
- | 1566 | int width = iter->width; |
|
1222 | _pixman_bits_image_setup_accessors (&image->bits); |
1567 | argb_t * buffer = (argb_t *)iter->buffer; |
- | 1568 | ||
- | 1569 | image->fetch_scanline_float ( |
|
- | 1570 | (pixman_image_t *)image, x, y, width, (uint32_t *)buffer, mask); |
|
- | 1571 | if (image->common.alpha_map) |
|
- | 1572 | { |
|
- | 1573 | argb_t *alpha; |
|
- | 1574 | ||
- | 1575 | if ((alpha = malloc (width * sizeof (argb_t)))) |
|
- | 1576 | { |
|
- | 1577 | int i; |
|
- | 1578 | ||
- | 1579 | x -= image->common.alpha_origin_x; |
|
1223 | 1580 | y -= image->common.alpha_origin_y; |
|
- | 1581 | ||
- | 1582 | image->common.alpha_map->fetch_scanline_float ( |
|
- | 1583 | (pixman_image_t *)image->common.alpha_map, |
|
- | 1584 | x, y, width, (uint32_t *)alpha, mask); |
|
- | 1585 | ||
- | 1586 | for (i = 0; i < width; ++i) |
|
- | 1587 | buffer[i].a = alpha[i].a; |
|
- | 1588 | ||
- | 1589 | free (alpha); |
|
- | 1590 | } |
|
- | 1591 | } |
|
- | 1592 | ||
- | 1593 | return iter->buffer; |
|
- | 1594 | } |
|
- | 1595 | ||
Line -... | Line 1596... | ||
- | 1596 | static void |
|
- | 1597 | dest_write_back_narrow (pixman_iter_t *iter) |
|
- | 1598 | { |
|
- | 1599 | bits_image_t * image = &iter->image->bits; |
|
- | 1600 | int x = iter->x; |
|
- | 1601 | int y = iter->y; |
|
- | 1602 | int width = iter->width; |
|
- | 1603 | const uint32_t *buffer = iter->buffer; |
|
- | 1604 | ||
1224 | info = fetcher_info; |
1605 | image->store_scanline_32 (image, x, y, width, buffer); |
- | 1606 | ||
- | 1607 | if (image->common.alpha_map) |
|
- | 1608 | { |
|
- | 1609 | x -= image->common.alpha_origin_x; |
|
- | 1610 | y -= image->common.alpha_origin_y; |
|
- | 1611 | ||
- | 1612 | image->common.alpha_map->store_scanline_32 ( |
|
- | 1613 | image->common.alpha_map, x, y, width, buffer); |
|
- | 1614 | } |
|
- | 1615 | ||
- | 1616 | iter->y++; |
|
- | 1617 | } |
|
- | 1618 | ||
- | 1619 | static void |
|
- | 1620 | dest_write_back_wide (pixman_iter_t *iter) |
|
- | 1621 | { |
|
- | 1622 | bits_image_t * image = &iter->image->bits; |
|
- | 1623 | int x = iter->x; |
|
- | 1624 | int y = iter->y; |
|
- | 1625 | int width = iter->width; |
|
- | 1626 | const uint32_t *buffer = iter->buffer; |
|
- | 1627 | ||
- | 1628 | image->store_scanline_float (image, x, y, width, buffer); |
|
- | 1629 | ||
- | 1630 | if (image->common.alpha_map) |
|
- | 1631 | { |
|
- | 1632 | x -= image->common.alpha_origin_x; |
|
- | 1633 | y -= image->common.alpha_origin_y; |
|
- | 1634 | ||
- | 1635 | image->common.alpha_map->store_scanline_float ( |
|
- | 1636 | image->common.alpha_map, x, y, width, buffer); |
|
- | 1637 | } |
|
- | 1638 | ||
- | 1639 | iter->y++; |
|
- | 1640 | } |
|
- | 1641 | ||
- | 1642 | void |
|
- | 1643 | _pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter) |
|
- | 1644 | { |
|
- | 1645 | if (iter->iter_flags & ITER_NARROW) |
|
- | 1646 | { |
|
- | 1647 | if ((iter->iter_flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) == |
|
- | 1648 | (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) |
|
- | 1649 | { |
|
- | 1650 | iter->get_scanline = _pixman_iter_get_scanline_noop; |
|
- | 1651 | } |
|
1225 | while (info->format != PIXMAN_null) |
1652 | else |
1226 | { |
1653 | { |
Line 1227... | Line 1654... | ||
1227 | if ((info->format == format || info->format == PIXMAN_any) && |
1654 | iter->get_scanline = dest_get_scanline_narrow; |
1228 | (info->flags & flags) == info->flags) |
1655 | } |
1229 | { |
1656 | |
1230 | image->common.get_scanline_32 = info->fetch_32; |
1657 | iter->write_back = dest_write_back_narrow; |
1231 | image->common.get_scanline_64 = info->fetch_64; |
1658 | } |
- | 1659 | else |
|
1232 | break; |
1660 | { |
1233 | } |
1661 | iter->get_scanline = dest_get_scanline_wide; |
1234 | 1662 | iter->write_back = dest_write_back_wide; |
|
1235 | info++; |
1663 | } |
Line 1236... | Line 1664... | ||
1236 | } |
1664 | } |
1237 | } |
1665 | |
1238 | 1666 | static uint32_t * |
|
1239 | static uint32_t * |
1667 | create_bits (pixman_format_code_t format, |
Line 1240... | Line 1668... | ||
1240 | create_bits (pixman_format_code_t format, |
1668 | int width, |
1241 | int width, |
1669 | int height, |
1242 | int height, |
1670 | int * rowstride_bytes, |
Line 1243... | Line 1671... | ||
1243 | int * rowstride_bytes) |
1671 | pixman_bool_t clear) |
1244 | { |
1672 | { |
1245 | int stride; |
1673 | int stride; |
Line 1246... | Line 1674... | ||
1246 | int buf_size; |
1674 | size_t buf_size; |
1247 | int bpp; |
1675 | int bpp; |
Line 1248... | Line 1676... | ||
1248 | 1676 | ||
Line 1249... | Line 1677... | ||
1249 | /* what follows is a long-winded way, avoiding any possibility of integer |
1677 | /* what follows is a long-winded way, avoiding any possibility of integer |
1250 | * overflows, of saying: |
1678 | * overflows, of saying: |
Line 1251... | Line 1679... | ||
1251 | * stride = ((width * bpp + 0x1f) >> 5) * sizeof (uint32_t); |
1679 | * stride = ((width * bpp + 0x1f) >> 5) * sizeof (uint32_t); |
Line 1252... | Line 1680... | ||
1252 | */ |
1680 | */ |
1253 | 1681 | ||
Line -... | Line 1682... | ||
- | 1682 | bpp = PIXMAN_FORMAT_BPP (format); |
|
1254 | bpp = PIXMAN_FORMAT_BPP (format); |
1683 | if (_pixman_multiply_overflows_int (width, bpp)) |
- | 1684 | return NULL; |
|
- | 1685 | ||
1255 | if (pixman_multiply_overflows_int (width, bpp)) |
1686 | stride = width * bpp; |
Line -... | Line 1687... | ||
- | 1687 | if (_pixman_addition_overflows_int (stride, 0x1f)) |
|
1256 | return NULL; |
1688 | return NULL; |
1257 | 1689 | ||
1258 | stride = width * bpp; |
1690 | stride += 0x1f; |
1259 | if (pixman_addition_overflows_int (stride, 0x1f)) |
1691 | stride >>= 5; |
1260 | return NULL; |
1692 | |
1261 | 1693 | stride *= sizeof (uint32_t); |
|
- | 1694 | ||
1262 | stride += 0x1f; |
1695 | if (_pixman_multiply_overflows_size (height, stride)) |
1263 | stride >>= 5; |
- | |
1264 | 1696 | return NULL; |
|
Line 1265... | Line -... | ||
1265 | stride *= sizeof (uint32_t); |
- | |
1266 | - | ||
1267 | if (pixman_multiply_overflows_int (height, stride)) |
- | |
1268 | return NULL; |
- | |
1269 | - | ||
1270 | buf_size = height * stride; |
- | |
1271 | - | ||
1272 | if (rowstride_bytes) |
1697 | |
1273 | *rowstride_bytes = stride; |
1698 | buf_size = height * stride; |
1274 | - | ||
1275 | return calloc (buf_size, 1); |
- | |
1276 | } |
1699 | |
1277 | - | ||
Line 1278... | Line 1700... | ||
1278 | PIXMAN_EXPORT pixman_image_t * |
1700 | if (rowstride_bytes) |
Line 1279... | Line -... | ||
1279 | pixman_image_create_bits (pixman_format_code_t format, |
- | |
1280 | int width, |
- | |
1281 | int height, |
1701 | *rowstride_bytes = stride; |
1282 | uint32_t * bits, |
1702 | |
Line 1283... | Line 1703... | ||
1283 | int rowstride_bytes) |
1703 | if (clear) |
1284 | { |
1704 | return calloc (buf_size, 1); |
Line -... | Line 1705... | ||
- | 1705 | else |
|
- | 1706 | return malloc (buf_size); |
|
1285 | pixman_image_t *image; |
1707 | } |
1286 | uint32_t *free_me = NULL; |
1708 | |
1287 | 1709 | pixman_bool_t |
|
1288 | /* must be a whole number of uint32_t's |
1710 | _pixman_bits_image_init (pixman_image_t * image, |
1289 | */ |
1711 | pixman_format_code_t format, |
1290 | return_val_if_fail ( |
1712 | int width, |
1291 | bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL); |
1713 | int height, |
1292 | 1714 | uint32_t * bits, |
|
1293 | return_val_if_fail (PIXMAN_FORMAT_BPP (format) >= PIXMAN_FORMAT_DEPTH (format), NULL); |
- | |
1294 | - | ||
1295 | if (!bits && width && height) |
1715 | int rowstride, |
1296 | { |
- | |
1297 | free_me = bits = create_bits (format, width, height, &rowstride_bytes); |
1716 | pixman_bool_t clear) |
Line 1298... | Line 1717... | ||
1298 | if (!bits) |
1717 | { |
Line 1299... | Line 1718... | ||
1299 | return NULL; |
1718 | uint32_t *free_me = NULL; |
Line -... | Line 1719... | ||
- | 1719 | ||
- | 1720 | if (!bits && width && height) |
|
- | 1721 | { |
|
- | 1722 | int rowstride_bytes; |
|
- | 1723 | ||
- | 1724 | free_me = bits = create_bits (format, width, height, &rowstride_bytes, clear); |
|
- | 1725 | ||
- | 1726 | if (!bits) |
|
- | 1727 | return FALSE; |
|
- | 1728 | ||
- | 1729 | rowstride = rowstride_bytes / (int) sizeof (uint32_t); |
|
- | 1730 | } |
|
- | 1731 | ||
- | 1732 | _pixman_image_init (image); |
|
- | 1733 | ||
- | 1734 | image->type = BITS; |
|
- | 1735 | image->bits.format = format; |
|
- | 1736 | image->bits.width = width; |
|
- | 1737 | image->bits.height = height; |
|
- | 1738 | image->bits.bits = bits; |
|
- | 1739 | image->bits.free_me = free_me; |
|
- | 1740 | image->bits.read_func = NULL; |
|
- | 1741 | image->bits.write_func = NULL; |
|
- | 1742 | image->bits.rowstride = rowstride; |
|
- | 1743 | image->bits.indexed = NULL; |
|
- | 1744 | ||
- | 1745 | image->common.property_changed = bits_image_property_changed; |
|
- | 1746 | ||
- | 1747 | _pixman_image_reset_clip_region (image); |
|
- | 1748 | ||
- | 1749 | return TRUE; |
|
- | 1750 | } |
|
- | 1751 | ||
1300 | } |
1752 | static pixman_image_t * |
1301 | 1753 | create_bits_image_internal (pixman_format_code_t format, |
|
- | 1754 | int width, |
|
- | 1755 | int height, |
|
- | 1756 | uint32_t * bits, |
|
- | 1757 | int rowstride_bytes, |
|
- | 1758 | pixman_bool_t clear) |
|
- | 1759 | { |
|
- | 1760 | pixman_image_t *image; |
|
- | 1761 | ||
- | 1762 | /* must be a whole number of uint32_t's |
|
- | 1763 | */ |
|
- | 1764 | return_val_if_fail ( |
|
- | 1765 | bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL); |
|
- | 1766 | ||
- | 1767 | return_val_if_fail (PIXMAN_FORMAT_BPP (format) >= PIXMAN_FORMAT_DEPTH (format), NULL); |
|
- | 1768 | ||
- | 1769 | image = _pixman_image_allocate (); |
|
- | 1770 | ||
- | 1771 | if (!image) |
|
- | 1772 | return NULL; |
|
- | 1773 | ||
- | 1774 | if (!_pixman_bits_image_init (image, format, width, height, bits, |
|
- | 1775 | rowstride_bytes / (int) sizeof (uint32_t), |
|
- | 1776 | clear)) |
|
- | 1777 | { |
|
- | 1778 | free (image); |