diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/evas/src/lib/engines/common/evas_scale_sample.c | 418 |
1 files changed, 0 insertions, 418 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_scale_sample.c b/libraries/evas/src/lib/engines/common/evas_scale_sample.c deleted file mode 100644 index c721c5e..0000000 --- a/libraries/evas/src/lib/engines/common/evas_scale_sample.c +++ /dev/null | |||
@@ -1,418 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_blend_private.h" | ||
3 | |||
4 | void scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); | ||
5 | |||
6 | #ifndef BUILD_SCALE_SMOOTH | ||
7 | #ifdef BUILD_SCALE_SAMPLE | ||
8 | EAPI void | ||
9 | evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst, | ||
10 | RGBA_Draw_Context *dc, | ||
11 | int src_region_x, int src_region_y, | ||
12 | int src_region_w, int src_region_h, | ||
13 | int dst_region_x, int dst_region_y, | ||
14 | int dst_region_w, int dst_region_h) | ||
15 | { | ||
16 | evas_common_scale_rgba_in_to_out_clip_sample(src, dst, dc, | ||
17 | src_region_x, src_region_y, | ||
18 | src_region_w, src_region_h, | ||
19 | dst_region_x, dst_region_y, | ||
20 | dst_region_w, dst_region_h); | ||
21 | } | ||
22 | #endif | ||
23 | #endif | ||
24 | |||
25 | #ifdef BUILD_SCALE_SAMPLE | ||
26 | EAPI void | ||
27 | evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, | ||
28 | RGBA_Draw_Context *dc, | ||
29 | int src_region_x, int src_region_y, | ||
30 | int src_region_w, int src_region_h, | ||
31 | int dst_region_x, int dst_region_y, | ||
32 | int dst_region_w, int dst_region_h) | ||
33 | { | ||
34 | Cutout_Rects *rects; | ||
35 | Cutout_Rect *r; | ||
36 | int c, cx, cy, cw, ch; | ||
37 | int i; | ||
38 | /* handle cutouts here! */ | ||
39 | |||
40 | if ((dst_region_w <= 0) || (dst_region_h <= 0)) return; | ||
41 | if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) | ||
42 | return; | ||
43 | /* no cutouts - cut right to the chase */ | ||
44 | if (!dc->cutout.rects) | ||
45 | { | ||
46 | scale_rgba_in_to_out_clip_sample_internal(src, dst, dc, | ||
47 | src_region_x, src_region_y, | ||
48 | src_region_w, src_region_h, | ||
49 | dst_region_x, dst_region_y, | ||
50 | dst_region_w, dst_region_h); | ||
51 | return; | ||
52 | } | ||
53 | /* save out clip info */ | ||
54 | c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h; | ||
55 | evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h); | ||
56 | evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h); | ||
57 | /* our clip is 0 size.. abort */ | ||
58 | if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) | ||
59 | { | ||
60 | dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; | ||
61 | return; | ||
62 | } | ||
63 | rects = evas_common_draw_context_apply_cutouts(dc); | ||
64 | for (i = 0; i < rects->active; ++i) | ||
65 | { | ||
66 | r = rects->rects + i; | ||
67 | evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h); | ||
68 | scale_rgba_in_to_out_clip_sample_internal(src, dst, dc, | ||
69 | src_region_x, src_region_y, | ||
70 | src_region_w, src_region_h, | ||
71 | dst_region_x, dst_region_y, | ||
72 | dst_region_w, dst_region_h); | ||
73 | |||
74 | } | ||
75 | evas_common_draw_context_apply_clear_cutouts(rects); | ||
76 | /* restore clip info */ | ||
77 | dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch; | ||
78 | } | ||
79 | |||
80 | void | ||
81 | scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst, | ||
82 | RGBA_Draw_Context *dc, | ||
83 | int src_region_x, int src_region_y, | ||
84 | int src_region_w, int src_region_h, | ||
85 | int dst_region_x, int dst_region_y, | ||
86 | int dst_region_w, int dst_region_h) | ||
87 | { | ||
88 | int x, y; | ||
89 | int *lin_ptr; | ||
90 | DATA32 *buf, *dptr; | ||
91 | DATA32 **row_ptr; | ||
92 | DATA32 *ptr, *dst_ptr, *src_data, *dst_data; | ||
93 | int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h; | ||
94 | int m_clip_x = 0, m_clip_y = 0, m_clip_w = 0, m_clip_h = 0, mdx = 0, mdy = 0; | ||
95 | int src_w, src_h, dst_w, dst_h; | ||
96 | RGBA_Gfx_Func func; | ||
97 | RGBA_Image *maskobj = NULL; | ||
98 | DATA8 *mask = NULL; | ||
99 | |||
100 | if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h))) | ||
101 | return; | ||
102 | if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->cache_entry.w, src->cache_entry.h))) | ||
103 | return; | ||
104 | |||
105 | src_w = src->cache_entry.w; | ||
106 | src_h = src->cache_entry.h; | ||
107 | dst_w = dst->cache_entry.w; | ||
108 | dst_h = dst->cache_entry.h; | ||
109 | |||
110 | src_data = src->image.data; | ||
111 | dst_data = dst->image.data; | ||
112 | |||
113 | if (dc->clip.use) | ||
114 | { | ||
115 | dst_clip_x = dc->clip.x; | ||
116 | dst_clip_y = dc->clip.y; | ||
117 | dst_clip_w = dc->clip.w; | ||
118 | dst_clip_h = dc->clip.h; | ||
119 | if (dst_clip_x < 0) | ||
120 | { | ||
121 | dst_clip_w += dst_clip_x; | ||
122 | dst_clip_x = 0; | ||
123 | } | ||
124 | if (dst_clip_y < 0) | ||
125 | { | ||
126 | dst_clip_h += dst_clip_y; | ||
127 | dst_clip_y = 0; | ||
128 | } | ||
129 | if ((dst_clip_x + dst_clip_w) > dst_w) | ||
130 | dst_clip_w = dst_w - dst_clip_x; | ||
131 | if ((dst_clip_y + dst_clip_h) > dst_h) | ||
132 | dst_clip_h = dst_h - dst_clip_y; | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | dst_clip_x = 0; | ||
137 | dst_clip_y = 0; | ||
138 | dst_clip_w = dst_w; | ||
139 | dst_clip_h = dst_h; | ||
140 | } | ||
141 | |||
142 | if (dc->mask.mask) | ||
143 | { | ||
144 | m_clip_x = dc->mask.x; | ||
145 | m_clip_y = dc->mask.y; | ||
146 | m_clip_w = dc->mask.mask->cache_entry.w; | ||
147 | m_clip_h = dc->mask.mask->cache_entry.h; | ||
148 | RECTS_CLIP_TO_RECT(m_clip_x, m_clip_y, m_clip_w, m_clip_h, | ||
149 | dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h); | ||
150 | if ((m_clip_w <= 0) || (m_clip_h <= 0)) return; | ||
151 | dst_clip_x = m_clip_x; | ||
152 | dst_clip_y = m_clip_y; | ||
153 | dst_clip_w = m_clip_w; | ||
154 | dst_clip_h = m_clip_h; | ||
155 | } | ||
156 | |||
157 | if (dst_clip_x < dst_region_x) | ||
158 | { | ||
159 | dst_clip_w += dst_clip_x - dst_region_x; | ||
160 | dst_clip_x = dst_region_x; | ||
161 | } | ||
162 | if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w)) | ||
163 | dst_clip_w = dst_region_x + dst_region_w - dst_clip_x; | ||
164 | if (dst_clip_y < dst_region_y) | ||
165 | { | ||
166 | dst_clip_h += dst_clip_y - dst_region_y; | ||
167 | dst_clip_y = dst_region_y; | ||
168 | } | ||
169 | if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h)) | ||
170 | dst_clip_h = dst_region_y + dst_region_h - dst_clip_y; | ||
171 | |||
172 | if ((src_region_w <= 0) || (src_region_h <= 0) || | ||
173 | (dst_region_w <= 0) || (dst_region_h <= 0) || | ||
174 | (dst_clip_w <= 0) || (dst_clip_h <= 0)) | ||
175 | return; | ||
176 | |||
177 | /* sanitise x */ | ||
178 | if (src_region_x < 0) | ||
179 | { | ||
180 | dst_region_x -= (src_region_x * dst_region_w) / src_region_w; | ||
181 | dst_region_w += (src_region_x * dst_region_w) / src_region_w; | ||
182 | src_region_w += src_region_x; | ||
183 | src_region_x = 0; | ||
184 | } | ||
185 | if (src_region_x >= src_w) return; | ||
186 | if ((src_region_x + src_region_w) > src_w) | ||
187 | { | ||
188 | dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w); | ||
189 | src_region_w = src_w - src_region_x; | ||
190 | } | ||
191 | if (dst_region_w <= 0) return; | ||
192 | if (src_region_w <= 0) return; | ||
193 | if (dst_clip_x < 0) | ||
194 | { | ||
195 | dst_clip_w += dst_clip_x; | ||
196 | dst_clip_x = 0; | ||
197 | } | ||
198 | if (dst_clip_w <= 0) return; | ||
199 | if (dst_clip_x >= dst_w) return; | ||
200 | if (dst_clip_x < dst_region_x) | ||
201 | { | ||
202 | dst_clip_w += (dst_clip_x - dst_region_x); | ||
203 | dst_clip_x = dst_region_x; | ||
204 | } | ||
205 | if ((dst_clip_x + dst_clip_w) > dst_w) | ||
206 | { | ||
207 | dst_clip_w = dst_w - dst_clip_x; | ||
208 | } | ||
209 | if (dst_clip_w <= 0) return; | ||
210 | |||
211 | /* sanitise y */ | ||
212 | if (src_region_y < 0) | ||
213 | { | ||
214 | dst_region_y -= (src_region_y * dst_region_h) / src_region_h; | ||
215 | dst_region_h += (src_region_y * dst_region_h) / src_region_h; | ||
216 | src_region_h += src_region_y; | ||
217 | src_region_y = 0; | ||
218 | } | ||
219 | if (src_region_y >= src_h) return; | ||
220 | if ((src_region_y + src_region_h) > src_h) | ||
221 | { | ||
222 | dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h); | ||
223 | src_region_h = src_h - src_region_y; | ||
224 | } | ||
225 | if (dst_region_h <= 0) return; | ||
226 | if (src_region_h <= 0) return; | ||
227 | if (dst_clip_y < 0) | ||
228 | { | ||
229 | dst_clip_h += dst_clip_y; | ||
230 | dst_clip_y = 0; | ||
231 | } | ||
232 | if (dst_clip_h <= 0) return; | ||
233 | if (dst_clip_y >= dst_h) return; | ||
234 | if (dst_clip_y < dst_region_y) | ||
235 | { | ||
236 | dst_clip_h += (dst_clip_y - dst_region_y); | ||
237 | dst_clip_y = dst_region_y; | ||
238 | } | ||
239 | if ((dst_clip_y + dst_clip_h) > dst_h) | ||
240 | { | ||
241 | dst_clip_h = dst_h - dst_clip_y; | ||
242 | } | ||
243 | if (dst_clip_h <= 0) return; | ||
244 | |||
245 | /* allocate scale lookup tables */ | ||
246 | lin_ptr = alloca(dst_clip_w * sizeof(int)); | ||
247 | row_ptr = alloca(dst_clip_h * sizeof(DATA32 *)); | ||
248 | |||
249 | /* figure out dst jump */ | ||
250 | //dst_jump = dst_w - dst_clip_w; | ||
251 | |||
252 | /* figure out dest start ptr */ | ||
253 | dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w); | ||
254 | |||
255 | if (dc->mask.mask) | ||
256 | { | ||
257 | func = evas_common_gfx_func_composite_pixel_mask_span_get(src, dst, dst_clip_w, dc->render_op); | ||
258 | maskobj = dc->mask.mask; | ||
259 | mask = maskobj->mask.mask; | ||
260 | /* | ||
261 | if (1 || dst_region_w > src_region_w || dst_region_h > src_region_h){ | ||
262 | printf("Mask w/h: %d/%d\n",maskobj->cache_entry.w, | ||
263 | maskobj->cache_entry.h); | ||
264 | printf("Warning: Unscaled mask (%d/%d) // (%d/%d)\n", | ||
265 | dst_region_w,src_region_w, | ||
266 | dst_region_h,src_region_h); | ||
267 | } | ||
268 | */ | ||
269 | } | ||
270 | else if (dc->mul.use) | ||
271 | func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op); | ||
272 | else | ||
273 | func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op); | ||
274 | |||
275 | if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h)) | ||
276 | { | ||
277 | #ifdef HAVE_PIXMAN | ||
278 | # ifdef PIXMAN_IMAGE_SCALE_SAMPLE | ||
279 | if ((src->pixman.im) && (dst->pixman.im) && (!dc->mask.mask) && | ||
280 | ((!dc->mul.use) || | ||
281 | ((dc->mul.use) && (dc->mul.col == 0xffffffff))) && | ||
282 | ((dc->render_op == _EVAS_RENDER_COPY) || | ||
283 | (dc->render_op == _EVAS_RENDER_BLEND))) | ||
284 | { | ||
285 | pixman_op_t op = PIXMAN_OP_SRC; // _EVAS_RENDER_COPY | ||
286 | if (dc->render_op == _EVAS_RENDER_BLEND) | ||
287 | op = PIXMAN_OP_OVER; | ||
288 | |||
289 | pixman_image_composite(op, | ||
290 | src->pixman.im, NULL, | ||
291 | dst->pixman.im, | ||
292 | (dst_clip_x - dst_region_x) + src_region_x, | ||
293 | (dst_clip_y - dst_region_y) + src_region_y, | ||
294 | 0, 0, | ||
295 | dst_clip_x, dst_clip_y, | ||
296 | dst_clip_w, dst_clip_h); | ||
297 | } | ||
298 | else if ((src->pixman.im) && (dst->pixman.im) && | ||
299 | (dc->mask.mask) && (dc->mask.mask->pixman.im) && | ||
300 | ((dc->render_op == _EVAS_RENDER_COPY) || | ||
301 | (dc->render_op == _EVAS_RENDER_BLEND))) | ||
302 | { | ||
303 | // In case of pixel and color operation. | ||
304 | pixman_op_t op = PIXMAN_OP_SRC; // _EVAS_RENDER_COPY | ||
305 | if (dc->render_op == _EVAS_RENDER_BLEND) | ||
306 | op = PIXMAN_OP_OVER; | ||
307 | |||
308 | pixman_image_composite(op, | ||
309 | src->pixman.im, dc->mask.mask->pixman.im, | ||
310 | dst->pixman.im, | ||
311 | (dst_clip_x - dst_region_x) + src_region_x, | ||
312 | (dst_clip_y - dst_region_y) + src_region_y, | ||
313 | 0, 0, | ||
314 | dst_clip_x, dst_clip_y, | ||
315 | dst_clip_w, dst_clip_h); | ||
316 | } | ||
317 | else | ||
318 | # endif | ||
319 | #endif | ||
320 | { | ||
321 | ptr = src_data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x; | ||
322 | if (mask) | ||
323 | { | ||
324 | mdx = (m_clip_x - dc->mask.x) + (m_clip_x - dst_clip_x); | ||
325 | mdy = (m_clip_y - dc->mask.y) + (m_clip_y - dst_clip_y); | ||
326 | mask += mdx + (mdy * maskobj->cache_entry.w); | ||
327 | } | ||
328 | for (y = 0; y < dst_clip_h; y++) | ||
329 | { | ||
330 | /* * blend here [clip_w *] ptr -> dst_ptr * */ | ||
331 | #ifdef EVAS_SLI | ||
332 | if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y) | ||
333 | #endif | ||
334 | { | ||
335 | func(ptr, mask, dc->mul.col, dst_ptr, dst_clip_w); | ||
336 | } | ||
337 | ptr += src_w; | ||
338 | dst_ptr += dst_w; | ||
339 | if (mask) mask += maskobj->cache_entry.w; | ||
340 | } | ||
341 | } | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | /* fill scale tables */ | ||
346 | for (x = 0; x < dst_clip_w; x++) | ||
347 | lin_ptr[x] = (((x + dst_clip_x - dst_region_x) * src_region_w) / dst_region_w) + src_region_x; | ||
348 | for (y = 0; y < dst_clip_h; y++) | ||
349 | row_ptr[y] = src_data + (((((y + dst_clip_y - dst_region_y) * src_region_h) / dst_region_h) | ||
350 | + src_region_y) * src_w); | ||
351 | /* scale to dst */ | ||
352 | dptr = dst_ptr; | ||
353 | #ifdef DIRECT_SCALE | ||
354 | if ((!src->cache_entry.flags.alpha) && | ||
355 | (!dst->cache_entry.flags.alpha) && | ||
356 | (!dc->mul.use)) | ||
357 | { | ||
358 | for (y = 0; y < dst_clip_h; y++) | ||
359 | { | ||
360 | # ifdef EVAS_SLI | ||
361 | if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y) | ||
362 | # endif | ||
363 | { | ||
364 | dst_ptr = dptr; | ||
365 | for (x = 0; x < dst_clip_w; x++) | ||
366 | { | ||
367 | ptr = row_ptr[y] + lin_ptr[x]; | ||
368 | *dst_ptr = *ptr; | ||
369 | dst_ptr++; | ||
370 | } | ||
371 | } | ||
372 | dptr += dst_w; | ||
373 | } | ||
374 | } | ||
375 | else | ||
376 | #endif | ||
377 | { | ||
378 | /* a scanline buffer */ | ||
379 | buf = alloca(dst_clip_w * sizeof(DATA32)); | ||
380 | for (y = 0; y < dst_clip_h; y++) | ||
381 | { | ||
382 | #ifdef EVAS_SLI | ||
383 | if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y) | ||
384 | #endif | ||
385 | { | ||
386 | dst_ptr = buf; | ||
387 | for (x = 0; x < dst_clip_w; x++) | ||
388 | { | ||
389 | ptr = row_ptr[y] + lin_ptr[x]; | ||
390 | *dst_ptr = *ptr; | ||
391 | dst_ptr++; | ||
392 | } | ||
393 | /* * blend here [clip_w *] buf -> dptr * */ | ||
394 | func(buf, NULL, dc->mul.col, dptr, dst_clip_w); | ||
395 | } | ||
396 | dptr += dst_w; | ||
397 | } | ||
398 | } | ||
399 | } | ||
400 | } | ||
401 | #else | ||
402 | #ifdef BUILD_SCALE_SMOOTH | ||
403 | EAPI void | ||
404 | evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, | ||
405 | RGBA_Draw_Context *dc, | ||
406 | int src_region_x, int src_region_y, | ||
407 | int src_region_w, int src_region_h, | ||
408 | int dst_region_x, int dst_region_y, | ||
409 | int dst_region_w, int dst_region_h) | ||
410 | { | ||
411 | evas_common_scale_rgba_in_to_out_clip_smooth(src, dst, dc, | ||
412 | src_region_x, src_region_y, | ||
413 | src_region_w, src_region_h, | ||
414 | dst_region_x, dst_region_y, | ||
415 | dst_region_w, dst_region_h); | ||
416 | } | ||
417 | #endif | ||
418 | #endif | ||