6 #include "evas_common.h"
7 #include "evas_private.h"
8 #include "../engines/common/evas_convert_color.h"
9 #include "../engines/common/evas_convert_colorspace.h"
10 #include "../engines/common/evas_convert_yuv.h"
12 #define VERBOSE_PROXY_ERROR 1
14 /* private magic number for image objects */
15 static const char o_type[] = "image";
17 /* private struct for rectangle object internal data */
18 typedef struct _Evas_Object_Image Evas_Object_Image;
20 struct _Evas_Object_Image
26 Evas_Coord_Rectangle fill;
43 unsigned char smooth_scale : 1;
44 unsigned char has_alpha :1;
45 unsigned char opaque :1;
46 unsigned char opaque_valid :1;
49 int pixels_checked_out;
51 Eina_List *pixel_updates;
54 unsigned char scale_down_by;
60 Eina_Bool orientation : 1;
64 Evas_Object_Image_Pixels_Get_Cb get_pixels;
65 void *get_pixels_data;
71 Evas_Image_Scale_Hint scale_hint;
72 Evas_Image_Content_Hint content_hint;
76 unsigned char changed : 1;
77 unsigned char dirty_pixels : 1;
78 unsigned char filled : 1;
79 unsigned char proxyrendering : 1;
80 unsigned char preloading : 1;
83 /* private methods for image objects */
84 static void evas_object_image_unload(Evas_Object *obj, Eina_Bool dirty);
85 static void evas_object_image_load(Evas_Object *obj);
86 static Evas_Coord evas_object_image_figure_x_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret);
87 static Evas_Coord evas_object_image_figure_y_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret);
89 static void evas_object_image_init(Evas_Object *obj);
90 static void *evas_object_image_new(void);
91 static void evas_object_image_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
92 static void evas_object_image_free(Evas_Object *obj);
93 static void evas_object_image_render_pre(Evas_Object *obj);
94 static void evas_object_image_render_post(Evas_Object *obj);
96 static unsigned int evas_object_image_id_get(Evas_Object *obj);
97 static unsigned int evas_object_image_visual_id_get(Evas_Object *obj);
98 static void *evas_object_image_engine_data_get(Evas_Object *obj);
100 static int evas_object_image_is_opaque(Evas_Object *obj);
101 static int evas_object_image_was_opaque(Evas_Object *obj);
102 static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
103 static int evas_object_image_has_opaque_rect(Evas_Object *obj);
104 static int evas_object_image_get_opaque_rect(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
105 static int evas_object_image_can_map(Evas_Object *obj);
107 static void *evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace);
108 static void evas_object_image_filled_resize_listener(void *data, Evas *e, Evas_Object *obj, void *einfo);
110 static void _proxy_unset(Evas_Object *proxy);
111 static void _proxy_set(Evas_Object *proxy, Evas_Object *src);
112 static void _proxy_error(Evas_Object *proxy, void *context, void *output, void *surface, int x, int y);
114 static void _cleanup_tmpf(Evas_Object *obj);
116 static const Evas_Object_Func object_func =
118 /* methods (compulsory) */
119 evas_object_image_free,
120 evas_object_image_render,
121 evas_object_image_render_pre,
122 evas_object_image_render_post,
123 evas_object_image_id_get,
124 evas_object_image_visual_id_get,
125 evas_object_image_engine_data_get,
126 /* these are optional. NULL = nothing */
131 evas_object_image_is_opaque,
132 evas_object_image_was_opaque,
133 evas_object_image_is_inside,
137 evas_object_image_has_opaque_rect,
138 evas_object_image_get_opaque_rect,
139 evas_object_image_can_map
142 EVAS_MEMPOOL(_mp_obj);
145 evas_object_image_add(Evas *e)
148 Evas_Object_Image *o;
150 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
153 obj = evas_object_new(e);
154 evas_object_image_init(obj);
155 evas_object_inject(obj, e);
156 o = (Evas_Object_Image *)(obj->object_data);
157 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
163 evas_object_image_filled_add(Evas *e)
166 obj = evas_object_image_add(e);
167 evas_object_image_filled_set(obj, 1);
172 _cleanup_tmpf(Evas_Object *obj)
174 Evas_Object_Image *o;
176 o = (Evas_Object_Image *)(obj->object_data);
177 if (!o->tmpf) return;
182 if (o->tmpf_fd >= 0) close(o->tmpf_fd);
183 eina_stringshare_del(o->tmpf);
189 _create_tmpf(Evas_Object *obj, void *data, int size, char *format __UNUSED__)
191 Evas_Object_Image *o;
196 o = (Evas_Object_Image *)(obj->object_data);
198 snprintf(buf, sizeof(buf), "/dev/shm/.evas-tmpf-%i-%p-%i-XXXXXX",
199 (int)getpid(), data, (int)size);
204 snprintf(buf, sizeof(buf), "/tmp/.evas-tmpf-%i-%p-%i-XXXXXX",
205 (int)getpid(), data, (int)size);
209 if (ftruncate(fd, size) < 0)
217 eina_mmap_safety_enabled_set(EINA_TRUE);
219 dst = mmap(NULL, size,
220 PROT_READ | PROT_WRITE,
223 if (dst == MAP_FAILED)
230 snprintf(buf, sizeof(buf), "/proc/%li/fd/%i", (long)getpid(), fd);
232 o->tmpf = eina_stringshare_add(buf);
233 memcpy(dst, data, size);
238 evas_object_image_memfile_set(Evas_Object *obj, void *data, int size, char *format, char *key)
240 Evas_Object_Image *o;
242 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
245 o = (Evas_Object_Image *)(obj->object_data);
246 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
250 evas_object_image_file_set(obj, NULL, NULL);
251 // invalidate the cache effectively
252 evas_object_image_alpha_set(obj, !o->cur.has_alpha);
253 evas_object_image_alpha_set(obj, !o->cur.has_alpha);
255 if ((size < 1) || (!data)) return;
257 _create_tmpf(obj, data, size, format);
258 evas_object_image_file_set(obj, o->tmpf, key);
261 ERR("unable to load '%s' from memory", o->tmpf);
268 evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
270 Evas_Object_Image *o;
271 Evas_Image_Load_Opts lo;
273 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
276 o = (Evas_Object_Image *)(obj->object_data);
277 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
280 if ((o->tmpf) && (file != o->tmpf)) _cleanup_tmpf(obj);
281 if ((o->cur.file) && (file) && (!strcmp(o->cur.file, file)))
283 if ((!o->cur.key) && (!key))
285 if ((o->cur.key) && (key) && (!strcmp(o->cur.key, key)))
289 * WTF? why cancel a null image preload? this is just silly (tm)
291 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
295 if (o->cur.source) _proxy_unset(obj);
296 if (o->cur.file) eina_stringshare_del(o->cur.file);
297 if (o->cur.key) eina_stringshare_del(o->cur.key);
298 if (file) o->cur.file = eina_stringshare_add(file);
299 else o->cur.file = NULL;
300 if (key) o->cur.key = eina_stringshare_add(key);
301 else o->cur.key = NULL;
309 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
313 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
316 o->load_error = EVAS_LOAD_ERROR_NONE;
317 lo.scale_down_by = o->load_opts.scale_down_by;
318 lo.dpi = o->load_opts.dpi;
319 lo.w = o->load_opts.w;
320 lo.h = o->load_opts.h;
321 lo.region.x = o->load_opts.region.x;
322 lo.region.y = o->load_opts.region.y;
323 lo.region.w = o->load_opts.region.w;
324 lo.region.h = o->load_opts.region.h;
325 lo.orientation = o->load_opts.orientation;
326 o->engine_data = obj->layer->evas->engine.func->image_load(obj->layer->evas->engine.data.output,
336 obj->layer->evas->engine.func->image_size_get(obj->layer->evas->engine.data.output,
337 o->engine_data, &w, &h);
338 if (obj->layer->evas->engine.func->image_stride_get)
339 obj->layer->evas->engine.func->image_stride_get(obj->layer->evas->engine.data.output,
340 o->engine_data, &stride);
343 o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
345 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
349 o->cur.image.stride = stride;
353 if (o->load_error == EVAS_LOAD_ERROR_NONE)
354 o->load_error = EVAS_LOAD_ERROR_GENERIC;
355 o->cur.has_alpha = 1;
356 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
359 o->cur.image.stride = 0;
362 evas_object_change(obj);
366 evas_object_image_file_get(const Evas_Object *obj, const char **file, const char **key)
368 Evas_Object_Image *o;
370 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
371 if (file) *file = NULL;
372 if (key) *key = NULL;
375 o = (Evas_Object_Image *)(obj->object_data);
376 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
377 if (file) *file = NULL;
378 if (key) *key = NULL;
381 if (file) *file = o->cur.file;
382 if (key) *key = o->cur.key;
386 evas_object_image_source_set(Evas_Object *obj, Evas_Object *src)
388 Evas_Object_Image *o;
390 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
393 o = obj->object_data;
394 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
398 if (src == obj) return EINA_FALSE;
399 if (o->cur.source == src) return EINA_TRUE;
401 if (o->tmpf) _cleanup_tmpf(obj);
402 /* Kill the image if any */
403 if (o->cur.file || o->cur.key)
404 evas_object_image_file_set(obj, NULL, NULL);
413 _proxy_set(obj, src);
421 evas_object_image_source_get(Evas_Object *obj)
423 Evas_Object_Image *o;
425 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
428 o = obj->object_data;
429 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
433 return o->cur.source;
437 evas_object_image_source_unset(Evas_Object *obj)
439 return evas_object_image_source_set(obj, NULL);
443 evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
445 Evas_Object_Image *o;
447 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
450 o = (Evas_Object_Image *)(obj->object_data);
451 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
458 if ((o->cur.border.l == l) &&
459 (o->cur.border.r == r) &&
460 (o->cur.border.t == t) &&
461 (o->cur.border.b == b)) return;
466 o->cur.opaque_valid = 0;
468 evas_object_change(obj);
472 evas_object_image_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
474 Evas_Object_Image *o;
476 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 (l) *l = o->cur.border.l;
492 if (r) *r = o->cur.border.r;
493 if (t) *t = o->cur.border.t;
494 if (b) *b = o->cur.border.b;
498 evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
500 Evas_Object_Image *o;
502 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
505 o = (Evas_Object_Image *)(obj->object_data);
506 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
509 if (fill == o->cur.border.fill) return;
510 o->cur.border.fill = fill;
512 evas_object_change(obj);
515 EAPI Evas_Border_Fill_Mode
516 evas_object_image_border_center_fill_get(const Evas_Object *obj)
518 Evas_Object_Image *o;
520 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
523 o = (Evas_Object_Image *)(obj->object_data);
524 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
527 return o->cur.border.fill;
531 evas_object_image_filled_set(Evas_Object *obj, Eina_Bool setting)
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);
544 if (o->filled == setting) return;
548 evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE, evas_object_image_filled_resize_listener);
553 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
554 evas_object_image_fill_set(obj, 0, 0, w, h);
556 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, evas_object_image_filled_resize_listener, NULL);
561 evas_object_image_filled_get(const Evas_Object *obj)
563 Evas_Object_Image *o;
565 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
568 o = (Evas_Object_Image *)(obj->object_data);
569 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
577 evas_object_image_border_scale_set(Evas_Object *obj, double scale)
579 Evas_Object_Image *o;
581 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
584 o = (Evas_Object_Image *)(obj->object_data);
585 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
588 if (scale == o->cur.border.scale) return;
589 o->cur.border.scale = scale;
591 evas_object_change(obj);
595 evas_object_image_border_scale_get(const Evas_Object *obj)
597 Evas_Object_Image *o;
599 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
602 o = (Evas_Object_Image *)(obj->object_data);
603 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
606 return o->cur.border.scale;
610 evas_object_image_fill_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
612 Evas_Object_Image *o;
618 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
621 o = (Evas_Object_Image *)(obj->object_data);
622 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
625 if ((o->cur.fill.x == x) &&
626 (o->cur.fill.y == y) &&
627 (o->cur.fill.w == w) &&
628 (o->cur.fill.h == h)) return;
633 o->cur.opaque_valid = 0;
635 evas_object_change(obj);
639 evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
641 Evas_Object_Image *o;
643 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
650 o = (Evas_Object_Image *)(obj->object_data);
651 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
658 if (x) *x = o->cur.fill.x;
659 if (y) *y = o->cur.fill.y;
660 if (w) *w = o->cur.fill.w;
661 if (h) *h = o->cur.fill.h;
666 evas_object_image_fill_spread_set(Evas_Object *obj, Evas_Fill_Spread spread)
668 Evas_Object_Image *o;
670 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
673 o = (Evas_Object_Image *)(obj->object_data);
674 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
677 if (spread == (Evas_Fill_Spread)o->cur.spread) return;
678 o->cur.spread = spread;
680 evas_object_change(obj);
683 EAPI Evas_Fill_Spread
684 evas_object_image_fill_spread_get(const Evas_Object *obj)
686 Evas_Object_Image *o;
688 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
689 return EVAS_TEXTURE_REPEAT;
691 o = (Evas_Object_Image *)(obj->object_data);
692 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
693 return EVAS_TEXTURE_REPEAT;
695 return (Evas_Fill_Spread)o->cur.spread;
699 evas_object_image_size_set(Evas_Object *obj, int w, int h)
701 Evas_Object_Image *o;
704 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
707 o = (Evas_Object_Image *)(obj->object_data);
708 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
711 if ((o->preloading) && (o->engine_data))
714 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
720 if (w > 32768) return;
721 if (h > 32768) return;
722 if ((w == o->cur.image.w) &&
723 (h == o->cur.image.h)) return;
724 if (o->tmpf) _cleanup_tmpf(obj);
728 o->engine_data = obj->layer->evas->engine.func->image_size_set(obj->layer->evas->engine.data.output,
732 o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data
733 (obj->layer->evas->engine.data.output, w, h, NULL, o->cur.has_alpha,
738 if (obj->layer->evas->engine.func->image_scale_hint_set)
739 obj->layer->evas->engine.func->image_scale_hint_set
740 (obj->layer->evas->engine.data.output,
741 o->engine_data, o->scale_hint);
742 if (obj->layer->evas->engine.func->image_content_hint_set)
743 obj->layer->evas->engine.func->image_content_hint_set
744 (obj->layer->evas->engine.data.output,
745 o->engine_data, o->content_hint);
746 if (obj->layer->evas->engine.func->image_stride_get)
747 obj->layer->evas->engine.func->image_stride_get
748 (obj->layer->evas->engine.data.output,
749 o->engine_data, &stride);
755 o->cur.image.stride = stride;
757 /* FIXME - in engine call above
759 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
763 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
765 evas_object_change(obj);
769 evas_object_image_size_get(const Evas_Object *obj, int *w, int *h)
771 Evas_Object_Image *o;
773 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
778 o = (Evas_Object_Image *)(obj->object_data);
779 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
784 if (w) *w = o->cur.image.w;
785 if (h) *h = o->cur.image.h;
789 evas_object_image_stride_get(const Evas_Object *obj)
791 Evas_Object_Image *o;
793 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
796 o = (Evas_Object_Image *)(obj->object_data);
797 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
800 return o->cur.image.stride;
804 evas_object_image_load_error_get(const Evas_Object *obj)
806 Evas_Object_Image *o;
808 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
811 o = (Evas_Object_Image *)(obj->object_data);
812 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
815 return o->load_error;
819 evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace)
821 Evas_Object_Image *o;
824 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
827 o = (Evas_Object_Image *)(obj->object_data);
828 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
831 if ((o->preloading) && (o->engine_data))
834 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
838 if (!o->engine_data) return NULL;
839 if (!o->cur.cspace == to_cspace) return NULL;
841 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
846 return evas_object_image_data_convert_internal(o, data, to_cspace);
850 evas_object_image_data_set(Evas_Object *obj, void *data)
852 Evas_Object_Image *o;
855 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
858 o = (Evas_Object_Image *)(obj->object_data);
859 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
862 if ((o->preloading) && (o->engine_data))
865 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
869 #ifdef EVAS_FRAME_QUEUING
871 evas_common_pipe_op_image_flush(o->engine_data);
873 p_data = o->engine_data;
874 if (o->tmpf) _cleanup_tmpf(obj);
878 o->engine_data = obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
882 o->engine_data = obj->layer->evas->engine.func->image_new_from_data(obj->layer->evas->engine.data.output,
892 if (obj->layer->evas->engine.func->image_scale_hint_set)
893 obj->layer->evas->engine.func->image_scale_hint_set
894 (obj->layer->evas->engine.data.output,
895 o->engine_data, o->scale_hint);
896 if (obj->layer->evas->engine.func->image_content_hint_set)
897 obj->layer->evas->engine.func->image_content_hint_set
898 (obj->layer->evas->engine.data.output,
899 o->engine_data, o->content_hint);
900 if (obj->layer->evas->engine.func->image_stride_get)
901 obj->layer->evas->engine.func->image_stride_get
902 (obj->layer->evas->engine.data.output,
903 o->engine_data, &stride);
905 stride = o->cur.image.w * 4;
906 o->cur.image.stride = stride;
912 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
914 o->load_error = EVAS_LOAD_ERROR_NONE;
917 o->cur.image.stride = 0;
918 o->engine_data = NULL;
920 /* FIXME - in engine call above
922 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
926 if (o->pixels_checked_out > 0) o->pixels_checked_out--;
927 if (p_data != o->engine_data)
929 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
930 o->pixels_checked_out = 0;
933 evas_object_change(obj);
937 evas_object_image_data_get(const Evas_Object *obj, Eina_Bool for_writing)
939 Evas_Object_Image *o;
942 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
945 o = (Evas_Object_Image *)(obj->object_data);
946 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
949 if (!o->engine_data) return NULL;
950 #ifdef EVAS_FRAME_QUEUING
951 evas_common_pipe_op_image_flush(o->engine_data);
955 if (obj->layer->evas->engine.func->image_scale_hint_set)
956 obj->layer->evas->engine.func->image_scale_hint_set
957 (obj->layer->evas->engine.data.output,
958 o->engine_data, o->scale_hint);
959 if (obj->layer->evas->engine.func->image_content_hint_set)
960 obj->layer->evas->engine.func->image_content_hint_set
961 (obj->layer->evas->engine.data.output,
962 o->engine_data, o->content_hint);
963 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
972 if (obj->layer->evas->engine.func->image_stride_get)
973 obj->layer->evas->engine.func->image_stride_get
974 (obj->layer->evas->engine.data.output,
975 o->engine_data, &stride);
977 stride = o->cur.image.w * 4;
978 o->cur.image.stride = stride;
980 o->pixels_checked_out++;
983 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
990 evas_object_image_preload(Evas_Object *obj, Eina_Bool cancel)
992 Evas_Object_Image *o;
994 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
997 o = (Evas_Object_Image *)(obj->object_data);
998 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1001 if (!o->engine_data)
1004 evas_object_inform_call_image_preloaded(obj);
1007 // FIXME: if already busy preloading, then dont request again until
1014 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1024 obj->layer->evas->engine.func->image_data_preload_request(obj->layer->evas->engine.data.output,
1032 evas_object_image_data_copy_set(Evas_Object *obj, void *data)
1034 Evas_Object_Image *o;
1037 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1040 o = (Evas_Object_Image *)(obj->object_data);
1041 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1044 if ((o->preloading) && (o->engine_data))
1047 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1051 if ((o->cur.image.w <= 0) ||
1052 (o->cur.image.h <= 0)) return;
1053 if (o->tmpf) _cleanup_tmpf(obj);
1055 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
1057 o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data(obj->layer->evas->engine.data.output,
1067 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1070 if (obj->layer->evas->engine.func->image_scale_hint_set)
1071 obj->layer->evas->engine.func->image_scale_hint_set
1072 (obj->layer->evas->engine.data.output,
1073 o->engine_data, o->scale_hint);
1074 if (obj->layer->evas->engine.func->image_content_hint_set)
1075 obj->layer->evas->engine.func->image_content_hint_set
1076 (obj->layer->evas->engine.data.output,
1077 o->engine_data, o->content_hint);
1078 if (obj->layer->evas->engine.func->image_stride_get)
1079 obj->layer->evas->engine.func->image_stride_get
1080 (obj->layer->evas->engine.data.output,
1081 o->engine_data, &stride);
1083 stride = o->cur.image.w * 4;
1084 o->cur.image.stride = stride;
1086 o->pixels_checked_out = 0;
1087 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
1091 evas_object_image_data_update_add(Evas_Object *obj, int x, int y, int w, int h)
1093 Evas_Object_Image *o;
1096 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1099 o = (Evas_Object_Image *)(obj->object_data);
1100 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1103 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur.image.w, o->cur.image.h);
1104 if ((w <= 0) || (h <= 0)) return;
1105 NEW_RECT(r, x, y, w, h);
1106 if (r) o->pixel_updates = eina_list_append(o->pixel_updates, r);
1108 evas_object_change(obj);
1112 evas_object_image_alpha_set(Evas_Object *obj, Eina_Bool has_alpha)
1114 Evas_Object_Image *o;
1116 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1119 o = (Evas_Object_Image *)(obj->object_data);
1120 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1123 if ((o->preloading) && (o->engine_data))
1126 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1130 if (((has_alpha) && (o->cur.has_alpha)) ||
1131 ((!has_alpha) && (!o->cur.has_alpha)))
1133 o->cur.has_alpha = has_alpha;
1138 #ifdef EVAS_FRAME_QUEUING
1139 evas_common_pipe_op_image_flush(o->engine_data);
1141 o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1144 if (obj->layer->evas->engine.func->image_scale_hint_set)
1145 obj->layer->evas->engine.func->image_scale_hint_set
1146 (obj->layer->evas->engine.data.output,
1147 o->engine_data, o->scale_hint);
1148 if (obj->layer->evas->engine.func->image_content_hint_set)
1149 obj->layer->evas->engine.func->image_content_hint_set
1150 (obj->layer->evas->engine.data.output,
1151 o->engine_data, o->content_hint);
1152 if (obj->layer->evas->engine.func->image_stride_get)
1153 obj->layer->evas->engine.func->image_stride_get
1154 (obj->layer->evas->engine.data.output,
1155 o->engine_data, &stride);
1157 stride = o->cur.image.w * 4;
1158 o->cur.image.stride = stride;
1160 evas_object_image_data_update_add(obj, 0, 0, o->cur.image.w, o->cur.image.h);
1161 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
1166 evas_object_image_alpha_get(const Evas_Object *obj)
1168 Evas_Object_Image *o;
1170 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1173 o = (Evas_Object_Image *)(obj->object_data);
1174 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1177 return o->cur.has_alpha;
1181 evas_object_image_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth_scale)
1183 Evas_Object_Image *o;
1185 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1188 o = (Evas_Object_Image *)(obj->object_data);
1189 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1192 if (((smooth_scale) && (o->cur.smooth_scale)) ||
1193 ((!smooth_scale) && (!o->cur.smooth_scale)))
1195 o->cur.smooth_scale = smooth_scale;
1197 evas_object_change(obj);
1201 evas_object_image_smooth_scale_get(const Evas_Object *obj)
1203 Evas_Object_Image *o;
1205 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1208 o = (Evas_Object_Image *)(obj->object_data);
1209 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1212 return o->cur.smooth_scale;
1216 evas_object_image_reload(Evas_Object *obj)
1218 Evas_Object_Image *o;
1220 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1223 o = (Evas_Object_Image *)(obj->object_data);
1224 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1227 if ((o->preloading) && (o->engine_data))
1230 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1234 if ((!o->cur.file) ||
1235 (o->pixels_checked_out > 0)) return;
1237 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);
1238 evas_object_image_unload(obj, 1);
1239 evas_object_inform_call_image_unloaded(obj);
1240 evas_object_image_load(obj);
1241 o->prev.file = NULL;
1244 evas_object_change(obj);
1248 evas_object_image_save(const Evas_Object *obj, const char *file, const char *key, const char *flags)
1250 Evas_Object_Image *o;
1251 DATA32 *data = NULL;
1252 int quality = 80, compress = 9, ok = 0;
1255 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1258 o = (Evas_Object_Image *)(obj->object_data);
1259 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1263 if (!o->engine_data) return 0;
1264 o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1274 tflags = alloca(strlen(flags) + 1);
1275 strcpy(tflags, flags);
1279 pp = strchr(p, ' ');
1281 sscanf(p, "quality=%i", &quality);
1282 sscanf(p, "compress=%i", &compress);
1287 im = (RGBA_Image*) evas_cache_image_data(evas_common_image_cache_get(),
1292 EVAS_COLORSPACE_ARGB8888);
1295 if (o->cur.cspace == EVAS_COLORSPACE_ARGB8888)
1296 im->image.data = data;
1298 im->image.data = evas_object_image_data_convert_internal(o,
1300 EVAS_COLORSPACE_ARGB8888);
1303 ok = evas_common_save_image_to_file(im, file, key, quality, compress);
1305 if (o->cur.cspace != EVAS_COLORSPACE_ARGB8888)
1306 free(im->image.data);
1309 evas_cache_image_drop(&im->cache_entry);
1315 evas_object_image_pixels_import(Evas_Object *obj, Evas_Pixel_Import_Source *pixels)
1317 Evas_Object_Image *o;
1319 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1322 o = (Evas_Object_Image *)(obj->object_data);
1323 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1327 if ((o->preloading) && (o->engine_data))
1330 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1334 if ((pixels->w != o->cur.image.w) || (pixels->h != o->cur.image.h)) return 0;
1335 if (o->tmpf) _cleanup_tmpf(obj);
1336 switch (pixels->format)
1339 case EVAS_PIXEL_FORMAT_ARGB32:
1343 DATA32 *image_pixels = NULL;
1346 obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1351 /* FIXME: need to actualyl support this */
1352 /* memcpy(image_pixels, pixels->rows, o->cur.image.w * o->cur.image.h * 4);*/
1355 obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
1360 obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1364 evas_object_change(obj);
1369 #ifdef BUILD_CONVERT_YUV
1370 case EVAS_PIXEL_FORMAT_YUV420P_601:
1374 DATA32 *image_pixels = NULL;
1377 obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
1383 evas_common_convert_yuv_420p_601_rgba((DATA8 **) pixels->rows,
1384 (DATA8 *) image_pixels,
1389 obj->layer->evas->engine.func->image_data_put(obj->layer->evas->engine.data.output,
1394 obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
1398 evas_object_change(obj);
1411 evas_object_image_pixels_get_callback_set(Evas_Object *obj, Evas_Object_Image_Pixels_Get_Cb func, void *data)
1413 Evas_Object_Image *o;
1415 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1418 o = (Evas_Object_Image *)(obj->object_data);
1419 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1422 o->func.get_pixels = func;
1423 o->func.get_pixels_data = data;
1427 evas_object_image_pixels_dirty_set(Evas_Object *obj, Eina_Bool dirty)
1429 Evas_Object_Image *o;
1431 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1434 o = (Evas_Object_Image *)(obj->object_data);
1435 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1438 if (dirty) o->dirty_pixels = 1;
1439 else o->dirty_pixels = 0;
1441 evas_object_change(obj);
1445 evas_object_image_pixels_dirty_get(const Evas_Object *obj)
1447 Evas_Object_Image *o;
1449 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1452 o = (Evas_Object_Image *)(obj->object_data);
1453 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1456 if (o->dirty_pixels) return 1;
1461 evas_object_image_load_dpi_set(Evas_Object *obj, double dpi)
1463 Evas_Object_Image *o;
1465 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1468 o = (Evas_Object_Image *)(obj->object_data);
1469 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1472 if (dpi == o->load_opts.dpi) return;
1473 o->load_opts.dpi = dpi;
1476 evas_object_image_unload(obj, 0);
1477 evas_object_inform_call_image_unloaded(obj);
1478 evas_object_image_load(obj);
1480 evas_object_change(obj);
1485 evas_object_image_load_dpi_get(const Evas_Object *obj)
1487 Evas_Object_Image *o;
1489 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1492 o = (Evas_Object_Image *)(obj->object_data);
1493 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1496 return o->load_opts.dpi;
1500 evas_object_image_load_size_set(Evas_Object *obj, int w, int h)
1502 Evas_Object_Image *o;
1504 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1507 o = (Evas_Object_Image *)(obj->object_data);
1508 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1511 if ((o->load_opts.w == w) && (o->load_opts.h == h)) return;
1516 evas_object_image_unload(obj, 0);
1517 evas_object_inform_call_image_unloaded(obj);
1518 evas_object_image_load(obj);
1520 evas_object_change(obj);
1525 evas_object_image_load_size_get(const Evas_Object *obj, int *w, int *h)
1527 Evas_Object_Image *o;
1529 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1532 o = (Evas_Object_Image *)(obj->object_data);
1533 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1536 if (w) *w = o->load_opts.w;
1537 if (h) *h = o->load_opts.h;
1541 evas_object_image_load_scale_down_set(Evas_Object *obj, int scale_down)
1543 Evas_Object_Image *o;
1545 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1548 o = (Evas_Object_Image *)(obj->object_data);
1549 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1552 if (o->load_opts.scale_down_by == scale_down) return;
1553 o->load_opts.scale_down_by = scale_down;
1556 evas_object_image_unload(obj, 0);
1557 evas_object_inform_call_image_unloaded(obj);
1558 evas_object_image_load(obj);
1560 evas_object_change(obj);
1565 evas_object_image_load_scale_down_get(const Evas_Object *obj)
1567 Evas_Object_Image *o;
1569 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1572 o = (Evas_Object_Image *)(obj->object_data);
1573 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1576 return o->load_opts.scale_down_by;
1580 evas_object_image_load_region_set(Evas_Object *obj, int x, int y, int w, int h)
1582 Evas_Object_Image *o;
1584 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1587 o = (Evas_Object_Image *)(obj->object_data);
1588 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1591 if ((o->load_opts.region.x == x) && (o->load_opts.region.y == y) &&
1592 (o->load_opts.region.w == w) && (o->load_opts.region.h == h)) return;
1593 o->load_opts.region.x = x;
1594 o->load_opts.region.y = y;
1595 o->load_opts.region.w = w;
1596 o->load_opts.region.h = h;
1599 evas_object_image_unload(obj, 0);
1600 evas_object_inform_call_image_unloaded(obj);
1601 evas_object_image_load(obj);
1603 evas_object_change(obj);
1608 evas_object_image_load_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1610 Evas_Object_Image *o;
1612 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1615 o = (Evas_Object_Image *)(obj->object_data);
1616 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1619 if (x) *x = o->load_opts.region.x;
1620 if (y) *y = o->load_opts.region.y;
1621 if (w) *w = o->load_opts.region.w;
1622 if (h) *h = o->load_opts.region.h;
1626 evas_object_image_load_orientation_set(Evas_Object *obj, Eina_Bool enable)
1628 Evas_Object_Image *o;
1630 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1633 o = (Evas_Object_Image *)(obj->object_data);
1634 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1637 o->load_opts.orientation = !!enable;
1641 evas_object_image_load_orientation_get(const Evas_Object *obj)
1643 Evas_Object_Image *o;
1645 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1648 o = (Evas_Object_Image *)(obj->object_data);
1649 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1652 return o->load_opts.orientation;
1656 evas_object_image_colorspace_set(Evas_Object *obj, Evas_Colorspace cspace)
1658 Evas_Object_Image *o;
1660 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1663 o = (Evas_Object_Image *)(obj->object_data);
1664 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1668 if ((o->preloading) && (o->engine_data))
1671 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1675 if (o->tmpf) _cleanup_tmpf(obj);
1676 #ifdef EVAS_FRAME_QUEUING
1677 if ((Evas_Colorspace)o->cur.cspace != cspace)
1680 evas_common_pipe_op_image_flush(o->engine_data);
1684 o->cur.cspace = cspace;
1686 obj->layer->evas->engine.func->image_colorspace_set(obj->layer->evas->engine.data.output,
1691 EAPI Evas_Colorspace
1692 evas_object_image_colorspace_get(const Evas_Object *obj)
1694 Evas_Object_Image *o;
1696 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1697 return EVAS_COLORSPACE_ARGB8888;
1699 o = (Evas_Object_Image *)(obj->object_data);
1700 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1701 return EVAS_COLORSPACE_ARGB8888;
1703 return o->cur.cspace;
1707 evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface *surf)
1709 Evas_Object_Image *o;
1711 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1714 o = (Evas_Object_Image *)(obj->object_data);
1715 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1718 if ((o->preloading) && (o->engine_data))
1721 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
1725 if (o->tmpf) _cleanup_tmpf(obj);
1726 if (o->cur.source) _proxy_unset(obj);
1727 if (!obj->layer->evas->engine.func->image_native_set) return;
1729 ((surf->version < 2) ||
1730 (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return;
1732 obj->layer->evas->engine.func->image_native_set(obj->layer->evas->engine.data.output,
1737 EAPI Evas_Native_Surface *
1738 evas_object_image_native_surface_get(const Evas_Object *obj)
1740 Evas_Object_Image *o;
1742 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1745 o = (Evas_Object_Image *)(obj->object_data);
1746 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1749 if (!obj->layer->evas->engine.func->image_native_get) return NULL;
1750 return obj->layer->evas->engine.func->image_native_get(obj->layer->evas->engine.data.output,
1755 evas_object_image_scale_hint_set(Evas_Object *obj, Evas_Image_Scale_Hint hint)
1757 Evas_Object_Image *o;
1759 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1762 o = (Evas_Object_Image *)(obj->object_data);
1763 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1766 if (o->scale_hint == hint) return;
1767 #ifdef EVAS_FRAME_QUEUING
1769 evas_common_pipe_op_image_flush(o->engine_data);
1771 o->scale_hint = hint;
1776 if (obj->layer->evas->engine.func->image_scale_hint_set)
1777 obj->layer->evas->engine.func->image_scale_hint_set
1778 (obj->layer->evas->engine.data.output,
1779 o->engine_data, o->scale_hint);
1780 if (obj->layer->evas->engine.func->image_stride_get)
1781 obj->layer->evas->engine.func->image_stride_get
1782 (obj->layer->evas->engine.data.output,
1783 o->engine_data, &stride);
1785 stride = o->cur.image.w * 4;
1786 o->cur.image.stride = stride;
1790 EAPI Evas_Image_Scale_Hint
1791 evas_object_image_scale_hint_get(const Evas_Object *obj)
1793 Evas_Object_Image *o;
1795 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1796 return EVAS_IMAGE_SCALE_HINT_NONE;
1798 o = (Evas_Object_Image *)(obj->object_data);
1799 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1800 return EVAS_IMAGE_SCALE_HINT_NONE;
1802 return o->scale_hint;
1806 evas_object_image_content_hint_set(Evas_Object *obj, Evas_Image_Content_Hint hint)
1808 Evas_Object_Image *o;
1810 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1813 o = (Evas_Object_Image *)(obj->object_data);
1814 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1817 if (o->content_hint == hint) return;
1818 #ifdef EVAS_FRAME_QUEUING
1820 evas_common_pipe_op_image_flush(o->engine_data);
1822 o->content_hint = hint;
1827 if (obj->layer->evas->engine.func->image_content_hint_set)
1828 obj->layer->evas->engine.func->image_content_hint_set
1829 (obj->layer->evas->engine.data.output,
1830 o->engine_data, o->content_hint);
1831 if (obj->layer->evas->engine.func->image_stride_get)
1832 obj->layer->evas->engine.func->image_stride_get
1833 (obj->layer->evas->engine.data.output,
1834 o->engine_data, &stride);
1836 stride = o->cur.image.w * 4;
1837 o->cur.image.stride = stride;
1842 evas_object_image_alpha_mask_set(Evas_Object *obj, Eina_Bool ismask)
1844 Evas_Object_Image *o;
1846 if (!ismask) return;
1848 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1851 o = (Evas_Object_Image *)(obj->object_data);
1852 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1856 /* Convert to A8 if not already */
1862 #define FRAME_MAX 1024
1863 EAPI Evas_Image_Content_Hint
1864 evas_object_image_content_hint_get(const Evas_Object *obj)
1866 Evas_Object_Image *o;
1868 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1869 return EVAS_IMAGE_CONTENT_HINT_NONE;
1871 o = (Evas_Object_Image *)(obj->object_data);
1872 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1873 return EVAS_IMAGE_CONTENT_HINT_NONE;
1875 return o->content_hint;
1878 /* animated feature */
1880 evas_object_image_animated_get(const Evas_Object *obj)
1882 Evas_Object_Image *o;
1884 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1887 o = (Evas_Object_Image *)(obj->object_data);
1888 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1892 if (obj->layer->evas->engine.func->image_animated_get)
1893 return obj->layer->evas->engine.func->image_animated_get(obj->layer->evas->engine.data.output, o->engine_data);
1898 evas_object_image_animated_frame_count_get(const Evas_Object *obj)
1900 Evas_Object_Image *o;
1902 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1905 o = (Evas_Object_Image *)(obj->object_data);
1906 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1910 if (!evas_object_image_animated_get(obj)) return -1;
1911 if (obj->layer->evas->engine.func->image_animated_frame_count_get)
1912 return obj->layer->evas->engine.func->image_animated_frame_count_get(obj->layer->evas->engine.data.output, o->engine_data);
1916 EAPI Evas_Image_Animated_Loop_Hint
1917 evas_object_image_animated_loop_type_get(const Evas_Object *obj)
1919 Evas_Object_Image *o;
1921 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1922 return EVAS_IMAGE_ANIMATED_HINT_NONE;
1924 o = (Evas_Object_Image *)(obj->object_data);
1925 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1926 return EVAS_IMAGE_ANIMATED_HINT_NONE;
1929 if (!evas_object_image_animated_get(obj)) return EVAS_IMAGE_ANIMATED_HINT_NONE;
1931 if (obj->layer->evas->engine.func->image_animated_loop_type_get)
1932 return obj->layer->evas->engine.func->image_animated_loop_type_get(obj->layer->evas->engine.data.output, o->engine_data);
1933 return EVAS_IMAGE_ANIMATED_HINT_NONE;
1937 evas_object_image_animated_loop_count_get(const Evas_Object *obj)
1939 Evas_Object_Image *o;
1941 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1944 o = (Evas_Object_Image *)(obj->object_data);
1945 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1949 if (!evas_object_image_animated_get(obj)) return -1;
1951 if (obj->layer->evas->engine.func->image_animated_loop_count_get)
1952 return obj->layer->evas->engine.func->image_animated_loop_count_get(obj->layer->evas->engine.data.output, o->engine_data);
1957 evas_object_image_animated_frame_duration_get(const Evas_Object *obj, int start_frame, int frame_num)
1959 Evas_Object_Image *o;
1960 int frame_count = 0;
1962 if (start_frame < 1) return -1;
1963 if (frame_num < 0) return -1;
1965 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1968 o = (Evas_Object_Image *)(obj->object_data);
1969 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1973 if (!evas_object_image_animated_get(obj)) return -1;
1975 if (!obj->layer->evas->engine.func->image_animated_frame_count_get) return -1;
1977 frame_count = obj->layer->evas->engine.func->image_animated_frame_count_get(obj->layer->evas->engine.data.output, o->engine_data);
1979 if ((start_frame + frame_num) > frame_count) return -1;
1980 if (obj->layer->evas->engine.func->image_animated_frame_duration_get)
1981 return obj->layer->evas->engine.func->image_animated_frame_duration_get(obj->layer->evas->engine.data.output, o->engine_data, start_frame, frame_num);
1986 evas_object_image_animated_frame_set(Evas_Object *obj, int frame_index)
1988 Evas_Object_Image *o;
1989 int frame_count = 0;
1991 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1994 o = (Evas_Object_Image *)(obj->object_data);
1995 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
1999 if (!o->cur.file) return;
2000 if (o->cur.frame == frame_index) return;
2002 if (!evas_object_image_animated_get(obj)) return;
2004 frame_count = evas_object_image_animated_frame_count_get(obj);
2006 /* limit the size of frame to FRAME_MAX */
2007 if ((frame_count > FRAME_MAX) || (frame_count < 0) || (frame_index > frame_count))
2010 if (!obj->layer->evas->engine.func->image_animated_frame_set) return;
2011 if (!obj->layer->evas->engine.func->image_animated_frame_set(obj->layer->evas->engine.data.output, o->engine_data, frame_index))
2014 o->prev.frame = o->cur.frame;
2015 o->cur.frame = frame_index;
2018 evas_object_change(obj);
2023 evas_image_cache_flush(Evas *e)
2025 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2029 e->engine.func->image_cache_flush(e->engine.data.output);
2033 evas_image_cache_reload(Evas *e)
2037 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2041 evas_image_cache_flush(e);
2042 EINA_INLIST_FOREACH(e->layers, layer)
2046 EINA_INLIST_FOREACH(layer->objects, obj)
2048 Evas_Object_Image *o;
2050 o = (Evas_Object_Image *)(obj->object_data);
2051 if (o->magic == MAGIC_OBJ_IMAGE)
2053 evas_object_image_unload(obj, 1);
2054 evas_object_inform_call_image_unloaded(obj);
2058 evas_image_cache_flush(e);
2059 EINA_INLIST_FOREACH(e->layers, layer)
2063 EINA_INLIST_FOREACH(layer->objects, obj)
2065 Evas_Object_Image *o;
2067 o = (Evas_Object_Image *)(obj->object_data);
2068 if (o->magic == MAGIC_OBJ_IMAGE)
2070 evas_object_image_load(obj);
2072 evas_object_change(obj);
2076 evas_image_cache_flush(e);
2080 evas_image_cache_set(Evas *e, int size)
2082 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2086 if (size < 0) size = 0;
2087 e->engine.func->image_cache_set(e->engine.data.output, size);
2091 evas_image_cache_get(const Evas *e)
2093 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
2097 return e->engine.func->image_cache_get(e->engine.data.output);
2100 /* all nice and private */
2102 _proxy_unset(Evas_Object *proxy)
2104 Evas_Object_Image *o;
2106 o = proxy->object_data;
2107 if (!o->cur.source) return;
2109 o->cur.source->proxy.proxies = eina_list_remove(o->cur.source->proxy.proxies, proxy);
2111 o->cur.source = NULL;
2114 evas_map_free(o->cur.defmap);
2115 o->cur.defmap = NULL;
2121 _proxy_set(Evas_Object *proxy, Evas_Object *src)
2123 Evas_Object_Image *o;
2125 o = proxy->object_data;
2127 evas_object_image_file_set(proxy, NULL, NULL);
2129 o->cur.source = src;
2131 src->proxy.proxies = eina_list_append(src->proxy.proxies, proxy);
2132 src->proxy.redraw = EINA_TRUE;
2135 /* Some moron just set a proxy on a proxy.
2136 * Give them some pixels. A random color
2139 _proxy_error(Evas_Object *proxy, void *context, void *output, void *surface,
2143 int r = rand() % 255;
2144 int g = rand() % 255;
2145 int b = rand() % 255;
2147 /* XXX: Eina log error or something I'm sure
2148 * If it bugs you, just fix it. Don't tell me */
2149 if (VERBOSE_PROXY_ERROR) printf("Err: Argh! Recursive proxies.\n");
2151 func = proxy->layer->evas->engine.func;
2152 func->context_color_set(output, context, r, g, b, 255);
2153 func->context_multiplier_unset(output, context);
2154 func->context_render_op_set(output, context, proxy->cur.render_op);
2155 func->rectangle_draw(output, context, surface, proxy->cur.geometry.x + x,
2156 proxy->cur.geometry.y + y,
2157 proxy->cur.geometry.w,
2158 proxy->cur.geometry.h);
2164 _proxy_subrender_recurse(Evas_Object *obj, Evas_Object *clip, void *output, void *surface, void *ctx, int x, int y)
2167 Evas *e = obj->layer->evas;
2169 if (obj->clip.clipees) return;
2170 if (!obj->cur.visible) return;
2171 if ((!clip) || (clip != obj->cur.clipper))
2173 if (!obj->cur.cache.clip.visible) return;
2174 if ((obj->cur.cache.clip.a == 0) &&
2175 (obj->cur.render_op == EVAS_RENDER_BLEND)) return;
2177 if ((obj->func->is_visible) && (!obj->func->is_visible(obj))) return;
2179 if (!obj->pre_render_done)
2180 obj->func->render_pre(obj);
2181 ctx = e->engine.func->context_new(output);
2182 if (obj->smart.smart)
2184 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
2186 _proxy_subrender_recurse(obj2, clip, output, surface, ctx, x, y);
2191 obj->func->render(obj, output, ctx, surface, x, y);
2193 e->engine.func->context_free(output, ctx);
2198 * Render the source object when a proxy is set.
2200 * Used to force a draw if necessary, else just makes sures it's available.
2203 _proxy_subrender(Evas *e, Evas_Object *source)
2206 /* Evas_Object *obj2, *clip;*/
2209 if (!source) return;
2211 w = source->cur.geometry.w;
2212 h = source->cur.geometry.h;
2214 source->proxy.redraw = EINA_FALSE;
2216 /* We need to redraw surface then */
2217 if ((source->proxy.surface) &&
2218 ((source->proxy.w != w) || (source->proxy.h != h)))
2220 e->engine.func->image_map_surface_free(e->engine.data.output,
2221 source->proxy.surface);
2222 source->proxy.surface = NULL;
2225 /* FIXME: Hardcoded alpha 'on' */
2226 /* FIXME (cont): Should see if the object has alpha */
2227 if (!source->proxy.surface)
2229 source->proxy.surface = e->engine.func->image_map_surface_new
2230 (e->engine.data.output, w, h, 1);
2231 source->proxy.w = w;
2232 source->proxy.h = h;
2235 ctx = e->engine.func->context_new(e->engine.data.output);
2236 e->engine.func->context_color_set(e->engine.data.output, ctx, 0, 0, 0, 0);
2237 e->engine.func->context_render_op_set(e->engine.data.output, ctx, EVAS_RENDER_COPY);
2238 e->engine.func->rectangle_draw(e->engine.data.output, ctx,
2239 source->proxy.surface, 0, 0, w, h);
2240 e->engine.func->context_free(e->engine.data.output, ctx);
2242 ctx = e->engine.func->context_new(e->engine.data.output);
2243 evas_render_mapped(e, source, ctx, source->proxy.surface,
2244 -source->cur.geometry.x,
2245 -source->cur.geometry.y,
2246 1, 0, 0, e->output.w, e->output.h);
2247 e->engine.func->context_free(e->engine.data.output, ctx);
2248 source->proxy.surface = e->engine.func->image_dirty_region
2249 (e->engine.data.output, source->proxy.surface, 0, 0, w, h);
2251 ctx = e->engine.func->context_new(e->engine.data.output);
2252 if (source->smart.smart)
2254 clip = evas_object_smart_clipped_clipper_get(source);
2255 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(source), obj2)
2257 _proxy_subrender_recurse(obj2, clip, e->engine.data.output,
2258 source->proxy.surface,
2260 -source->cur.geometry.x,
2261 -source->cur.geometry.y);
2266 if (!source->pre_render_done)
2267 source->func->render_pre(source);
2268 source->func->render(source, e->engine.data.output, ctx,
2269 source->proxy.surface,
2270 -source->cur.geometry.x,
2271 -source->cur.geometry.y);
2274 e->engine.func->context_free(e->engine.data.output, ctx);
2275 source->proxy.surface = e->engine.func->image_dirty_region
2276 (e->engine.data.output, source->proxy.surface, 0, 0, w, h);
2280 #if 0 // filtering disabled
2283 * Note that this is similar to proxy_subrender_recurse. It should be
2284 * possible to merge I guess
2287 image_filter_draw_under_recurse(Evas *e, Evas_Object *obj, Evas_Object *stop,
2288 void *output, void *ctx, void *surface,
2293 if (obj->clip.clipees) return;
2294 /* FIXME: Doing bounding box test */
2295 if (!evas_object_is_in_output_rect(obj, stop->cur.geometry.x,
2296 stop->cur.geometry.y,
2297 stop->cur.geometry.w,
2298 stop->cur.geometry.h))
2301 if (!evas_object_is_visible(obj)) return;
2302 obj->pre_render_done = 1;
2303 ctx = e->engine.func->context_new(output);
2305 if (obj->smart.smart)
2307 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj), obj2)
2309 if (obj2 == stop) return;
2310 image_filter_draw_under_recurse(e, obj2, stop, output, surface,
2315 obj->func->render(obj, output, ctx, surface, x ,y);
2316 e->engine.func->context_free(output, ctx);
2320 * Draw all visible objects intersecting an object which are _beneath_ it.
2323 image_filter_draw_under(Evas *e, Evas_Object *stop, void *output, void *ctx, void *surface, int dx, int dy)
2328 x = stop->cur.geometry.x - dx;
2329 y = stop->cur.geometry.y - dy;
2331 EINA_INLIST_FOREACH(e->layers, lay)
2334 EINA_INLIST_FOREACH(lay->objects, obj)
2336 if (obj->delete_me) continue;
2337 if (obj == stop) return;
2338 /* FIXME: Do bounding box check */
2339 image_filter_draw_under_recurse(e, obj, stop, output, ctx,
2343 e->engine.func->image_dirty_region(output, surface, 0, 0, 300, 300);
2344 e->engine.func->output_flush(output);
2348 * Update the filtered object.
2350 * Creates a new context, and renders stuff (filtered) onto that.
2353 image_filter_update(Evas *e, Evas_Object *obj, void *src, int imagew, int imageh, int *outw, int *outh)
2357 Evas_Filter_Info *info;
2363 if (info->mode == EVAS_FILTER_MODE_BELOW)
2365 w = obj->cur.geometry.w;
2366 h = obj->cur.geometry.h;
2367 evas_filter_get_size(info, w, h, &imagew, &imageh, EINA_TRUE);
2372 evas_filter_get_size(info, imagew, imageh, &w, &h, EINA_FALSE);
2373 alpha = e->engine.func->image_alpha_get(e->engine.data.output, src);
2376 /* Certain filters may make alpha images anyway */
2377 if (alpha == EINA_FALSE) alpha = evas_filter_always_alpha(info);
2379 surface = e->engine.func->image_map_surface_new(e->engine.data.output, w, h,
2382 if (info->mode == EVAS_FILTER_MODE_BELOW)
2387 disw = obj->cur.geometry.w;
2388 dish = obj->cur.geometry.h;
2389 dx = (imagew - w) >> 1;
2390 dy = (imageh - h) >> 1;
2391 subsurface = e->engine.func->image_map_surface_new
2392 (e->engine.data.output, imagew, imageh, 1);
2393 ctx = e->engine.func->context_new(e->engine.data.output);
2394 e->engine.func->context_color_set(e->engine.data.output, ctx, 0, 255, 0, 255);
2395 e->engine.func->context_render_op_set(e->engine.data.output, ctx, EVAS_RENDER_COPY);
2396 e->engine.func->rectangle_draw(e->engine.data.output, ctx,
2397 subsurface, 0, 0, imagew, imageh);
2399 image_filter_draw_under(e, obj, e->engine.data.output, ctx,
2400 subsurface, dx, dy);
2402 e->engine.func->context_free(e->engine.data.output, ctx);
2404 ctx = e->engine.func->context_new(e->engine.data.output);
2406 e->engine.func->image_draw_filtered(e->engine.data.output,
2407 ctx, surface, subsurface, info);
2409 e->engine.func->context_free(e->engine.data.output, ctx);
2411 e->engine.func->image_map_surface_free(e->engine.data.output,
2416 ctx = e->engine.func->context_new(e->engine.data.output);
2417 e->engine.func->image_draw_filtered(e->engine.data.output,
2418 ctx, surface, src, info);
2419 e->engine.func->context_free(e->engine.data.output, ctx);
2422 e->engine.func->image_dirty_region(e->engine.data.output, surface,
2424 if (outw) *outw = w;
2425 if (outh) *outh = h;
2426 return e->engine.func->image_filtered_save(src, surface,
2433 evas_object_image_unload(Evas_Object *obj, Eina_Bool dirty)
2435 Evas_Object_Image *o;
2437 o = (Evas_Object_Image *)(obj->object_data);
2439 if ((!o->cur.file) ||
2440 (o->pixels_checked_out > 0)) return;
2444 o->engine_data = obj->layer->evas->engine.func->image_dirty_region
2445 (obj->layer->evas->engine.data.output,
2448 o->cur.image.w, o->cur.image.h);
2455 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
2459 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
2462 o->engine_data = NULL;
2463 o->load_error = EVAS_LOAD_ERROR_NONE;
2464 o->cur.has_alpha = 1;
2465 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
2468 o->cur.image.stride = 0;
2472 evas_object_image_load(Evas_Object *obj)
2474 Evas_Object_Image *o;
2475 Evas_Image_Load_Opts lo;
2477 o = (Evas_Object_Image *)(obj->object_data);
2478 if (o->engine_data) return;
2480 lo.scale_down_by = o->load_opts.scale_down_by;
2481 lo.dpi = o->load_opts.dpi;
2482 lo.w = o->load_opts.w;
2483 lo.h = o->load_opts.h;
2484 lo.region.x = o->load_opts.region.x;
2485 lo.region.y = o->load_opts.region.y;
2486 lo.region.w = o->load_opts.region.w;
2487 lo.region.h = o->load_opts.region.h;
2488 lo.orientation = o->load_opts.orientation;
2489 o->engine_data = obj->layer->evas->engine.func->image_load
2490 (obj->layer->evas->engine.data.output,
2500 obj->layer->evas->engine.func->image_size_get
2501 (obj->layer->evas->engine.data.output,
2502 o->engine_data, &w, &h);
2503 if (obj->layer->evas->engine.func->image_stride_get)
2504 obj->layer->evas->engine.func->image_stride_get
2505 (obj->layer->evas->engine.data.output,
2506 o->engine_data, &stride);
2509 o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get
2510 (obj->layer->evas->engine.data.output,
2512 o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get
2513 (obj->layer->evas->engine.data.output,
2517 o->cur.image.stride = stride;
2521 o->load_error = EVAS_LOAD_ERROR_GENERIC;
2526 evas_object_image_figure_x_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret)
2530 w = ((size * obj->layer->evas->output.w) /
2531 (Evas_Coord)obj->layer->evas->viewport.w);
2532 if (size <= 0) size = 1;
2535 while (start - size > 0) start -= size;
2539 while (start < 0) start += size;
2541 start = ((start * obj->layer->evas->output.w) /
2542 (Evas_Coord)obj->layer->evas->viewport.w);
2548 evas_object_image_figure_y_fill(Evas_Object *obj, Evas_Coord start, Evas_Coord size, Evas_Coord *size_ret)
2552 h = ((size * obj->layer->evas->output.h) /
2553 (Evas_Coord)obj->layer->evas->viewport.h);
2554 if (size <= 0) size = 1;
2557 while (start - size > 0) start -= size;
2561 while (start < 0) start += size;
2563 start = ((start * obj->layer->evas->output.h) /
2564 (Evas_Coord)obj->layer->evas->viewport.h);
2570 evas_object_image_init(Evas_Object *obj)
2572 /* alloc image ob, setup methods and default values */
2573 obj->object_data = evas_object_image_new();
2574 /* set up default settings for this kind of object */
2575 obj->cur.color.r = 255;
2576 obj->cur.color.g = 255;
2577 obj->cur.color.b = 255;
2578 obj->cur.color.a = 255;
2579 obj->cur.geometry.x = 0;
2580 obj->cur.geometry.y = 0;
2581 obj->cur.geometry.w = 0;
2582 obj->cur.geometry.h = 0;
2584 obj->cur.anti_alias = 0;
2585 obj->cur.render_op = EVAS_RENDER_BLEND;
2586 /* set up object-specific settings */
2587 obj->prev = obj->cur;
2588 /* set up methods (compulsory) */
2589 obj->func = &object_func;
2594 evas_object_image_new(void)
2596 Evas_Object_Image *o;
2598 /* alloc obj private data */
2599 EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_image", Evas_Object_Image, 256, NULL);
2600 o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Image);
2601 if (!o) return NULL;
2602 EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Image);
2603 o->magic = MAGIC_OBJ_IMAGE;
2606 o->cur.smooth_scale = 1;
2607 o->cur.border.fill = 1;
2608 o->cur.border.scale = 1.0;
2609 o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
2610 o->cur.spread = EVAS_TEXTURE_REPEAT;
2611 o->cur.opaque_valid = 0;
2612 o->cur.source = NULL;
2619 evas_object_image_free(Evas_Object *obj)
2621 Evas_Object_Image *o;
2624 /* frees private object data. very simple here */
2625 o = (Evas_Object_Image *)(obj->object_data);
2626 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
2631 if (o->cur.file) eina_stringshare_del(o->cur.file);
2632 if (o->cur.key) eina_stringshare_del(o->cur.key);
2633 if (o->cur.source) _proxy_unset(obj);
2639 obj->layer->evas->engine.func->image_data_preload_cancel(obj->layer->evas->engine.data.output,
2643 obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
2646 o->engine_data = NULL;
2648 EINA_LIST_FREE(o->pixel_updates, r)
2649 eina_rectangle_free(r);
2650 EVAS_MEMPOOL_FREE(_mp_obj, o);
2654 evas_object_image_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y)
2656 Evas_Object_Image *o;
2657 int imagew, imageh, uvw, uvh;
2660 /* render object to surface with context, and offset by x,y */
2661 o = (Evas_Object_Image *)(obj->object_data);
2663 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
2664 return; /* no error message, already printed in pre_render */
2667 if (o->proxyrendering)
2669 _proxy_error(obj, context, output, surface, x, y);
2674 obj->layer->evas->engine.func->context_color_set(output,
2676 255, 255, 255, 255);
2678 if ((obj->cur.cache.clip.r == 255) &&
2679 (obj->cur.cache.clip.g == 255) &&
2680 (obj->cur.cache.clip.b == 255) &&
2681 (obj->cur.cache.clip.a == 255))
2683 obj->layer->evas->engine.func->context_multiplier_unset(output,
2687 obj->layer->evas->engine.func->context_multiplier_set(output,
2689 obj->cur.cache.clip.r,
2690 obj->cur.cache.clip.g,
2691 obj->cur.cache.clip.b,
2692 obj->cur.cache.clip.a);
2694 obj->layer->evas->engine.func->context_render_op_set(output, context,
2695 obj->cur.render_op);
2699 pixels = o->engine_data;
2700 imagew = o->cur.image.w;
2701 imageh = o->cur.image.h;
2705 else if (o->cur.source->proxy.surface && !o->cur.source->proxy.redraw)
2707 pixels = o->cur.source->proxy.surface;
2708 imagew = o->cur.source->proxy.w;
2709 imageh = o->cur.source->proxy.h;
2713 else if (o->cur.source->type == o_type &&
2714 ((Evas_Object_Image *)o->cur.source->object_data)->engine_data)
2716 Evas_Object_Image *oi;
2717 oi = o->cur.source->object_data;
2718 pixels = oi->engine_data;
2719 imagew = oi->cur.image.w;
2720 imageh = oi->cur.image.h;
2721 uvw = o->cur.source->cur.geometry.w;
2722 uvh = o->cur.source->cur.geometry.h;
2726 o->proxyrendering = 1;
2727 _proxy_subrender(obj->layer->evas, o->cur.source);
2728 pixels = o->cur.source->proxy.surface;
2729 imagew = o->cur.source->proxy.w;
2730 imageh = o->cur.source->proxy.h;
2733 o->proxyrendering = 0;
2736 #if 0 // filtering disabled
2737 /* Now check/update filter */
2738 if (obj->filter && obj->filter->filter)
2740 Filtered_Image *fi = NULL;
2741 //printf("%p has filter: %s\n", obj,obj->filter->dirty?"dirty":"clean");
2742 if (obj->filter->dirty)
2744 if (obj->filter->mode != EVAS_FILTER_MODE_BELOW)
2749 if (obj->filter->key) free(obj->filter->key);
2750 obj->filter->key = NULL;
2751 obj->filter->len = 0;
2752 key = evas_filter_key_get(obj->filter, &len);
2755 obj->filter->key = key;
2756 obj->filter->len = len;
2757 fi = obj->layer->evas->engine.func->image_filtered_get
2758 (o->engine_data, key, len);
2759 if (obj->filter->cached && fi != obj->filter->cached)
2761 obj->layer->evas->engine.func->image_filtered_free
2762 (o->engine_data, obj->filter->cached);
2763 obj->filter->cached = NULL;
2767 else if (obj->filter->cached)
2769 obj->layer->evas->engine.func->image_filtered_free
2770 (o->engine_data, obj->filter->cached);
2773 fi = image_filter_update(obj->layer->evas, obj, pixels,
2774 imagew, imageh, &imagew, &imageh);
2776 obj->filter->dirty = 0;
2777 obj->filter->cached = fi;
2781 fi = obj->filter->cached;
2789 Evas_Coord idw, idh, idx, idy;
2792 if (o->dirty_pixels)
2794 if (o->func.get_pixels)
2796 o->func.get_pixels(o->func.get_pixels_data, obj);
2797 o->engine_data = obj->layer->evas->engine.func->image_dirty_region
2798 (obj->layer->evas->engine.data.output, o->engine_data,
2799 0, 0, o->cur.image.w, o->cur.image.h);
2801 o->dirty_pixels = 0;
2803 if ((obj->cur.map) && (obj->cur.map->count > 3) && (obj->cur.usemap))
2805 const Evas_Map_Point *p, *p_end;
2806 RGBA_Map_Point pts[obj->cur.map->count], *pt;
2808 p = obj->cur.map->points;
2809 p_end = p + obj->cur.map->count;
2812 pts[0].px = obj->cur.map->persp.px << FP;
2813 pts[0].py = obj->cur.map->persp.py << FP;
2814 pts[0].foc = obj->cur.map->persp.foc << FP;
2815 pts[0].z0 = obj->cur.map->persp.z0 << FP;
2817 for (; p < p_end; p++, pt++)
2819 pt->x = (p->x + (double)x) * FP1;
2820 pt->y = (p->y + (double)y) * FP1;
2821 pt->z = (p->z) * FP1;
2825 pt->u = ((p->u * imagew) / uvw) * FP1;
2826 pt->v = ((p->v * imageh) / uvh) * FP1;
2827 if (pt->u < 0) pt->u = 0;
2828 else if (pt->u > (imagew * FP1)) pt->u = (imagew * FP1);
2829 if (pt->v < 0) pt->v = 0;
2830 else if (pt->v > (imageh * FP1)) pt->v = (imageh * FP1);
2831 pt->col = ARGB_JOIN(p->a, p->r, p->g, p->b);
2833 if (obj->cur.map->count & 0x1)
2835 pts[obj->cur.map->count] = pts[obj->cur.map->count -1];
2838 obj->layer->evas->engine.func->image_map_draw
2839 (output, context, surface, pixels, obj->cur.map->count,
2840 pts, o->cur.smooth_scale | obj->cur.map->smooth, 0);
2844 obj->layer->evas->engine.func->image_scale_hint_set(output,
2847 /* This is technically a bug here: If the value is recreated
2848 * (which is returned)it may be a new object, however exactly 0
2849 * of all the evas engines do this. */
2850 obj->layer->evas->engine.func->image_border_set(output, pixels,
2851 o->cur.border.l, o->cur.border.r,
2852 o->cur.border.t, o->cur.border.b);
2853 idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
2854 idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
2855 if (idw < 1) idw = 1;
2856 if (idh < 1) idh = 1;
2857 if (idx > 0) idx -= idw;
2858 if (idy > 0) idy -= idh;
2859 while ((int)idx < obj->cur.geometry.w)
2866 if ((o->cur.fill.w == obj->cur.geometry.w) &&
2867 (o->cur.fill.x == 0))
2870 iw = obj->cur.geometry.w;
2873 iw = ((int)(idx + idw)) - ix;
2874 while ((int)idy < obj->cur.geometry.h)
2879 if ((o->cur.fill.h == obj->cur.geometry.h) &&
2880 (o->cur.fill.y == 0))
2882 ih = obj->cur.geometry.h;
2886 ih = ((int)(idy + idh)) - iy;
2887 if ((o->cur.border.l == 0) &&
2888 (o->cur.border.r == 0) &&
2889 (o->cur.border.t == 0) &&
2890 (o->cur.border.b == 0) &&
2891 (o->cur.border.fill != 0))
2892 obj->layer->evas->engine.func->image_draw(output,
2899 obj->cur.geometry.x + ix + x,
2900 obj->cur.geometry.y + iy + y,
2902 o->cur.smooth_scale);
2905 int inx, iny, inw, inh, outx, outy, outw, outh;
2906 int bl, br, bt, bb, bsl, bsr, bst, bsb;
2907 int imw, imh, ox, oy;
2909 ox = obj->cur.geometry.x + ix + x;
2910 oy = obj->cur.geometry.y + iy + y;
2913 bl = o->cur.border.l;
2914 br = o->cur.border.r;
2915 bt = o->cur.border.t;
2916 bb = o->cur.border.b;
2922 if ((bl + br) > imw)
2932 if ((bt + bb) > imh)
2937 if (o->cur.border.scale != 1.0)
2939 bsl = ((double)bl * o->cur.border.scale);
2940 bsr = ((double)br * o->cur.border.scale);
2941 bst = ((double)bt * o->cur.border.scale);
2942 bsb = ((double)bb * o->cur.border.scale);
2946 bsl = bl; bsr = br; bst = bt; bsb = bb;
2952 outx = ox; outy = oy;
2953 outw = bsl; outh = bst;
2954 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2958 inw = imw - bl - br; inh = bt;
2959 outx = ox + bsl; outy = oy;
2960 outw = iw - bsl - bsr; outh = bst;
2961 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2964 inx = imw - br; iny = 0;
2966 outx = ox + iw - bsr; outy = oy;
2967 outw = bsr; outh = bst;
2968 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2972 inw = bl; inh = imh - bt - bb;
2973 outx = ox; outy = oy + bst;
2974 outw = bsl; outh = ih - bst - bsb;
2975 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2978 if (o->cur.border.fill > EVAS_BORDER_FILL_NONE)
2981 inw = imw - bl - br; inh = imh - bt - bb;
2982 outx = ox + bsl; outy = oy + bst;
2983 outw = iw - bsl - bsr; outh = ih - bst - bsb;
2984 if ((o->cur.border.fill == EVAS_BORDER_FILL_SOLID) &&
2985 (obj->cur.cache.clip.a == 255) &&
2986 (obj->cur.render_op == EVAS_RENDER_BLEND))
2988 obj->layer->evas->engine.func->context_render_op_set(output, context,
2990 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2991 obj->layer->evas->engine.func->context_render_op_set(output, context,
2992 obj->cur.render_op);
2995 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
2999 inx = imw - br; iny = bt;
3000 inw = br; inh = imh - bt - bb;
3001 outx = ox + iw - bsr; outy = oy + bst;
3002 outw = bsr; outh = ih - bst - bsb;
3003 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3006 inx = 0; iny = imh - bb;
3008 outx = ox; outy = oy + ih - bsb;
3009 outw = bsl; outh = bsb;
3010 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3013 inx = bl; iny = imh - bb;
3014 inw = imw - bl - br; inh = bb;
3015 outx = ox + bsl; outy = oy + ih - bsb;
3016 outw = iw - bsl - bsr; outh = bsb;
3017 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3020 inx = imw - br; iny = imh - bb;
3022 outx = ox + iw - bsr; outy = oy + ih - bsb;
3023 outw = bsr; outh = bsb;
3024 obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale);
3027 if (dobreak_h) break;
3031 if (dobreak_w) break;
3038 evas_object_image_render_pre(Evas_Object *obj)
3040 Evas_Object_Image *o;
3041 int is_v = 0, was_v = 0;
3044 /* dont pre-render the obj twice! */
3045 if (obj->pre_render_done) return;
3046 obj->pre_render_done = 1;
3047 /* pre-render phase. this does anything an object needs to do just before */
3048 /* rendering. this could mean loading the image data, retrieving it from */
3049 /* elsewhere, decoding video etc. */
3050 /* then when this is done the object needs to figure if it changed and */
3051 /* if so what and where and add the appropriate redraw rectangles */
3052 o = (Evas_Object_Image *)(obj->object_data);
3053 e = obj->layer->evas;
3055 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
3057 ERR("%p has invalid fill size: %dx%d. Ignored",
3058 obj, o->cur.fill.w, o->cur.fill.h);
3062 /* if someone is clipping this obj - go calculate the clipper */
3063 if (obj->cur.clipper)
3065 if (obj->cur.cache.clip.dirty)
3066 evas_object_clip_recalc(obj->cur.clipper);
3067 obj->cur.clipper->func->render_pre(obj->cur.clipper);
3069 /* Proxy: Do it early */
3070 if (o->cur.source &&
3071 (o->cur.source->proxy.redraw || o->cur.source->changed))
3073 /* XXX: Do I need to sort out the map here? */
3074 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3078 /* now figure what changed and add draw rects */
3079 /* if it just became visible or invisible */
3080 is_v = evas_object_is_visible(obj);
3081 was_v = evas_object_was_visible(obj);
3084 evas_object_render_pre_visible_change(&e->clip_changes, obj, is_v, was_v);
3085 if (!o->pixel_updates) goto done;
3087 if ((obj->cur.map != obj->prev.map) ||
3088 (obj->cur.usemap != obj->prev.usemap))
3090 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3093 /* it's not visible - we accounted for it appearing or not so just abort */
3094 if (!is_v) goto done;
3095 /* clipper changed this is in addition to anything else for obj */
3096 evas_object_render_pre_clipper_change(&e->clip_changes, obj);
3097 /* if we restacked (layer or just within a layer) and don't clip anyone */
3100 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3101 if (!o->pixel_updates) goto done;
3103 /* if it changed color */
3104 if ((obj->cur.color.r != obj->prev.color.r) ||
3105 (obj->cur.color.g != obj->prev.color.g) ||
3106 (obj->cur.color.b != obj->prev.color.b) ||
3107 (obj->cur.color.a != obj->prev.color.a))
3109 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3110 if (!o->pixel_updates) goto done;
3112 /* if it changed render op */
3113 if (obj->cur.render_op != obj->prev.render_op)
3115 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3116 if (!o->pixel_updates) goto done;
3118 /* if it changed anti_alias */
3119 if (obj->cur.anti_alias != obj->prev.anti_alias)
3121 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3122 if (!o->pixel_updates) goto done;
3126 if (((o->cur.file) && (!o->prev.file)) ||
3127 ((!o->cur.file) && (o->prev.file)) ||
3128 ((o->cur.key) && (!o->prev.key)) ||
3129 ((!o->cur.key) && (o->prev.key))
3132 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3133 if (!o->pixel_updates) goto done;
3135 if ((o->cur.image.w != o->prev.image.w) ||
3136 (o->cur.image.h != o->prev.image.h) ||
3137 (o->cur.has_alpha != o->prev.has_alpha) ||
3138 (o->cur.cspace != o->prev.cspace) ||
3139 (o->cur.smooth_scale != o->prev.smooth_scale))
3141 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3142 if (!o->pixel_updates) goto done;
3144 if ((o->cur.border.l != o->prev.border.l) ||
3145 (o->cur.border.r != o->prev.border.r) ||
3146 (o->cur.border.t != o->prev.border.t) ||
3147 (o->cur.border.b != o->prev.border.b) ||
3148 (o->cur.border.fill != o->prev.border.fill) ||
3149 (o->cur.border.scale != o->prev.border.scale))
3151 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3152 if (!o->pixel_updates) goto done;
3154 if (o->dirty_pixels)
3156 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3157 if (!o->pixel_updates) goto done;
3159 if (o->cur.frame != o->prev.frame)
3161 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3162 if (!o->pixel_updates) goto done;
3166 /* if it changed geometry - and obviously not visibility or color */
3167 /* calculate differences since we have a constant color fill */
3168 /* we really only need to update the differences */
3169 #if 0 // XXX: maybe buggy?
3170 if (((obj->cur.geometry.x != obj->prev.geometry.x) ||
3171 (obj->cur.geometry.y != obj->prev.geometry.y) ||
3172 (obj->cur.geometry.w != obj->prev.geometry.w) ||
3173 (obj->cur.geometry.h != obj->prev.geometry.h)) &&
3174 (o->cur.fill.w == o->prev.fill.w) &&
3175 (o->cur.fill.h == o->prev.fill.h) &&
3176 ((o->cur.fill.x + obj->cur.geometry.x) == (o->prev.fill.x + obj->prev.geometry.x)) &&
3177 ((o->cur.fill.y + obj->cur.geometry.y) == (o->prev.fill.y + obj->prev.geometry.y)) &&
3181 evas_rects_return_difference_rects(&e->clip_changes,
3182 obj->cur.geometry.x,
3183 obj->cur.geometry.y,
3184 obj->cur.geometry.w,
3185 obj->cur.geometry.h,
3186 obj->prev.geometry.x,
3187 obj->prev.geometry.y,
3188 obj->prev.geometry.w,
3189 obj->prev.geometry.h);
3190 if (!o->pixel_updates) goto done;
3193 if (((obj->cur.geometry.x != obj->prev.geometry.x) ||
3194 (obj->cur.geometry.y != obj->prev.geometry.y) ||
3195 (obj->cur.geometry.w != obj->prev.geometry.w) ||
3196 (obj->cur.geometry.h != obj->prev.geometry.h))
3199 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3200 if (!o->pixel_updates) goto done;
3204 if ((o->cur.fill.x != o->prev.fill.x) ||
3205 (o->cur.fill.y != o->prev.fill.y) ||
3206 (o->cur.fill.w != o->prev.fill.w) ||
3207 (o->cur.fill.h != o->prev.fill.h))
3209 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3210 if (!o->pixel_updates) goto done;
3212 if (o->pixel_updates)
3214 if ((o->cur.border.l == 0) &&
3215 (o->cur.border.r == 0) &&
3216 (o->cur.border.t == 0) &&
3217 (o->cur.border.b == 0) &&
3218 (o->cur.image.w > 0) &&
3219 (o->cur.image.h > 0) &&
3220 (!((obj->cur.map) && (obj->cur.usemap))))
3224 EINA_LIST_FREE(o->pixel_updates, rr)
3226 Evas_Coord idw, idh, idx, idy;
3229 e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, rr->x, rr->y, rr->w, rr->h);
3231 idx = evas_object_image_figure_x_fill(obj, o->cur.fill.x, o->cur.fill.w, &idw);
3232 idy = evas_object_image_figure_y_fill(obj, o->cur.fill.y, o->cur.fill.h, &idh);
3234 if (idw < 1) idw = 1;
3235 if (idh < 1) idh = 1;
3236 if (idx > 0) idx -= idw;
3237 if (idy > 0) idy -= idh;
3238 while (idx < obj->cur.geometry.w)
3244 w = ((int)(idx + idw)) - x;
3245 while (idy < obj->cur.geometry.h)
3250 h = ((int)(idy + idh)) - y;
3252 r.x = ((rr->x - 1) * w) / o->cur.image.w;
3253 r.y = ((rr->y - 1) * h) / o->cur.image.h;
3254 r.w = ((rr->w + 2) * w) / o->cur.image.w;
3255 r.h = ((rr->h + 2) * h) / o->cur.image.h;
3256 r.x += obj->cur.geometry.x + x;
3257 r.y += obj->cur.geometry.y + y;
3258 evas_add_rect(&e->clip_changes, r.x, r.y, r.w, r.h);
3264 eina_rectangle_free(rr);
3272 EINA_LIST_FREE(o->pixel_updates, r)
3273 eina_rectangle_free(r);
3274 e->engine.func->image_dirty_region(e->engine.data.output, o->engine_data, 0, 0, o->cur.image.w, o->cur.image.h);
3275 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3280 #if 0 // filtering disabled
3281 if (obj->filter && obj->filter->dirty)
3283 evas_object_render_pre_prev_cur_add(&e->clip_changes, obj);
3286 /* it obviously didn't change - add a NO obscure - this "unupdates" this */
3287 /* area so if there were updates for it they get wiped. don't do it if we */
3288 /* aren't fully opaque and we are visible */
3289 if (evas_object_is_visible(obj) &&
3290 evas_object_is_opaque(obj))
3292 e->engine.func->output_redraws_rect_del(e->engine.data.output,
3293 obj->cur.cache.clip.x,
3294 obj->cur.cache.clip.y,
3295 obj->cur.cache.clip.w,
3296 obj->cur.cache.clip.h);
3299 evas_object_render_pre_effect_updates(&e->clip_changes, obj, is_v, was_v);
3303 evas_object_image_render_post(Evas_Object *obj)
3305 Evas_Object_Image *o;
3308 /* this moves the current data to the previous state parts of the object */
3309 /* in whatever way is safest for the object. also if we don't need object */
3310 /* data anymore we can free it if the object deems this is a good idea */
3311 o = (Evas_Object_Image *)(obj->object_data);
3312 /* remove those pesky changes */
3313 evas_object_clip_changes_clean(obj);
3314 EINA_LIST_FREE(o->pixel_updates, r)
3315 eina_rectangle_free(r);
3316 /* move cur to prev safely for object data */
3317 obj->prev = obj->cur;
3320 /* FIXME: copy strings across */
3323 static unsigned int evas_object_image_id_get(Evas_Object *obj)
3325 Evas_Object_Image *o;
3327 o = (Evas_Object_Image *)(obj->object_data);
3329 return MAGIC_OBJ_IMAGE;
3332 static unsigned int evas_object_image_visual_id_get(Evas_Object *obj)
3334 Evas_Object_Image *o;
3336 o = (Evas_Object_Image *)(obj->object_data);
3338 return MAGIC_OBJ_IMAGE;
3341 static void *evas_object_image_engine_data_get(Evas_Object *obj)
3343 Evas_Object_Image *o;
3345 o = (Evas_Object_Image *)(obj->object_data);
3346 if (!o) return NULL;
3347 return o->engine_data;
3351 evas_object_image_is_opaque(Evas_Object *obj)
3353 Evas_Object_Image *o;
3355 /* this returns 1 if the internal object data implies that the object is */
3356 /* currently fully opaque over the entire rectangle it occupies */
3357 o = (Evas_Object_Image *)(obj->object_data);
3358 if (o->cur.opaque_valid)
3360 if (!o->cur.opaque) return 0;
3365 o->cur.opaque_valid = 1;
3366 if ((o->cur.fill.w < 1) || (o->cur.fill.h < 1))
3368 if (((o->cur.border.l != 0) ||
3369 (o->cur.border.r != 0) ||
3370 (o->cur.border.t != 0) ||
3371 (o->cur.border.b != 0)) &&
3372 (!o->cur.border.fill)) return 0;
3373 if (!o->engine_data) return 0;
3377 if (o->cur.source) return 0; /* FIXME: Should go poke at the object */
3378 if ((obj->cur.map) && (obj->cur.usemap)) return 0;
3379 if (obj->cur.render_op == EVAS_RENDER_COPY) return 1;
3380 if (o->cur.has_alpha) return 0;
3385 evas_object_image_was_opaque(Evas_Object *obj)
3387 Evas_Object_Image *o;
3389 /* this returns 1 if the internal object data implies that the object was */
3390 /* previously fully opaque over the entire rectangle it occupies */
3391 o = (Evas_Object_Image *)(obj->object_data);
3392 if (o->prev.opaque_valid)
3394 if (!o->prev.opaque) return 0;
3399 o->prev.opaque_valid = 1;
3400 if ((o->prev.fill.w < 1) || (o->prev.fill.h < 1))
3402 if (((o->prev.border.l != 0) ||
3403 (o->prev.border.r != 0) ||
3404 (o->prev.border.t != 0) ||
3405 (o->prev.border.b != 0)) &&
3406 (!o->prev.border.fill)) return 0;
3407 if (!o->engine_data) return 0;
3411 if (o->prev.source) return 0; /* FIXME: Should go poke at the object */
3412 if (obj->prev.usemap) return 0;
3413 if (obj->prev.render_op == EVAS_RENDER_COPY) return 1;
3414 if (o->prev.has_alpha) return 0;
3415 if (obj->prev.render_op != EVAS_RENDER_BLEND) return 0;
3420 evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
3422 Evas_Object_Image *o;
3424 int w, h, stride, iw, ih;
3427 o = (Evas_Object_Image *)(obj->object_data);
3429 x -= obj->cur.cache.clip.x;
3430 y -= obj->cur.cache.clip.y;
3431 w = obj->cur.cache.clip.w;
3432 h = obj->cur.cache.clip.h;
3433 iw = o->cur.image.w;
3434 ih = o->cur.image.h;
3436 if ((x < 0) || (y < 0) || (x >= w) || (y >= h)) return 0;
3437 if (!o->cur.has_alpha) return 1;
3439 // FIXME: proxy needs to be honored
3442 x = obj->cur.map->mx;
3443 y = obj->cur.map->my;
3447 int bl, br, bt, bb, bsl, bsr, bst, bsb;
3449 bl = o->cur.border.l;
3450 br = o->cur.border.r;
3451 bt = o->cur.border.t;
3452 bb = o->cur.border.b;
3473 if (o->cur.border.scale != 1.0)
3475 bsl = ((double)bl * o->cur.border.scale);
3476 bsr = ((double)br * o->cur.border.scale);
3477 bst = ((double)bt * o->cur.border.scale);
3478 bsb = ((double)bb * o->cur.border.scale);
3482 bsl = bl; bsr = br; bst = bt; bsb = bb;
3495 if (o->cur.border.fill != EVAS_BORDER_FILL_DEFAULT)
3497 if ((x > bsl) && (x < (w - bsr)) &&
3498 (y > bst) && (y < (h - bsb)))
3500 if (o->cur.border.fill == EVAS_BORDER_FILL_SOLID) return 1;
3505 if (x < bsl) x = (x * bl) / bsl;
3506 else if (x > (w - bsr)) x = iw - (((w - x) * br) / bsr);
3507 else if ((bsl + bsr) < w) x = bl + (((x - bsl) * (iw - bl - br)) / (w - bsl - bsr));
3510 if (y < bst) y = (y * bt) / bst;
3511 else if (y > (h - bsb)) y = ih - (((h - y) * bb) / bsb);
3512 else if ((bst + bsb) < h) y = bt + (((y - bst) * (ih - bt - bb)) / (h - bst - bsb));
3518 if (x >= iw) x = iw - 1;
3519 if (y >= ih) y = ih - 1;
3521 stride = o->cur.image.stride;
3523 o->engine_data = obj->layer->evas->engine.func->image_data_get
3524 (obj->layer->evas->engine.data.output,
3532 switch (o->cur.cspace)
3534 case EVAS_COLORSPACE_ARGB8888:
3535 data = ((DATA32*)(data) + ((y * (stride >> 2)) + x));
3536 a = (*((DATA32*)(data)) >> 24) & 0xff;
3538 case EVAS_COLORSPACE_RGB565_A5P:
3539 data = (void*) ((DATA16*)(data) + (h * (stride >> 1)));
3540 data = (void*) ((DATA8*)(data) + ((y * (stride >> 1)) + x));
3541 a = (*((DATA8*)(data))) & 0x1f;
3552 evas_object_image_has_opaque_rect(Evas_Object *obj)
3554 Evas_Object_Image *o;
3556 o = (Evas_Object_Image *)(obj->object_data);
3557 if ((obj->cur.map) && (obj->cur.usemap)) return 0;
3558 if (((o->cur.border.l | o->cur.border.r | o->cur.border.t | o->cur.border.b) != 0) &&
3559 (o->cur.border.fill == EVAS_BORDER_FILL_SOLID) &&
3560 (obj->cur.render_op == EVAS_RENDER_BLEND) &&
3561 (obj->cur.cache.clip.a == 255) &&
3562 (o->cur.fill.x == 0) &&
3563 (o->cur.fill.y == 0) &&
3564 (o->cur.fill.w == obj->cur.geometry.w) &&
3565 (o->cur.fill.h == obj->cur.geometry.h)
3571 evas_object_image_get_opaque_rect(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3573 Evas_Object_Image *o;
3575 o = (Evas_Object_Image *)(obj->object_data);
3576 if (o->cur.border.scale == 1.0)
3578 *x = obj->cur.geometry.x + o->cur.border.l;
3579 *y = obj->cur.geometry.y + o->cur.border.t;
3580 *w = obj->cur.geometry.w - (o->cur.border.l + o->cur.border.r);
3582 *h = obj->cur.geometry.h - (o->cur.border.t + o->cur.border.b);
3587 *x = obj->cur.geometry.x + (o->cur.border.l * o->cur.border.scale);
3588 *y = obj->cur.geometry.y + (o->cur.border.t * o->cur.border.scale);
3589 *w = obj->cur.geometry.w - ((o->cur.border.l * o->cur.border.scale) + (o->cur.border.r * o->cur.border.scale));
3591 *h = obj->cur.geometry.h - ((o->cur.border.t * o->cur.border.scale) + (o->cur.border.b * o->cur.border.scale));
3598 evas_object_image_can_map(Evas_Object *obj __UNUSED__)
3604 evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace)
3611 switch (o->cur.cspace)
3613 case EVAS_COLORSPACE_ARGB8888:
3614 out = evas_common_convert_argb8888_to(data,
3617 o->cur.image.stride >> 2,
3621 case EVAS_COLORSPACE_RGB565_A5P:
3622 out = evas_common_convert_rgb565_a5p_to(data,
3625 o->cur.image.stride >> 1,
3637 evas_object_image_filled_resize_listener(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *einfo __UNUSED__)
3640 Evas_Object_Image *o;
3642 o = obj->object_data;
3643 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
3644 evas_object_image_fill_set(obj, 0, 0, w, h);
3649 _evas_object_image_preloading_get(const Evas_Object *obj)
3651 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3652 if (!o) return EINA_FALSE;
3653 MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
3656 return o->preloading;
3660 _evas_object_image_preloading_set(Evas_Object *obj, Eina_Bool preloading)
3662 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3663 o->preloading = preloading;
3667 _evas_object_image_preloading_check(Evas_Object *obj)
3669 Evas_Object_Image *o = (Evas_Object_Image *)(obj->object_data);
3670 if (obj->layer->evas->engine.func->image_load_error_get)
3671 o->load_error = obj->layer->evas->engine.func->image_load_error_get
3672 (obj->layer->evas->engine.data.output, o->engine_data);
3675 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/