Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h eimage.c eimage.h magwin.c mod-misc.c pager.c Log Message: Optionally use render for scaling. =================================================================== RCS file: /cvs/e/e16/e/src/E.h,v retrieving revision 1.600 retrieving revision 1.601 diff -u -3 -r1.600 -r1.601 --- E.h 30 Dec 2007 21:20:52 -0000 1.600 +++ E.h 24 Jan 2008 18:37:45 -0000 1.601 @@ -3,7 +3,7 @@ /*****************************************************************************/ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -425,6 +425,7 @@ int image_cache_size; int mask_alpha_threshold; char enable_startup_id; + char use_render_for_scaling; } testing; char autosave; =================================================================== RCS file: /cvs/e/e16/e/src/eimage.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- eimage.c 14 Jan 2008 21:49:12 -0000 1.23 +++ eimage.c 24 Jan 2008 18:37:45 -0000 1.24 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -24,6 +24,9 @@ #include "eimage.h" #include "xwin.h" #include <Imlib2.h> +#if HAVE_X11_EXTENSIONS_XRENDER_H +#include <X11/extensions/Xrender.h> +#endif static Window _default_draw; static Visual *_default_vis; @@ -478,16 +481,61 @@ void ScaleRect(Win wsrc, Drawable src, Win wdst, Pixmap dst, int sx, int sy, int sw, int sh, - int dx, int dy, int dw, int dh, int scale) + int dx, int dy, int dw, int dh, int flags) { - Imlib_Image im; +#if HAVE_X11_EXTENSIONS_XRENDER_H + if (Conf.testing.use_render_for_scaling) + { + XRenderPictFormat *pictfmt; + XRenderPictureAttributes pa; + XTransform tr; + Picture psrc, pdst; + double scale_x, scale_y; + + scale_x = (double)sw / (double)dw; + scale_y = (double)sh / (double)dh; + memset(&tr, 0, sizeof(tr)); + tr.matrix[0][0] = XDoubleToFixed(scale_x); + tr.matrix[1][1] = XDoubleToFixed(scale_y); + tr.matrix[2][2] = XDoubleToFixed(1.); + + pa.subwindow_mode = IncludeInferiors; + pictfmt = XRenderFindVisualFormat(disp, wsrc->visual); + psrc = XRenderCreatePicture(disp, src, pictfmt, CPSubwindowMode, &pa); + pictfmt = XRenderFindVisualFormat(disp, wdst->visual); + pdst = XRenderCreatePicture(disp, dst, pictfmt, CPSubwindowMode, &pa); + + XRenderSetPictureFilter(disp, psrc, (flags & EIMAGE_ANTI_ALIAS) ? + FilterBest : FilterNearest, NULL, 0); + XRenderSetPictureTransform(disp, psrc, &tr); + XRenderComposite(disp, PictOpSrc, psrc, None, pdst, + (int)(sx / scale_x + .5), (int)(sy / scale_y + .5), + 0, 0, dx, dy, dw, dh); + XRenderFreePicture(disp, psrc); + XRenderFreePicture(disp, pdst); + } + else +#endif + { + int scale; + Imlib_Image im; - scale = (scale) ? 2 : 1; + if (flags & (EIMAGE_ISCALE)) + { + scale = (flags & EIMAGE_ISCALE) >> 8; + im = EImageGrabDrawableScaled(wsrc, src, None, sx, sy, sw, sh, + scale * dw, scale * dh, 0, 0); + flags |= EIMAGE_ANTI_ALIAS; + } + else + { + im = EImageGrabDrawableScaled(wsrc, src, None, sx, sy, sw, sh, + sw, sh, 0, 0); + } - im = EImageGrabDrawableScaled(wsrc, src, None, sx, sy, sw, sh, - scale * dw, scale * dh, 0, 0); - EImageRenderOnDrawable(im, wdst, dst, EIMAGE_ANTI_ALIAS, dx, dy, dw, dh); - imlib_free_image(); + EImageRenderOnDrawable(im, wdst, dst, flags, dx, dy, dw, dh); + imlib_free_image(); + } } void =================================================================== RCS file: /cvs/e/e16/e/src/eimage.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- eimage.h 14 Jan 2008 21:49:12 -0000 1.15 +++ eimage.h 24 Jan 2008 18:37:45 -0000 1.16 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -34,9 +34,10 @@ int left, right, top, bottom; } EImageBorder; -#define EIMAGE_BLEND 0x01 -#define EIMAGE_ANTI_ALIAS 0x02 -#define EIMAGE_HIGH_MASK_THR 0x04 +#define EIMAGE_BLEND 0x0001 +#define EIMAGE_ANTI_ALIAS 0x0002 +#define EIMAGE_HIGH_MASK_THR 0x0004 +#define EIMAGE_ISCALE 0x0f00 /* Intermediate scaling */ void EImageInit(Display * dpy); int EImageSetCacheSize(int size); @@ -104,9 +105,9 @@ void ScaleRect(Win wsrc, Drawable src, Win wdst, Pixmap dst, int sx, int sy, int sw, int sh, - int dx, int dy, int dw, int dh, int scale); + int dx, int dy, int dw, int dh, int flags); void ScaleTile(Win wsrc, Drawable src, Win wdst, Pixmap dst, - int dx, int dy, int dw, int dh, int scale); + int dx, int dy, int dw, int dh, int flags); void EDrawableDumpImage(Drawable draw, const char *txt); =================================================================== RCS file: /cvs/e/e16/e/src/magwin.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- magwin.c 21 Dec 2007 22:04:55 -0000 1.6 +++ magwin.c 24 Jan 2008 18:37:45 -0000 1.7 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Kim Woelders + * Copyright (C) 2007-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -47,7 +47,6 @@ { EWin *ewin; const char *title; - EImage *im; int cx, cy; /* Center */ int scale; /* Zoom level */ int sx, sy; /* Scene x,y */ @@ -56,6 +55,7 @@ char bpress; char filter; char grabbing; + char step; unsigned int damage_count; char update; } MagWindow; @@ -79,6 +79,20 @@ txt, x, y, cw, ch, 17, 0); } +static unsigned int +MagwinGetPixel(Drawable draw, unsigned int x, unsigned int y) +{ + EImage *im; + unsigned int *pd, pixel; + + im = EImageGrabDrawable(draw, None, x, y, 1, 1, 0); + pd = (unsigned int *)EImageGetData(im); + pixel = *pd; + EImageFree(im); + + return pixel; +} + static void MagwinRedraw(MagWindow * mw, int paint) { @@ -89,7 +103,8 @@ char buf[128]; int px, py; int qx, qy; - unsigned int *pd; + int out; + unsigned int pixel; ww = mw->ewin->client.w; wh = mw->ewin->client.h; @@ -125,42 +140,38 @@ if (paint) { - if (mw->im) - EImageDecache(mw->im); + int dw, dh; + dw = (int)(sw * scale + .5); + dh = (int)(sh * scale + .5); draw = (VRoot.pmap != None) ? VRoot.pmap : VRoot.xwin; - mw->im = EImageGrabDrawable(draw, None, sx, sy, sw, sh, 0); - EImageRenderOnDrawable(mw->im, EwinGetClientWin(mw->ewin), - EwinGetClientXwin(mw->ewin), - (mw->filter) ? EIMAGE_ANTI_ALIAS : 0, - 0, 0, (int)(sw * scale + .5), - (int)(sh * scale + .5)); + ScaleRect(VRoot.win, draw, EwinGetClientWin(mw->ewin), + EwinGetClientXwin(mw->ewin), sx, sy, sw, sh, + 0, 0, dw, dh, (mw->filter) ? EIMAGE_ANTI_ALIAS : 0); } + /* Check if pointer is in magnifier window */ + EQueryPointer(EwinGetClientWin(mw->ewin), &px, &py, NULL, NULL); + out = px < 0 || px >= mw->ewin->client.w || + py < 0 || py >= mw->ewin->client.h; + /* If inside grab pixel before drawing in window */ + pixel = (out) ? 0 : MagwinGetPixel(EwinGetClientXwin(mw->ewin), px, py); + /* Show magnified area coordinates */ Esnprintf(buf, sizeof(buf), "%d,%d %dx%d", sx, sy, sw, sh); MagwinDrawText(mw, 10, 10, buf); - /* Show info about pixel at cursor (if in magnifier) */ - EQueryPointer(EwinGetClientWin(mw->ewin), &px, &py, NULL, NULL); - if (px < 0 || px >= mw->ewin->client.w || py < 0 || py >= mw->ewin->client.h) + if (out) return; + + /* Show info about pixel at cursor (if in magnifier) */ qx = (int)(px / scale); qy = (int)(py / scale); if (qx > VRoot.w - 1) qx = VRoot.w - 1; if (qy > VRoot.h - 1) qy = VRoot.h - 1; - if (!mw->im) - return; - pd = (unsigned int *)EImageGetData(mw->im); -#if 0 - Esnprintf(buf, sizeof(buf), "%d,%d: pixel=%#08x (%d,%d)", - sx + qx, sy + qy, pd[qy * sw + qx], px, py); -#else - Esnprintf(buf, sizeof(buf), "%d,%d: pixel=%#08x", - sx + qx, sy + qy, pd[qy * sw + qx]); -#endif + Esnprintf(buf, sizeof(buf), "%d,%d: pixel=%#08x", sx + qx, sy + qy, pixel); MagwinDrawText(mw, 10, 20, buf); } @@ -247,26 +258,36 @@ if (mw->scale < -20) mw->scale = -20; break; + case XK_Left: - mw->cx -= 4; + mw->cx -= mw->step; if (mw->cx < mw->sw / 2) mw->cx = mw->sw / 2; break; case XK_Right: - mw->cx += 4; + mw->cx += mw->step; if (mw->cx > VRoot.w - mw->sw / 2) mw->cx = VRoot.w - mw->sw / 2; break; case XK_Up: - mw->cy -= 4; + mw->cy -= mw->step; if (mw->cy < mw->sh / 2) mw->cy = mw->sh / 2; break; case XK_Down: - mw->cy += 4; + mw->cy += mw->step; if (mw->cy > VRoot.h - mw->sh / 2) mw->cy = VRoot.h - mw->sh / 2; break; + + case XK_r: /* Switch render mode */ + Conf.testing.use_render_for_scaling = + !Conf.testing.use_render_for_scaling; + break; + + case XK_s: /* x/y move step size */ + mw->step = (mw->step == 1) ? 4 : 1; + break; } return 0; @@ -412,6 +433,7 @@ EQueryPointer(VRoot.win, &mw->cx, &mw->cy, NULL, NULL); mw->scale = 1; + mw->step = 4; return mw; } @@ -424,8 +446,6 @@ #endif EventCallbackUnregister(EwinGetClientWin(mw->ewin), 0, MagwinEvent, mw); EDestroyWindow(EwinGetClientWin(mw->ewin)); - if (mw->im) - EImageDecache(mw->im); Efree(mw); } =================================================================== RCS file: /cvs/e/e16/e/src/mod-misc.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -3 -r1.61 -r1.62 --- mod-misc.c 22 Sep 2007 10:21:18 -0000 1.61 +++ mod-misc.c 24 Jan 2008 18:37:45 -0000 1.62 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2007 Kim Woelders + * Copyright (C) 2003-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -194,9 +194,10 @@ CFG_ITEM_BOOL(Conf, testing.argb_internal_clients, 0), CFG_ITEM_BOOL(Conf, testing.argb_clients, 0), CFG_ITEM_BOOL(Conf, testing.argb_clients_inherit_attr, 0), - CFG_ITEM_BOOL(Conf, testing.enable_startup_id, 1), CFG_FUNC_INT(Conf, testing.image_cache_size, -1, _CfgImageCacheSize), CFG_ITEM_INT(Conf, testing.mask_alpha_threshold, 8), + CFG_ITEM_BOOL(Conf, testing.enable_startup_id, 1), + CFG_ITEM_BOOL(Conf, testing.use_render_for_scaling, 0), CFG_ITEM_BOOL(Conf, autosave, 1), CFG_ITEM_BOOL(Conf, memory_paranoia, 1), =================================================================== RCS file: /cvs/e/e16/e/src/pager.c,v retrieving revision 1.253 retrieving revision 1.254 diff -u -3 -r1.253 -r1.254 --- pager.c 14 Jan 2008 21:49:12 -0000 1.253 +++ pager.c 24 Jan 2008 18:37:45 -0000 1.254 @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -48,7 +48,7 @@ #endif #define USE_PAGER_BACKGROUND_CACHE 1 -#define IMG_SCALE 2 +#define HIQ ((Conf_pagers.hiq) ? 0x200 : 0x100) #define PAGER_MODE_SIMPLE 0 #define PAGER_MODE_SNAP 1 @@ -249,7 +249,7 @@ y2 = (y * VRoot.h) / hh; ScaleRect(VRoot.win, VRoot.xwin, p->win, WinGetPmap(p->win), 0, y2, - VRoot.w, VRoot.h / hh, xx, yy + y, ww, 1, Conf_pagers.hiq); + VRoot.w, VRoot.h / hh, xx, yy + y, ww, 1, HIQ); EClearArea(p->win, xx, yy + y, ww, 1, False); y2 = p->h; #else @@ -257,7 +257,7 @@ y2 = (y * VRoot.w) / ww; ScaleRect(VRoot.win, VRoot.xwin, p->win, WinGetPmap(p->win), y2, 0, - VRoot.w / ww, VRoot.h, xx + y, yy, 1, hh, Conf_pagers.hiq); + VRoot.w / ww, VRoot.h, xx + y, yy, 1, hh, HIQ); EClearArea(p->win, xx + y, yy, 1, hh, False); y2 = p->w; #endif @@ -351,8 +351,7 @@ else { ScaleRect(EoGetWin(ewin), draw, p->win, ewin->mini_pmm.pmap, - 0, 0, EoGetW(ewin), EoGetH(ewin), 0, 0, w, h, - Conf_pagers.hiq); + 0, 0, EoGetW(ewin), EoGetH(ewin), 0, 0, w, h, HIQ); Dprintf("Grab scaled, pmap=%#lx\n", ewin->mini_pmm.pmap); } @@ -482,8 +481,7 @@ Dprintf("doPagerUpdate %d: Snap screen\n", p->dsk->num); /* Update pager area by snapshotting entire screen */ ScaleRect(VRoot.win, VRoot.xwin, p->win, pmap, 0, 0, - VRoot.w, VRoot.h, cx * p->dw, cy * p->dh, p->dw, p->dh, - Conf_pagers.hiq); + VRoot.w, VRoot.h, cx * p->dw, cy * p->dh, p->dw, p->dh, HIQ); EClearWindow(p->win); @@ -612,7 +610,7 @@ if (pager_mode != PAGER_MODE_SIMPLE && p->dsk->bg.pmap) { ScaleTile(VRoot.win, p->dsk->bg.pmap, p->win, pmap, - 0, 0, p->dw, p->dh, Conf_pagers.hiq); + 0, 0, p->dw, p->dh, HIQ); return; } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs