1 #ifndef EVAS_IMAGE_PRIVATE_H 2 #define EVAS_IMAGE_PRIVATE_H 3 4 /* Those functions are shared between legacy evas_object_image.c and the 5 * new efl_canvas classes (image, snapshot, proxy, ...) 6 */ 7 8 #define EFL_CANVAS_FILTER_INTERNAL_PROTECTED 9 #define EFL_CANVAS_OBJECT_PROTECTED 10 11 #include "evas_common_private.h" 12 13 #include <sys/types.h> 14 #include <unistd.h> 15 #include <math.h> 16 17 #include "evas_private.h" 18 #include "../common/evas_convert_color.h" 19 #include "../common/evas_convert_colorspace.h" 20 #include "../common/evas_convert_yuv.h" 21 22 #include "canvas/evas_image_eo.h" 23 #include "canvas/efl_canvas_filter_internal.eo.h" 24 #include "evas_filter.h" 25 26 /* private struct for rectangle object internal data */ 27 typedef struct _Evas_Image_Data Evas_Image_Data; 28 typedef struct _Evas_Image_Map Evas_Image_Map; 29 typedef struct _Evas_Object_Image_Load_Opts Evas_Object_Image_Load_Opts; 30 typedef struct _Evas_Object_Image_Pixels Evas_Object_Image_Pixels; 31 typedef struct _Evas_Object_Image_State Evas_Object_Image_State; 32 33 struct _Evas_Object_Image_Load_Opts 34 { 35 unsigned char scale_down_by; 36 double dpi; 37 short w, h; 38 struct { 39 short x, y, w, h; 40 } region; 41 struct { 42 int src_x, src_y, src_w, src_h; 43 int dst_w, dst_h; 44 int smooth; 45 int scale_hint; 46 } scale_load; 47 Eina_Bool orientation : 1; 48 }; 49 50 struct _Evas_Object_Image_Pixels 51 { 52 Eina_List *pixel_updates; 53 struct { 54 /* FIXME: no good match for eo */ 55 Evas_Object_Image_Pixels_Get_Cb get_pixels; 56 void *get_pixels_data; 57 } func; 58 Eina_Hash *images_to_free; /* pixel void* -> Evas_Image_Legacy_Pixels_Entry */ 59 60 Evas_Video_Surface video; 61 unsigned int video_caps; 62 }; 63 64 struct _Evas_Object_Image_State 65 { 66 Eina_Rectangle fill; 67 struct { 68 short w, h, stride; 69 } image; 70 struct { 71 double scale; 72 short l, r, t, b; 73 unsigned char fill; 74 } border; 75 struct { 76 struct { 77 uint8_t *region; 78 uint32_t stretchable; 79 uint32_t total; 80 } horizontal, vertical; 81 } stretch; 82 83 Evas_Object *source; 84 Evas_Map *defmap; 85 86 Eina_File *f; 87 const char *key; 88 int frame; 89 90 Evas_Colorspace cspace; 91 Evas_Image_Orient orient; 92 93 Eina_Bool smooth_scale : 1; 94 Eina_Bool has_alpha :1; 95 Eina_Bool opaque_valid : 1; 96 Eina_Bool opaque : 1; 97 98 Eina_Bool free_stretch : 1; // Should we free stretch region? 99 Eina_Bool stretch_loaded : 1; // Is the stretch region loaded from file? 100 }; 101 102 #define EVAS_IMAGE_PRELOAD_NONE 0x00 103 #define EVAS_IMAGE_PRELOADING 0x01 104 #define EVAS_IMAGE_PRELOADED 0x04 105 #define EVAS_IMAGE_PRELOAD_CANCEL 0x08 106 107 struct _Evas_Image_Data 108 { 109 const Evas_Object_Image_State *cur; 110 const Evas_Object_Image_State *prev; 111 const Evas_Object_Image_Load_Opts *load_opts; 112 const Evas_Object_Image_Pixels *pixels; 113 114 void *engine_data; 115 void *engine_data_prep; 116 117 void *plane; 118 119 int pixels_checked_out; 120 Eina_Error load_error; /* Efl.Gfx.Image.Load_Error */ 121 122 Efl_Gfx_Image_Scale_Hint scale_hint; 123 Efl_Gfx_Image_Content_Hint content_hint; 124 Efl_Gfx_Image_Orientation orient_value; 125 126 struct { 127 short w, h; 128 } file_size; 129 130 unsigned char preload; //See above EVAS_IMAGE_PRELOAD*** 131 132 Eina_Bool changed : 1; 133 Eina_Bool dirty_pixels : 1; 134 Eina_Bool filled : 1; 135 Eina_Bool filled_set : 1; 136 Eina_Bool proxyrendering : 1; 137 Eina_Bool video_surface : 1; 138 Eina_Bool video_visible : 1; 139 Eina_Bool created : 1; 140 Eina_Bool proxyerror : 1; 141 Eina_Bool proxy_src_clip : 1; 142 Eina_Bool written : 1; 143 Eina_Bool direct_render : 1; 144 Eina_Bool has_filter : 1; 145 Eina_Bool changed_filter : 1; 146 Eina_Bool buffer_data_set : 1; 147 struct 148 { 149 Eina_Bool video_move : 1; 150 Eina_Bool video_resize : 1; 151 Eina_Bool video_show : 1; 152 Eina_Bool video_hide : 1; 153 } delayed; 154 Eina_Bool legacy_type : 1; 155 Eina_Bool skip_head : 1; 156 Eina_Bool can_scanout : 1; 157 Eina_Bool plane_status : 1; 158 }; 159 160 /* shared functions between legacy and new eo classes */ 161 void _evas_image_init_set(const Eina_File *f, const char *key, Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Image_Load_Opts *lo); 162 void _evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); 163 void _evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); 164 void *_evas_image_pixels_get(Eo *eo_obj, Evas_Object_Protected_Data *obj, void *engine, void *output, void *context, void *surface, int x, int y, int *imagew, int *imageh, int *uvw, int *uvh, Eina_Bool filtered, Eina_Bool needs_post_render); 165 166 /* Efl.Gfx.Fill */ 167 void _evas_image_fill_set(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w, int h); 168 169 /* Efl.File */ 170 Eina_Bool _evas_image_file_load(Eo *eo_obj, Evas_Image_Data *o); 171 void _evas_image_file_unload(Eo *eo_obj); 172 const Eina_File *_evas_image_mmap_get(const Eo *eo_obj); 173 const char *_evas_image_key_get(const Eo *eo_obj); 174 void _efl_canvas_image_load_error_set(Eo *eo_obj EINA_UNUSED, Eina_Error err); 175 176 /* Efl.Image.Load */ 177 void _evas_image_load_post_update(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj); 178 void _evas_image_load_async_start(Eo *eo_obj); 179 void _evas_image_load_async_cancel(Eo *eo_obj); 180 void _evas_image_load_dpi_set(Eo *eo_obj, double dpi); 181 double _evas_image_load_dpi_get(const Eo *eo_obj); 182 void _evas_image_load_size_set(Eo *eo_obj, int w, int h); 183 void _evas_image_load_size_get(const Eo *eo_obj, int *w, int *h); 184 void _evas_image_load_scale_down_set(Eo *eo_obj, int scale_down); 185 int _evas_image_load_scale_down_get(const Eo *eo_obj); 186 void _evas_image_load_region_set(Eo *eo_obj, int x, int y, int w, int h); 187 void _evas_image_load_region_get(const Eo *eo_obj, int *x, int *y, int *w, int *h); 188 void _evas_image_load_head_skip_set(const Eo *eo_obj, Eina_Bool skip); 189 Eina_Bool _evas_image_load_head_skip_get(const Eo *eo_obj); 190 void _evas_image_load_orientation_set(Eo *eo_obj, Eina_Bool enable); 191 Eina_Bool _evas_image_load_orientation_get(const Eo *eo_obj); 192 Eina_Bool _evas_image_load_region_support_get(const Eo *eo_obj); 193 void _evas_image_orientation_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Image_Orient orient); 194 195 /* Efl.Image_Animation_Controller */ 196 Eina_Bool _evas_image_animated_get(const Eo *eo_obj); 197 int _evas_image_animated_frame_count_get(const Eo *eo_obj); 198 Efl_Gfx_Frame_Controller_Loop_Hint _evas_image_animated_loop_type_get(const Eo *eo_obj); 199 int _evas_image_animated_loop_count_get(const Eo *eo_obj); 200 double _evas_image_animated_frame_duration_get(const Eo *eo_obj, int start_frame, int frame_num); 201 Eina_Bool _evas_image_animated_frame_set(Eo *eo_obj, int frame_index); 202 int _evas_image_animated_frame_get(const Eo *eo_obj); 203 204 /* Efl.Canvas.Proxy */ 205 void _evas_image_proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); 206 void _evas_image_proxy_set(Evas_Object *proxy, Evas_Object *src); 207 void _evas_image_proxy_error(Evas_Object *proxy, void *engine, void *output, void *context, void *surface, int x, int y, Eina_Bool do_async); 208 Eina_Bool _evas_image_proxy_source_set(Eo *eo_obj, Evas_Object *eo_src); 209 Evas_Object *_evas_image_proxy_source_get(const Eo *eo_obj); 210 void _evas_image_proxy_source_clip_set(Eo *eo_obj, Eina_Bool source_clip); 211 Eina_Bool _evas_image_proxy_source_clip_get(const Eo *eo_obj); 212 void _evas_image_proxy_source_events_set(Eo *eo_obj, Eina_Bool source_events); 213 Eina_Bool _evas_image_proxy_source_events_get(const Eo *eo_obj); 214 215 /* Efl.Canvas.Surface */ 216 Eina_Bool _evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface *surf); 217 Evas_Native_Surface *_evas_image_native_surface_get(const Evas_Object *eo_obj); 218 219 /* deprecated but in use */ 220 void *_evas_image_data_convert_internal(Evas_Image_Data *o, void *data, Evas_Colorspace to_cspace); 221 void _evas_image_unload(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool dirty); 222 void _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); 223 224 # define EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, Write) \ 225 EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, Obj->cur, Evas_Object_Image_State, Write) 226 227 # define EINA_COW_IMAGE_STATE_WRITE_END(Obj, Write) \ 228 eina_cow_done(evas_object_image_state_cow, ((const Eina_Cow_Data**)&(Obj->cur)), Write, \ 229 Obj->content_hint == EFL_GFX_IMAGE_CONTENT_HINT_DYNAMIC ? EINA_FALSE : EINA_TRUE); \ 230 } \ 231 while (0); 232 233 # define EINA_COW_PIXEL_WRITE_BEGIN(Obj, Write) \ 234 EINA_COW_WRITE_BEGIN(evas_object_image_pixels_cow, Obj->pixels, Evas_Object_Image_Pixels, Write) 235 236 # define EINA_COW_PIXEL_WRITE_END(Obj, Write) \ 237 EINA_COW_WRITE_END(evas_object_image_pixels_cow, Obj->pixels, Write) 238 239 # define EINA_COW_LOAD_OPTS_WRITE_BEGIN(Obj, Write) \ 240 EINA_COW_WRITE_BEGIN(evas_object_image_load_opts_cow, Obj->load_opts, Evas_Object_Image_Load_Opts, Write) 241 242 # define EINA_COW_LOAD_OPTS_WRITE_END(Obj, Write) \ 243 EINA_COW_WRITE_END(evas_object_image_load_opts_cow, Obj->load_opts, Write) 244 245 # define EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(Obj) \ 246 if (Obj->cur->key) \ 247 { \ 248 EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, cur_write) \ 249 { \ 250 EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, Obj->prev, Evas_Object_Image_State, prev_write) \ 251 EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(cur_write, prev_write); \ 252 EINA_COW_WRITE_END(evas_object_image_state_cow, Obj->prev, prev_write); \ 253 } \ 254 EINA_COW_IMAGE_STATE_WRITE_END(Obj, cur_write); \ 255 } 256 257 #define FRAME_MAX 1024 258 259 #endif // EVAS_IMAGE_PRIVATE_H 260