Use anti-alias only when appropriate.

SVN revision: 29429
This commit is contained in:
Kim Woelders 2007-04-06 22:20:07 +00:00
parent 7965494d63
commit 799f662fce
13 changed files with 72 additions and 46 deletions

View File

@ -657,7 +657,7 @@ BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
{
/* Window, no fg, no offset, and scale to 100%, or tiled, no trans */
pmap = BackgroundCreatePixmap(win, w, h);
EImageRenderOnDrawable(bg->bg.im, win, pmap, 0, 0, w, h, 0);
EImageRenderOnDrawable(bg->bg.im, win, pmap, 0, 0, 0, w, h);
#if 0 /* FIXME - Remove? */
if (x == 0 && y == 0) /* Hmmm. Always true. */
@ -723,7 +723,7 @@ BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
EImageBlend(im, bg->top.im, 1, 0, 0, ww, hh, x, y, w, h, 0, 0);
}
EImageRenderOnDrawable(im, win, pmap, 0, 0, rw, rh, 0);
EImageRenderOnDrawable(im, win, pmap, 0, 0, 0, rw, rh);
if (im != bg->bg.im)
EImageFree(im);
@ -1836,7 +1836,7 @@ BG_RedrawView(void)
im = BackgroundCacheMini(bg, 1, 0);
if (im)
{
EImageRenderOnDrawable(im, win, pmap, x + 4, 4, 64, 48, 0);
EImageRenderOnDrawable(im, win, pmap, 0, x + 4, 4, 64, 48);
EImageFree(im);
}
}

View File

@ -1166,7 +1166,7 @@ ContainerDraw(Container * ct)
if (im)
{
EMapWindow(ct->icon_win);
EImageRenderPixmaps(im, ct->icon_win, &pmap, &mask, 0, 0);
EImageRenderPixmaps(im, ct->icon_win, 0, &pmap, &mask, 0, 0);
ESetWindowBackgroundPixmap(ct->icon_win, pmap);
EShapeCombineMask(ct->icon_win, ShapeBounding, 0, 0, mask, ShapeSet);
EImagePixmapFree(pmap);

View File

@ -446,7 +446,8 @@ DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
db->w - (h + 2 + pad->left + pad->right),
h, h, TextclassGetJustification(db->tclass));
EImageRenderOnDrawable(im, db->win, None, pad->left, pad->top, h, h, 1);
EImageRenderOnDrawable(im, db->win, None, EIMAGE_BLEND,
pad->left, pad->top, h, h);
EImageFree(im);
}
else
@ -1222,7 +1223,7 @@ DialogRealizeItem(Dialog * d, DItem * di)
EImageGetSize(im, &iw, &ih);
di->win = ECreateWindow(d->win, 0, 0, iw, ih, 0);
EMapWindow(di->win);
EImageRenderPixmaps(im, di->win, &pmap, &mask, 0, 0);
EImageRenderPixmaps(im, di->win, 0, &pmap, &mask, 0, 0);
ESetWindowBackgroundPixmap(di->win, pmap);
EShapeCombineMask(di->win, ShapeBounding, 0, 0, mask, ShapeSet);
EClearWindow(di->win);

View File

@ -49,6 +49,7 @@ EImageInit(Display * dpy)
imlib_context_set_mask_alpha_threshold(Conf.testing.mask_alpha_threshold);
#endif
imlib_context_set_anti_alias(0);
imlib_context_set_dither(1);
}
@ -363,9 +364,23 @@ EImageGrabDrawableScaled(Win win, Drawable draw, Pixmap mask,
return im;
}
static void
_EImageFlagsSet(int flags)
{
imlib_context_set_anti_alias((flags & EIMAGE_ANTI_ALIAS) ? 1 : 0);
imlib_context_set_blend((flags & EIMAGE_BLEND) ? 1 : 0);
}
static void
_EImageFlagsReset(void)
{
imlib_context_set_anti_alias(0);
imlib_context_set_blend(0);
}
void
EImageRenderOnDrawable(EImage * im, Win win, Drawable draw, int x, int y,
int w, int h, int blend)
EImageRenderOnDrawable(EImage * im, Win win, Drawable draw, int flags,
int x, int y, int w, int h)
{
Visual *vis;
@ -375,19 +390,19 @@ EImageRenderOnDrawable(EImage * im, Win win, Drawable draw, int x, int y,
if (vis)
imlib_context_set_visual(vis);
if (blend)
imlib_context_set_blend(1);
if (flags)
_EImageFlagsSet(flags);
imlib_render_image_on_drawable_at_size(x, y, w, h);
if (blend)
imlib_context_set_blend(0);
if (flags)
_EImageFlagsReset();
if (vis)
imlib_context_set_visual(_default_vis);
}
void
EImageRenderPixmaps(EImage * im, Win win, Pixmap * pmap, Pixmap * mask,
int w, int h)
EImageRenderPixmaps(EImage * im, Win win, int flags,
Pixmap * pmap, Pixmap * mask, int w, int h)
{
Visual *vis;
Pixmap m;
@ -404,10 +419,14 @@ EImageRenderPixmaps(EImage * im, Win win, Pixmap * pmap, Pixmap * mask,
if (mask)
*mask = None;
if (flags)
_EImageFlagsSet(flags);
if (w <= 0 || h <= 0)
imlib_render_pixmaps_for_whole_image(pmap, mask);
else
imlib_render_pixmaps_for_whole_image_at_size(pmap, mask, w, h);
if (flags)
_EImageFlagsReset();
if (vis)
imlib_context_set_visual(_default_vis);
@ -430,14 +449,14 @@ ScaleRect(Win wsrc, Drawable src, Win wdst, Pixmap dst, Pixmap * pdst,
im = EImageGrabDrawableScaled(wsrc, src, None, sx, sy, sw, sh,
scale * dw, scale * dh, 0, 0);
imlib_context_set_anti_alias(1);
if (pdst)
{
EImageRenderPixmaps(im, wdst, pdst, None, dw, dh);
EImageRenderPixmaps(im, wdst, EIMAGE_ANTI_ALIAS, pdst, None, dw, dh);
}
else
{
EImageRenderOnDrawable(im, wdst, dst, dx, dy, dw, dh, 0);
EImageRenderOnDrawable(im, wdst, dst, EIMAGE_ANTI_ALIAS,
dx, dy, dw, dh);
}
imlib_free_image();
}

View File

@ -34,6 +34,9 @@ typedef struct
int left, right, top, bottom;
} EImageBorder;
#define EIMAGE_BLEND 0x01
#define EIMAGE_ANTI_ALIAS 0x02
void EImageInit(Display * dpy);
EImage *EImageCreate(int w, int h);
@ -79,10 +82,10 @@ EImage *EImageGrabDrawableScaled(Win win,
int get_mask_from_shape);
void EImageRenderOnDrawable(EImage * im, Win win, Drawable draw,
int x, int y, int w, int h,
int blend);
int flags,
int x, int y, int w, int h);
void EImageRenderPixmaps(EImage * im, Win win,
void EImageRenderPixmaps(EImage * im, Win win, int flags,
Pixmap * pmap, Pixmap * mask,
int w, int h);
void EImagePixmapFree(Pixmap pmap);

View File

@ -118,7 +118,7 @@ ExtInitWinMain(void)
im = ThemeImageLoad(s);
if (im)
{
EImageRenderPixmaps(im, NULL, &pmap, &mask, 0, 0);
EImageRenderPixmaps(im, NULL, 0, &pmap, &mask, 0, 0);
EImageGetSize(im, &w, &h);
XShapeCombineMask(disp, w2, ShapeBounding, 0, 0, mask,
ShapeSet);

View File

@ -643,7 +643,7 @@ FX_imagespinner_timeout(int val __UNUSED__, void *data __UNUSED__)
sscanf(fx_imagespinner_params, "%*s %i %i ", &x, &y);
x = ((VRoot.w * x) >> 10) - ((w * x) >> 10);
y = ((VRoot.h * y) >> 10) - ((h * y) >> 10);
EImageRenderOnDrawable(im, fx_imagespinner_win, x, y, w, h, 0);
EImageRenderOnDrawable(im, fx_imagespinner_win, 0, x, y, w, h);
EImageFree(im);
}
Efree(string);

View File

@ -109,12 +109,12 @@ static void
HiwinRenderImageDrawX(Hiwin * phi, Drawable draw __UNUSED__)
{
#if 0
EImageRenderOnDrawable(phi->im, EoGetWin(phi), draw, 0, 0,
EoGetW(phi), EoGetH(phi), 0);
EImageRenderOnDrawable(phi->im, EoGetWin(phi), draw, 0,
0, 0, EoGetW(phi), EoGetH(phi));
#else
Pixmap pmap, mask;
EImageRenderPixmaps(phi->im, EoGetWin(phi), &pmap, &mask,
EImageRenderPixmaps(phi->im, EoGetWin(phi), EIMAGE_ANTI_ALIAS, &pmap, &mask,
EoGetW(phi), EoGetH(phi));
ESetWindowBackgroundPixmap(EoGetWin(phi), pmap);
if (mask)

View File

@ -844,7 +844,7 @@ ImageclassApplySimple(ImageClass * ic, Win win, Drawable draw, int state,
x = y = 0;
}
EImageRenderOnDrawable(im, win, draw, x, y, w, h, 0);
EImageRenderOnDrawable(im, win, draw, 0, x, y, w, h);
EImageFree(im);
return pmap;
@ -1014,14 +1014,15 @@ ImagestateMakePmapMask(ImageState * is, Win win, PmapMask * pmm,
pmm->mask = None;
pmm->w = w;
pmm->h = h;
EImageRenderOnDrawable(ii, win, pmap, 0, 0, w, h, 0);
EImageRenderOnDrawable(ii, win, pmap, 0, 0, 0, w, h);
if (make_mask && !(flags & ICLASS_ATTR_NO_CLIP))
{
if (EImageHasAlpha(is->im))
{
/* Make the scaled clip mask to be used */
EImageRenderPixmaps(is->im, win, &pmap, &mask, w, h);
EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmap,
&mask, w, h);
/* Replace the mask with the correct one */
pmm->mask = EXCreatePixmapCopy(mask, w, h, 1);
@ -1042,7 +1043,8 @@ ImagestateMakePmapMask(ImageState * is, Win win, PmapMask * pmm,
pmm->pmap = pmm->mask = None;
pmm->w = w;
pmm->h = h;
EImageRenderPixmaps(is->im, win, &pmm->pmap, &pmm->mask, w, h);
EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmm->pmap,
&pmm->mask, w, h);
}
else
{
@ -1078,7 +1080,8 @@ ImagestateMakePmapMask(ImageState * is, Win win, PmapMask * pmm,
pmm->pmap = pmm->mask = None;
pmm->w = pw;
pmm->h = ph;
EImageRenderPixmaps(is->im, win, &pmm->pmap, &pmm->mask, pw, ph);
EImageRenderPixmaps(is->im, win, EIMAGE_ANTI_ALIAS, &pmm->pmap,
&pmm->mask, pw, ph);
}
}

View File

@ -281,7 +281,7 @@ PagerHiwinUpdate(Hiwin * phi, Pager * p __UNUSED__, EWin * ewin)
im = EImageGrabDrawable(ewin->mini_pmm.pmap, None, 0, 0,
ewin->mini_w, ewin->mini_h, 0);
EImageRenderOnDrawable(im, EoGetWin(phi), 0, 0, EoGetW(phi), EoGetH(phi), 0);
EImageRenderOnDrawable(im, EoGetWin(phi), 0, 0, 0, EoGetW(phi), EoGetH(phi));
EImageDecache(im);
}
#endif
@ -597,7 +597,7 @@ PagerUpdateBg(Pager * p)
im = EImageLoad(s);
if (im)
{
EImageRenderOnDrawable(im, p->win, pmap, 0, 0, p->dw, p->dh, 0);
EImageRenderOnDrawable(im, p->win, pmap, 0, 0, 0, p->dw, p->dh);
EImageDecache(im);
}
else

View File

@ -68,20 +68,20 @@ TextDrawRotTo(Win win, Drawable src, Drawable dst, int x, int y,
case FONT_TO_UP:
im = EImageGrabDrawable(src, 0, y, x, h, w, 0);
EImageOrientate(im, 1);
EImageRenderOnDrawable(im, win, dst, 0, 0, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, 0, 0, w, h);
EImageFree(im);
break;
case FONT_TO_DOWN:
EXGetGeometry(src, NULL, NULL, NULL, &win_w, NULL, NULL, NULL);
im = EImageGrabDrawable(src, None, win_w - y - h, x, h, w, 0);
EImageOrientate(im, 3);
EImageRenderOnDrawable(im, win, dst, 0, 0, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, 0, 0, w, h);
EImageFree(im);
break;
case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */
im = EImageGrabDrawable(src, None, x, y, w, h, 0);
EImageOrientate(im, 2);
EImageRenderOnDrawable(im, win, dst, 0, 0, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, 0, 0, w, h);
EImageFree(im);
break;
default:
@ -101,20 +101,20 @@ TextDrawRotBack(Win win, Drawable dst, Drawable src, int x, int y,
case FONT_TO_UP:
im = EImageGrabDrawable(src, None, 0, 0, w, h, 0);
EImageOrientate(im, 3);
EImageRenderOnDrawable(im, win, dst, y, x, h, w, 0);
EImageRenderOnDrawable(im, win, dst, 0, y, x, h, w);
EImageFree(im);
break;
case FONT_TO_DOWN:
EXGetGeometry(dst, NULL, NULL, NULL, &win_w, NULL, NULL, NULL);
im = EImageGrabDrawable(src, None, 0, 0, w, h, 0);
im = EImageGrabDrawable(src, None, 0, 0, 0, w, h);
EImageOrientate(im, 1);
EImageRenderOnDrawable(im, win, dst, win_w - y - h, x, h, w, 0);
EImageRenderOnDrawable(im, win, dst, 0, win_w - y - h, x, h, w);
EImageFree(im);
break;
case FONT_TO_LEFT: /* Holy carumba! That's for yoga addicts, maybe .... */
im = EImageGrabDrawable(src, None, 0, 0, w, h, 0);
EImageOrientate(im, 2);
EImageRenderOnDrawable(im, win, dst, x, y, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, x, y, w, h);
EImageFree(im);
break;
default:
@ -164,20 +164,20 @@ TextImagePut(EImage * im, Win win, Drawable dst, int x, int y,
{
default:
case FONT_TO_RIGHT:
EImageRenderOnDrawable(im, win, dst, x, y, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, x, y, w, h);
break;
case FONT_TO_LEFT:
EImageOrientate(im, 2);
EImageRenderOnDrawable(im, win, dst, x, y, w, h, 0);
EImageRenderOnDrawable(im, win, dst, 0, x, y, w, h);
break;
case FONT_TO_UP:
EImageOrientate(im, 3);
EImageRenderOnDrawable(im, win, dst, y, x, h, w, 0);
EImageRenderOnDrawable(im, win, dst, 0, y, x, h, w);
break;
case FONT_TO_DOWN:
EXGetGeometry(dst, NULL, NULL, NULL, &win_w, NULL, NULL, NULL);
EImageOrientate(im, 1);
EImageRenderOnDrawable(im, win, dst, win_w - y - h, x, h, w, 0);
EImageRenderOnDrawable(im, win, dst, 0, win_w - y - h, x, h, w);
break;
}
EImageFree(im);

View File

@ -276,7 +276,7 @@ TooltipIclassPaste(ToolTip * tt, const char *ic_name, int x, int y, int *px)
return;
EImageGetSize(im, &w, &h);
EImageRenderOnDrawable(im, tt->TTWIN->win, None, x, y, w, h, 1);
EImageRenderOnDrawable(im, tt->TTWIN->win, None, EIMAGE_BLEND, x, y, w, h);
*px = x + w;
}

View File

@ -236,9 +236,9 @@ WarpFocusWinPaint(WarpFocusWin * fw)
Conf.warplist.icon_mode);
if (im)
{
EImageRenderOnDrawable(im, wi->win, None,
EImageRenderOnDrawable(im, wi->win, None, EIMAGE_BLEND,
pad->left + ICON_PAD, ICON_PAD,
icon_size, icon_size, 1);
icon_size, icon_size);
EImageFree(im);
}
iw = fw->mh;