2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "evas_common.h"
6 #include "evas_blend_private.h"
8 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);
10 #ifndef BUILD_SCALE_SMOOTH
11 #ifdef BUILD_SCALE_SAMPLE
13 evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
14 RGBA_Draw_Context *dc,
15 int src_region_x, int src_region_y,
16 int src_region_w, int src_region_h,
17 int dst_region_x, int dst_region_y,
18 int dst_region_w, int dst_region_h)
20 evas_common_scale_rgba_in_to_out_clip_sample(src, dst, dc,
21 src_region_x, src_region_y,
22 src_region_w, src_region_h,
23 dst_region_x, dst_region_y,
24 dst_region_w, dst_region_h);
29 #ifdef BUILD_SCALE_SAMPLE
31 evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
32 RGBA_Draw_Context *dc,
33 int src_region_x, int src_region_y,
34 int src_region_w, int src_region_h,
35 int dst_region_x, int dst_region_y,
36 int dst_region_w, int dst_region_h)
40 int c, cx, cy, cw, ch;
42 /* handle cutouts here! */
44 if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
45 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)))
47 /* no cutouts - cut right to the chase */
48 if (!dc->cutout.rects)
50 scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
51 src_region_x, src_region_y,
52 src_region_w, src_region_h,
53 dst_region_x, dst_region_y,
54 dst_region_w, dst_region_h);
57 /* save out clip info */
58 c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
59 evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
60 evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
61 /* our clip is 0 size.. abort */
62 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
64 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
67 rects = evas_common_draw_context_apply_cutouts(dc);
68 for (i = 0; i < rects->active; ++i)
71 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
72 scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
73 src_region_x, src_region_y,
74 src_region_w, src_region_h,
75 dst_region_x, dst_region_y,
76 dst_region_w, dst_region_h);
79 evas_common_draw_context_apply_clear_cutouts(rects);
80 /* restore clip info */
81 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
85 scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
86 RGBA_Draw_Context *dc,
87 int src_region_x, int src_region_y,
88 int src_region_w, int src_region_h,
89 int dst_region_x, int dst_region_y,
90 int dst_region_w, int dst_region_h)
96 DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
98 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
99 int src_w, src_h, dst_w, dst_h;
102 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)))
104 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)))
107 src_w = src->cache_entry.w;
108 src_h = src->cache_entry.h;
109 dst_w = dst->cache_entry.w;
110 dst_h = dst->cache_entry.h;
112 src_data = src->image.data;
113 dst_data = dst->image.data;
117 dst_clip_x = dc->clip.x;
118 dst_clip_y = dc->clip.y;
119 dst_clip_w = dc->clip.w;
120 dst_clip_h = dc->clip.h;
123 dst_clip_w += dst_clip_x;
128 dst_clip_h += dst_clip_y;
131 if ((dst_clip_x + dst_clip_w) > dst_w)
132 dst_clip_w = dst_w - dst_clip_x;
133 if ((dst_clip_y + dst_clip_h) > dst_h)
134 dst_clip_h = dst_h - dst_clip_y;
144 if (dst_clip_x < dst_region_x)
146 dst_clip_w += dst_clip_x - dst_region_x;
147 dst_clip_x = dst_region_x;
149 if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w))
150 dst_clip_w = dst_region_x + dst_region_w - dst_clip_x;
151 if (dst_clip_y < dst_region_y)
153 dst_clip_h += dst_clip_y - dst_region_y;
154 dst_clip_y = dst_region_y;
156 if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h))
157 dst_clip_h = dst_region_y + dst_region_h - dst_clip_y;
159 if ((src_region_w <= 0) || (src_region_h <= 0) ||
160 (dst_region_w <= 0) || (dst_region_h <= 0) ||
161 (dst_clip_w <= 0) || (dst_clip_h <= 0))
165 if (src_region_x < 0)
167 dst_region_x -= (src_region_x * dst_region_w) / src_region_w;
168 dst_region_w += (src_region_x * dst_region_w) / src_region_w;
169 src_region_w += src_region_x;
172 if (src_region_x >= src_w) return;
173 if ((src_region_x + src_region_w) > src_w)
175 dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w);
176 src_region_w = src_w - src_region_x;
178 if (dst_region_w <= 0) return;
179 if (src_region_w <= 0) return;
182 dst_clip_w += dst_clip_x;
185 if (dst_clip_w <= 0) return;
186 if (dst_clip_x >= dst_w) return;
187 if (dst_clip_x < dst_region_x)
189 dst_clip_w += (dst_clip_x - dst_region_x);
190 dst_clip_x = dst_region_x;
192 if ((dst_clip_x + dst_clip_w) > dst_w)
194 dst_clip_w = dst_w - dst_clip_x;
196 if (dst_clip_w <= 0) return;
199 if (src_region_y < 0)
201 dst_region_y -= (src_region_y * dst_region_h) / src_region_h;
202 dst_region_h += (src_region_y * dst_region_h) / src_region_h;
203 src_region_h += src_region_y;
206 if (src_region_y >= src_h) return;
207 if ((src_region_y + src_region_h) > src_h)
209 dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h);
210 src_region_h = src_h - src_region_y;
212 if (dst_region_h <= 0) return;
213 if (src_region_h <= 0) return;
216 dst_clip_h += dst_clip_y;
219 if (dst_clip_h <= 0) return;
220 if (dst_clip_y >= dst_h) return;
221 if (dst_clip_y < dst_region_y)
223 dst_clip_h += (dst_clip_y - dst_region_y);
224 dst_clip_y = dst_region_y;
226 if ((dst_clip_y + dst_clip_h) > dst_h)
228 dst_clip_h = dst_h - dst_clip_y;
230 if (dst_clip_h <= 0) return;
232 /* allocate scale lookup tables */
233 lin_ptr = alloca(dst_clip_w * sizeof(int));
234 row_ptr = alloca(dst_clip_h * sizeof(DATA32 *));
236 /* figure out dst jump */
237 dst_jump = dst_w - dst_clip_w;
239 /* figure out dest start ptr */
240 dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_w);
243 func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
245 func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op);
247 if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h))
249 ptr = src_data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x;
250 for (y = 0; y < dst_clip_h; y++)
252 /* * blend here [clip_w *] ptr -> dst_ptr * */
254 if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y)
257 func(ptr, NULL, dc->mul.col, dst_ptr, dst_clip_w);
265 /* fill scale tables */
266 for (x = 0; x < dst_clip_w; x++)
267 lin_ptr[x] = (((x + dst_clip_x - dst_region_x) * src_region_w) / dst_region_w) + src_region_x;
268 for (y = 0; y < dst_clip_h; y++)
269 row_ptr[y] = src_data + (((((y + dst_clip_y - dst_region_y) * src_region_h) / dst_region_h)
270 + src_region_y) * src_w);
274 if ((!src->cache_entry.flags.alpha) &&
275 (!dst->cache_entry.flags.alpha) &&
278 for (y = 0; y < dst_clip_h; y++)
281 if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y)
285 for (x = 0; x < dst_clip_w; x++)
287 ptr = row_ptr[y] + lin_ptr[x];
298 /* a scanline buffer */
299 buf = alloca(dst_clip_w * sizeof(DATA32));
300 for (y = 0; y < dst_clip_h; y++)
303 if (((y + dst_clip_y) % dc->sli.h) == dc->sli.y)
307 for (x = 0; x < dst_clip_w; x++)
309 ptr = row_ptr[y] + lin_ptr[x];
313 /* * blend here [clip_w *] buf -> dptr * */
314 func(buf, NULL, dc->mul.col, dptr, dst_clip_w);
322 #ifdef BUILD_SCALE_SMOOTH
324 evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
325 RGBA_Draw_Context *dc,
326 int src_region_x, int src_region_y,
327 int src_region_w, int src_region_h,
328 int dst_region_x, int dst_region_y,
329 int dst_region_w, int dst_region_h)
331 evas_common_scale_rgba_in_to_out_clip_smooth(src, dst, dc,
332 src_region_x, src_region_y,
333 src_region_w, src_region_h,
334 dst_region_x, dst_region_y,
335 dst_region_w, dst_region_h);