aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/fb/evas_engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/modules/engines/fb/evas_engine.c')
-rw-r--r--libraries/evas/src/modules/engines/fb/evas_engine.c317
1 files changed, 317 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/fb/evas_engine.c b/libraries/evas/src/modules/engines/fb/evas_engine.c
new file mode 100644
index 0000000..7681b00
--- /dev/null
+++ b/libraries/evas/src/modules/engines/fb/evas_engine.c
@@ -0,0 +1,317 @@
1#include "evas_common.h"
2#include "evas_private.h"
3#include "evas_engine.h"
4#include "Evas_Engine_FB.h"
5
6int _evas_engine_fb_log_dom = -1;
7
8/* function tables - filled in later (func and parent func) */
9static Evas_Func func, pfunc;
10
11/* engine struct data */
12typedef struct _Render_Engine Render_Engine;
13
14struct _Render_Engine
15{
16 Tilebuf *tb;
17 Outbuf *ob;
18 Tilebuf_Rect *rects;
19 Eina_Inlist *cur_rect;
20 int end : 1;
21};
22
23/* prototypes we will use here */
24static void *_output_setup(int w, int h, int rot, int vt, int dev, int refresh);
25
26static void *eng_info(Evas *e);
27static void eng_info_free(Evas *e, void *info);
28static int eng_setup(Evas *e, void *info);
29static void eng_output_free(void *data);
30static void eng_output_resize(void *data, int w, int h);
31static void eng_output_tile_size_set(void *data, int w, int h);
32static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
33static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
34static void eng_output_redraws_clear(void *data);
35static 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);
36static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
37static void eng_output_flush(void *data);
38static void eng_output_idle_flush(void *data);
39
40/* internal engine routines */
41static void *
42_output_setup(int w, int h, int rot, int vt, int dev, int refresh)
43{
44 Render_Engine *re;
45
46 re = calloc(1, sizeof(Render_Engine));
47 if (!re)
48 return NULL;
49 /* if we haven't initialized - init (automatic abort if already done) */
50 evas_common_cpu_init();
51
52 evas_common_blend_init();
53 evas_common_image_init();
54 evas_common_convert_init();
55 evas_common_scale_init();
56 evas_common_rectangle_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();
62
63 evas_fb_outbuf_fb_init();
64
65 /* get any stored performance metrics from device (xserver) */
66 re->ob = evas_fb_outbuf_fb_setup_fb(w, h, rot, OUTBUF_DEPTH_INHERIT, vt, dev, refresh);
67 re->tb = evas_common_tilebuf_new(evas_fb_outbuf_fb_get_width(re->ob), evas_fb_outbuf_fb_get_height(re->ob));
68 /* no backbuf! */
69 evas_fb_outbuf_fb_set_have_backbuf(re->ob, 0);
70 /* in preliminary tests 16x16 gave highest framerates */
71 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
72 return re;
73}
74
75/* engine api this module provides */
76static void *
77eng_info(Evas *e)
78{
79 Evas_Engine_Info_FB *info;
80 info = calloc(1, sizeof(Evas_Engine_Info_FB));
81 if (!info) return NULL;
82 info->magic.magic = rand();
83 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
84 return info;
85 e = NULL;
86}
87
88static void
89eng_info_free(Evas *e __UNUSED__, void *info)
90{
91 Evas_Engine_Info_FB *in;
92 in = (Evas_Engine_Info_FB *)info;
93 free(in);
94}
95
96static int
97eng_setup(Evas *e, void *in)
98{
99 Render_Engine *re;
100 Evas_Engine_Info_FB *info;
101
102 info = (Evas_Engine_Info_FB *)in;
103 re = _output_setup(e->output.w,
104 e->output.h,
105 info->info.rotation,
106 info->info.virtual_terminal,
107 info->info.device_number,
108 info->info.refresh);
109 e->engine.data.output = re;
110 if (!e->engine.data.output) return 0;
111 e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
112
113 return 1;
114}
115
116static void
117eng_output_free(void *data)
118{
119 Render_Engine *re;
120
121 re = (Render_Engine *)data;
122 evas_fb_outbuf_fb_free(re->ob);
123 evas_common_tilebuf_free(re->tb);
124 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
125 free(re);
126
127 evas_common_font_shutdown();
128 evas_common_image_shutdown();
129}
130
131static void
132eng_output_resize(void *data, int w, int h)
133{
134 Render_Engine *re;
135
136 re = (Render_Engine *)data;
137 evas_fb_outbuf_fb_reconfigure(re->ob, w, h,
138 evas_fb_outbuf_fb_get_rot(re->ob),
139 OUTBUF_DEPTH_INHERIT);
140 evas_common_tilebuf_free(re->tb);
141 re->tb = evas_common_tilebuf_new(w, h);
142 if (re->tb)
143 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
144}
145
146static void
147eng_output_tile_size_set(void *data, int w, int h)
148{
149 Render_Engine *re;
150
151 re = (Render_Engine *)data;
152 evas_common_tilebuf_set_tile_size(re->tb, w, h);
153}
154
155static void
156eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
157{
158 Render_Engine *re;
159
160 re = (Render_Engine *)data;
161 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
162}
163
164static void
165eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
166{
167 Render_Engine *re;
168
169 re = (Render_Engine *)data;
170 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
171}
172
173static void
174eng_output_redraws_clear(void *data)
175{
176 Render_Engine *re;
177
178 re = (Render_Engine *)data;
179 evas_common_tilebuf_clear(re->tb);
180}
181
182static void *
183eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
184{
185 Render_Engine *re;
186 RGBA_Image *surface;
187 Tilebuf_Rect *rect;
188 int ux, uy, uw, uh;
189
190 re = (Render_Engine *)data;
191 if (re->end)
192 {
193 re->end = 0;
194 return NULL;
195 }
196 if (!re->rects)
197 {
198 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
199 re->cur_rect = EINA_INLIST_GET(re->rects);
200 }
201 if (!re->cur_rect) return NULL;
202 rect = (Tilebuf_Rect *)re->cur_rect;
203 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
204 re->cur_rect = re->cur_rect->next;
205 if (!re->cur_rect)
206 {
207 evas_common_tilebuf_free_render_rects(re->rects);
208 re->rects = NULL;
209 re->end = 1;
210 }
211
212 surface = evas_fb_outbuf_fb_new_region_for_update(re->ob,
213 ux, uy, uw, uh,
214 cx, cy, cw, ch);
215 *x = ux; *y = uy; *w = uw; *h = uh;
216 return surface;
217}
218
219static void
220eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
221{
222 Render_Engine *re;
223
224 re = (Render_Engine *)data;
225#ifdef BUILD_PIPE_RENDER
226 evas_common_pipe_map_begin(surface);
227#endif
228 evas_fb_outbuf_fb_push_updated_region(re->ob, surface, x, y, w, h);
229 evas_fb_outbuf_fb_free_region_for_update(re->ob, surface);
230 evas_common_cpu_end_opt();
231}
232
233static void
234eng_output_flush(void *data)
235{
236 Render_Engine *re;
237
238 re = (Render_Engine *)data;
239}
240
241static void
242eng_output_idle_flush(void *data)
243{
244 Render_Engine *re;
245
246 re = (Render_Engine *)data;
247}
248
249static Eina_Bool
250eng_canvas_alpha_get(void *data, void *context __UNUSED__)
251{
252 Render_Engine *re;
253
254 re = (Render_Engine *)data;
255 return (re->ob->priv.fb.fb->fb_var.transp.length > 0);
256}
257
258/* module advertising code */
259static int
260module_open(Evas_Module *em)
261{
262 if (!em) return 0;
263 /* get whatever engine module we inherit from */
264 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
265 _evas_engine_fb_log_dom = eina_log_domain_register
266 ("evas-fb", EVAS_DEFAULT_LOG_COLOR);
267 if (_evas_engine_fb_log_dom < 0)
268 {
269 EINA_LOG_ERR("Can not create a module log domain.");
270 return 0;
271 }
272
273 /* store it for later use */
274 func = pfunc;
275 /* now to override methods */
276#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
277 ORD(info);
278 ORD(info_free);
279 ORD(setup);
280 ORD(canvas_alpha_get);
281 ORD(output_free);
282 ORD(output_resize);
283 ORD(output_tile_size_set);
284 ORD(output_redraws_rect_add);
285 ORD(output_redraws_rect_del);
286 ORD(output_redraws_clear);
287 ORD(output_redraws_next_update_get);
288 ORD(output_redraws_next_update_push);
289 ORD(output_flush);
290 ORD(output_idle_flush);
291 /* now advertise out own api */
292 em->functions = (void *)(&func);
293 return 1;
294}
295
296static void
297module_close(Evas_Module *em __UNUSED__)
298{
299 eina_log_domain_unregister(_evas_engine_fb_log_dom);
300}
301
302static Evas_Module_Api evas_modapi =
303{
304 EVAS_MODULE_API_VERSION,
305 "fb",
306 "none",
307 {
308 module_open,
309 module_close
310 }
311};
312
313EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, fb);
314
315#ifndef EVAS_STATIC_BUILD_FB
316EVAS_EINA_MODULE_DEFINE(engine, fb);
317#endif