2 SCALE_FUNC(RGBA_Image *src, RGBA_Image *dst,
4 int src_region_x, int src_region_y,
5 int src_region_w, int src_region_h,
6 int dst_region_x, int dst_region_y,
7 int dst_region_w, int dst_region_h)
11 int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
12 int src_w, src_h, dst_w, dst_h;
14 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)))
16 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)))
19 src_w = src->cache_entry.w;
20 src_h = src->cache_entry.h;
21 dst_w = dst->cache_entry.w;
22 dst_h = dst->cache_entry.h;
26 dst_clip_x = dc->clip.x;
27 dst_clip_y = dc->clip.y;
28 dst_clip_w = dc->clip.w;
29 dst_clip_h = dc->clip.h;
32 dst_clip_w += dst_clip_x;
37 dst_clip_h += dst_clip_y;
40 if ((dst_clip_w <= 0) || (dst_clip_h <= 0)) return;
41 if ((dst_clip_x + dst_clip_w) > dst_w) dst_clip_w = dst_w - dst_clip_x;
42 if ((dst_clip_y + dst_clip_h) > dst_h) dst_clip_h = dst_h - dst_clip_y;
52 if (dst_clip_x < dst_region_x)
54 dst_clip_w += dst_clip_x - dst_region_x;
55 dst_clip_x = dst_region_x;
57 if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w))
58 dst_clip_w = dst_region_x + dst_region_w - dst_clip_x;
59 if (dst_clip_y < dst_region_y)
61 dst_clip_h += dst_clip_y - dst_region_y;
62 dst_clip_y = dst_region_y;
64 if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h))
65 dst_clip_h = dst_region_y + dst_region_h - dst_clip_y;
67 if ((src_region_w <= 0) || (src_region_h <= 0) ||
68 (dst_region_w <= 0) || (dst_region_h <= 0) ||
69 (dst_clip_w <= 0) || (dst_clip_h <= 0))
75 dst_region_x -= (src_region_x * dst_region_w) / src_region_w;
76 dst_region_w += (src_region_x * dst_region_w) / src_region_w;
77 src_region_w += src_region_x;
80 if (src_region_x >= src_w) return;
81 if ((src_region_x + src_region_w) > src_w)
83 dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w);
84 src_region_w = src_w - src_region_x;
86 if (dst_region_w <= 0) return;
87 if (src_region_w <= 0) return;
90 dst_clip_w += dst_clip_x;
93 if (dst_clip_w <= 0) return;
94 if (dst_clip_x >= dst_w) return;
95 if (dst_clip_x < dst_region_x)
97 dst_clip_w += (dst_clip_x - dst_region_x);
98 dst_clip_x = dst_region_x;
100 if ((dst_clip_x + dst_clip_w) > dst_w)
102 dst_clip_w = dst_w - dst_clip_x;
104 if (dst_clip_w <= 0) return;
107 if (src_region_y < 0)
109 dst_region_y -= (src_region_y * dst_region_h) / src_region_h;
110 dst_region_h += (src_region_y * dst_region_h) / src_region_h;
111 src_region_h += src_region_y;
114 if (src_region_y >= src_h) return;
115 if ((src_region_y + src_region_h) > src_h)
117 dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h);
118 src_region_h = src_h - src_region_y;
120 if (dst_region_h <= 0) return;
121 if (src_region_h <= 0) return;
124 dst_clip_h += dst_clip_y;
127 if (dst_clip_h <= 0) return;
128 if (dst_clip_y >= dst_h) return;
129 if (dst_clip_y < dst_region_y)
131 dst_clip_h += (dst_clip_y - dst_region_y);
132 dst_clip_y = dst_region_y;
134 if ((dst_clip_y + dst_clip_h) > dst_h)
136 dst_clip_h = dst_h - dst_clip_y;
138 if (dst_clip_h <= 0) return;
140 /* figure out dst jump */
141 dst_jump = dst_w - dst_clip_w;
143 /* figure out dest start ptr */
144 dst_ptr = dst->image.data + dst_clip_x + (dst_clip_y * dst_w);
148 * things to do later for speedups:
150 * break upscale into 3 cases (as listed below - up:up, 1:up, up:1)
152 * break downscale into more cases (as listed below)
154 * roll func (blend/copy/cultiply/cmod) code into inner loop of scaler.
155 * (578 fps vs 550 in mmx upscale in evas demo - this means probably
156 * a good 10-15% speedup over the func call, but means massively larger
159 * anything involving downscaling has no mmx equivalent code and maybe the
160 * C could do with a little work.
162 * ---------------------------------------------------------------------------
164 * (1 = no scaling (1:1 ratio), + = scale up, - = scale down)
165 * (* == fully optimised mmx, # = fully optimised C)
184 if ((dst_region_w == src_region_w) &&
185 (dst_region_h == src_region_h))
187 #include "evas_scale_smooth_scaler_noscale.c"
191 /* scaling up only - dont need anything except original */
192 // if ((!dc->anti_alias) || ((dst_region_w >= src_region_w) && (dst_region_h >= src_region_h)))
193 if (((dst_region_w >= src_region_w) && (dst_region_h >= src_region_h)))
195 #include "evas_scale_smooth_scaler_up.c"
199 /* scaling down... funkiness */
201 #include "evas_scale_smooth_scaler_down.c"