This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via ac5ab1fc384840bd63b923cd8d02043176676d01 (commit) from 34edb5f159d98fccc62cfdcd268f51109320dafd (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/ac5ab1fc384840bd63b923cd8d02043176676...
commit ac5ab1fc384840bd63b923cd8d02043176676d01 Author: Cyril Hrubis metan@ucw.cz Date: Fri Apr 25 23:37:17 2014 +0200
spiv: Fix slow blit for images with alpha channel
The pattern_fill() function that draws chessboard like pattern before images with alpha channel are blitted was drawing the pattern pixel by pixel, which is quite slow and caused dropped events when moving such image in the spiv window.
This commit optimizes the function a bit (about then times faster) which fixes the problem.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 6d26c600..d4785e0a 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -171,26 +171,21 @@ static GP_Context *load_image(int elevate) static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, unsigned int w, unsigned int h) { - unsigned int x, y; + unsigned int x, y, i, j = 0; + GP_Pixel col[2];
- GP_Pixel g1 = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx); - GP_Pixel g2 = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx); + col[0] = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx); + col[1] = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
- unsigned int wm = w/10 < 10 ? 10 : w/10; - unsigned int hm = h/10 < 10 ? 10 : h/10; - unsigned int wt = w/20 < 5 ? 5 : w/20; - unsigned int ht = h/20 < 5 ? 5 : h/20; + unsigned int wm = w/20 < 5 ? 5 : w/20; + unsigned int hm = h/20 < 5 ? 5 : h/20;
- for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - GP_Pixel pix; - - if ((x % wm < wt) ^ (y % hm < ht)) - pix = g1; - else - pix = g2; - - GP_PutPixel(ctx, x0 + x, y0 + y, pix); + for (y = 0; y < h; y += hm) { + i = j; + j = !j; + for (x = 0; x < w; x += wm) { + GP_FillRectXYWH(ctx, x0 + x, y0 + y, wm, hm, col[i]); + i = !i; } } } @@ -323,7 +318,6 @@ static void update_display(struct loader_params *params, GP_Context *img, } else { if (GP_PixelHasFlags(img->pixel_type, GP_PIXEL_HAS_ALPHA)) pattern_fill(context, cx, cy, img->w, img->h); - GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy); }
-----------------------------------------------------------------------
Summary of changes: demos/spiv/spiv.c | 30 ++++++++++++------------------ 1 files changed, 12 insertions(+), 18 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.