if xrender is on a 16bpp target - do some "faster" paths - i hope.

SVN revision: 34216
This commit is contained in:
Carsten Haitzler 2008-04-07 23:07:23 +00:00
parent b495b19470
commit 87f4bedb81
6 changed files with 94 additions and 37 deletions

View File

@ -251,7 +251,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
_xr_render_surface_solid_rectangle_set(surface, 0, 0, 0, 0, 0, 0, uw, uh);
return surface;
}
return _xr_render_surface_new(re->xinf, uw, uh, re->xinf->fmt24, 0);
return _xr_render_surface_new(re->xinf, uw, uh, re->xinf->fmtdef, 0);
}
static void

View File

@ -28,6 +28,7 @@ struct _Ximage_Info
XRenderPictFormat *fmt8;
XRenderPictFormat *fmt4;
XRenderPictFormat *fmt1;
XRenderPictFormat *fmtdef;
unsigned char mul_r, mul_g, mul_b, mul_a;
Xrender_Surface *mul;
int references;

View File

@ -12,6 +12,7 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
DATA8 *data;
int w, h, j;
XRenderPictureAttributes att;
XRenderPictFormat *fmt;
Ximage_Image *xim;
Evas_Hash *pool;
char buf[256], buf2[256];
@ -52,14 +53,18 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
snprintf(buf2, sizeof(buf2), "%p", fg);
pool = evas_hash_add(pool, buf2, fs);
_xr_fg_pool = evas_hash_add(_xr_fg_pool, buf, pool);
fs->draw = XCreatePixmap(xinf->disp, xinf->root, w, h, xinf->fmt8->depth);
/* FIXME: maybe use fmt4? */
fmt = xinf->fmt8;
fs->draw = XCreatePixmap(xinf->disp, xinf->root, w, h,fmt->depth);
att.dither = 0;
att.component_alpha = 0;
att.repeat = 0;
fs->pic = XRenderCreatePicture(xinf->disp, fs->draw, xinf->fmt8, CPRepeat | CPDither | CPComponentAlpha, &att);
fs->pic = XRenderCreatePicture(xinf->disp, fs->draw,fmt,
CPRepeat | CPDither | CPComponentAlpha, &att);
xim = _xr_image_new(fs->xinf, w, h, xinf->fmt8->depth);
/* FIXME: handle if fmt->depth != 8 */
xim = _xr_image_new(fs->xinf, w, h,fmt->depth);
if ((fg->glyph_out->bitmap.num_grays == 256) &&
(fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays))
{

View File

@ -490,7 +490,16 @@ _xre_image_alpha_set(XR_Image *im, int alpha)
if (im->alpha)
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmt32, 1);
else
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmt24, 0);
{
/* FIXME: if im->depth == 16, use xinf->fmtdef */
if ((im->xinf->depth == 16) &&
(im->xinf->vis->red_mask == 0xf800) &&
(im->xinf->vis->green_mask == 0x07e0) &&
(im->xinf->vis->blue_mask == 0x001f))
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmtdef, 0);
else
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmt24, 0);
}
if (im->surface)
_xr_render_surface_copy(old_surface, im->surface, 0, 0, 0, 0, im->w + 2, im->h + 2);
_xr_render_surface_free(old_surface);
@ -597,6 +606,8 @@ _xre_image_surface_gen(XR_Image *im)
if (im->alpha)
_xr_render_surface_argb_pixels_fill(im->surface, im->w, im->h, data, rx, ry, rw, rh, 1, 1);
else
/* FIXME: if im->depth == 16 - convert to 16bpp then
* upload */
_xr_render_surface_rgb_pixels_fill(im->surface, im->w, im->h, data, rx, ry, rw, rh, 1, 1);
}
evas_common_tilebuf_free_render_rects(rects);
@ -614,7 +625,16 @@ _xre_image_surface_gen(XR_Image *im)
}
else
{
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmt24, 0);
/* FIXME: if im->xinf->depth == 16, use xinf->fmtdef */
if ((im->xinf->depth == 16) &&
(im->xinf->vis->red_mask == 0xf800) &&
(im->xinf->vis->green_mask == 0x07e0) &&
(im->xinf->vis->blue_mask == 0x001f))
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmtdef, 0);
else
im->surface = _xr_render_surface_new(im->xinf, im->w + 2, im->h + 2, im->xinf->fmt24, 0);
/* FIXME: if im->depth == 16 - convert to 16bpp then
* upload */
_xr_render_surface_rgb_pixels_fill(im->surface, im->w, im->h, data, 0, 0, im->w, im->h, 1, 1);
}
/* fill borders */

View File

@ -37,13 +37,18 @@ _xr_image_info_get(Display *disp, Drawable draw, Visual *vis)
xinf->references = 1;
xinf->disp = disp;
xinf->draw = draw;
XGetGeometry(xinf->disp, xinf->draw, &(xinf->root), &di, &di, &dui, &dui, &dui, &dui);
XGetGeometry(xinf->disp, xinf->draw, &(xinf->root),
&di, &di, &dui, &dui, &dui, &dui);
xinf->vis = vis;
xinf->fmt32 = XRenderFindStandardFormat(xinf->disp, PictStandardARGB32);
xinf->fmt24 = XRenderFindStandardFormat(xinf->disp, PictStandardRGB24);
xinf->fmt8 = XRenderFindStandardFormat(xinf->disp, PictStandardA8);
xinf->fmt4 = XRenderFindStandardFormat(xinf->disp, PictStandardA4);
xinf->fmt1 = XRenderFindStandardFormat(xinf->disp, PictStandardA1);
/* find fmt for default visual */
xinf->fmtdef = XRenderFindVisualFormat(xinf->disp, xinf->vis);
xinf->mul = _xr_render_surface_new(xinf, 1, 1, xinf->fmt32, 1);
_xr_render_surface_repeat_set(xinf->mul, 1);
xinf->mul_r = xinf->mul_g = xinf->mul_b = xinf->mul_a = 0xff;

View File

@ -46,10 +46,11 @@ _xr_render_surface_new(Ximage_Info *xinf, int w, int h, XRenderPictFormat *fmt,
return NULL;
}
rs->xinf->references++;
att.dither = 0;
att.dither = 1;
att.component_alpha = 0;
att.repeat = 0;
rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt,
CPRepeat | CPDither | CPComponentAlpha, &att);
if (rs->pic == None)
{
XFreePixmap(rs->xinf->disp, rs->draw);
@ -82,10 +83,11 @@ _xr_render_surface_adopt(Ximage_Info *xinf, Drawable draw, int w, int h, int alp
rs->allocated = 0;
rs->draw = draw;
rs->xinf->references++;
att.dither = 0;
att.dither = 1;
att.component_alpha = 0;
att.repeat = 0;
rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt, CPRepeat | CPDither | CPComponentAlpha, &att);
rs->pic = XRenderCreatePicture(xinf->disp, rs->draw, fmt,
CPRepeat | CPDither | CPComponentAlpha, &att);
if (rs->pic == None)
{
rs->xinf->references--;
@ -223,38 +225,62 @@ _xr_render_surface_rgb_pixels_fill(Xrender_Surface *rs, int sw, int sh, void *pi
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;
if
#ifdef WORDS_BIGENDIAN
(xim->xim->byte_order == LSBFirst)
#else
(xim->xim->byte_order == MSBFirst)
#endif
if (rs->depth == 16)
{
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;
}
jump = ((xim->line_bytes / 2) - w);
/* FIXME: if rs->depth == 16 - convert */
Gfx_Func_Convert conv_func;
int swap;
#ifdef WORDS_BIGENDIAN
swap = (int)(xim->xim->byte_order == LSBFirst);
#else
swap = (int)(xim->xim->byte_order == MSBFirst);
#endif
/* FIXME: swap not handled */
conv_func = evas_common_convert_func_get(sp, w, h, rs->depth,
rs->xinf->vis->red_mask,
rs->xinf->vis->green_mask,
rs->xinf->vis->blue_mask,
PAL_MODE_NONE, 0);
if (conv_func)
conv_func(sp, p, sjump, jump, w, h, x, y, NULL);
}
else
{
while (sp < spe)
jump = ((xim->line_bytes / 4) - w);
if
#ifdef WORDS_BIGENDIAN
(xim->xim->byte_order == LSBFirst)
#else
(xim->xim->byte_order == MSBFirst)
#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
{
sple = sp + w;
while (sp < sple)
*p++ = 0xff000000 | *sp++;
p += jump;
sp += sjump;
while (sp < spe)
{
sple = sp + w;
while (sp < sple)
*p++ = 0xff000000 | *sp++;
p += jump;
sp += sjump;
}
}
}
_xr_image_put(xim, rs->draw, x + ox, y + oy, w, h);