* evas: Cleanup move to eina log.
[profile/ivi/evas.git] / src / lib / include / evas_common.h
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifndef EVAS_COMMON_H
6 #define EVAS_COMMON_H
7
8 #ifdef HAVE_CONFIG_H
9 # include "config.h"  /* so that EAPI in Evas.h is correctly defined */
10 #endif
11
12 #include <Eina.h>
13 #include "Evas.h"
14
15 /* macros needed to log message through eina_log */
16 extern EAPI int _evas_log_dom_global;
17 #ifdef  _EVAS_DEFAULT_LOG_DOM
18 # undef _EVAS_DEFAULT_LOG_DOM
19 #endif
20 #define _EVAS_DEFAULT_LOG_DOM _evas_log_dom_global
21
22 #ifdef EVAS_DEFAULT_LOG_COLOR
23 # undef EVAS_DEFAULT_LOG_COLOR
24 #endif
25 #define EVAS_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
26
27 #ifdef ERR
28 # undef ERR
29 #endif
30 #define ERR(...) EINA_LOG_DOM_ERR(_EVAS_DEFAULT_LOG_DOM, __VA_ARGS__)
31
32 #ifdef DBG
33 # undef DBG
34 #endif
35 #define DBG(...) EINA_LOG_DOM_DBG(_EVAS_DEFAULT_LOG_DOM, __VA_ARGS__)
36
37 #ifdef INF
38 # undef INF
39 #endif
40 #define INF(...) EINA_LOG_DOM_INFO(_EVAS_DEFAULT_LOG_DOM, __VA_ARGS__)
41
42 #ifdef WRN
43 # undef WRN
44 #endif
45 #define WRN(...) EINA_LOG_DOM_WARN(_EVAS_DEFAULT_LOG_DOM, __VA_ARGS__)
46
47 #ifdef CRIT
48 # undef CRIT
49 #endif
50 #define CRIT(...) EINA_LOG_DOM_CRIT(_EVAS_DEFAULT_LOG_DOM, __VA_ARGS__)
51
52 /*****************************************************************************/
53
54 #include "evas_options.h"
55
56 #if defined(__ARM_ARCH_3M__)
57 # define __ARM_ARCH__ 40
58 #endif
59 #if defined(__ARM_ARCH_4__)
60 # define __ARM_ARCH__ 40
61 #endif
62 #if defined(__ARM_ARCH_4T__)
63 # define __ARM_ARCH__ 41
64 #endif
65
66 #if defined(__ARM_ARCH_5__)
67 # define __ARM_ARCH__ 50
68 #endif
69 #if defined(__ARM_ARCH_5T__)
70 # define __ARM_ARCH__ 51
71 #endif
72 #if defined(__ARM_ARCH_5E__)
73 # define __ARM_ARCH__ 52
74 #endif
75 #if defined(__ARM_ARCH_5TE__)
76 # define __ARM_ARCH__ 53
77 #endif
78 #if defined(__ARM_ARCH_5TEJ__)
79 # define __ARM_ARCH__ 54
80 #endif
81
82 #if defined(__ARM_ARCH_6__)
83 # define __ARM_ARCH__ 60
84 #endif
85 #if defined(__ARM_ARCH_6J__)
86 # define __ARM_ARCH__ 61
87 #endif
88 #if defined(__ARM_ARCH_6K__)
89 # define __ARM_ARCH__ 62
90 #endif
91 #if defined(__ARM_ARCH_6Z__)
92 # define __ARM_ARCH__ 63
93 #endif
94 #if defined(__ARM_ARCH_6ZK__)
95 # define __ARM_ARCH__ 64
96 #endif
97 #if defined(__ARM_ARCH_6T2__)
98 # define __ARM_ARCH__ 65
99 #endif
100
101 #if defined(__ARM_ARCH_7__)
102 # define __ARM_ARCH__ 70
103 #endif
104 #if defined(__ARM_ARCH_7A__)
105 # define __ARM_ARCH__ 71
106 #endif
107 #if defined(__ARM_ARCH_7R__)
108 # define __ARM_ARCH__ 72
109 #endif
110 #if defined(__ARM_ARCH_7M__)
111 # define __ARM_ARCH__ 73
112 #endif
113
114 #ifndef _GNU_SOURCE
115 # define _GNU_SOURCE
116 #endif
117
118 #ifndef BUILD_PTHREAD
119 # undef BUILD_PIPE_RENDER
120 #endif
121
122 #ifdef BUILD_PTHREAD
123
124 #ifndef __USE_GNU
125 #define __USE_GNU
126 #endif
127
128 # include <pthread.h>
129 # include <sched.h>
130 # define LK(x)  pthread_mutex_t x
131 # define LKI(x) pthread_mutex_init(&(x), NULL);
132 # define LKD(x) pthread_mutex_destroy(&(x));
133 # define LKL(x) pthread_mutex_lock(&(x));
134 # define LKT(x) pthread_mutex_trylock(&(x));
135 # define LKU(x) pthread_mutex_unlock(&(x));
136 # define TH(x)  pthread_t x
137 # define THI(x) int x
138 # define TH_MAX 8
139
140 // even though in theory having every Nth rendered line done by a different
141 // thread might even out load across threads - it actually slows things down.
142 //#define EVAS_SLI 1
143
144 #else
145 # define LK(x)
146 # define LKI(x)
147 # define LKD(x)
148 # define LKL(x)
149 # define LKT(x) 0
150 # define LKU(x)
151 # define TH(x)
152 # define THI(x)
153 # define TH_MAX 0
154 #endif
155
156 #ifdef HAVE_ALLOCA_H
157 # include <alloca.h>
158 #elif defined __GNUC__
159 # define alloca __builtin_alloca
160 #elif defined _AIX
161 # define alloca __alloca
162 #elif defined _MSC_VER
163 # include <malloc.h>
164 # define alloca _alloca
165 #else
166 # include <stddef.h>
167 # ifdef  __cplusplus
168 extern "C"
169 # endif
170 void *alloca (size_t);
171 #endif
172
173 #include <stdio.h>
174 #include <stdlib.h>
175 #include <string.h>
176 #include <sys/types.h>
177 #include <sys/stat.h>
178 #include <time.h>
179 #include <ctype.h>
180 #ifndef _MSC_VER
181 # include <stdint.h>
182 # include <unistd.h>
183 #endif
184
185 #include <ft2build.h>
186 #include FT_FREETYPE_H
187 #include FT_GLYPH_H
188 #include FT_SIZES_H
189 #include FT_MODULE_H
190
191 #ifdef __GNUC__
192 # if __GNUC__ >= 4
193 // BROKEN in gcc 4 on amd64
194 //#  pragma GCC visibility push(hidden)
195 # endif
196 #define LIKELY(x)   __builtin_expect(!!(x), 1)
197 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
198 #else
199 #define LIKELY(x)   (x)
200 #define UNLIKELY(x) (x)
201 #endif
202
203 /*****************************************************************************/
204
205 /* use exact rects for updates not tiles */
206 /* #define RECTUPDATE */
207 #define TILESIZE 8
208 #define IMG_MAX_SIZE 65000
209
210 #define IMG_TOO_BIG(w, h) \
211    ((((unsigned long long)w) * ((unsigned long long)h)) >= \
212        ((1ULL << (29 * (sizeof(void *) / 4))) - 2048))
213
214 #ifdef BUILD_SMALL_DITHER_MASK
215 # define DM_TABLE     _evas_dither_44
216 # define DM_SIZE      4
217 # define DM_BITS      4
218 # define DM_DIV       16
219 # define USE_DITHER_44 1
220 # define DM_MSK       (DM_SIZE - 1)
221 # define DM_SHF(_b)   (DM_BITS - (8 - _b))
222 #else
223 # define DM_TABLE     _evas_dither_128128
224 # define DM_SIZE      128
225 # define DM_BITS      6
226 # define DM_DIV       64
227 # define USE_DITHER_128128 1
228 # define DM_MSK       (DM_SIZE - 1)
229 # define DM_SHF(_b)   (DM_BITS - (8 - _b))
230 #endif
231
232 /* if more than 1/ALPHA_SPARSE_INV_FRACTION is "alpha" (1-254) then sparse
233  * alpha flag gets set */
234 #define ALPHA_SPARSE_INV_FRACTION 3
235
236 /*****************************************************************************/
237
238 #if defined(__ARM_ARCH_3M__)
239 # define __ARM_ARCH__ 40
240 #endif
241 #if defined(__ARM_ARCH_4__)
242 # define __ARM_ARCH__ 40
243 #endif
244 #if defined(__ARM_ARCH_4T__)
245 # define __ARM_ARCH__ 41
246 #endif
247
248 #if defined(__ARM_ARCH_5__)
249 # define __ARM_ARCH__ 50
250 #endif
251 #if defined(__ARM_ARCH_5T__)
252 # define __ARM_ARCH__ 51
253 #endif
254 #if defined(__ARM_ARCH_5E__)
255 # define __ARM_ARCH__ 52
256 #endif
257 #if defined(__ARM_ARCH_5TE__)
258 # define __ARM_ARCH__ 53
259 #endif
260 #if defined(__ARM_ARCH_5TEJ__)
261 # define __ARM_ARCH__ 54
262 #endif
263
264 #if defined(__ARM_ARCH_6__)
265 # define __ARM_ARCH__ 60
266 #endif
267 #if defined(__ARM_ARCH_6J__)
268 # define __ARM_ARCH__ 61
269 #endif
270 #if defined(__ARM_ARCH_6K__)
271 # define __ARM_ARCH__ 62
272 #endif
273 #if defined(__ARM_ARCH_6Z__)
274 # define __ARM_ARCH__ 63
275 #endif
276 #if defined(__ARM_ARCH_6ZK__)
277 # define __ARM_ARCH__ 64
278 #endif
279 #if defined(__ARM_ARCH_6T2__)
280 # define __ARM_ARCH__ 65
281 #endif
282
283 #if defined(__ARM_ARCH_7__)
284 # define __ARM_ARCH__ 70
285 #endif
286 #if defined(__ARM_ARCH_7A__)
287 # define __ARM_ARCH__ 71
288 #endif
289 #if defined(__ARM_ARCH_7R__)
290 # define __ARM_ARCH__ 72
291 #endif
292 #if defined(__ARM_ARCH_7M__)
293 # define __ARM_ARCH__ 73
294 #endif
295
296 #if defined(__ARM_ARCH__) && (__ARM_ARCH__ >= 52)
297 /* tested on ARMv6 (arm1136j-s), Nokia N800 CPU */
298 #define pld(addr, off)                                                  \
299    __asm__("pld [%[address], %[offset]]"::                              \
300            [address] "r" (addr), [offset] "i" (off))
301 #else
302 #define pld(addr, off)
303 #endif /* __ARMEL__ */
304
305 /*****************************************************************************/
306
307 #define UNROLL2(op...) op op
308 #define UNROLL4(op...) UNROLL2(op) UNROLL2(op)
309 #define UNROLL8(op...) UNROLL4(op) UNROLL4(op)
310 #define UNROLL16(op...) UNROLL8(op) UNROLL8(op)
311
312 #define UNROLL8_PLD_WHILE(start, size, end, op)         \
313     pld(start, 0);                                      \
314     end = start + (size & ~7);                          \
315     while (start < end)                                 \
316         {                                               \
317             pld(start, 32);                             \
318             UNROLL8(op);                                \
319         }                                               \
320     end += (size & 7);                                  \
321     pld(start, 32);                                     \
322     while (start <  end)                                \
323         {                                               \
324         op;                                             \
325         }
326
327 /*****************************************************************************/
328
329 typedef unsigned long long              DATA64;
330 typedef unsigned int                    DATA32;
331 typedef unsigned short                  DATA16;
332 typedef unsigned char                   DATA8;
333
334 typedef struct _Image_Entry             Image_Entry;
335 typedef struct _Image_Entry_Flags       Image_Entry_Flags;
336 typedef struct _Engine_Image_Entry      Engine_Image_Entry;
337 typedef struct _Evas_Cache_Target       Evas_Cache_Target;
338
339 typedef struct _RGBA_Image_Loadopts   RGBA_Image_Loadopts;
340 #ifdef BUILD_PIPE_RENDER
341 typedef struct _RGBA_Pipe_Op          RGBA_Pipe_Op;
342 typedef struct _RGBA_Pipe             RGBA_Pipe;
343 typedef struct _RGBA_Pipe_Thread_Info RGBA_Pipe_Thread_Info;
344 #endif
345 typedef struct _RGBA_Image            RGBA_Image;
346 typedef struct _RGBA_Image_Span       RGBA_Image_Span;
347 typedef struct _RGBA_Draw_Context     RGBA_Draw_Context;
348 typedef struct _RGBA_Gradient         RGBA_Gradient;
349 typedef struct _RGBA_Gradient_Color_Stop   RGBA_Gradient_Color_Stop;
350 typedef struct _RGBA_Gradient_Alpha_Stop   RGBA_Gradient_Alpha_Stop;
351 typedef struct _RGBA_Gradient_Type    RGBA_Gradient_Type;
352 typedef struct _RGBA_Gradient2         RGBA_Gradient2;
353 typedef struct _RGBA_Gradient2_Type    RGBA_Gradient2_Type;
354 typedef struct _RGBA_Gradient2_Color_Np_Stop   RGBA_Gradient2_Color_Np_Stop;
355 typedef struct _RGBA_Polygon_Point    RGBA_Polygon_Point;
356 typedef struct _RGBA_Font             RGBA_Font;
357 typedef struct _RGBA_Font_Int         RGBA_Font_Int;
358 typedef struct _RGBA_Font_Source      RGBA_Font_Source;
359 typedef struct _RGBA_Font_Glyph       RGBA_Font_Glyph;
360 typedef struct _RGBA_Gfx_Compositor   RGBA_Gfx_Compositor;
361
362 typedef struct _Cutout_Rect           Cutout_Rect;
363 typedef struct _Cutout_Rects            Cutout_Rects;
364
365 typedef struct _Convert_Pal             Convert_Pal;
366
367 typedef struct _Tilebuf                 Tilebuf;
368 typedef struct _Tilebuf_Tile            Tilebuf_Tile;
369 typedef struct _Tilebuf_Rect            Tilebuf_Rect;
370
371 typedef struct _Evas_Common_Transform        Evas_Common_Transform;
372
373 /*
374 typedef struct _Regionbuf             Regionbuf;
375 typedef struct _Regionspan            Regionspan;
376 */
377
378 typedef void (*RGBA_Gfx_Func)    (DATA32 *src, DATA8 *mask, DATA32 col, DATA32 *dst, int len);
379 typedef void (*RGBA_Gfx_Pt_Func) (DATA32 src, DATA8 mask, DATA32 col, DATA32 *dst);
380 typedef void (*Gfx_Func_Copy)    (DATA32 *src, DATA32 *dst, int len);
381
382 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);
383
384 typedef void (*Gfx_Func_Gradient_Fill)(DATA32 *src, int src_len,
385                                          DATA32 *dst, DATA8 *mask, int len,
386                                          int x, int y, int axx, int axy, int ayx, int ayy,
387                                          void *geom_data);
388
389 typedef void (*Gfx_Func_Gradient2_Fill)(DATA32 *src, int src_len,
390                                          DATA32 *dst, DATA8 *mask, int len,
391                                          int x, int y,
392                                          void *geom_data);
393
394 #include "../cache/evas_cache.h"
395
396 /*****************************************************************************/
397
398 typedef enum _RGBA_Image_Flags
399 {
400    RGBA_IMAGE_NOTHING       = (0),
401 /*    RGBA_IMAGE_HAS_ALPHA     = (1 << 0), */
402    RGBA_IMAGE_IS_DIRTY      = (1 << 1),
403    RGBA_IMAGE_INDEXED       = (1 << 2),
404    RGBA_IMAGE_ALPHA_ONLY    = (1 << 3),
405    RGBA_IMAGE_ALPHA_TILES   = (1 << 4),
406 /*    RGBA_IMAGE_ALPHA_SPARSE  = (1 << 5), */
407 /*    RGBA_IMAGE_LOADED        = (1 << 6), */
408 /*    RGBA_IMAGE_NEED_DATA     = (1 << 7) */
409 } RGBA_Image_Flags;
410
411 typedef enum _Convert_Pal_Mode
412 {
413    PAL_MODE_NONE,
414    PAL_MODE_MONO,
415    PAL_MODE_GRAY4,
416    PAL_MODE_GRAY16,
417    PAL_MODE_GRAY64,
418    PAL_MODE_GRAY256,
419    PAL_MODE_RGB111,
420    PAL_MODE_RGB121,
421    PAL_MODE_RGB221,
422    PAL_MODE_RGB222,
423    PAL_MODE_RGB232,
424    PAL_MODE_RGB332,
425    PAL_MODE_RGB666,
426    PAL_MODE_LAST
427 } Convert_Pal_Mode;
428
429 typedef enum _CPU_Features
430 {
431    CPU_FEATURE_C       = 0,
432    CPU_FEATURE_MMX     = (1 << 0),
433    CPU_FEATURE_MMX2    = (1 << 1),
434    CPU_FEATURE_SSE     = (1 << 2),
435    CPU_FEATURE_ALTIVEC = (1 << 3),
436    CPU_FEATURE_VIS     = (1 << 4),
437    CPU_FEATURE_VIS2    = (1 << 5),
438    CPU_FEATURE_NEON    = (1 << 6)
439 } CPU_Features;
440
441 typedef enum _Font_Hint_Flags
442 {
443    FONT_NO_HINT,
444    FONT_AUTO_HINT,
445    FONT_BYTECODE_HINT
446 } Font_Hint_Flags;
447
448 /*****************************************************************************/
449
450 struct _RGBA_Image_Loadopts
451 {
452    int                  scale_down_by; // if > 1 then use this
453    double               dpi; // if > 0.0 use this
454    int                  w, h; // if > 0 use this
455    struct {
456       int               x, y, w, h;
457    } region;
458 };
459
460 struct _Image_Entry_Flags
461 {
462    Eina_Bool loaded       : 1;
463    Eina_Bool dirty        : 1;
464    Eina_Bool activ        : 1;
465    Eina_Bool need_data    : 1;
466    Eina_Bool lru_nodata   : 1;
467    Eina_Bool cached       : 1;
468    Eina_Bool alpha        : 1;
469    Eina_Bool alpha_sparse : 1;
470 #ifdef BUILD_ASYNC_PRELOAD
471    Eina_Bool preload      : 1;
472    Eina_Bool pending      : 1;
473 #endif
474 };
475
476 struct _Evas_Cache_Target
477 {
478   EINA_INLIST;
479   const void *target;
480 };
481
482 struct _Image_Entry
483 {
484    EINA_INLIST;
485
486    Evas_Cache_Image      *cache;
487
488    const char            *cache_key;
489
490    const char            *file;
491    const char            *key;
492
493    Evas_Cache_Target     *targets;
494
495    time_t                 timestamp;
496    time_t                 laststat;
497
498    int                    references;
499
500    unsigned char          scale;
501
502    RGBA_Image_Loadopts    load_opts;
503    int                    space;
504    int                    w;
505    int                    h;
506
507    struct
508      {
509         int              w;
510         int              h;
511      } allocated;
512
513    struct
514      {
515         void            *module;
516         void            *loader;
517      } info;
518
519 #ifdef BUILD_ASYNC_PRELOAD
520    LK(lock);
521 #endif
522
523    Image_Entry_Flags      flags;
524    Evas_Image_Scale_Hint  scale_hint;
525    void                  *data1, *data2;
526    int                    server_id;
527    int                    connect_num;
528    int                    channel;
529 };
530
531 struct _Engine_Image_Entry
532 {
533    EINA_INLIST;
534
535    /* Upper Engine data. */
536    Image_Entry                  *src;
537
538    /* Cache stuff. */
539    Evas_Cache_Engine_Image      *cache;
540    const char                   *cache_key;
541
542    struct
543    {
544      Eina_Bool                   cached : 1;
545      Eina_Bool                   activ : 1;
546      Eina_Bool                   dirty : 1;
547      Eina_Bool                   loaded : 1;
548      Eina_Bool                   need_parent : 1;
549    } flags;
550
551    int                           references;
552    int                           w;
553    int                           h;
554 };
555
556 struct _Cutout_Rect
557 {
558    int               x, y, w, h;
559 };
560
561 struct _Cutout_Rects
562 {
563    Cutout_Rect*      rects;
564    int               active;
565    int               max;
566 };
567
568 struct _Evas_Common_Transform
569 {
570    float  mxx, mxy, mxz;
571    float  myx, myy, myz;
572    float  mzx, mzy, mzz;
573 };
574
575 struct _RGBA_Draw_Context
576 {
577    struct {
578       Eina_Bool use : 1;
579       DATA32 col;
580    } mul;
581    struct {
582       DATA32 col;
583    } col;
584    struct RGBA_Draw_Context_clip {
585       int    x, y, w, h;
586       Eina_Bool use : 1;
587    } clip;
588    Cutout_Rects cutout;
589    struct {
590       struct {
591          void *(*gl_new)  (void *data, RGBA_Font_Glyph *fg);
592          void  (*gl_free) (void *ext_dat);
593          void  (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y);
594       } func;
595       void *data;
596    } font_ext;
597    struct {
598       int color_space;
599    } interpolation;
600    struct {
601       int y, h;
602    } sli;
603    int            render_op;
604    Eina_Bool anti_alias : 1;
605 };
606
607 #ifdef BUILD_PIPE_RENDER
608 struct _RGBA_Pipe_Op
609 {
610    RGBA_Draw_Context         context;
611    void                    (*op_func) (RGBA_Image *dst, RGBA_Pipe_Op *op, RGBA_Pipe_Thread_Info *info);
612    void                    (*free_func) (RGBA_Pipe_Op *op);
613
614    union {
615       struct {
616          int                 x, y, w, h;
617       } rect;
618       struct {
619          int                 x0, y0, x1, y1;
620       } line;
621       struct {
622          RGBA_Polygon_Point *points;
623       } poly;
624       struct {
625          RGBA_Gradient      *grad;
626          int                 x, y, w, h;
627       } grad;
628       struct {
629          RGBA_Gradient2      *grad;
630          int                 x, y, w, h;
631       } grad2;
632       struct {
633          RGBA_Font          *font;
634          int                 x, y;
635          char               *text;
636       } text;
637       struct {
638          RGBA_Image         *src;
639          int                 sx, sy, sw, sh, dx, dy, dw, dh;
640          int                 smooth;
641          char               *text;
642       } image;
643    } op;
644 };
645
646 #define PIPE_LEN 256
647
648 struct _RGBA_Pipe
649 {
650    EINA_INLIST;
651    int               op_num;
652    RGBA_Pipe_Op      op[PIPE_LEN];
653 };
654
655 struct _RGBA_Pipe_Thread_Info
656 {
657    RGBA_Image *im;
658    int         x, y, w, h;
659 };
660 #endif
661
662 struct _RGBA_Image
663 {
664    Image_Entry          cache_entry;
665
666    RGBA_Image_Flags     flags;
667    struct
668      {
669 /*      void           *module; */
670 /*      void           *loader; */
671 /*      char           *real_file; */
672         char           *comment;
673 //      int             format;
674      } info;
675
676    void                *extended_info;
677 #ifdef BUILD_PIPE_RENDER
678    RGBA_Pipe           *pipe;
679 #endif
680    int                  ref;
681
682 /*    unsigned char        scale; */
683
684    /* Colorspace stuff. */
685    struct {
686       void              *data;
687       Eina_Bool          no_free : 1;
688       Eina_Bool          dirty : 1;
689    } cs;
690
691    /* RGBA stuff */
692    struct {
693       DATA32            *data;
694       Eina_Bool          no_free : 1;
695    } image;
696
697    struct {
698       LK(lock);
699       Eina_List *list;
700       unsigned long long orig_usage;
701       unsigned long long usage_count;
702       int populate_count;
703       unsigned long long newest_usage;
704       unsigned long long newest_usage_count;
705    } cache;
706 };
707
708 struct _RGBA_Gradient_Color_Stop
709 {
710    EINA_INLIST;
711    int               r, g, b, a;
712    int               dist;
713 };
714
715 struct _RGBA_Gradient_Alpha_Stop
716 {
717    EINA_INLIST;
718    int               a;
719    int               dist;
720 };
721
722 struct _RGBA_Gradient
723 {
724    struct
725      {
726         DATA32        *data;
727         int            len;
728         float          angle;
729         int            direction;
730         float          offset;
731         Eina_Bool      has_alpha : 1;
732      } map;
733
734    struct {
735         Eina_Inlist *stops;
736         DATA32           *data;
737         int               nstops;
738         int               len;
739    }  color;
740    struct {
741         Eina_Inlist *stops;
742         DATA8            *data;
743         int               nstops;
744         int               len;
745    }  alpha;
746
747    struct
748      {
749         int            x, y, w, h;
750         int            spread;
751         float          angle;
752      } fill;
753    struct
754      {
755         char          *name;
756         char          *params;
757         RGBA_Gradient_Type *geometer;
758         void          *gdata;
759      } type;
760
761    int references;
762
763    Eina_Bool imported_data : 1;
764    Eina_Bool has_alpha : 1;
765 };
766
767 struct _RGBA_Gradient_Type
768 {
769    const char              *name;
770    void                    (*init)(void);
771    void                    (*shutdown)(void);
772    void                    (*geom_init)(RGBA_Gradient *gr);
773    void                    (*geom_set)(RGBA_Gradient *gr);
774    void                    (*geom_free)(void *gdata);
775    int                     (*has_alpha)(RGBA_Gradient *gr, int render_op);
776    int                     (*has_mask)(RGBA_Gradient *gr, int render_op);
777    int                     (*get_map_len)(RGBA_Gradient *gr);
778    Gfx_Func_Gradient_Fill  (*get_fill_func)(RGBA_Gradient *gr, int render_op, unsigned char aa);
779 };
780
781 struct _RGBA_Gradient2_Color_Np_Stop
782 {
783    EINA_INLIST;
784    int               r, g, b, a;
785    float             pos;
786    int               dist;
787 };
788
789 struct _RGBA_Gradient2
790 {
791    struct
792      {
793         DATA32        *data;
794         int            len;
795         Eina_Bool      has_alpha : 1;
796      } map;
797
798    struct {
799         Eina_Inlist *stops;
800         int               nstops;
801         DATA32           *cdata;
802         DATA8            *adata;
803         int               len;
804    }  stops;
805
806    struct
807      {
808         Evas_Common_Transform  transform;
809         int                    spread;
810      } fill;
811    struct
812      {
813         int                 id;
814         RGBA_Gradient2_Type *geometer;
815         void                *gdata;
816      } type;
817
818    int references;
819
820    Eina_Bool has_alpha : 1;
821 };
822
823 struct _RGBA_Gradient2_Type
824 {
825    const char              *name;
826    void                    (*init)(void);
827    void                    (*shutdown)(void);
828    void                    (*geom_init)(RGBA_Gradient2 *gr);
829    void                    (*geom_update)(RGBA_Gradient2 *gr);
830    void                    (*geom_free)(void *gdata);
831    int                     (*has_alpha)(RGBA_Gradient2 *gr, int render_op);
832    int                     (*has_mask)(RGBA_Gradient2 *gr, int render_op);
833    int                     (*get_map_len)(RGBA_Gradient2 *gr);
834    Gfx_Func_Gradient2_Fill  (*get_fill_func)(RGBA_Gradient2 *gr, int render_op);
835 };
836
837
838 struct _RGBA_Polygon_Point
839 {
840    EINA_INLIST;
841    int               x, y;
842 };
843
844 struct _RGBA_Font
845 {
846    Eina_List *fonts;
847    Font_Hint_Flags hinting;
848    int references;
849    LK(lock);
850 };
851
852 struct _RGBA_Font_Int
853 {
854    RGBA_Font_Source *src;
855
856    int               size;
857    int               real_size;
858    int               max_h;
859
860    struct {
861       FT_Size       size;
862    } ft;
863
864    Eina_Hash       *glyphs;
865
866    LK(ft_mutex);
867
868    Eina_Hash       *kerning;
869    Eina_Hash       *indexes;
870
871    int              usage;
872    Font_Hint_Flags hinting;
873
874    int              references;
875
876 };
877
878 struct _RGBA_Font_Source
879 {
880    const char       *name;
881    const char       *file;
882
883    void             *data;
884    int               data_size;
885    int               current_size;
886 #if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */
887    Evas_Array_Hash  *charmap;
888 #endif
889
890    struct {
891       int           orig_upem;
892       FT_Face       face;
893    } ft;
894
895    int              references;
896 };
897
898 struct _RGBA_Font_Glyph
899 {
900    FT_UInt         index;
901    FT_Glyph        glyph;
902    FT_BitmapGlyph  glyph_out;
903    /* this is a problem - only 1 engine at a time can extend such a font... grrr */
904    void           *ext_dat;
905    void           (*ext_dat_free) (void *ext_dat);
906    RGBA_Font_Int   *fi;
907 };
908
909 struct _RGBA_Gfx_Compositor
910 {
911    const char *name;
912
913    void              (*init)(void);
914    void              (*shutdown)(void);
915
916    RGBA_Gfx_Func  (*composite_pixel_span_get)(RGBA_Image *src, RGBA_Image *dst, int pixels);
917    RGBA_Gfx_Func  (*composite_color_span_get)(DATA32 col, RGBA_Image *dst, int pixels);
918    RGBA_Gfx_Func  (*composite_pixel_color_span_get)(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels);
919    RGBA_Gfx_Func  (*composite_mask_color_span_get)(DATA32 col, RGBA_Image *dst, int pixels);
920    RGBA_Gfx_Func  (*composite_pixel_mask_span_get)(RGBA_Image *src, RGBA_Image *dst, int pixels);
921
922    RGBA_Gfx_Pt_Func  (*composite_pixel_pt_get)(Image_Entry_Flags src_flags, RGBA_Image *dst);
923    RGBA_Gfx_Pt_Func  (*composite_color_pt_get)(DATA32 col, RGBA_Image *dst);
924    RGBA_Gfx_Pt_Func  (*composite_pixel_color_pt_get)(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst);
925    RGBA_Gfx_Pt_Func  (*composite_mask_color_pt_get)(DATA32 col, RGBA_Image *dst);
926    RGBA_Gfx_Pt_Func  (*composite_pixel_mask_pt_get)(Image_Entry_Flags src_flags, RGBA_Image *dst);
927 };
928
929 #define EVAS_RECT_SPLIT 1
930 #ifdef EVAS_RECT_SPLIT
931 typedef struct list_node list_node_t;
932 typedef struct list list_t;
933 typedef struct rect rect_t;
934 typedef struct rect_node rect_node_t;
935
936 struct list_node
937 {
938     struct list_node *next;
939 };
940
941 struct list
942 {
943     struct list_node *head;
944     struct list_node *tail;
945 };
946
947 struct rect
948 {
949     short left;
950     short top;
951     short right;
952     short bottom;
953     short width;
954     short height;
955     int area;
956 };
957
958 struct rect_node
959 {
960     struct list_node _lst;
961     struct rect rect;
962 };
963
964 void rect_list_node_pool_set_max(int max);
965 void rect_list_node_pool_flush(void);
966 list_node_t *rect_list_node_pool_get(void);
967 void rect_list_node_pool_put(list_node_t *node);
968
969 void rect_init(rect_t *r, int x, int y, int w, int h);
970 void rect_list_append_node(list_t *rects, list_node_t *node);
971 void rect_list_append(list_t *rects, const rect_t r);
972 void rect_list_append_xywh(list_t *rects, int x, int y, int w, int h);
973 void rect_list_concat(list_t *rects, list_t *other);
974 list_node_t *rect_list_unlink_next(list_t *rects, list_node_t *parent_node);
975 void rect_list_del_next(list_t *rects, list_node_t *parent_node);
976 void rect_list_clear(list_t *rects);
977 void rect_list_del_split_strict(list_t *rects, const rect_t del_r);
978 void rect_list_add_split_strict(list_t *rects, list_node_t *node);
979 list_node_t *rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error);
980 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);
981
982 void rect_print(const rect_t r);
983 void rect_list_print(const list_t rects);
984 #endif /* EVAS_RECT_SPLIT */
985
986 struct _Tilebuf
987 {
988    int outbuf_w;
989    int outbuf_h;
990
991    struct {
992       int           w, h;
993    } tile_size;
994
995 #ifdef RECTUPDATE
996    Regionbuf *rb;
997 #elif defined(EVAS_RECT_SPLIT)
998    int need_merge;
999    list_t rects;
1000 #else
1001    struct {
1002       int           w, h;
1003       Tilebuf_Tile *tiles;
1004    } tiles;
1005 #endif
1006 };
1007
1008 struct _Tilebuf_Tile
1009 {
1010    Eina_Bool redraw : 1;
1011 /* FIXME: need these flags later - but not now */
1012 /*
1013    Eina_Bool done   : 1;
1014    Eina_Bool edge   : 1;
1015    Eina_Bool from   : 1;
1016
1017    struct {
1018       int dx, dy;
1019    } vector;
1020  */
1021 };
1022
1023 struct _Tilebuf_Rect
1024 {
1025    EINA_INLIST;
1026    int               x, y, w, h;
1027 };
1028 /*
1029 struct _Regionbuf
1030 {
1031    int w, h;
1032    Regionspan **spans;
1033 };
1034
1035 struct _Regionspan
1036 {
1037   EINA_INLIST;
1038    int x1, x2;
1039 };
1040 */
1041
1042 struct _Convert_Pal
1043 {
1044    int               references;
1045    int               count;
1046    Convert_Pal_Mode  colors;
1047    DATA8            *lookup;
1048    void             *data;
1049 };
1050
1051 /****/
1052
1053 /*****************************************************************************/
1054 #include "evas_macros.h"
1055
1056 #ifndef WORDS_BIGENDIAN
1057 /* x86 */
1058 #define A_VAL(p) ((DATA8 *)(p))[3]
1059 #define R_VAL(p) ((DATA8 *)(p))[2]
1060 #define G_VAL(p) ((DATA8 *)(p))[1]
1061 #define B_VAL(p) ((DATA8 *)(p))[0]
1062 #define AR_VAL(p) ((DATA16 *)(p)[1])
1063 #define GB_VAL(p) ((DATA16 *)(p)[0])
1064 #else
1065 /* ppc */
1066 #define A_VAL(p) ((DATA8 *)(p))[0]
1067 #define R_VAL(p) ((DATA8 *)(p))[1]
1068 #define G_VAL(p) ((DATA8 *)(p))[2]
1069 #define B_VAL(p) ((DATA8 *)(p))[3]
1070 #define AR_VAL(p) ((DATA16 *)(p)[0])
1071 #define GB_VAL(p) ((DATA16 *)(p)[1])
1072 #endif
1073
1074 #define RGB_JOIN(r,g,b) \
1075         (((r) << 16) + ((g) << 8) + (b))
1076
1077 #define ARGB_JOIN(a,r,g,b) \
1078         (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
1079
1080 #include "evas_blend_ops.h"
1081
1082 #define _EVAS_RENDER_FILL        -1
1083 #define _EVAS_RENDER_BLEND        0
1084 #define _EVAS_RENDER_BLEND_REL    1
1085 #define _EVAS_RENDER_COPY         2
1086 #define _EVAS_RENDER_COPY_REL     3
1087 #define _EVAS_RENDER_ADD          4
1088 #define _EVAS_RENDER_ADD_REL      5
1089 #define _EVAS_RENDER_SUB          6
1090 #define _EVAS_RENDER_SUB_REL      7
1091 #define _EVAS_RENDER_TINT         8
1092 #define _EVAS_RENDER_TINT_REL     9
1093 #define _EVAS_RENDER_MASK         10
1094 #define _EVAS_RENDER_MUL          11
1095 #define _EVAS_RENDER_CLIP         12
1096
1097 #define _EVAS_TEXTURE_REFLECT           0
1098 #define _EVAS_TEXTURE_REPEAT            1
1099 #define _EVAS_TEXTURE_RESTRICT          2
1100 #define _EVAS_TEXTURE_RESTRICT_REFLECT  3
1101 #define _EVAS_TEXTURE_RESTRICT_REPEAT   4
1102 #define _EVAS_TEXTURE_PAD               5
1103
1104 #define _EVAS_COLOR_SPACE_ARGB    0
1105 #define _EVAS_COLOR_SPACE_AHSV    1
1106
1107 /*****************************************************************************/
1108
1109 #ifdef __cplusplus
1110 extern "C" {
1111 #endif
1112
1113 /****/
1114 void evas_common_init                                   (void);
1115 void evas_common_shutdown                               (void);
1116
1117 EAPI void evas_common_cpu_init                          (void);
1118
1119 int  evas_common_cpu_have_cpuid                         (void);
1120 int  evas_common_cpu_has_feature                        (unsigned int feature);
1121 EAPI void evas_common_cpu_can_do                        (int *mmx, int *sse, int *sse2);
1122 EAPI void evas_common_cpu_end_opt                       (void);
1123
1124 /****/
1125 #include "../engines/common/evas_blend.h"
1126
1127 EAPI Gfx_Func_Copy        evas_common_draw_func_copy_get        (int pixels, int reverse);
1128
1129 /****/
1130 #include "../engines/common/evas_convert_color.h"
1131 #include "../engines/common/evas_convert_colorspace.h"
1132 #include "../engines/common/evas_convert_main.h"
1133 #include "../engines/common/evas_convert_yuv.h"
1134 #include "../engines/common/evas_scale_main.h"
1135 #include "../engines/common/evas_scale_smooth.h"
1136 #include "../engines/common/evas_scale_span.h"
1137
1138 /****/
1139 #include "../engines/common/evas_image.h"
1140
1141 /****/
1142 #include "../engines/common/evas_line.h"
1143 #include "../engines/common/evas_polygon.h"
1144 #include "../engines/common/evas_rectangle.h"
1145
1146 /****/
1147 EAPI void     evas_common_blit_init               (void);
1148
1149 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);
1150
1151 /****/
1152 #include "../engines/common/evas_gradient.h"
1153 #include "../engines/common/evas_font.h"
1154
1155 /****/
1156 EAPI void          evas_common_tilebuf_init               (void);
1157
1158 EAPI Tilebuf      *evas_common_tilebuf_new               (int w, int h);
1159 EAPI void          evas_common_tilebuf_free              (Tilebuf *tb);
1160 EAPI void          evas_common_tilebuf_set_tile_size     (Tilebuf *tb, int tw, int th);
1161 EAPI void          evas_common_tilebuf_get_tile_size     (Tilebuf *tb, int *tw, int *th);
1162 EAPI int           evas_common_tilebuf_add_redraw        (Tilebuf *tb, int x, int y, int w, int h);
1163 EAPI int           evas_common_tilebuf_del_redraw        (Tilebuf *tb, int x, int y, int w, int h);
1164 EAPI int           evas_common_tilebuf_add_motion_vector (Tilebuf *tb, int x, int y, int w, int h, int dx, int dy, int alpha);
1165 EAPI void          evas_common_tilebuf_clear             (Tilebuf *tb);
1166 EAPI Tilebuf_Rect *evas_common_tilebuf_get_render_rects  (Tilebuf *tb);
1167 EAPI void          evas_common_tilebuf_free_render_rects (Tilebuf_Rect *rects);
1168
1169 /*
1170 Regionbuf    *evas_common_regionbuf_new       (int w, int h);
1171 void          evas_common_regionbuf_free      (Regionbuf *rb);
1172 void          evas_common_regionbuf_clear     (Regionbuf *rb);
1173 void          evas_common_regionbuf_span_add  (Regionbuf *rb, int x1, int x2, int y);
1174 void          evas_common_regionbuf_span_del  (Regionbuf *rb, int x1, int x2, int y);
1175 Tilebuf_Rect *evas_common_regionbuf_rects_get (Regionbuf *rb);
1176 */
1177
1178 /****/
1179 #include "../engines/common/evas_draw.h"
1180
1181 #include "../engines/common/evas_map_image.h"
1182
1183 /****/
1184 #ifdef BUILD_PIPE_RENDER
1185 # include "../engines/common/evas_pipe.h"
1186 #endif
1187
1188 void              evas_font_dir_cache_free(void);
1189
1190 /****/
1191
1192 /*****************************************************************************/
1193
1194 #if defined(__ARM_ARCH__) && (__ARM_ARCH__ >= 70)
1195 #ifdef BUILD_NEON
1196 # include <arm_neon.h>
1197 #endif
1198 #endif
1199
1200 #ifdef __cplusplus
1201 }
1202 #endif
1203 #endif