diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/modules/engines/software_16_wince/evas_engine.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/modules/engines/software_16_wince/evas_engine.c')
-rw-r--r-- | libraries/evas/src/modules/engines/software_16_wince/evas_engine.c | 770 |
1 files changed, 770 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/software_16_wince/evas_engine.c b/libraries/evas/src/modules/engines/software_16_wince/evas_engine.c new file mode 100644 index 0000000..74d56e6 --- /dev/null +++ b/libraries/evas/src/modules/engines/software_16_wince/evas_engine.c | |||
@@ -0,0 +1,770 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_private.h" | ||
3 | #include "evas_engine.h" | ||
4 | #include "Evas_Engine_Software_16_WinCE.h" | ||
5 | #include "evas_common_soft16.h" | ||
6 | |||
7 | int _evas_engine_soft16_wince_log_dom = -1; | ||
8 | |||
9 | typedef enum | ||
10 | { | ||
11 | EVAS_ENGINE_WINCE_FB, | ||
12 | EVAS_ENGINE_WINCE_GAPI, | ||
13 | EVAS_ENGINE_WINCE_DDRAW, | ||
14 | EVAS_ENGINE_WINCE_GDI | ||
15 | } Evas_Engine_WinCE_Backend; | ||
16 | |||
17 | |||
18 | /* function tables - filled in later (func and parent func) */ | ||
19 | static Evas_Func func, pfunc; | ||
20 | |||
21 | /* engine struct data */ | ||
22 | typedef struct _Render_Engine Render_Engine; | ||
23 | |||
24 | struct _Render_Engine | ||
25 | { | ||
26 | Evas_Engine_WinCE_Backend backend; /* 1: raw, 2: gapi, 3: ddraw, 4: GDI */ | ||
27 | void *backend_priv; | ||
28 | void (*backend_shutdown)(void *priv); | ||
29 | FB_Output_Buffer *(*backend_output_buffer_new)(void *priv, | ||
30 | int width, | ||
31 | int height); | ||
32 | void (*backend_output_buffer_free)(FB_Output_Buffer *fbob); | ||
33 | void (*backend_output_buffer_paste)(FB_Output_Buffer *fbob); | ||
34 | void (*backend_surface_resize)(FB_Output_Buffer *fbob); | ||
35 | |||
36 | int width; | ||
37 | int height; | ||
38 | int rotation; | ||
39 | Tilebuf *tb; | ||
40 | Tilebuf_Rect *rects; | ||
41 | Tilebuf_Rect *cur_rect; | ||
42 | FB_Output_Buffer *fbob; | ||
43 | Soft16_Image *tmp_out; /* used by indirect render, like rotation */ | ||
44 | HRGN clip_rects; | ||
45 | unsigned char end : 1; | ||
46 | }; | ||
47 | |||
48 | /* prototypes we will use here */ | ||
49 | |||
50 | static void *eng_info(Evas *e); | ||
51 | static void eng_info_free(Evas *e, void *info); | ||
52 | static int eng_setup(Evas *e, void *info); | ||
53 | static void eng_output_free(void *data); | ||
54 | static void eng_output_resize(void *data, int w, int h); | ||
55 | static void eng_output_tile_size_set(void *data, int w, int h); | ||
56 | static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h); | ||
57 | static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h); | ||
58 | static void eng_output_redraws_clear(void *data); | ||
59 | 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); | ||
60 | static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h); | ||
61 | static void eng_output_flush(void *data); | ||
62 | static void eng_output_idle_flush(void *data); | ||
63 | |||
64 | static int | ||
65 | _suspend(int backend) | ||
66 | { | ||
67 | switch (backend) | ||
68 | { | ||
69 | case 2: /* gapi */ | ||
70 | return evas_software_wince_gapi_suspend(); | ||
71 | default: /* other engines do not need it */ | ||
72 | return 0; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static int | ||
77 | _resume(int backend) | ||
78 | { | ||
79 | switch (backend) | ||
80 | { | ||
81 | case 2: /* gapi */ | ||
82 | return evas_software_wince_gapi_resume(); | ||
83 | default: /* other engines do not need it */ | ||
84 | return 0; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | /* engine api this module provides */ | ||
89 | static void * | ||
90 | eng_info(Evas *e) | ||
91 | { | ||
92 | Evas_Engine_Info_Software_16_WinCE *info; | ||
93 | info = calloc(1, sizeof(Evas_Engine_Info_Software_16_WinCE)); | ||
94 | if (!info) return NULL; | ||
95 | info->magic.magic = rand(); | ||
96 | info->func.suspend = _suspend; | ||
97 | info->func.resume = _resume; | ||
98 | info->render_mode = EVAS_RENDER_MODE_BLOCKING; | ||
99 | return info; | ||
100 | e = NULL; | ||
101 | } | ||
102 | |||
103 | static void | ||
104 | eng_info_free(Evas *e, void *info) | ||
105 | { | ||
106 | Evas_Engine_Info_Software_16_WinCE *in; | ||
107 | in = (Evas_Engine_Info_Software_16_WinCE *)info; | ||
108 | free(in); | ||
109 | } | ||
110 | |||
111 | static void | ||
112 | _tmp_out_alloc(Render_Engine *re) | ||
113 | { | ||
114 | Tilebuf_Rect *r; | ||
115 | int w = 0, h = 0; | ||
116 | |||
117 | EINA_INLIST_FOREACH(re->rects, r) | ||
118 | { | ||
119 | if (r->w > w) w = r->w; | ||
120 | if (r->h > h) h = r->h; | ||
121 | } | ||
122 | |||
123 | if (re->tmp_out) | ||
124 | { | ||
125 | if ((re->tmp_out->cache_entry.w < w) || (re->tmp_out->cache_entry.h < h)) | ||
126 | { | ||
127 | evas_cache_image_drop(&re->tmp_out->cache_entry); | ||
128 | re->tmp_out = NULL; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | if (!re->tmp_out) | ||
133 | { | ||
134 | Soft16_Image *im; | ||
135 | |||
136 | im = (Soft16_Image *) evas_cache_image_empty(evas_common_soft16_image_cache_get()); | ||
137 | im->cache_entry.flags.alpha = 0; | ||
138 | evas_cache_image_surface_alloc(&im->cache_entry, w, h); | ||
139 | |||
140 | re->tmp_out = im; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | |||
145 | static int | ||
146 | eng_setup(Evas *e, void *in) | ||
147 | { | ||
148 | Render_Engine *re; | ||
149 | Evas_Engine_Info_Software_16_WinCE *info; | ||
150 | |||
151 | info = (Evas_Engine_Info_Software_16_WinCE *)in; | ||
152 | if (!e->engine.data.output) | ||
153 | { | ||
154 | /* do common routine init - we wil at least use it for core | ||
155 | * image loading and font loading/glyph rendering & placement */ | ||
156 | evas_common_cpu_init(); | ||
157 | |||
158 | evas_common_blend_init(); | ||
159 | evas_common_image_init(); | ||
160 | evas_common_convert_init(); | ||
161 | evas_common_scale_init(); | ||
162 | evas_common_rectangle_init(); | ||
163 | evas_common_polygon_init(); | ||
164 | evas_common_line_init(); | ||
165 | evas_common_font_init(); | ||
166 | evas_common_draw_init(); | ||
167 | evas_common_tilebuf_init(); | ||
168 | evas_common_soft16_image_init(); | ||
169 | |||
170 | /* render engine specific data */ | ||
171 | re = calloc(1, sizeof(Render_Engine)); | ||
172 | if (!re) | ||
173 | return 0; | ||
174 | e->engine.data.output = re; | ||
175 | |||
176 | switch(info->info.backend) | ||
177 | { | ||
178 | case 1: /* FB */ | ||
179 | re->backend = EVAS_ENGINE_WINCE_FB; | ||
180 | re->backend_priv = evas_software_wince_fb_init(info->info.window, info->info.width, info->info.height); | ||
181 | if (!re->backend_priv) | ||
182 | { | ||
183 | free(re); | ||
184 | return 0; | ||
185 | } | ||
186 | re->backend_shutdown = evas_software_wince_fb_shutdown; | ||
187 | re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new; | ||
188 | re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free; | ||
189 | re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste; | ||
190 | re->backend_surface_resize = evas_software_wince_fb_surface_resize; | ||
191 | break; | ||
192 | case 2: /* GAPI */ | ||
193 | re->backend = EVAS_ENGINE_WINCE_GAPI; | ||
194 | re->backend_priv = evas_software_wince_gapi_init(info->info.window, info->info.width, info->info.height); | ||
195 | if (!re->backend_priv) | ||
196 | { | ||
197 | free(re); | ||
198 | return 0; | ||
199 | } | ||
200 | re->backend_shutdown = evas_software_wince_gapi_shutdown; | ||
201 | re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new; | ||
202 | re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free; | ||
203 | re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste; | ||
204 | re->backend_surface_resize = evas_software_wince_gapi_surface_resize; | ||
205 | break; | ||
206 | case 3: /* DirectDraw */ | ||
207 | re->backend = EVAS_ENGINE_WINCE_DDRAW; | ||
208 | re->backend_priv = evas_software_wince_ddraw_init(info->info.window, info->info.width, info->info.height); | ||
209 | if (!re->backend_priv) | ||
210 | { | ||
211 | free(re); | ||
212 | return 0; | ||
213 | } | ||
214 | re->backend_shutdown = evas_software_wince_ddraw_shutdown; | ||
215 | re->backend_output_buffer_new = evas_software_wince_ddraw_output_buffer_new; | ||
216 | re->backend_output_buffer_free = evas_software_wince_ddraw_output_buffer_free; | ||
217 | re->backend_output_buffer_paste = evas_software_wince_ddraw_output_buffer_paste; | ||
218 | re->backend_surface_resize = evas_software_wince_ddraw_surface_resize; | ||
219 | break; | ||
220 | case 4: /* GDI */ | ||
221 | re->backend = EVAS_ENGINE_WINCE_GDI; | ||
222 | re->backend_priv = evas_software_wince_gdi_init(info->info.window, info->info.width, info->info.height, info->info.fullscreen); | ||
223 | if (!re->backend_priv) | ||
224 | { | ||
225 | free(re); | ||
226 | return 0; | ||
227 | } | ||
228 | re->backend_shutdown = evas_software_wince_gdi_shutdown; | ||
229 | re->backend_output_buffer_new = evas_software_wince_gdi_output_buffer_new; | ||
230 | re->backend_output_buffer_free = evas_software_wince_gdi_output_buffer_free; | ||
231 | re->backend_output_buffer_paste = evas_software_wince_gdi_output_buffer_paste; | ||
232 | re->backend_surface_resize = evas_software_wince_gdi_surface_resize; | ||
233 | break; | ||
234 | default: | ||
235 | free(re); | ||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | re->width = e->output.w; | ||
240 | re->height = e->output.h; | ||
241 | re->rotation = info->info.rotation; | ||
242 | re->tb = evas_common_tilebuf_new(e->output.w, e->output.h); | ||
243 | if (re->tb) | ||
244 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | re = e->engine.data.output; | ||
249 | if (re->tb) evas_common_tilebuf_free(re->tb); | ||
250 | |||
251 | switch(info->info.backend) | ||
252 | { | ||
253 | case 1: /* FB */ | ||
254 | re->backend = EVAS_ENGINE_WINCE_FB; | ||
255 | re->backend_priv = evas_software_wince_fb_init(info->info.window, info->info.width, info->info.height); | ||
256 | if (!re->backend_priv) | ||
257 | { | ||
258 | free(re); | ||
259 | return 0; | ||
260 | } | ||
261 | re->backend_shutdown = evas_software_wince_fb_shutdown; | ||
262 | re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new; | ||
263 | re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free; | ||
264 | re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste; | ||
265 | re->backend_surface_resize = evas_software_wince_fb_surface_resize; | ||
266 | break; | ||
267 | case 2: /* GAPI */ | ||
268 | re->backend = EVAS_ENGINE_WINCE_GAPI; | ||
269 | re->backend_priv = evas_software_wince_gapi_init(info->info.window, info->info.width, info->info.height); | ||
270 | if (!re->backend_priv) | ||
271 | { | ||
272 | free(re); | ||
273 | return 0; | ||
274 | } | ||
275 | re->backend_shutdown = evas_software_wince_gapi_shutdown; | ||
276 | re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new; | ||
277 | re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free; | ||
278 | re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste; | ||
279 | re->backend_surface_resize = evas_software_wince_gapi_surface_resize; | ||
280 | break; | ||
281 | case 3: /* DirectDraw */ | ||
282 | re->backend = EVAS_ENGINE_WINCE_DDRAW; | ||
283 | re->backend_priv = evas_software_wince_ddraw_init(info->info.window, info->info.width, info->info.height); | ||
284 | if (!re->backend_priv) | ||
285 | { | ||
286 | free(re); | ||
287 | return 0; | ||
288 | } | ||
289 | re->backend_shutdown = evas_software_wince_ddraw_shutdown; | ||
290 | re->backend_output_buffer_new = evas_software_wince_ddraw_output_buffer_new; | ||
291 | re->backend_output_buffer_free = evas_software_wince_ddraw_output_buffer_free; | ||
292 | re->backend_output_buffer_paste = evas_software_wince_ddraw_output_buffer_paste; | ||
293 | re->backend_surface_resize = evas_software_wince_ddraw_surface_resize; | ||
294 | break; | ||
295 | case 4: /* GDI */ | ||
296 | re->backend = EVAS_ENGINE_WINCE_GDI; | ||
297 | re->backend_priv = evas_software_wince_gdi_init(info->info.window, info->info.width, info->info.height, info->info.fullscreen); | ||
298 | if (!re->backend_priv) | ||
299 | { | ||
300 | free(re); | ||
301 | return 0; | ||
302 | } | ||
303 | re->backend_shutdown = evas_software_wince_gdi_shutdown; | ||
304 | re->backend_output_buffer_new = evas_software_wince_gdi_output_buffer_new; | ||
305 | re->backend_output_buffer_free = evas_software_wince_gdi_output_buffer_free; | ||
306 | re->backend_output_buffer_paste = evas_software_wince_gdi_output_buffer_paste; | ||
307 | re->backend_surface_resize = evas_software_wince_gdi_surface_resize; | ||
308 | break; | ||
309 | default: | ||
310 | free(re); | ||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | re->width = e->output.w; | ||
315 | re->height = e->output.h; | ||
316 | re->rotation = info->info.rotation; | ||
317 | re->tb = evas_common_tilebuf_new(e->output.w, e->output.h); | ||
318 | if (re->tb) | ||
319 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
320 | if (re->tmp_out) | ||
321 | { | ||
322 | evas_cache_image_drop(&re->tmp_out->cache_entry); | ||
323 | re->tmp_out = NULL; | ||
324 | } | ||
325 | } | ||
326 | if (!e->engine.data.output) return 0; | ||
327 | /* add a draw context if we dont have one */ | ||
328 | if (!e->engine.data.context) | ||
329 | e->engine.data.context = | ||
330 | e->engine.func->context_new(e->engine.data.output); | ||
331 | |||
332 | return 1; | ||
333 | } | ||
334 | |||
335 | static void | ||
336 | eng_output_free(void *data) | ||
337 | { | ||
338 | Render_Engine *re; | ||
339 | |||
340 | re = (Render_Engine *)data; | ||
341 | if (re->fbob) re->backend_output_buffer_free(re->backend_priv); | ||
342 | re->backend_shutdown(re->backend_priv); | ||
343 | if (re->clip_rects) DeleteObject(re->clip_rects); | ||
344 | if (re->tb) evas_common_tilebuf_free(re->tb); | ||
345 | if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); | ||
346 | if (re->tmp_out) evas_cache_image_drop(&re->tmp_out->cache_entry); | ||
347 | free(re); | ||
348 | |||
349 | evas_common_font_shutdown(); | ||
350 | evas_common_image_shutdown(); | ||
351 | evas_common_soft16_image_shutdown(); | ||
352 | } | ||
353 | |||
354 | static void | ||
355 | eng_output_resize(void *data, int w, int h) | ||
356 | { | ||
357 | Render_Engine *re; | ||
358 | |||
359 | re = (Render_Engine *)data; | ||
360 | |||
361 | if ((re->width == w) && (re->height == h)) return; | ||
362 | |||
363 | /* FIXME: is it needed ?? */ | ||
364 | if (re->fbob) | ||
365 | re->backend_surface_resize(re->fbob); | ||
366 | |||
367 | evas_common_tilebuf_free(re->tb); | ||
368 | re->width = w; | ||
369 | re->height = h; | ||
370 | re->tb = evas_common_tilebuf_new(w, h); | ||
371 | if (re->tb) | ||
372 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
373 | if (re->fbob) | ||
374 | { | ||
375 | re->backend_output_buffer_free(re->fbob); | ||
376 | re->fbob = NULL; | ||
377 | } | ||
378 | if (re->clip_rects) | ||
379 | { | ||
380 | DeleteObject(re->clip_rects); | ||
381 | re->clip_rects = NULL; | ||
382 | } | ||
383 | if (re->tmp_out) | ||
384 | { | ||
385 | evas_cache_image_drop(&re->tmp_out->cache_entry); | ||
386 | re->tmp_out = NULL; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | static void | ||
391 | eng_output_tile_size_set(void *data, int w, int h) | ||
392 | { | ||
393 | Render_Engine *re; | ||
394 | |||
395 | re = (Render_Engine *)data; | ||
396 | evas_common_tilebuf_set_tile_size(re->tb, w, h); | ||
397 | } | ||
398 | |||
399 | static void | ||
400 | eng_output_redraws_rect_add(void *data, int x, int y, int w, int h) | ||
401 | { | ||
402 | Render_Engine *re; | ||
403 | |||
404 | re = (Render_Engine *)data; | ||
405 | evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); | ||
406 | } | ||
407 | |||
408 | static void | ||
409 | eng_output_redraws_rect_del(void *data, int x, int y, int w, int h) | ||
410 | { | ||
411 | Render_Engine *re; | ||
412 | |||
413 | re = (Render_Engine *)data; | ||
414 | evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); | ||
415 | } | ||
416 | |||
417 | static void | ||
418 | eng_output_redraws_clear(void *data) | ||
419 | { | ||
420 | Render_Engine *re; | ||
421 | |||
422 | re = (Render_Engine *)data; | ||
423 | evas_common_tilebuf_clear(re->tb); | ||
424 | } | ||
425 | |||
426 | static inline void | ||
427 | _output_buffer_alloc(Render_Engine *re) | ||
428 | { | ||
429 | int width; | ||
430 | int height; | ||
431 | |||
432 | if (re->fbob) return; | ||
433 | |||
434 | if ((re->rotation == 0) || (re->rotation == 180)) | ||
435 | { | ||
436 | width = re->width; | ||
437 | height = re->height; | ||
438 | } | ||
439 | else | ||
440 | { | ||
441 | width = re->height; | ||
442 | height = re->width; | ||
443 | } | ||
444 | |||
445 | re->fbob = re->backend_output_buffer_new(re->backend_priv, | ||
446 | width, | ||
447 | height); | ||
448 | } | ||
449 | |||
450 | static void * | ||
451 | eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch) | ||
452 | { | ||
453 | Render_Engine *re; | ||
454 | Tilebuf_Rect *rect; | ||
455 | int ux, uy, uw, uh; | ||
456 | |||
457 | re = (Render_Engine *)data; | ||
458 | if (re->end) | ||
459 | { | ||
460 | re->end = 0; | ||
461 | return NULL; | ||
462 | } | ||
463 | if (!re->rects) | ||
464 | { | ||
465 | re->rects = evas_common_tilebuf_get_render_rects(re->tb); | ||
466 | if (!re->rects) return NULL; | ||
467 | |||
468 | re->cur_rect = re->rects; | ||
469 | _output_buffer_alloc(re); | ||
470 | if (re->rotation != 0) _tmp_out_alloc(re); /* grows if required */ | ||
471 | } | ||
472 | if (!re->cur_rect) | ||
473 | { | ||
474 | if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); | ||
475 | re->rects = NULL; | ||
476 | return NULL; | ||
477 | } | ||
478 | rect = re->cur_rect; | ||
479 | ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h; | ||
480 | re->cur_rect = (Tilebuf_Rect *)((EINA_INLIST_GET(re->cur_rect))->next); | ||
481 | if (!re->cur_rect) | ||
482 | { | ||
483 | evas_common_tilebuf_free_render_rects(re->rects); | ||
484 | re->rects = NULL; | ||
485 | re->end = 1; | ||
486 | } | ||
487 | |||
488 | *x = ux; *y = uy; *w = uw; *h = uh; | ||
489 | if (re->rotation == 0) | ||
490 | { | ||
491 | *cx = ux; *cy = uy; *cw = uw; *ch = uh; | ||
492 | return re->fbob->im; | ||
493 | } | ||
494 | else | ||
495 | { | ||
496 | *cx = 0; *cy = 0; *cw = uw; *ch = uh; | ||
497 | return re->tmp_out; | ||
498 | } | ||
499 | } | ||
500 | |||
501 | static void | ||
502 | _blit_rot_90(Soft16_Image *dst, const Soft16_Image *src, | ||
503 | int out_x, int out_y, int w, int h) | ||
504 | { | ||
505 | DATA16 *dp, *sp; | ||
506 | int x, y; | ||
507 | |||
508 | sp = src->pixels; | ||
509 | dp = dst->pixels + (out_x + | ||
510 | (w + out_y - 1) * dst->stride); | ||
511 | |||
512 | for (y = 0; y < h; y++) | ||
513 | { | ||
514 | DATA16 *dp_itr, *sp_itr; | ||
515 | |||
516 | sp_itr = sp; | ||
517 | dp_itr = dp; | ||
518 | |||
519 | for (x = 0; x < w; x++) | ||
520 | { | ||
521 | *dp_itr = *sp_itr; | ||
522 | |||
523 | sp_itr++; | ||
524 | dp_itr -= dst->stride; | ||
525 | } | ||
526 | sp += src->stride; | ||
527 | dp++; | ||
528 | } | ||
529 | } | ||
530 | |||
531 | static void | ||
532 | _blit_rot_180(Soft16_Image *dst, const Soft16_Image *src, | ||
533 | int out_x, int out_y, int w, int h) | ||
534 | { | ||
535 | DATA16 *dp, *sp; | ||
536 | int x, y; | ||
537 | |||
538 | sp = src->pixels; | ||
539 | dp = dst->pixels + ((w + out_x - 1) + | ||
540 | (h + out_y - 1) * dst->stride); | ||
541 | |||
542 | for (y = 0; y < h; y++) | ||
543 | { | ||
544 | DATA16 *dp_itr, *sp_itr; | ||
545 | |||
546 | sp_itr = sp; | ||
547 | dp_itr = dp; | ||
548 | |||
549 | for (x = 0; x < w; x++) | ||
550 | { | ||
551 | *dp_itr = *sp_itr; | ||
552 | |||
553 | sp_itr++; | ||
554 | dp_itr--; | ||
555 | } | ||
556 | sp += src->stride; | ||
557 | dp -= dst->stride; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | static void | ||
562 | _blit_rot_270(Soft16_Image *dst, const Soft16_Image *src, | ||
563 | int out_x, int out_y, int w, int h) | ||
564 | { | ||
565 | DATA16 *dp, *sp; | ||
566 | int x, y; | ||
567 | |||
568 | sp = src->pixels; | ||
569 | dp = dst->pixels + ((h + out_x - 1) + | ||
570 | out_y * dst->stride); | ||
571 | |||
572 | for (y = 0; y < h; y++) | ||
573 | { | ||
574 | DATA16 *dp_itr, *sp_itr; | ||
575 | |||
576 | sp_itr = sp; | ||
577 | dp_itr = dp; | ||
578 | |||
579 | for (x = 0; x < w; x++) | ||
580 | { | ||
581 | *dp_itr = *sp_itr; | ||
582 | |||
583 | sp_itr++; | ||
584 | dp_itr += dst->stride; | ||
585 | } | ||
586 | sp += src->stride; | ||
587 | dp--; | ||
588 | } | ||
589 | } | ||
590 | |||
591 | static void | ||
592 | _tmp_out_process(Render_Engine *re, int out_x, int out_y, int w, int h) | ||
593 | { | ||
594 | Soft16_Image *d, *s; | ||
595 | |||
596 | d = re->fbob->im; | ||
597 | s = re->tmp_out; | ||
598 | |||
599 | if ((w < 1) || (h < 1) || (out_x >= d->cache_entry.w) || (out_y >= d->cache_entry.h)) | ||
600 | return; | ||
601 | |||
602 | if (re->rotation == 90) | ||
603 | _blit_rot_90(d, s, out_x, out_y, w, h); | ||
604 | else if (re->rotation == 180) | ||
605 | _blit_rot_180(d, s, out_x, out_y, w, h); | ||
606 | else if (re->rotation == 270) | ||
607 | _blit_rot_270(d, s, out_x, out_y, w, h); | ||
608 | } | ||
609 | |||
610 | static void | ||
611 | eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) | ||
612 | { | ||
613 | Render_Engine *re; | ||
614 | HRGN region; | ||
615 | int xx; | ||
616 | int yy; | ||
617 | int width; | ||
618 | int height; | ||
619 | |||
620 | re = (Render_Engine *)data; | ||
621 | |||
622 | if (!re->clip_rects) | ||
623 | re->clip_rects = CreateRectRgn(0, 0, 0, 0); | ||
624 | |||
625 | if (re->rotation == 0) | ||
626 | { | ||
627 | xx = x; | ||
628 | yy = y; | ||
629 | width = w; | ||
630 | height = h; | ||
631 | } | ||
632 | else if (re->rotation == 90) | ||
633 | { | ||
634 | xx = y; | ||
635 | yy = re->width - w - x; | ||
636 | width = h; | ||
637 | height = w; | ||
638 | } | ||
639 | else if (re->rotation == 180) | ||
640 | { | ||
641 | xx = re->width - w - x; | ||
642 | yy = re->height - h - y; | ||
643 | width = w; | ||
644 | height = h; | ||
645 | } | ||
646 | else if (re->rotation == 270) | ||
647 | { | ||
648 | xx = re->height - h - y; | ||
649 | yy = x; | ||
650 | width = h; | ||
651 | height = w; | ||
652 | } | ||
653 | |||
654 | region = CreateRectRgn(xx, yy, xx + width, yy + height); | ||
655 | |||
656 | if (re->rotation != 0) | ||
657 | _tmp_out_process(re, xx, yy, w, h); | ||
658 | CombineRgn(re->clip_rects, re->clip_rects, region, RGN_OR); | ||
659 | } | ||
660 | |||
661 | static void | ||
662 | eng_output_flush(void *data) | ||
663 | { | ||
664 | Render_Engine *re; | ||
665 | |||
666 | re = (Render_Engine *)data; | ||
667 | if (re->clip_rects) | ||
668 | { | ||
669 | /* FIXME : i have to manage that */ | ||
670 | /* XSetRegion(re->disp, re->gc, re->clip_rects); */ | ||
671 | DeleteObject(re->clip_rects); | ||
672 | re->clip_rects = NULL; | ||
673 | } | ||
674 | else return; | ||
675 | |||
676 | re->backend_output_buffer_paste(re->fbob); | ||
677 | |||
678 | /* FIXME : i have to manage that */ | ||
679 | /* XSetClipMask(re->disp, re->gc, None); */ | ||
680 | } | ||
681 | |||
682 | static void | ||
683 | eng_output_idle_flush(void *data) | ||
684 | { | ||
685 | Render_Engine *re; | ||
686 | |||
687 | re = (Render_Engine *)data; | ||
688 | if (re->fbob) | ||
689 | { | ||
690 | re->backend_output_buffer_free(re->fbob); | ||
691 | re->fbob = NULL; | ||
692 | } | ||
693 | if (re->clip_rects) | ||
694 | { | ||
695 | DeleteObject(re->clip_rects); | ||
696 | re->clip_rects = NULL; | ||
697 | } | ||
698 | if (re->tmp_out) | ||
699 | { | ||
700 | evas_cache_image_drop(&re->tmp_out->cache_entry); | ||
701 | re->tmp_out = NULL; | ||
702 | } | ||
703 | } | ||
704 | |||
705 | static Eina_Bool | ||
706 | eng_canvas_alpha_get(void *data, void *context) | ||
707 | { | ||
708 | return EINA_FALSE; | ||
709 | } | ||
710 | |||
711 | /* module advertising code */ | ||
712 | static int | ||
713 | module_open(Evas_Module *em) | ||
714 | { | ||
715 | if (!em) return 0; | ||
716 | /* get whatever engine module we inherit from */ | ||
717 | if (!_evas_module_engine_inherit(&pfunc, "software_16")) return 0; | ||
718 | _evas_engine_soft16_wince_log_dom = eina_log_domain_register | ||
719 | ("evas-software_16_wince", EVAS_DEFAULT_LOG_COLOR); | ||
720 | if (_evas_engine_soft16_wince_log_dom < 0) | ||
721 | { | ||
722 | EINA_LOG_ERR("Can not create a module log domain."); | ||
723 | return 0; | ||
724 | } | ||
725 | |||
726 | /* store it for later use */ | ||
727 | func = pfunc; | ||
728 | /* now to override methods */ | ||
729 | #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) | ||
730 | ORD(info); | ||
731 | ORD(info_free); | ||
732 | ORD(setup); | ||
733 | ORD(canvas_alpha_get); | ||
734 | ORD(output_free); | ||
735 | ORD(output_resize); | ||
736 | ORD(output_tile_size_set); | ||
737 | ORD(output_redraws_rect_add); | ||
738 | ORD(output_redraws_rect_del); | ||
739 | ORD(output_redraws_clear); | ||
740 | ORD(output_redraws_next_update_get); | ||
741 | ORD(output_redraws_next_update_push); | ||
742 | ORD(output_flush); | ||
743 | ORD(output_idle_flush); | ||
744 | /* now advertise out own api */ | ||
745 | em->functions = (void *)(&func); | ||
746 | return 1; | ||
747 | } | ||
748 | |||
749 | static void | ||
750 | module_close(Evas_Module *em) | ||
751 | { | ||
752 | eina_log_domain_unregister(_evas_engine_soft16_wince_log_dom); | ||
753 | } | ||
754 | |||
755 | static Evas_Module_Api evas_modapi = | ||
756 | { | ||
757 | EVAS_MODULE_API_VERSION, | ||
758 | "software_16_wince", | ||
759 | "none", | ||
760 | { | ||
761 | module_open, | ||
762 | module_close | ||
763 | } | ||
764 | }; | ||
765 | |||
766 | EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_16_wince); | ||
767 | |||
768 | #ifndef EVAS_STATIC_BUILD_SOFTWARE_16_WINCE | ||
769 | EVAS_EINA_MODULE_DEFINE(engine, software_16_wince); | ||
770 | #endif | ||