2 #include "evas_common.h"
3 #include "evas_private.h"
4 #include "evas_engine.h"
5 #include "Evas_Engine_Software_Xcb.h"
7 /* function tables - filled in later (func and parent func) */
8 static Evas_Func func, pfunc;
10 /* engine struct data */
11 typedef struct _Render_Engine Render_Engine;
18 Evas_Object_List *cur_rect;
22 /* prototypes we will use here */
23 static void *_output_setup(int w, int h, int rot, xcb_connection_t *conn, xcb_screen_t *screen, xcb_drawable_t draw, xcb_visualtype_t *vis, xcb_colormap_t cmap, int depth, int debug, int grayscale, int max_colors, xcb_drawable_t mask, int shape_dither, int destination_alpha);
24 static xcb_visualtype_t *_best_visual_get(xcb_screen_t *screen);
25 static xcb_colormap_t _best_colormap_get(xcb_screen_t *screen);
26 static int _best_depth_get(xcb_screen_t *screen);
28 static void *eng_info(Evas *e);
29 static void eng_info_free(Evas *e, void *info);
30 static void eng_setup(Evas *e, void *info);
31 static void eng_output_free(void *data);
32 static void eng_output_resize(void *data, int w, int h);
33 static void eng_output_tile_size_set(void *data, int w, int h);
34 static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
35 static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
36 static void eng_output_redraws_clear(void *data);
37 static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
38 static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
39 static void eng_output_flush(void *data);
40 static void eng_output_idle_flush(void *data);
46 xcb_connection_t *conn,
49 xcb_visualtype_t *vis,
57 int destination_alpha)
61 re = calloc(1, sizeof(Render_Engine));
62 /* if we haven't initialized - init (automatic abort if already done) */
63 evas_common_cpu_init();
65 evas_common_blend_init();
66 evas_common_image_init();
67 evas_common_convert_init();
68 evas_common_scale_init();
69 evas_common_rectangle_init();
70 evas_common_gradient_init();
71 evas_common_polygon_init();
72 evas_common_line_init();
73 evas_common_font_init();
74 evas_common_draw_init();
75 evas_common_tilebuf_init();
77 evas_software_xcb_x_init();
78 evas_software_xcb_x_color_init();
79 evas_software_xcb_outbuf_init();
81 re->ob = evas_software_xcb_outbuf_setup_x(w, h, rot,
100 /* for updates return 1 big buffer, but only use portions of it, also cache
101 it and keepit around until an idle_flush */
102 /* disable for now - i am hunting down why some expedite tests are slower,
103 * as well as shaped stuff is broken and probable non-32bpp is broken as
104 * convert funcs dont do the right thing
109 evas_software_xcb_outbuf_debug_set(re->ob, debug);
110 re->tb = evas_common_tilebuf_new(w, h);
113 evas_software_xcb_outbuf_free(re->ob);
117 /* in preliminary tests 16x16 gave highest framerates */
118 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
122 static xcb_visualtype_t *
123 _best_visual_get(xcb_screen_t *screen)
125 xcb_depth_iterator_t iter_depth;
127 if (!screen) return NULL;
129 iter_depth = xcb_screen_allowed_depths_iterator(screen);
130 for (; iter_depth.rem; xcb_depth_next (&iter_depth))
132 xcb_visualtype_iterator_t iter_vis;
134 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
135 for (; iter_vis.rem; xcb_visualtype_next (&iter_vis))
137 if (screen->root_visual == iter_vis.data->visual_id)
138 return iter_vis.data;
145 static xcb_colormap_t
146 _best_colormap_get(xcb_screen_t *screen)
151 return screen->default_colormap;
155 _best_depth_get(xcb_screen_t *screen)
160 return screen->root_depth;
163 /* engine api this module provides */
167 Evas_Engine_Info_Software_Xcb *info;
169 info = calloc(1, sizeof(Evas_Engine_Info_Software_Xcb));
170 if (!info) return NULL;
171 info->magic.magic = rand();
172 info->info.debug = 0;
173 info->info.alloc_grayscale = 0;
174 info->info.alloc_colors_max = 216;
175 info->func.best_visual_get = _best_visual_get;
176 info->func.best_colormap_get = _best_colormap_get;
177 info->func.best_depth_get = _best_depth_get;
183 eng_info_free(Evas *e, void *info)
185 Evas_Engine_Info_Software_Xcb *in;
187 in = (Evas_Engine_Info_Software_Xcb *)info;
192 eng_setup(Evas *e, void *in)
195 Evas_Engine_Info_Software_Xcb *info;
197 info = (Evas_Engine_Info_Software_Xcb *)in;
198 if (!e->engine.data.output)
199 e->engine.data.output =
200 _output_setup(e->output.w,
210 info->info.alloc_grayscale,
211 info->info.alloc_colors_max,
213 info->info.shape_dither,
214 info->info.destination_alpha);
219 re = e->engine.data.output;
220 ponebuf = re->ob->onebuf;
221 evas_software_xcb_outbuf_free(re->ob);
222 re->ob = evas_software_xcb_outbuf_setup_x(e->output.w,
225 OUTBUF_DEPTH_INHERIT,
232 info->info.alloc_grayscale,
233 info->info.alloc_colors_max,
235 info->info.shape_dither,
236 info->info.destination_alpha);
237 evas_software_xcb_outbuf_debug_set(re->ob, info->info.debug);
238 re->ob->onebuf = ponebuf;
241 if (!e->engine.data.output) return;
242 if (!e->engine.data.context)
243 e->engine.data.context =
244 e->engine.func->context_new(e->engine.data.output);
246 re = e->engine.data.output;
247 evas_software_xcb_outbuf_drawable_set(re->ob, info->info.drawable);
248 evas_software_xcb_outbuf_mask_set(re->ob, info->info.mask);
249 evas_software_xcb_outbuf_rotation_set(re->ob, info->info.rotation);
253 eng_output_free(void *data)
259 re = (Render_Engine *)data;
260 evas_software_xcb_outbuf_free(re->ob);
261 evas_common_tilebuf_free(re->tb);
262 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
265 evas_common_font_shutdown();
266 evas_common_image_shutdown();
270 eng_output_resize(void *data, int w, int h)
274 re = (Render_Engine *)data;
275 evas_software_xcb_outbuf_reconfigure(re->ob, w, h,
276 evas_software_xcb_outbuf_get_rot(re->ob),
277 OUTBUF_DEPTH_INHERIT);
278 evas_common_tilebuf_free(re->tb);
279 re->tb = evas_common_tilebuf_new(w, h);
281 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
285 eng_output_tile_size_set(void *data, int w, int h)
289 re = (Render_Engine *)data;
290 evas_common_tilebuf_set_tile_size(re->tb, w, h);
294 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
298 re = (Render_Engine *)data;
299 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
303 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
307 re = (Render_Engine *)data;
308 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
312 eng_output_redraws_clear(void *data)
316 re = (Render_Engine *)data;
317 evas_common_tilebuf_clear(re->tb);
321 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
328 re = (Render_Engine *)data;
336 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
337 re->cur_rect = (Evas_Object_List *)re->rects;
339 if (!re->cur_rect) return NULL;
340 rect = (Tilebuf_Rect *)re->cur_rect;
341 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
342 re->cur_rect = re->cur_rect->next;
345 evas_common_tilebuf_free_render_rects(re->rects);
350 surface = evas_software_xcb_outbuf_new_region_for_update(re->ob,
353 *x = ux; *y = uy; *w = uw; *h = uh;
358 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
362 re = (Render_Engine *)data;
363 evas_common_pipe_begin(surface);
364 evas_common_pipe_flush(surface);
365 evas_software_xcb_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
366 evas_software_xcb_outbuf_free_region_for_update(re->ob, surface);
367 evas_common_cpu_end_opt();
371 eng_output_flush(void *data)
375 re = (Render_Engine *)data;
376 evas_software_xcb_outbuf_flush(re->ob);
380 eng_output_idle_flush(void *data)
384 re = (Render_Engine *)data;
385 evas_software_xcb_outbuf_idle_flush(re->ob);
388 /* module advertising code */
390 module_open(Evas_Module *em)
393 /* get whatever engine module we inherit from */
394 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
395 /* store it for later use */
397 /* now to override methods */
398 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
404 ORD(output_tile_size_set);
405 ORD(output_redraws_rect_add);
406 ORD(output_redraws_rect_del);
407 ORD(output_redraws_clear);
408 ORD(output_redraws_next_update_get);
409 ORD(output_redraws_next_update_push);
411 ORD(output_idle_flush);
412 /* now advertise out own api */
413 em->functions = (void *)(&func);
422 EAPI Evas_Module_Api evas_modapi =
424 EVAS_MODULE_API_VERSION,
425 EVAS_MODULE_TYPE_ENGINE,