move around - flatter.
[profile/ivi/evas.git] / src / lib / engines / common / evas_scale_smooth_scaler_downx.c
1 {
2    int Cx, j;
3    DATA32 *pix, *dptr, *pbuf, **yp;
4    int r, g, b, a, rr, gg, bb, aa;
5    int *xp, xap, yap, pos;
6    int dyy, dxx;
7    int w = dst_clip_w;
8 #ifdef EVAS_SLI
9    int ysli = dst_clip_y;
10 #endif
11
12    dptr = dst_ptr;
13    pos = (src_region_y * src_w) + src_region_x;
14    dyy = dst_clip_y - dst_region_y;
15    dxx = dst_clip_x - dst_region_x;
16
17    xp = xpoints + dxx;
18    yp = ypoints + dyy;
19    xapp = xapoints + dxx;
20    yapp = yapoints + dyy;
21    pbuf = buf;
22
23    if (src->cache_entry.flags.alpha)
24      {
25         while (dst_clip_h--)
26           {
27 #ifdef EVAS_SLI
28              if (((ysli) % dc->sli.h) == dc->sli.y)
29 #endif
30                {
31                   while (dst_clip_w--)
32                     {
33                        Cx = *xapp >> 16;
34                        xap = *xapp & 0xffff;
35                        pix = *yp + *xp + pos;
36
37                        a = (A_VAL(pix) * xap) >> 10;
38                        r = (R_VAL(pix) * xap) >> 10;
39                        g = (G_VAL(pix) * xap) >> 10;
40                        b = (B_VAL(pix) * xap) >> 10;
41                        for (j = (1 << 14) - xap; j > Cx; j -= Cx)
42                          {
43                             pix++;
44                             a += (A_VAL(pix) * Cx) >> 10;
45                             r += (R_VAL(pix) * Cx) >> 10;
46                             g += (G_VAL(pix) * Cx) >> 10;
47                             b += (B_VAL(pix) * Cx) >> 10;
48                          }
49                        if (j > 0)
50                          {
51                             pix++;
52                             a += (A_VAL(pix) * j) >> 10;
53                             r += (R_VAL(pix) * j) >> 10;
54                             g += (G_VAL(pix) * j) >> 10;
55                             b += (B_VAL(pix) * j) >> 10;
56                          }
57                        if ((yap = *yapp) > 0)
58                          {
59                             pix = *yp + *xp + src_w + pos;
60                             aa = (A_VAL(pix) * xap) >> 10;
61                             rr = (R_VAL(pix) * xap) >> 10;
62                             gg = (G_VAL(pix) * xap) >> 10;
63                             bb = (B_VAL(pix) * xap) >> 10;
64                             for (j = (1 << 14) - xap; j > Cx; j -= Cx)
65                               {
66                                  pix++;
67                                  aa += (A_VAL(pix) * Cx) >> 10;
68                                  rr += (R_VAL(pix) * Cx) >> 10;
69                                  gg += (G_VAL(pix) * Cx) >> 10;
70                                  bb += (B_VAL(pix) * Cx) >> 10;
71                               }
72                             if (j > 0)
73                               {
74                                  pix++;
75                                  aa += (A_VAL(pix) * j) >> 10;
76                                  rr += (R_VAL(pix) * j) >> 10;
77                                  gg += (G_VAL(pix) * j) >> 10;
78                                  bb += (B_VAL(pix) * j) >> 10;
79                               }
80                             a += ((aa - a) * yap) >> 8;
81                             r += ((rr - r) * yap) >> 8;
82                             g += ((gg - g) * yap) >> 8;
83                             b += ((bb - b) * yap) >> 8;
84                          }
85                        *pbuf++ = ARGB_JOIN(a >> 4, r >> 4, g >> 4, b >> 4);
86                        xp++;  xapp++;
87                     }
88
89                   func(buf, NULL, dc->mul.col, dptr, w);
90                }
91 #ifdef EVAS_SLI
92              ysli++;
93 #endif
94              pbuf = buf;
95              dptr += dst_w;  dst_clip_w = w;
96              yp++;  yapp++;
97              xp = xpoints + dxx;
98              xapp = xapoints + dxx;
99           }
100      }
101    else
102      {
103 #ifdef DIRECT_SCALE
104         if ((!src->cache_entry.flags.alpha) &&
105             (!dst->cache_entry.flags.alpha) &&
106             (!dc->mul.use))
107           {
108              while (dst_clip_h--)
109                {
110                   pbuf = dptr;
111 #ifdef EVAS_SLI
112                   if (((ysli) % dc->sli.h) == dc->sli.y)
113 #endif
114                     {
115                        while (dst_clip_w--)
116                          {
117                             Cx = *xapp >> 16;
118                             xap = *xapp & 0xffff;
119                             pix = *yp + *xp + pos;
120
121                             r = (R_VAL(pix) * xap) >> 10;
122                             g = (G_VAL(pix) * xap) >> 10;
123                             b = (B_VAL(pix) * xap) >> 10;
124                             for (j = (1 << 14) - xap; j > Cx; j -= Cx)
125                               {
126                                  pix++;
127                                  r += (R_VAL(pix) * Cx) >> 10;
128                                  g += (G_VAL(pix) * Cx) >> 10;
129                                  b += (B_VAL(pix) * Cx) >> 10;
130                               }
131                             if (j > 0)
132                               {
133                                  pix++;
134                                  r += (R_VAL(pix) * j) >> 10;
135                                  g += (G_VAL(pix) * j) >> 10;
136                                  b += (B_VAL(pix) * j) >> 10;
137                               }
138                             if ((yap = *yapp) > 0)
139                               {
140                                  pix = *yp + *xp + src_w + pos;
141                                  rr = (R_VAL(pix) * xap) >> 10;
142                                  gg = (G_VAL(pix) * xap) >> 10;
143                                  bb = (B_VAL(pix) * xap) >> 10;
144                                  for (j = (1 << 14) - xap; j > Cx; j -= Cx)
145                                    {
146                                       pix++;
147                                       rr += (R_VAL(pix) * Cx) >> 10;
148                                       gg += (G_VAL(pix) * Cx) >> 10;
149                                       bb += (B_VAL(pix) * Cx) >> 10;
150                                    }
151                                  if (j > 0)
152                                    {
153                                       pix++;
154                                       rr += (R_VAL(pix) * j) >> 10;
155                                       gg += (G_VAL(pix) * j) >> 10;
156                                       bb += (B_VAL(pix) * j) >> 10;
157                                    }
158                                  r += ((rr - r) * yap) >> 8;
159                                  g += ((gg - g) * yap) >> 8;
160                                  b += ((bb - b) * yap) >> 8;
161                               }
162                             *pbuf++ = ARGB_JOIN(0xff, r >> 4, g >> 4, b >> 4);
163                             xp++;  xapp++;
164                          }
165                     }
166 #ifdef EVAS_SLI
167                   ysli++;
168 #endif
169
170                   dptr += dst_w;  dst_clip_w = w;
171                   yp++;  yapp++;
172                   xp = xpoints + dxx;
173                   xapp = xapoints + dxx;
174                }
175           }
176         else
177 #endif
178           {
179              while (dst_clip_h--)
180                {
181 #ifdef EVAS_SLI
182                   if (((ysli) % dc->sli.h) == dc->sli.y)
183 #endif
184                     {
185                        while (dst_clip_w--)
186                          {
187                             Cx = *xapp >> 16;
188                             xap = *xapp & 0xffff;
189                             pix = *yp + *xp + pos;
190
191                             r = (R_VAL(pix) * xap) >> 10;
192                             g = (G_VAL(pix) * xap) >> 10;
193                             b = (B_VAL(pix) * xap) >> 10;
194                             for (j = (1 << 14) - xap; j > Cx; j -= Cx)
195                               {
196                                  pix++;
197                                  r += (R_VAL(pix) * Cx) >> 10;
198                                  g += (G_VAL(pix) * Cx) >> 10;
199                                  b += (B_VAL(pix) * Cx) >> 10;
200                               }
201                             if (j > 0)
202                               {
203                                  pix++;
204                                  r += (R_VAL(pix) * j) >> 10;
205                                  g += (G_VAL(pix) * j) >> 10;
206                                  b += (B_VAL(pix) * j) >> 10;
207                               }
208                             if ((yap = *yapp) > 0)
209                               {
210                                  pix = *yp + *xp + src_w + pos;
211                                  rr = (R_VAL(pix) * xap) >> 10;
212                                  gg = (G_VAL(pix) * xap) >> 10;
213                                  bb = (B_VAL(pix) * xap) >> 10;
214                                  for (j = (1 << 14) - xap; j > Cx; j -= Cx)
215                                    {
216                                       pix++;
217                                       rr += (R_VAL(pix) * Cx) >> 10;
218                                       gg += (G_VAL(pix) * Cx) >> 10;
219                                       bb += (B_VAL(pix) * Cx) >> 10;
220                                    }
221                                  if (j > 0)
222                                    {
223                                       pix++;
224                                       rr += (R_VAL(pix) * j) >> 10;
225                                       gg += (G_VAL(pix) * j) >> 10;
226                                       bb += (B_VAL(pix) * j) >> 10;
227                                    }
228                                  r += ((rr - r) * yap) >> 8;
229                                  g += ((gg - g) * yap) >> 8;
230                                  b += ((bb - b) * yap) >> 8;
231                               }
232                             *pbuf++ = ARGB_JOIN(0xff, r >> 4, g >> 4, b >> 4);
233                             xp++;  xapp++;
234                          }
235
236                        func(buf, NULL, dc->mul.col, dptr, w);
237                     }
238 #ifdef EVAS_SLI
239                   ysli++;
240 #endif
241
242                   pbuf = buf;
243                   dptr += dst_w;  dst_clip_w = w;
244                   yp++;  yapp++;
245                   xp = xpoints + dxx;
246                   xapp = xapoints + dxx;
247                }
248           }
249      }
250 }