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