2006-09-11 07:42:39 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2005-10-02 08:15:44 -07:00
|
|
|
#include "evas_common.h"
|
2006-10-04 22:28:35 -07:00
|
|
|
//#include "evas_macros.h"
|
2005-10-02 08:15:44 -07:00
|
|
|
#include "evas_private.h"
|
|
|
|
#include "evas_engine.h"
|
|
|
|
#include "Evas_Engine_XRender_X11.h"
|
2005-10-07 21:57:57 -07:00
|
|
|
#include <math.h>
|
2005-10-02 08:15:44 -07:00
|
|
|
|
2006-09-11 17:03:53 -07:00
|
|
|
/* this is a work around broken xrender - when/if this ever gets fixed in xorg
|
|
|
|
* we can comment this out and one day remove it - for now keep it until such
|
|
|
|
* a fix is spotted in the wild
|
|
|
|
*/
|
|
|
|
#define BROKEN_XORG_XRENDER 1
|
|
|
|
|
2006-09-13 03:28:22 -07:00
|
|
|
/* should be const char*, but the prototype for XRenderSetPictureFilter
|
|
|
|
* is silly
|
|
|
|
*/
|
|
|
|
static inline char *
|
|
|
|
get_filter(int smooth)
|
|
|
|
{
|
|
|
|
return smooth ? FilterBest : FilterNearest;
|
|
|
|
}
|
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
Xrender_Surface *
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_new(Ximage_Info *xinf, int w, int h, XRenderPictFormat *fmt, int alpha)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
Xrender_Surface *rs;
|
|
|
|
XRenderPictureAttributes att;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-05-11 05:48:22 -07:00
|
|
|
if ((!xinf) || (!fmt) || (w < 1) || (h < 1)) return NULL;
|
2005-10-02 08:15:44 -07:00
|
|
|
rs = calloc(1, sizeof(Xrender_Surface));
|
|
|
|
if (!rs) return NULL;
|
|
|
|
rs->xinf = xinf;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->width = w;
|
|
|
|
rs->height = h;
|
|
|
|
rs->x11.xlib.fmt = fmt;
|
2005-10-02 08:15:44 -07:00
|
|
|
rs->alpha = alpha;
|
|
|
|
rs->depth = fmt->depth;
|
|
|
|
rs->allocated = 1;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.draw = XCreatePixmap(xinf->x11.connection, xinf->x11.root, w, h, fmt->depth);
|
|
|
|
if (rs->x11.xlib.draw == None)
|
2006-05-11 05:48:22 -07:00
|
|
|
{
|
|
|
|
free(rs);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-10-08 07:59:45 -07:00
|
|
|
rs->xinf->references++;
|
2008-04-07 16:07:23 -07:00
|
|
|
att.dither = 1;
|
2005-10-06 02:53:10 -07:00
|
|
|
att.component_alpha = 0;
|
2005-10-02 08:15:44 -07:00
|
|
|
att.repeat = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.pic = XRenderCreatePicture(xinf->x11.connection, rs->x11.xlib.draw, fmt,
|
2008-04-07 16:07:23 -07:00
|
|
|
CPRepeat | CPDither | CPComponentAlpha, &att);
|
2009-03-24 00:44:54 -07:00
|
|
|
if (rs->x11.xlib.pic == None)
|
2006-05-11 05:48:22 -07:00
|
|
|
{
|
2009-03-24 00:44:54 -07:00
|
|
|
XFreePixmap(rs->xinf->x11.connection, rs->x11.xlib.draw);
|
2006-05-11 05:48:22 -07:00
|
|
|
rs->xinf->references--;
|
|
|
|
free(rs);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
Xrender_Surface *
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_adopt(Ximage_Info *xinf, Drawable draw, int w, int h, int alpha)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
Xrender_Surface *rs;
|
|
|
|
XRenderPictFormat *fmt;
|
|
|
|
XRenderPictureAttributes att;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-05-11 05:48:22 -07:00
|
|
|
if ((!xinf) || (draw == None) || (w < 1) || (h < 1)) return NULL;
|
2009-03-24 00:44:54 -07:00
|
|
|
fmt = XRenderFindVisualFormat(xinf->x11.connection, xinf->x11.visual);
|
2006-03-08 05:43:46 -08:00
|
|
|
if (!fmt) return NULL;
|
|
|
|
rs = calloc(1, sizeof(Xrender_Surface));
|
2006-05-11 05:48:22 -07:00
|
|
|
if (!rs) return NULL;
|
2005-10-02 08:15:44 -07:00
|
|
|
rs->xinf = xinf;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->width = w;
|
|
|
|
rs->height = h;
|
|
|
|
rs->x11.xlib.fmt = fmt;
|
2005-10-02 08:15:44 -07:00
|
|
|
rs->alpha = alpha;
|
|
|
|
rs->depth = fmt->depth;
|
2005-10-02 20:34:21 -07:00
|
|
|
if (fmt->depth == 32) rs->alpha = 1;
|
|
|
|
rs->allocated = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.draw = draw;
|
2005-10-08 07:59:45 -07:00
|
|
|
rs->xinf->references++;
|
2008-04-07 16:07:23 -07:00
|
|
|
att.dither = 1;
|
2005-10-06 02:53:10 -07:00
|
|
|
att.component_alpha = 0;
|
2005-10-02 20:34:21 -07:00
|
|
|
att.repeat = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.pic = XRenderCreatePicture(xinf->x11.connection, rs->x11.xlib.draw, fmt,
|
2008-04-07 16:07:23 -07:00
|
|
|
CPRepeat | CPDither | CPComponentAlpha, &att);
|
2009-03-24 00:44:54 -07:00
|
|
|
if (rs->x11.xlib.pic == None)
|
2006-05-11 05:48:22 -07:00
|
|
|
{
|
|
|
|
rs->xinf->references--;
|
|
|
|
free(rs);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-10-02 20:34:21 -07:00
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
Xrender_Surface *
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_format_adopt(Ximage_Info *xinf, Drawable draw, int w, int h, XRenderPictFormat *fmt, int alpha)
|
2005-10-02 20:34:21 -07:00
|
|
|
{
|
|
|
|
Xrender_Surface *rs;
|
|
|
|
XRenderPictureAttributes att;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-05-11 05:48:22 -07:00
|
|
|
if ((!xinf) || (!fmt) || (draw == None) || (w < 1) || (h < 1)) return NULL;
|
2005-10-02 20:34:21 -07:00
|
|
|
rs = calloc(1, sizeof(Xrender_Surface));
|
2006-05-11 05:48:22 -07:00
|
|
|
if (!rs) return NULL;
|
2005-10-02 20:34:21 -07:00
|
|
|
rs->xinf = xinf;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->width = w;
|
|
|
|
rs->height = h;
|
|
|
|
rs->x11.xlib.fmt = fmt;
|
2005-10-02 20:34:21 -07:00
|
|
|
rs->alpha = alpha;
|
|
|
|
rs->depth = fmt->depth;
|
|
|
|
if (fmt->depth == 32) rs->alpha = 1;
|
2005-10-08 07:59:45 -07:00
|
|
|
rs->xinf->references++;
|
2005-10-02 08:15:44 -07:00
|
|
|
rs->allocated = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.draw = draw;
|
2009-01-04 20:06:19 -08:00
|
|
|
att.dither = 1;
|
2005-10-06 02:53:10 -07:00
|
|
|
att.component_alpha = 0;
|
2005-10-02 08:15:44 -07:00
|
|
|
att.repeat = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
rs->x11.xlib.pic = XRenderCreatePicture(xinf->x11.connection, rs->x11.xlib.draw, fmt,
|
2009-01-04 20:06:19 -08:00
|
|
|
CPRepeat | CPDither | CPComponentAlpha, &att);
|
2009-03-24 00:44:54 -07:00
|
|
|
if (rs->x11.xlib.pic == None)
|
2006-05-11 05:48:22 -07:00
|
|
|
{
|
|
|
|
rs->xinf->references--;
|
|
|
|
free(rs);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_free(Xrender_Surface *rs)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2006-05-11 05:48:22 -07:00
|
|
|
if (!rs) return;
|
|
|
|
if (rs->xinf)
|
|
|
|
{
|
2009-03-24 00:44:54 -07:00
|
|
|
if ((rs->allocated) && (rs->x11.xlib.draw != None))
|
|
|
|
XFreePixmap(rs->xinf->x11.connection, rs->x11.xlib.draw);
|
|
|
|
if (rs->x11.xlib.pic != None)
|
|
|
|
XRenderFreePicture(rs->xinf->x11.connection, rs->x11.xlib.pic);
|
|
|
|
_xr_xlib_image_info_free(rs->xinf);
|
2006-05-11 05:48:22 -07:00
|
|
|
rs->xinf = NULL;
|
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
free(rs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_repeat_set(Xrender_Surface *rs, int repeat)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
XRenderPictureAttributes att;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
att.repeat = repeat;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(rs->xinf->x11.connection, rs->x11.xlib.pic, CPRepeat, &att);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_solid_rectangle_set(Xrender_Surface *rs, int r, int g, int b, int a, int x, int y, int w, int h)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
XRenderColor col;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
col.red = (r << 8) | r;
|
|
|
|
col.green = (g << 8) | g;
|
|
|
|
col.blue = (b << 8) | b;
|
|
|
|
col.alpha = (a << 8) | a;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderFillRectangle(rs->xinf->x11.connection, PictOpSrc, rs->x11.xlib.pic, &col, x, y, w, h);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_argb_pixels_fill(Xrender_Surface *rs, int sw, int sh __UNUSED__, void *pixels, int x, int y, int w, int h, int ox, int oy)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
Ximage_Image *xim;
|
|
|
|
unsigned int *p, *sp, *sple, *spe;
|
|
|
|
unsigned int jump, sjump;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
|
|
|
xim = _xr_xlib_image_new(rs->xinf, w, h, rs->depth);
|
2005-10-02 08:15:44 -07:00
|
|
|
if (!xim) return;
|
|
|
|
p = (unsigned int *)xim->data;
|
|
|
|
sp = ((unsigned int *)pixels) + (y * sw) + x;
|
|
|
|
jump = ((xim->line_bytes / 4) - w);
|
|
|
|
sjump = sw - w;
|
|
|
|
spe = sp + ((h - 1) * sw) + w;
|
2005-10-05 21:18:52 -07:00
|
|
|
if
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
2009-03-24 00:44:54 -07:00
|
|
|
(xim->x11.xlib.xim->byte_order == LSBFirst)
|
2005-10-05 21:18:52 -07:00
|
|
|
#else
|
2009-03-24 00:44:54 -07:00
|
|
|
(xim->x11.xlib.xim->byte_order == MSBFirst)
|
2005-10-05 21:18:52 -07:00
|
|
|
#endif
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2005-10-05 21:18:52 -07:00
|
|
|
while (sp < spe)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2005-10-05 21:18:52 -07:00
|
|
|
sple = sp + w;
|
|
|
|
while (sp < sple)
|
|
|
|
{
|
2006-09-30 03:18:37 -07:00
|
|
|
*p++ = (*sp << 24) + ((*sp << 8) & 0xff0000) + ((*sp >> 8) & 0xff00) + (*sp >> 24);
|
|
|
|
// *p++ = (B_VAL(sp) << 24) | (G_VAL(sp) << 16) | (R_VAL(sp) << 8) | A_VAL(sp);
|
2005-10-05 21:18:52 -07:00
|
|
|
sp++;
|
|
|
|
}
|
|
|
|
p += jump;
|
|
|
|
sp += sjump;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (sp < spe)
|
|
|
|
{
|
|
|
|
sple = sp + w;
|
|
|
|
while (sp < sple)
|
2006-09-30 03:18:37 -07:00
|
|
|
*p++ = *sp++;
|
2005-10-05 21:18:52 -07:00
|
|
|
p += jump;
|
|
|
|
sp += sjump;
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_image_put(xim, rs->x11.xlib.draw, x + ox, y + oy, w, h);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_rgb_pixels_fill(Xrender_Surface *rs, int sw, int sh __UNUSED__, void *pixels, int x, int y, int w, int h, int ox, int oy)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
Ximage_Image *xim;
|
|
|
|
unsigned int *p, *sp, *sple, *spe;
|
|
|
|
unsigned int jump, sjump;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
|
|
|
xim = _xr_xlib_image_new(rs->xinf, w, h, rs->depth);
|
2005-10-02 08:15:44 -07:00
|
|
|
if (!xim) return;
|
|
|
|
p = (unsigned int *)xim->data;
|
|
|
|
sp = ((unsigned int *)pixels) + (y * sw) + x;
|
|
|
|
sjump = sw - w;
|
|
|
|
spe = sp + ((h - 1) * sw) + w;
|
2008-04-07 16:07:23 -07:00
|
|
|
if (rs->depth == 16)
|
|
|
|
{
|
|
|
|
jump = ((xim->line_bytes / 2) - w);
|
|
|
|
/* FIXME: if rs->depth == 16 - convert */
|
|
|
|
Gfx_Func_Convert conv_func;
|
|
|
|
int swap;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2005-10-05 21:18:52 -07:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
2009-03-24 00:44:54 -07:00
|
|
|
swap = (int)(xim->x11.xlib.xim->byte_order == LSBFirst);
|
2005-10-05 21:18:52 -07:00
|
|
|
#else
|
2009-03-24 00:44:54 -07:00
|
|
|
swap = (int)(xim->x11.xlib.xim->byte_order == MSBFirst);
|
2005-10-05 21:18:52 -07:00
|
|
|
#endif
|
2008-04-07 16:07:23 -07:00
|
|
|
/* FIXME: swap not handled */
|
2009-03-24 00:44:54 -07:00
|
|
|
conv_func = evas_common_convert_func_get((DATA8 *)sp, w, h, rs->depth,
|
|
|
|
((Visual *)rs->xinf->x11.visual)->red_mask,
|
|
|
|
((Visual *)rs->xinf->x11.visual)->green_mask,
|
|
|
|
((Visual *)rs->xinf->x11.visual)->blue_mask,
|
2008-04-07 16:07:23 -07:00
|
|
|
PAL_MODE_NONE, 0);
|
|
|
|
if (conv_func)
|
2009-03-24 00:44:54 -07:00
|
|
|
conv_func(sp, (DATA8 *)p, sjump, jump, w, h, x, y, NULL);
|
2005-10-05 21:18:52 -07:00
|
|
|
}
|
|
|
|
else
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2008-04-07 16:07:23 -07:00
|
|
|
jump = ((xim->line_bytes / 4) - w);
|
|
|
|
if
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
2009-03-24 00:44:54 -07:00
|
|
|
(xim->x11.xlib.xim->byte_order == LSBFirst)
|
2008-04-07 16:07:23 -07:00
|
|
|
#else
|
2009-03-24 00:44:54 -07:00
|
|
|
(xim->x11.xlib.xim->byte_order == MSBFirst)
|
2008-04-07 16:07:23 -07:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
while (sp < spe)
|
|
|
|
{
|
|
|
|
sple = sp + w;
|
|
|
|
while (sp < sple)
|
|
|
|
{
|
|
|
|
*p++ = (*sp << 24) + ((*sp << 8) & 0xff0000) + ((*sp >> 8) & 0xff00) + 0xff;
|
|
|
|
// *p++ = ((B_VAL(sp)) << 24) | ((G_VAL(sp)) << 16) | ((R_VAL(sp)) << 8) | 0x000000ff;
|
|
|
|
sp++;
|
|
|
|
}
|
|
|
|
p += jump;
|
|
|
|
sp += sjump;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2008-04-07 16:07:23 -07:00
|
|
|
while (sp < spe)
|
|
|
|
{
|
|
|
|
sple = sp + w;
|
|
|
|
while (sp < sple)
|
|
|
|
*p++ = 0xff000000 | *sp++;
|
|
|
|
p += jump;
|
|
|
|
sp += sjump;
|
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_image_put(xim, rs->x11.xlib.draw, x + ox, y + oy, w, h);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
|
2005-10-07 21:57:57 -07:00
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_clips_set(Xrender_Surface *rs, RGBA_Draw_Context *dc, int rx, int ry, int rw, int rh)
|
2005-10-07 21:57:57 -07:00
|
|
|
{
|
|
|
|
int num = 0;
|
|
|
|
XRectangle *rect = NULL;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2005-10-07 21:57:57 -07:00
|
|
|
if ((dc) && (dc->clip.use))
|
|
|
|
{
|
|
|
|
RECTS_CLIP_TO_RECT(rx, ry, rw, rh,
|
|
|
|
dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
|
|
|
|
}
|
|
|
|
if ((!dc) || (!dc->cutout.rects))
|
|
|
|
{
|
|
|
|
rect = malloc(sizeof(XRectangle));
|
|
|
|
if (!rect) return;
|
|
|
|
rect->x = rx;
|
|
|
|
rect->y = ry;
|
|
|
|
rect->width = rw;
|
|
|
|
rect->height = rh;
|
|
|
|
num = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-04 02:55:40 -07:00
|
|
|
Cutout_Rects *rects;
|
|
|
|
Cutout_Rect *r;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
rects = evas_common_draw_context_apply_cutouts(dc);
|
|
|
|
num = rects->active;
|
2005-10-07 21:57:57 -07:00
|
|
|
rect = malloc(num * sizeof(XRectangle));
|
|
|
|
if (!rect) return;
|
2007-04-04 02:55:40 -07:00
|
|
|
for (i = 0; i < num; i++)
|
2005-10-07 21:57:57 -07:00
|
|
|
{
|
2007-04-04 02:55:40 -07:00
|
|
|
r = rects->rects + i;
|
2005-10-07 21:57:57 -07:00
|
|
|
rect[i].x = r->x;
|
|
|
|
rect[i].y = r->y;
|
|
|
|
rect[i].width = r->w;
|
|
|
|
rect[i].height = r->h;
|
|
|
|
}
|
2007-04-04 02:55:40 -07:00
|
|
|
evas_common_draw_context_apply_clear_cutouts(rects);
|
2005-10-07 21:57:57 -07:00
|
|
|
}
|
|
|
|
if (!rect) return;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureClipRectangles(rs->xinf->x11.connection, rs->x11.xlib.pic, 0, 0, rect, num);
|
2005-10-07 21:57:57 -07:00
|
|
|
free(rect);
|
|
|
|
}
|
|
|
|
|
2006-09-11 07:42:39 -07:00
|
|
|
/* initialized the transform to the identity */
|
2006-10-04 22:28:35 -07:00
|
|
|
static void
|
|
|
|
init_xtransform(XTransform *t)
|
2006-09-11 07:42:39 -07:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
t->matrix[i][j] = XDoubleToFixed((i == j) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2006-10-04 22:28:35 -07:00
|
|
|
static void
|
2006-11-05 04:51:23 -08:00
|
|
|
set_xtransform_scale(XTransform *t, int sw, int sh, int w, int h, int tx, int ty)
|
2006-10-04 22:28:35 -07:00
|
|
|
{
|
2006-11-05 01:28:50 -08:00
|
|
|
// if ((sw > 1) && (w > 1))
|
|
|
|
// { sw--; w--; }
|
|
|
|
// if ((sh > 1) && (h > 1))
|
|
|
|
// { sh--; h--; }
|
2006-11-05 04:51:23 -08:00
|
|
|
t->matrix[0][0] = XDoubleToFixed((double)(sw) / (double)(w));
|
|
|
|
t->matrix[1][1] = XDoubleToFixed((double)(sh) / (double)(h));
|
2006-11-05 04:53:25 -08:00
|
|
|
t->matrix[2][0] = (tx * sw) / w;
|
|
|
|
t->matrix[2][1] = (ty * sh) / h;
|
2006-10-04 22:28:35 -07:00
|
|
|
}
|
2006-09-11 07:42:39 -07:00
|
|
|
|
2005-10-06 02:53:10 -07:00
|
|
|
// when color multiplier is used want: instead
|
2005-10-07 21:57:57 -07:00
|
|
|
// CA src IN mask SRC temp; non-CA temp OVER dst. - i think. need to check.
|
2005-10-02 08:15:44 -07:00
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_composite(Xrender_Surface *srs, Xrender_Surface *drs, RGBA_Draw_Context *dc, int sx, int sy, int sw, int sh, int x, int y, int w, int h, int smooth)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2006-04-16 10:04:36 -07:00
|
|
|
Xrender_Surface *trs = NULL;
|
2006-09-11 08:19:02 -07:00
|
|
|
XTransform xf;
|
2005-10-02 08:15:44 -07:00
|
|
|
XRenderPictureAttributes att;
|
2006-10-04 22:28:35 -07:00
|
|
|
Picture mask = None;
|
|
|
|
int e, is_scaling, op;
|
2005-10-02 08:15:44 -07:00
|
|
|
|
|
|
|
if ((sw <= 0) || (sh <= 0) || (w <= 0) || (h <= 0)) return;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-10-04 22:28:35 -07:00
|
|
|
is_scaling = e = ((sw != w) || (sh != h));
|
2006-06-07 16:30:15 -07:00
|
|
|
|
2006-04-16 10:04:36 -07:00
|
|
|
att.clip_mask = None;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, srs->x11.xlib.pic, CPClipMask, &att);
|
|
|
|
XRenderChangePicture(drs->xinf->x11.connection, drs->x11.xlib.pic, CPClipMask, &att);
|
|
|
|
|
2006-10-04 22:28:35 -07:00
|
|
|
init_xtransform(&xf);
|
|
|
|
|
|
|
|
op = PictOpOver;
|
|
|
|
if (dc->render_op == _EVAS_RENDER_BLEND)
|
|
|
|
{
|
|
|
|
if (!srs->alpha) op = PictOpSrc;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_BLEND_REL)
|
2006-11-05 01:28:50 -08:00
|
|
|
op = PictOpAtop;
|
2006-10-04 22:28:35 -07:00
|
|
|
else if (dc->render_op == _EVAS_RENDER_MUL)
|
2006-11-05 01:28:50 -08:00
|
|
|
op = PictOpIn;
|
2006-10-04 22:28:35 -07:00
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY)
|
2006-11-05 01:28:50 -08:00
|
|
|
op = PictOpSrc;
|
2006-10-04 22:28:35 -07:00
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY_REL)
|
2006-11-05 01:28:50 -08:00
|
|
|
op = PictOpIn;
|
2006-10-04 22:28:35 -07:00
|
|
|
else if (dc->render_op == _EVAS_RENDER_MASK)
|
2006-11-05 01:28:50 -08:00
|
|
|
op = PictOpInReverse;
|
2006-10-04 22:28:35 -07:00
|
|
|
|
2006-04-16 10:04:36 -07:00
|
|
|
if ((dc) && (dc->mul.use))
|
|
|
|
{
|
2006-10-04 22:28:35 -07:00
|
|
|
int r, g, b, a;
|
|
|
|
|
|
|
|
if ((op == PictOpOver) && (!dc->mul.col)) return;
|
|
|
|
a = dc->mul.col >> 24;
|
|
|
|
r = (dc->mul.col >> 16) & 0xff;
|
|
|
|
g = (dc->mul.col >> 8) & 0xff;
|
|
|
|
b = dc->mul.col & 0xff;
|
2006-11-04 22:04:51 -08:00
|
|
|
if (a < 255) op = PictOpOver;
|
2006-10-04 22:28:35 -07:00
|
|
|
if (dc->mul.col != 0xffffffff)
|
2006-04-16 10:04:36 -07:00
|
|
|
{
|
|
|
|
if ((srs->xinf->mul_r != r) || (srs->xinf->mul_g != g) ||
|
|
|
|
(srs->xinf->mul_b != b) || (srs->xinf->mul_a != a))
|
|
|
|
{
|
|
|
|
srs->xinf->mul_r = r;
|
|
|
|
srs->xinf->mul_g = g;
|
|
|
|
srs->xinf->mul_b = b;
|
|
|
|
srs->xinf->mul_a = a;
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_solid_rectangle_set(srs->xinf->mul,
|
|
|
|
r, g, b, a,
|
|
|
|
0, 0, 1, 1);
|
2006-04-16 10:04:36 -07:00
|
|
|
}
|
2009-03-24 00:44:54 -07:00
|
|
|
mask = srs->xinf->mul->x11.xlib.pic;
|
2006-10-04 22:28:35 -07:00
|
|
|
if (dc->mul.col == (a * 0x01010101))
|
2006-04-16 10:04:36 -07:00
|
|
|
{
|
2006-06-07 16:30:15 -07:00
|
|
|
att.component_alpha = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, mask, CPComponentAlpha, &att);
|
2006-04-16 10:04:36 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-05 15:55:04 -07:00
|
|
|
if ((srs->alpha) || (a != 0xff))
|
2009-03-24 00:44:54 -07:00
|
|
|
trs = _xr_xlib_render_surface_new(srs->xinf, sw + 2, sh + 2,
|
|
|
|
srs->xinf->x11.fmt32, 1);
|
2006-05-05 15:55:04 -07:00
|
|
|
else
|
2009-03-24 00:44:54 -07:00
|
|
|
trs = _xr_xlib_render_surface_new(srs->xinf, sw + 2, sh + 2,
|
|
|
|
srs->x11.xlib.fmt, srs->alpha);
|
2006-06-07 16:30:15 -07:00
|
|
|
if (!trs) return;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-06-07 16:30:15 -07:00
|
|
|
att.component_alpha = 1;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, mask, CPComponentAlpha, &att);
|
|
|
|
XRenderSetPictureTransform(srs->xinf->x11.connection, srs->x11.xlib.pic, &xf);
|
|
|
|
XRenderComposite(srs->xinf->x11.connection, PictOpSrc, srs->x11.xlib.pic, mask,
|
|
|
|
trs->x11.xlib.pic,
|
|
|
|
sx, sy,
|
|
|
|
sx, sy,
|
2006-11-05 04:51:23 -08:00
|
|
|
0, 0, sw + 2, sh + 2);
|
2006-06-07 16:30:15 -07:00
|
|
|
mask = None;
|
2006-04-16 10:04:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-07 16:30:15 -07:00
|
|
|
|
2006-11-05 04:51:23 -08:00
|
|
|
//#define HFW + (sw / 2)
|
2009-03-24 00:44:54 -07:00
|
|
|
//#define HFH + (sh / 2)
|
2006-11-05 04:51:23 -08:00
|
|
|
#define HFW
|
|
|
|
#define HFH
|
2009-03-24 00:44:54 -07:00
|
|
|
|
|
|
|
_xr_xlib_render_surface_clips_set(drs, dc, x, y, w, h);
|
2006-04-16 10:04:36 -07:00
|
|
|
if (trs)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureFilter(trs->xinf->x11.connection, trs->x11.xlib.pic, get_filter(smooth), NULL, 0);
|
2006-09-16 07:59:28 -07:00
|
|
|
|
2006-11-05 04:51:23 -08:00
|
|
|
set_xtransform_scale(&xf, sw, sh, w, h, -1, -1);
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureTransform(trs->xinf->x11.connection, trs->x11.xlib.pic, &xf);
|
2006-10-04 22:28:35 -07:00
|
|
|
|
|
|
|
att.component_alpha = 0;
|
2006-11-05 04:51:23 -08:00
|
|
|
if (dc->render_op == _EVAS_RENDER_MUL) att.component_alpha = 1;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(trs->xinf->x11.connection, trs->x11.xlib.pic, CPComponentAlpha, &att);
|
2006-10-04 22:28:35 -07:00
|
|
|
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderComposite(trs->xinf->x11.connection, op, trs->x11.xlib.pic, mask, drs->x11.xlib.pic,
|
2006-11-05 04:51:23 -08:00
|
|
|
(w HFW) / sw, (h HFH) / sh,
|
|
|
|
(w HFW) / sw, (h HFH) / sh,
|
|
|
|
x, y, w, h);
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_free(trs);
|
2006-04-16 10:04:36 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-16 07:59:28 -07:00
|
|
|
if (srs->bordered && is_scaling)
|
2006-06-07 16:30:15 -07:00
|
|
|
{
|
2009-03-24 00:44:54 -07:00
|
|
|
trs = _xr_xlib_render_surface_new(srs->xinf, sw + 2, sh + 2,
|
|
|
|
srs->x11.xlib.fmt, srs->alpha);
|
2006-11-05 01:28:50 -08:00
|
|
|
if (!trs) return;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-11-05 01:28:50 -08:00
|
|
|
att.component_alpha = 0;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, srs->x11.xlib.pic, CPComponentAlpha, &att);
|
|
|
|
XRenderSetPictureTransform(srs->xinf->x11.connection, srs->x11.xlib.pic, &xf);
|
|
|
|
|
|
|
|
XRenderComposite(srs->xinf->x11.connection, PictOpSrc, srs->x11.xlib.pic, None,
|
|
|
|
trs->x11.xlib.pic, sx, sy, sx, sy, 0, 0, sw + 2, sh + 2);
|
|
|
|
|
|
|
|
XRenderSetPictureFilter(trs->xinf->x11.connection, trs->x11.xlib.pic, get_filter(smooth), NULL, 0);
|
|
|
|
|
2006-11-05 04:51:23 -08:00
|
|
|
set_xtransform_scale(&xf, sw, sh, w, h, -1, -1);
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureTransform(trs->xinf->x11.connection, trs->x11.xlib.pic, &xf);
|
|
|
|
|
2006-11-05 01:28:50 -08:00
|
|
|
if (dc->render_op == _EVAS_RENDER_MUL)
|
|
|
|
{
|
|
|
|
att.component_alpha = 1;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(trs->xinf->x11.connection, trs->x11.xlib.pic, CPComponentAlpha, &att);
|
2006-11-05 01:28:50 -08:00
|
|
|
}
|
2009-03-24 00:44:54 -07:00
|
|
|
|
|
|
|
XRenderComposite(trs->xinf->x11.connection, op, trs->x11.xlib.pic, mask, drs->x11.xlib.pic,
|
2006-11-05 04:51:23 -08:00
|
|
|
(w HFW) / sw, (h HFH) / sh,
|
|
|
|
(w HFW) / sw, (h HFH) / sh,
|
|
|
|
// 1, 1, 1, 1,
|
|
|
|
x, y, w, h);
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_free(trs);
|
2006-06-07 16:30:15 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureFilter(srs->xinf->x11.connection, srs->x11.xlib.pic, get_filter(smooth), NULL, 0);
|
|
|
|
|
2006-11-05 04:51:23 -08:00
|
|
|
set_xtransform_scale(&xf, sw, sh, w, h, 0, 0);
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureTransform(srs->xinf->x11.connection, srs->x11.xlib.pic, &xf);
|
|
|
|
|
2006-11-05 01:28:50 -08:00
|
|
|
att.component_alpha = 0;
|
|
|
|
if (dc->render_op == _EVAS_RENDER_MUL)
|
|
|
|
att.component_alpha = 1;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, srs->x11.xlib.pic, CPComponentAlpha, &att);
|
|
|
|
|
|
|
|
XRenderComposite(srs->xinf->x11.connection, op, srs->x11.xlib.pic, mask, drs->x11.xlib.pic,
|
2006-11-05 04:51:23 -08:00
|
|
|
((((sx + 1) * w) HFW) / sw),
|
|
|
|
((((sy + 1) * h) HFH) / sh),
|
|
|
|
((((sx + 1) * w) HFW) / sw),
|
|
|
|
((((sy + 1) * h) HFH) / sh),
|
|
|
|
x, y, w, h);
|
2006-06-07 16:30:15 -07:00
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_copy(Xrender_Surface *srs, Xrender_Surface *drs, int sx, int sy, int x, int y, int w, int h)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
XTransform xf;
|
|
|
|
XRenderPictureAttributes att;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-03-08 05:43:46 -08:00
|
|
|
if ((w <= 0) || (h <= 0) || (!srs) || (!drs)) return;
|
2006-09-11 07:42:39 -07:00
|
|
|
|
2006-10-04 22:28:35 -07:00
|
|
|
init_xtransform(&xf);
|
2009-03-24 00:44:54 -07:00
|
|
|
#ifdef BROKEN_XORG_XRENDER
|
2006-05-11 05:48:22 -07:00
|
|
|
/* FIXME: why do we need to change the identity matrix ifthe src surface
|
|
|
|
* is 1 bit deep?
|
|
|
|
*/
|
2006-09-11 07:42:39 -07:00
|
|
|
if (srs->depth == 1)
|
|
|
|
{
|
|
|
|
xf.matrix[0][0] = xf.matrix[1][1] = xf.matrix[2][2] = 1;
|
|
|
|
}
|
2006-09-11 17:03:53 -07:00
|
|
|
#endif
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderSetPictureTransform(srs->xinf->x11.connection, srs->x11.xlib.pic, &xf);
|
|
|
|
// XRenderSetPictureFilter(srs->xinf->x11.connection, srs->x11.xlib.pic, FilterNearest, NULL, 0);
|
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
att.clip_mask = None;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(srs->xinf->x11.connection, srs->x11.xlib.pic, CPClipMask, &att);
|
|
|
|
XRenderChangePicture(drs->xinf->x11.connection, drs->x11.xlib.pic, CPClipMask, &att);
|
|
|
|
|
|
|
|
XRenderComposite(srs->xinf->x11.connection, PictOpSrc, srs->x11.xlib.pic, None, drs->x11.xlib.pic,
|
2005-10-02 08:15:44 -07:00
|
|
|
sx, sy, 0, 0, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_rectangle_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, int x, int y, int w, int h)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
XRenderColor col;
|
|
|
|
XRenderPictureAttributes att;
|
2006-09-30 03:18:37 -07:00
|
|
|
int r, g, b, a, op;
|
2005-10-02 08:15:44 -07:00
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
if ((!rs) || (!dc)) return;
|
|
|
|
if ((w <= 0) || (h <= 0)) return;
|
|
|
|
a = dc->col.col >> 24;
|
2005-10-02 08:15:44 -07:00
|
|
|
r = (dc->col.col >> 16) & 0xff;
|
|
|
|
g = (dc->col.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->col.col ) & 0xff;
|
|
|
|
col.red = (r << 8) | r;
|
|
|
|
col.green = (g << 8) | g;
|
|
|
|
col.blue = (b << 8) | b;
|
|
|
|
col.alpha = (a << 8) | a;
|
2006-09-30 03:18:37 -07:00
|
|
|
op = PictOpOver;
|
|
|
|
if (dc->render_op == _EVAS_RENDER_BLEND)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
if (a == 0xff) op = PictOpSrc;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_BLEND_REL)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
op = PictOpAtop;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MUL)
|
|
|
|
{
|
|
|
|
if (dc->col.col == 0xffffffff) return;
|
|
|
|
op = PictOpIn;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY)
|
|
|
|
op = PictOpSrc;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY_REL)
|
|
|
|
op = PictOpIn;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MASK)
|
|
|
|
op = PictOpInReverse;
|
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
att.clip_mask = None;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(rs->xinf->x11.connection, rs->x11.xlib.pic, CPClipMask, &att);
|
2005-10-07 21:57:57 -07:00
|
|
|
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_clips_set(rs, dc, x, y, w, h);
|
|
|
|
XRenderFillRectangle(rs->xinf->x11.connection, op, rs->x11.xlib.pic, &col, x, y, w, h);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_line_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
XRenderPictureAttributes att;
|
|
|
|
int op;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
if ((!rs) || (!dc) || (!dc->col.col)) return;
|
2006-05-16 00:52:35 -07:00
|
|
|
op = PictOpOver;
|
2006-09-30 03:18:37 -07:00
|
|
|
if (dc->render_op == _EVAS_RENDER_BLEND)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_BLEND_REL)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
op = PictOpAtop;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MUL)
|
|
|
|
{
|
|
|
|
if (dc->col.col == 0xffffffff) return;
|
|
|
|
op = PictOpIn;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY)
|
|
|
|
op = PictOpSrc;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY_REL)
|
|
|
|
op = PictOpIn;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MASK)
|
|
|
|
op = PictOpInReverse;
|
2005-10-02 08:15:44 -07:00
|
|
|
att.clip_mask = None;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(rs->xinf->x11.connection, rs->x11.xlib.pic, CPClipMask, &att);
|
|
|
|
_xr_xlib_render_surface_clips_set(rs, dc, 0, 0, rs->width, rs->height);
|
2006-05-16 00:52:35 -07:00
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
int r, g, b, a;
|
|
|
|
XPointDouble poly[4];
|
|
|
|
int dx, dy;
|
|
|
|
double len, ddx, ddy;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
dx = x2 - x1;
|
|
|
|
dy = y2 - y1;
|
2005-10-07 21:57:57 -07:00
|
|
|
len = sqrt((double)(dx * dx) + (double)(dy * dy));
|
2005-10-02 08:15:44 -07:00
|
|
|
ddx = (0.5 * dx) / len;
|
|
|
|
ddy = (0.5 * dy) / len;
|
2006-05-16 00:52:35 -07:00
|
|
|
if (ddx < 0) ddx = -0.5 - ddx;
|
|
|
|
else ddx = 0.5 - ddx;
|
|
|
|
if (ddy < 0) ddy = -0.5 - ddy;
|
|
|
|
else ddy = 0.5 - ddy;
|
2005-10-02 08:15:44 -07:00
|
|
|
poly[0].x = (x1 + ddx);
|
|
|
|
poly[0].y = (y1 - ddy);
|
|
|
|
poly[1].x = (x2 + ddx);
|
|
|
|
poly[1].y = (y2 - ddy);
|
|
|
|
poly[2].x = (x2 - ddx);
|
|
|
|
poly[2].y = (y2 + ddy);
|
|
|
|
poly[3].x = (x1 - ddx);
|
|
|
|
poly[3].y = (y1 + ddy);
|
2006-05-16 00:52:35 -07:00
|
|
|
|
2005-10-02 08:15:44 -07:00
|
|
|
a = (dc->col.col >> 24) & 0xff;
|
|
|
|
r = (dc->col.col >> 16) & 0xff;
|
|
|
|
g = (dc->col.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->col.col ) & 0xff;
|
|
|
|
if ((rs->xinf->mul_r != r) || (rs->xinf->mul_g != g) ||
|
|
|
|
(rs->xinf->mul_b != b) || (rs->xinf->mul_a != a))
|
|
|
|
{
|
|
|
|
rs->xinf->mul_r = r;
|
|
|
|
rs->xinf->mul_g = g;
|
|
|
|
rs->xinf->mul_b = b;
|
|
|
|
rs->xinf->mul_a = a;
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_solid_rectangle_set(rs->xinf->mul, r, g, b, a, 0, 0, 1, 1);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderCompositeDoublePoly(rs->xinf->x11.connection, op,
|
|
|
|
rs->xinf->mul->x11.xlib.pic, rs->x11.xlib.pic,
|
|
|
|
rs->xinf->x11.fmt8, 0, 0, 0, 0,
|
2005-10-02 08:15:44 -07:00
|
|
|
poly, 4, EvenOddRule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_polygon_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, RGBA_Polygon_Point *points)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
|
|
|
RGBA_Polygon_Point *pt;
|
|
|
|
int i, num;
|
|
|
|
XPointDouble *pts;
|
|
|
|
int r, g, b, a;
|
|
|
|
XRenderPictureAttributes att;
|
|
|
|
int op;
|
2009-03-24 00:44:54 -07:00
|
|
|
|
2006-05-11 05:48:22 -07:00
|
|
|
if ((!rs) || (!dc)) return;
|
2008-10-21 05:19:57 -07:00
|
|
|
num = 0; EINA_INLIST_FOREACH(points, pt) num++;
|
2005-10-02 08:15:44 -07:00
|
|
|
if (num < 3) return;
|
2006-09-30 03:18:37 -07:00
|
|
|
op = PictOpOver;
|
|
|
|
if (dc->render_op == _EVAS_RENDER_BLEND)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_BLEND_REL)
|
|
|
|
{
|
|
|
|
if (!dc->col.col) return;
|
|
|
|
op = PictOpAtop;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MUL)
|
|
|
|
{
|
|
|
|
if (dc->col.col == 0xffffffff) return;
|
|
|
|
op = PictOpIn;
|
|
|
|
}
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY)
|
|
|
|
op = PictOpSrc;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_COPY_REL)
|
|
|
|
op = PictOpIn;
|
|
|
|
else if (dc->render_op == _EVAS_RENDER_MASK)
|
|
|
|
op = PictOpInReverse;
|
2005-10-02 08:15:44 -07:00
|
|
|
a = (dc->col.col >> 24) & 0xff;
|
|
|
|
r = (dc->col.col >> 16) & 0xff;
|
|
|
|
g = (dc->col.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->col.col ) & 0xff;
|
|
|
|
if ((rs->xinf->mul_r != r) || (rs->xinf->mul_g != g) ||
|
|
|
|
(rs->xinf->mul_b != b) || (rs->xinf->mul_a != a))
|
|
|
|
{
|
|
|
|
rs->xinf->mul_r = r;
|
|
|
|
rs->xinf->mul_g = g;
|
|
|
|
rs->xinf->mul_b = b;
|
|
|
|
rs->xinf->mul_a = a;
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_solid_rectangle_set(rs->xinf->mul, r, g, b, a, 0, 0, 1, 1);
|
2005-10-02 08:15:44 -07:00
|
|
|
}
|
|
|
|
pts = malloc(num * sizeof(XPointDouble));
|
|
|
|
if (!pts) return;
|
|
|
|
i = 0;
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(points, pt)
|
2005-10-02 08:15:44 -07:00
|
|
|
{
|
2005-10-03 08:49:45 -07:00
|
|
|
if (i < num)
|
|
|
|
{
|
|
|
|
pts[i].x = pt->x;
|
|
|
|
pts[i].y = pt->y;
|
|
|
|
i++;
|
|
|
|
}
|
2006-09-30 03:18:37 -07:00
|
|
|
}
|
2005-10-02 08:15:44 -07:00
|
|
|
att.clip_mask = None;
|
2009-03-24 00:44:54 -07:00
|
|
|
XRenderChangePicture(rs->xinf->x11.connection, rs->x11.xlib.pic, CPClipMask, &att);
|
2005-10-07 21:57:57 -07:00
|
|
|
|
2009-03-24 00:44:54 -07:00
|
|
|
_xr_xlib_render_surface_clips_set(rs, dc, 0, 0, rs->width, rs->height);
|
|
|
|
XRenderCompositeDoublePoly(rs->xinf->x11.connection, op,
|
|
|
|
rs->xinf->mul->x11.xlib.pic, rs->x11.xlib.pic,
|
|
|
|
rs->xinf->x11.fmt8, 0, 0, 0, 0,
|
2005-10-02 08:15:44 -07:00
|
|
|
pts, num, Complex);
|
|
|
|
free(pts);
|
|
|
|
}
|