1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_engine.h"
4 #include "Evas_Engine_Software_X11.h"
6 /* function tables - filled in later (func and parent func) */
7 static Evas_Func func, pfunc;
9 /* engine struct data */
10 typedef struct _Render_Engine Render_Engine;
17 Evas_Object_List *cur_rect;
21 /* prototypes we will use here */
22 static void *_output_setup(int w, int h, int rot, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth, int debug, int grayscale, int max_colors, Pixmap mask, int shape_dither, int destination_alpha);
23 static Visual *_best_visual_get(Display *disp, int screen);
24 static Colormap _best_colormap_get(Display *disp, int screen);
25 static int _best_depth_get(Display *disp, int screen);
27 static void *eng_info(Evas *e);
28 static void eng_info_free(Evas *e, void *info);
29 static void eng_setup(Evas *e, void *info);
30 static void eng_output_free(void *data);
31 static void eng_output_resize(void *data, int w, int h);
32 static void eng_output_tile_size_set(void *data, int w, int h);
33 static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
34 static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
35 static void eng_output_redraws_clear(void *data);
36 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);
37 static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
38 static void eng_output_flush(void *data);
39 static void eng_output_idle_flush(void *data);
41 /* internal engine routines */
43 _output_setup(int w, int h, int rot, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth, int debug, int grayscale, int max_colors, Pixmap mask, int shape_dither, int destination_alpha)
47 re = calloc(1, sizeof(Render_Engine));
48 /* if we haven't initialized - init (automatic abort if already done) */
49 evas_common_cpu_init();
51 evas_common_blend_init();
52 evas_common_image_init();
53 evas_common_convert_init();
54 evas_common_scale_init();
55 evas_common_rectangle_init();
56 evas_common_gradient_init();
57 evas_common_polygon_init();
58 evas_common_line_init();
59 evas_common_font_init();
60 evas_common_draw_init();
61 evas_common_tilebuf_init();
63 evas_software_x11_x_init();
64 evas_software_x11_x_color_init();
65 evas_software_x11_outbuf_init();
67 re->ob = evas_software_x11_outbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT,
68 disp, draw, vis, cmap, depth,
69 grayscale, max_colors, mask,
70 shape_dither, destination_alpha);
77 /* for updates return 1 big buffer, but only use portions of it, also cache
78 it and keepit around until an idle_flush */
79 /* disable for now - i am hunting down why some expedite tests are slower,
80 * as well as shaped stuff is broken and probable non-32bpp is broken as
81 * convert funcs dont do the right thing
86 evas_software_x11_outbuf_debug_set(re->ob, debug);
87 re->tb = evas_common_tilebuf_new(w, h);
90 evas_software_x11_outbuf_free(re->ob);
94 /* in preliminary tests 16x16 gave highest framerates */
95 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
100 _best_visual_get(Display *disp, int screen)
102 if (!disp) return NULL;
103 return DefaultVisual(disp, screen);
107 _best_colormap_get(Display *disp, int screen)
110 return DefaultColormap(disp, screen);
114 _best_depth_get(Display *disp, int screen)
117 return DefaultDepth(disp, screen);
120 /* engine api this module provides */
124 Evas_Engine_Info_Software_X11 *info;
126 info = calloc(1, sizeof(Evas_Engine_Info_Software_X11));
127 if (!info) return NULL;
128 info->magic.magic = rand();
129 info->info.debug = 0;
130 info->info.alloc_grayscale = 0;
131 info->info.alloc_colors_max = 216;
132 info->func.best_visual_get = _best_visual_get;
133 info->func.best_colormap_get = _best_colormap_get;
134 info->func.best_depth_get = _best_depth_get;
140 eng_info_free(Evas *e, void *info)
142 Evas_Engine_Info_Software_X11 *in;
144 in = (Evas_Engine_Info_Software_X11 *)info;
149 eng_setup(Evas *e, void *in)
152 Evas_Engine_Info_Software_X11 *info;
154 info = (Evas_Engine_Info_Software_X11 *)in;
155 if (!e->engine.data.output)
156 e->engine.data.output =
157 _output_setup(e->output.w,
166 info->info.alloc_grayscale,
167 info->info.alloc_colors_max,
169 info->info.shape_dither,
170 info->info.destination_alpha);
175 re = e->engine.data.output;
176 ponebuf = re->ob->onebuf;
177 evas_software_x11_outbuf_free(re->ob);
178 re->ob = evas_software_x11_outbuf_setup_x(e->output.w,
181 OUTBUF_DEPTH_INHERIT,
187 info->info.alloc_grayscale,
188 info->info.alloc_colors_max,
190 info->info.shape_dither,
191 info->info.destination_alpha);
192 evas_software_x11_outbuf_debug_set(re->ob, info->info.debug);
193 re->ob->onebuf = ponebuf;
195 if (!e->engine.data.output) return;
196 if (!e->engine.data.context)
197 e->engine.data.context =
198 e->engine.func->context_new(e->engine.data.output);
200 re = e->engine.data.output;
201 evas_software_x11_outbuf_drawable_set(re->ob, info->info.drawable);
202 evas_software_x11_outbuf_mask_set(re->ob, info->info.mask);
203 evas_software_x11_outbuf_rotation_set(re->ob, info->info.rotation);
207 eng_output_free(void *data)
213 re = (Render_Engine *)data;
214 evas_software_x11_outbuf_free(re->ob);
215 evas_common_tilebuf_free(re->tb);
216 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
219 evas_common_font_shutdown();
220 evas_common_image_shutdown();
224 eng_output_resize(void *data, int w, int h)
228 re = (Render_Engine *)data;
229 evas_software_x11_outbuf_reconfigure(re->ob, w, h,
230 evas_software_x11_outbuf_get_rot(re->ob),
231 OUTBUF_DEPTH_INHERIT);
232 evas_common_tilebuf_free(re->tb);
233 re->tb = evas_common_tilebuf_new(w, h);
235 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
239 eng_output_tile_size_set(void *data, int w, int h)
243 re = (Render_Engine *)data;
244 evas_common_tilebuf_set_tile_size(re->tb, w, h);
248 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
252 re = (Render_Engine *)data;
253 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
257 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
261 re = (Render_Engine *)data;
262 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
266 eng_output_redraws_clear(void *data)
270 re = (Render_Engine *)data;
271 evas_common_tilebuf_clear(re->tb);
275 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
282 re = (Render_Engine *)data;
290 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
291 re->cur_rect = (Evas_Object_List *)re->rects;
293 if (!re->cur_rect) return NULL;
294 rect = (Tilebuf_Rect *)re->cur_rect;
295 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
296 re->cur_rect = re->cur_rect->next;
299 evas_common_tilebuf_free_render_rects(re->rects);
304 surface = evas_software_x11_outbuf_new_region_for_update
305 (re->ob, ux, uy, uw, uh, cx, cy, cw, ch);
306 *x = ux; *y = uy; *w = uw; *h = uh;
311 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
315 re = (Render_Engine *)data;
316 evas_common_pipe_begin(surface);
317 evas_common_pipe_flush(surface);
318 evas_software_x11_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
319 evas_software_x11_outbuf_free_region_for_update(re->ob, surface);
320 evas_common_cpu_end_opt();
324 eng_output_flush(void *data)
328 re = (Render_Engine *)data;
329 evas_software_x11_outbuf_flush(re->ob);
333 eng_output_idle_flush(void *data)
337 re = (Render_Engine *)data;
338 evas_software_x11_outbuf_idle_flush(re->ob);
342 /* module advertising code */
344 module_open(Evas_Module *em)
347 /* get whatever engine module we inherit from */
348 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
349 /* store it for later use */
351 /* now to override methods */
352 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
358 ORD(output_tile_size_set);
359 ORD(output_redraws_rect_add);
360 ORD(output_redraws_rect_del);
361 ORD(output_redraws_clear);
362 ORD(output_redraws_next_update_get);
363 ORD(output_redraws_next_update_push);
365 ORD(output_idle_flush);
366 /* now advertise out own api */
367 em->functions = (void *)(&func);
376 EAPI Evas_Module_Api evas_modapi =
378 EVAS_MODULE_API_VERSION,
379 EVAS_MODULE_TYPE_ENGINE,