SVN revision: 13822
This commit is contained in:
doursse 2005-03-20 23:44:22 +00:00 committed by doursse
parent 7858393939
commit 2b2a800ad6
19 changed files with 4587 additions and 2 deletions

View File

@ -92,6 +92,9 @@ AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source Code Director
x_dir=""
x_cflags=""
x_libs=""
xcb_dir=""
xcb_cflags=""
xcb_libs=""
gl_dir=""
gl_cflags=""
gl_libs=""
@ -170,6 +173,69 @@ else
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_X11, false)
fi
#######################################
## Check if we should build the software_xcb engine
have_evas_software_xcb="no";
ENGINE_SOFTWARE_XCB_PRG="";
## Automatic check...
PKG_CHECK_MODULES(
XCB,
xcb-image,
[AC_CHECK_HEADER(
X11/X.h,
[have_evas_software_xcb="yes"],
[have_evas_software_xcb="no"])],
[ have_evas_software_xcb="no" ])
PKG_CHECK_MODULES(
XCB_ICCCM,
xcb-icccm,
[ have_evas_software_xcb="yes" ],
[ have_evas_software_xcb="no" ])
## Manual override
AC_MSG_CHECKING(whether software xcb backend is to be built)
AC_ARG_ENABLE(software-xcb, [ --enable-software-xcb enable the Software XCB rendering backend], [
if [ test "$enableval" = "yes" ]; then
AC_MSG_RESULT(yes)
have_evas_software_xcb="yes"
else
AC_MSG_RESULT(no)
have_evas_software_xcb="no"
fi
], [
AC_MSG_RESULT($have_evas_software_xcb)
]
)
if test "x$have_evas_software_xcb" = "xyes"; then
AC_PATH_XTRA
PKG_CHECK_MODULES(
XCB_ICCCM,
xcb-icccm)
PKG_CHECK_MODULES(
XCB,
xcb-image,
[AC_CHECK_HEADER(
X11/X.h,
[AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_XCB, true)
AC_DEFINE(BUILD_ENGINE_SOFTWARE_XCB, 1, [Software XCB Rendering Backend])
xcb_dir=${x_dir:-/usr/X11R6}
xcb_cflags="${x_cflags:--I${x_includes:-$x_dir/include}} $XCB_CFLAGS $XCB_ICCCM_CFLAGS"
xcb_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} $XCB_LIBS $XCB_ICCCM_LIBS"
ENGINE_SOFTWARE_XCB_PRG="evas_software_xcb_test evas_software_xcb_perf_test evas_software_xcb_perf_load"],
[AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_XCB, false)
AC_MSG_RESULT(disabling software XCB engine)
have_evas_software_xcb="no"])],
[AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_XCB, false)
AC_MSG_RESULT(disabling software XCB engine)
have_evas_software_xcb="no" ])
else
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_XCB, false)
fi
#######################################
## Check if we should build the directfb engine
have_evas_directfb="no";
@ -1413,6 +1479,9 @@ AC_SUBST(freetype_libs)
AC_SUBST(x_cflags)
AC_SUBST(x_libs)
AC_SUBST(xcb_cflags)
AC_SUBST(xcb_libs)
AC_SUBST(gl_cflags)
AC_SUBST(gl_libs)
@ -1443,6 +1512,7 @@ fi
AC_SUBST(requirements)
AC_SUBST(ENGINE_SOFTWARE_X11_PRG)
AC_SUBST(ENGINE_SOFTWARE_XCB_PRG)
AC_SUBST(ENGINE_DIRECTFB_PRG)
AC_SUBST(ENGINE_FB_PRG)
AC_SUBST(ENGINE_BUFFER_PRG)
@ -1470,6 +1540,7 @@ src/lib/imaging/Makefile
src/lib/engines/Makefile
src/lib/engines/common/Makefile
src/lib/engines/software_x11/Makefile
src/lib/engines/software_xcb/Makefile
src/lib/engines/fb/Makefile
src/lib/engines/buffer/Makefile
src/lib/engines/software_win32_gdi/Makefile
@ -1509,6 +1580,7 @@ echo "Configuration Options Summary:"
echo
echo "Engines:"
echo " Software X11............: $have_evas_software_x11"
echo " Software XCB............: $have_evas_software_xcb"
echo " Software Framebuffer....: $have_evas_fb"
echo " Software Qtopia.........: $have_evas_qtopia"
echo " Software Memory Buffer..: $have_evas_buffer"

View File

@ -6,6 +6,7 @@ INCLUDES = \
bin_PROGRAMS = \
@ENGINE_SOFTWARE_X11_PRG@ \
@ENGINE_SOFTWARE_XCB_PRG@ \
@ENGINE_DIRECTFB_PRG@ \
@ENGINE_FB_PRG@ \
@ENGINE_BUFFER_PRG@ \
@ -17,6 +18,9 @@ EXTRA_PROGRAMS = \
evas_software_x11_test \
evas_software_x11_perf_test \
evas_software_x11_perf_load \
evas_software_xcb_test \
evas_software_xcb_perf_test \
evas_software_xcb_perf_load \
evas_directfb_test \
evas_directfb_window \
evas_fb_test \
@ -42,6 +46,21 @@ evas_software_x11_perf_load_LDADD = $(top_builddir)/src/lib/libevas.la -lm @x_li
evas_software_x11_perf_load_CFLAGS = $(CFLAGS) @x_cflags@
evas_software_x11_perf_load_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
evas_software_xcb_test_SOURCES = evas_test_main.h evas_test_main.c evas_software_xcb_main.c
evas_software_xcb_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm @xcb_libs@
evas_software_xcb_test_CFLAGS = $(CFLAGS) @xcb_cflags@
evas_software_xcb_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
evas_software_xcb_perf_test_SOURCES = evas_software_xcb_perf_test.c
evas_software_xcb_perf_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm @xcb_libs@
evas_software_xcb_perf_test_CFLAGS = $(CFLAGS) @xcb_cflags@
evas_software_xcb_perf_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
evas_software_xcb_perf_load_SOURCES = evas_software_xcb_perf_load.c
evas_software_xcb_perf_load_LDADD = $(top_builddir)/src/lib/libevas.la -lm @xcb_libs@
evas_software_xcb_perf_load_CFLAGS = $(CFLAGS) @xcb_cflags@
evas_software_xcb_perf_load_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
evas_directfb_test_SOURCES = evas_test_main.h evas_test_main.c evas_directfb_main.c
evas_directfb_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm @DIRECTFB_LIBS@
evas_directfb_test_CFLAGS = $(CFLAGS) @DIRECTFB_CFLAGS@

View File

@ -0,0 +1,304 @@
#include "evas_test_main.h"
#include <X11/XCB/xcb.h>
#include <X11/XCB/xcb_icccm.h>
#include "Evas.h"
#include "Evas_Engine_Software_Xcb.h"
XCBVISUALTYPE *
get_visual(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDEPTH *d;
XCBVISUALTYPEIter iter;
int cur;
d = XCBSCREENAllowedDepthsIter(root).data;
if (!d) return NULL;
iter = XCBDEPTHVisualsIter(d);
for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur)
if (root->root_visual.id == iter.data->visual_id.id)
return iter.data;
return NULL;
}
int
get_depth(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDRAWABLE drawable;
XCBGetGeometryRep *geom;
int depth;
drawable.window = root->root;
geom = XCBGetGeometryReply (conn, XCBGetGeometry(conn, drawable), 0);
if(!geom)
{
perror ("GetGeometry(root) failed");
exit (0);
}
depth = geom->depth;
free (geom);
return depth;
}
int
main(int argc, char **argv)
{
int pause_me = 0;
XCBConnection *conn;
XCBDRAWABLE win;
XCBSCREEN *screen;
XCBGenericEvent *e;
CARD32 mask;
CARD32 value[6];
/* XClassHint chint; */
SizeHints *szhints;
conn = XCBConnectBasic ();
if (!conn)
{
printf("Error: cannot open a connection.\n");
exit(-1);
}
screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup(conn)).data;
mask =
CWBackingStore | CWColormap |
CWBackPixmap | CWBorderPixel |
CWBitGravity | CWEventMask;
value[0] = None;
value[1] = 0;
value[2] = ForgetGravity;
value[3] = NotUseful;
value[4] = ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask;
value[5] = screen->default_colormap.xid;
win.window = XCBWINDOWNew(conn);
XCBCreateWindow (conn,
get_depth(conn, screen),
win.window, screen->root,
0, 0,
win_w, win_h,
0,
InputOutput,
screen->root_visual,
mask, value);
/* XStoreName(disp, win, "Evas Software X11 Test"); */
/* chint.res_name = "Evas_Software_X11_Test"; */
/* chint.res_class = "Main"; */
/* SetClassHint(disp, win, &chint); */
#if 0
szhints = AllocSizeHints();
SizeHintsSetMinSize(szhints, win_w, win_h);
SizeHintsSetMaxSize(szhints, win_w, win_h);
SizeHintsSetSize(szhints, 0, win_w, win_h);
SetWMNormalHints(conn, win.window, szhints);
FreeSizeHints(szhints);
#endif
XCBMapWindow (conn, win.window);
XCBSync(conn, 0);
/* test evas_free.... :) */
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = conn;
einfo->info.visual = get_visual (conn, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(conn, screen);
einfo->info.rotation = 0;
einfo->info.debug = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
setup();
printf("################ evas free\n");
evas_free(evas);
printf("evas freed. DONE\n");
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = conn;
einfo->info.visual = get_visual (conn, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(conn, screen);
einfo->info.rotation = 0;
einfo->info.debug = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
setup();
printf("################ evas free\n");
evas_free(evas);
printf("evas freed. DONE\n");
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = conn;
einfo->info.visual = get_visual (conn, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(conn, screen);
einfo->info.rotation = 0;
einfo->info.debug = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
setup();
printf("################ evas free\n");
evas_free(evas);
printf("evas freed. DONE\n");
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = conn;
einfo->info.visual = get_visual (conn, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(conn, screen);
einfo->info.rotation = 0;
einfo->info.debug = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
setup();
printf("################ evas free\n");
evas_free(evas);
printf("evas freed. DONE\n");
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = conn;
einfo->info.visual = get_visual (conn, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(conn, screen);
einfo->info.rotation = 0;
einfo->info.debug = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
setup();
orig_start_time = start_time = get_time();
while (1)
{
e = XCBPollForEvent(conn, NULL);
if (e) {
switch (e->response_type)
{
case XCBButtonPress: {
XCBButtonPressEvent *ev = (XCBButtonPressEvent *)e;
if ((ev->state | Button3Mask) == Button3Mask)
exit(0);
#if 0
if (!pause_me)
pause_me = 1;
else if (pause_me == 1)
pause_me = 2;
else
pause_me = 1;
#endif
evas_event_feed_mouse_move(evas, ev->event_x, ev->event_y, NULL);
evas_event_feed_mouse_down(evas, ev->state, EVAS_BUTTON_NONE, NULL);
break;
}
case XCBButtonRelease: {
XCBButtonReleaseEvent *ev = (XCBButtonReleaseEvent *)e;
evas_event_feed_mouse_move(evas, ev->event_x, ev->event_y, NULL);
evas_event_feed_mouse_up(evas, ev->state, EVAS_BUTTON_NONE, NULL);
break;
}
case XCBMotionNotify: {
XCBMotionNotifyEvent *ev = (XCBMotionNotifyEvent *)e;
evas_event_feed_mouse_move(evas, ev->event_x, ev->event_y, NULL);
break;
}
case Expose: {
XCBExposeEvent *ev = (XCBExposeEvent *)e;
evas_damage_rectangle_add(evas,
ev->x,
ev->y,
ev->width,
ev->height);
break;
}
case ConfigureNotify: {
XCBConfigureNotifyEvent *ev = (XCBConfigureNotifyEvent *)e;
evas_output_size_set(evas,
ev->width,
ev->height);
break;
default:
break;
}
}
free (e);
}
if (!(pause_me == 1))
{
loop();
evas_render(evas);
XCBFlush(conn);
}
if (pause_me == 2)
usleep(100000);
}
return 0;
}

View File

@ -0,0 +1,245 @@
#include <X11/XCB/xcb.h>
#include <X11/XCB/xcb_icccm.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "Evas.h"
#include "Evas_Engine_Software_Xcb.h"
XCBConnection *c = NULL;
XCBDRAWABLE win;
Evas *evas = NULL;
int win_w = 240;
int win_h = 240;
XCBVISUALTYPE *
get_visual(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDEPTH *d;
XCBVISUALTYPEIter iter;
int cur;
d = XCBSCREENAllowedDepthsIter(root).data;
if (!d) return NULL;
iter = XCBDEPTHVisualsIter(d);
for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur)
if (root->root_visual.id == iter.data->visual_id.id)
return iter.data;
return NULL;
}
int
get_depth(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDRAWABLE drawable;
XCBGetGeometryRep *geom;
int depth;
drawable.window = root->root;
geom = XCBGetGeometryReply (conn, XCBGetGeometry(conn, drawable), 0);
if(!geom)
{
perror ("GetGeometry(root) failed");
exit (0);
}
depth = geom->depth;
free (geom);
return depth;
}
int
main(int argc, char **argv)
{
int exposed = 0;
XCBSCREEN *screen;
XCBGenericEvent *e;
CARD32 mask = 0;
CARD32 value[6];
/* XClassHint chint; */
SizeHints *szhints;
c = XCBConnectBasic ();
if (!c)
{
printf("Error: cannot open a connection.\n");
exit(-1);
}
screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup(c)).data;
mask = CWBackingStore | CWColormap |
CWBackPixmap | CWBorderPixel |
CWBitGravity | CWEventMask;
value[0] = None;
value[1] = 0;
value[2] = ForgetGravity;
value[3] = NotUseful;
value[4] = ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
value[5] = screen->default_colormap.xid;
win.window = XCBWINDOWNew(c);
XCBCreateWindow (c,
get_depth(c, screen),
win.window, screen->root,
0, 0,
win_w, win_h,
0,
InputOutput,
screen->root_visual,
mask, value);
/* XStoreName(disp, win, "Evas Performance Test"); */
/* chint.res_name = "Evas_Test"; */
/* chint.res_class = "Main"; */
/* XSetClassHint(disp, win, &chint); */
szhints = AllocSizeHints();
SizeHintsSetMinSize(szhints, win_w, win_h);
SizeHintsSetMaxSize(szhints, win_w, win_h);
SizeHintsSetSize(szhints, 0, win_w, win_h);
SetWMNormalHints(c, win.window, szhints);
FreeSizeHints(szhints);
XCBMapWindow (c, win.window);
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = c;
einfo->info.visual = get_visual (c, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(c, screen);
einfo->info.rotation = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
while (1)
{
e = XCBPollForEvent(c, NULL);
if (e)
{
switch (e->response_type)
{
case ButtonPress: {
XCBButtonPressEvent *ev = (XCBButtonPressEvent *)e;
/* evas_event_button_down(evas, ev->event_x, ev->event_y, ev->detail.id);*/
break;
}
case ButtonRelease: {
XCBButtonReleaseEvent *ev = (XCBButtonReleaseEvent *)e;
/* evas_event_button_up(evas, ev->event_x, ev->event_y, ev->detail.id);*/
break;
}
case MotionNotify: {
XCBMotionNotifyEvent *ev = (XCBMotionNotifyEvent *)e;
/* evas_event_move(evas, ev->event_x, ev->event_y);*/
break;
}
case Expose: {
XCBExposeEvent *ev = (XCBExposeEvent *)e;
exposed = 1;
evas_damage_rectangle_add(evas,
ev->x,
ev->y,
ev->width,
ev->height);
break;
}
default:
break;
}
}
evas_render(evas);
XCBFlush(c);
if (exposed)
{
Evas_Engine_Info_Software_Xcb *einfo;
Evas_Performance *perf;
char buf[4096];
char *data, *key;
static mode_t default_mode =
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
S_IXOTH;
FILE *f;
data = NULL;
einfo =
(Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
perf =
einfo->func.performance_new(evas, c,
get_visual (c, screen),
screen->default_colormap,
win,
get_depth(c, screen));
key = einfo->func.performance_key_get(perf);
snprintf(buf, sizeof(buf), "%s/.evas/%s", getenv("HOME"), key);
free(key);
f = fopen(buf, "r");
if (f)
{
char buf[4096];
size_t sz;
sz = fread(buf, 1, 4000, f);
if (sz > 0)
{
data = malloc(sz + 1);
if (data)
{
strncpy(data, buf, sz);
data[sz] = 0;
}
}
fclose(f);
}
if (data)
{
einfo->func.performance_build(perf, data);
einfo->func.performance_device_store(perf);
free(data);
}
else
{
printf("No cached performance values for your display.\n");
printf("Please run evas_perf_test to generate them.\n");
einfo->func.performance_free(perf);
exit(-1);
}
einfo->func.performance_free(perf);
exit(0);
}
}
return 0;
}

View File

@ -0,0 +1,219 @@
#include <X11/XCB/xcb.h>
#include <X11/XCB/xcb_icccm.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "Evas.h"
#include "Evas_Engine_Software_Xcb.h"
XCBConnection *c = NULL;
XCBDRAWABLE win;
Evas *evas = NULL;
int win_w = 240;
int win_h = 240;
XCBVISUALTYPE *
get_visual(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDEPTH *d;
XCBVISUALTYPEIter iter;
int cur;
d = XCBSCREENAllowedDepthsIter(root).data;
if (!d) return NULL;
iter = XCBDEPTHVisualsIter(d);
for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur)
if (root->root_visual.id == iter.data->visual_id.id)
return iter.data;
return NULL;
}
int
get_depth(XCBConnection *conn,
XCBSCREEN *root)
{
XCBDRAWABLE drawable;
XCBGetGeometryRep *geom;
int depth;
drawable.window = root->root;
geom = XCBGetGeometryReply (conn, XCBGetGeometry(conn, drawable), 0);
if(!geom)
{
perror ("GetGeometry(root) failed");
exit (0);
}
depth = geom->depth;
free (geom);
return depth;
}
int
main(int argc, char **argv)
{
int exposed = 0;
XCBSCREEN *screen;
XCBGenericEvent *e;
CARD32 mask = 0;
CARD32 value[6];
/* XClassHint chint; */
SizeHints *szhints;
c = XCBConnectBasic ();
if (!c)
{
printf("Error: cannot open a connection.\n");
exit(-1);
}
screen = XCBConnSetupSuccessRepRootsIter (XCBGetSetup(c)).data;
mask = CWBackingStore | CWColormap |
CWBackPixmap | CWBorderPixel |
CWBitGravity | CWEventMask;
value[0] = None;
value[1] = 0;
value[2] = ForgetGravity;
value[3] = NotUseful;
value[4] = ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
value[5] = screen->default_colormap.xid;
win.window = XCBWINDOWNew(c);
XCBCreateWindow (c,
get_depth(c, screen),
win.window, screen->root,
0, 0,
win_w, win_h,
0,
InputOutput,
screen->root_visual,
mask, value);
/* XStoreName(disp, win, "Evas Performance Test"); */
/* chint.res_name = "Evas_Test"; */
/* chint.res_class = "Main"; */
/* XSetClassHint(disp, win, &chint); */
szhints = AllocSizeHints();
SizeHintsSetMinSize(szhints, win_w, win_h);
SizeHintsSetMaxSize(szhints, win_w, win_h);
SizeHintsSetSize(szhints, 0, win_w, win_h);
SetWMNormalHints(c, win.window, szhints);
FreeSizeHints(szhints);
XCBMapWindow (c, win.window);
XCBSync(c, 0);
sleep(1);
evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("software_xcb"));
evas_output_size_set(evas, win_w, win_h);
evas_output_viewport_set(evas, 0, 0, win_w, win_h);
{
Evas_Engine_Info_Software_Xcb *einfo;
einfo = (Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
/* the following is specific to the engine */
einfo->info.conn = c;
einfo->info.visual = get_visual (c, screen);
einfo->info.colormap = screen->default_colormap;
einfo->info.drawable = win;
einfo->info.depth = get_depth(c, screen);
einfo->info.rotation = 0;
evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
}
while (1)
{
e = XCBPollForEvent(c, NULL);
if (e)
{
switch (e->response_type)
{
case XCBButtonPress: {
XCBButtonPressEvent *ev = (XCBButtonPressEvent *)e;
/* evas_event_button_down(evas, ev->event_x, ev->event_y, ev->detail.id);*/
break;
}
case XCBButtonRelease: {
XCBButtonReleaseEvent *ev = (XCBButtonReleaseEvent *)e;
/* evas_event_button_up(evas, ev->event_x, ev->event_y, ev->detail.id);*/
break;
}
case XCBExpose: {
XCBExposeEvent *ev = (XCBExposeEvent *)e;
exposed = 1;
evas_damage_rectangle_add(evas,
ev->x,
ev->y,
ev->width,
ev->height);
break;
}
}
free (e);
}
evas_render(evas);
XCBFlush(c);
if (exposed)
{
Evas_Engine_Info_Software_Xcb *einfo;
Evas_Performance *perf;
char buf[4096];
char *data, *key;
static mode_t default_mode =
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
S_IXOTH;
FILE *f;
einfo =
(Evas_Engine_Info_Software_Xcb *) evas_engine_info_get(evas);
perf =
einfo->func.performance_test(evas, c,
get_visual (c, screen),
screen->default_colormap,
win,
get_depth(c, screen));
einfo->func.performance_device_store(perf);
data = einfo->func.performance_data_get(perf);
key = einfo->func.performance_key_get(perf);
snprintf(buf, sizeof(buf), "%s/.evas", getenv("HOME"));
mkdir(buf, default_mode);
snprintf(buf, sizeof(buf), "%s/.evas/%s", getenv("HOME"), key);
free(key);
f = fopen(buf, "w");
if (f)
{
fprintf(f, "%s", data);
free(data);
fclose(f);
}
einfo->func.performance_free(perf);
exit(0);
}
}
return 0;
}

View File

@ -0,0 +1,58 @@
#ifndef _EVAS_ENGINE_SOFTWARE_XCB_H
#define _EVAS_ENGINE_SOFTWARE_XCB_H
#include <X11/XCB/xcb.h>
typedef struct _Evas_Engine_Info_Software_Xcb Evas_Engine_Info_Software_Xcb;
struct _Evas_Engine_Info_Software_Xcb
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
/* engine specific data & parameters it needs to set up */
struct {
XCBConnection *conn;
XCBDRAWABLE drawable;
XCBDRAWABLE mask;
XCBVISUALTYPE *visual;
XCBCOLORMAP colormap;
int depth;
int rotation;
int alloc_grayscale : 1;
int debug : 1;
int shape_dither : 1;
int alloc_colors_max;
} info;
/* engine specific function calls to query stuff about the destination */
/* engine (what visual & colormap & depth to use, performance info etc. */
struct {
XCBVISUALTYPE * (*best_visual_get) (XCBConnection *conn, int screen);
XCBCOLORMAP (*best_colormap_get) (XCBConnection *conn, int screen);
int (*best_depth_get) (XCBConnection *conn, int screen);
Evas_Performance *(*performance_test) (Evas *e,
XCBConnection *conn,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
XCBDRAWABLE draw,
int depth);
void (*performance_free) (Evas_Performance *perf);
char * (*performance_data_get) (Evas_Performance *perf);
char * (*performance_key_get) (Evas_Performance *perf);
Evas_Performance *(*performance_new) (Evas *e,
XCBConnection *conn,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
XCBDRAWABLE draw,
int depth);
void (*performance_build) (Evas_Performance *perf,
const char *data);
void (*performance_device_store) (Evas_Performance *perf);
} func;
};
#endif /* _EVAS_ENGINE_SOFTWARE_XCB_H */

View File

@ -4,7 +4,7 @@ SUBDIRS = canvas data file engines imaging include
AUTOMAKE_OPTIONS = 1.4 foreign
INCLUDES = @freetype_cflags@ @x_cflags@ @qt_cflags@ @DIRECTFB_CFLAGS@ @gl_cflags@ \
INCLUDES = @freetype_cflags@ @x_cflags@ @xcb_cflags@ @qt_cflags@ @DIRECTFB_CFLAGS@ @gl_cflags@ \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include
@ -13,6 +13,7 @@ lib_LTLIBRARIES = libevas.la
EXTRA_DIST = \
Evas_Engine_Software_X11.h \
Evas_Engine_Software_Xcb.h \
Evas_Engine_DirectFB.h \
Evas_Engine_FB.h \
Evas_Engine_Buffer.h \
@ -29,6 +30,14 @@ ENGINE_SOFTWARE_X11 =
ENGINE_SOFTWARE_X11_INC =
endif
if BUILD_ENGINE_SOFTWARE_XCB
ENGINE_SOFTWARE_XCB = engines/software_xcb/libevas_engine_software_xcb.la
ENGINE_SOFTWARE_XCB_INC = Evas_Engine_Software_Xcb.h
else
ENGINE_SOFTWARE_XCB =
ENGINE_SOFTWARE_XCB_INC =
endif
if BUILD_ENGINE_DIRECTFB
ENGINE_DIRECTFB = engines/directfb/libevas_engine_directfb.la
ENGINE_DIRECTFB_INC = Evas_Engine_DirectFB.h
@ -96,6 +105,7 @@ endif
include_HEADERS = \
Evas.h \
$(ENGINE_SOFTWARE_X11_INC) \
$(ENGINE_SOFTWARE_XCB_INC) \
$(ENGINE_DIRECTFB_INC) \
$(ENGINE_FB_INC) \
$(ENGINE_BUFFER_INC) \
@ -118,6 +128,7 @@ libevas_la_LIBADD = \
@freetype_libs@ \
@png_libs@ @jpeg_libs@ @eet_libs@ @edb_libs@ \
$(ENGINE_SOFTWARE_X11) \
$(ENGINE_SOFTWARE_XCB) \
$(ENGINE_DIRECTFB) \
$(ENGINE_FB) \
$(ENGINE_BUFFER) \
@ -136,6 +147,7 @@ libevas_la_DEPENDENCIES = \
imaging/libevas_imaging.la \
engines/common/libevas_engine_common.la \
$(ENGINE_SOFTWARE_X11) \
$(ENGINE_SOFTWARE_XCB) \
$(ENGINE_DIRECTFB) \
$(ENGINE_FB) \
$(ENGINE_BUFFER) \

View File

@ -3,6 +3,9 @@
#ifdef BUILD_ENGINE_SOFTWARE_X11
#include "evas_engine_api_software_x11.h"
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB
#include "evas_engine_api_software_xcb.h"
#endif
#ifdef BUILD_ENGINE_DIRECTFB
#include "evas_engine_api_directfb.h"
#endif
@ -222,6 +225,11 @@ evas_output_method_set(Evas *e, int render_method)
e->engine.func = &evas_engine_software_x11_func;
else
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB
if (e->output.render_method == RENDER_METHOD_SOFTWARE_XCB)
e->engine.func = &evas_engine_software_xcb_func;
else
#endif
#ifdef BUILD_ENGINE_GL_X11
if (e->output.render_method == RENDER_METHOD_GL_X11)
e->engine.func = &evas_engine_gl_x11_func;
@ -663,10 +671,13 @@ int
evas_render_method_lookup(const char *name)
{
if (!name) return RENDER_METHOD_INVALID;
#ifdef BUILD_ENGINE_SOFTWARE_X11
if (!strcmp(name, "software_x11")) return RENDER_METHOD_SOFTWARE_X11;
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB
if (!strcmp(name, "software_xcb")) return RENDER_METHOD_SOFTWARE_XCB;
#endif
#ifdef BUILD_ENGINE_GL_X11
if (!strcmp(name, "gl_x11")) return RENDER_METHOD_GL_X11;
#endif
@ -733,6 +744,9 @@ evas_render_method_list(void)
#ifdef BUILD_ENGINE_SOFTWARE_X11
methods = evas_list_append(methods, strdup("software_x11"));
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB
methods = evas_list_append(methods, strdup("software_xcb"));
#endif
#ifdef BUILD_ENGINE_GL_X11
methods = evas_list_append(methods, strdup("gl_x11"));

View File

@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = \
common \
software_x11 \
software_xcb \
fb \
buffer \
software_win32_gdi \

View File

@ -0,0 +1,37 @@
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = 1.4 foreign
# A list of all the files in the current directory which can be regenerated
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = @freetype_cflags@ @xcb_cflags@ \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include
if BUILD_ENGINE_SOFTWARE_XCB
noinst_LTLIBRARIES = libevas_engine_software_xcb.la
libevas_engine_software_xcb_la_SOURCES = \
evas_engine.h \
evas_engine.c \
evas_outbuf.c \
evas_xcb_buffer.c \
evas_xcb_color.c \
evas_xcb_main.c
libevas_engine_software_xcb_la_LIBADD = @xcb_libs@
libevas_engine_software_xcb_la_DEPENDENCIES = \
$(top_builddir)/config.h
endif
EXTRA_DIST = \
evas_engine.h \
evas_engine.c \
evas_outbuf.c \
evas_xcb_buffer.c \
evas_xcb_color.c \
evas_xcb_main.c

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,215 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <X11/XCB/xcb.h>
typedef struct _Outbuf Outbuf;
typedef struct _Outbuf_Perf Outbuf_Perf;
typedef struct _Xcb_Output_Buffer Xcb_Output_Buffer;
typedef enum _Outbuf_Depth Outbuf_Depth;
enum _Outbuf_Depth
{
OUTBUF_DEPTH_NONE,
OUTBUF_DEPTH_INHERIT,
OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED,
OUTBUF_DEPTH_RGB_32BPP_888_8888,
OUTBUF_DEPTH_LAST
};
struct _Outbuf
{
Outbuf_Depth depth;
int w, h;
int rot;
Outbuf_Perf *perf;
struct {
Convert_Pal *pal;
struct {
XCBConnection *conn;
XCBDRAWABLE win;
XCBDRAWABLE mask;
XCBVISUALTYPE *vis;
XCBCOLORMAP cmap;
int depth;
int shm;
XCBGCONTEXT gc;
XCBGCONTEXT gcm;
int swap : 1;
} x;
struct {
DATA32 r, g, b;
} mask;
RGBA_Image *back_buf;
int mask_dither : 1;
int debug : 1;
} priv;
};
struct _Outbuf_Perf
{
struct {
XCBConnection *conn;
XCBDRAWABLE root;
char *display;
char *vendor;
int version;
int revision;
int release;
int w, h;
int screen_count;
int depth;
int screen_num;
} x;
struct{
char *name;
char *version;
char *machine;
} os;
struct {
char *info;
} cpu;
int min_shm_image_pixel_count;
};
/****/
/* main */
void evas_software_x11_x_software_xcb_init (void);
/* buffer */
void evas_software_x11_x_software_xcb_write_mask_line (Xcb_Output_Buffer *xcbob,
DATA32 *src,
int w,
int y);
int evas_software_x11_x_software_xcb_can_do_shm (XCBConnection *c);
Xcb_Output_Buffer *evas_software_x11_x_software_xcb_output_buffer_new (XCBConnection *c,
int depth,
int w,
int h,
int try_shm,
void *data);
void evas_software_x11_x_software_xcb_output_buffer_free (Xcb_Output_Buffer *xcbob);
void evas_software_x11_x_software_xcb_output_buffer_paste (Xcb_Output_Buffer *xcbob,
XCBDRAWABLE d,
XCBGCONTEXT gc,
int x,
int y);
DATA8 *evas_software_x11_x_software_xcb_output_buffer_data (Xcb_Output_Buffer *xcbob,
int *bytes_per_line_ret);
int evas_software_x11_x_software_xcb_output_buffer_depth (Xcb_Output_Buffer *xcbob);
int evas_software_x11_x_software_xcb_output_buffer_byte_order(Xcb_Output_Buffer *xcbob);
/* color */
void x_software_xcb_color_init (void);
Convert_Pal *evas_software_x11_x_software_xcb_color_allocate (XCBConnection *conn,
XCBCOLORMAP cmap,
XCBVISUALTYPE *vis,
Convert_Pal_Mode colors);
void evas_software_x11_x_software_xcb_color_deallocate (XCBConnection *conn,
XCBCOLORMAP cmap,
XCBVISUALTYPE *vis,
Convert_Pal *pal);
/* outbuf */
void evas_software_x11_outbuf_software_xcb_init (void);
void evas_software_x11_outbuf_software_xcb_free (Outbuf *buf);
Outbuf *evas_software_x11_outbuf_software_xcb_setup_x (int w,
int h,
int rot,
Outbuf_Depth depth,
XCBConnection *conn,
XCBDRAWABLE draw,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
int x_depth,
Outbuf_Perf *perf,
int grayscale,
int max_colors,
XCBDRAWABLE mask,
int shape_dither);
char *evas_software_x11_outbuf_software_xcb_perf_serialize_x (Outbuf_Perf *perf);
void evas_software_x11_outbuf_software_xcb_perf_deserialize_x (Outbuf_Perf *perf,
const char *data);
Outbuf_Perf *evas_software_x11_outbuf_software_xcb_perf_new_x (XCBConnection *conn,
XCBDRAWABLE draw,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
int x_depth);
char *evas_software_x11_outbuf_software_xcb_perf_serialize_info_x (Outbuf_Perf *perf);
void evas_software_x11_outbuf_software_xcb_perf_store_x (Outbuf_Perf *perf);
Outbuf_Perf *evas_software_x11_outbuf_software_xcb_perf_restore_x (XCBConnection *conn,
XCBDRAWABLE draw,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
int x_depth);
void evas_software_x11_outbuf_software_xcb_perf_free (Outbuf_Perf *perf);
Outbuf_Perf *evas_software_x11_outbuf_software_xcb_perf_x (XCBConnection *conn,
XCBDRAWABLE draw,
XCBVISUALTYPE *vis,
XCBCOLORMAP cmap,
int x_depth);
void evas_software_x11_outbuf_software_xcb_blit (Outbuf *buf,
int src_x,
int src_y,
int w,
int h,
int dst_x,
int dst_y);
void evas_software_x11_outbuf_software_xcb_update (Outbuf *buf,
int x,
int y,
int w,
int h);
RGBA_Image *evas_software_x11_outbuf_software_xcb_new_region_for_update (Outbuf *buf,
int x,
int y,
int w,
int h,
int *cx,
int *cy,
int *cw,
int *ch);
void evas_software_x11_outbuf_software_xcb_free_region_for_update (Outbuf *buf,
RGBA_Image *update);
void evas_software_x11_outbuf_software_xcb_push_updated_region (Outbuf *buf,
RGBA_Image *update,
int x,
int y,
int w,
int h);
void evas_software_x11_outbuf_software_xcb_reconfigure (Outbuf *buf,
int w,
int h,
int rot,
Outbuf_Depth depth);
int evas_software_x11_outbuf_software_xcb_get_width (Outbuf *buf);
int evas_software_x11_outbuf_software_xcb_get_height (Outbuf *buf);
Outbuf_Depth evas_software_x11_outbuf_software_xcb_get_depth (Outbuf *buf);
int evas_software_x11_outbuf_software_xcb_get_rot (Outbuf *buf);
int evas_software_x11_outbuf_software_xcb_get_have_backbuf (Outbuf *buf);
void evas_software_x11_outbuf_software_xcb_set_have_backbuf (Outbuf *buf, int have_backbuf);
void evas_software_x11_outbuf_software_xcb_drawable_set (Outbuf *buf, XCBDRAWABLE draw);
void evas_software_x11_outbuf_software_xcb_mask_set (Outbuf *buf, XCBDRAWABLE mask);
void evas_software_x11_outbuf_software_xcb_rotation_set (Outbuf *buf, int rot);
void evas_software_x11_outbuf_software_xcb_debug_set (Outbuf *buf, int debug);
void evas_software_x11_outbuf_software_xcb_debug_show (Outbuf *buf,
XCBDRAWABLE draw,
int x,
int y,
int w,
int h);
#endif /* EVAS_ENGINE_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,231 @@
#include "evas_common.h"
#include "evas_engine.h"
#include <X11/XCB/shm.h>
#include <X11/XCB/xcb_image.h>
#include <sys/ipc.h>
#include <sys/shm.h>
struct _Xcb_Output_Buffer
{
XCBConnection *connection;
XCBImage *image;
XCBShmSegmentInfo *shm_info;
void *data;
};
static int _xcb_err = 0;
void
evas_software_x11_x_software_xcb_write_mask_line(Xcb_Output_Buffer *xcbob,
DATA32 *src,
int w,
int y)
{
int x;
for (x = 0; x < w; x++)
{
XCBImagePutPixel(xcbob->image, x, y, A_VAL(&(src[x])) >> 7);
}
}
int
evas_software_x11_x_software_xcb_can_do_shm(XCBConnection *c)
{
XCBGetGeometryRep *geom;
XCBDRAWABLE drawable;
int depth;
drawable.window = XCBConnSetupSuccessRepRootsIter (XCBGetSetup(c)).data->root;
geom = XCBGetGeometryReply (c, XCBGetGeometry(c, drawable), 0);
if(!geom)
return 0;
depth = geom->depth;
free (geom);
if (XCBShmInit(c))
{
Xcb_Output_Buffer *xcbob;
xcbob = evas_software_x11_x_software_xcb_output_buffer_new(c,
depth,
16,
16,
2,
NULL);
if (!xcbob)
return 0;
evas_software_x11_x_software_xcb_output_buffer_free(xcbob);
return 1;
}
return 0;
}
/*
* FIXME: no error mechanism
*/
/* static void */
/* x_software_x11_output_tmp_x11_err(XCBConnection *c, XErrorEvent * ev) */
/* { */
/* _xcb_err = 1; */
/* return; */
/* d = NULL; */
/* ev = NULL; */
/* } */
Xcb_Output_Buffer *
evas_software_x11_x_software_xcb_output_buffer_new(XCBConnection *c,
int depth,
int w,
int h,
int try_shm,
void *data)
{
Xcb_Output_Buffer *xcbob;
xcbob = calloc(1, sizeof(Xcb_Output_Buffer));
if (!xcbob) return NULL;
xcbob->connection = c;
xcbob->image = NULL;
xcbob->shm_info = NULL;
if (try_shm > 0)
{
xcbob->shm_info = malloc(sizeof(XCBShmSegmentInfo));
if (xcbob->shm_info)
{
xcbob->shm_info->shmseg = XCBShmSEGNew(c);
xcbob->image = XCBImageSHMCreate(c, depth, ZPixmap, NULL, w, h);
if (xcbob->image)
{
xcbob->shm_info->shmid = shmget(IPC_PRIVATE,
xcbob->image->bytes_per_line *
xcbob->image->height,
IPC_CREAT | 0777);
if (xcbob->shm_info->shmid >= 0)
{
xcbob->shm_info->shmaddr = xcbob->image->data =
shmat(xcbob->shm_info->shmid, 0, 0);
if (xcbob->shm_info->shmaddr != NULL)
{
/*
* FIXME: no error mechanism
*/
/* XErrorHandler ph; */
XCBSync(c, 0);
_xcb_err = 0;
/* ph = XSetErrorHandler((XErrorHandler) */
/* x_software_x11_output_tmp_x_err); */
XCBShmAttach(c,
xcbob->shm_info->shmseg,
xcbob->shm_info->shmid, 0);
XCBSync(c, 0);
/* XSetErrorHandler((XErrorHandler)ph); */
if (!_xcb_err)
{
return xcbob;
}
}
shmdt(xcbob->shm_info->shmaddr);
shmctl(xcbob->shm_info->shmid, IPC_RMID, 0);
}
if (xcbob->image) XCBImageSHMDestroy(xcbob->image);
xcbob->image = NULL;
}
if (xcbob->shm_info) free(xcbob->shm_info);
xcbob->shm_info = NULL;
}
}
if (try_shm > 1) return NULL;
xcbob->image = XCBImageCreate(c, depth, ZPixmap, 0, data, w, h, 32, 0);
if (!xcbob->image)
{
free(xcbob);
return NULL;
}
xcbob->data = data;
if (!xcbob->image->data)
{
xcbob->image->data = malloc(xcbob->image->bytes_per_line * xcbob->image->height);
if (!xcbob->image->data)
{
XCBImageDestroy(xcbob->image);
free(xcbob);
return NULL;
}
}
return xcbob;
}
void
evas_software_x11_x_software_xcb_output_buffer_free(Xcb_Output_Buffer *xcbob)
{
if (xcbob->shm_info)
{
XCBSync(xcbob->connection, 0);
XCBShmDetach(xcbob->connection, xcbob->shm_info->shmseg);
XCBImageSHMDestroy(xcbob->image);
shmdt(xcbob->shm_info->shmaddr);
shmctl(xcbob->shm_info->shmid, IPC_RMID, 0);
free(xcbob->shm_info);
}
else
{
if (xcbob->data) xcbob->image->data = NULL;
XCBImageDestroy(xcbob->image);
}
free(xcbob);
}
void
evas_software_x11_x_software_xcb_output_buffer_paste(Xcb_Output_Buffer *xcbob,
XCBDRAWABLE d,
XCBGCONTEXT gc,
int x,
int y)
{
if (xcbob->shm_info)
{
XCBImageSHMPut(xcbob->connection, d, gc,
xcbob->image, *xcbob->shm_info,
0, 0,
x, y,
xcbob->image->width, xcbob->image->height,
0);
XCBSync(xcbob->connection, 0);
}
else
{
XCBImagePut(xcbob->connection, d, gc, xcbob->image, 0, 0, x, y, xcbob->image->width, xcbob->image->height);
}
}
DATA8 *
evas_software_x11_x_software_xcb_output_buffer_data(Xcb_Output_Buffer *xcbob,
int *bytes_per_line_ret)
{
if (bytes_per_line_ret) *bytes_per_line_ret = xcbob->image->bytes_per_line;
return xcbob->image->data;
}
int
evas_software_x11_x_software_xcb_output_buffer_depth(Xcb_Output_Buffer *xcbob)
{
return xcbob->image->bits_per_pixel;
}
int
evas_software_x11_x_software_xcb_output_buffer_byte_order(Xcb_Output_Buffer *xcbob)
{
return xcbob->image->image_byte_order;
}

View File

@ -0,0 +1,359 @@
#include "evas_common.h"
#include "evas_engine.h"
#include <X11/XCB/xcb.h>
typedef struct _Convert_Pal_Priv Convert_Pal_Priv;
struct _Convert_Pal_Priv
{
XCBConnection *conn;
XCBCOLORMAP cmap;
XCBVISUALTYPE *vis;
};
typedef DATA8 * (*Xcb_Func_Alloc_Colors) (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static Xcb_Func_Alloc_Colors x_software_xcb_color_alloc[PAL_MODE_LAST + 1];
static int x_software_xcb_color_count[PAL_MODE_LAST + 1];
static Evas_List *palettes = NULL;
static DATA8 * x_software_xcb_color_alloc_rgb(int nr, int ng, int nb, XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_gray(int ng, XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_332 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_666 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_232 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_222 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_221 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_121 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_rgb_111 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_gray_256 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_gray_64 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_gray_16 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_gray_4 (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 * x_software_xcb_color_alloc_mono (XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v);
static DATA8 *
x_software_xcb_color_alloc_rgb(int nr, int ng, int nb, XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
int r, g, b, i;
DATA8 *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb_value; i++) sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb_value);
i = 0;
color_lut = malloc((nr) * (ng) * (nb));
if (!color_lut) return NULL;
for (r = 0; r < (nr); r++)
{
for (g = 0; g < (ng); g++)
{
for (b = 0; b < (nb); b++)
{
XCBCOLORITEM xcl;
XCBCOLORITEM xcl_in;
int val;
XCBAllocColorRep *rep;
val = (int)((((double)r) / ((nr) - 1)) * 65535);
xcl.red = (unsigned short)(val);
val = (int)((((double)g) / ((ng) - 1)) * 65535);
xcl.green = (unsigned short)(val);
val = (int)((((double)b) / ((nb) - 1)) * 65535);
xcl.blue = (unsigned short)(val);
xcl_in = xcl;
rep = XCBAllocColorReply(conn,
XCBAllocColor(conn, cmap,
xcl.red, xcl.green, xcl.blue),
0);
/* TODO: XAllocColor tries to approach the color */
/* in case the allocation fails */
/* XCB does not that (i think). It should be done */
/* So if rep == NULL, the other following tests */
/* should be always satisfied */
if ((!rep) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long)color_lut[j];
XCBFreeColors(conn, cmap, 0, i, pixels);
}
free(color_lut);
return NULL;
}
color_lut[i] = rep->pixel;
i++;
free(rep);
}
}
}
return color_lut;
}
static DATA8 *
x_software_xcb_color_alloc_gray(int ng, XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
int g, i;
DATA8 *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb_value; i++) sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb_value);
i = 0;
color_lut = malloc(ng);
if (!color_lut) return NULL;
for (g = 0; g < (ng); g++)
{
XCBCOLORITEM xcl;
XCBCOLORITEM xcl_in;
int val;
XCBAllocColorRep *rep;
val = (int)((((double)g) / ((ng) - 1)) * 65535);
xcl.red = (unsigned short)(val);
xcl.green = (unsigned short)(val);
xcl.blue = (unsigned short)(val);
xcl_in = xcl;
rep = XCBAllocColorReply(conn,
XCBAllocColor(conn, cmap,
xcl.red, xcl.green, xcl.blue),
0);
/* TODO: XAllocColor tries to approach the color */
/* in case the allocation fails */
/* XCB does not that (i think). It should be done */
/* So if rep == NULL, the other following tests */
/* should be always satisfied */
if ((!rep) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) color_lut[j];
XCBFreeColors(conn, cmap, 0, i, pixels);
}
free(color_lut);
return NULL;
}
color_lut[i] = xcl.pixel;
i++;
free(rep);
}
return color_lut;
}
static DATA8 *
x_software_xcb_color_alloc_rgb_332(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(8, 8, 4, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_666(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(6, 6, 6, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_232(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(4, 8, 4, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_222(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(4, 4, 4, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_221(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(4, 4, 2, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_121(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(2, 4, 2, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_rgb_111(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_rgb(2, 2, 2, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_gray_256(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_gray(256, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_gray_64(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_gray(64, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_gray_16(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_gray(32, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_gray_4(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_gray(16, conn, cmap, v);
}
static DATA8 *
x_software_xcb_color_alloc_mono(XCBConnection *conn, XCBCOLORMAP cmap, XCBVISUALTYPE *v)
{
return x_software_xcb_color_alloc_gray(2, conn, cmap, v);
}
void
x_software_xcb_color_init(void)
{
static int initialised = 0;
if (initialised) return;
x_software_xcb_color_alloc[PAL_MODE_NONE] = NULL;
x_software_xcb_color_count[PAL_MODE_NONE] = 0;
x_software_xcb_color_alloc[PAL_MODE_MONO] = x_software_xcb_color_alloc_mono;
x_software_xcb_color_count[PAL_MODE_MONO] = 2;
x_software_xcb_color_alloc[PAL_MODE_GRAY4] = x_software_xcb_color_alloc_gray_4;
x_software_xcb_color_count[PAL_MODE_GRAY4] = 4;
x_software_xcb_color_alloc[PAL_MODE_GRAY16] = x_software_xcb_color_alloc_gray_16;
x_software_xcb_color_count[PAL_MODE_GRAY16] = 16;
x_software_xcb_color_alloc[PAL_MODE_GRAY64] = x_software_xcb_color_alloc_gray_64;
x_software_xcb_color_count[PAL_MODE_GRAY64] = 64;
x_software_xcb_color_alloc[PAL_MODE_GRAY256] = x_software_xcb_color_alloc_gray_256;
x_software_xcb_color_count[PAL_MODE_GRAY256] = 256;
x_software_xcb_color_alloc[PAL_MODE_RGB111] = x_software_xcb_color_alloc_rgb_111;
x_software_xcb_color_count[PAL_MODE_RGB111] = 2 * 2 * 2;
x_software_xcb_color_alloc[PAL_MODE_RGB121] = x_software_xcb_color_alloc_rgb_121;
x_software_xcb_color_count[PAL_MODE_RGB121] = 2 * 4 * 2;
x_software_xcb_color_alloc[PAL_MODE_RGB221] = x_software_xcb_color_alloc_rgb_221;
x_software_xcb_color_count[PAL_MODE_RGB221] = 4 * 4 * 2;
x_software_xcb_color_alloc[PAL_MODE_RGB222] = x_software_xcb_color_alloc_rgb_222;
x_software_xcb_color_count[PAL_MODE_RGB222] = 4 * 4 * 4;
x_software_xcb_color_alloc[PAL_MODE_RGB232] = x_software_xcb_color_alloc_rgb_232;
x_software_xcb_color_count[PAL_MODE_RGB232] = 4 * 8 * 4;
x_software_xcb_color_alloc[PAL_MODE_RGB666] = x_software_xcb_color_alloc_rgb_666;
x_software_xcb_color_count[PAL_MODE_RGB666] = 6 * 6 * 6;
x_software_xcb_color_alloc[PAL_MODE_RGB332] = x_software_xcb_color_alloc_rgb_332;
x_software_xcb_color_count[PAL_MODE_RGB332] = 8 * 8 * 4;
x_software_xcb_color_alloc[PAL_MODE_LAST] = NULL;
x_software_xcb_color_count[PAL_MODE_LAST] = 0;
initialised = 1;
}
Convert_Pal *
evas_software_x11_x_software_xcb_color_allocate(XCBConnection *conn,
XCBCOLORMAP cmap,
XCBVISUALTYPE *vis,
Convert_Pal_Mode colors)
{
Convert_Pal_Priv *palpriv;
Convert_Pal *pal;
Convert_Pal_Mode c;
Evas_List *l;
for (l = palettes; l; l = l->next)
{
pal = l->data;
palpriv = pal->data;
if ((conn == palpriv->conn) &&
(vis == palpriv->vis) &&
(cmap.xid == palpriv->cmap.xid))
{
pal->references++;
return pal;
}
}
pal = calloc(1, sizeof(struct _Convert_Pal));
if (!pal) return NULL;
for (c = colors; c > PAL_MODE_NONE; c--)
{
if (x_software_xcb_color_alloc[c])
{
pal->lookup = (x_software_xcb_color_alloc[c])(conn, cmap, vis);
if (pal->lookup) break;
}
}
pal->references = 1;
pal->colors = c;
pal->count = x_software_xcb_color_count[c];
palpriv = calloc(1, sizeof(Convert_Pal_Priv));
pal->data = palpriv;
if (!palpriv)
{
if (pal->lookup) free(pal->lookup);
free(pal);
return NULL;
}
palpriv->conn = conn;
palpriv->vis = vis;
palpriv->cmap = cmap;
if (pal->colors == PAL_MODE_NONE)
{
if (pal->lookup) free(pal->lookup);
free(pal);
return NULL;
}
palettes = evas_list_append(palettes, pal);
return pal;
}
void
evas_software_x11_x_software_xcb_color_deallocate(XCBConnection *conn,
XCBCOLORMAP cmap,
XCBVISUALTYPE *vis,
Convert_Pal *pal)
{
unsigned long pixels[256];
int j;
pal->references--;
if (pal->references > 0) return;
if (pal->lookup)
{
for(j = 0; j < pal->count; j++)
pixels[j] = (unsigned long) pal->lookup[j];
XCBFreeColors(conn, cmap, 0, pal->count, pixels);
free(pal->lookup);
}
free(pal->data);
palettes = evas_list_remove(palettes, pal);
free(pal);
}

View File

@ -0,0 +1,9 @@
#include "evas_common.h"
#include "evas_engine.h"
#include <X11/XCB/xcb.h>
void
evas_software_x11_x_software_xcb_init(void)
{
}

View File

@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = \
evas_common.h \
evas_engine_api_software_x11.h \
evas_engine_api_software_xcb.h \
evas_engine_api_directfb.h \
evas_engine_api_fb.h \
evas_engine_api_buffer.h \

View File

@ -0,0 +1,7 @@
#ifndef EVAS_ENGINE_SOFTWARE_XCB_H
#define EVAS_ENGINE_SOFTWARE_XCB_H
#include <X11/XCB/xcb.h>
extern Evas_Func evas_engine_software_xcb_func;
#endif /* EVAS_ENGINE_SOFTWARE_XCB_H */

View File

@ -17,6 +17,7 @@
#define RENDER_METHOD_SOFTWARE_QTOPIA 0x00000006
#define RENDER_METHOD_GL_X11 0x00000007
#define RENDER_METHOD_CAIRO_X11 0x00000008
#define RENDER_METHOD_SOFTWARE_XCB 0x00000009
#define RENDER_METHOD_INVALID 0x00000000