move around - flatter.
[profile/ivi/evas.git] / src / modules / engines / software_xcb / evas_engine.h
1 #ifndef EVAS_ENGINE_H
2 #define EVAS_ENGINE_H
3
4 #include <sys/ipc.h>
5 #include <sys/shm.h>
6
7 #include <xcb/xcb.h>
8 #include <xcb/xcb_image.h>
9
10 typedef struct _Outbuf                Outbuf;
11 typedef struct _Outbuf_Region         Outbuf_Region;
12 typedef struct _Xcb_Output_Buffer     Xcb_Output_Buffer;
13
14 typedef enum   _Outbuf_Depth          Outbuf_Depth;
15
16 enum _Outbuf_Depth
17 {
18    OUTBUF_DEPTH_NONE,
19    OUTBUF_DEPTH_INHERIT,
20    OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED,
21    OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED,
22    OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED,
23    OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED,
24    OUTBUF_DEPTH_RGB_32BPP_888_8888,
25    OUTBUF_DEPTH_LAST
26 };
27
28 struct _Outbuf
29 {
30    Outbuf_Depth    depth;
31    int             w, h;
32    int             rot;
33    int             onebuf;
34
35    struct {
36       Convert_Pal *pal;
37       struct {
38          xcb_connection_t  *conn;
39          xcb_screen_t      *screen;
40          xcb_drawable_t     win;
41          xcb_drawable_t     mask;
42          xcb_visualtype_t  *vis;
43          xcb_colormap_t     cmap;
44          int                depth;
45          int                shm;
46          xcb_gcontext_t     gc;
47          xcb_gcontext_t     gcm;
48          unsigned char      swap     : 1;
49          unsigned char      bit_swap : 1;
50       } x;
51       struct {
52          DATA32    r, g, b;
53       } mask;
54
55       /* 1 big buffer for updates - flush on idle_flush */
56       RGBA_Image  *onebuf;
57       Evas_List   *onebuf_regions;
58
59       /* a list of pending regions to write to the target */
60       Evas_List   *pending_writes;
61       /* a list of previous frame pending regions to write to the target */
62       Evas_List   *prev_pending_writes;
63
64       unsigned char mask_dither       : 1;
65       unsigned char destination_alpha : 1;
66       unsigned char debug             : 1;
67       unsigned char synced            : 1;
68    } priv;
69 };
70
71 struct _Outbuf_Region
72 {
73    Xcb_Output_Buffer *xcbob;
74    Xcb_Output_Buffer *mxcbob;
75    int                x;
76    int                y;
77    int                w;
78    int                h;
79 };
80
81 struct _Xcb_Output_Buffer
82 {
83    xcb_connection_t       *connection;
84    xcb_image_t            *image;
85    xcb_shm_segment_info_t *shm_info;
86    void                   *data;
87    int                     w;
88    int                     h;
89    int                     bpl;
90    int                     psize;
91 };
92
93
94 /****/
95 /* main */
96 void               evas_software_xcb_x_init                    (void);
97
98 /* buffer */
99 void               evas_software_xcb_x_write_mask_line         (Outbuf            *buf,
100                                                                 Xcb_Output_Buffer *xcbob,
101                                                                 DATA32            *src,
102                                                                 int                w,
103                                                                 int                y);
104 int                evas_software_xcb_x_can_do_shm              (xcb_connection_t *c,
105                                                                 xcb_screen_t     *screen);
106 Xcb_Output_Buffer *evas_software_xcb_x_output_buffer_new       (xcb_connection_t *c,
107                                                                 int            depth,
108                                                                 int            w,
109                                                                 int            h,
110                                                                 int            try_shm,
111                                                                 void          *data);
112 void               evas_software_xcb_x_output_buffer_free      (Xcb_Output_Buffer *xcbob,
113                                                                 int                sync);
114 void               evas_software_xcb_x_output_buffer_paste     (Xcb_Output_Buffer *xcbob,
115                                                                 xcb_drawable_t        d,
116                                                                 xcb_gcontext_t        gc,
117                                                                 int                x,
118                                                                 int                y,
119                                                                 int                sync);
120 DATA8             *evas_software_xcb_x_output_buffer_data      (Xcb_Output_Buffer *xcbob,
121                                                                 int               *bytes_per_line_ret);
122 int                evas_software_xcb_x_output_buffer_depth     (Xcb_Output_Buffer *xcbob);
123 int                evas_software_xcb_x_output_buffer_byte_order(Xcb_Output_Buffer *xcbob);
124 int                evas_software_xcb_x_output_buffer_bit_order (Xcb_Output_Buffer *xcbob);
125
126
127 /* color */
128 void         evas_software_xcb_x_color_init       (void);
129 Convert_Pal *evas_software_xcb_x_color_allocate   (xcb_connection_t   *conn,
130                                                    xcb_colormap_t      cmap,
131                                                    xcb_visualtype_t   *vis,
132                                                    Convert_Pal_Mode    colors);
133 void         evas_software_xcb_x_color_deallocate (xcb_connection_t *conn,
134                                                    xcb_colormap_t    cmap,
135                                                    xcb_visualtype_t *vis,
136                                                    Convert_Pal      *pal);
137
138 /* outbuf */
139 void         evas_software_xcb_outbuf_init                   (void);
140 void         evas_software_xcb_outbuf_free                   (Outbuf *buf);
141 Outbuf      *evas_software_xcb_outbuf_setup_x                (int               w,
142                                                               int               h,
143                                                               int               rot,
144                                                               Outbuf_Depth      depth,
145                                                               xcb_connection_t *conn,
146                                                               xcb_screen_t     *screen,
147                                                               xcb_drawable_t    draw,
148                                                               xcb_visualtype_t *vis,
149                                                               xcb_colormap_t    cmap,
150                                                               int               x_depth,
151                                                               int               grayscale,
152                                                               int               max_colors,
153                                                               xcb_drawable_t    mask,
154                                                               int               shape_dither,
155                                                               int               destination_alpha);
156 RGBA_Image  *evas_software_xcb_outbuf_new_region_for_update  (Outbuf *buf,
157                                                               int     x,
158                                                               int     y,
159                                                               int     w,
160                                                               int     h,
161                                                               int    *cx,
162                                                               int    *cy,
163                                                               int    *cw,
164                                                               int    *ch);
165 void         evas_software_xcb_outbuf_free_region_for_update (Outbuf    *buf,
166                                                               RGBA_Image *update);
167 void         evas_software_xcb_outbuf_flush                  (Outbuf *buf);
168 void         evas_software_xcb_outbuf_idle_flush             (Outbuf *buf);
169 void         evas_software_xcb_outbuf_push_updated_region    (Outbuf     *buf,
170                                                               RGBA_Image *update,
171                                                               int         x,
172                                                               int         y,
173                                                               int         w,
174                                                               int         h);
175 void         evas_software_xcb_outbuf_reconfigure            (Outbuf      *buf,
176                                                               int          w,
177                                                               int          h,
178                                                               int          rot,
179                                                               Outbuf_Depth depth);
180 int          evas_software_xcb_outbuf_get_width              (Outbuf *buf);
181 int          evas_software_xcb_outbuf_get_height             (Outbuf *buf);
182 Outbuf_Depth evas_software_xcb_outbuf_get_depth              (Outbuf *buf);
183 int          evas_software_xcb_outbuf_get_rot                (Outbuf *buf);
184 void         evas_software_xcb_outbuf_drawable_set           (Outbuf *buf, xcb_drawable_t draw);
185 void         evas_software_xcb_outbuf_mask_set               (Outbuf *buf, xcb_drawable_t mask);
186 void         evas_software_xcb_outbuf_rotation_set           (Outbuf *buf, int rot);
187
188 void         evas_software_xcb_outbuf_debug_set              (Outbuf *buf, int debug);
189 void         evas_software_xcb_outbuf_debug_show             (Outbuf        *buf,
190                                                               xcb_drawable_t draw,
191                                                               int            x,
192                                                               int            y,
193                                                               int            w,
194                                                               int            h);
195
196 #endif /* EVAS_ENGINE_H */