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