2 # include "config.h" /* so that EAPI in Evas.h is correctly defined */
13 #include "evas_common.h"
14 #include "evas_private.h"
15 #include "../engines/common/evas_convert_color.h"
16 #include "../engines/common/evas_convert_colorspace.h"
17 #include "../engines/common/evas_convert_yuv.h"
19 #define VERBOSE_PROXY_ERROR 1
21 /* private magic number for image objects */
22 static const char o_type[] = "image";
24 /* private struct for rectangle object internal data */
25 typedef struct _Evas_Object_Image Evas_Object_Image;
27 struct _Evas_Object_Image
33 Evas_Coord_Rectangle fill;
48 Evas_Colorspace cspace;
50 unsigned char smooth_scale : 1;
51 unsigned char has_alpha :1;
52 unsigned char opaque :1;
53 unsigned char opaque_valid :1;
56 int pixels_checked_out;
58 Eina_List *pixel_updates;
61 unsigned char scale_down_by;
67 Eina_Bool orientation : 1;
71 Evas_Object_Image_Pixels_Get_Cb get_pixels;
72 void *get_pixels_data;
75 Evas_Video_Surface video;
80 Evas_Image_Scale_Hint scale_hint;
81 Evas_Image_Content_Hint content_hint;
85 unsigned char changed : 1;
86 unsigned char dirty_pixels : 1;
87 unsigned char filled : 1;
88 unsigned char proxyrendering : 1;
89 unsigned char preloading : 1;
90 unsigned char video_rendering : 1;
91 unsigned char video_surface : 1;
92 unsigned char video_visible : 1;
93 unsigned char created : 1;
96 /* private methods for image objects */
97 static void evas_object_image_unload(Evas_Object *obj, Eina_Bool dirty);
98 static void evas_object_image_load(Evas_Object *obj);
99 static Evas_Coord evas_object_image_figure_x_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret);
100 static Evas_Coord evas_object_image_figure_y_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret);
102 static void evas_object_image_init(Evas_Object *obj);
103 static void *evas_object_image_new(void);
104 static void evas_object_image_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
105 static void evas_object_image_free(Evas_Object *obj);
106 static void evas_object_image_render_pre(Evas_Object *obj);
107 static void evas_object_image_render_post(Evas_Object *obj);
109 static unsigned int evas_object_image_id_get(Evas_Object *obj);
110 static unsigned int evas_object_image_visual_id_get(Evas_Object *obj);
111 static void *evas_object_image_engine_data_get(Evas_Object *obj);
113 static int evas_object_image_is_opaque(Evas_Object *obj);
114 static int evas_object_image_was_opaque(Evas_Object *obj);
115 static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
116 static int evas_object_image_has_opaque_rect(Evas_Object *obj);
117 static int evas_object_image_get_opaque_rect(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
118 static int evas_object_image_can_map(Evas_Object *obj);
120 static void *evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace);
121 static void evas_object_image_filled_resize_listener(void *data, Evas *e, Evas_Object *obj, void *einfo);
123 static void _proxy_unset(Evas_Object *proxy);
124 static void _proxy_set(Evas_Object *proxy, Evas_Object *src);
125 static void _proxy_error(Evas_Object *proxy, void *context, void *output, void *surface, int x, int y);
127 static void _cleanup_tmpf(Evas_Object *obj);
129 static const Evas_Object_Func object_func =
131 /* methods (compulsory) */
132 evas_object_image_free,
133 evas_object_image_render,
134 evas_object_image_render_pre,
135 evas_object_image_render_post,
136 evas_object_image_id_get,
137 evas_object_image_visual_id_get,
138 evas_object_image_engine_data_get,
139 /* these are optional. NULL = nothing */
144 evas_object_image_is_opaque,
145 evas_object_image_was_opaque,
146 evas_object_image_is_inside,
150 evas_object_image_has_opaque_rect,
151 evas_object_image_get_opaque_rect,
152 evas_object_image_can_map
155 EVAS_MEMPOOL(_mp_obj);
158 _evas_object_image_cleanup(Evas_Object *obj, Evas_Object_Image *o)
160 if ((o->preloading) && (o->engine_data))
163 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
167 if (o->tmpf) _cleanup_tmpf(obj);
168 if (o->cur.source) _proxy_unset(obj);
172 evas_object_image_add(Evas *e)
175 Evas_Object_Image *o;
177 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
180 obj = evas_object_new(e);
181 evas_object_image_init(obj);
182 evas_object_inject(obj, e);
183 o = (Evas_Object_Image *)(obj->object_data);
184 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
190 evas_object_image_filled_add(Evas *e)
193 obj = evas_object_image_add(e);
194 evas_object_image_filled_set(obj, 1);
199 _cleanup_tmpf(Evas_Object *obj)
201 #ifdef HAVE_SYS_MMAN_H
202 Evas_Object_Image *o;
204 o = (Evas_Object_Image *)(obj->object_data);
205 if (!o->tmpf) return;
210 if (o->tmpf_fd >= 0) close(o->tmpf_fd);
211 eina_stringshare_del(o->tmpf);
220 _create_tmpf(Evas_Object *obj, void *data, int size, char *format __UNUSED__)
222 #ifdef HAVE_SYS_MMAN_H
223 Evas_Object_Image *o;
228 o = (Evas_Object_Image *)(obj->object_data);
230 snprintf(buf, sizeof(buf), "/dev/shm/.evas-tmpf-%i-%p-%i-XXXXXX",
231 (int)getpid(), data, (int)size);
236 snprintf(buf, sizeof(buf), "/tmp/.evas-tmpf-%i-%p-%i-XXXXXX",
237 (int)getpid(), data, (int)size);
241 if (ftruncate(fd, size) < 0)
249 eina_mmap_safety_enabled_set(EINA_TRUE);
251 dst = mmap(NULL, size,
252 PROT_READ | PROT_WRITE,
255 if (dst == MAP_FAILED)
262 snprintf(buf, sizeof(buf), "/proc/%li/fd/%i", (long)getpid(), fd);
264 o->tmpf = eina_stringshare_add(buf);
265 memcpy(dst, data, size);
276 evas_object_image_memfile_set(Evas_Object *obj, void *data, int size, char *format, char *key)
278 Evas_Object_Image *o;
280 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
283 o = (Evas_Object_Image *)(obj->object_data);
284 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
288 evas_object_image_file_set(obj, NULL, NULL);
289 // invalidate the cache effectively
290 evas_object_image_alpha_set(obj, !o->cur.has_alpha);
291 evas_object_image_alpha_set(obj, !o->cur.has_alpha);
293 if ((size < 1) || (!data)) return;
295 _create_tmpf(obj, data, size, format);
296 evas_object_image_file_set(obj, o->tmpf, key);
299 ERR("unable to load '%s' from memory", o->tmpf);
306 evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
308 Evas_Object_Image *o;
309 Evas_Image_Load_Opts lo;
311 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
314 o = (Evas_Object_Image *)(obj->object_data);
315 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
318 if ((o->tmpf) && (file != o->tmpf)) _cleanup_tmpf(obj);
319 if ((o->cur.file) && (file) && (!strcmp(o->cur.file, file)))
321 if ((!o->cur.key) && (!key))
323 if ((o->cur.key) && (key) && (!strcmp(o->cur.key, key)))
327 * WTF? why cancel a null image preload? this is just silly (tm)
329 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
333 if (o->cur.source) _proxy_unset(obj);
334 if (o->cur.file) eina_stringshare_del(o->cur.file);
335 if (o->cur.key) eina_stringshare_del(o->cur.key);
336 if (file) o->cur.file = eina_stringshare_add(file);
337 else o->cur.file = NULL;
338 if (key) o->cur.key = eina_stringshare_add(key);
339 else o->cur.key = NULL;
347 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
351 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
354 o->load_error = EVAS_LOAD_ERROR_NONE;
355 lo.scale_down_by = o->load_opts.scale_down_by;
356 lo.dpi = o->load_opts.dpi;
357 lo.w = o->load_opts.w;
358 lo.h = o->load_opts.h;
359 lo.region.x = o->load_opts.region.x;
360 lo.region.y = o->load_opts.region.y;
361 lo.region.w = o->load_opts.region.w;
362 lo.region.h = o->load_opts.region.h;
363 lo.orientation = o->load_opts.orientation;
364 o->engine_data = obj->layer->evas->engine.func->image_load(obj->layer->evas->engine.data.output,
374 obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output,
375 o->engine_data, &w, &h);
376 if (obj->layer->evas->engine.func->image_stride_get)
377 obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output,
378 o->engine_data, &stride);
381 o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
383 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
387 o->cur.image.stride = stride;
391 if (o->load_error == EVAS_LOAD_ERROR_NONE)
392 o->load_error = EVAS_LOAD_ERROR_GENERIC;
393 o->cur.has_alpha = 1;
394 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
397 o->cur.image.stride = 0;
400 evas_object_change(obj);
404 evas_object_image_file_get(const Evas_Object *obj, const char **file, const char **key)
406 Evas_Object_Image *o;
408 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
409 if (file) *file = NULL;
410 if (key) *key = NULL;
413 o = (Evas_Object_Image *)(obj->object_data);
414 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
415 if (file) *file = NULL;
416 if (key) *key = NULL;
419 if (file) *file = o->cur.file;
420 if (key) *key = o->cur.key;
424 evas_object_image_source_set(Evas_Object *obj, Evas_Object *src)
426 Evas_Object_Image *o;
428 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
431 o = obj->object_data;
432 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
436 if (src == obj) return EINA_FALSE;
437 if (o->cur.source == src) return EINA_TRUE;
439 _evas_object_image_cleanup(obj, o);
440 /* Kill the image if any */
441 if (o->cur.file || o->cur.key)
442 evas_object_image_file_set(obj, NULL, NULL);
446 _proxy_set(obj, src);
454 evas_object_image_source_get(const Evas_Object *obj)
456 Evas_Object_Image *o;
458 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
461 o = obj->object_data;
462 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
466 return o->cur.source;
470 evas_object_image_source_unset(Evas_Object *obj)
472 return evas_object_image_source_set(obj, NULL);
476 evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
478 Evas_Object_Image *o;
480 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
483 o = (Evas_Object_Image *)(obj->object_data);
484 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
491 if ((o->cur.border.l == l) &&
492 (o->cur.border.r == r) &&
493 (o->cur.border.t == t) &&
494 (o->cur.border.b == b)) return;
499 o->cur.opaque_valid = 0;
501 evas_object_change(obj);
505 evas_object_image_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
507 Evas_Object_Image *o;
509 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
516 o = (Evas_Object_Image *)(obj->object_data);
517 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
524 if (l) *l = o->cur.border.l;
525 if (r) *r = o->cur.border.r;
526 if (t) *t = o->cur.border.t;
527 if (b) *b = o->cur.border.b;
531 evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
533 Evas_Object_Image *o;
535 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
538 o = (Evas_Object_Image *)(obj->object_data);
539 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
542 if (fill == o->cur.border.fill) return;
543 o->cur.border.fill = fill;
545 evas_object_change(obj);
548 EAPI Evas_Border_Fill_Mode
549 evas_object_image_border_center_fill_get(const Evas_Object *obj)
551 Evas_Object_Image *o;
553 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
556 o = (Evas_Object_Image *)(obj->object_data);
557 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
560 return o->cur.border.fill;
564 evas_object_image_filled_set(Evas_Object *obj, Eina_Bool setting)
566 Evas_Object_Image *o;
568 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
571 o = (Evas_Object_Image *)(obj->object_data);
572 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
577 if (o->filled == setting) return;
581 evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE, evas_object_image_filled_resize_listener);
586 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
587 evas_object_image_fill_set(obj, 0, 0, w, h);
589 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, evas_object_image_filled_resize_listener, NULL);
594 evas_object_image_filled_get(const Evas_Object *obj)
596 Evas_Object_Image *o;
598 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
601 o = (Evas_Object_Image *)(obj->object_data);
602 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
610 evas_object_image_border_scale_set(Evas_Object *obj, double scale)
612 Evas_Object_Image *o;
614 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
617 o = (Evas_Object_Image *)(obj->object_data);
618 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
621 if (scale == o->cur.border.scale) return;
622 o->cur.border.scale = scale;
624 evas_object_change(obj);
628 evas_object_image_border_scale_get(const Evas_Object *obj)
630 Evas_Object_Image *o;
632 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
635 o = (Evas_Object_Image *)(obj->object_data);
636 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
639 return o->cur.border.scale;
643 evas_object_image_fill_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
645 Evas_Object_Image *o;
651 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
654 o = (Evas_Object_Image *)(obj->object_data);
655 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
658 if ((o->cur.fill.x == x) &&
659 (o->cur.fill.y == y) &&
660 (o->cur.fill.w == w) &&
661 (o->cur.fill.h == h)) return;
666 o->cur.opaque_valid = 0;
668 evas_object_change(obj);
672 evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
674 Evas_Object_Image *o;
676 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
683 o = (Evas_Object_Image *)(obj->object_data);
684 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
691 if (x) *x = o->cur.fill.x;
692 if (y) *y = o->cur.fill.y;
693 if (w) *w = o->cur.fill.w;
694 if (h) *h = o->cur.fill.h;
699 evas_object_image_fill_spread_set(Evas_Object *obj, Evas_Fill_Spread spread)
701 Evas_Object_Image *o;
703 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
706 o = (Evas_Object_Image *)(obj->object_data);
707 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
710 if (spread == (Evas_Fill_Spread)o->cur.spread) return;
711 o->cur.spread = spread;
713 evas_object_change(obj);
716 EAPI Evas_Fill_Spread
717 evas_object_image_fill_spread_get(const Evas_Object *obj)
719 Evas_Object_Image *o;
721 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
722 return EVAS_TEXTURE_REPEAT;
724 o = (Evas_Object_Image *)(obj->object_data);
725 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
726 return EVAS_TEXTURE_REPEAT;
728 return (Evas_Fill_Spread)o->cur.spread;
732 evas_object_image_size_set(Evas_Object *obj, int w, int h)
734 Evas_Object_Image *o;
737 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
740 o = (Evas_Object_Image *)(obj->object_data);
741 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
744 _evas_object_image_cleanup(obj, o);
747 if (w > 32768) return;
748 if (h > 32768) return;
749 if ((w == o->cur.image.w) &&
750 (h == o->cur.image.h)) return;
754 o->engine_data = obj->layer->evas->engine.func->image_size_set(obj->layer->evas->engine.data.output,
758 o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data
759 (obj->layer->evas->engine.data.output, w, h, NULL, o->cur.has_alpha,
764 if (obj->layer->evas->engine.func->image_scale_hint_set)
765 obj->layer->evas->engine.func->image_scale_hint_set
766 (obj->layer->evas->engine.data.output,
767 o->engine_data, o->scale_hint);
768 if (obj->layer->evas->engine.func->image_content_hint_set)
769 obj->layer->evas->engine.func->image_content_hint_set
770 (obj->layer->evas->engine.data.output,
771 o->engine_data, o->content_hint);
772 if (obj->layer->evas->engine.func->image_stride_get)
773 obj->layer->evas->engine.func->image_stride_get
774 (obj->layer->evas->engine.data.output,
775 o->engine_data, &stride);
781 o->cur.image.stride = stride;
783 /* FIXME - in engine call above
785 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
789 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
791 evas_object_change(obj);
795 evas_object_image_size_get(const Evas_Object *obj, int *w, int *h)
797 Evas_Object_Image *o;
799 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
804 o = (Evas_Object_Image *)(obj->object_data);
805 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
810 if (w) *w = o->cur.image.w;
811 if (h) *h = o->cur.image.h;
815 evas_object_image_stride_get(const Evas_Object *obj)
817 Evas_Object_Image *o;
819 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
822 o = (Evas_Object_Image *)(obj->object_data);
823 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
826 return o->cur.image.stride;
830 evas_object_image_load_error_get(const Evas_Object *obj)
832 Evas_Object_Image *o;
834 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
837 o = (Evas_Object_Image *)(obj->object_data);
838 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
841 return o->load_error;
845 evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace)
847 Evas_Object_Image *o;
850 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
853 o = (Evas_Object_Image *)(obj->object_data);
854 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
857 if ((o->preloading) && (o->engine_data))
860 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
864 if (!o->engine_data) return NULL;
865 if (o->video_surface)
866 o->video.update_pixels(o->video.data, obj, &o->video);
867 if (o->cur.cspace == to_cspace) return NULL;
869 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
876 result = evas_object_image_data_convert_internal(o, data, to_cspace);
878 o->engine_data = obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
885 evas_object_image_data_set(Evas_Object *obj, void *data)
887 Evas_Object_Image *o;
890 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
893 o = (Evas_Object_Image *)(obj->object_data);
894 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
897 _evas_object_image_cleanup(obj, o);
898 #ifdef EVAS_FRAME_QUEUING
900 evas_common_pipe_op_image_flush(o->engine_data);
902 p_data = o->engine_data;
906 o->engine_data = obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
910 o->engine_data = obj->layer->evas->engine.func->image_new_from_data(obj->layer->evas->engine.data.output,
920 if (obj->layer->evas->engine.func->image_scale_hint_set)
921 obj->layer->evas->engine.func->image_scale_hint_set
922 (obj->layer->evas->engine.data.output,
923 o->engine_data, o->scale_hint);
924 if (obj->layer->evas->engine.func->image_content_hint_set)
925 obj->layer->evas->engine.func->image_content_hint_set
926 (obj->layer->evas->engine.data.output,
927 o->engine_data, o->content_hint);
928 if (obj->layer->evas->engine.func->image_stride_get)
929 obj->layer->evas->engine.func->image_stride_get
930 (obj->layer->evas->engine.data.output,
931 o->engine_data, &stride);
933 stride = o->cur.image.w * 4;
934 o->cur.image.stride = stride;
940 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
942 o->load_error = EVAS_LOAD_ERROR_NONE;
945 o->cur.image.stride = 0;
946 o->engine_data = NULL;
948 /* FIXME - in engine call above
950 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
954 if (o->pixels_checked_out > 0) o->pixels_checked_out--;
955 if (p_data != o->engine_data)
957 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
958 o->pixels_checked_out = 0;
961 evas_object_change(obj);
965 evas_object_image_data_get(const Evas_Object *obj, Eina_Bool for_writing)
967 Evas_Object_Image *o;
970 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
973 o = (Evas_Object_Image *)(obj->object_data);
974 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
977 if (!o->engine_data) return NULL;
978 #ifdef EVAS_FRAME_QUEUING
979 evas_common_pipe_op_image_flush(o->engine_data);
983 if (obj->layer->evas->engine.func->image_scale_hint_set)
984 obj->layer->evas->engine.func->image_scale_hint_set
985 (obj->layer->evas->engine.data.output,
986 o->engine_data, o->scale_hint);
987 if (obj->layer->evas->engine.func->image_content_hint_set)
988 obj->layer->evas->engine.func->image_content_hint_set
989 (obj->layer->evas->engine.data.output,
990 o->engine_data, o->content_hint);
991 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
997 /* if we fail to get engine_data, we have to return NULL */
998 if (!o->engine_data) return NULL;
1004 if (obj->layer->evas->engine.func->image_stride_get)
1005 obj->layer->evas->engine.func->image_stride_get
1006 (obj->layer->evas->engine.data.output,
1007 o->engine_data, &stride);
1009 stride = o->cur.image.w * 4;
1010 o->cur.image.stride = stride;
1012 o->pixels_checked_out++;
1015 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
1022 evas_object_image_preload(Evas_Object *obj, Eina_Bool cancel)
1024 Evas_Object_Image *o;
1026 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1029 o = (Evas_Object_Image *)(obj->object_data);
1030 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1033 if (!o->engine_data)
1036 evas_object_inform_call_image_preloaded(obj);
1039 // FIXME: if already busy preloading, then dont request again until
1046 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1056 obj->layer->evas->engine.func->image_data_preload_request(obj->layer->evas->engine.data.output,
1064 evas_object_image_data_copy_set(Evas_Object *obj, void *data)
1066 Evas_Object_Image *o;
1069 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1072 o = (Evas_Object_Image *)(obj->object_data);
1073 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1076 _evas_object_image_cleanup(obj, o);
1077 if ((o->cur.image.w <= 0) ||
1078 (o->cur.image.h <= 0)) return;
1080 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
1082 o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data(obj->layer->evas->engine.data.output,
1092 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1095 if (obj->layer->evas->engine.func->image_scale_hint_set)
1096 obj->layer->evas->engine.func->image_scale_hint_set
1097 (obj->layer->evas->engine.data.output,
1098 o->engine_data, o->scale_hint);
1099 if (obj->layer->evas->engine.func->image_content_hint_set)
1100 obj->layer->evas->engine.func->image_content_hint_set
1101 (obj->layer->evas->engine.data.output,
1102 o->engine_data, o->content_hint);
1103 if (obj->layer->evas->engine.func->image_stride_get)
1104 obj->layer->evas->engine.func->image_stride_get
1105 (obj->layer->evas->engine.data.output,
1106 o->engine_data, &stride);
1108 stride = o->cur.image.w * 4;
1109 o->cur.image.stride = stride;
1111 o->pixels_checked_out = 0;
1112 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
1116 evas_object_image_data_update_add(Evas_Object *obj, int x, int y, int w, int h)
1118 Evas_Object_Image *o;
1121 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1124 o = (Evas_Object_Image *)(obj->object_data);
1125 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1128 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur.image.w, o->cur.image.h);
1129 if ((w <= 0) || (h <= 0)) return;
1130 NEW_RECT(r, x, y, w, h);
1131 if (r) o->pixel_updates = eina_list_append(o->pixel_updates, r);
1133 evas_object_change(obj);
1137 evas_object_image_alpha_set(Evas_Object *obj, Eina_Bool has_alpha)
1139 Evas_Object_Image *o;
1141 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1144 o = (Evas_Object_Image *)(obj->object_data);
1145 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1148 if ((o->preloading) && (o->engine_data))
1151 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1155 if (((has_alpha) && (o->cur.has_alpha)) ||
1156 ((!has_alpha) && (!o->cur.has_alpha)))
1158 o->cur.has_alpha = has_alpha;
1163 #ifdef EVAS_FRAME_QUEUING
1164 evas_common_pipe_op_image_flush(o->engine_data);
1166 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1169 if (obj->layer->evas->engine.func->image_scale_hint_set)
1170 obj->layer->evas->engine.func->image_scale_hint_set
1171 (obj->layer->evas->engine.data.output,
1172 o->engine_data, o->scale_hint);
1173 if (obj->layer->evas->engine.func->image_content_hint_set)
1174 obj->layer->evas->engine.func->image_content_hint_set
1175 (obj->layer->evas->engine.data.output,
1176 o->engine_data, o->content_hint);
1177 if (obj->layer->evas->engine.func->image_stride_get)
1178 obj->layer->evas->engine.func->image_stride_get
1179 (obj->layer->evas->engine.data.output,
1180 o->engine_data, &stride);
1182 stride = o->cur.image.w * 4;
1183 o->cur.image.stride = stride;
1185 evas_object_image_data_update_add(obj, 0, 0, o->cur.image.w, o->cur.image.h);
1186 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
1191 evas_object_image_alpha_get(const Evas_Object *obj)
1193 Evas_Object_Image *o;
1195 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1198 o = (Evas_Object_Image *)(obj->object_data);
1199 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1202 return o->cur.has_alpha;
1206 evas_object_image_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth_scale)
1208 Evas_Object_Image *o;
1210 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1213 o = (Evas_Object_Image *)(obj->object_data);
1214 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1217 if (((smooth_scale) && (o->cur.smooth_scale)) ||
1218 ((!smooth_scale) && (!o->cur.smooth_scale)))
1220 o->cur.smooth_scale = smooth_scale;
1222 evas_object_change(obj);
1226 evas_object_image_smooth_scale_get(const Evas_Object *obj)
1228 Evas_Object_Image *o;
1230 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1233 o = (Evas_Object_Image *)(obj->object_data);
1234 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1237 return o->cur.smooth_scale;
1241 evas_object_image_reload(Evas_Object *obj)
1243 Evas_Object_Image *o;
1245 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1248 o = (Evas_Object_Image *)(obj->object_data);
1249 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1252 if ((o->preloading) && (o->engine_data))
1255 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1259 if ((!o->cur.file) ||
1260 (o->pixels_checked_out > 0)) return;
1262 o->engine_data = obj->layer->evas->engine.func->image_dirty_region(obj->layer->evas->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h);
1263 evas_object_image_unload(obj, 1);
1264 evas_object_inform_call_image_unloaded(obj);
1265 evas_object_image_load(obj);
1266 o->prev.file = NULL;
1269 evas_object_change(obj);
1273 evas_object_image_save(const Evas_Object *obj, const char *file, const char *key, const char *flags)
1275 Evas_Object_Image *o;
1276 DATA32 *data = NULL;
1277 int quality = 80, compress = 9, ok = 0;
1280 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1283 o = (Evas_Object_Image *)(obj->object_data);
1284 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1288 if (!o->engine_data) return 0;
1289 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1299 tflags = alloca(strlen(flags) + 1);
1300 strcpy(tflags, flags);
1304 pp = strchr(p, ' ');
1306 sscanf(p, "quality=%i", &quality);
1307 sscanf(p, "compress=%i", &compress);
1312 im = (RGBA_Image*) evas_cache_image_data(evas_common_image_cache_get(),
1317 EVAS_COLORSPACE_ARGB8888);
1320 if (o->cur.cspace == EVAS_COLORSPACE_ARGB8888)
1321 im->image.data = data;
1323 im->image.data = evas_object_image_data_convert_internal(o,
1325 EVAS_COLORSPACE_ARGB8888);
1328 ok = evas_common_save_image_to_file(im, file, key, quality, compress);
1330 if (o->cur.cspace != EVAS_COLORSPACE_ARGB8888)
1331 free(im->image.data);
1334 evas_cache_image_drop(&im->cache_entry);
1336 o->engine_data = obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
1343 evas_object_image_pixels_import(Evas_Object *obj, Evas_Pixel_Import_Source *pixels)
1345 Evas_Object_Image *o;
1347 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1350 o = (Evas_Object_Image *)(obj->object_data);
1351 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1354 _evas_object_image_cleanup(obj, o);
1355 if ((pixels->w != o->cur.image.w) || (pixels->h != o->cur.image.h)) return 0;
1356 switch (pixels->format)
1359 case EVAS_PIXEL_FORMAT_ARGB32:
1363 DATA32 *image_pixels = NULL;
1366 obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1371 /* FIXME: need to actualyl support this */
1372 /* memcpy(image_pixels, pixels->rows, o->cur.image.w * o->cur.image.h * 4);*/
1375 obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
1380 obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1384 evas_object_change(obj);
1389 #ifdef BUILD_CONVERT_YUV
1390 case EVAS_PIXEL_FORMAT_YUV420P_601:
1394 DATA32 *image_pixels = NULL;
1397 obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1403 evas_common_convert_yuv_420p_601_rgba((DATA8 **) pixels->rows,
1404 (DATA8 *) image_pixels,
1409 obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
1414 obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1418 evas_object_change(obj);
1431 evas_object_image_pixels_get_callback_set(Evas_Object *obj, Evas_Object_Image_Pixels_Get_Cb func, void *data)
1433 Evas_Object_Image *o;
1435 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1438 o = (Evas_Object_Image *)(obj->object_data);
1439 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1442 o->func.get_pixels = func;
1443 o->func.get_pixels_data = data;
1447 evas_object_image_pixels_dirty_set(Evas_Object *obj, Eina_Bool dirty)
1449 Evas_Object_Image *o;
1451 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1454 o = (Evas_Object_Image *)(obj->object_data);
1455 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1458 if (dirty) o->dirty_pixels = 1;
1459 else o->dirty_pixels = 0;
1461 evas_object_change(obj);
1465 evas_object_image_pixels_dirty_get(const Evas_Object *obj)
1467 Evas_Object_Image *o;
1469 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1472 o = (Evas_Object_Image *)(obj->object_data);
1473 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1476 if (o->dirty_pixels) return 1;
1481 evas_object_image_load_dpi_set(Evas_Object *obj, double dpi)
1483 Evas_Object_Image *o;
1485 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1488 o = (Evas_Object_Image *)(obj->object_data);
1489 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1492 if (dpi == o->load_opts.dpi) return;
1493 o->load_opts.dpi = dpi;
1496 evas_object_image_unload(obj, 0);
1497 evas_object_inform_call_image_unloaded(obj);
1498 evas_object_image_load(obj);
1500 evas_object_change(obj);
1505 evas_object_image_load_dpi_get(const Evas_Object *obj)
1507 Evas_Object_Image *o;
1509 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1512 o = (Evas_Object_Image *)(obj->object_data);
1513 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1516 return o->load_opts.dpi;
1520 evas_object_image_load_size_set(Evas_Object *obj, int w, int h)
1522 Evas_Object_Image *o;
1524 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1527 o = (Evas_Object_Image *)(obj->object_data);
1528 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1531 if ((o->load_opts.w == w) && (o->load_opts.h == h)) return;
1536 evas_object_image_unload(obj, 0);
1537 evas_object_inform_call_image_unloaded(obj);
1538 evas_object_image_load(obj);
1540 evas_object_change(obj);
1545 evas_object_image_load_size_get(const Evas_Object *obj, int *w, int *h)
1547 Evas_Object_Image *o;
1549 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1552 o = (Evas_Object_Image *)(obj->object_data);
1553 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1556 if (w) *w = o->load_opts.w;
1557 if (h) *h = o->load_opts.h;
1561 evas_object_image_load_scale_down_set(Evas_Object *obj, int scale_down)
1563 Evas_Object_Image *o;
1565 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1568 o = (Evas_Object_Image *)(obj->object_data);
1569 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1572 if (o->load_opts.scale_down_by == scale_down) return;
1573 o->load_opts.scale_down_by = scale_down;
1576 evas_object_image_unload(obj, 0);
1577 evas_object_inform_call_image_unloaded(obj);
1578 evas_object_image_load(obj);
1580 evas_object_change(obj);
1585 evas_object_image_load_scale_down_get(const Evas_Object *obj)
1587 Evas_Object_Image *o;
1589 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1592 o = (Evas_Object_Image *)(obj->object_data);
1593 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1596 return o->load_opts.scale_down_by;
1600 evas_object_image_load_region_set(Evas_Object *obj, int x, int y, int w, int h)
1602 Evas_Object_Image *o;
1604 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1607 o = (Evas_Object_Image *)(obj->object_data);
1608 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1611 if ((o->load_opts.region.x == x) && (o->load_opts.region.y == y) &&
1612 (o->load_opts.region.w == w) && (o->load_opts.region.h == h)) return;
1613 o->load_opts.region.x = x;
1614 o->load_opts.region.y = y;
1615 o->load_opts.region.w = w;
1616 o->load_opts.region.h = h;
1619 evas_object_image_unload(obj, 0);
1620 evas_object_inform_call_image_unloaded(obj);
1621 evas_object_image_load(obj);
1623 evas_object_change(obj);
1628 evas_object_image_load_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1630 Evas_Object_Image *o;
1632 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1635 o = (Evas_Object_Image *)(obj->object_data);
1636 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1639 if (x) *x = o->load_opts.region.x;
1640 if (y) *y = o->load_opts.region.y;
1641 if (w) *w = o->load_opts.region.w;
1642 if (h) *h = o->load_opts.region.h;
1646 evas_object_image_load_orientation_set(Evas_Object *obj, Eina_Bool enable)
1648 Evas_Object_Image *o;
1650 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1653 o = (Evas_Object_Image *)(obj->object_data);
1654 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1657 o->load_opts.orientation = !!enable;
1661 evas_object_image_load_orientation_get(const Evas_Object *obj)
1663 Evas_Object_Image *o;
1665 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1668 o = (Evas_Object_Image *)(obj->object_data);
1669 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1672 return o->load_opts.orientation;
1676 evas_object_image_colorspace_set(Evas_Object *obj, Evas_Colorspace cspace)
1678 Evas_Object_Image *o;
1680 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1683 o = (Evas_Object_Image *)(obj->object_data);
1684 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1688 _evas_object_image_cleanup(obj, o);
1689 #ifdef EVAS_FRAME_QUEUING
1690 if ((Evas_Colorspace)o->cur.cspace != cspace)
1693 evas_common_pipe_op_image_flush(o->engine_data);
1697 o->cur.cspace = cspace;
1699 obj->layer->evas->engine.func->image_colorspace_set(obj->layer->evas->engine.data.output,
1704 EAPI Evas_Colorspace
1705 evas_object_image_colorspace_get(const Evas_Object *obj)
1707 Evas_Object_Image *o;
1709 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1710 return EVAS_COLORSPACE_ARGB8888;
1712 o = (Evas_Object_Image *)(obj->object_data);
1713 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1714 return EVAS_COLORSPACE_ARGB8888;
1716 return o->cur.cspace;
1720 evas_object_image_video_surface_set(Evas_Object *obj, Evas_Video_Surface *surf)
1722 Evas_Object_Image *o;
1724 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1727 o = (Evas_Object_Image *)(obj->object_data);
1728 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1731 _evas_object_image_cleanup(obj, o);
1732 if (o->video_surface)
1734 o->video_surface = 0;
1735 obj->layer->evas->video_objects = eina_list_remove(obj->layer->evas->video_objects, obj);
1740 if (surf->version != EVAS_VIDEO_SURFACE_VERSION) return ;
1742 if (!surf->update_pixels ||
1749 o->created = EINA_TRUE;
1750 o->video_surface = 1;
1753 obj->layer->evas->video_objects = eina_list_append(obj->layer->evas->video_objects, obj);
1757 o->video_surface = 0;
1758 o->video.update_pixels = NULL;
1759 o->video.move = NULL;
1760 o->video.resize = NULL;
1761 o->video.hide = NULL;
1762 o->video.show = NULL;
1763 o->video.data = NULL;
1767 EAPI const Evas_Video_Surface *
1768 evas_object_image_video_surface_get(const Evas_Object *obj)
1770 Evas_Object_Image *o;
1772 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1775 o = (Evas_Object_Image *)(obj->object_data);
1776 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1779 if (!o->video_surface) return NULL;
1784 evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface *surf)
1786 Evas_Object_Image *o;
1788 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1791 o = (Evas_Object_Image *)(obj->object_data);
1792 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1795 _evas_object_image_cleanup(obj, o);
1796 if (!obj->layer->evas->engine.func->image_native_set) return;
1798 ((surf->version < 2) ||
1799 (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return;
1801 obj->layer->evas->engine.func->image_native_set(obj->layer->evas->engine.data.output,
1806 EAPI Evas_Native_Surface *
1807 evas_object_image_native_surface_get(const Evas_Object *obj)
1809 Evas_Object_Image *o;
1811 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1814 o = (Evas_Object_Image *)(obj->object_data);
1815 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1818 if (!obj->layer->evas->engine.func->image_native_get) return NULL;
1819 return obj->layer->evas->engine.func->image_native_get(obj->layer->evas->engine.data.output,
1824 evas_object_image_scale_hint_set(Evas_Object *obj, Evas_Image_Scale_Hint hint)
1826 Evas_Object_Image *o;
1828 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1831 o = (Evas_Object_Image *)(obj->object_data);
1832 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1835 if (o->scale_hint == hint) return;
1836 #ifdef EVAS_FRAME_QUEUING
1838 evas_common_pipe_op_image_flush(o->engine_data);
1840 o->scale_hint = hint;
1845 if (obj->layer->evas->engine.func->image_scale_hint_set)
1846 obj->layer->evas->engine.func->image_scale_hint_set
1847 (obj->layer->evas->engine.data.output,
1848 o->engine_data, o->scale_hint);
1849 if (obj->layer->evas->engine.func->image_stride_get)
1850 obj->layer->evas->engine.func->image_stride_get
1851 (obj->layer->evas->engine.data.output,
1852 o->engine_data, &stride);
1854 stride = o->cur.image.w * 4;
1855 o->cur.image.stride = stride;
1859 EAPI Evas_Image_Scale_Hint
1860 evas_object_image_scale_hint_get(const Evas_Object *obj)
1862 Evas_Object_Image *o;
1864 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1865 return EVAS_IMAGE_SCALE_HINT_NONE;
1867 o = (Evas_Object_Image *)(obj->object_data);
1868 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1869 return EVAS_IMAGE_SCALE_HINT_NONE;
1871 return o->scale_hint;
1875 evas_object_image_content_hint_set(Evas_Object *obj, Evas_Image_Content_Hint hint)
1877 Evas_Object_Image *o;
1879 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1882 o = (Evas_Object_Image *)(obj->object_data);
1883 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1886 if (o->content_hint == hint) return;
1887 #ifdef EVAS_FRAME_QUEUING
1889 evas_common_pipe_op_image_flush(o->engine_data);
1891 o->content_hint = hint;
1896 if (obj->layer->evas->engine.func->image_content_hint_set)
1897 obj->layer->evas->engine.func->image_content_hint_set
1898 (obj->layer->evas->engine.data.output,
1899 o->engine_data, o->content_hint);
1900 if (obj->layer->evas->engine.func->image_stride_get)
1901 obj->layer->evas->engine.func->image_stride_get
1902 (obj->layer->evas->engine.data.output,
1903 o->engine_data, &stride);
1905 stride = o->cur.image.w * 4;
1906 o->cur.image.stride = stride;
1911 evas_object_image_alpha_mask_set(Evas_Object *obj, Eina_Bool ismask)
1913 Evas_Object_Image *o;
1915 if (!ismask) return;
1917 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1920 o = (Evas_Object_Image *)(obj->object_data);
1921 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1925 /* Convert to A8 if not already */
1931 #define FRAME_MAX 1024
1932 EAPI Evas_Image_Content_Hint
1933 evas_object_image_content_hint_get(const Evas_Object *obj)
1935 Evas_Object_Image *o;
1937 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1938 return EVAS_IMAGE_CONTENT_HINT_NONE;
1940 o = (Evas_Object_Image *)(obj->object_data);
1941 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1942 return EVAS_IMAGE_CONTENT_HINT_NONE;
1944 return o->content_hint;
1948 evas_object_image_region_support_get(const Evas_Object *obj)
1950 Evas_Object_Image *o;
1952 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1955 o = (Evas_Object_Image *) (obj->object_data);
1956 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1960 return obj->layer->evas->engine.func->image_can_region_get(
1961 obj->layer->evas->engine.data.output,
1965 /* animated feature */
1967 evas_object_image_animated_get(const Evas_Object *obj)
1969 Evas_Object_Image *o;
1971 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1974 o = (Evas_Object_Image *)(obj->object_data);
1975 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1979 if (obj->layer->evas->engine.func->image_animated_get)
1980 return obj->layer->evas->engine.func->image_animated_get(obj->layer->evas->engine.data.output, o->engine_data);
1985 evas_object_image_animated_frame_count_get(const Evas_Object *obj)
1987 Evas_Object_Image *o;
1989 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1992 o = (Evas_Object_Image *)(obj->object_data);
1993 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1997 if (!evas_object_image_animated_get(obj)) return -1;
1998 if (obj->layer->evas->engine.func->image_animated_frame_count_get)
1999 return obj->layer->evas->engine.func->image_animated_frame_count_get(obj->layer->evas->engine.data.output, o->engine_data);
2003 EAPI Evas_Image_Animated_Loop_Hint
2004 evas_object_image_animated_loop_type_get(const Evas_Object *obj)
2006 Evas_Object_Image *o;
2008 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
2009 return EVAS_IMAGE_ANIMATED_HINT_NONE;
2011 o = (Evas_Object_Image *)(obj->object_data);
2012 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2013 return EVAS_IMAGE_ANIMATED_HINT_NONE;
2016 if (!evas_object_image_animated_get(obj)) return EVAS_IMAGE_ANIMATED_HINT_NONE;
2018 if (obj->layer->evas->engine.func->image_animated_loop_type_get)
2019 return obj->layer->evas->engine.func->image_animated_loop_type_get(obj->layer->evas->engine.data.output, o->engine_data);
2020 return EVAS_IMAGE_ANIMATED_HINT_NONE;
2024 evas_object_image_animated_loop_count_get(const Evas_Object *obj)
2026 Evas_Object_Image *o;
2028 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
2031 o = (Evas_Object_Image *)(obj->object_data);
2032 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2036 if (!evas_object_image_animated_get(obj)) return -1;
2038 if (obj->layer->evas->engine.func->image_animated_loop_count_get)
2039 return obj->layer->evas->engine.func->image_animated_loop_count_get(obj->layer->evas->engine.data.output, o->engine_data);
2044 evas_object_image_animated_frame_duration_get(const Evas_Object *obj, int start_frame, int frame_num)
2046 Evas_Object_Image *o;
2047 int frame_count = 0;
2049 if (start_frame < 1) return -1;
2050 if (frame_num < 0) return -1;
2052 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
2055 o = (Evas_Object_Image *)(obj->object_data);
2056 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2060 if (!evas_object_image_animated_get(obj)) return -1;
2062 if (!obj->layer->evas->engine.func->image_animated_frame_count_get) return -1;
2064 frame_count = obj->layer->evas->engine.func->image_animated_frame_count_get(obj->layer->evas->engine.data.output, o->engine_data);
2066 if ((start_frame + frame_num) > frame_count) return -1;
2067 if (obj->layer->evas->engine.func->image_animated_frame_duration_get)
2068 return obj->layer->evas->engine.func->image_animated_frame_duration_get(obj->layer->evas->engine.data.output, o->engine_data, start_frame, frame_num);
2073 evas_object_image_animated_frame_set(Evas_Object *obj, int frame_index)
2075 Evas_Object_Image *o;
2076 int frame_count = 0;
2078 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
2081 o = (Evas_Object_Image *)(obj->object_data);
2082 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2086 if (!o->cur.file) return;
2087 if (o->cur.frame == frame_index) return;
2089 if (!evas_object_image_animated_get(obj)) return;
2091 frame_count = evas_object_image_animated_frame_count_get(obj);
2093 /* limit the size of frame to FRAME_MAX */
2094 if ((frame_count > FRAME_MAX) || (frame_count < 0) || (frame_index > frame_count))
2097 if (!obj->layer->evas->engine.func->image_animated_frame_set) return;
2098 if (!obj->layer->evas->engine.func->image_animated_frame_set(obj->layer->evas->engine.data.output, o->engine_data, frame_index))
2101 o->prev.frame = o->cur.frame;
2102 o->cur.frame = frame_index;
2105 evas_object_change(obj);
2110 evas_image_cache_flush(Evas *e)
2112 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2116 e->engine.func->image_cache_flush(e->engine.data.output);
2120 evas_image_cache_reload(Evas *e)
2124 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2128 evas_image_cache_flush(e);
2129 EINA_INLIST_FOREACH(e->layers, layer)
2133 EINA_INLIST_FOREACH(layer->objects, obj)
2135 Evas_Object_Image *o;
2137 o = (Evas_Object_Image *)(obj->object_data);
2138 if (o->magic == MAGIC_OBJ_IMAGE)
2140 evas_object_image_unload(obj, 1);
2141 evas_object_inform_call_image_unloaded(obj);
2145 evas_image_cache_flush(e);
2146 EINA_INLIST_FOREACH(e->layers, layer)
2150 EINA_INLIST_FOREACH(layer->objects, obj)
2152 Evas_Object_Image *o;
2154 o = (Evas_Object_Image *)(obj->object_data);
2155 if (o->magic == MAGIC_OBJ_IMAGE)
2157 evas_object_image_load(obj);
2159 evas_object_change(obj);
2163 evas_image_cache_flush(e);
2167 evas_image_cache_set(Evas *e, int size)
2169 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2173 if (size < 0) size = 0;
2174 e->engine.func->image_cache_set(e->engine.data.output, size);
2178 evas_image_cache_get(const Evas *e)
2180 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2184 return e->engine.func->image_cache_get(e->engine.data.output);
2188 evas_image_max_size_get(const Evas *e, int *maxw, int *maxh)
2191 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2195 if (maxw) *maxw = 0xffff;
2196 if (maxh) *maxh = 0xffff;
2197 if (!e->engine.func->image_max_size_get) return EINA_FALSE;
2198 e->engine.func->image_max_size_get(e->engine.data.output, &w, &h);
2199 if (maxw) *maxw = w;
2200 if (maxh) *maxh = h;
2204 /* all nice and private */
2206 _proxy_unset(Evas_Object *proxy)
2208 Evas_Object_Image *o;
2210 o = proxy->object_data;
2211 if (!o->cur.source) return;
2213 o->cur.source->proxy.proxies = eina_list_remove(o->cur.source->proxy.proxies, proxy);
2215 o->cur.source = NULL;
2218 evas_map_free(o->cur.defmap);
2219 o->cur.defmap = NULL;
2225 _proxy_set(Evas_Object *proxy, Evas_Object *src)
2227 Evas_Object_Image *o;
2229 o = proxy->object_data;
2231 evas_object_image_file_set(proxy, NULL, NULL);
2233 o->cur.source = src;
2235 src->proxy.proxies = eina_list_append(src->proxy.proxies, proxy);
2236 src->proxy.redraw = EINA_TRUE;
2239 /* Some moron just set a proxy on a proxy.
2240 * Give them some pixels. A random color
2243 _proxy_error(Evas_Object *proxy, void *context, void *output, void *surface,
2247 int r = rand() % 255;
2248 int g = rand() % 255;
2249 int b = rand() % 255;
2251 /* XXX: Eina log error or something I'm sure
2252 * If it bugs you, just fix it. Don't tell me */
2253 if (VERBOSE_PROXY_ERROR) printf("Err: Argh! Recursive proxies.\n");
2255 func = proxy->layer->evas->engine.func;
2256 func->context_color_set(output, context, r, g, b, 255);
2257 func->context_multiplier_unset(output, context);
2258 func->context_render_op_set(output, context, proxy->cur.render_op);
2259 func->rectangle_draw(output, context, surface, proxy->cur.geometry.x + x,
2260 proxy->cur.geometry.y + y,
2261 proxy->cur.geometry.w,
2262 proxy->cur.geometry.h);
2268 _proxy_subrender_recurse(Evas_Object *obj, Evas_Object *clip, void *output, void *surface, void *ctx, int x, int y)
2271 Evas *e = obj->layer->evas;
2273 if (obj->clip.clipees) return;
2274 if (!obj->cur.visible) return;
2275 if ((!clip) || (clip != obj->cur.clipper))
2277 if (!obj->cur.cache.clip.visible) return;
2278 if ((obj->cur.cache.clip.a == 0) &&
2279 (obj->cur.render_op == EVAS_RENDER_BLEND)) return;
2281 if ((obj->func->is_visible) && (!obj->func->is_visible(obj))) return;
2283 if (!obj->pre_render_done)
2284 obj->func->render_pre(obj);
2285 ctx = e->engine.func->context_new(output);
2286 if (obj->smart.smart)
2288 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
2290 _proxy_subrender_recurse(obj2, clip, output, surface, ctx, x, y);
2295 obj->func->render(obj, output, ctx, surface, x, y);
2297 e->engine.func->context_free(output, ctx);
2302 * Render the source object when a proxy is set.
2304 * Used to force a draw if necessary, else just makes sures it's available.
2307 _proxy_subrender(Evas *e, Evas_Object *source)
2310 /* Evas_Object *obj2, *clip;*/
2313 if (!source) return;
2315 w = source->cur.geometry.w;
2316 h = source->cur.geometry.h;
2318 source->proxy.redraw = EINA_FALSE;
2320 /* We need to redraw surface then */
2321 if ((source->proxy.surface) &&
2322 ((source->proxy.w != w) || (source->proxy.h != h)))
2324 e->engine.func->image_map_surface_free(e->engine.data.output,
2325 source->proxy.surface);
2326 source->proxy.surface = NULL;
2329 /* FIXME: Hardcoded alpha 'on' */
2330 /* FIXME (cont): Should see if the object has alpha */
2331 if (!source->proxy.surface)
2333 source->proxy.surface = e->engine.func->image_map_surface_new
2334 (e->engine.data.output, w, h, 1);
2335 source->proxy.w = w;
2336 source->proxy.h = h;
2339 ctx = e->engine.func->context_new(e->engine.data.output);
2340 e->engine.func->context_color_set(e->engine.data.output, ctx, 0, 0, 0, 0);
2341 e->engine.func->context_render_op_set(e->engine.data.output, ctx, EVAS_RENDER_COPY);
2342 e->engine.func->rectangle_draw(e->engine.data.output, ctx,
2343 source->proxy.surface, 0, 0, w, h);
2344 e->engine.func->context_free(e->engine.data.output, ctx);
2346 ctx = e->engine.func->context_new(e->engine.data.output);
2347 evas_render_mapped(e, source, ctx, source->proxy.surface,
2348 -source->cur.geometry.x,
2349 -source->cur.geometry.y,
2350 1, 0, 0, e->output.w, e->output.h);
2351 e->engine.func->context_free(e->engine.data.output, ctx);
2352 source->proxy.surface = e->engine.func->image_dirty_region
2353 (e->engine.data.output, source->proxy.surface, 0, 0, w, h);
2355 ctx = e->engine.func->context_new(e->engine.data.output);
2356 if (source->smart.smart)
2358 clip = evas_object_smart_clipped_clipper_get(source);
2359 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(source), obj2)
2361 _proxy_subrender_recurse(obj2, clip, e->engine.data.output,
2362 source->proxy.surface,
2364 -source->cur.geometry.x,
2365 -source->cur.geometry.y);
2370 if (!source->pre_render_done)
2371 source->func->render_pre(source);
2372 source->func->render(source, e->engine.data.output, ctx,
2373 source->proxy.surface,
2374 -source->cur.geometry.x,
2375 -source->cur.geometry.y);
2378 e->engine.func->context_free(e->engine.data.output, ctx);
2379 source->proxy.surface = e->engine.func->image_dirty_region
2380 (e->engine.data.output, source->proxy.surface, 0, 0, w, h);
2384 #if 0 // filtering disabled
2387 * Note that this is similar to proxy_subrender_recurse. It should be
2388 * possible to merge I guess
2391 image_filter_draw_under_recurse(Evas *e, Evas_Object *obj, Evas_Object *stop,
2392 void *output, void *ctx, void *surface,
2397 if (obj->clip.clipees) return;
2398 /* FIXME: Doing bounding box test */
2399 if (!evas_object_is_in_output_rect(obj, stop->cur.geometry.x,
2400 stop->cur.geometry.y,
2401 stop->cur.geometry.w,
2402 stop->cur.geometry.h))
2405 if (!evas_object_is_visible(obj)) return;
2406 obj->pre_render_done = 1;
2407 ctx = e->engine.func->context_new(output);
2409 if (obj->smart.smart)
2411 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
2413 if (obj2 == stop) return;
2414 image_filter_draw_under_recurse(e, obj2, stop, output, surface,
2419 obj->func->render(obj, output, ctx, surface, x ,y);
2420 e->engine.func->context_free(output, ctx);
2424 * Draw all visible objects intersecting an object which are _beneath_ it.
2427 image_filter_draw_under(Evas *e, Evas_Object *stop, void *output, void *ctx, void *surface, int dx, int dy)
2432 x = stop->cur.geometry.x - dx;
2433 y = stop->cur.geometry.y - dy;
2435 EINA_INLIST_FOREACH(e->layers, lay)
2438 EINA_INLIST_FOREACH(lay->objects, obj)
2440 if (obj->delete_me) continue;
2441 if (obj == stop) return;
2442 /* FIXME: Do bounding box check */
2443 image_filter_draw_under_recurse(e, obj, stop, output, ctx,
2447 e->engine.func->image_dirty_region(output, surface, 0, 0, 300, 300);
2448 e->engine.func->output_flush(output);
2452 * Update the filtered object.
2454 * Creates a new context, and renders stuff (filtered) onto that.
2457 image_filter_update(Evas *e, Evas_Object *obj, void *src, int imagew, int imageh, int *outw, int *outh)
2461 Evas_Filter_Info *info;
2467 if (info->mode == EVAS_FILTER_MODE_BELOW)
2469 w = obj->cur.geometry.w;
2470 h = obj->cur.geometry.h;
2471 evas_filter_get_size(info, w, h, &imagew, &imageh, EINA_TRUE);
2476 evas_filter_get_size(info, imagew, imageh, &w, &h, EINA_FALSE);
2477 alpha = e->engine.func->image_alpha_get(e->engine.data.output, src);
2480 /* Certain filters may make alpha images anyway */
2481 if (alpha == EINA_FALSE) alpha = evas_filter_always_alpha(info);
2483 surface = e->engine.func->image_map_surface_new(e->engine.data.output, w, h,
2486 if (info->mode == EVAS_FILTER_MODE_BELOW)
2491 disw = obj->cur.geometry.w;
2492 dish = obj->cur.geometry.h;
2493 dx = (imagew - w) >> 1;
2494 dy = (imageh - h) >> 1;
2495 subsurface = e->engine.func->image_map_surface_new
2496 (e->engine.data.output, imagew, imageh, 1);
2497 ctx = e->engine.func->context_new(e->engine.data.output);
2498 e->engine.func->context_color_set(e->engine.data.output, ctx, 0, 255, 0, 255);
2499 e->engine.func->context_render_op_set(e->engine.data.output, ctx, EVAS_RENDER_COPY);
2500 e->engine.func->rectangle_draw(e->engine.data.output, ctx,
2501 subsurface, 0, 0, imagew, imageh);
2503 image_filter_draw_under(e, obj, e->engine.data.output, ctx,
2504 subsurface, dx, dy);
2506 e->engine.func->context_free(e->engine.data.output, ctx);
2508 ctx = e->engine.func->context_new(e->engine.data.output);
2510 e->engine.func->image_draw_filtered(e->engine.data.output,
2511 ctx, surface, subsurface, info);
2513 e->engine.func->context_free(e->engine.data.output, ctx);
2515 e->engine.func->image_map_surface_free(e->engine.data.output,
2520 ctx = e->engine.func->context_new(e->engine.data.output);
2521 e->engine.func->image_draw_filtered(e->engine.data.output,
2522 ctx, surface, src, info);
2523 e->engine.func->context_free(e->engine.data.output, ctx);
2526 e->engine.func->image_dirty_region(e->engine.data.output, surface,
2528 if (outw) *outw = w;
2529 if (outh) *outh = h;
2530 return e->engine.func->image_filtered_save(src, surface,
2537 evas_object_image_unload(Evas_Object *obj, Eina_Bool dirty)
2539 Evas_Object_Image *o;
2541 o = (Evas_Object_Image *)(obj->object_data);
2543 if ((!o->cur.file) ||
2544 (o->pixels_checked_out > 0)) return;
2548 o->engine_data = obj->layer->evas->engine.func->image_dirty_region
2549 (obj->layer->evas->engine.data.output,
2552 o->cur.image.w, o->cur.image.h);
2559 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
2563 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
2566 o->engine_data = NULL;
2567 o->load_error = EVAS_LOAD_ERROR_NONE;
2568 o->cur.has_alpha = 1;
2569 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
2572 o->cur.image.stride = 0;
2576 evas_object_image_load(Evas_Object *obj)
2578 Evas_Object_Image *o;
2579 Evas_Image_Load_Opts lo;
2581 o = (Evas_Object_Image *)(obj->object_data);
2582 if (o->engine_data) return;
2584 lo.scale_down_by = o->load_opts.scale_down_by;
2585 lo.dpi = o->load_opts.dpi;
2586 lo.w = o->load_opts.w;
2587 lo.h = o->load_opts.h;
2588 lo.region.x = o->load_opts.region.x;
2589 lo.region.y = o->load_opts.region.y;
2590 lo.region.w = o->load_opts.region.w;
2591 lo.region.h = o->load_opts.region.h;
2592 lo.orientation = o->load_opts.orientation;
2593 o->engine_data = obj->layer->evas->engine.func->image_load
2594 (obj->layer->evas->engine.data.output,
2604 obj->layer->evas->engine.func->image_size_get
2605 (obj->layer->evas->engine.data.output,
2606 o->engine_data, &w, &h);
2607 if (obj->layer->evas->engine.func->image_stride_get)
2608 obj->layer->evas->engine.func->image_stride_get
2609 (obj->layer->evas->engine.data.output,
2610 o->engine_data, &stride);
2613 o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get
2614 (obj->layer->evas->engine.data.output,
2616 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get
2617 (obj->layer->evas->engine.data.output,
2621 o->cur.image.stride = stride;
2625 o->load_error = EVAS_LOAD_ERROR_GENERIC;
2630 evas_object_image_figure_x_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret)
2634 w = ((size * obj->layer->evas->output.w) /
2635 (Evas_Coord)obj->layer->evas->viewport.w);
2636 if (size <= 0) size = 1;
2639 while (start - size > 0) start -= size;
2643 while (start < 0) start += size;
2645 start = ((start * obj->layer->evas->output.w) /
2646 (Evas_Coord)obj->layer->evas->viewport.w);
2652 evas_object_image_figure_y_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret)
2656 h = ((size * obj->layer->evas->output.h) /
2657 (Evas_Coord)obj->layer->evas->viewport.h);
2658 if (size <= 0) size = 1;
2661 while (start - size > 0) start -= size;
2665 while (start < 0) start += size;
2667 start = ((start * obj->layer->evas->output.h) /
2668 (Evas_Coord)obj->layer->evas->viewport.h);
2674 evas_object_image_init(Evas_Object *obj)
2676 /* alloc image ob, setup methods and default values */
2677 obj->object_data = evas_object_image_new();
2678 /* set up default settings for this kind of object */
2679 obj->cur.color.r = 255;
2680 obj->cur.color.g = 255;
2681 obj->cur.color.b = 255;
2682 obj->cur.color.a = 255;
2683 obj->cur.geometry.x = 0;
2684 obj->cur.geometry.y = 0;
2685 obj->cur.geometry.w = 0;
2686 obj->cur.geometry.h = 0;
2688 obj->cur.anti_alias = 0;
2689 obj->cur.render_op = EVAS_RENDER_BLEND;
2690 /* set up object-specific settings */
2691 obj->prev = obj->cur;
2692 /* set up methods (compulsory) */
2693 obj->func = &object_func;
2698 evas_object_image_new(void)
2700 Evas_Object_Image *o;
2702 /* alloc obj private data */
2703 EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_image", Evas_Object_Image, 256, NULL);
2704 o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Image);
2705 if (!o) return NULL;
2706 EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Image);
2707 o->magic = MAGIC_OBJ_IMAGE;
2710 o->cur.smooth_scale = 1;
2711 o->cur.border.fill = 1;
2712 o->cur.border.scale = 1.0;
2713 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
2714 o->cur.spread = EVAS_TEXTURE_REPEAT;
2715 o->cur.opaque_valid = 0;
2716 o->cur.source = NULL;
2723 evas_object_image_free(Evas_Object *obj)
2725 Evas_Object_Image *o;
2728 /* frees private object data. very simple here */
2729 o = (Evas_Object_Image *)(obj->object_data);
2730 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2735 if (o->cur.file) eina_stringshare_del(o->cur.file);
2736 if (o->cur.key) eina_stringshare_del(o->cur.key);
2737 if (o->cur.source) _proxy_unset(obj);
2743 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
2747 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
2750 if (o->video_surface)
2752 o->video_surface = 0;
2753 obj->layer->evas->video_objects = eina_list_remove(obj->layer->evas->video_objects, obj);
2755 o->engine_data = NULL;
2757 EINA_LIST_FREE(o->pixel_updates, r)
2758 eina_rectangle_free(r);
2759 EVAS_MEMPOOL_FREE(_mp_obj, o);
2763 evas_object_image_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y)
2765 Evas_Object_Image *o;
2766 int imagew, imageh, uvw, uvh;
2769 /* render object to surface with context, and offset by x,y */
2770 o = (Evas_Object_Image *)(obj->object_data);
2772 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
2773 return; /* no error message, already printed in pre_render */
2776 if (o->proxyrendering)
2778 _proxy_error(obj, context, output, surface, x, y);
2782 /* We are displaying the overlay */
2783 if (o->video_visible)
2785 /* Create a transparent rectangle */
2786 obj->layer->evas->engine.func->context_color_set(output,
2789 obj->layer->evas->engine.func->context_multiplier_unset(output,
2791 obj->layer->evas->engine.func->context_render_op_set(output, context,
2793 obj->layer->evas->engine.func->rectangle_draw(output,
2796 obj->cur.geometry.x + x,
2797 obj->cur.geometry.y + y,
2798 obj->cur.geometry.w,
2799 obj->cur.geometry.h);
2804 obj->layer->evas->engine.func->context_color_set(output,
2806 255, 255, 255, 255);
2808 if ((obj->cur.cache.clip.r == 255) &&
2809 (obj->cur.cache.clip.g == 255) &&
2810 (obj->cur.cache.clip.b == 255) &&
2811 (obj->cur.cache.clip.a == 255))
2813 obj->layer->evas->engine.func->context_multiplier_unset(output,
2817 obj->layer->evas->engine.func->context_multiplier_set(output,
2819 obj->cur.cache.clip.r,
2820 obj->cur.cache.clip.g,
2821 obj->cur.cache.clip.b,
2822 obj->cur.cache.clip.a);
2824 obj->layer->evas->engine.func->context_render_op_set(output, context,
2825 obj->cur.render_op);
2829 pixels = o->engine_data;
2830 imagew = o->cur.image.w;
2831 imageh = o->cur.image.h;
2835 else if (o->cur.source->proxy.surface && !o->cur.source->proxy.redraw)
2837 pixels = o->cur.source->proxy.surface;
2838 imagew = o->cur.source->proxy.w;
2839 imageh = o->cur.source->proxy.h;
2843 else if (o->cur.source->type == o_type &&
2844 ((Evas_Object_Image *)o->cur.source->object_data)->engine_data)
2846 Evas_Object_Image *oi;
2847 oi = o->cur.source->object_data;
2848 pixels = oi->engine_data;
2849 imagew = oi->cur.image.w;
2850 imageh = oi->cur.image.h;
2851 uvw = o->cur.source->cur.geometry.w;
2852 uvh = o->cur.source->cur.geometry.h;
2856 o->proxyrendering = 1;
2857 _proxy_subrender(obj->layer->evas, o->cur.source);
2858 pixels = o->cur.source->proxy.surface;
2859 imagew = o->cur.source->proxy.w;
2860 imageh = o->cur.source->proxy.h;
2863 o->proxyrendering = 0;
2866 #if 0 // filtering disabled
2867 /* Now check/update filter */
2868 if (obj->filter && obj->filter->filter)
2870 Filtered_Image *fi = NULL;
2871 //printf("%p has filter: %s\n", obj,obj->filter->dirty?"dirty":"clean");
2872 if (obj->filter->dirty)
2874 if (obj->filter->mode != EVAS_FILTER_MODE_BELOW)
2879 if (obj->filter->key) free(obj->filter->key);
2880 obj->filter->key = NULL;
2881 obj->filter->len = 0;
2882 key = evas_filter_key_get(obj->filter, &len);
2885 obj->filter->key = key;
2886 obj->filter->len = len;
2887 fi = obj->layer->evas->engine.func->image_filtered_get
2888 (o->engine_data, key, len);
2889 if (obj->filter->cached && fi != obj->filter->cached)
2891 obj->layer->evas->engine.func->image_filtered_free
2892 (o->engine_data, obj->filter->cached);
2893 obj->filter->cached = NULL;
2897 else if (obj->filter->cached)
2899 obj->layer->evas->engine.func->image_filtered_free
2900 (o->engine_data, obj->filter->cached);
2903 fi = image_filter_update(obj->layer->evas, obj, pixels,
2904 imagew, imageh, &imagew, &imageh);
2906 obj->filter->dirty = 0;
2907 obj->filter->cached = fi;
2911 fi = obj->filter->cached;
2919 Evas_Coord idw, idh, idx, idy;
2923 if (o->dirty_pixels)
2925 if (o->func.get_pixels)
2927 // Set img object for direct rendering optimization
2928 // Check for image w/h against image geometry w/h
2929 // Check for image color r,g,b,a = {255,255,255,255}
2930 // Check and make sure that there are no maps.
2931 if ( (obj->cur.geometry.w == o->cur.image.w) &&
2932 (obj->cur.geometry.h == o->cur.image.h) &&
2933 (obj->cur.color.r == 255) &&
2934 (obj->cur.color.g == 255) &&
2935 (obj->cur.color.b == 255) &&
2936 (obj->cur.color.a == 255) &&
2939 if (obj->layer->evas->engine.func->gl_img_obj_set)
2941 obj->layer->evas->engine.func->gl_img_obj_set(output, obj, o->cur.has_alpha);
2946 o->func.get_pixels(o->func.get_pixels_data, obj);
2947 if (o->engine_data != pixels)
2948 pixels = o->engine_data;
2949 o->engine_data = obj->layer->evas->engine.func->image_dirty_region
2950 (obj->layer->evas->engine.data.output, o->engine_data,
2951 0, 0, o->cur.image.w, o->cur.image.h);
2953 o->dirty_pixels = 0;
2955 if ((obj->cur.map) && (obj->cur.map->count > 3) && (obj->cur.usemap))
2957 const Evas_Map_Point *p, *p_end;
2958 RGBA_Map_Point pts[obj->cur.map->count], *pt;
2960 p = obj->cur.map->points;
2961 p_end = p + obj->cur.map->count;
2964 pts[0].px = obj->cur.map->persp.px << FP;
2965 pts[0].py = obj->cur.map->persp.py << FP;
2966 pts[0].foc = obj->cur.map->persp.foc << FP;
2967 pts[0].z0 = obj->cur.map->persp.z0 << FP;
2969 for (; p < p_end; p++, pt++)
2971 pt->x = (lround(p->x) + x) * FP1;
2972 pt->y = (lround(p->y) + y) * FP1;
2973 pt->z = (lround(p->z) ) * FP1;
2977 pt->u = ((lround(p->u) * imagew) / uvw) * FP1;
2978 pt->v = ((lround(p->v) * imageh) / uvh) * FP1;
2979 if (pt->u < 0) pt->u = 0;
2980 else if (pt->u > (imagew * FP1)) pt->u = (imagew * FP1);
2981 if (pt->v < 0) pt->v = 0;
2982 else if (pt->v > (imageh * FP1)) pt->v = (imageh * FP1);
2983 pt->col = ARGB_JOIN(p->a, p->r, p->g, p->b);
2985 if (obj->cur.map->count & 0x1)
2987 pts[obj->cur.map->count] = pts[obj->cur.map->count -1];
2990 obj->layer->evas->engine.func->image_map_draw
2991 (output, context, surface, pixels, obj->cur.map->count,
2992 pts, o->cur.smooth_scale | obj->cur.map->smooth, 0);
2996 obj->layer->evas->engine.func->image_scale_hint_set(output,
2999 /* This is technically a bug here: If the value is recreated
3000 * (which is returned)it may be a new object, however exactly 0
3001 * of all the evas engines do this. */
3002 obj->layer->evas->engine.func->image_border_set(output, pixels,
3003 o->cur.border.l, o->cur.border.r,
3004 o->cur.border.t, o->cur.border.b);
3005 idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
3006 idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
3007 if (idw < 1) idw = 1;
3008 if (idh < 1) idh = 1;
3009 if (idx > 0) idx -= idw;
3010 if (idy > 0) idy -= idh;
3011 while ((int)idx < obj->cur.geometry.w)
3018 if ((o->cur.fill.w == obj->cur.geometry.w) &&
3019 (o->cur.fill.x == 0))
3022 iw = obj->cur.geometry.w;
3025 iw = ((int)(idx + idw)) - ix;
3026 while ((int)idy < obj->cur.geometry.h)
3031 if ((o->cur.fill.h == obj->cur.geometry.h) &&
3032 (o->cur.fill.y == 0))
3034 ih = obj->cur.geometry.h;
3038 ih = ((int)(idy + idh)) - iy;
3039 if ((o->cur.border.l == 0) &&
3040 (o->cur.border.r == 0) &&
3041 (o->cur.border.t == 0) &&
3042 (o->cur.border.b == 0) &&
3043 (o->cur.border.fill != 0))
3044 obj->layer->evas->engine.func->image_draw(output,
3051 obj->cur.geometry.x + ix + x,
3052 obj->cur.geometry.y + iy + y,
3054 o->cur.smooth_scale);
3057 int inx, iny, inw, inh, outx, outy, outw, outh;
3058 int bl, br, bt, bb, bsl, bsr, bst, bsb;
3059 int imw, imh, ox, oy;
3061 ox = obj->cur.geometry.x + ix + x;
3062 oy = obj->cur.geometry.y + iy + y;
3065 bl = o->cur.border.l;
3066 br = o->cur.border.r;
3067 bt = o->cur.border.t;
3068 bb = o->cur.border.b;
3074 if ((bl + br) > imw)
3084 if ((bt + bb) > imh)
3089 if (o->cur.border.scale != 1.0)
3091 bsl = ((double)bl * o->cur.border.scale);
3092 bsr = ((double)br * o->cur.border.scale);
3093 bst = ((double)bt * o->cur.border.scale);
3094 bsb = ((double)bb * o->cur.border.scale);
3098 bsl = bl; bsr = br; bst = bt; bsb = bb;
3104 outx = ox; outy = oy;
3105 outw = bsl; outh = bst;
3106 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3110 inw = imw - bl - br; inh = bt;
3111 outx = ox + bsl; outy = oy;
3112 outw = iw - bsl - bsr; outh = bst;
3113 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3116 inx = imw - br; iny = 0;
3118 outx = ox + iw - bsr; outy = oy;
3119 outw = bsr; outh = bst;
3120 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3124 inw = bl; inh = imh - bt - bb;
3125 outx = ox; outy = oy + bst;
3126 outw = bsl; outh = ih - bst - bsb;
3127 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3130 if (o->cur.border.fill > EVAS_BORDER_FILL_NONE)
3133 inw = imw - bl - br; inh = imh - bt - bb;
3134 outx = ox + bsl; outy = oy + bst;
3135 outw = iw - bsl - bsr; outh = ih - bst - bsb;
3136 if ((o->cur.border.fill == EVAS_BORDER_FILL_SOLID) &&
3137 (obj->cur.cache.clip.a == 255) &&
3138 (obj->cur.render_op == EVAS_RENDER_BLEND))
3140 obj->layer->evas->engine.func->context_render_op_set(output, context,
3142 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3143 obj->layer->evas->engine.func->context_render_op_set(output, context,
3144 obj->cur.render_op);
3147 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3151 inx = imw - br; iny = bt;
3152 inw = br; inh = imh - bt - bb;
3153 outx = ox + iw - bsr; outy = oy + bst;
3154 outw = bsr; outh = ih - bst - bsb;
3155 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3158 inx = 0; iny = imh - bb;
3160 outx = ox; outy = oy + ih - bsb;
3161 outw = bsl; outh = bsb;
3162 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3165 inx = bl; iny = imh - bb;
3166 inw = imw - bl - br; inh = bb;
3167 outx = ox + bsl; outy = oy + ih - bsb;
3168 outw = iw - bsl - bsr; outh = bsb;
3169 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3172 inx = imw - br; iny = imh - bb;
3174 outx = ox + iw - bsr; outy = oy + ih - bsb;
3175 outw = bsr; outh = bsb;
3176 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3179 if (dobreak_h) break;
3183 if (dobreak_w) break;
3190 if (obj->layer->evas->engine.func->gl_img_obj_set)
3192 obj->layer->evas->engine.func->gl_img_obj_set(output, NULL, 0);
3200 evas_object_image_render_pre(Evas_Object *obj)
3202 Evas_Object_Image *o;
3203 int is_v = 0, was_v = 0;
3206 /* dont pre-render the obj twice! */
3207 if (obj->pre_render_done) return;
3208 obj->pre_render_done = 1;
3209 /* pre-render phase. this does anything an object needs to do just before */
3210 /* rendering. this could mean loading the image data, retrieving it from */
3211 /* elsewhere, decoding video etc. */
3212 /* then when this is done the object needs to figure if it changed and */
3213 /* if so what and where and add the appropriate redraw rectangles */
3214 o = (Evas_Object_Image *)(obj->object_data);
3215 e = obj->layer->evas;
3217 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
3219 ERR("%p has invalid fill size: %dx%d. Ignored",
3220 obj, o->cur.fill.w, o->cur.fill.h);
3224 /* if someone is clipping this obj - go calculate the clipper */
3225 if (obj->cur.clipper)
3227 if (obj->cur.cache.clip.dirty)
3228 evas_object_clip_recalc(obj->cur.clipper);
3229 obj->cur.clipper->func->render_pre(obj->cur.clipper);
3231 /* Proxy: Do it early */
3232 if (o->cur.source &&
3233 (o->cur.source->proxy.redraw || o->cur.source->changed))
3235 /* XXX: Do I need to sort out the map here? */
3236 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3240 /* now figure what changed and add draw rects */
3241 /* if it just became visible or invisible */
3242 is_v = evas_object_is_visible(obj);
3243 was_v = evas_object_was_visible(obj);
3246 evas_object_render_pre_visible_change(&e->clip_changes, obj, is_v, was_v);
3247 if (!o->pixel_updates) goto done;
3249 if (obj->changed_map)
3251 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3254 /* it's not visible - we accounted for it appearing or not so just abort */
3255 if (!is_v) goto done;
3256 /* clipper changed this is in addition to anything else for obj */
3257 evas_object_render_pre_clipper_change(&e->clip_changes, obj);
3258 /* if we restacked (layer or just within a layer) and don't clip anyone */
3261 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3262 if (!o->pixel_updates) goto done;
3264 /* if it changed color */
3265 if ((obj->cur.color.r != obj->prev.color.r) ||
3266 (obj->cur.color.g != obj->prev.color.g) ||
3267 (obj->cur.color.b != obj->prev.color.b) ||
3268 (obj->cur.color.a != obj->prev.color.a))
3270 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3271 if (!o->pixel_updates) goto done;
3273 /* if it changed render op */
3274 if (obj->cur.render_op != obj->prev.render_op)
3276 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3277 if (!o->pixel_updates) goto done;
3279 /* if it changed anti_alias */
3280 if (obj->cur.anti_alias != obj->prev.anti_alias)
3282 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3283 if (!o->pixel_updates) goto done;
3287 if (((o->cur.file) && (!o->prev.file)) ||
3288 ((!o->cur.file) && (o->prev.file)) ||
3289 ((o->cur.key) && (!o->prev.key)) ||
3290 ((!o->cur.key) && (o->prev.key))
3293 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3294 if (!o->pixel_updates) goto done;
3296 if ((o->cur.image.w != o->prev.image.w) ||
3297 (o->cur.image.h != o->prev.image.h) ||
3298 (o->cur.has_alpha != o->prev.has_alpha) ||
3299 (o->cur.cspace != o->prev.cspace) ||
3300 (o->cur.smooth_scale != o->prev.smooth_scale))
3302 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3303 if (!o->pixel_updates) goto done;
3305 if ((o->cur.border.l != o->prev.border.l) ||
3306 (o->cur.border.r != o->prev.border.r) ||
3307 (o->cur.border.t != o->prev.border.t) ||
3308 (o->cur.border.b != o->prev.border.b) ||
3309 (o->cur.border.fill != o->prev.border.fill) ||
3310 (o->cur.border.scale != o->prev.border.scale))
3312 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3313 if (!o->pixel_updates) goto done;
3315 if (o->dirty_pixels)
3317 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3318 if (!o->pixel_updates) goto done;
3320 if (o->cur.frame != o->prev.frame)
3322 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3323 if (!o->pixel_updates) goto done;
3327 /* if it changed geometry - and obviously not visibility or color */
3328 /* calculate differences since we have a constant color fill */
3329 /* we really only need to update the differences */
3330 #if 0 // XXX: maybe buggy?
3331 if (((obj->cur.geometry.x != obj->prev.geometry.x) ||
3332 (obj->cur.geometry.y != obj->prev.geometry.y) ||
3333 (obj->cur.geometry.w != obj->prev.geometry.w) ||
3334 (obj->cur.geometry.h != obj->prev.geometry.h)) &&
3335 (o->cur.fill.w == o->prev.fill.w) &&
3336 (o->cur.fill.h == o->prev.fill.h) &&
3337 ((o->cur.fill.x + obj->cur.geometry.x) == (o->prev.fill.x + obj->prev.geometry.x)) &&
3338 ((o->cur.fill.y + obj->cur.geometry.y) == (o->prev.fill.y + obj->prev.geometry.y)) &&
3342 evas_rects_return_difference_rects(&e->clip_changes,
3343 obj->cur.geometry.x,
3344 obj->cur.geometry.y,
3345 obj->cur.geometry.w,
3346 obj->cur.geometry.h,
3347 obj->prev.geometry.x,
3348 obj->prev.geometry.y,
3349 obj->prev.geometry.w,
3350 obj->prev.geometry.h);
3351 if (!o->pixel_updates) goto done;
3354 if (((obj->cur.geometry.x != obj->prev.geometry.x) ||
3355 (obj->cur.geometry.y != obj->prev.geometry.y) ||
3356 (obj->cur.geometry.w != obj->prev.geometry.w) ||
3357 (obj->cur.geometry.h != obj->prev.geometry.h))
3360 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3361 if (!o->pixel_updates) goto done;
3365 if ((o->cur.fill.x != o->prev.fill.x) ||
3366 (o->cur.fill.y != o->prev.fill.y) ||
3367 (o->cur.fill.w != o->prev.fill.w) ||
3368 (o->cur.fill.h != o->prev.fill.h))
3370 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3371 if (!o->pixel_updates) goto done;
3373 if (o->pixel_updates)
3375 if ((o->cur.border.l == 0) &&
3376 (o->cur.border.r == 0) &&
3377 (o->cur.border.t == 0) &&
3378 (o->cur.border.b == 0) &&
3379 (o->cur.image.w > 0) &&
3380 (o->cur.image.h > 0) &&
3381 (!((obj->cur.map) && (obj->cur.usemap))))
3385 EINA_LIST_FREE(o->pixel_updates, rr)
3387 Evas_Coord idw, idh, idx, idy;
3390 e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, rr->x, rr->y, rr->w, rr->h);
3392 idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
3393 idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
3395 if (idw < 1) idw = 1;
3396 if (idh < 1) idh = 1;
3397 if (idx > 0) idx -= idw;
3398 if (idy > 0) idy -= idh;
3399 while (idx < obj->cur.geometry.w)
3405 w = ((int)(idx + idw)) - x;
3406 while (idy < obj->cur.geometry.h)
3411 h = ((int)(idy + idh)) - y;
3413 r.x = (rr->x * w) / o->cur.image.w;
3414 r.y = (rr->y * h) / o->cur.image.h;
3415 r.w = ((rr->w * w) + (o->cur.image.w * 2) - 1) / o->cur.image.w;
3416 r.h = ((rr->h * h) + (o->cur.image.h * 2) - 1) / o->cur.image.h;
3417 r.x += obj->cur.geometry.x + x;
3418 r.y += obj->cur.geometry.y + y;
3419 RECTS_CLIP_TO_RECT(r.x, r.y, r.w, r.h,
3420 obj->cur.cache.clip.x, obj->cur.cache.clip.y,
3421 obj->cur.cache.clip.w, obj->cur.cache.clip.h);
3422 evas_add_rect(&e->clip_changes, r.x, r.y, r.w, r.h);
3428 eina_rectangle_free(rr);
3436 EINA_LIST_FREE(o->pixel_updates, r)
3437 eina_rectangle_free(r);
3438 e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h);
3439 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3444 #if 0 // filtering disabled
3445 if (obj->filter && obj->filter->dirty)
3447 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3450 /* it obviously didn't change - add a NO obscure - this "unupdates" this */
3451 /* area so if there were updates for it they get wiped. don't do it if we */
3452 /* aren't fully opaque and we are visible */
3453 if (evas_object_is_visible(obj) &&
3454 evas_object_is_opaque(obj))
3456 Evas_Coord x, y, w, h;
3458 x = obj->cur.cache.clip.x;
3459 y = obj->cur.cache.clip.y;
3460 w = obj->cur.cache.clip.w;
3461 h = obj->cur.cache.clip.h;
3462 if (obj->cur.clipper)
3464 RECTS_CLIP_TO_RECT(x, y, w, h,
3465 obj->cur.clipper->cur.cache.clip.x,
3466 obj->cur.clipper->cur.cache.clip.y,
3467 obj->cur.clipper->cur.cache.clip.w,
3468 obj->cur.clipper->cur.cache.clip.h);
3470 e->engine.func->output_redraws_rect_del(e->engine.data.output,
3474 evas_object_render_pre_effect_updates(&e->clip_changes, obj, is_v, was_v);
3478 evas_object_image_render_post(Evas_Object *obj)
3480 Evas_Object_Image *o;
3483 /* this moves the current data to the previous state parts of the object */
3484 /* in whatever way is safest for the object. also if we don't need object */
3485 /* data anymore we can free it if the object deems this is a good idea */
3486 o = (Evas_Object_Image *)(obj->object_data);
3487 /* remove those pesky changes */
3488 evas_object_clip_changes_clean(obj);
3489 EINA_LIST_FREE(o->pixel_updates, r)
3490 eina_rectangle_free(r);
3491 /* move cur to prev safely for object data */
3492 obj->prev = obj->cur;
3495 /* FIXME: copy strings across */
3498 static unsigned int evas_object_image_id_get(Evas_Object *obj)
3500 Evas_Object_Image *o;
3502 o = (Evas_Object_Image *)(obj->object_data);
3504 return MAGIC_OBJ_IMAGE;
3507 static unsigned int evas_object_image_visual_id_get(Evas_Object *obj)
3509 Evas_Object_Image *o;
3511 o = (Evas_Object_Image *)(obj->object_data);
3513 return MAGIC_OBJ_IMAGE;
3516 static void *evas_object_image_engine_data_get(Evas_Object *obj)
3518 Evas_Object_Image *o;
3520 o = (Evas_Object_Image *)(obj->object_data);
3521 if (!o) return NULL;
3522 return o->engine_data;
3526 evas_object_image_is_opaque(Evas_Object *obj)
3528 Evas_Object_Image *o;
3530 /* this returns 1 if the internal object data implies that the object is */
3531 /* currently fully opaque over the entire rectangle it occupies */
3532 o = (Evas_Object_Image *)(obj->object_data);
3533 /* disable caching due tyo maps screwing with this
3534 o->cur.opaque_valid = 0;
3535 if (o->cur.opaque_valid)
3537 if (!o->cur.opaque) return 0;
3543 /* disable caching */
3544 /* o->cur.opaque_valid = 1; */
3545 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
3546 return o->cur.opaque;
3547 if (((o->cur.border.l != 0) ||
3548 (o->cur.border.r != 0) ||
3549 (o->cur.border.t != 0) ||
3550 (o->cur.border.b != 0)) &&
3551 (!o->cur.border.fill)) return o->cur.opaque;
3552 if (!o->engine_data) return o->cur.opaque;
3558 o->cur.opaque = evas_object_is_opaque(o->cur.source);
3559 return o->cur.opaque; /* FIXME: Should go poke at the object */
3561 if (o->cur.has_alpha)
3564 return o->cur.opaque;
3566 if ((obj->cur.map) && (obj->cur.usemap))
3568 Evas_Map *m = obj->cur.map;
3570 if ((m->points[0].a == 255) &&
3571 (m->points[1].a == 255) &&
3572 (m->points[2].a == 255) &&
3573 (m->points[3].a == 255))
3576 ((m->points[0].x == m->points[3].x) &&
3577 (m->points[1].x == m->points[2].x) &&
3578 (m->points[0].y == m->points[1].y) &&
3579 (m->points[2].y == m->points[3].y))
3581 ((m->points[0].x == m->points[1].x) &&
3582 (m->points[2].x == m->points[3].x) &&
3583 (m->points[0].y == m->points[3].y) &&
3584 (m->points[1].y == m->points[2].y))
3587 if ((m->points[0].x == obj->cur.geometry.x) &&
3588 (m->points[0].y == obj->cur.geometry.y) &&
3589 (m->points[2].x == (obj->cur.geometry.x + obj->cur.geometry.w)) &&
3590 (m->points[2].y == (obj->cur.geometry.y + obj->cur.geometry.h)))
3591 return o->cur.opaque;
3595 return o->cur.opaque;
3597 if (obj->cur.render_op == EVAS_RENDER_COPY) return o->cur.opaque;
3598 return o->cur.opaque;
3602 evas_object_image_was_opaque(Evas_Object *obj)
3604 Evas_Object_Image *o;
3606 /* this returns 1 if the internal object data implies that the object was */
3607 /* previously fully opaque over the entire rectangle it occupies */
3608 o = (Evas_Object_Image *)(obj->object_data);
3609 if (o->prev.opaque_valid)
3611 if (!o->prev.opaque) return 0;
3616 o->prev.opaque_valid = 1;
3617 if ((o->prev.fill.w < 1) || (o->prev.fill.h < 1))
3619 if (((o->prev.border.l != 0) ||
3620 (o->prev.border.r != 0) ||
3621 (o->prev.border.t != 0) ||
3622 (o->prev.border.b != 0)) &&
3623 (!o->prev.border.fill)) return 0;
3624 if (!o->engine_data) return 0;
3628 if (o->prev.source) return 0; /* FIXME: Should go poke at the object */
3629 if (obj->prev.usemap) return 0;
3630 if (obj->prev.render_op == EVAS_RENDER_COPY) return 1;
3631 if (o->prev.has_alpha) return 0;
3632 if (obj->prev.render_op != EVAS_RENDER_BLEND) return 0;
3637 evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
3639 Evas_Object_Image *o;
3641 int w, h, stride, iw, ih;
3644 o = (Evas_Object_Image *)(obj->object_data);
3646 x -= obj->cur.cache.clip.x;
3647 y -= obj->cur.cache.clip.y;
3648 w = obj->cur.cache.clip.w;
3649 h = obj->cur.cache.clip.h;
3650 iw = o->cur.image.w;
3651 ih = o->cur.image.h;
3653 if ((x < 0) || (y < 0) || (x >= w) || (y >= h)) return 0;
3654 if (!o->cur.has_alpha) return 1;
3656 // FIXME: proxy needs to be honored
3659 x = obj->cur.map->mx;
3660 y = obj->cur.map->my;
3664 int bl, br, bt, bb, bsl, bsr, bst, bsb;
3666 bl = o->cur.border.l;
3667 br = o->cur.border.r;
3668 bt = o->cur.border.t;
3669 bb = o->cur.border.b;
3690 if (o->cur.border.scale != 1.0)
3692 bsl = ((double)bl * o->cur.border.scale);
3693 bsr = ((double)br * o->cur.border.scale);
3694 bst = ((double)bt * o->cur.border.scale);
3695 bsb = ((double)bb * o->cur.border.scale);
3699 bsl = bl; bsr = br; bst = bt; bsb = bb;
3712 if (o->cur.border.fill != EVAS_BORDER_FILL_DEFAULT)
3714 if ((x > bsl) && (x < (w - bsr)) &&
3715 (y > bst) && (y < (h - bsb)))
3717 if (o->cur.border.fill == EVAS_BORDER_FILL_SOLID) return 1;
3722 if (x < bsl) x = (x * bl) / bsl;
3723 else if (x > (w - bsr)) x = iw - (((w - x) * br) / bsr);
3724 else if ((bsl + bsr) < w) x = bl + (((x - bsl) * (iw - bl - br)) / (w - bsl - bsr));
3727 if (y < bst) y = (y * bt) / bst;
3728 else if (y > (h - bsb)) y = ih - (((h - y) * bb) / bsb);
3729 else if ((bst + bsb) < h) y = bt + (((y - bst) * (ih - bt - bb)) / (h - bst - bsb));
3735 if (x >= iw) x = iw - 1;
3736 if (y >= ih) y = ih - 1;
3738 stride = o->cur.image.stride;
3740 o->engine_data = obj->layer->evas->engine.func->image_data_get
3741 (obj->layer->evas->engine.data.output,
3753 switch (o->cur.cspace)
3755 case EVAS_COLORSPACE_ARGB8888:
3756 data = ((DATA32*)(data) + ((y * (stride >> 2)) + x));
3757 a = (*((DATA32*)(data)) >> 24) & 0xff;
3759 case EVAS_COLORSPACE_RGB565_A5P:
3760 data = (void*) ((DATA16*)(data) + (h * (stride >> 1)));
3761 data = (void*) ((DATA8*)(data) + ((y * (stride >> 1)) + x));
3762 a = (*((DATA8*)(data))) & 0x1f;
3770 return_value = (a != 0);
3775 obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
3778 return return_value;
3782 evas_object_image_has_opaque_rect(Evas_Object *obj)
3784 Evas_Object_Image *o;
3786 o = (Evas_Object_Image *)(obj->object_data);
3787 if ((obj->cur.map) && (obj->cur.usemap)) return 0;
3788 if (((o->cur.border.l | o->cur.border.r | o->cur.border.t | o->cur.border.b) != 0) &&
3789 (o->cur.border.fill == EVAS_BORDER_FILL_SOLID) &&
3790 (obj->cur.render_op == EVAS_RENDER_BLEND) &&
3791 (obj->cur.cache.clip.a == 255) &&
3792 (o->cur.fill.x == 0) &&
3793 (o->cur.fill.y == 0) &&
3794 (o->cur.fill.w == obj->cur.geometry.w) &&
3795 (o->cur.fill.h == obj->cur.geometry.h)
3801 evas_object_image_get_opaque_rect(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3803 Evas_Object_Image *o;
3805 o = (Evas_Object_Image *)(obj->object_data);
3806 if (o->cur.border.scale == 1.0)
3808 *x = obj->cur.geometry.x + o->cur.border.l;
3809 *y = obj->cur.geometry.y + o->cur.border.t;
3810 *w = obj->cur.geometry.w - (o->cur.border.l + o->cur.border.r);
3812 *h = obj->cur.geometry.h - (o->cur.border.t + o->cur.border.b);
3817 *x = obj->cur.geometry.x + (o->cur.border.l * o->cur.border.scale);
3818 *y = obj->cur.geometry.y + (o->cur.border.t * o->cur.border.scale);
3819 *w = obj->cur.geometry.w - ((o->cur.border.l * o->cur.border.scale) + (o->cur.border.r * o->cur.border.scale));
3821 *h = obj->cur.geometry.h - ((o->cur.border.t * o->cur.border.scale) + (o->cur.border.b * o->cur.border.scale));
3828 evas_object_image_can_map(Evas_Object *obj __UNUSED__)
3834 evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace)
3841 switch (o->cur.cspace)
3843 case EVAS_COLORSPACE_ARGB8888:
3844 out = evas_common_convert_argb8888_to(data,
3847 o->cur.image.stride >> 2,
3851 case EVAS_COLORSPACE_RGB565_A5P:
3852 out = evas_common_convert_rgb565_a5p_to(data,
3855 o->cur.image.stride >> 1,
3859 case EVAS_COLORSPACE_YCBCR422601_PL:
3860 out = evas_common_convert_yuv_422_601_to(data,
3865 case EVAS_COLORSPACE_YCBCR422P601_PL:
3866 out = evas_common_convert_yuv_422P_601_to(data,
3871 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
3872 out = evas_common_convert_yuv_420_601_to(data,
3877 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
3878 out = evas_common_convert_yuv_420T_601_to(data,
3884 WRN("unknow colorspace: %i\n", o->cur.cspace);
3892 evas_object_image_filled_resize_listener(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *einfo __UNUSED__)
3896 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
3897 evas_object_image_fill_set(obj, 0, 0, w, h);
3902 _evas_object_image_preloading_get(const Evas_Object *obj)
3904 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3905 if (!o) return EINA_FALSE;
3906 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
3909 return o->preloading;
3913 _evas_object_image_preloading_set(Evas_Object *obj, Eina_Bool preloading)
3915 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3916 o->preloading = preloading;
3920 _evas_object_image_preloading_check(Evas_Object *obj)
3922 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3923 if (obj->layer->evas->engine.func->image_load_error_get)
3924 o->load_error = obj->layer->evas->engine.func->image_load_error_get
3925 (obj->layer->evas->engine.data.output, o->engine_data);
3929 _evas_object_image_video_parent_get(Evas_Object *obj)
3931 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3933 return o->video_surface ? o->video.parent : NULL;
3937 _evas_object_image_video_overlay_show(Evas_Object *obj)
3939 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3941 if (obj->cur.cache.clip.x != obj->prev.cache.clip.x ||
3942 obj->cur.cache.clip.y != obj->prev.cache.clip.y ||
3943 o->created || !o->video_visible)
3944 o->video.move(o->video.data, obj, &o->video, obj->cur.cache.clip.x, obj->cur.cache.clip.y);
3945 if (obj->cur.cache.clip.w != obj->prev.cache.clip.w ||
3946 obj->cur.cache.clip.h != obj->prev.cache.clip.h ||
3947 o->created || !o->video_visible)
3948 o->video.resize(o->video.data, obj, &o->video, obj->cur.cache.clip.w, obj->cur.cache.clip.h);
3949 if (!o->video_visible || o->created)
3951 o->video.show(o->video.data, obj, &o->video);
3955 /* Cancel dirty on the image */
3958 o->dirty_pixels = 0;
3959 EINA_LIST_FREE(o->pixel_updates, r)
3960 eina_rectangle_free(r);
3962 o->video_visible = EINA_TRUE;
3963 o->created = EINA_FALSE;
3967 _evas_object_image_video_overlay_hide(Evas_Object *obj)
3969 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3971 if (o->video_visible || o->created)
3972 o->video.hide(o->video.data, obj, &o->video);
3973 if (evas_object_is_visible(obj))
3974 o->video.update_pixels(o->video.data, obj, &o->video);
3975 o->video_visible = EINA_FALSE;
3976 o->created = EINA_FALSE;
3979 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/