summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-10-10 06:03:42 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-10-10 06:03:42 +0000
commitf91826870daf36209f642cf3b86362f2b8784e97 (patch)
tree7348bfa918076895688606df6ea1f5ebc6c5aa6b
parent34fd7793b02589515beaf85837d8419af2d492e8 (diff)
remove software_16_x11 - danielz! u added it back. it ewas gone from upstream!
SVN revision: 77687
-rw-r--r--legacy/evas/src/modules/engines/software_16_x11/Evas_Engine_Software_16_X11.h26
-rw-r--r--legacy/evas/src/modules/engines/software_16_x11/Makefile.am48
-rw-r--r--legacy/evas/src/modules/engines/software_16_x11/evas_engine.c622
-rw-r--r--legacy/evas/src/modules/engines/software_16_x11/evas_engine.h63
-rw-r--r--legacy/evas/src/modules/engines/software_16_x11/evas_x_buffer.c186
5 files changed, 0 insertions, 945 deletions
diff --git a/legacy/evas/src/modules/engines/software_16_x11/Evas_Engine_Software_16_X11.h b/legacy/evas/src/modules/engines/software_16_x11/Evas_Engine_Software_16_X11.h
deleted file mode 100644
index 9768f0a4fd..0000000000
--- a/legacy/evas/src/modules/engines/software_16_x11/Evas_Engine_Software_16_X11.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef _EVAS_ENGINE_SOFTWARE_16_X11_H
2#define _EVAS_ENGINE_SOFTWARE_16_X11_H
3
4#include <X11/Xlib.h>
5
6typedef struct _Evas_Engine_Info_Software_16_X11 Evas_Engine_Info_Software_16_X11;
7
8struct _Evas_Engine_Info_Software_16_X11
9{
10 /* PRIVATE - don't mess with this baby or evas will poke its tongue out */
11 /* at you and make nasty noises */
12 Evas_Engine_Info magic;
13
14 /* engine specific data & parameters it needs to set up */
15 struct {
16 Display *display;
17 Drawable drawable;
18 int rotation;
19 } info;
20
21 /* non-blocking or blocking mode */
22 Evas_Engine_Render_Mode render_mode;
23};
24#endif
25
26
diff --git a/legacy/evas/src/modules/engines/software_16_x11/Makefile.am b/legacy/evas/src/modules/engines/software_16_x11/Makefile.am
deleted file mode 100644
index 68be01476b..0000000000
--- a/legacy/evas/src/modules/engines/software_16_x11/Makefile.am
+++ /dev/null
@@ -1,48 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_srcdir)/src/lib \
7-I$(top_srcdir)/src/lib/include \
8-I$(top_srcdir)/src/modules/engines \
9-I$(top_srcdir)/src/modules/engines/software_16 \
10@FREETYPE_CFLAGS@ \
11@EVAS_GENERAL_CFLAGS@ \
12@PIXMAN_CFLAGS@ \
13@FRIBIDI_CFLAGS@ \
14@evas_engine_software_16_x11_cflags@
15
16if BUILD_ENGINE_SOFTWARE_16_X11
17
18SOFTWARE_16_X11_SOURCES = \
19evas_engine.c \
20evas_x_buffer.c
21
22SOFTWARE_16_X11_LIBADD = @evas_engine_software_16_x11_libs@
23
24
25includes_HEADERS = Evas_Engine_Software_16_X11.h
26includesdir = $(includedir)/evas-@VMAJ@
27
28if !EVAS_STATIC_BUILD_SOFTWARE_16_X11
29
30pkgdir = $(libdir)/evas/modules/engines/software_16_x11/$(MODULE_ARCH)
31pkg_LTLIBRARIES = module.la
32
33module_la_SOURCES = $(SOFTWARE_16_X11_SOURCES)
34module_la_LIBADD = @EVAS_GENERAL_LIBS@ $(SOFTWARE_16_X11_LIBADD) $(top_builddir)/src/lib/libevas.la
35module_la_LDFLAGS = -no-undefined -module -avoid-version
36module_la_LIBTOOLFLAGS = --tag=disable-static
37
38else
39
40noinst_LTLIBRARIES = libevas_engine_software_16_x11.la
41
42libevas_engine_software_16_x11_la_SOURCES = $(SOFTWARE_16_X11_SOURCES)
43libevas_engine_software_16_x11_la_LIBADD = $(SOFTWARE_16_X11_LIBADD)
44
45endif
46endif
47
48EXTRA_DIST = evas_engine.h
diff --git a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c
deleted file mode 100644
index dfe0fe833f..0000000000
--- a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c
+++ /dev/null
@@ -1,622 +0,0 @@
1#include "evas_common.h"
2#include "evas_private.h"
3#include "evas_engine.h"
4#include "Evas_Engine_Software_16_X11.h"
5#include "evas_common_soft16.h"
6
7int _evas_engine_soft16_x11_log_dom = -1;
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 Display *disp;
17 Drawable draw;
18 GC gc;
19 int w, h, rot;
20 Tilebuf *tb;
21 Tilebuf_Rect *rects;
22 Tilebuf_Rect *cur_rect;
23 X_Output_Buffer *shbuf;
24 Soft16_Image *tmp_out; /* used by indirect render, like rotation */
25 Region clip_rects;
26 unsigned char end : 1;
27 unsigned char shm : 1;
28};
29
30/* prototypes we will use here */
31
32static void *eng_info(Evas *e);
33static void eng_info_free(Evas *e, void *info);
34static int eng_setup(Evas *e, void *info);
35static void eng_output_free(void *data);
36static void eng_output_resize(void *data, int w, int h);
37static void eng_output_tile_size_set(void *data, int w, int h);
38static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
39static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
40static void eng_output_redraws_clear(void *data);
41static 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);
42static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
43static void eng_output_flush(void *data);
44static void eng_output_idle_flush(void *data);
45
46/* engine api this module provides */
47static void *
48eng_info(Evas *e)
49{
50 Evas_Engine_Info_Software_16_X11 *info;
51
52 info = calloc(1, sizeof(Evas_Engine_Info_Software_16_X11));
53 if (!info) return NULL;
54 info->magic.magic = rand();
55 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
56 return info;
57 e = NULL;
58}
59
60static void
61eng_info_free(Evas *e __UNUSED__, void *info)
62{
63 Evas_Engine_Info_Software_16_X11 *in;
64 in = (Evas_Engine_Info_Software_16_X11 *)info;
65 free(in);
66}
67
68static void
69_tmp_out_alloc(Render_Engine *re)
70{
71 Tilebuf_Rect *r;
72 unsigned int w = 0, h = 0;
73
74 EINA_INLIST_FOREACH(re->rects, r)
75 {
76 if (r->w > (int)w) w = r->w;
77 if (r->h > (int)h) h = r->h;
78 }
79
80 if (re->tmp_out)
81 {
82 if ((re->tmp_out->cache_entry.w < w) || (re->tmp_out->cache_entry.h < h))
83 {
84 evas_cache_image_drop(&re->tmp_out->cache_entry);
85 re->tmp_out = NULL;
86 }
87 }
88
89 if (!re->tmp_out)
90 {
91 Soft16_Image *im;
92
93 im = (Soft16_Image *) evas_cache_image_empty(evas_common_soft16_image_cache_get());
94 im->cache_entry.flags.alpha = 0;
95 evas_cache_image_surface_alloc(&im->cache_entry, w, h);
96
97 re->tmp_out = im;
98 }
99}
100
101
102static int
103eng_setup(Evas *eo_e, void *in)
104{
105 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
106 Render_Engine *re;
107 Evas_Engine_Info_Software_16_X11 *info;
108/* X_Output_Buffer *xob; */
109 XGCValues gcv;
110
111 info = (Evas_Engine_Info_Software_16_X11 *)in;
112 if (!e->engine.data.output)
113 {
114 /* the only check - simplistic, i know, but enough for this
115 * "special purpose" engine. Remember it is meant to be used
116 * for limited power devices that have a 16bit display mode
117 * and no real other acceleration, and high resolution so we
118 * can pre-dither into 16bpp. */
119// if (DefaultDepth(info->info.display,
120// DefaultScreen(info->info.display)) != 16)
121// return;
122 /* do common routine init - we wil at least use it for core
123 * image loading and font loading/glyph rendering & placement */
124 evas_common_cpu_init();
125
126 evas_common_blend_init();
127 evas_common_image_init();
128 evas_common_convert_init();
129 evas_common_scale_init();
130 evas_common_rectangle_init();
131 evas_common_polygon_init();
132 evas_common_line_init();
133 evas_common_font_init();
134 evas_common_draw_init();
135 evas_common_tilebuf_init();
136 evas_common_soft16_image_init();
137
138 /* render engine specific data */
139 re = calloc(1, sizeof(Render_Engine));
140 if (!re)
141 return 0;
142 e->engine.data.output = re;
143 re->disp = info->info.display;
144 re->draw = info->info.drawable;
145 re->gc = XCreateGC(re->disp, re->draw, 0, &gcv);
146 re->w = e->output.w;
147 re->h = e->output.h;
148 re->rot = info->info.rotation;
149 re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
150 if (re->tb)
151 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
152 }
153 else
154 {
155 /* we changed the info after first init - do a re-eval where
156 * appropriate */
157// if (DefaultDepth(info->info.display,
158// DefaultScreen(info->info.display)) != 16)
159// return;
160 re = e->engine.data.output;
161 if (re->tb) evas_common_tilebuf_free(re->tb);
162 re->disp = info->info.display;
163 re->draw = info->info.drawable;
164 XFreeGC(re->disp, re->gc);
165 re->gc = XCreateGC(re->disp, re->draw, 0, &gcv);
166 re->w = e->output.w;
167 re->h = e->output.h;
168 re->rot = info->info.rotation;
169 re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
170 if (re->tb)
171 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
172 if (re->tmp_out)
173 {
174 evas_cache_image_drop(&re->tmp_out->cache_entry);
175 re->tmp_out = NULL;
176 }
177 }
178 if (!e->engine.data.output) return 0;
179
180 /* add a draw context if we dont have one */
181 if (!e->engine.data.context)
182 e->engine.data.context =
183 e->engine.func->context_new(e->engine.data.output);
184 /* check if the display can do shm */
185 re->shm = evas_software_16_x11_x_can_do_shm(re->disp);
186
187 return 1;
188}
189
190static void
191eng_output_free(void *data)
192{
193 Render_Engine *re;
194
195 re = (Render_Engine *)data;
196
197 if (re->shbuf) evas_software_16_x11_x_output_buffer_free(re->shbuf, 0);
198 if (re->clip_rects) XDestroyRegion(re->clip_rects);
199 if (re->gc) XFreeGC(re->disp, re->gc);
200 if (re->tb) evas_common_tilebuf_free(re->tb);
201 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
202 if (re->tmp_out) evas_cache_image_drop(&re->tmp_out->cache_entry);
203 free(re);
204
205 evas_common_font_shutdown();
206 evas_common_image_shutdown();
207 evas_common_soft16_image_shutdown();
208}
209
210static void
211eng_output_resize(void *data, int w, int h)
212{
213 Render_Engine *re;
214
215 re = (Render_Engine *)data;
216
217 if ((re->w == w) && (re->h == h)) return;
218
219 evas_common_tilebuf_free(re->tb);
220 re->w = w;
221 re->h = h;
222 re->tb = evas_common_tilebuf_new(w, h);
223 if (re->tb)
224 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
225 if (re->shbuf)
226 {
227 evas_software_16_x11_x_output_buffer_free(re->shbuf, 0);
228 re->shbuf = NULL;
229 }
230 if (re->clip_rects)
231 {
232 XDestroyRegion(re->clip_rects);
233 re->clip_rects = NULL;
234 }
235 if (re->tmp_out)
236 {
237 evas_cache_image_drop(&re->tmp_out->cache_entry);
238 re->tmp_out = NULL;
239 }
240}
241
242static void
243eng_output_tile_size_set(void *data, int w, int h)
244{
245 Render_Engine *re;
246
247 re = (Render_Engine *)data;
248 evas_common_tilebuf_set_tile_size(re->tb, w, h);
249}
250
251static void
252eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
253{
254 Render_Engine *re;
255
256 re = (Render_Engine *)data;
257 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
258}
259
260static void
261eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
262{
263 Render_Engine *re;
264
265 re = (Render_Engine *)data;
266 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
267}
268
269static void
270eng_output_redraws_clear(void *data)
271{
272 Render_Engine *re;
273
274 re = (Render_Engine *)data;
275 evas_common_tilebuf_clear(re->tb);
276}
277
278static inline void
279_output_buffer_alloc(Render_Engine *re)
280{
281 int w, h;
282 if (re->shbuf) return;
283
284 if ((re->rot == 0) || (re->rot == 180))
285 {
286 w = re->w;
287 h = re->h;
288 }
289 else
290 {
291 w = re->h;
292 h = re->w;
293 }
294
295 re->shbuf = evas_software_16_x11_x_output_buffer_new
296 (re->disp, DefaultVisual(re->disp, DefaultScreen(re->disp)),
297 DefaultDepth(re->disp, DefaultScreen(re->disp)),
298 w, h, 1, NULL);
299}
300
301static void *
302eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
303{
304 Render_Engine *re;
305 Tilebuf_Rect *rect;
306 int ux, uy, uw, uh;
307
308 re = (Render_Engine *)data;
309 if (re->end)
310 {
311 re->end = 0;
312 return NULL;
313 }
314 if (!re->rects)
315 {
316 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
317 if (!re->rects) return NULL;
318
319 re->cur_rect = re->rects;
320 _output_buffer_alloc(re);
321 if (re->rot != 0) _tmp_out_alloc(re); /* grows if required */
322 }
323 if (!re->cur_rect)
324 {
325 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
326 re->rects = NULL;
327 return NULL;
328 }
329 rect = re->cur_rect;
330 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
331 re->cur_rect = (Tilebuf_Rect *)((EINA_INLIST_GET(re->cur_rect))->next);
332 if (!re->cur_rect)
333 {
334 evas_common_tilebuf_free_render_rects(re->rects);
335 re->rects = NULL;
336 re->end = 1;
337 }
338
339 *x = ux; *y = uy; *w = uw; *h = uh;
340 if (re->rot == 0)
341 {
342 *cx = ux; *cy = uy; *cw = uw; *ch = uh;
343 return re->shbuf->im;
344 }
345 else
346 {
347 *cx = 0; *cy = 0; *cw = uw; *ch = uh;
348 return re->tmp_out;
349 }
350}
351
352static void
353_blit_rot_90(Soft16_Image *dst, const Soft16_Image *src,
354 int out_x, int out_y, int w, int h)
355{
356 DATA16 *dp, *sp;
357 int x, y;
358
359 sp = src->pixels;
360 dp = dst->pixels + (out_x +
361 (w + out_y - 1) * dst->stride);
362
363 for (y = 0; y < h; y++)
364 {
365 DATA16 *dp_itr, *sp_itr;
366
367 sp_itr = sp;
368 dp_itr = dp;
369
370 for (x = 0; x < w; x++)
371 {
372 *dp_itr = *sp_itr;
373
374 sp_itr++;
375 dp_itr -= dst->stride;
376 }
377 sp += src->stride;
378 dp++;
379 }
380}
381
382static void
383_blit_rot_180(Soft16_Image *dst, const Soft16_Image *src,
384 int out_x, int out_y, int w, int h)
385{
386 DATA16 *dp, *sp;
387 int x, y;
388
389 sp = src->pixels;
390 dp = dst->pixels + ((w + out_x - 1) +
391 (h + out_y - 1) * dst->stride);
392
393 for (y = 0; y < h; y++)
394 {
395 DATA16 *dp_itr, *sp_itr;
396
397 sp_itr = sp;
398 dp_itr = dp;
399
400 for (x = 0; x < w; x++)
401 {
402 *dp_itr = *sp_itr;
403
404 sp_itr++;
405 dp_itr--;
406 }
407 sp += src->stride;
408 dp -= dst->stride;
409 }
410}
411
412static void
413_blit_rot_270(Soft16_Image *dst, const Soft16_Image *src,
414 int out_x, int out_y, int w, int h)
415{
416 DATA16 *dp, *sp;
417 int x, y;
418
419 sp = src->pixels;
420 dp = dst->pixels + ((h + out_x - 1) +
421 out_y * dst->stride);
422
423 for (y = 0; y < h; y++)
424 {
425 DATA16 *dp_itr, *sp_itr;
426
427 sp_itr = sp;
428 dp_itr = dp;
429
430 for (x = 0; x < w; x++)
431 {
432 *dp_itr = *sp_itr;
433
434 sp_itr++;
435 dp_itr += dst->stride;
436 }
437 sp += src->stride;
438 dp--;
439 }
440}
441
442static void
443_tmp_out_process(Render_Engine *re, int out_x, int out_y, int w, int h)
444{
445 Soft16_Image *d, *s;
446
447 d = re->shbuf->im;
448 s = re->tmp_out;
449
450 if ((w < 1) || (h < 1) ||
451 (out_x >= (int)d->cache_entry.w) || (out_y >= (int)d->cache_entry.h))
452 return;
453
454 if (re->rot == 90)
455 _blit_rot_90(d, s, out_x, out_y, w, h);
456 else if (re->rot == 180)
457 _blit_rot_180(d, s, out_x, out_y, w, h);
458 else if (re->rot == 270)
459 _blit_rot_270(d, s, out_x, out_y, w, h);
460}
461
462static void
463eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x, int y, int w, int h)
464{
465 Render_Engine *re;
466 XRectangle r = { 0, 0, 0, 0 };
467
468 re = (Render_Engine *)data;
469
470 if (!re->clip_rects)
471 re->clip_rects = XCreateRegion();
472
473 if (re->rot == 0)
474 {
475 r.x = x;
476 r.y = y;
477 r.width = w;
478 r.height = h;
479 }
480 else if (re->rot == 90)
481 {
482 r.x = y;
483 r.y = re->w - w - x;
484 r.width = h;
485 r.height = w;
486 }
487 else if (re->rot == 180)
488 {
489 r.x = re->w - w - x;
490 r.y = re->h - h - y;
491 r.width = w;
492 r.height = h;
493 }
494 else if (re->rot == 270)
495 {
496 r.x = re->h - h - y;
497 r.y = x;
498 r.width = h;
499 r.height = w;
500 }
501
502 if (re->rot != 0)
503 _tmp_out_process(re, r.x, r.y, w, h);
504 XUnionRectWithRegion(&r, re->clip_rects, re->clip_rects);
505}
506
507static void
508eng_output_flush(void *data)
509{
510 Render_Engine *re;
511
512 re = (Render_Engine *)data;
513 if (re->clip_rects)
514 {
515 XSetRegion(re->disp, re->gc, re->clip_rects);
516 XDestroyRegion(re->clip_rects);
517 re->clip_rects = NULL;
518 }
519 else return;
520
521 evas_software_16_x11_x_output_buffer_paste
522 (re->shbuf, re->draw, re->gc, 0, 0, re->shbuf->im->cache_entry.w, re->shbuf->im->cache_entry.h, 1);
523 XSetClipMask(re->disp, re->gc, None);
524}
525
526static void
527eng_output_idle_flush(void *data)
528{
529 Render_Engine *re;
530
531 re = (Render_Engine *)data;
532 if (re->shbuf)
533 {
534 evas_software_16_x11_x_output_buffer_free(re->shbuf, 0);
535 re->shbuf = NULL;
536 }
537 if (re->clip_rects)
538 {
539 XDestroyRegion(re->clip_rects);
540 re->clip_rects = NULL;
541 }
542 if (re->tmp_out)
543 {
544 evas_cache_image_drop(&re->tmp_out->cache_entry);
545 re->tmp_out = NULL;
546 }
547}
548
549static Eina_Bool
550eng_canvas_alpha_get(void *data __UNUSED__, void *context __UNUSED__)
551{
552 return EINA_FALSE;
553}
554
555/* module advertising code */
556static int
557module_open(Evas_Module *em)
558{
559 static Eina_Bool xrm_inited = EINA_FALSE;
560 if (!xrm_inited)
561 {
562 xrm_inited = EINA_TRUE;
563 XrmInitialize();
564 }
565
566 if (!em) return 0;
567 /* get whatever engine module we inherit from */
568 if (!_evas_module_engine_inherit(&pfunc, "software_16")) return 0;
569 _evas_engine_soft16_x11_log_dom = eina_log_domain_register
570 ("evas-software_16_x11", EVAS_DEFAULT_LOG_COLOR);
571 if (_evas_engine_soft16_x11_log_dom < 0)
572 {
573 EINA_LOG_ERR("Can not create a module log domain.");
574 return 0;
575 }
576
577 /* store it for later use */
578 func = pfunc;
579 /* now to override methods */
580#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
581 ORD(info);
582 ORD(info_free);
583 ORD(setup);
584 ORD(canvas_alpha_get);
585 ORD(output_free);
586 ORD(output_resize);
587 ORD(output_tile_size_set);
588 ORD(output_redraws_rect_add);
589 ORD(output_redraws_rect_del);
590 ORD(output_redraws_clear);
591 ORD(output_redraws_next_update_get);
592 ORD(output_redraws_next_update_push);
593 ORD(output_flush);
594 ORD(output_idle_flush);
595 /* now advertise out own api */
596 em->functions = (void *)(&func);
597 return 1;
598}
599
600static void
601module_close(Evas_Module *em __UNUSED__)
602{
603 eina_log_domain_unregister(_evas_engine_soft16_x11_log_dom);
604}
605
606static Evas_Module_Api evas_modapi =
607{
608 EVAS_MODULE_API_VERSION,
609 "software_16_x11",
610 "none",
611 {
612 module_open,
613 module_close
614 }
615};
616
617EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_16_x11);
618
619#ifndef EVAS_STATIC_BUILD_SOFTWARE_16_X11
620EVAS_EINA_MODULE_DEFINE(engine, software_16_x11);
621#endif
622
diff --git a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h
deleted file mode 100644
index 066ef50243..0000000000
--- a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h
+++ /dev/null
@@ -1,63 +0,0 @@
1#ifndef EVAS_ENGINE_H
2#define EVAS_ENGINE_H
3
4#include <X11/Xlib.h>
5#include <X11/Xutil.h>
6#include <X11/Xatom.h>
7#include <X11/extensions/XShm.h>
8#include <X11/Xresource.h> // xres - dpi
9#include <sys/ipc.h>
10#include <sys/shm.h>
11#include "evas_common.h"
12#include "evas_common_soft16.h"
13
14extern int _evas_engine_soft16_x11_log_dom;
15#ifdef ERR
16# undef ERR
17#endif
18#define ERR(...) EINA_LOG_DOM_ERR(_evas_engine_soft16_x11_log_dom, __VA_ARGS__)
19
20#ifdef DBG
21# undef DBG
22#endif
23#define DBG(...) EINA_LOG_DOM_DBG(_evas_engine_soft16_x11_log_dom, __VA_ARGS__)
24
25#ifdef INF
26# undef INF
27#endif
28#define INF(...) EINA_LOG_DOM_INFO(_evas_engine_soft16_x11_log_dom, __VA_ARGS__)
29
30#ifdef WRN
31# undef WRN
32#endif
33#define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_soft16_x11_log_dom, __VA_ARGS__)
34
35#ifdef CRIT
36# undef CRIT
37#endif
38#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_engine_soft16_x11_log_dom, __VA_ARGS__)
39
40typedef struct _X_Output_Buffer X_Output_Buffer;
41
42struct _X_Output_Buffer
43{
44 Soft16_Image *im;
45 Display *display;
46 XImage *xim;
47 XShmSegmentInfo *shm_info;
48 void *data;
49};
50
51/****/
52void evas_software_16_x11_x_init (void);
53
54int evas_software_16_x11_x_can_do_shm (Display *d);
55X_Output_Buffer *evas_software_16_x11_x_output_buffer_new (Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data);
56void evas_software_16_x11_x_output_buffer_free (X_Output_Buffer *xob, int sync);
57void evas_software_16_x11_x_output_buffer_paste (X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int w, int h, int sync);
58DATA8 *evas_software_16_x11_x_output_buffer_data (X_Output_Buffer *xob, int *bytes_per_line_ret);
59int evas_software_16_x11_x_output_buffer_depth (X_Output_Buffer *xob);
60int evas_software_16_x11_x_output_buffer_byte_order (X_Output_Buffer *xob);
61int evas_software_16_x11_x_output_buffer_bit_order (X_Output_Buffer *xob);
62
63#endif
diff --git a/legacy/evas/src/modules/engines/software_16_x11/evas_x_buffer.c b/legacy/evas/src/modules/engines/software_16_x11/evas_x_buffer.c
deleted file mode 100644
index 32784b05c5..0000000000
--- a/legacy/evas/src/modules/engines/software_16_x11/evas_x_buffer.c
+++ /dev/null
@@ -1,186 +0,0 @@
1#include "evas_common.h"
2#include "evas_engine.h"
3
4static int _x_err = 0;
5
6int
7evas_software_16_x11_x_can_do_shm(Display *d)
8{
9 static Display *cached_d = NULL;
10 static int cached_result = 0;
11
12 if (d == cached_d) return cached_result;
13 cached_d = d;
14 if (XShmQueryExtension(d))
15 {
16 X_Output_Buffer *xob;
17
18 xob = evas_software_16_x11_x_output_buffer_new
19 (d, DefaultVisual(d, DefaultScreen(d)),
20 DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
21 if (!xob)
22 {
23 cached_result = 0;
24 return 0;
25 }
26 evas_software_16_x11_x_output_buffer_free(xob, 1);
27 cached_result = 1;
28 return 1;
29 }
30 cached_result = 0;
31 return 0;
32}
33
34static void
35x_output_tmp_x_err(Display * d __UNUSED__, XErrorEvent * ev __UNUSED__)
36{
37 _x_err = 1;
38 return;
39}
40
41X_Output_Buffer *
42evas_software_16_x11_x_output_buffer_new(Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data)
43{
44 X_Output_Buffer *xob;
45
46 xob = calloc(1, sizeof(X_Output_Buffer));
47 if (!xob) return NULL;
48
49 xob->display = d;
50 xob->xim = NULL;
51 xob->shm_info = NULL;
52
53 if (try_shm > 0)
54 {
55 xob->shm_info = malloc(sizeof(XShmSegmentInfo));
56 if (xob->shm_info)
57 {
58 xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
59 xob->shm_info, w, h);
60 if (xob->xim)
61 {
62 xob->shm_info->shmid = shmget(IPC_PRIVATE,
63 xob->xim->bytes_per_line *
64 xob->xim->height,
65 IPC_CREAT | 0777);
66 if (xob->shm_info->shmid >= 0)
67 {
68 xob->shm_info->readOnly = False;
69 xob->shm_info->shmaddr = xob->xim->data =
70 shmat(xob->shm_info->shmid, 0, 0);
71 if (xob->shm_info->shmaddr)
72 {
73 XErrorHandler ph;
74
75 XSync(d, False);
76 _x_err = 0;
77 ph = XSetErrorHandler((XErrorHandler)
78 x_output_tmp_x_err);
79 XShmAttach(d, xob->shm_info);
80 XSync(d, False);
81 XSetErrorHandler((XErrorHandler)ph);
82 if (!_x_err)
83 {
84 xob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, (DATA32 *) xob->xim->data, 0, EVAS_COLORSPACE_RGB565_A5P);
85 if (xob->im)
86 xob->im->stride = xob->xim->bytes_per_line / sizeof(DATA16);
87 return xob;
88 }
89 }
90 shmdt(xob->shm_info->shmaddr);
91 shmctl(xob->shm_info->shmid, IPC_RMID, 0);
92 }
93 if (xob->xim) XDestroyImage(xob->xim);
94 xob->xim = NULL;
95 }
96 if (xob->shm_info) free(xob->shm_info);
97 xob->shm_info = NULL;
98 }
99 }
100
101 if (try_shm > 1) return NULL;
102
103 xob->xim = XCreateImage(d, v, depth, ZPixmap, 0, data, w, h, 32, 0);
104 if (!xob->xim)
105 {
106 free(xob);
107 return NULL;
108 }
109
110 xob->data = data;
111
112 if (!xob->xim->data)
113 {
114 xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
115 if (!xob->xim->data)
116 {
117 XDestroyImage(xob->xim);
118 free(xob);
119 return NULL;
120 }
121 }
122 if (xob->im)
123 evas_cache_image_drop(&xob->im->cache_entry);
124
125 xob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, (DATA32 *) xob->xim->data, 0, EVAS_COLORSPACE_RGB565_A5P);
126 if (xob->im)
127 xob->im->stride = xob->xim->bytes_per_line / sizeof(DATA16);
128 return xob;
129}
130
131void
132evas_software_16_x11_x_output_buffer_free(X_Output_Buffer *xob, int sync)
133{
134 if (xob->shm_info)
135 {
136 if (sync) XSync(xob->display, False);
137 XShmDetach(xob->display, xob->shm_info);
138 XDestroyImage(xob->xim);
139 shmdt(xob->shm_info->shmaddr);
140 shmctl(xob->shm_info->shmid, IPC_RMID, 0);
141 free(xob->shm_info);
142 }
143 else
144 {
145 if (xob->data) xob->xim->data = NULL;
146 XDestroyImage(xob->xim);
147 }
148 free(xob);
149}
150
151void
152evas_software_16_x11_x_output_buffer_paste(X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int w, int h, int sync)
153{
154 if (xob->shm_info)
155 {
156 XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y, w, h, False);
157 if (sync) XSync(xob->display, False);
158 }
159 else
160 XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y, w, h);
161}
162
163DATA8 *
164evas_software_16_x11_x_output_buffer_data(X_Output_Buffer *xob, int *bytes_per_line_ret)
165{
166 if (bytes_per_line_ret) *bytes_per_line_ret = xob->xim->bytes_per_line;
167 return (DATA8*) xob->xim->data;
168}
169
170int
171evas_software_16_x11_x_output_buffer_depth(X_Output_Buffer *xob)
172{
173 return xob->xim->bits_per_pixel;
174}
175
176int
177evas_software_16_x11_x_output_buffer_byte_order(X_Output_Buffer *xob)
178{
179 return xob->xim->byte_order;
180}
181
182int
183evas_software_16_x11_x_output_buffer_bit_order(X_Output_Buffer *xob)
184{
185 return xob->xim->bitmap_bit_order;
186}