1 #include "evas_common.h"
2 #include "evas_private.h"
5 /* #define REND_DGB 1 */
6 /* #define STDOUT_DBG 1 */
9 static FILE *dbf = NULL;
12 rend_dbg(const char *txt)
19 dbf = fopen("EVAS-RENDER-DEBUG.log", "w");
28 char __tmpbuf[4096]; \
30 snprintf(__tmpbuf, sizeof(__tmpbuf), ##args); \
35 char __tmpbuf[4096]; int __tmpi; \
36 for (__tmpi = 0; __tmpi < xxxx; __tmpi++) \
37 __tmpbuf[__tmpi] = ' '; \
38 __tmpbuf[__tmpi] = 0; \
47 evas_render_updates_internal(Evas *e, unsigned char make_updates, unsigned char do_draw);
50 evas_damage_rectangle_add(Evas *e, int x, int y, int w, int h)
54 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
57 NEW_RECT(r, x, y, w, h);
59 e->damages = eina_list_append(e->damages, r);
64 evas_obscured_rectangle_add(Evas *e, int x, int y, int w, int h)
68 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
71 NEW_RECT(r, x, y, w, h);
73 e->obscures = eina_list_append(e->obscures, r);
77 evas_obscured_clear(Evas *e)
81 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
84 EINA_LIST_FREE(e->obscures, r)
86 eina_rectangle_free(r);
91 _evas_render_has_map(Evas_Object *obj)
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));
99 _evas_render_had_map(Evas_Object *obj)
101 return ((obj->prev.map) && (obj->prev.usemap));
102 // return ((!obj->cur.map) && (obj->prev.usemap));
106 _evas_render_is_relevant(Evas_Object *obj)
108 return ((evas_object_is_visible(obj) && (!obj->cur.have_clipees)) ||
109 (evas_object_was_visible(obj) && (!obj->prev.have_clipees)));
113 _evas_render_can_render(Evas_Object *obj)
115 return (evas_object_is_visible(obj) && (!obj->cur.have_clipees));
119 _evas_render_prev_cur_clip_cache_add(Evas *e, Evas_Object *obj)
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);
134 _evas_render_cur_clip_cache_del(Evas *e, Evas_Object *obj)
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);
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)
154 RD(" [--- PHASE 1 DIRECT\n");
155 for (i = 0; i < active_objects->count; i++)
159 obj = eina_array_data_get(active_objects, i);
162 /* Flag need redraw on proxy too */
163 evas_object_clip_recalc(obj);
164 if (obj->proxy.proxies)
166 EINA_LIST_FOREACH(obj->proxy.proxies, l, proxy)
167 proxy->proxy.redraw = 1;
171 for (i = 0; i < render_objects->count; i++)
175 obj = eina_array_data_get(render_objects, i);
176 RD(" OBJ [%p] changed %i\n", obj, obj->changed);
179 /* Flag need redraw on proxy too */
180 evas_object_clip_recalc(obj);
181 obj->func->render_pre(obj);
182 if (obj->proxy.proxies)
184 obj->proxy.redraw = 1;
185 EINA_LIST_FOREACH(obj->proxy.proxies, l, proxy)
187 proxy->func->render_pre(proxy);
188 _evas_render_prev_cur_clip_cache_add(e, proxy);
191 else if (obj->proxy.redraw)
193 _evas_render_prev_cur_clip_cache_add(e, obj);
195 if (obj->pre_render_done)
197 RD(" pre-render-done smart:%p|%p [%p, %i] | [%p, %i] has_map:%i had_map:%i\n",
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)))
207 RD(" has map + smart\n");
208 _evas_render_prev_cur_clip_cache_add(e, obj);
211 else if (_evas_render_had_map(obj))
213 RD(" no pre-render done\n");
214 _evas_render_prev_cur_clip_cache_add(e, obj);
219 if (obj->smart.smart)
221 // obj->func->render_pre(obj);
223 else if (obj->rect_del)
226 _evas_render_cur_clip_cache_del(e, obj);
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,
246 Eina_Bool clean_them = EINA_FALSE;
254 #ifndef EVAS_FRAME_QUEUING
255 /* because of clip objects - delete 2 cycles later */
256 if (obj->delete_me == 2)
258 if (obj->delete_me == evas_common_frameq_get_frameq_sz() + 2)
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;
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;
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);
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);
283 map = _evas_render_has_map(obj);
284 hmap = _evas_render_had_map(obj);
286 if ((restack) && (!map))
290 eina_array_push(&e->pending_objects, obj);
294 clean_them = EINA_TRUE;
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))))
313 eina_array_push(render_objects, obj);
314 _evas_render_prev_cur_clip_cache_add(e, obj);
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))))
321 eina_array_push(render_objects, obj);
322 _evas_render_prev_cur_clip_cache_add(e, obj);
328 else if (_evas_render_had_map(obj))
331 RD(" had map - restack objs\n");
332 // eina_array_push(restack_objects, obj);
333 _evas_render_prev_cur_clip_cache_add(e, obj);
340 if ((obj->cur.map) && (obj->cur.usemap)) map = 1;
350 /* handle normal rendering. this object knows how to handle maps */
353 if (obj->smart.smart)
356 RD(" changed + smart - render ok\n");
357 eina_array_push(render_objects, obj);
359 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
361 _evas_render_phase1_object_process(e, obj2,
377 if ((is_active) && (!obj->clip.clipees) &&
378 _evas_render_is_relevant(obj))
381 RD(" relevant + active\n");
383 eina_array_push(restack_objects, obj);
386 eina_array_push(render_objects, obj);
393 RD(" skip - not smart, not active or clippees or not relevant\n");
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))))
407 if (obj->smart.smart)
410 RD(" smart + visible/was visible + not clip\n");
411 eina_array_push(render_objects, obj);
414 (evas_object_smart_members_get_direct(obj), obj2)
416 _evas_render_phase1_object_process(e, obj2,
431 if (evas_object_is_opaque(obj) &&
432 evas_object_is_visible(obj))
435 RD(" opaque + visible\n");
436 eina_array_push(render_objects, obj);
439 else if (evas_object_is_visible(obj))
443 eina_array_push(render_objects, obj);
454 else if (obj->smart.smart)
457 RD(" smart + mot visible/was visible\n");
458 eina_array_push(render_objects, obj);
461 (evas_object_smart_members_get_direct(obj), obj2)
463 _evas_render_phase1_object_process(e, obj2,
478 if (!is_active) obj->restack = 0;
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,
493 Eina_Bool clean_them = EINA_FALSE;
495 RD(" [--- PHASE 1\n");
496 EINA_INLIST_FOREACH(e->layers, lay)
500 EINA_INLIST_FOREACH(lay->objects, obj)
502 clean_them |= _evas_render_phase1_object_process
503 (e, obj, active_objects, restack_objects, delete_objects,
504 render_objects, 0, 0, redraw_all
516 _evas_render_check_pending_objects(Eina_Array *pending_objects, Evas *e)
520 for (i = 0; i < pending_objects->count; ++i)
523 int is_active, ok = 0;
525 obj = eina_array_data_get(pending_objects, i);
527 if (!obj->layer) goto clean_stuff;
529 evas_object_clip_recalc(obj);
530 is_active = evas_object_is_active(obj);
532 if ((!is_active) && (!obj->is_active) && (!obj->render_pre) &&
539 if (obj->is_active == is_active)
543 if (obj->smart.smart)
545 if (obj->render_pre || obj->rect_del) ok = 1;
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))))
552 if (!(obj->render_pre || obj->rect_del)) ok = 1;
555 if (is_active && (!obj->clip.clipees) &&
556 (_evas_render_can_render(obj) ||
557 (evas_object_was_visible(obj) && (!obj->prev.have_clipees))))
559 if (obj->render_pre || obj->rect_del) ok = 1;
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))
568 if (obj->rect_del || obj->smart.smart) ok = 1;
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);
587 pending_change(void *data, void *gdata __UNUSED__)
592 if (obj->delete_me) return EINA_FALSE;
593 if (obj->pre_render_done)
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
599 obj->changed_move_only = 0;
600 obj->changed_nomove = 0;
601 obj->changed_move = 0;
603 return obj->changed ? EINA_TRUE : EINA_FALSE;
607 unchange(Evas_Object *obj)
611 if (!obj->changed) return;
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)
623 chlist(Evas_Object *obj, int i)
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,
633 obj->changed_move_only,
642 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
645 ret |= chlist(obj2, i + 1);
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
661 Eina_Bool clean_them = EINA_FALSE;
663 evas_object_clip_recalc(obj);
665 RD(" { evas_render_mapped(%p, %p, %p, %p, %i, %i, %i, %i)\n", e, obj, context, surface, off_x, off_y, mapped, level);
668 if ((!evas_object_is_visible(obj)) || (obj->clip.clipees) ||
669 (obj->cur.have_clipees))
676 else if (!(((evas_object_is_active(obj) && (!obj->clip.clipees) &&
677 (_evas_render_can_render(obj))))
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))
693 const Evas_Map_Point *p, *p_end;
694 RGBA_Map_Point pts[4], *pt;
696 int changed = 0, rendered = 0;
698 clean_them = EINA_TRUE;
700 sw = obj->cur.geometry.w;
701 sh = obj->cur.geometry.h;
703 RD(" mapped obj: %ix%i\n", sw, sh);
704 if ((sw <= 0) || (sh <= 0))
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;
716 p = obj->cur.map->points;
717 p_end = p + obj->cur.map->count;
719 for (; p < p_end; p++, pt++)
721 pt->x = (p->x + (double)off_x) * FP1;
722 pt->y = (p->y + (double)off_y) * FP1;
723 pt->z = (p->z) * 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);
735 /* Copy last for software engine */
736 if (obj->cur.map->count & 0x1)
738 pts[obj->cur.map->count] = pts[obj->cur.map->count - 1];
742 if (obj->cur.map->surface)
744 if ((obj->cur.map->surface_w != sw) ||
745 (obj->cur.map->surface_h != sh))
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;
754 if (!obj->cur.map->surface)
756 obj->cur.map->surface_w = sw;
757 obj->cur.map->surface_h = sh;
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);
765 RD(" fisrt surf: %ix%i\n", sw, sh);
768 if (obj->smart.smart)
772 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), o2)
774 if (!evas_object_is_visible(o2) &&
775 !evas_object_was_visible(o2))
778 o2->changed_move_only = 0;
779 o2->changed_nomove = 0;
780 o2->changed_move = 0;
788 o2->changed_move_only = 0;
789 o2->changed_nomove = 0;
790 o2->changed_move = 0;
796 obj->changed_move_only = 0;
797 obj->changed_nomove = 0;
798 obj->changed_move = 0;
806 obj->changed_move_only = 0;
807 obj->changed_nomove = 0;
808 obj->changed_move = 0;
812 // clear surface before re-render
813 if ((changed) && (obj->cur.map->surface))
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)
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,
830 obj->cur.map->surface,
832 obj->cur.map->surface_w,
833 obj->cur.map->surface_h);
834 e->engine.func->context_free(e->engine.data.output, ctx);
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)
842 (evas_object_smart_members_get_direct(obj), obj2)
844 clean_them |= evas_render_mapped(e, obj2, ctx,
845 obj->cur.map->surface,
856 int x = 0, y = 0, w = 0, h = 0;
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,
864 obj->cur.geometry.h);
866 e->engine.func->context_clip_set(e->engine.data.output,
868 obj->func->render(obj, e->engine.data.output, ctx,
869 obj->cur.map->surface, off_x2, off_y2);
871 e->engine.func->context_free(e->engine.data.output, ctx);
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);
884 e->engine.func->context_clip_unset(e->engine.data.output,
885 e->engine.data.context);
886 if (obj->cur.map->surface)
888 if (obj->smart.smart)
890 if (obj->cur.clipper)
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);
916 if (obj->cur.clipper)
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);
936 if (surface == e->engine.data.output)
937 e->engine.func->context_clip_clip(e->engine.data.output,
938 e->engine.data.context,
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;
956 RD(" draw child of mapped obj\n");
957 ctx = e->engine.func->context_new(e->engine.data.output);
958 if (obj->smart.smart)
961 (evas_object_smart_members_get_direct(obj), obj2)
963 clean_them |= evas_render_mapped(e, obj2, ctx,
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;
986 if (obj->cur.clipper)
988 if (_evas_render_has_map(obj))
989 evas_object_clip_recalc(obj);
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);
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);
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,
1021 obj->func->render(obj, e->engine.data.output, ctx,
1022 surface, off_x, off_y);
1024 obj->layer->evas->engine.func->context_color_set(e->engine.data.output,
1027 obj->layer->evas->engine.func->rectangle_draw(e->engine.data.output,
1033 e->engine.func->context_free(e->engine.data.output, ctx);
1037 if (obj->cur.clipper)
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);
1061 RD(" draw normal obj\n");
1062 obj->func->render(obj, e->engine.data.output, context, surface,
1073 evas_render_updates_internal(Evas *e,
1074 unsigned char make_updates,
1075 unsigned char do_draw)
1077 Eina_List *updates = NULL;
1080 Eina_Bool clean_them = EINA_FALSE;
1089 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1092 if (!e->changed) return NULL;
1094 evas_call_smarts_calculate(e);
1096 RD("[--- RENDER EVAS (size: %ix%i)\n", e->viewport.w, e->viewport.h);
1098 /* Check if the modified object mean recalculating every thing */
1100 _evas_render_check_pending_objects(&e->pending_objects, e);
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,
1106 &e->restack_objects,
1111 _evas_render_phase1_direct(e, &e->active_objects, &e->restack_objects,
1112 &e->delete_objects, &e->render_objects);
1114 /* phase 2. force updates for restacks */
1115 for (i = 0; i < e->restack_objects.count; ++i)
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);
1123 eina_array_clean(&e->restack_objects);
1124 /* phase 3. add exposes */
1125 EINA_LIST_FREE(e->damages, r)
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);
1131 /* phase 4. output & viewport changes */
1132 if (e->viewport.changed)
1134 e->engine.func->output_redraws_rect_add(e->engine.data.output,
1136 e->output.w, e->output.h);
1138 if (e->output.changed)
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,
1144 e->output.w, e->output.h);
1146 if ((e->output.w != e->viewport.w) || (e->output.h != e->viewport.h))
1148 ERR("viewport size != output size!");
1152 e->engine.func->output_redraws_rect_add(e->engine.data.output,
1154 e->output.w, e->output.h);
1156 /* phase 5. add obscures */
1157 EINA_LIST_FOREACH(e->obscures, ll, r)
1159 e->engine.func->output_redraws_rect_del(e->engine.data.output,
1160 r->x, r->y, r->w, r->h);
1162 /* build obscure objects list of active objects that obscure */
1163 for (i = 0; i < e->active_objects.count; ++i)
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);
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*/
1186 unsigned int offset = 0;
1188 alpha = e->engine.func->canvas_alpha_get(e->engine.data.output,
1189 e->engine.data.context);
1191 e->engine.func->output_redraws_next_update_get
1192 (e->engine.data.output,
1194 &cx, &cy, &cw, &ch)))
1198 RD(" [--- UPDATE %i %i %ix%i\n", ux, uy, uw, uh);
1201 Eina_Rectangle *rect;
1203 NEW_RECT(rect, ux, uy, uw, uh);
1205 updates = eina_list_append(updates, rect);
1210 /* build obscuring objects list (in order from bottom to top) */
1211 for (i = 0; i < e->obscuring_objects.count; ++i)
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))
1219 eina_array_push(&e->temporary_objects, obj);
1221 /* reset the background of the area if needed (using cutout and engine alpha flag to help) */
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);
1234 if (obj->func->get_opaque_rect)
1236 Evas_Coord obx, oby, obw, obh;
1238 obj->func->get_opaque_rect
1239 (obj, &obx, &oby, &obw, &obh);
1240 if ((obw > 0) && (obh > 0))
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,
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,
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,
1274 e->engine.func->rectangle_draw(e->engine.data.output,
1275 e->engine.data.context,
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);
1283 /* render all object that intersect with rect */
1284 for (i = 0; i < e->active_objects.count; ++i)
1288 obj = eina_array_data_get(&e->active_objects, i);
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)))
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))
1307 x = cx; y = cy; w = cw; h = ch;
1308 if (((w > 0) && (h > 0)) || (obj->smart.smart))
1310 if (!obj->smart.smart)
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);
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);
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,
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)
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);
1351 if (obj2->func->get_opaque_rect)
1353 Evas_Coord obx, oby, obw, obh;
1355 obj2->func->get_opaque_rect
1356 (obj2, &obx, &oby, &obw, &obh);
1357 if ((obw > 0) && (obh > 0))
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,
1375 e->engine.func->context_clip_set(e->engine.data.output,
1376 e->engine.data.context,
1378 clean_them |= evas_render_mapped(e, obj, e->engine.data.context,
1379 surface, off_x, off_y, 0,
1385 e->engine.func->context_cutout_clear(e->engine.data.output,
1386 e->engine.data.context);
1390 /* punch rect out */
1391 e->engine.func->output_redraws_next_update_push(e->engine.data.output,
1394 /* free obscuring objects list */
1395 eina_array_clean(&e->temporary_objects);
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);
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)
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))
1418 RD(" OBJ [%p] post... func1\n", obj);
1419 obj->func->render_post(obj);
1422 obj->changed_move_only = 0;
1423 obj->changed_nomove = 0;
1424 obj->changed_move = 0;
1426 else if ((obj->cur.map != obj->prev.map) ||
1427 (obj->cur.usemap != obj->prev.usemap))
1429 RD(" OBJ [%p] post... func2\n", obj);
1430 obj->func->render_post(obj);
1433 obj->changed_move_only = 0;
1434 obj->changed_nomove = 0;
1435 obj->changed_move = 0;
1437 /* moved to other pre-process phase 1
1438 if (obj->delete_me == 2)
1440 delete_objects = eina_list_append(delete_objects, obj);
1442 else if (obj->delete_me != 0) obj->delete_me++;
1445 /* free our obscuring object list */
1446 eina_array_clean(&e->obscuring_objects);
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);
1452 for (i = 0; i < e->render_objects.count; ++i)
1456 obj = eina_array_data_get(&e->render_objects, i);
1457 obj->pre_render_done = 0;
1460 /* delete all objects flagged for deletion now */
1461 for (i = 0; i < e->delete_objects.count; ++i)
1465 obj = eina_array_data_get(&e->delete_objects, i);
1466 evas_object_free(obj, 1);
1468 eina_array_clean(&e->delete_objects);
1471 e->viewport.changed = 0;
1472 e->output.changed = 0;
1475 /* If their are some object to restack or some object to delete,
1476 * it's useless to keep the render object list around. */
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);
1487 evas_module_clean();
1495 evas_render_updates_free(Eina_List *updates)
1499 EINA_LIST_FREE(updates, r)
1500 eina_rectangle_free(r);
1504 evas_render_updates(Evas *e)
1506 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1510 #ifdef EVAS_FRAME_QUEUING
1511 evas_common_frameq_flush_ready ();
1514 if (!e->changed) return NULL;
1515 return evas_render_updates_internal(e, 1, 1);
1519 evas_render(Evas *e)
1521 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1525 #ifdef EVAS_FRAME_QUEUING
1526 evas_common_frameq_flush_ready ();
1529 if (!e->changed) return;
1530 evas_render_updates_internal(e, 0, 1);
1534 evas_norender(Evas *e)
1536 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1540 // if (!e->changed) return;
1541 evas_render_updates_internal(e, 0, 0);
1545 evas_render_idle_flush(Evas *e)
1547 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1551 evas_fonts_zero_presure(e);
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);
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);
1569 #ifdef EVAS_FRAME_QUEUING
1570 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1574 evas_common_frameq_flush();
1581 _evas_render_dump_map_surfaces(Evas_Object *obj)
1583 if ((obj->cur.map) && obj->cur.map->surface)
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;
1590 if (obj->smart.smart)
1594 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
1595 _evas_render_dump_map_surfaces(obj2);
1600 evas_render_dump(Evas *e)
1604 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1608 EINA_INLIST_FOREACH(e->layers, lay)
1612 EINA_INLIST_FOREACH(lay->objects, obj)
1614 if ((obj->type) && (!strcmp(obj->type, "image")))
1615 evas_object_inform_call_image_unloaded(obj);
1616 _evas_render_dump_map_surfaces(obj);
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);
1625 evas_render_invalidate(Evas *e)
1627 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1631 eina_array_clean(&e->active_objects);
1632 eina_array_clean(&e->render_objects);
1634 eina_array_flush(&e->restack_objects);
1635 eina_array_flush(&e->delete_objects);
1641 evas_render_object_recalc(Evas_Object *obj)
1643 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1647 #ifndef EVAS_FRAME_QUEUING
1648 if ((!obj->changed) && (obj->delete_me < 2))
1650 if ((!obj->changed))
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;
1660 eina_array_push(&e->pending_objects, obj);
1665 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/