41ea0f5688bd7ccf2c0f73e111fe2817d9c7960e
[framework/uifw/evas.git] / src / lib / canvas / evas_render.c
1 #include "evas_common.h"
2 #include "evas_private.h"
3
4 // debug rendering
5 /* #define REND_DGB 1 */
6 /* #define STDOUT_DBG 1 */
7
8 #ifdef REND_DGB
9 static FILE *dbf = NULL;
10
11 static void
12 rend_dbg(const char *txt)
13 {
14    if (!dbf)
15      {
16 #ifdef STDOUT_DBG
17         dbf = stdout;
18 #else
19         dbf = fopen("EVAS-RENDER-DEBUG.log", "w");
20 #endif
21         if (!dbf) return;
22      }
23    fputs(txt, dbf);
24    fflush(dbf);
25 }
26 #define RD(args...) \
27    { \
28       char __tmpbuf[4096]; \
29       \
30       snprintf(__tmpbuf, sizeof(__tmpbuf), ##args); \
31       rend_dbg(__tmpbuf); \
32    }
33 #define RDI(xxxx) \
34    { \
35       char __tmpbuf[4096]; int __tmpi; \
36       for (__tmpi = 0; __tmpi < xxxx; __tmpi++) \
37         __tmpbuf[__tmpi] = ' '; \
38       __tmpbuf[__tmpi] = 0; \
39       rend_dbg(__tmpbuf); \
40    }
41 #else
42 #define RD(args...)
43 #define RDI(x)
44 #endif
45
46 static Eina_List *
47 evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned char do_draw);
48
49 EAPI void
50 evas_damage_rectangle_add(Evas *e, int x, int y, int w, int h)
51 {
52    Eina_Rectangle *r;
53
54    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
55    return;
56    MAGIC_CHECK_END();
57    NEW_RECT(r, x, y, w, h);
58    if (!r) return;
59    e->damages = eina_list_append(e->damages, r);
60    e->changed = 1;
61 }
62
63 EAPI void
64 evas_obscured_rectangle_add(Evas *e, int x, int y, int w, int h)
65 {
66    Eina_Rectangle *r;
67
68    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
69    return;
70    MAGIC_CHECK_END();
71    NEW_RECT(r, x, y, w, h);
72    if (!r) return;
73    e->obscures = eina_list_append(e->obscures, r);
74 }
75
76 EAPI void
77 evas_obscured_clear(Evas *e)
78 {
79    Eina_Rectangle *r;
80
81    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
82    return;
83    MAGIC_CHECK_END();
84    EINA_LIST_FREE(e->obscures, r)
85      {
86         eina_rectangle_free(r);
87      }
88 }
89
90 static Eina_Bool
91 _evas_render_has_map(Evas_Object *obj)
92 {
93    return ((!((obj->func->can_map) && (obj->func->can_map(obj)))) &&
94            ((obj->cur.map) && (obj->cur.usemap)));
95    //   return ((obj->cur.map) && (obj->cur.usemap));
96 }
97
98 static Eina_Bool
99 _evas_render_had_map(Evas_Object *obj)
100 {
101    return ((obj->prev.map) && (obj->prev.usemap));
102    //   return ((!obj->cur.map) && (obj->prev.usemap));
103 }
104
105 static Eina_Bool
106 _evas_render_is_relevant(Evas_Object *obj)
107 {
108    return ((evas_object_is_visible(obj) && (!obj->cur.have_clipees)) ||
109            (evas_object_was_visible(obj) && (!obj->prev.have_clipees)));
110 }
111
112 static Eina_Bool
113 _evas_render_can_render(Evas_Object *obj)
114 {
115    return (evas_object_is_visible(obj) && (!obj->cur.have_clipees));
116 }
117
118 static void
119 _evas_render_prev_cur_clip_cache_add(Evas *e, Evas_Object *obj)
120 {
121    e->engine.func->output_redraws_rect_add(e->engine.data.output,
122                                            obj->prev.cache.clip.x,
123                                            obj->prev.cache.clip.y,
124                                            obj->prev.cache.clip.w,
125                                            obj->prev.cache.clip.h);
126    e->engine.func->output_redraws_rect_add(e->engine.data.output,
127                                            obj->cur.cache.clip.x,
128                                            obj->cur.cache.clip.y,
129                                            obj->cur.cache.clip.w,
130                                            obj->cur.cache.clip.h);
131 }
132
133 static void
134 _evas_render_cur_clip_cache_del(Evas *e, Evas_Object *obj)
135 {
136    e->engine.func->output_redraws_rect_del(e->engine.data.output,
137                                            obj->cur.cache.clip.x,
138                                            obj->cur.cache.clip.y,
139                                            obj->cur.cache.clip.w,
140                                            obj->cur.cache.clip.h);
141 }
142
143 static void
144 _evas_render_phase1_direct(Evas *e,
145                            Eina_Array *active_objects,
146                            Eina_Array *restack_objects __UNUSED__,
147                            Eina_Array *delete_objects __UNUSED__,
148                            Eina_Array *render_objects)
149 {
150    unsigned int i;
151    Eina_List *l;
152    Evas_Object *proxy;
153
154    RD("  [--- PHASE 1 DIRECT\n");
155    for (i = 0; i < active_objects->count; i++)
156      {
157         Evas_Object *obj;
158
159         obj = eina_array_data_get(active_objects, i);
160         if (obj->changed)
161           {
162              /* Flag need redraw on proxy too */
163              evas_object_clip_recalc(obj);
164              if (obj->proxy.proxies)
165                {
166                   EINA_LIST_FOREACH(obj->proxy.proxies, l, proxy)
167                     proxy->proxy.redraw = 1;
168                }
169           }
170      }
171    for (i = 0; i < render_objects->count; i++)
172      {
173         Evas_Object *obj;
174
175         obj = eina_array_data_get(render_objects, i);
176         RD("    OBJ [%p] changed %i\n", obj, obj->changed);
177         if (obj->changed)
178           {
179              /* Flag need redraw on proxy too */
180              evas_object_clip_recalc(obj);
181              obj->func->render_pre(obj);
182              if (obj->proxy.proxies)
183                {
184                   obj->proxy.redraw = 1;
185                   EINA_LIST_FOREACH(obj->proxy.proxies, l, proxy)
186                     {
187                        proxy->func->render_pre(proxy);
188                        _evas_render_prev_cur_clip_cache_add(e, proxy);
189                     }
190                }
191              else if (obj->proxy.redraw)
192                {
193                   _evas_render_prev_cur_clip_cache_add(e, obj);
194                }
195              if (obj->pre_render_done)
196                {
197                   RD("      pre-render-done smart:%p|%p  [%p, %i] | [%p, %i] has_map:%i had_map:%i\n",
198                      obj->smart.smart,
199                      evas_object_smart_members_get_direct(obj),
200                      obj->cur.map, obj->cur.usemap,
201                      obj->prev.map, obj->prev.usemap,
202                      _evas_render_has_map(obj),
203                      _evas_render_had_map(obj));
204                   if ((obj->smart.smart) &&
205                       (_evas_render_has_map(obj)))
206                     {
207                        RD("      has map + smart\n");
208                        _evas_render_prev_cur_clip_cache_add(e, obj);
209                     }
210                }
211              else if (_evas_render_had_map(obj))
212                {
213                   RD("      no pre-render done\n");
214                   _evas_render_prev_cur_clip_cache_add(e, obj);
215                }
216           }
217         else
218           {
219              if (obj->smart.smart)
220                {
221                   //                  obj->func->render_pre(obj);
222                }
223              else if (obj->rect_del)
224                {
225                   RD("    rect del\n");
226                   _evas_render_cur_clip_cache_del(e, obj);
227                }
228           }
229      }
230    RD("  ---]\n");
231 }
232
233 static Eina_Bool
234 _evas_render_phase1_object_process(Evas *e, Evas_Object *obj,
235                                    Eina_Array *active_objects,
236                                    Eina_Array *restack_objects,
237                                    Eina_Array *delete_objects,
238                                    Eina_Array *render_objects,
239                                    int restack, int map,
240                                    int *redraw_all
241 #ifdef REND_DGB
242                                    , int level
243 #endif
244                                   )
245 {
246    Eina_Bool clean_them = EINA_FALSE;
247    Evas_Object *obj2;
248    int is_active;
249    Eina_Bool hmap;
250
251    obj->rect_del = 0;
252    obj->render_pre = 0;
253
254 #ifndef EVAS_FRAME_QUEUING
255    /* because of clip objects - delete 2 cycles later */
256    if (obj->delete_me == 2)
257 #else
258      if (obj->delete_me == evas_common_frameq_get_frameq_sz() + 2)
259 #endif
260        eina_array_push(delete_objects, obj);
261      else if (obj->delete_me != 0) obj->delete_me++;
262    /* If the object will be removed, we should not cache anything during this run. */
263    if (obj->delete_me != 0) clean_them = EINA_TRUE;
264
265    /* build active object list */
266    evas_object_clip_recalc(obj);
267    is_active = evas_object_is_active(obj);
268    obj->is_active = is_active;
269
270    RDI(level);
271    RD("    [--- PROCESS [%p] '%s' active = %i, del = %i | %i %i %ix%i\n", obj, obj->type, is_active, obj->delete_me, obj->cur.geometry.x, obj->cur.geometry.y, obj->cur.geometry.w, obj->cur.geometry.h);
272    if ((is_active) || (obj->delete_me != 0))
273      eina_array_push(active_objects, obj);
274
275 #ifdef REND_DGB
276    if (!is_active)
277      {
278         RDI(level);
279         RD("     [%p] vis: %i, cache.clip.vis: %i cache.clip.a: %i [%p]\n", obj, obj->cur.visible, obj->cur.cache.clip.visible, obj->cur.cache.clip.a, obj->func->is_visible);
280      }
281 #endif
282
283    map = _evas_render_has_map(obj);
284    hmap = _evas_render_had_map(obj);
285
286    if ((restack) && (!map))
287      {
288         if (!obj->changed)
289           {
290              eina_array_push(&e->pending_objects, obj);
291              obj->changed = 1;
292           }
293         obj->restack = 1;
294         clean_them = EINA_TRUE;
295      }
296
297    if (map)
298      {
299         RDI(level);
300         RD("      obj mapped\n");
301         if (obj->changed)
302           {
303              if (map != hmap)
304                {
305                   *redraw_all = 1;
306                }
307              evas_object_clip_recalc(obj);
308              if ((obj->restack) &&
309                  (is_active) && (!obj->clip.clipees) &&
310                  ((evas_object_is_visible(obj) && (!obj->cur.have_clipees)) ||
311                   (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
312                {
313                   eina_array_push(render_objects, obj);
314                   _evas_render_prev_cur_clip_cache_add(e, obj);
315                   obj->render_pre = 1;
316                }
317              else if ((is_active) && (!obj->clip.clipees) &&
318                       ((evas_object_is_visible(obj) && (!obj->cur.have_clipees)) ||
319                        (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
320                {
321                   eina_array_push(render_objects, obj);
322                   _evas_render_prev_cur_clip_cache_add(e, obj);
323                   obj->render_pre = 1;
324                }
325           }
326         return clean_them;
327      }
328    else if (_evas_render_had_map(obj))
329      {
330         RDI(level);
331         RD("      had map - restack objs\n");
332         //        eina_array_push(restack_objects, obj);
333         _evas_render_prev_cur_clip_cache_add(e, obj);
334         if (obj->changed)
335           {
336              if (hmap)
337                {
338                   if (!map)
339                     {
340                        if ((obj->cur.map) && (obj->cur.usemap)) map = 1;
341                     }
342                }
343              if (map != hmap)
344                {
345                   *redraw_all = 1;
346                }
347           }
348      }
349
350    /* handle normal rendering. this object knows how to handle maps */
351    if (obj->changed)
352      {
353         if (obj->smart.smart)
354           {
355              RDI(level);
356              RD("      changed + smart - render ok\n");
357              eina_array_push(render_objects, obj);
358              obj->render_pre = 1;
359              EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
360                {
361                   _evas_render_phase1_object_process(e, obj2,
362                                                      active_objects,
363                                                      restack_objects,
364                                                      delete_objects,
365                                                      render_objects,
366                                                      obj->restack,
367                                                      map,
368                                                      redraw_all
369 #ifdef REND_DGB
370                                                      , level + 1
371 #endif
372                                                     );
373                }
374           }
375         else
376           {
377              if ((is_active) && (!obj->clip.clipees) &&
378                  _evas_render_is_relevant(obj))
379                {
380                   RDI(level);
381                   RD("      relevant + active\n");
382                   if (obj->restack)
383                     eina_array_push(restack_objects, obj);
384                   else
385                     {
386                        eina_array_push(render_objects, obj);
387                        obj->render_pre = 1;
388                     }
389                }
390              else
391                {
392                   RDI(level);
393                   RD("      skip - not smart, not active or clippees or not relevant\n");
394                }
395           }
396      }
397    else
398      {
399         RD("      not changed... [%i] -> (%i %i %p %i) [%i]\n",
400            evas_object_is_visible(obj),
401            obj->cur.visible, obj->cur.cache.clip.visible, obj->smart.smart, obj->cur.cache.clip.a,
402            evas_object_was_visible(obj));
403         if ((!obj->clip.clipees) && (obj->delete_me == 0) &&
404             (_evas_render_can_render(obj) ||
405              (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
406           {
407              if (obj->smart.smart)
408                {
409                   RDI(level);
410                   RD("      smart + visible/was visible + not clip\n");
411                   eina_array_push(render_objects, obj);
412                   obj->render_pre = 1;
413                   EINA_INLIST_FOREACH
414                      (evas_object_smart_members_get_direct(obj), obj2)
415                        {
416                           _evas_render_phase1_object_process(e, obj2,
417                                                              active_objects,
418                                                              restack_objects,
419                                                              delete_objects,
420                                                              render_objects,
421                                                              restack, map,
422                                                              redraw_all
423 #ifdef REND_DGB
424                                                              , level + 1
425 #endif
426                                                             );
427                        }
428                }
429              else
430                {
431                   if (evas_object_is_opaque(obj) &&
432                       evas_object_is_visible(obj))
433                     {
434                        RDI(level);
435                        RD("      opaque + visible\n");
436                        eina_array_push(render_objects, obj);
437                        obj->rect_del = 1;
438                     }
439                   else if (evas_object_is_visible(obj))
440                     {
441                        RDI(level);
442                        RD("      visible\n");
443                        eina_array_push(render_objects, obj);
444                        obj->render_pre = 1;
445                     }
446                   else
447                     {
448                        RDI(level);
449                        RD("      skip\n");
450                     }
451                }
452           }
453         /*
454            else if (obj->smart.smart)
455            {
456            RDI(level);
457            RD("      smart + mot visible/was visible\n");
458            eina_array_push(render_objects, obj);
459            obj->render_pre = 1;
460            EINA_INLIST_FOREACH
461            (evas_object_smart_members_get_direct(obj), obj2)
462            {
463            _evas_render_phase1_object_process(e, obj2,
464            active_objects,
465            restack_objects,
466            delete_objects,
467            render_objects,
468            restack, map,
469            redraw_all
470 #ifdef REND_DGB
471 , level + 1
472 #endif
473 );
474 }
475 }
476          */
477 }
478 if (!is_active) obj->restack = 0;
479 RDI(level);
480 RD("    ---]\n");
481 return clean_them;
482 }
483
484 static Eina_Bool
485 _evas_render_phase1_process(Evas *e,
486                             Eina_Array *active_objects,
487                             Eina_Array *restack_objects,
488                             Eina_Array *delete_objects,
489                             Eina_Array *render_objects,
490                             int *redraw_all)
491 {
492    Evas_Layer *lay;
493    Eina_Bool clean_them = EINA_FALSE;
494
495    RD("  [--- PHASE 1\n");
496    EINA_INLIST_FOREACH(e->layers, lay)
497      {
498         Evas_Object *obj;
499
500         EINA_INLIST_FOREACH(lay->objects, obj)
501           {
502              clean_them |= _evas_render_phase1_object_process
503                 (e, obj, active_objects, restack_objects, delete_objects,
504                  render_objects, 0, 0, redraw_all
505 #ifdef REND_DGB
506                  , 1
507 #endif
508                 );
509           }
510      }
511    RD("  ---]\n");
512    return clean_them;
513 }
514
515 static void
516 _evas_render_check_pending_objects(Eina_Array *pending_objects, Evas *e)
517 {
518    unsigned int i;
519
520    for (i = 0; i < pending_objects->count; ++i)
521      {
522         Evas_Object *obj;
523         int is_active, ok = 0;
524
525         obj = eina_array_data_get(pending_objects, i);
526
527         if (!obj->layer) goto clean_stuff;
528
529         evas_object_clip_recalc(obj);
530         is_active = evas_object_is_active(obj);
531
532         if ((!is_active) && (!obj->is_active) && (!obj->render_pre) &&
533             (!obj->rect_del))
534           {
535              ok = 1;
536              goto clean_stuff;
537           }
538
539         if (obj->is_active == is_active)
540           {
541              if (obj->changed)
542                {
543                   if (obj->smart.smart)
544                     {
545                        if (obj->render_pre || obj->rect_del) ok = 1;
546                     }
547                   else
548                     if ((is_active) && (obj->restack) && (!obj->clip.clipees) &&
549                         (_evas_render_can_render(obj) ||
550                          (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
551                       {
552                          if (!(obj->render_pre || obj->rect_del)) ok = 1;
553                       }
554                     else
555                       if (is_active && (!obj->clip.clipees) &&
556                           (_evas_render_can_render(obj) ||
557                            (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
558                         {
559                            if (obj->render_pre || obj->rect_del) ok = 1;
560                         }
561                }
562              else
563                {
564                   if ((!obj->clip.clipees) && (obj->delete_me == 0) &&
565                       (!obj->cur.have_clipees || (evas_object_was_visible(obj) && (!obj->prev.have_clipees)))
566                       && evas_object_is_opaque(obj) && evas_object_is_visible(obj))
567                     {
568                        if (obj->rect_del || obj->smart.smart) ok = 1;
569                     }
570                }
571           }
572
573 clean_stuff:
574         if (!ok)
575           {
576              eina_array_clean(&e->active_objects);
577              eina_array_clean(&e->render_objects);
578              eina_array_clean(&e->restack_objects);
579              eina_array_clean(&e->delete_objects);
580              e->invalidate = 1;
581              return ;
582           }
583      }
584 }
585
586 Eina_Bool
587 pending_change(void *data, void *gdata __UNUSED__)
588 {
589    Evas_Object *obj;
590
591    obj = data;
592    if (obj->delete_me) return EINA_FALSE;
593    if (obj->pre_render_done)
594      {
595         RD("  OBJ [%p] pending change %i -> 0, pre %i\n", obj, obj->changed, obj->pre_render_done);
596         obj->pre_render_done = 0;
597         //// FIXME: this wipes out changes
598         obj->changed = 0;
599         obj->changed_move_only = 0;
600         obj->changed_nomove = 0;
601         obj->changed_move = 0;
602      }
603    return obj->changed ? EINA_TRUE : EINA_FALSE;
604 }
605 /*
606    static void
607    unchange(Evas_Object *obj)
608    {
609    Evas_Object *obj2;
610
611    if (!obj->changed) return;
612    obj->changed = 0;
613    obj->changed_move_only = 0;
614    obj->changed_nomove = 0;
615    obj->changed_move = 0;
616    EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
617    {
618    unchange(obj2);
619    }
620    }
621
622    static int
623    chlist(Evas_Object *obj, int i)
624    {
625    Evas_Object *obj2;
626    int j;
627    int ret = 0;
628
629    if (!obj->changed) return 0;
630    for (j = 0; j < i; j++) printf(" ");
631    printf("ch2 %p %s %i [%i %i %ix%i] v %i/%i [r%i] %p\n", obj,
632    obj->type,
633    obj->changed_move_only,
634    obj->cur.geometry.x,
635    obj->cur.geometry.y,
636    obj->cur.geometry.w,
637    obj->cur.geometry.h,
638    obj->cur.visible,
639    obj->prev.visible,
640    obj->restack,
641    obj->clip.clipees);
642    EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
643    {
644    if (obj2->changed)
645    ret |= chlist(obj2, i + 1);
646    }
647    }
648  */
649
650 Eina_Bool
651 evas_render_mapped(Evas *e, Evas_Object *obj, void *context, void *surface,
652                    int off_x, int off_y, int mapped,
653                    int ecx, int ecy, int ecw, int ech
654 #ifdef REND_DGB
655                    , int level
656 #endif
657                   )
658 {
659    void *ctx;
660    Evas_Object *obj2;
661    Eina_Bool clean_them = EINA_FALSE;
662
663    evas_object_clip_recalc(obj);
664    RDI(level);
665    RD("      { evas_render_mapped(%p, %p,   %p, %p,   %i, %i,   %i,   %i)\n", e, obj, context, surface, off_x, off_y, mapped, level);
666    if (mapped)
667      {
668         if ((!evas_object_is_visible(obj)) || (obj->clip.clipees) ||
669             (obj->cur.have_clipees))
670           {
671              RDI(level);
672              RD("      }\n");
673              return clean_them;
674           }
675      }
676    else if (!(((evas_object_is_active(obj) && (!obj->clip.clipees) &&
677                 (_evas_render_can_render(obj))))
678              ))
679      {
680         RDI(level);
681         RD("      }\n");
682         return clean_them;
683      }
684
685    // set render_pre - for child objs that may not have gotten it.
686    obj->pre_render_done = 1;
687    RD("          Hasmap: %p (%d) %p %d -> %d\n",obj->func->can_map,
688       obj->func->can_map ? obj->func->can_map(obj): -1,
689       obj->cur.map, obj->cur.usemap,
690       _evas_render_has_map(obj));
691    if (_evas_render_has_map(obj))
692      {
693         const Evas_Map_Point *p, *p_end;
694         RGBA_Map_Point pts[4], *pt;
695         int sw, sh;
696         int changed = 0, rendered = 0;
697
698         clean_them = EINA_TRUE;
699
700         sw = obj->cur.geometry.w;
701         sh = obj->cur.geometry.h;
702         RDI(level);
703         RD("        mapped obj: %ix%i\n", sw, sh);
704         if ((sw <= 0) || (sh <= 0))
705           {
706              RDI(level);
707              RD("      }\n");
708              return clean_them;
709           }
710
711         pts[0].px = obj->cur.map->persp.px << FP;
712         pts[0].py = obj->cur.map->persp.py << FP;
713         pts[0].foc = obj->cur.map->persp.foc << FP;
714         pts[0].z0 = obj->cur.map->persp.z0 << FP;
715
716         p = obj->cur.map->points;
717         p_end = p + obj->cur.map->count;
718         pt = pts;
719         for (; p < p_end; p++, pt++)
720           {
721              pt->x = (p->x + (double)off_x) * FP1;
722              pt->y = (p->y + (double)off_y) * FP1;
723              pt->z = (p->z)                 * FP1;
724              pt->fx = p->px;
725              pt->fy = p->py;
726              pt->fz = p->z;
727              pt->u = p->u * FP1;
728              pt->v = p->v * FP1;
729              if      (pt->u < 0) pt->u = 0;
730              else if (pt->u > (sw * FP1)) pt->u = (sw * FP1);
731              if      (pt->v < 0) pt->v = 0;
732              else if (pt->v > (sh * FP1)) pt->v = (sh * FP1);
733              pt->col = ARGB_JOIN(p->a, p->r, p->g, p->b);
734           }
735         /* Copy last for software engine */
736         if (obj->cur.map->count & 0x1)
737           {
738              pts[obj->cur.map->count] = pts[obj->cur.map->count - 1];
739           }
740
741
742         if (obj->cur.map->surface)
743           {
744              if ((obj->cur.map->surface_w != sw) ||
745                  (obj->cur.map->surface_h != sh))
746                {
747                   RDI(level);
748                   RD("        new surf: %ix%i\n", sw, sh);
749                   obj->layer->evas->engine.func->image_map_surface_free
750                      (e->engine.data.output, obj->cur.map->surface);
751                   obj->cur.map->surface = NULL;
752                }
753           }
754         if (!obj->cur.map->surface)
755           {
756              obj->cur.map->surface_w = sw;
757              obj->cur.map->surface_h = sh;
758
759              obj->cur.map->surface =
760                 obj->layer->evas->engine.func->image_map_surface_new
761                 (e->engine.data.output, obj->cur.map->surface_w,
762                  obj->cur.map->surface_h,
763                  obj->cur.map->alpha);
764              RDI(level);
765              RD("        fisrt surf: %ix%i\n", sw, sh);
766              changed = 1;
767           }
768         if (obj->smart.smart)
769           {
770              Evas_Object *o2;
771
772              EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), o2)
773                {
774                   if (!evas_object_is_visible(o2) &&
775                       !evas_object_was_visible(o2))
776                     {
777                        o2->changed = 0;
778                        o2->changed_move_only = 0;
779                        o2->changed_nomove = 0;
780                        o2->changed_move = 0;
781                        continue;
782                     }
783                   if (o2->changed)
784                     {
785                        //                       chlist(o2, 0);
786                        changed = 1;
787                        o2->changed = 0;
788                        o2->changed_move_only = 0;
789                        o2->changed_nomove = 0;
790                        o2->changed_move = 0;
791                        break;
792                     }
793                }
794              //             unchange(obj);
795              obj->changed = 0;
796              obj->changed_move_only = 0;
797              obj->changed_nomove = 0;
798              obj->changed_move = 0;
799           }
800         else
801           {
802              if (obj->changed)
803                {
804                   changed = 1;
805                   obj->changed = 0;
806                   obj->changed_move_only = 0;
807                   obj->changed_nomove = 0;
808                   obj->changed_move = 0;
809                }
810           }
811
812         // clear surface before re-render
813         if ((changed) && (obj->cur.map->surface))
814           {
815              int off_x2, off_y2;
816
817              RDI(level);
818              RD("        children redraw\n");
819              // FIXME: calculate "changes" within map surface and only clear
820              // and re-render those
821              if (obj->cur.map->alpha)
822                {
823                   ctx = e->engine.func->context_new(e->engine.data.output);
824                   e->engine.func->context_color_set
825                      (e->engine.data.output, ctx, 0, 0, 0, 0);
826                   e->engine.func->context_render_op_set
827                      (e->engine.data.output, ctx, EVAS_RENDER_COPY);
828                   e->engine.func->rectangle_draw(e->engine.data.output,
829                                                  ctx,
830                                                  obj->cur.map->surface,
831                                                  0, 0,
832                                                  obj->cur.map->surface_w,
833                                                  obj->cur.map->surface_h);
834                   e->engine.func->context_free(e->engine.data.output, ctx);
835                }
836              ctx = e->engine.func->context_new(e->engine.data.output);
837              off_x2 = -obj->cur.geometry.x;
838              off_y2 = -obj->cur.geometry.y;
839              if (obj->smart.smart)
840                {
841                   EINA_INLIST_FOREACH
842                      (evas_object_smart_members_get_direct(obj), obj2)
843                        {
844                           clean_them |= evas_render_mapped(e, obj2, ctx,
845                                                            obj->cur.map->surface,
846                                                            off_x2, off_y2, 1,
847                                                            ecx, ecy, ecw, ech
848 #ifdef REND_DGB
849                                                            , level + 1
850 #endif
851                                                           );
852                        }
853                }
854              else
855                {
856                   int x = 0, y = 0, w = 0, h = 0;
857
858                   w = obj->cur.map->surface_w;
859                   h = obj->cur.map->surface_h;
860                   RECTS_CLIP_TO_RECT(x, y, w, h,
861                                      obj->cur.geometry.x + off_x2,
862                                      obj->cur.geometry.y + off_y2,
863                                      obj->cur.geometry.w,
864                                      obj->cur.geometry.h);
865
866                   e->engine.func->context_clip_set(e->engine.data.output,
867                                                    ctx, x, y, w, h);
868                   obj->func->render(obj, e->engine.data.output, ctx,
869                                     obj->cur.map->surface, off_x2, off_y2);
870                }
871              e->engine.func->context_free(e->engine.data.output, ctx);
872              rendered = 1;
873           }
874
875         RDI(level);
876         RD("        draw map\n");
877
878         if (rendered)
879           {
880              obj->cur.map->surface = e->engine.func->image_dirty_region
881                 (e->engine.data.output, obj->cur.map->surface,
882                  0, 0, obj->cur.map->surface_w, obj->cur.map->surface_h);
883           }
884         e->engine.func->context_clip_unset(e->engine.data.output,
885                                            e->engine.data.context);
886         if (obj->cur.map->surface)
887           {
888              if (obj->smart.smart)
889                {
890                   if (obj->cur.clipper)
891                     {
892                        int x, y, w, h;
893                        Evas_Object *tobj;
894
895                        obj->cur.cache.clip.dirty = 1;
896                        tobj = obj->cur.map_parent;
897                        obj->cur.map_parent = obj->cur.clipper->cur.map_parent;
898                        evas_object_clip_recalc(obj);
899                        obj->cur.map_parent = tobj;
900                        x = obj->cur.cache.clip.x;
901                        y = obj->cur.cache.clip.y;
902                        w = obj->cur.cache.clip.w;
903                        h = obj->cur.cache.clip.h;
904                        RECTS_CLIP_TO_RECT(x, y, w, h,
905                                           obj->cur.clipper->cur.cache.clip.x,
906                                           obj->cur.clipper->cur.cache.clip.y,
907                                           obj->cur.clipper->cur.cache.clip.w,
908                                           obj->cur.clipper->cur.cache.clip.h);
909                        e->engine.func->context_clip_set(e->engine.data.output,
910                                                         e->engine.data.context,
911                                                         x + off_x, y + off_y, w, h);
912                     }
913                }
914              else
915                {
916                   if (obj->cur.clipper)
917                     {
918                        int x, y, w, h;
919
920                        evas_object_clip_recalc(obj);
921                        x = obj->cur.cache.clip.x;
922                        y = obj->cur.cache.clip.y;
923                        w = obj->cur.cache.clip.w;
924                        h = obj->cur.cache.clip.h;
925                        RECTS_CLIP_TO_RECT(x, y, w, h,
926                                           obj->cur.clipper->cur.cache.clip.x,
927                                           obj->cur.clipper->cur.cache.clip.y,
928                                           obj->cur.clipper->cur.cache.clip.w,
929                                           obj->cur.clipper->cur.cache.clip.h);
930                        e->engine.func->context_clip_set(e->engine.data.output,
931                                                         e->engine.data.context,
932                                                         x + off_x, y + off_y, w, h);
933                     }
934                }
935           }
936         if (surface == e->engine.data.output)
937           e->engine.func->context_clip_clip(e->engine.data.output,
938                                             e->engine.data.context,
939                                             ecx, ecy, ecw, ech);
940         if (obj->cur.cache.clip.visible)
941           obj->layer->evas->engine.func->image_map_draw
942              (e->engine.data.output, e->engine.data.context, surface,
943               obj->cur.map->surface, obj->cur.map->count, pts,
944               obj->cur.map->smooth, 0);
945         // FIXME: needs to cache these maps and
946         // keep them only rendering updates
947         //        obj->layer->evas->engine.func->image_map_surface_free
948         //          (e->engine.data.output, obj->cur.map->surface);
949         //        obj->cur.map->surface = NULL;
950      }
951    else
952      {
953         if (mapped)
954           {
955              RDI(level);
956              RD("        draw child of mapped obj\n");
957              ctx = e->engine.func->context_new(e->engine.data.output);
958              if (obj->smart.smart)
959                {
960                   EINA_INLIST_FOREACH
961                      (evas_object_smart_members_get_direct(obj), obj2)
962                        {
963                           clean_them |= evas_render_mapped(e, obj2, ctx,
964                                                            surface,
965                                                            off_x, off_y, 1,
966                                                            ecx, ecy, ecw, ech
967 #ifdef REND_DGB
968                                                            , level + 1
969 #endif
970                                                           );
971                        }
972                }
973              else
974                {
975                   if (!obj->cur.map)
976                     {
977                        int x, y, w, h;
978
979                        RDI(level);
980
981                        x = obj->cur.cache.clip.x + off_x;
982                        y = obj->cur.cache.clip.y + off_y;
983                        w = obj->cur.cache.clip.w;
984                        h = obj->cur.cache.clip.h;
985
986                        if (obj->cur.clipper)
987                          {
988                             if (_evas_render_has_map(obj))
989                               evas_object_clip_recalc(obj);
990
991                             RD("        clipper: %i %i %ix%i\n",
992                                obj->cur.clipper->cur.cache.clip.x + off_x,
993                                obj->cur.clipper->cur.cache.clip.y + off_y,
994                                obj->cur.clipper->cur.cache.clip.w,
995                                obj->cur.clipper->cur.cache.clip.h);
996
997                             RECTS_CLIP_TO_RECT(x, y, w, h,
998                                                obj->cur.clipper->cur.cache.clip.x + off_x,
999                                                obj->cur.clipper->cur.cache.clip.y + off_y,
1000                                                obj->cur.clipper->cur.cache.clip.w,
1001                                                obj->cur.clipper->cur.cache.clip.h);
1002                          }
1003
1004                        RD("        clip: %i %i %ix%i [%i %i %ix%i]\n",
1005                           obj->cur.cache.clip.x + off_x,
1006                           obj->cur.cache.clip.y + off_y,
1007                           obj->cur.cache.clip.w,
1008                           obj->cur.cache.clip.h,
1009                           obj->cur.geometry.x + off_x,
1010                           obj->cur.geometry.y + off_y,
1011                           obj->cur.geometry.w,
1012                           obj->cur.geometry.h);
1013                        e->engine.func->context_clip_set(e->engine.data.output,
1014                                                         ctx, x, y, w, h);
1015                     }
1016                   else
1017                     {
1018                        RDI(level);
1019                        RD("        noclip\n");
1020                     }
1021                   obj->func->render(obj, e->engine.data.output, ctx,
1022                                     surface, off_x, off_y);
1023                   /*
1024                                       obj->layer->evas->engine.func->context_color_set(e->engine.data.output,
1025                                       ctx,
1026                                       0, 30, 0, 30);
1027                                       obj->layer->evas->engine.func->rectangle_draw(e->engine.data.output,
1028                                       ctx,
1029                                       surface,
1030                                       0, 0, 9999, 9999);
1031                    */
1032                }
1033              e->engine.func->context_free(e->engine.data.output, ctx);
1034           }
1035         else
1036           {
1037              if (obj->cur.clipper)
1038                {
1039                   int x, y, w, h;
1040
1041                   if (_evas_render_has_map(obj))
1042                     evas_object_clip_recalc(obj);
1043                   x = obj->cur.cache.clip.x;
1044                   y = obj->cur.cache.clip.y;
1045                   w = obj->cur.cache.clip.w;
1046                   h = obj->cur.cache.clip.h;
1047                   RECTS_CLIP_TO_RECT(x, y, w, h,
1048                                      obj->cur.clipper->cur.cache.clip.x,
1049                                      obj->cur.clipper->cur.cache.clip.y,
1050                                      obj->cur.clipper->cur.cache.clip.w,
1051                                      obj->cur.clipper->cur.cache.clip.h);
1052                   e->engine.func->context_clip_set(e->engine.data.output,
1053                                                    e->engine.data.context,
1054                                                    x + off_x, y + off_y, w, h);
1055                   e->engine.func->context_clip_clip(e->engine.data.output,
1056                                                     e->engine.data.context,
1057                                                     ecx, ecy, ecw, ech);
1058                }
1059
1060              RDI(level);
1061              RD("        draw normal obj\n");
1062              obj->func->render(obj, e->engine.data.output, context, surface,
1063                                off_x, off_y);
1064           }
1065      }
1066    RDI(level);
1067    RD("      }\n");
1068
1069    return clean_them;
1070 }
1071
1072 static Eina_List *
1073 evas_render_updates_internal(Evas *e,
1074                              unsigned char make_updates,
1075                              unsigned char do_draw)
1076 {
1077    Eina_List *updates = NULL;
1078    Eina_List *ll;
1079    void *surface;
1080    Eina_Bool clean_them = EINA_FALSE;
1081    Eina_Bool alpha;
1082    Eina_Rectangle *r;
1083    int ux, uy, uw, uh;
1084    int cx, cy, cw, ch;
1085    unsigned int i, j;
1086    int haveup = 0;
1087    int redraw_all = 0;
1088
1089    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1090    return NULL;
1091    MAGIC_CHECK_END();
1092    if (!e->changed) return NULL;
1093
1094    evas_call_smarts_calculate(e);
1095
1096    RD("[--- RENDER EVAS (size: %ix%i)\n", e->viewport.w, e->viewport.h);
1097
1098    /* Check if the modified object mean recalculating every thing */
1099    if (!e->invalidate)
1100      _evas_render_check_pending_objects(&e->pending_objects, e);
1101
1102    /* phase 1. add extra updates for changed objects */
1103    if (e->invalidate || e->render_objects.count <= 0)
1104      clean_them = _evas_render_phase1_process(e,
1105                                               &e->active_objects,
1106                                               &e->restack_objects,
1107                                               &e->delete_objects,
1108                                               &e->render_objects,
1109                                               &redraw_all);
1110
1111    _evas_render_phase1_direct(e, &e->active_objects, &e->restack_objects,
1112                               &e->delete_objects, &e->render_objects);
1113
1114    /* phase 2. force updates for restacks */
1115    for (i = 0; i < e->restack_objects.count; ++i)
1116      {
1117         Evas_Object *obj;
1118
1119         obj = eina_array_data_get(&e->restack_objects, i);
1120         obj->func->render_pre(obj);
1121         _evas_render_prev_cur_clip_cache_add(e, obj);
1122      }
1123    eina_array_clean(&e->restack_objects);
1124    /* phase 3. add exposes */
1125    EINA_LIST_FREE(e->damages, r)
1126      {
1127         e->engine.func->output_redraws_rect_add(e->engine.data.output,
1128                                                 r->x, r->y, r->w, r->h);
1129         eina_rectangle_free(r);
1130      }
1131    /* phase 4. output & viewport changes */
1132    if (e->viewport.changed)
1133      {
1134         e->engine.func->output_redraws_rect_add(e->engine.data.output,
1135                                                 0, 0,
1136                                                 e->output.w, e->output.h);
1137      }
1138    if (e->output.changed)
1139      {
1140         e->engine.func->output_resize(e->engine.data.output,
1141                                       e->output.w, e->output.h);
1142         e->engine.func->output_redraws_rect_add(e->engine.data.output,
1143                                                 0, 0,
1144                                                 e->output.w, e->output.h);
1145      }
1146    if ((e->output.w != e->viewport.w) || (e->output.h != e->viewport.h))
1147      {
1148         ERR("viewport size != output size!");
1149      }
1150    if (redraw_all)
1151      {
1152         e->engine.func->output_redraws_rect_add(e->engine.data.output,
1153                                                 0, 0,
1154                                                 e->output.w, e->output.h);
1155      }
1156    /* phase 5. add obscures */
1157    EINA_LIST_FOREACH(e->obscures, ll, r)
1158      {
1159         e->engine.func->output_redraws_rect_del(e->engine.data.output,
1160                                                 r->x, r->y, r->w, r->h);
1161      }
1162    /* build obscure objects list of active objects that obscure */
1163    for (i = 0; i < e->active_objects.count; ++i)
1164      {
1165         Evas_Object *obj;
1166
1167         obj = eina_array_data_get(&e->active_objects, i);
1168         if (UNLIKELY((evas_object_is_opaque(obj) ||
1169                       ((obj->func->has_opaque_rect) &&
1170                        (obj->func->has_opaque_rect(obj)))) &&
1171                      evas_object_is_visible(obj) &&
1172                      (!obj->clip.clipees) &&
1173                      (obj->cur.visible) &&
1174                      (!obj->delete_me) &&
1175                      (obj->cur.cache.clip.visible) &&
1176                      (!obj->smart.smart)))
1177           /*      obscuring_objects = eina_list_append(obscuring_objects, obj); */
1178           eina_array_push(&e->obscuring_objects, obj);
1179      }
1180    /* save this list */
1181    /*    obscuring_objects_orig = obscuring_objects; */
1182    /*    obscuring_objects = NULL; */
1183    /* phase 6. go thru each update rect and render objects in it*/
1184    if (do_draw)
1185      {
1186         unsigned int offset = 0;
1187
1188         alpha = e->engine.func->canvas_alpha_get(e->engine.data.output,
1189                                                  e->engine.data.context);
1190         while ((surface =
1191                 e->engine.func->output_redraws_next_update_get
1192                 (e->engine.data.output,
1193                  &ux, &uy, &uw, &uh,
1194                  &cx, &cy, &cw, &ch)))
1195           {
1196              int off_x, off_y;
1197
1198              RD("  [--- UPDATE %i %i %ix%i\n", ux, uy, uw, uh);
1199              if (make_updates)
1200                {
1201                   Eina_Rectangle *rect;
1202
1203                   NEW_RECT(rect, ux, uy, uw, uh);
1204                   if (rect)
1205                     updates = eina_list_append(updates, rect);
1206                }
1207              haveup = 1;
1208              off_x = cx - ux;
1209              off_y = cy - uy;
1210              /* build obscuring objects list (in order from bottom to top) */
1211              for (i = 0; i < e->obscuring_objects.count; ++i)
1212                {
1213                   Evas_Object *obj;
1214
1215                   obj = (Evas_Object *)eina_array_data_get
1216                      (&e->obscuring_objects, i);
1217                   if (evas_object_is_in_output_rect(obj, ux, uy, uw, uh))
1218                     {
1219                        eina_array_push(&e->temporary_objects, obj);
1220
1221                        /* reset the background of the area if needed (using cutout and engine alpha flag to help) */
1222                        if (alpha)
1223                          {
1224                             if (evas_object_is_opaque(obj))
1225                               e->engine.func->context_cutout_add
1226                                  (e->engine.data.output,
1227                                   e->engine.data.context,
1228                                   obj->cur.cache.clip.x + off_x,
1229                                   obj->cur.cache.clip.y + off_y,
1230                                   obj->cur.cache.clip.w,
1231                                   obj->cur.cache.clip.h);
1232                             else
1233                               {
1234                                  if (obj->func->get_opaque_rect)
1235                                    {
1236                                       Evas_Coord obx, oby, obw, obh;
1237
1238                                       obj->func->get_opaque_rect
1239                                          (obj, &obx, &oby, &obw, &obh);
1240                                       if ((obw > 0) && (obh > 0))
1241                                         {
1242                                            obx += off_x;
1243                                            oby += off_y;
1244                                            RECTS_CLIP_TO_RECT
1245                                               (obx, oby, obw, obh,
1246                                                obj->cur.cache.clip.x + off_x,
1247                                                obj->cur.cache.clip.y + off_y,
1248                                                obj->cur.cache.clip.w,
1249                                                obj->cur.cache.clip.h);
1250                                            e->engine.func->context_cutout_add
1251                                               (e->engine.data.output,
1252                                                e->engine.data.context,
1253                                                obx, oby,
1254                                                obw, obh);
1255                                         }
1256                                    }
1257                               }
1258                          }
1259                     }
1260                }
1261              if (alpha)
1262                {
1263                   e->engine.func->context_clip_set(e->engine.data.output,
1264                                                    e->engine.data.context,
1265                                                    ux + off_x, uy + off_y, uw, uh);
1266                   e->engine.func->context_color_set(e->engine.data.output,
1267                                                     e->engine.data.context,
1268                                                     0, 0, 0, 0);
1269                   e->engine.func->context_multiplier_unset
1270                      (e->engine.data.output, e->engine.data.context);
1271                   e->engine.func->context_render_op_set(e->engine.data.output,
1272                                                         e->engine.data.context,
1273                                                         EVAS_RENDER_COPY);
1274                   e->engine.func->rectangle_draw(e->engine.data.output,
1275                                                  e->engine.data.context,
1276                                                  surface,
1277                                                  cx, cy, cw, ch);
1278                   e->engine.func->context_cutout_clear(e->engine.data.output,
1279                                                        e->engine.data.context);
1280                   e->engine.func->context_clip_unset(e->engine.data.output,
1281                                                      e->engine.data.context);
1282                }
1283              /* render all object that intersect with rect */
1284              for (i = 0; i < e->active_objects.count; ++i)
1285                {
1286                   Evas_Object *obj;
1287
1288                   obj = eina_array_data_get(&e->active_objects, i);
1289
1290                   /* if it's in our outpout rect and it doesn't clip anything */
1291                   RD("    OBJ: [%p] '%s' %i %i %ix%i\n", obj, obj->type, obj->cur.geometry.x, obj->cur.geometry.y, obj->cur.geometry.w, obj->cur.geometry.h);
1292                   if ((evas_object_is_in_output_rect(obj, ux, uy, uw, uh) ||
1293                        (obj->smart.smart)) &&
1294                       (!obj->clip.clipees) &&
1295                       (obj->cur.visible) &&
1296                       (!obj->delete_me) &&
1297                       (obj->cur.cache.clip.visible) &&
1298                       //                      (!obj->smart.smart) &&
1299                       ((obj->cur.color.a > 0 || obj->cur.render_op != EVAS_RENDER_BLEND)))
1300                     {
1301                        int x, y, w, h;
1302
1303                        RD("      DRAW (vis: %i, a: %i, clipees: %p\n", obj->cur.visible, obj->cur.color.a, obj->clip.clipees);
1304                        if ((e->temporary_objects.count > offset) &&
1305                            (eina_array_data_get(&e->temporary_objects, offset) == obj))
1306                          offset++;
1307                        x = cx; y = cy; w = cw; h = ch;
1308                        if (((w > 0) && (h > 0)) || (obj->smart.smart))
1309                          {
1310                             if (!obj->smart.smart)
1311                               {
1312                                  RECTS_CLIP_TO_RECT(x, y, w, h,
1313                                                     obj->cur.cache.clip.x + off_x,
1314                                                     obj->cur.cache.clip.y + off_y,
1315                                                     obj->cur.cache.clip.w,
1316                                                     obj->cur.cache.clip.h);
1317                               }
1318                             if (obj->cur.mask)
1319                               e->engine.func->context_mask_set(e->engine.data.output,
1320                                                                e->engine.data.context,
1321                                                                obj->cur.mask->func->engine_data_get(obj->cur.mask),
1322                                                                obj->cur.mask->cur.geometry.x + off_x,
1323                                                                obj->cur.mask->cur.geometry.y + off_y,
1324                                                                obj->cur.mask->cur.geometry.w,
1325                                                                obj->cur.mask->cur.geometry.h);
1326                             else
1327                               e->engine.func->context_mask_unset(e->engine.data.output,
1328                                                                  e->engine.data.context);
1329                             if (obj->cur.clipper)
1330                               e->engine.func->context_clip_set(e->engine.data.output,
1331                                                                e->engine.data.context,
1332                                                                x, y, w, h);
1333                             else
1334                               e->engine.func->context_clip_unset(e->engine.data.output,
1335                                                                  e->engine.data.context);
1336 #if 1 /* FIXME: this can slow things down... figure out optimum... coverage */
1337                             for (j = offset; j < e->temporary_objects.count; ++j)
1338                               {
1339                                  Evas_Object *obj2;
1340
1341                                  obj2 = (Evas_Object *) eina_array_data_get(&e->temporary_objects, j);
1342                                  if (evas_object_is_opaque(obj2))
1343                                    e->engine.func->context_cutout_add(e->engine.data.output,
1344                                                                       e->engine.data.context,
1345                                                                       obj2->cur.cache.clip.x + off_x,
1346                                                                       obj2->cur.cache.clip.y + off_y,
1347                                                                       obj2->cur.cache.clip.w,
1348                                                                       obj2->cur.cache.clip.h);
1349                                  else
1350                                    {
1351                                       if (obj2->func->get_opaque_rect)
1352                                         {
1353                                            Evas_Coord obx, oby, obw, obh;
1354
1355                                            obj2->func->get_opaque_rect
1356                                               (obj2, &obx, &oby, &obw, &obh);
1357                                            if ((obw > 0) && (obh > 0))
1358                                              {
1359                                                 obx += off_x;
1360                                                 oby += off_y;
1361                                                 RECTS_CLIP_TO_RECT(obx, oby, obw, obh,
1362                                                                    obj2->cur.cache.clip.x + off_x,
1363                                                                    obj2->cur.cache.clip.y + off_y,
1364                                                                    obj2->cur.cache.clip.w,
1365                                                                    obj2->cur.cache.clip.h);
1366                                                 e->engine.func->context_cutout_add(e->engine.data.output,
1367                                                                                    e->engine.data.context,
1368                                                                                    obx, oby,
1369                                                                                    obw, obh);
1370                                              }
1371                                         }
1372                                    }
1373                               }
1374 #endif
1375                             e->engine.func->context_clip_set(e->engine.data.output,
1376                                                              e->engine.data.context,
1377                                                              x, y, w, h);
1378                             clean_them |= evas_render_mapped(e, obj, e->engine.data.context,
1379                                                              surface, off_x, off_y, 0,
1380                                                              cx, cy, cw, ch
1381 #ifdef REND_DGB
1382                                                              , 1
1383 #endif
1384                                                             );
1385                             e->engine.func->context_cutout_clear(e->engine.data.output,
1386                                                                  e->engine.data.context);
1387                          }
1388                     }
1389                }
1390              /* punch rect out */
1391              e->engine.func->output_redraws_next_update_push(e->engine.data.output,
1392                                                              surface,
1393                                                              ux, uy, uw, uh);
1394              /* free obscuring objects list */
1395              eina_array_clean(&e->temporary_objects);
1396              RD("  ---]\n");
1397           }
1398         /* flush redraws */
1399         if (haveup)
1400           {
1401              evas_event_callback_call(e, EVAS_CALLBACK_RENDER_FLUSH_PRE, NULL);
1402              e->engine.func->output_flush(e->engine.data.output);
1403              evas_event_callback_call(e, EVAS_CALLBACK_RENDER_FLUSH_POST, NULL);
1404           }
1405      }
1406    /* clear redraws */
1407    e->engine.func->output_redraws_clear(e->engine.data.output);
1408    /* and do a post render pass */
1409    for (i = 0; i < e->active_objects.count; ++i)
1410      {
1411         Evas_Object *obj;
1412
1413         obj = eina_array_data_get(&e->active_objects, i);
1414         obj->pre_render_done = 0;
1415         RD("    OBJ [%p] post... %i %i\n", obj, obj->changed, do_draw);
1416         if ((obj->changed) && (do_draw))
1417           {
1418              RD("    OBJ [%p] post... func1\n", obj);
1419              obj->func->render_post(obj);
1420              obj->restack = 0;
1421              obj->changed = 0;
1422              obj->changed_move_only = 0;
1423              obj->changed_nomove = 0;
1424              obj->changed_move = 0;
1425           }
1426         else if ((obj->cur.map != obj->prev.map) ||
1427                  (obj->cur.usemap != obj->prev.usemap))
1428           {
1429              RD("    OBJ [%p] post... func2\n", obj);
1430              obj->func->render_post(obj);
1431              obj->restack = 0;
1432              obj->changed = 0;
1433              obj->changed_move_only = 0;
1434              obj->changed_nomove = 0;
1435              obj->changed_move = 0;
1436           }
1437         /* moved to other pre-process phase 1
1438            if (obj->delete_me == 2)
1439            {
1440            delete_objects = eina_list_append(delete_objects, obj);
1441            }
1442            else if (obj->delete_me != 0) obj->delete_me++;
1443          */
1444      }
1445    /* free our obscuring object list */
1446    eina_array_clean(&e->obscuring_objects);
1447
1448    /* If some object are still marked as changed, do not remove
1449       them from the pending list. */
1450    eina_array_remove(&e->pending_objects, pending_change, NULL);
1451
1452    for (i = 0; i < e->render_objects.count; ++i)
1453      {
1454         Evas_Object *obj;
1455
1456         obj = eina_array_data_get(&e->render_objects, i);
1457         obj->pre_render_done = 0;
1458      }
1459
1460    /* delete all objects flagged for deletion now */
1461    for (i = 0; i < e->delete_objects.count; ++i)
1462      {
1463         Evas_Object *obj;
1464
1465         obj = eina_array_data_get(&e->delete_objects, i);
1466         evas_object_free(obj, 1);
1467      }
1468    eina_array_clean(&e->delete_objects);
1469
1470    e->changed = 0;
1471    e->viewport.changed = 0;
1472    e->output.changed = 0;
1473    e->invalidate = 0;
1474
1475    /* If their are some object to restack or some object to delete,
1476     * it's useless to keep the render object list around. */
1477    if (clean_them)
1478      {
1479         eina_array_clean(&e->active_objects);
1480         eina_array_clean(&e->render_objects);
1481         eina_array_clean(&e->restack_objects);
1482         eina_array_clean(&e->delete_objects);
1483         eina_array_clean(&e->obscuring_objects);
1484         e->invalidate = 1;
1485      }
1486
1487    evas_module_clean();
1488
1489    RD("---]\n");
1490
1491    return updates;
1492 }
1493
1494 EAPI void
1495 evas_render_updates_free(Eina_List *updates)
1496 {
1497    Eina_Rectangle *r;
1498
1499    EINA_LIST_FREE(updates, r)
1500       eina_rectangle_free(r);
1501 }
1502
1503 EAPI Eina_List *
1504 evas_render_updates(Evas *e)
1505 {
1506    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1507    return NULL;
1508    MAGIC_CHECK_END();
1509
1510 #ifdef EVAS_FRAME_QUEUING
1511    evas_common_frameq_flush_ready ();
1512 #endif
1513
1514    if (!e->changed) return NULL;
1515    return evas_render_updates_internal(e, 1, 1);
1516 }
1517
1518 EAPI void
1519 evas_render(Evas *e)
1520 {
1521    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1522    return;
1523    MAGIC_CHECK_END();
1524
1525 #ifdef EVAS_FRAME_QUEUING
1526    evas_common_frameq_flush_ready ();
1527 #endif
1528
1529    if (!e->changed) return;
1530    evas_render_updates_internal(e, 0, 1);
1531 }
1532
1533 EAPI void
1534 evas_norender(Evas *e)
1535 {
1536    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1537    return;
1538    MAGIC_CHECK_END();
1539
1540    //   if (!e->changed) return;
1541    evas_render_updates_internal(e, 0, 0);
1542 }
1543
1544 EAPI void
1545 evas_render_idle_flush(Evas *e)
1546 {
1547    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1548    return;
1549    MAGIC_CHECK_END();
1550
1551    evas_fonts_zero_presure(e);
1552
1553    if ((e->engine.func) && (e->engine.func->output_idle_flush) &&
1554        (e->engine.data.output))
1555      e->engine.func->output_idle_flush(e->engine.data.output);
1556
1557    eina_array_flush(&e->delete_objects);
1558    eina_array_flush(&e->active_objects);
1559    eina_array_flush(&e->restack_objects);
1560    eina_array_flush(&e->render_objects);
1561    eina_array_flush(&e->clip_changes);
1562
1563    e->invalidate = 1;
1564 }
1565
1566 EAPI void
1567 evas_sync(Evas *e)
1568 {
1569 #ifdef EVAS_FRAME_QUEUING
1570    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1571    return;
1572    MAGIC_CHECK_END();
1573
1574    evas_common_frameq_flush();
1575 #else
1576    (void) e;
1577 #endif
1578 }
1579
1580 static void
1581 _evas_render_dump_map_surfaces(Evas_Object *obj)
1582 {
1583    if ((obj->cur.map) && obj->cur.map->surface)
1584      {
1585         obj->layer->evas->engine.func->image_map_surface_free
1586            (obj->layer->evas->engine.data.output, obj->cur.map->surface);
1587         obj->cur.map->surface = NULL;
1588      }
1589
1590    if (obj->smart.smart)
1591      {
1592         Evas_Object *obj2;
1593
1594         EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
1595            _evas_render_dump_map_surfaces(obj2);
1596      }
1597 }
1598
1599 EAPI void
1600 evas_render_dump(Evas *e)
1601 {
1602    Evas_Layer *lay;
1603
1604    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1605    return;
1606    MAGIC_CHECK_END();
1607
1608    EINA_INLIST_FOREACH(e->layers, lay)
1609      {
1610         Evas_Object *obj;
1611
1612         EINA_INLIST_FOREACH(lay->objects, obj)
1613           {
1614              if ((obj->type) && (!strcmp(obj->type, "image")))
1615                evas_object_inform_call_image_unloaded(obj);
1616              _evas_render_dump_map_surfaces(obj);
1617           }
1618      }
1619    if ((e->engine.func) && (e->engine.func->output_dump) &&
1620        (e->engine.data.output))
1621      e->engine.func->output_dump(e->engine.data.output);
1622 }
1623
1624 void
1625 evas_render_invalidate(Evas *e)
1626 {
1627    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1628    return;
1629    MAGIC_CHECK_END();
1630
1631    eina_array_clean(&e->active_objects);
1632    eina_array_clean(&e->render_objects);
1633
1634    eina_array_flush(&e->restack_objects);
1635    eina_array_flush(&e->delete_objects);
1636
1637    e->invalidate = 1;
1638 }
1639
1640 void
1641 evas_render_object_recalc(Evas_Object *obj)
1642 {
1643    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1644    return;
1645    MAGIC_CHECK_END();
1646
1647 #ifndef EVAS_FRAME_QUEUING
1648    if ((!obj->changed) && (obj->delete_me < 2))
1649 #else
1650      if ((!obj->changed))
1651 #endif
1652        {
1653           Evas *e;
1654
1655           e = obj->layer->evas;
1656           if ((!e) || (e->cleanup)) return;
1657 #ifdef EVAS_FRAME_QUEUING
1658           if (obj->delete_me >= evas_common_frameq_get_frameq_sz() + 2) return;
1659 #endif
1660           eina_array_push(&e->pending_objects, obj);
1661           obj->changed = 1;
1662        }
1663 }
1664
1665 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/