2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
9 # include "config.h" /* so that EAPI in Evas.h is correctly defined */
14 /*****************************************************************************/
16 #include "evas_options.h"
25 # define LK(x) pthread_mutex_t x
26 # define LKI(x) pthread_mutex_init(&(x), NULL);
27 # define LKD(x) pthread_mutex_destroy(&(x));
28 # define LKL(x) pthread_mutex_lock(&(x));
29 # define LKU(x) pthread_mutex_unlock(&(x));
30 # define TH(x) pthread_t x
34 // even though in theory having every Nth rendered line done by a different
35 // thread might even out load across threads - it actually slows things down.
54 #include <sys/types.h>
63 #elif defined __GNUC__
64 # define alloca __builtin_alloca
66 # define alloca __alloca
67 #elif defined _MSC_VER
69 # define alloca _alloca
75 void *alloca (size_t);
79 #include FT_FREETYPE_H
86 // BROKEN in gcc 4 on amd64
87 //# pragma GCC visibility push(hidden)
89 #define LIKELY(x) __builtin_expect(!!(x), 1)
90 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
93 #define UNLIKELY(x) (x)
96 /*****************************************************************************/
98 /* use exact rects for updates not tiles */
99 /* #define RECTUPDATE */
102 #ifdef BUILD_SMALL_DITHER_MASK
103 # define DM_TABLE _evas_dither_44
107 # define USE_DITHER_44 1
108 # define DM_MSK (DM_SIZE - 1)
109 # define DM_SHF(_b) (DM_BITS - (8 - _b))
111 # define DM_TABLE _evas_dither_128128
115 # define USE_DITHER_128128 1
116 # define DM_MSK (DM_SIZE - 1)
117 # define DM_SHF(_b) (DM_BITS - (8 - _b))
120 /* if more than 1/ALPHA_SPARSE_INV_FRACTION is "alpha" (1-254) then sparse
121 * alpha flag gets set */
122 #define ALPHA_SPARSE_INV_FRACTION 3
124 /*****************************************************************************/
126 /*****************************************************************************/
128 typedef unsigned long long DATA64;
129 typedef unsigned int DATA32;
130 typedef unsigned short DATA16;
131 typedef unsigned char DATA8;
133 typedef struct _Image_Entry Image_Entry;
134 typedef struct _Image_Entry_Flags Image_Entry_Flags;
135 typedef struct _Engine_Image_Entry Engine_Image_Entry;
137 typedef struct _RGBA_Image_Loadopts RGBA_Image_Loadopts;
138 typedef struct _RGBA_Pipe_Op RGBA_Pipe_Op;
139 typedef struct _RGBA_Pipe RGBA_Pipe;
140 typedef struct _RGBA_Pipe_Thread_Info RGBA_Pipe_Thread_Info;
141 typedef struct _RGBA_Image RGBA_Image;
142 typedef struct _RGBA_Image_Span RGBA_Image_Span;
143 typedef struct _RGBA_Draw_Context RGBA_Draw_Context;
144 typedef struct _RGBA_Gradient RGBA_Gradient;
145 typedef struct _RGBA_Gradient_Color_Stop RGBA_Gradient_Color_Stop;
146 typedef struct _RGBA_Gradient_Alpha_Stop RGBA_Gradient_Alpha_Stop;
147 typedef struct _RGBA_Gradient_Type RGBA_Gradient_Type;
148 typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point;
149 typedef struct _RGBA_Font RGBA_Font;
150 typedef struct _RGBA_Font_Int RGBA_Font_Int;
151 typedef struct _RGBA_Font_Source RGBA_Font_Source;
152 typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
153 typedef struct _RGBA_Gfx_Compositor RGBA_Gfx_Compositor;
155 typedef struct _Cutout_Rect Cutout_Rect;
156 typedef struct _Cutout_Rects Cutout_Rects;
158 typedef struct _Convert_Pal Convert_Pal;
160 typedef struct _Tilebuf Tilebuf;
161 typedef struct _Tilebuf_Tile Tilebuf_Tile;
162 typedef struct _Tilebuf_Rect Tilebuf_Rect;
165 typedef struct _Regionbuf Regionbuf;
166 typedef struct _Regionspan Regionspan;
169 typedef void (*RGBA_Gfx_Func) (DATA32 *src, DATA8 *mask, DATA32 col, DATA32 *dst, int len);
170 typedef void (*RGBA_Gfx_Pt_Func) (DATA32 src, DATA8 mask, DATA32 col, DATA32 *dst);
171 typedef void (*Gfx_Func_Copy) (DATA32 *src, DATA32 *dst, int len);
173 typedef void (*Gfx_Func_Convert) (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal);
175 typedef void (*Gfx_Func_Gradient_Fill)(DATA32 *src, int src_len,
176 DATA32 *dst, DATA8 *mask, int len,
177 int x, int y, int axx, int axy, int ayx, int ayy,
180 #include "../cache/evas_cache.h"
182 /*****************************************************************************/
184 typedef enum _RGBA_Image_Flags
186 RGBA_IMAGE_NOTHING = (0),
187 /* RGBA_IMAGE_HAS_ALPHA = (1 << 0), */
188 RGBA_IMAGE_IS_DIRTY = (1 << 1),
189 RGBA_IMAGE_INDEXED = (1 << 2),
190 RGBA_IMAGE_ALPHA_ONLY = (1 << 3),
191 RGBA_IMAGE_ALPHA_TILES = (1 << 4),
192 /* RGBA_IMAGE_ALPHA_SPARSE = (1 << 5), */
193 /* RGBA_IMAGE_LOADED = (1 << 6), */
194 /* RGBA_IMAGE_NEED_DATA = (1 << 7) */
197 typedef enum _Convert_Pal_Mode
215 typedef enum _CPU_Features
218 CPU_FEATURE_MMX = (1 << 0),
219 CPU_FEATURE_MMX2 = (1 << 1),
220 CPU_FEATURE_SSE = (1 << 2),
221 CPU_FEATURE_ALTIVEC = (1 << 3),
222 CPU_FEATURE_VIS = (1 << 4),
223 CPU_FEATURE_VIS2 = (1 << 5)
226 typedef enum _Font_Hint_Flags
233 /*****************************************************************************/
235 struct _RGBA_Image_Loadopts
237 int scale_down_by; // if > 1 then use this
238 double dpi; // if > 0.0 use this
239 int w, h; // if > 0 use this
242 struct _Image_Entry_Flags
244 Evas_Bool loaded : 1;
247 Evas_Bool need_data : 1;
248 Evas_Bool lru_nodata : 1;
249 Evas_Bool cached : 1;
251 Evas_Bool alpha_sparse : 1;
256 Evas_Object_List _list_data;
258 Evas_Cache_Image *cache;
260 const char *cache_key;
272 RGBA_Image_Loadopts load_opts;
289 Image_Entry_Flags flags;
292 struct _Engine_Image_Entry
294 Evas_Object_List _list_data;
296 /* Upper Engine data. */
300 Evas_Cache_Engine_Image *cache;
301 const char *cache_key;
305 Evas_Bool cached : 1;
308 Evas_Bool loaded : 1;
309 Evas_Bool need_parent : 1;
329 struct _RGBA_Draw_Context
338 struct RGBA_Draw_Context_clip {
345 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg);
346 void (*gl_free) (void *ext_dat);
347 void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y);
358 Evas_Bool anti_alias : 1;
363 RGBA_Draw_Context context;
364 void (*op_func) (RGBA_Image *dst, RGBA_Pipe_Op *op, RGBA_Pipe_Thread_Info *info);
365 void (*free_func) (RGBA_Pipe_Op *op);
375 RGBA_Polygon_Point *points;
388 int sx, sy, sw, sh, dx, dy, dw, dh;
399 Evas_Object_List _list_data;
401 RGBA_Pipe_Op op[PIPE_LEN];
404 struct _RGBA_Pipe_Thread_Info
412 Image_Entry cache_entry;
414 RGBA_Image_Flags flags;
419 /* char *real_file; */
428 /* unsigned char scale; */
430 /* Colorspace stuff. */
433 Evas_Bool no_free : 1;
441 Evas_Bool no_free : 1;
445 struct _RGBA_Gradient_Color_Stop
447 Evas_Object_List _list_data;
452 struct _RGBA_Gradient_Alpha_Stop
454 Evas_Object_List _list_data;
459 struct _RGBA_Gradient
468 Evas_Bool has_alpha : 1;
472 Evas_Object_List *stops;
478 Evas_Object_List *stops;
494 RGBA_Gradient_Type *geometer;
500 Evas_Bool imported_data : 1;
501 Evas_Bool has_alpha : 1;
504 struct _RGBA_Gradient_Type
508 void (*shutdown)(void);
509 void (*geom_init)(RGBA_Gradient *gr);
510 void (*geom_set)(RGBA_Gradient *gr);
511 void (*geom_free)(void *gdata);
512 int (*has_alpha)(RGBA_Gradient *gr, int render_op);
513 int (*has_mask)(RGBA_Gradient *gr, int render_op);
514 int (*get_map_len)(RGBA_Gradient *gr);
515 Gfx_Func_Gradient_Fill (*get_fill_func)(RGBA_Gradient *gr, int render_op, unsigned char aa);
518 struct _RGBA_Polygon_Point
520 Evas_Object_List _list_data;
527 Font_Hint_Flags hinting;
532 struct _RGBA_Font_Int
534 Evas_Object_List _list_data;
536 RGBA_Font_Source *src;
548 Font_Hint_Flags hinting;
553 struct _RGBA_Font_Source
555 Evas_Object_List _list_data;
563 Evas_Array_Hash *charmap;
573 struct _RGBA_Font_Glyph
576 FT_BitmapGlyph glyph_out;
577 /* this is a problem - only 1 engine at a time can extend such a font... grrr */
579 void (*ext_dat_free) (void *ext_dat);
582 struct _RGBA_Gfx_Compositor
587 void (*shutdown)(void);
589 RGBA_Gfx_Func (*composite_pixel_span_get)(RGBA_Image *src, RGBA_Image *dst, int pixels);
590 RGBA_Gfx_Func (*composite_color_span_get)(DATA32 col, RGBA_Image *dst, int pixels);
591 RGBA_Gfx_Func (*composite_pixel_color_span_get)(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels);
592 RGBA_Gfx_Func (*composite_mask_color_span_get)(DATA32 col, RGBA_Image *dst, int pixels);
593 RGBA_Gfx_Func (*composite_pixel_mask_span_get)(RGBA_Image *src, RGBA_Image *dst, int pixels);
595 RGBA_Gfx_Pt_Func (*composite_pixel_pt_get)(Image_Entry_Flags src_flags, RGBA_Image *dst);
596 RGBA_Gfx_Pt_Func (*composite_color_pt_get)(DATA32 col, RGBA_Image *dst);
597 RGBA_Gfx_Pt_Func (*composite_pixel_color_pt_get)(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst);
598 RGBA_Gfx_Pt_Func (*composite_mask_color_pt_get)(DATA32 col, RGBA_Image *dst);
599 RGBA_Gfx_Pt_Func (*composite_pixel_mask_pt_get)(Image_Entry_Flags src_flags, RGBA_Image *dst);
602 #define EVAS_RECT_SPLIT 1
603 #ifdef EVAS_RECT_SPLIT
604 typedef struct list_node list_node_t;
605 typedef struct list list_t;
606 typedef struct rect rect_t;
607 typedef struct rect_node rect_node_t;
611 struct list_node *next;
616 struct list_node *head;
617 struct list_node *tail;
633 struct list_node _lst;
637 void rect_list_node_pool_set_max(int max);
638 void rect_list_node_pool_flush(void);
639 list_node_t *rect_list_node_pool_get(void);
640 void rect_list_node_pool_put(list_node_t *node);
642 void rect_init(rect_t *r, int x, int y, int w, int h);
643 void rect_list_append_node(list_t *rects, list_node_t *node);
644 void rect_list_append(list_t *rects, const rect_t r);
645 void rect_list_append_xywh(list_t *rects, int x, int y, int w, int h);
646 void rect_list_concat(list_t *rects, list_t *other);
647 list_node_t *rect_list_unlink_next(list_t *rects, list_node_t *parent_node);
648 void rect_list_del_next(list_t *rects, list_node_t *parent_node);
649 void rect_list_clear(list_t *rects);
650 void rect_list_del_split_strict(list_t *rects, const rect_t del_r);
651 void rect_list_add_split_strict(list_t *rects, list_node_t *node);
652 list_node_t *rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error);
653 void rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error);void rect_list_add_split_fuzzy_and_merge(list_t *rects, list_node_t *node, int split_accepted_error, int merge_accepted_error);
655 void rect_print(const rect_t r);
656 void rect_list_print(const list_t rects);
657 #endif /* EVAS_RECT_SPLIT */
670 #elif defined(EVAS_RECT_SPLIT)
683 Evas_Bool redraw : 1;
684 /* FIXME: need these flags later - but not now */
698 Evas_Object_List _list_data;
710 Evas_Object_List _list_data;
719 Convert_Pal_Mode colors;
726 /*****************************************************************************/
727 #include "evas_macros.h"
729 #ifndef WORDS_BIGENDIAN
731 #define A_VAL(p) ((DATA8 *)(p))[3]
732 #define R_VAL(p) ((DATA8 *)(p))[2]
733 #define G_VAL(p) ((DATA8 *)(p))[1]
734 #define B_VAL(p) ((DATA8 *)(p))[0]
735 #define AR_VAL(p) ((DATA16 *)(p)[1])
736 #define GB_VAL(p) ((DATA16 *)(p)[0])
739 #define A_VAL(p) ((DATA8 *)(p))[0]
740 #define R_VAL(p) ((DATA8 *)(p))[1]
741 #define G_VAL(p) ((DATA8 *)(p))[2]
742 #define B_VAL(p) ((DATA8 *)(p))[3]
743 #define AR_VAL(p) ((DATA16 *)(p)[0])
744 #define GB_VAL(p) ((DATA16 *)(p)[1])
747 #define RGB_JOIN(r,g,b) \
748 (((r) << 16) + ((g) << 8) + (b))
750 #define ARGB_JOIN(a,r,g,b) \
751 (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
753 #include "evas_blend_ops.h"
755 #define _EVAS_RENDER_FILL -1
756 #define _EVAS_RENDER_BLEND 0
757 #define _EVAS_RENDER_BLEND_REL 1
758 #define _EVAS_RENDER_COPY 2
759 #define _EVAS_RENDER_COPY_REL 3
760 #define _EVAS_RENDER_ADD 4
761 #define _EVAS_RENDER_ADD_REL 5
762 #define _EVAS_RENDER_SUB 6
763 #define _EVAS_RENDER_SUB_REL 7
764 #define _EVAS_RENDER_TINT 8
765 #define _EVAS_RENDER_TINT_REL 9
766 #define _EVAS_RENDER_MASK 10
767 #define _EVAS_RENDER_MUL 11
768 #define _EVAS_RENDER_CLIP 12
770 #define _EVAS_TEXTURE_REFLECT 0
771 #define _EVAS_TEXTURE_REPEAT 1
772 #define _EVAS_TEXTURE_RESTRICT 2
773 #define _EVAS_TEXTURE_RESTRICT_REFLECT 3
774 #define _EVAS_TEXTURE_RESTRICT_REPEAT 4
775 #define _EVAS_TEXTURE_PAD 5
777 #define _EVAS_COLOR_SPACE_ARGB 0
778 #define _EVAS_COLOR_SPACE_AHSV 1
780 /*****************************************************************************/
787 void evas_common_init (void);
788 void evas_common_shutdown (void);
790 EAPI void evas_common_cpu_init (void);
792 int evas_common_cpu_have_cpuid (void);
793 int evas_common_cpu_has_feature (unsigned int feature);
794 EAPI void evas_common_cpu_can_do (int *mmx, int *sse, int *sse2);
795 EAPI void evas_common_cpu_end_opt (void);
796 EAPI int evas_common_cpu_count (void);
799 #include "../engines/common/evas_blend.h"
801 EAPI Gfx_Func_Copy evas_common_draw_func_copy_get (int pixels, int reverse);
804 #include "../engines/common/evas_convert_color.h"
805 #include "../engines/common/evas_convert_colorspace.h"
806 #include "../engines/common/evas_convert_main.h"
807 #include "../engines/common/evas_convert_yuv.h"
808 #include "../engines/common/evas_scale_main.h"
809 #include "../engines/common/evas_scale_smooth.h"
810 #include "../engines/common/evas_scale_span.h"
813 #include "../engines/common/evas_image.h"
816 #include "../engines/common/evas_line.h"
817 #include "../engines/common/evas_polygon.h"
818 #include "../engines/common/evas_rectangle.h"
821 EAPI void evas_common_blit_init (void);
823 EAPI void evas_common_blit_rectangle (const RGBA_Image *src, RGBA_Image *dst, int src_x, int src_y, int w, int h, int dst_x, int dst_y);
826 #include "../engines/common/evas_gradient.h"
827 #include "../engines/common/evas_font.h"
830 EAPI void evas_common_tilebuf_init (void);
832 EAPI Tilebuf *evas_common_tilebuf_new (int w, int h);
833 EAPI void evas_common_tilebuf_free (Tilebuf *tb);
834 EAPI void evas_common_tilebuf_set_tile_size (Tilebuf *tb, int tw, int th);
835 EAPI void evas_common_tilebuf_get_tile_size (Tilebuf *tb, int *tw, int *th);
836 EAPI int evas_common_tilebuf_add_redraw (Tilebuf *tb, int x, int y, int w, int h);
837 EAPI int evas_common_tilebuf_del_redraw (Tilebuf *tb, int x, int y, int w, int h);
838 EAPI int evas_common_tilebuf_add_motion_vector (Tilebuf *tb, int x, int y, int w, int h, int dx, int dy, int alpha);
839 EAPI void evas_common_tilebuf_clear (Tilebuf *tb);
840 EAPI Tilebuf_Rect *evas_common_tilebuf_get_render_rects (Tilebuf *tb);
841 EAPI void evas_common_tilebuf_free_render_rects (Tilebuf_Rect *rects);
844 Regionbuf *evas_common_regionbuf_new (int w, int h);
845 void evas_common_regionbuf_free (Regionbuf *rb);
846 void evas_common_regionbuf_clear (Regionbuf *rb);
847 void evas_common_regionbuf_span_add (Regionbuf *rb, int x1, int x2, int y);
848 void evas_common_regionbuf_span_del (Regionbuf *rb, int x1, int x2, int y);
849 Tilebuf_Rect *evas_common_regionbuf_rects_get (Regionbuf *rb);
853 #include "../engines/common/evas_draw.h"
856 #include "../engines/common/evas_pipe.h"
858 void evas_font_dir_cache_free(void);
862 /*****************************************************************************/