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