fix a leak in xcb eng sfw (it remains one, but I don't see where it comes from). Update the xrender one. Don't use them yet (but who uses them ??), because it relies on fix of xcb that are in my hd

SVN revision: 22323
This commit is contained in:
doursse 2006-04-23 15:38:23 +00:00 committed by doursse
parent 1799b347e8
commit fd14218f04
14 changed files with 184 additions and 123 deletions

View File

@ -1,3 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = data src proj
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \

View File

@ -5,6 +5,7 @@ AC_INIT(configure.in)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_ISC_POSIX
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(evas, 0.9.9.026)
AM_CONFIG_HEADER(config.h)
@ -223,7 +224,7 @@ ENGINE_SOFTWARE_XCB_PRG="";
## Automatic check...
PKG_CHECK_MODULES(
XCB,
xcb xcb-image xcb-icccm,
xcb xcb-shm xcb-image xcb-icccm,
[AC_CHECK_HEADER(
X11/X.h,
[have_evas_software_xcb="yes"],
@ -251,7 +252,7 @@ if test "x$have_evas_software_xcb" = "xyes"; then
PKG_CHECK_MODULES(
XCB,
xcb xcb-image xcb-icccm,
xcb xcb-shm xcb-aux xcb-image xcb-icccm,
[AC_DEFINE(BUILD_ENGINE_SOFTWARE_XCB, 1, [Software XCB Rendering Backend])
xcb_cflags=$XCB_CFLAGS
xcb_libs=$XCB_LIBS
@ -602,8 +603,8 @@ ENGINE_XRENDER_XCB_PRG="";
## Automatic check...
PKG_CHECK_MODULES(
XCB,
xcb xcb-image xcb-icccm,
XCBRENDER,
xcb xcb-shm xcb-render xcb-image xcb-icccm,
[AC_CHECK_HEADER(
X11/X.h,
[have_evas_xrender_xcb="yes"],
@ -630,11 +631,11 @@ if test "x$have_evas_xrender_xcb" = "xyes"; then
AC_PATH_XTRA
PKG_CHECK_MODULES(
XCB,
xcb xcb-image xcb-icccm,
XCBRENDER,
xcb xcb-shm xcb-render xcb-image xcb-icccm,
[AC_DEFINE(BUILD_ENGINE_XRENDER_XCB, 1, [Xrender XCB Rendering Backend])
xcb_cflags=$XCB_CFLAGS
xcb_libs=$XCB_LIBS
xcbrender_cflags=$XCBRENDER_CFLAGS
xcbrender_libs=$XCBRENDER_LIBS
ENGINE_XRENDER_XCB_PRG="evas_xrender_xcb_test"],
[AC_MSG_RESULT(disabling xrender XCB engine)
have_evas_xrender_xcb="no"])
@ -1725,6 +1726,8 @@ AC_SUBST(x_libs)
AC_SUBST(xcb_cflags)
AC_SUBST(xcb_libs)
AC_SUBST(xcbrender_cflags)
AC_SUBST(xcbrender_libs)
AC_SUBST(gl_cflags)
AC_SUBST(gl_libs)

View File

@ -126,8 +126,8 @@ evas_xrender_x11_test_CFLAGS = $(CFLAGS) @x_cflags@
evas_xrender_x11_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
evas_xrender_xcb_test_SOURCES = evas_test_main.h evas_test_main.c evas_xrender_xcb_main.c
evas_xrender_xcb_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm @xcb_libs@
evas_xrender_xcb_test_CFLAGS = $(CFLAGS) @xcb_cflags@
evas_xrender_xcb_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm @xcbrender_libs@
evas_xrender_xcb_test_CFLAGS = $(CFLAGS) @xcbrender_cflags@
evas_xrender_xcb_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la
EXTRA_DIST = evas_software_qtopia_main.h evas_software_qtopia_main.cpp

View File

@ -20,6 +20,7 @@ evas_blend_pixel_cmod_pixel.c \
evas_blend_pixel_mul_pixel.c \
evas_blend_pixel_pixel.c \
evas_blit_main.c \
evas_circle_main.c \
evas_convert_color.c \
evas_convert_gry_1.c \
evas_convert_gry_4.c \

View File

@ -336,4 +336,4 @@ _evas_module_engine_inherit(Evas_Func *funcs, char *name)
}
}
return 0;
}
}

View File

@ -32,4 +32,4 @@ evas_outbuf.c \
evas_xcb_buffer.c \
evas_xcb_color.c \
evas_xcb_main.c \
Evas_Engine_Software_Xcb.h
Evas_Engine_Software_Xcb.h

View File

@ -118,41 +118,16 @@ _output_setup(int w,
return re;
}
static XCBSCREEN *
_screen_get(XCBConnection *conn, int screen)
{
XCBSCREENIter i;
int cur;
if (!conn) return NULL;
i = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(conn));
if (screen > i.rem - 1) return NULL; /* screen must be between 0 and i.rem - 1 */
for (cur = 0; cur <= screen; XCBSCREENNext(&i), ++cur);
return i.data;
}
static XCBVISUALTYPE *
_best_visual_get(XCBConnection *conn, int screen)
{
XCBSCREEN *scr;
XCBDEPTH *d;
XCBVISUALTYPEIter iter;
int cur;
if (!conn) return NULL;
scr = _screen_get(conn, screen);
scr = XCBAuxGetScreen(conn, screen);
if (!scr) return NULL;
d = XCBSCREENAllowedDepthsIter(scr).data;
if (!d) return NULL;
iter = XCBDEPTHVisualsIter(d);
for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur)
if (scr->root_visual.id == iter.data->visual_id.id)
return iter.data;
return NULL;
return XCBAuxGetVisualtype (conn, screen, scr->root_visual);
}
static XCBCOLORMAP
@ -163,7 +138,7 @@ _best_colormap_get(XCBConnection *conn, int screen)
c.xid = 0;
if (!conn) return c;
scr = _screen_get(conn, screen);
scr = XCBAuxGetScreen(conn, screen);
if (!scr) return c;
return scr->default_colormap;
@ -175,7 +150,7 @@ _best_depth_get(XCBConnection *conn, int screen)
XCBSCREEN *scr;
if (!conn) return 0;
scr = _screen_get(conn, screen);
scr = XCBAuxGetScreen(conn, screen);
if (!scr) return 0;
return scr->root_depth;

View File

@ -1,12 +1,14 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <X11/XCB/xcb.h>
#include <X11/XCB/shm.h>
#include <X11/XCB/xcb_image.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/XCB/xcb.h>
#include <X11/XCB/shm.h>
#include <X11/XCB/xcb_aux.h>
#include <X11/XCB/xcb_image.h>
typedef struct _Outbuf Outbuf;
typedef struct _Outbuf_Perf Outbuf_Perf;
typedef struct _Outbuf_Region Outbuf_Region;

View File

@ -905,6 +905,8 @@ evas_software_xcb_outbuf_perf_store_x(Outbuf_Perf *perf)
strlen (type_str),
type_str),
NULL);
if (!rep) return;
type = rep->atom;
format = STRING;
@ -914,6 +916,7 @@ evas_software_xcb_outbuf_perf_store_x(Outbuf_Perf *perf)
strlen(str), str);
/* XSync(perf->x.disp, False); */
free(str);
free (rep);
}
Outbuf_Perf *
@ -930,8 +933,6 @@ evas_software_xcb_outbuf_perf_restore_x(XCBConnection *conn,
char *type_str;
XCBATOM type, format;
Outbuf_Perf *perf;
char *retval;
int retnum;
perf = evas_software_xcb_outbuf_perf_new_x(conn, draw, vis, cmap, x_depth);
@ -944,31 +945,28 @@ evas_software_xcb_outbuf_perf_restore_x(XCBConnection *conn,
NULL);
type = type_rep->atom;
format = STRING;
retval = NULL;
cookie = XCBGetProperty(conn, 0, perf->x.root.window,
type, format,
0, 16384);
prop_rep = XCBGetPropertyReply(conn, cookie, NULL);
retval = XCBGetPropertyValue(prop_rep);
retnum = XCBGetPropertyValueLength(prop_rep);
if (retval)
if ((prop_rep) &&
(prop_rep->format == 8) &&
(prop_rep->type.xid == type.xid))
{
if ((prop_rep->format == 8) &&
(prop_rep->type.xid == type.xid))
{
char *s;
char *retval;
int retnum;
s = malloc(retnum + 1);
strncpy(s, retval, retnum);
s[retnum] = 0;
evas_software_xcb_outbuf_perf_deserialize_x(perf, s);
free(s);
}
/* FIXME: doesn't seem to be need (from valgrind) */
/* free(retval); */
retval = XCBGetPropertyValue(prop_rep);
retnum = XCBGetPropertyValueLength(prop_rep);
retval[retnum] = '\0';
evas_software_xcb_outbuf_perf_deserialize_x(perf, retval);
}
if (prop_rep)
free(prop_rep);
return perf;
}

View File

@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = 1.4 foreign
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include -I$(top_srcdir)/src/modules/engines @FREETYPE_CFLAGS@ @xcb_cflags@
INCLUDES = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include -I$(top_srcdir)/src/modules/engines @FREETYPE_CFLAGS@ @xcbrender_cflags@
if BUILD_ENGINE_XRENDER_XCB
@ -18,7 +18,7 @@ evas_engine_image.c \
evas_engine_font.c \
evas_engine_gradient.c
module_la_LIBADD = @xcb_libs@ $(top_builddir)/src/lib/libevas.la
module_la_LIBADD = @xcbrender_libs@ $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs
module_la_DEPENDENCIES = $(top_builddir)/config.h

View File

@ -113,6 +113,7 @@ eng_setup(Evas *e, void *in)
{
Render_Engine *re;
Evas_Engine_Info_XRender_Xcb *info;
int resize = 1;
info = (Evas_Engine_Info_XRender_Xcb *)in;
if (!e->engine.data.output)
@ -134,6 +135,7 @@ eng_setup(Evas *e, void *in)
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
e->engine.data.output = re;
resize = 0;
}
re = e->engine.data.output;
if (!re) return;
@ -150,19 +152,31 @@ eng_setup(Evas *e, void *in)
re->xcbinf = _xr_image_info_get(re->conn, re->win, re->vis);
if (re->output) _xr_render_surface_free(re->output);
re->output = _xr_render_surface_adopt(re->xcbinf, re->win, e->output.w, e->output.h, 0);
if (re->mask.xid)
{
XCBDRAWABLE draw;
if (re->mask_output) _xr_render_surface_free(re->mask_output);
if (!re->mask.xid)
re->output = _xr_render_surface_adopt(re->xcbinf, re->win, e->output.w, e->output.h, re->destination_alpha);
else
re->output = _xr_render_surface_adopt(re->xcbinf, re->win, e->output.w, e->output.h, 0);
if (re->mask.xid) {
XCBDRAWABLE draw;
if (re->mask_output) _xr_render_surface_free(re->mask_output);
draw.pixmap = re->mask;
re->mask_output = _xr_render_surface_format_adopt(re->xcbinf, draw,
e->output.w, e->output.h,
re->xcbinf->fmt1, 1);
}
draw.pixmap = re->mask;
re->mask_output = _xr_render_surface_format_adopt(re->xcbinf, draw,
e->output.w, e->output.h,
re->xcbinf->fmt1, 1);
}
else
re->mask_output = NULL;
if (resize)
{
if (re->tb) evas_common_tilebuf_free(re->tb);
if ((e->output.w > 0) && (e->output.h > 0))
re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
else
re->tb = evas_common_tilebuf_new(1, 1);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
}
}
static void

View File

@ -279,7 +279,8 @@ _xre_image_resize(XR_Image *im, int w, int h)
ww = w; hh = h;
RECTS_CLIP_TO_RECT(x, y, ww, hh, 0, 0, im->w, im->h);
old_surface = im->surface;
im->surface = _xr_render_surface_new(old_surface->xcbinf, w, h, old_surface->fmt, old_surface->alpha);
im->surface = _xr_render_surface_new(old_surface->xcbinf,
w + 1, h + 1, old_surface->fmt, old_surface->alpha);
if (im->surface)
_xr_render_surface_copy(old_surface, im->surface, 0, 0, 0, 0, ww, hh);
_xr_render_surface_free(old_surface);
@ -451,11 +452,14 @@ _xre_image_alpha_set(XR_Image *im, int alpha)
old_surface = im->surface;
im->surface = NULL;
if (im->alpha)
im->surface = _xr_render_surface_new(im->xcbinf, im->w, im->h, im->xcbinf->fmt32, 1);
im->surface = _xr_render_surface_new(im->xcbinf,
im->w + 1, im->h + 1, im->xcbinf->fmt32, 1);
else
im->surface = _xr_render_surface_new(im->xcbinf, im->w, im->h, im->xcbinf->fmt24, 0);
im->surface = _xr_render_surface_new(im->xcbinf,
im->w + 1, im->h + 1, im->xcbinf->fmt24, 0);
if (im->surface)
_xr_render_surface_copy(old_surface, im->surface, 0, 0, 0, 0, im->w, im->h);
_xr_render_surface_copy(old_surface,
im->surface, 0, 0, 0, 0, im->w + 1, im->h + 1);
_xr_render_surface_free(old_surface);
}
if (im->updates)
@ -517,14 +521,29 @@ _xre_image_surface_gen(XR_Image *im)
}
if (im->alpha)
{
im->surface = _xr_render_surface_new(im->xcbinf, im->w, im->h, im->xcbinf->fmt32, 1);
im->surface = _xr_render_surface_new(im->xcbinf,
im->w + 1, im->h + 1, im->xcbinf->fmt32, 1);
_xr_render_surface_argb_pixels_fill(im->surface, im->w, im->h, data, 0, 0, im->w, im->h);
}
else
{
im->surface = _xr_render_surface_new(im->xcbinf, im->w, im->h, im->xcbinf->fmt24, 0);
im->surface = _xr_render_surface_new(im->xcbinf,
im->w + 1, im->h + 1, im->xcbinf->fmt24, 0);
_xr_render_surface_rgb_pixels_fill(im->surface, im->w, im->h, data, 0, 0, im->w, im->h);
}
}
/* fill right and bottom pixel so interpolation works right */
_xr_render_surface_copy(im->surface, im->surface,
im->w - 1, 0,
im->w, 0,
1, im->h);
_xr_render_surface_copy(im->surface, im->surface,
0, im->h - 1,
0, im->h,
im->w, 1);
_xr_render_surface_copy(im->surface, im->surface,
im->w - 1, im->h - 1,
im->w, im->h,
1, 1);
if ((im->im) && (!im->dirty))
{
evas_common_image_unref(im->im);

View File

@ -93,9 +93,9 @@ _xr_render_surface_adopt(XCBimage_Info *xcbinf, XCBDRAWABLE draw, int w, int h,
CARD32 mask;
CARD32 values[3];
rs = calloc(1, sizeof(XCBrender_Surface));
fmt = XCBRenderFindVisualFormat(xcbinf->conn, xcbinf->vis);
if (!fmt) return NULL;
rs = calloc(1, sizeof(XCBrender_Surface));
rs->xcbinf = xcbinf;
rs->w = w;
rs->h = h;
@ -386,6 +386,7 @@ _xr_render_surface_clips_set(XCBrender_Surface *rs, RGBA_Draw_Context *dc, int r
void
_xr_render_surface_composite(XCBrender_Surface *srs, XCBrender_Surface *drs, RGBA_Draw_Context *dc, int sx, int sy, int sw, int sh, int x, int y, int w, int h, int smooth)
{
XCBrender_Surface *trs = NULL;
XCBRenderTRANSFORM xf;
XCBRenderPICTURE mask;
CARD32 value_mask;
@ -395,6 +396,65 @@ _xr_render_surface_composite(XCBrender_Surface *srs, XCBrender_Surface *drs, RGB
int op;
if ((sw <= 0) || (sh <= 0) || (w <= 0) || (h <= 0)) return;
value_mask = XCBRenderCPClipMask;
value_list[0] = 0;
XCBRenderChangePicture(srs->xcbinf->conn, srs->pic, value_mask, value_list);
XCBRenderChangePicture(srs->xcbinf->conn, drs->pic, value_mask, value_list);
op = XCBRenderPictOpSrc;
if (srs->alpha) op = XCBRenderPictOpOver;
mask.xid = 0;
if ((dc) && (dc->mul.use))
{
r = (int)(R_VAL(&dc->mul.col));
g = (int)(G_VAL(&dc->mul.col));
b = (int)(B_VAL(&dc->mul.col));
a = (int)(A_VAL(&dc->mul.col));
if ((r != 0xff) || (g != 0xff) || (b != 0xff) || (a != 0xff))
{
if ((srs->xcbinf->mul_r != r) || (srs->xcbinf->mul_g != g) ||
(srs->xcbinf->mul_b != b) || (srs->xcbinf->mul_a != a))
{
srs->xcbinf->mul_r = r;
srs->xcbinf->mul_g = g;
srs->xcbinf->mul_b = b;
srs->xcbinf->mul_a = a;
_xr_render_surface_solid_rectangle_set(srs->xcbinf->mul,
r,
g,
b,
a,
0, 0, 1, 1);
}
op = XCBRenderPictOpOver;
value_mask = XCBRenderCPComponentAlpha;
value_list[0] = 1;
XCBRenderChangePicture(srs->xcbinf->conn, mask, value_mask, value_list);
if ((r == 0xff) && (g == 0xff) && (b == 0xff) && (a != 0xff))
{
}
else
{
xf.matrix11 = 1;
xf.matrix12 = 0;
xf.matrix13 = 0;
xf.matrix21 = 0;
xf.matrix22 = 1;
xf.matrix23 = 0;
xf.matrix31 = 0;
xf.matrix32 = 0;
xf.matrix33 = 1;
trs = _xr_render_surface_new(srs->xcbinf, sw, sh, srs->fmt, srs->alpha);
XCBRenderSetPictureTransform(srs->xcbinf->conn, srs->pic, xf);
XCBRenderComposite(srs->xcbinf->conn, XCBRenderPictOpSrc, srs->pic, mask, trs->pic,
sx, sy, 0, 0, 0, 0, sw, sh);
mask.xid = 0;
}
}
}
sf = MAX(sw, sh);
#define BMAX 26
@ -424,45 +484,32 @@ _xr_render_surface_composite(XCBrender_Surface *srs, XCBrender_Surface *drs, RGB
xf.matrix32 = 0;
xf.matrix33 = sf;
op = XCBRenderPictOpSrc;
if (srs->alpha) op = XCBRenderPictOpOver;
mask.xid = 0;
if ((dc) && (dc->mul.use))
{
r = (int)(R_VAL(&dc->mul.col));
g = (int)(G_VAL(&dc->mul.col));
b = (int)(B_VAL(&dc->mul.col));
a = (int)(A_VAL(&dc->mul.col));
if ((r != 0xff) || (g != 0xff) || (b != 0xff) || (a != 0xff))
{
if ((srs->xcbinf->mul_r != r) || (srs->xcbinf->mul_g != g) ||
(srs->xcbinf->mul_b != b) || (srs->xcbinf->mul_a != a))
{
srs->xcbinf->mul_r = r;
srs->xcbinf->mul_g = g;
srs->xcbinf->mul_b = b;
srs->xcbinf->mul_a = a;
_xr_render_surface_solid_rectangle_set(srs->xcbinf->mul, r, g, b, a, 0, 0, 1, 1);
}
op = XCBRenderPictOpOver;
mask = srs->xcbinf->mul->pic;
}
}
XCBRenderSetPictureTransform(srs->xcbinf->conn, srs->pic, xf);
value_mask = XCBRenderCPClipMask;
value_list[0] = 0;
XCBRenderChangePicture(srs->xcbinf->conn, srs->pic, value_mask, value_list);
XCBRenderChangePicture(srs->xcbinf->conn, drs->pic, value_mask, value_list);
if (smooth) XCBRenderSetPictureFilter(srs->xcbinf->conn, srs->pic, strlen("best"), "best", 0, NULL);
else XCBRenderSetPictureFilter(srs->xcbinf->conn, srs->pic, strlen("nearest"), "nearest", 0, NULL);
_xr_render_surface_clips_set(drs, dc, x, y, w, h);
XCBRenderComposite(srs->xcbinf->conn, op, srs->pic, mask, drs->pic,
((sx * w) + (sw / 2)) / sw,
((sy * h) + (sh / 2)) / sh,
0, 0, x, y, w, h);
if (trs)
{
if (smooth)
XCBRenderSetPictureFilter (trs->xcbinf->conn, trs->pic, strlen ("best"), "best", 0, NULL);
else
XCBRenderSetPictureFilter (trs->xcbinf->conn, trs->pic, strlen ("nearest"), "nearest", 0, NULL);
XCBRenderSetPictureTransform(trs->xcbinf->conn, trs->pic, xf);
XCBRenderComposite(srs->xcbinf->conn, op, trs->pic, mask, drs->pic,
0, 0, 0, 0, x, y, w, h);
_xr_render_surface_free(trs);
}
else
{
if (smooth)
XCBRenderSetPictureFilter (srs->xcbinf->conn, srs->pic, strlen ("best"), "best", 0, NULL);
else
XCBRenderSetPictureFilter (srs->xcbinf->conn, srs->pic, strlen ("nearest"), "nearest", 0, NULL);
XCBRenderSetPictureTransform(srs->xcbinf->conn, srs->pic, xf);
XCBRenderComposite(srs->xcbinf->conn, op, srs->pic, mask, drs->pic,
((sx * w) + (sw / 2)) / sw,
((sy * h) + (sh / 2)) / sh,
0, 0, x, y, w, h);
}
}
void
@ -473,7 +520,7 @@ _xr_render_surface_copy(XCBrender_Surface *srs, XCBrender_Surface *drs, int sx,
CARD32 value_mask;
CARD32 value_list[1];
if ((w <= 0) || (h <= 0)) return;
if ((w <= 0) || (h <= 0) || (!srs) || (!drs)) return;
xf.matrix11 = 1;
xf.matrix12 = 0;
xf.matrix13 = 0;

View File

@ -185,7 +185,7 @@ evas_image_load_file_data_tiff(RGBA_Image *im, const char *file, const char *key
uint32 num_pixels;
int fd;
uint16 magic_number;
if (!file)
return 0;