aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/software_gdi/evas_engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/modules/engines/software_gdi/evas_engine.c')
-rw-r--r--libraries/evas/src/modules/engines/software_gdi/evas_engine.c387
1 files changed, 387 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/software_gdi/evas_engine.c b/libraries/evas/src/modules/engines/software_gdi/evas_engine.c
new file mode 100644
index 0000000..414e880
--- /dev/null
+++ b/libraries/evas/src/modules/engines/software_gdi/evas_engine.c
@@ -0,0 +1,387 @@
1#include "evas_common.h"
2#include "evas_private.h"
3#include "evas_engine.h"
4#include "Evas_Engine_Software_Gdi.h"
5
6int _evas_engine_soft_gdi_log_dom = -1;
7/* function tables - filled in later (func and parent func) */
8static Evas_Func func, pfunc;
9
10/* engine struct data */
11typedef struct _Render_Engine Render_Engine;
12
13struct _Render_Engine
14{
15 Tilebuf *tb;
16 Outbuf *ob;
17 Tilebuf_Rect *rects;
18 Eina_Inlist *cur_rect;
19 int end : 1;
20};
21
22
23static void *
24_output_setup(int width,
25 int height,
26 int rot,
27 HWND window,
28 int depth,
29 unsigned int borderless,
30 unsigned int fullscreen,
31 unsigned int region)
32{
33 Render_Engine *re;
34
35 re = calloc(1, sizeof(Render_Engine));
36 if (!re)
37 return NULL;
38
39 /* if we haven't initialized - init (automatic abort if already done) */
40 evas_common_cpu_init();
41
42 evas_common_blend_init();
43 evas_common_image_init();
44 evas_common_convert_init();
45 evas_common_scale_init();
46 evas_common_rectangle_init();
47 evas_common_polygon_init();
48 evas_common_line_init();
49 evas_common_font_init();
50 evas_common_draw_init();
51 evas_common_tilebuf_init();
52
53 evas_software_gdi_outbuf_init();
54
55 if (width <= 0)
56 width = 1;
57 if (height <= 0)
58 height = 1;
59
60 re->ob = evas_software_gdi_outbuf_setup(width, height, rot,
61 OUTBUF_DEPTH_INHERIT,
62 window, depth, borderless, fullscreen, region,
63 0, 0);
64 if (!re->ob)
65 {
66 free(re);
67 return NULL;
68 }
69
70 /* for updates return 1 big buffer, but only use portions of it, also cache
71 it and keep it around until an idle_flush */
72 /* disable for now - i am hunting down why some expedite tests are slower,
73 * as well as shaped stuff is broken and probable non-32bpp is broken as
74 * convert funcs dont do the right thing
75 *
76 re->ob->onebuf = 1;
77 */
78
79 re->tb = evas_common_tilebuf_new(width, height);
80 if (!re->tb)
81 {
82 evas_software_gdi_outbuf_free(re->ob);
83 free(re);
84 return NULL;
85 }
86 /* in preliminary tests 16x16 gave highest framerates */
87 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
88
89 return re;
90}
91
92
93/* engine api this module provides */
94
95static void *
96eng_info(Evas *e __UNUSED__)
97{
98 Evas_Engine_Info_Software_Gdi *info;
99 info = calloc(1, sizeof(Evas_Engine_Info_Software_Gdi));
100 if (!info) return NULL;
101 info->magic.magic = rand();
102 return info;
103}
104
105static void
106eng_info_free(Evas *e __UNUSED__, void *info)
107{
108 Evas_Engine_Info_Software_Gdi *in;
109 in = (Evas_Engine_Info_Software_Gdi *)info;
110 free(in);
111}
112
113static int
114eng_setup(Evas *e, void *in)
115{
116 Render_Engine *re;
117 Evas_Engine_Info_Software_Gdi *info;
118
119 info = (Evas_Engine_Info_Software_Gdi *)in;
120 if (!e->engine.data.output)
121 e->engine.data.output = _output_setup(e->output.w,
122 e->output.h,
123 info->info.rotation,
124 info->info.window,
125 info->info.depth,
126 info->info.borderless,
127 info->info.fullscreen,
128 info->info.region);
129 else
130 {
131 int ponebuf = 0;
132
133 re = e->engine.data.output;
134 ponebuf = re->ob->onebuf;
135 evas_software_gdi_outbuf_free(re->ob);
136 re->ob = evas_software_gdi_outbuf_setup(e->output.w,
137 e->output.h,
138 info->info.rotation,
139 OUTBUF_DEPTH_INHERIT,
140 info->info.window,
141 info->info.depth,
142 info->info.borderless,
143 info->info.fullscreen,
144 info->info.region,
145 0, 0);
146 re->ob->onebuf = ponebuf;
147 }
148 if (!e->engine.data.output) return 0;
149 if (!e->engine.data.context)
150 e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
151
152 re = e->engine.data.output;
153
154 return 1;
155}
156
157static void
158eng_output_free(void *data)
159{
160 Render_Engine *re;
161
162 if (!data) return;
163
164 re = (Render_Engine *)data;
165 evas_software_gdi_outbuf_free(re->ob);
166 evas_common_tilebuf_free(re->tb);
167 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
168 free(re);
169
170 evas_common_font_shutdown();
171 evas_common_image_shutdown();
172}
173
174static void
175eng_output_resize(void *data, int width, int height)
176{
177 Render_Engine *re;
178
179 re = (Render_Engine *)data;
180 evas_software_gdi_outbuf_reconfigure(re->ob,
181 width,
182 height,
183 evas_software_gdi_outbuf_rot_get(re->ob),
184 OUTBUF_DEPTH_INHERIT);
185 evas_common_tilebuf_free(re->tb);
186 re->tb = evas_common_tilebuf_new(width, height);
187 if (re->tb)
188 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
189}
190
191static void
192eng_output_tile_size_set(void *data, int w, int h)
193{
194 Render_Engine *re;
195
196 re = (Render_Engine *)data;
197 evas_common_tilebuf_set_tile_size(re->tb, w, h);
198}
199
200static void
201eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
202{
203 Render_Engine *re;
204
205 re = (Render_Engine *)data;
206 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
207}
208
209static void
210eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
211{
212 Render_Engine *re;
213
214 re = (Render_Engine *)data;
215 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
216}
217
218static void
219eng_output_redraws_clear(void *data)
220{
221 Render_Engine *re;
222
223 re = (Render_Engine *)data;
224 evas_common_tilebuf_clear(re->tb);
225}
226
227static void *
228eng_output_redraws_next_update_get(void *data,
229 int *x,
230 int *y,
231 int *w,
232 int *h,
233 int *cx,
234 int *cy,
235 int *cw,
236 int *ch)
237{
238 Render_Engine *re;
239 RGBA_Image *surface;
240 Tilebuf_Rect *rect;
241 int ux;
242 int uy;
243 int uw;
244 int uh;
245
246 re = (Render_Engine *)data;
247 if (re->end)
248 {
249 re->end = 0;
250 return NULL;
251 }
252 if (!re->rects)
253 {
254 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
255 re->cur_rect = EINA_INLIST_GET(re->rects);
256 }
257 if (!re->cur_rect) return NULL;
258 rect = (Tilebuf_Rect *)re->cur_rect;
259 ux = rect->x;
260 uy = rect->y;
261 uw = rect->w;
262 uh = rect->h;
263 re->cur_rect = re->cur_rect->next;
264 if (!re->cur_rect)
265 {
266 evas_common_tilebuf_free_render_rects(re->rects);
267 re->rects = NULL;
268 re->end = 1;
269 }
270
271 surface = evas_software_gdi_outbuf_new_region_for_update(re->ob,
272 ux,
273 uy,
274 uw,
275 uh,
276 cx,
277 cy,
278 cw,
279 ch);
280
281 *x = ux;
282 *y = uy;
283 *w = uw;
284 *h = uh;
285
286 return surface;
287}
288
289static void
290eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
291{
292 Render_Engine *re;
293
294 re = (Render_Engine *)data;
295#ifdef BUILD_PIPE_RENDER
296 evas_common_pipe_map_begin(surface);
297#endif
298 evas_software_gdi_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
299 evas_software_gdi_outbuf_free_region_for_update(re->ob, surface);
300 evas_common_cpu_end_opt();
301}
302
303static void
304eng_output_flush(void *data)
305{
306 Render_Engine *re;
307
308 re = (Render_Engine *)data;
309 evas_software_gdi_outbuf_flush(re->ob);
310}
311
312static void
313eng_output_idle_flush(void *data)
314{
315 Render_Engine *re;
316
317 re = (Render_Engine *)data;
318 evas_software_gdi_outbuf_idle_flush(re->ob);
319}
320
321static Eina_Bool
322eng_canvas_alpha_get(void *data, void *context)
323{
324 return EINA_FALSE;
325}
326
327/* module advertising code */
328static int
329module_open(Evas_Module *em)
330{
331 if (!em) return 0;
332 /* get whatever engine module we inherit from */
333 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
334
335 _evas_engine_soft_gdi_log_dom = eina_log_domain_register
336 ("evas-software_gdi", EVAS_DEFAULT_LOG_COLOR);
337 if (_evas_engine_soft_gdi_log_dom < 0)
338 {
339 EINA_LOG_ERR("Can not create a module log domain.");
340 return 0;
341 }
342 /* store it for later use */
343 func = pfunc;
344 /* now to override methods */
345#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
346 ORD(info);
347 ORD(info_free);
348 ORD(setup);
349 ORD(canvas_alpha_get);
350 ORD(output_free);
351 ORD(output_resize);
352 ORD(output_tile_size_set);
353 ORD(output_redraws_rect_add);
354 ORD(output_redraws_rect_del);
355 ORD(output_redraws_clear);
356 ORD(output_redraws_next_update_get);
357 ORD(output_redraws_next_update_push);
358 ORD(output_flush);
359 ORD(output_idle_flush);
360 /* now advertise out own api */
361 em->functions = (void *)(&func);
362 return 1;
363}
364
365static void
366module_close(Evas_Module *em)
367{
368 eina_log_domain_unregister(_evas_engine_soft_gdi_log_dom);
369 _evas_engine_soft_gdi_log_dom = -1;
370}
371
372static Evas_Module_Api evas_modapi =
373{
374 EVAS_MODULE_API_VERSION,
375 "software_gdi",
376 "none",
377 {
378 module_open,
379 module_close
380 }
381};
382
383EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_gdi);
384
385#ifndef EVAS_STATIC_BUILD_SOFTWARE_GDI
386EVAS_EINA_MODULE_DEFINE(engine, software_gdi);
387#endif