merged evas image masking code from brett
[framework/uifw/evas.git] / src / modules / engines / gl_common / evas_gl_image.c
1 #include "evas_gl_private.h"
2
3 void
4 evas_gl_common_image_all_unload(Evas_GL_Context *gc)
5 {
6    Eina_List *l;
7    Evas_GL_Image *im;
8    
9    EINA_LIST_FOREACH(gc->shared->images, l, im)
10      {
11         if (im->im) evas_cache_image_unload_data(&im->im->cache_entry);
12         if (im->tex)
13           {
14              if (!im->tex->pt->dyn.img)
15                {
16                   evas_gl_common_texture_free(im->tex);
17                   im->tex = NULL;
18                }
19           }
20      }
21 }
22
23 Evas_GL_Image *
24 evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error)
25 {
26    Evas_GL_Image        *im;
27    RGBA_Image           *im_im;
28    Eina_List            *l;
29
30    im_im = evas_common_load_image_from_file(file, key, lo, error);
31    if (!im_im) return NULL;
32
33    EINA_LIST_FOREACH(gc->shared->images, l, im)
34      {
35         if (im->im == im_im)
36           {
37              evas_cache_image_drop(&im_im->cache_entry);
38              gc->shared->images = eina_list_remove_list(gc->shared->images, l);
39              gc->shared->images = eina_list_prepend(gc->shared->images, im);
40              im->references++;
41              *error = EVAS_LOAD_ERROR_NONE;
42              return im;
43           }
44      }
45
46    im = calloc(1, sizeof(Evas_GL_Image));
47    if (!im)
48      {
49         *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
50         return NULL;
51      }
52    im->references = 1;
53    im->im = im_im;
54    im->gc = gc;
55    im->references = 1;
56    im->cached = 1;
57    im->cs.space = EVAS_COLORSPACE_ARGB8888;
58    im->alpha = im->im->cache_entry.flags.alpha;
59    im->w = im->im->cache_entry.w;
60    im->h = im->im->cache_entry.h;
61    if (lo) im->load_opts = *lo;
62    gc->shared->images = eina_list_prepend(gc->shared->images, im);
63    return im;
64 }
65
66 Evas_GL_Image *
67 evas_gl_common_image_new_from_data(Evas_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, int cspace)
68 {
69    Evas_GL_Image *im;
70    Eina_List *l;
71
72    if (data)
73      {
74         EINA_LIST_FOREACH(gc->shared->images, l, im)
75           {
76              if (((void *)(im->im->image.data) == (void *)data) &&
77                  (im->im->cache_entry.w == w) &&
78                  (im->im->cache_entry.h == h))
79                {
80                   gc->shared->images = eina_list_remove_list(gc->shared->images, l);
81                   gc->shared->images = eina_list_prepend(gc->shared->images, im);
82                   im->references++;
83                   return im;
84                }
85           }
86      }
87    im = calloc(1, sizeof(Evas_GL_Image));
88    if (!im) return NULL;
89    im->references = 1;
90    im->im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
91                                                  w, h, data, alpha, cspace);
92    if (!im->im)
93      {
94         free(im);
95         return NULL;
96      }
97    im->gc = gc;
98    im->cs.space = cspace;
99    im->alpha = im->im->cache_entry.flags.alpha;
100    im->w = im->im->cache_entry.w;
101    im->h = im->im->cache_entry.h;
102    switch (cspace)
103      {
104       case EVAS_COLORSPACE_ARGB8888:
105         break;
106       case EVAS_COLORSPACE_YCBCR422P601_PL:
107       case EVAS_COLORSPACE_YCBCR422P709_PL:
108         if (im->tex) evas_gl_common_texture_free(im->tex);
109         im->tex = NULL;
110         im->cs.data = data;
111         im->cs.no_free = 1;
112         break;
113       default:
114         abort();
115         break;
116      }
117    return im;
118 }
119
120 Evas_GL_Image *
121 evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, int cspace)
122 {
123    Evas_GL_Image *im;
124
125    im = calloc(1, sizeof(Evas_GL_Image));
126    if (!im) return NULL;
127    im->references = 1;
128    im->im = (RGBA_Image *) evas_cache_image_copied_data(evas_common_image_cache_get(),
129                                                         w, h, data, alpha, cspace);
130    if (!im->im)
131      {
132         free(im);
133         return NULL;
134      }
135    im->gc = gc;
136    im->cs.space = cspace;
137    im->alpha = im->im->cache_entry.flags.alpha;
138    im->w = im->im->cache_entry.w;
139    im->h = im->im->cache_entry.h;
140    switch (cspace)
141      {
142       case EVAS_COLORSPACE_ARGB8888:
143         break;
144       case EVAS_COLORSPACE_YCBCR422P601_PL:
145       case EVAS_COLORSPACE_YCBCR422P709_PL:
146         if (im->tex) evas_gl_common_texture_free(im->tex);
147         im->tex = NULL;
148         im->cs.no_free = 0;
149         if (im->im->cache_entry.h > 0)
150           im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
151         if ((data) && (im->cs.data))
152           memcpy(im->cs.data, data, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
153         break;
154       default:
155         abort();
156         break;
157      }
158    return im;
159 }
160
161 Evas_GL_Image *
162 evas_gl_common_image_new(Evas_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int cspace)
163 {
164    Evas_GL_Image *im;
165
166    im = calloc(1, sizeof(Evas_GL_Image));
167    if (!im) return NULL;
168    im->references = 1;
169    im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
170    if (!im->im)
171      {
172         free(im);
173         return NULL;
174      }
175    im->gc = gc;
176    im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
177    im->cs.space = cspace;
178    im->alpha = im->im->cache_entry.flags.alpha;
179    im->im->cache_entry.w = w;
180    im->im->cache_entry.h = h;
181    im->w = im->im->cache_entry.w;
182    im->h = im->im->cache_entry.h;
183    evas_cache_image_colorspace(&im->im->cache_entry, cspace);
184    im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, w, h);
185    switch (cspace)
186      {
187       case EVAS_COLORSPACE_ARGB8888:
188         break;
189       case EVAS_COLORSPACE_YCBCR422P601_PL:
190       case EVAS_COLORSPACE_YCBCR422P709_PL:
191 //        if (im->tex) evas_gl_common_texture_free(im->tex);
192         im->tex = NULL;
193         im->cs.no_free = 0;
194         if (im->im->cache_entry.h > 0)
195           im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
196         break;
197       default:
198         abort();
199         break;
200      }
201    return im;
202 }
203
204 Evas_GL_Image *
205 evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha)
206 {
207    if (!im) return NULL;
208    if (im->alpha == alpha) return im;
209    im->alpha = alpha;
210    if (!im->im) return im;
211    im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
212    if (im->tex)
213      {
214         evas_gl_common_texture_free(im->tex);
215         im->tex = NULL;
216      }
217    if (!im->tex)
218      im->tex = evas_gl_common_texture_new(im->gc, im->im);
219    return im;
220 }
221
222 void
223 evas_gl_common_image_native_enable(Evas_GL_Image *im)
224 {
225    if (im->cs.data)
226      {
227         if (!im->cs.no_free) free(im->cs.data);
228         im->cs.data = NULL;
229      }
230    im->cs.no_free = 0;
231    if (im->cached)
232      {
233         im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
234         im->cached = 0;
235      }
236    if (im->im)
237      {
238         evas_cache_image_drop(&im->im->cache_entry);
239         im->im = NULL;
240      }
241    if (im->tex)
242      {
243         evas_gl_common_texture_free(im->tex);
244         im->tex = NULL;
245      }
246    
247    im->cs.space = EVAS_COLORSPACE_ARGB8888;
248    im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha, im);
249    im->tex_only = 1;
250 }
251
252 void
253 evas_gl_common_image_native_disable(Evas_GL_Image *im)
254 {
255    if (im->im)
256      {
257         evas_cache_image_drop(&im->im->cache_entry);
258         im->im = NULL;
259      }
260    if (im->tex)
261      {
262         evas_gl_common_texture_free(im->tex);
263         im->tex = NULL;
264      }
265    im->tex_only = 0;
266    
267    im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
268    im->im->cache_entry.flags.alpha = im->alpha;
269    im->cs.space = EVAS_COLORSPACE_ARGB8888;
270    evas_cache_image_colorspace(&im->im->cache_entry, im->cs.space);
271    im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, im->w, im->h);
272    if (!im->tex)
273      im->tex = evas_gl_common_texture_new(im->gc, im->im);
274 }
275
276 void
277 evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint)
278 {
279    im->scale_hint = hint;
280    // FIXME: take advantage of this even in gl (eg if image is
281    // 1600x1200 but we always use it at 800x600 or even less - drop
282    // the texture res down for "non dynamic" stuff to save memory)
283 }
284
285 void
286 evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
287 {
288    if (im->content_hint == hint) return;
289    im->content_hint = hint;
290    if (!im->gc) return;
291    if (!im->gc->shared->info.sec_image_map) return;
292    if (!im->gc->shared->info.bgra) return;
293    // does not handle yuv yet.
294    if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return;
295    if (im->content_hint == EVAS_IMAGE_CONTENT_HINT_DYNAMIC)
296      {
297         if (im->cs.data)
298           {
299              if (!im->cs.no_free) free(im->cs.data);
300              im->cs.data = NULL;
301           }
302         im->cs.no_free = 0;
303         if (im->cached)
304           {
305              im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
306              im->cached = 0;
307           }
308         if (im->im)
309           {
310              evas_cache_image_drop(&im->im->cache_entry);
311              im->im = NULL;
312           }
313         if (im->tex)
314           {
315              evas_gl_common_texture_free(im->tex);
316              im->tex = NULL;
317           }
318         im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
319         im->tex_only = 1;
320      }
321    else
322      {
323         if (im->im)
324           {
325              evas_cache_image_drop(&im->im->cache_entry);
326              im->im = NULL;
327           }
328         if (im->tex)
329           {
330              evas_gl_common_texture_free(im->tex);
331              im->tex = NULL;
332           }
333         im->tex_only = 0;
334         
335         im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
336         im->im->cache_entry.flags.alpha = im->alpha;
337         im->cs.space = EVAS_COLORSPACE_ARGB8888;
338         evas_cache_image_colorspace(&im->im->cache_entry, im->cs.space);
339         im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, im->w, im->h);
340         if (!im->tex)
341            im->tex = evas_gl_common_texture_new(im->gc, im->im);
342      }
343 }
344
345 void
346 evas_gl_common_image_free(Evas_GL_Image *im)
347 {
348    im->references--;
349    if (im->references > 0) return;
350    
351    if (im->native.func.free)
352      im->native.func.free(im->native.func.data, im);
353    
354    if (im->cs.data)
355      {
356         if (!im->cs.no_free) free(im->cs.data);
357      }
358    if (im->cached) im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
359    if (im->im) evas_cache_image_drop(&im->im->cache_entry);
360    if (im->tex) evas_gl_common_texture_free(im->tex);
361    free(im);
362 }
363
364 Evas_GL_Image *
365 evas_gl_common_image_surface_new(Evas_GL_Context *gc, unsigned int w, unsigned int h, int alpha)
366 {
367    Evas_GL_Image *im;
368
369    im = calloc(1, sizeof(Evas_GL_Image));
370    if (!im) return NULL;
371    im->references = 1;
372    im->gc = gc;
373    im->cs.space = EVAS_COLORSPACE_ARGB8888;
374    im->alpha = alpha;
375    im->w = w;
376    im->h = h;
377    im->tex = evas_gl_common_texture_render_new(gc, w, h, alpha);
378    im->tex_only = 1;
379    return im;
380 }
381
382 void
383 evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
384 {
385    if ((w == 0) && (h == 0) && (x == 0) && (y == 0))
386      {
387         w = im->w;
388         h = im->h;
389      }
390    if (im->im)
391      {
392         im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h);
393      }
394    im->dirty = 1;
395 }
396
397 static void
398 _evas_gl_common_image_update(Evas_GL_Context *gc, Evas_GL_Image *im)
399 {
400    if (!im->im) return;
401 /*   
402    if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
403        (im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
404      {
405         // SOFTWARE convert. do multi texture later
406         if ((im->cs.data) && (*((unsigned char **)im->cs.data)))
407           {
408              if (im->dirty || !im->im->image.data)
409                {
410                   free(im->im->image.data);
411                   im->im->image.data = malloc(im->im->cache_entry.w * im->im->cache_entry.h * sizeof(DATA32));
412                   if (im->im->image.data)
413                     evas_common_convert_yuv_420p_601_rgba(im->cs.data, 
414                                                           (void *)im->im->image.data,
415                                                           im->im->cache_entry.w, im->im->cache_entry.h);
416                }
417           }
418         space = EVAS_COLORSPACE_ARGB8888;
419      }
420    else
421  */
422    switch (im->cs.space)
423      {
424       case EVAS_COLORSPACE_ARGB8888:
425         if ((im->tex) && (im->dirty))
426           {
427              evas_cache_image_load_data(&im->im->cache_entry);
428              evas_gl_common_texture_update(im->tex, im->im);
429              evas_cache_image_unload_data(&im->im->cache_entry);
430           }
431         if (!im->tex)
432           {
433              evas_cache_image_load_data(&im->im->cache_entry);
434              im->tex = evas_gl_common_texture_new(gc, im->im);
435              evas_cache_image_unload_data(&im->im->cache_entry);
436           }
437         im->dirty = 0;
438         if (!im->tex) return;
439         break;
440       case EVAS_COLORSPACE_YCBCR422P601_PL:
441       case EVAS_COLORSPACE_YCBCR422P709_PL:
442         if ((im->tex) && (im->dirty))
443           {
444              evas_gl_common_texture_yuv_update(im->tex, im->cs.data,
445                                                im->im->cache_entry.w, 
446                                                im->im->cache_entry.h);
447              im->dirty = 0;
448           }
449         if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
450           {
451              im->tex = evas_gl_common_texture_yuv_new(gc, im->cs.data,
452                                                       im->im->cache_entry.w, 
453                                                       im->im->cache_entry.h);
454              im->dirty = 0;
455           }
456         if (!im->tex) return;
457         break;
458       default:
459          ERR("unhandled img format colorspace=%d", im->cs.space);
460         break;
461     }
462 }
463
464 void
465 evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im, 
466                                RGBA_Map_Point *p, int smooth, int level __UNUSED__)
467 {
468    RGBA_Draw_Context *dc;
469    int r, g, b, a;
470    int c, cx, cy, cw, ch;
471    Eina_Bool yuv = 0;
472    
473    dc = gc->dc;
474    if (dc->mul.use)
475      {
476         a = (dc->mul.col >> 24) & 0xff;
477         r = (dc->mul.col >> 16) & 0xff;
478         g = (dc->mul.col >> 8 ) & 0xff;
479         b = (dc->mul.col      ) & 0xff;
480      }
481    else
482      {
483         r = g = b = a = 255;
484      }
485    
486    _evas_gl_common_image_update(gc, im);
487
488    c = gc->dc->clip.use; 
489    cx = gc->dc->clip.x; cy = gc->dc->clip.y; 
490    cw = gc->dc->clip.w; ch = gc->dc->clip.h;
491    im->tex->im = im;
492    if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
493        (im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
494       yuv = 1;
495    evas_gl_common_context_image_map4_push(gc, im->tex, p, 
496                                           c, cx, cy, cw, ch, 
497                                           r, g, b, a, smooth, im->tex_only,
498                                           yuv);
499 }
500
501 void
502 evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth)
503 {
504    RGBA_Draw_Context *dc;
505    Evas_GL_Image *imm;
506    int r, g, b, a;
507    double ssx, ssy, ssw, ssh;
508    double mssx, mssy, mssw, mssh;
509    Cutout_Rects *rects;
510    Cutout_Rect  *rct;
511    int c, cx, cy, cw, ch;
512    int i;
513    int yuv = 0;
514    
515    if (sw < 1) sw = 1;
516    if (sh < 1) sh = 1;
517    dc = gc->dc;
518    imm = dc->mask.mask;
519    if (dc->mul.use)
520      {
521         a = (dc->mul.col >> 24) & 0xff;
522         r = (dc->mul.col >> 16) & 0xff;
523         g = (dc->mul.col >> 8 ) & 0xff;
524         b = (dc->mul.col      ) & 0xff;
525      }
526    else
527      {
528         r = g = b = a = 255;
529      }
530    
531    _evas_gl_common_image_update(gc, im);
532    if (!im->tex)
533      {
534         evas_gl_common_rect_draw(gc, dx, dy, dw, dh);
535         return;
536      }
537    if (imm)
538      {
539         _evas_gl_common_image_update(gc, imm);
540         if (!imm->tex) imm = NULL; /* Turn of mask on error */
541      }
542
543    if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
544        (im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
545      yuv = 1;
546
547    im->tex->im = im;
548    if (imm) imm->tex->im = imm;
549    if ((!gc->dc->cutout.rects) ||
550        ((gc->shared->info.tune.cutout.max > 0) &&
551            (gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
552      {
553         if (gc->dc->clip.use)
554           {
555              int nx, ny, nw, nh;
556              double scalex,scaley;
557
558              nx = dx; ny = dy; nw = dw; nh = dh;
559              RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
560                                 gc->dc->clip.x, gc->dc->clip.y,
561                                 gc->dc->clip.w, gc->dc->clip.h);
562              if ((nw < 1) || (nh < 1)) return;
563              if ((!imm) && (nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
564                {
565                   if (yuv)
566                     evas_gl_common_context_yuv_push(gc,
567                                                     im->tex,
568                                                     sx, sy, sw, sh,
569                                                     dx, dy, dw, dh,
570                                                     r, g, b, a,
571                                                     smooth);
572                   else
573                     evas_gl_common_context_image_push(gc,
574                                                       im->tex,
575                                                       sx, sy, sw, sh,
576                                                       dx, dy, dw, dh,
577                                                       r, g, b, a,
578                                                       smooth, im->tex_only);
579                   return;
580                }
581
582              ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
583              ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
584              ssw = ((double)sw * (double)(nw)) / (double)(dw);
585              ssh = ((double)sh * (double)(nh)) / (double)(dh);
586              if (imm)
587                {
588                   /* Correct ones here */
589                   scalex = imm->w / (double)dc->mask.w;
590                   scaley = imm->h / (double)dc->mask.h;
591                   mssx = scalex * (nx - dc->mask.x);
592                   mssy = scaley * (ny - dc->mask.y);
593                   mssw = scalex * nw;
594                   mssh = scaley * nh;
595
596                   /* No yuv + imm I'm afraid */
597                   evas_gl_common_context_image_mask_push(gc,
598                                                im->tex,
599                                                imm->tex,
600                                                ssx, ssy, ssw, ssh,
601                                                mssx, mssy, mssw, mssh,
602                                                //dc->mask.x, dc->mask.y, dc->mask.w, dc->mask.h,
603                                                nx, ny, nw, nh,
604                                                r, g, b, a,
605                                                smooth);
606                }
607              else if (yuv)
608                evas_gl_common_context_yuv_push(gc,
609                                                im->tex,
610                                                ssx, ssy, ssw, ssh,
611                                                nx, ny, nw, nh,
612                                                r, g, b, a,
613                                                smooth);
614              else
615                evas_gl_common_context_image_push(gc,
616                                                  im->tex,
617                                                  ssx, ssy, ssw, ssh,
618                                                  nx, ny, nw, nh,
619                                                  r, g, b, a,
620                                                  smooth, im->tex_only);
621           }
622         else
623           {
624              if (yuv)
625                evas_gl_common_context_yuv_push(gc,
626                                                im->tex,
627                                                sx, sy, sw, sh,
628                                                dx, dy, dw, dh,
629                                                r, g, b, a,
630                                                smooth);
631              else
632                evas_gl_common_context_image_push(gc,
633                                                  im->tex,
634                                                  sx, sy, sw, sh,
635                                                  dx, dy, dw, dh,
636                                                  r, g, b, a,
637                                                  smooth, im->tex_only);
638           }
639         return;
640      }
641    
642    /* save out clip info */
643    c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h;
644    evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->w, gc->h);
645    evas_common_draw_context_clip_clip(gc->dc, dx, dy, dw, dh);
646    /* our clip is 0 size.. abort */
647    if ((gc->dc->clip.w <= 0) || (gc->dc->clip.h <= 0))
648      {
649         gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
650         return;
651      }
652    rects = evas_common_draw_context_apply_cutouts(dc);
653    for (i = 0; i < rects->active; ++i)
654      {
655         int nx, ny, nw, nh;
656
657         rct = rects->rects + i;
658         nx = dx; ny = dy; nw = dw; nh = dh;
659         RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h);
660         if ((nw < 1) || (nh < 1)) continue;
661         if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
662           {
663              if (yuv)
664                evas_gl_common_context_yuv_push(gc,
665                                                im->tex,
666                                                sx, sy, sw, sh,
667                                                dx, dy, dw, dh,
668                                                r, g, b, a,
669                                                smooth);
670              else
671                evas_gl_common_context_image_push(gc,
672                                                  im->tex,
673                                                  sx, sy, sw, sh,
674                                                  dx, dy, dw, dh,
675                                                  r, g, b, a,
676                                                  smooth, im->tex_only);
677              continue;
678           }
679         ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
680         ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
681         ssw = ((double)sw * (double)(nw)) / (double)(dw);
682         ssh = ((double)sh * (double)(nh)) / (double)(dh);
683         if (yuv)
684           evas_gl_common_context_yuv_push(gc,
685                                           im->tex,
686                                           ssx, ssy, ssw, ssh,
687                                           nx, ny, nw, nh,
688                                           r, g, b, a,
689                                           smooth);
690         else
691           evas_gl_common_context_image_push(gc,
692                                             im->tex,
693                                             ssx, ssy, ssw, ssh,
694                                             nx, ny, nw, nh,
695                                             r, g, b, a,
696                                             smooth, im->tex_only);
697      }
698    evas_common_draw_context_apply_clear_cutouts(rects);
699    /* restore clip info */
700    gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
701 }
702
703
704
705 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/