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