From b8ca24f8cab6af4ad779f92e26688589bcd90014 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 18 Apr 2008 10:28:14 +0800 Subject: * New Makefile --- basicblur.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 12 deletions(-) diff --git a/basicblur.c b/basicblur.c index 3ed0987..1731048 100644 --- a/basicblur.c +++ b/basicblur.c @@ -27,16 +27,18 @@ typedef struct _basicblurDisplay { } basicblurDisplay; -typedef struct _basicblurSCreen { +typedef struct _basicblurScreen { int windowPrivateIndex; DrawWindowTextureProc drawWindowTexture; DamageWindowRectProc damageWindowRect; + PaintWindowProc paintWindow; Bool isBlured; } basicblurScreen; typedef struct _basicblurWindow { Bool first; Bool isBlured; + Region region; } basicblurWindow; #define GET_BASICBLUR_DISPLAY(d) ((basicblurDisplay *) (d)->base.privates[BasicBlurdisplayPrivateIndex].ptr) @@ -46,8 +48,25 @@ typedef struct _basicblurWindow { #define GET_BASICBLUR_WINDOW(w, ns) ((basicblurWindow *) (w)->base.privates[(ns)->windowPrivateIndex].ptr) #define BASICBLUR_WINDOW(w) basicblurWindow *nw = GET_BASICBLUR_WINDOW (w, GET_BASICBLUR_SCREEN (w->screen, GET_BASICBLUR_DISPLAY (w->screen->display))) +#define WIN_OUTPUT_X(w) (w->attrib.x - w->output.left) +#define WIN_OUTPUT_Y(w) (w->attrib.y - w->output.top) + +#define WIN_OUTPUT_W(w) (w->width + w->output.left + w->output.right) +#define WIN_OUTPUT_H(w) (w->height + w->output.top + w->output.bottom) + #define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption)) +#define DAMAGE_WIN_REGION \ + REGION region; \ + region.rects = ®ion.extents; \ + region.numRects = region.size = 1; \ + region.extents.x1 = WIN_OUTPUT_X (w); \ + region.extents.x2 = WIN_OUTPUT_X (w) + WIN_OUTPUT_W (w); \ + region.extents.y1 = WIN_OUTPUT_Y (w); \ + region.extents.y2 = WIN_OUTPUT_Y (w) + WIN_OUTPUT_H (w); \ + damageScreenRegion (w->screen, ®ion); + + static void basicblurToggleWindow (CompWindow *w) { @@ -57,13 +76,16 @@ basicblurToggleWindow (CompWindow *w) BASICBLUR_WINDOW (w); nw->isBlured = !nw->isBlured; nw->first = TRUE; - + /* if(w->redirected) { unredirectWindow(w); redirectWindow(w); } - addWindowDamage(w); + */ + addWindowDamage(w); + + DAMAGE_WIN_REGION } } @@ -75,7 +97,28 @@ basicblurToggleScreen (CompScreen *s) ns->isBlured = !ns->isBlured; for (w = s->windows; w; w = w->next) - if (w) basicblurToggleWindow (w); + if (w) + { + BASICBLUR_WINDOW (w); + addWindowDamage(w); + basicblurToggleWindow (w); + + /* + + nw->region->rects = &nw->region->extents; + nw->region->numRects = 1; + + nw->region->extents.x1 = WIN_OUTPUT_X (w); + nw->region->extents.x2 = WIN_OUTPUT_X (w) + WIN_OUTPUT_W (w); + nw->region->extents.y1 = WIN_OUTPUT_Y (w); + nw->region->extents.y2 = WIN_OUTPUT_Y (w) + WIN_OUTPUT_H (w); + + damageScreenRegion (w->screen, nw->region); + + */ + + DAMAGE_WIN_REGION; + } } static Bool @@ -128,6 +171,46 @@ basicblurToggleAll (CompDisplay *d, CompAction *action, CompActionState state, C return TRUE; } +static Bool +basicblurPaintWindow (CompWindow *w, + const WindowPaintAttrib *attrib, + const CompTransform *transform, + Region region, + unsigned int mask) +{ + WindowPaintAttrib sAttrib; + CompScreen *s = w->screen; + Bool status; + + BASICBLUR_WINDOW (w); + BASICBLUR_SCREEN (w->screen); + + if(nw->isBlured) + { + // We use a convolution filter + glEnable(GL_CONVOLUTION_2D); + glConvolutionFilter2D (GL_CONVOLUTION_2D, GL_RGBA, fsize, fsize, GL_RGBA, GL_FLOAT, convfilter); + glConvolutionParameteri (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_REPLICATE_BORDER); + UNWRAP (ns, w->screen, paintWindow); + status = (*s->paintWindow) (w, attrib, transform, region, mask); + WRAP (ns, w->screen, paintWindow, basicblurPaintWindow); + if(nw->first) + { + nw->first = FALSE; + } + glDisable(GL_CONVOLUTION_2D); + + } + else + { + UNWRAP (ns, w->screen, drawWindowTexture); + status = (*s->paintWindow) (w, attrib, transform, region, mask); + WRAP (ns, w->screen, paintWindow, basicblurPaintWindow); + } + + return status; +} + static void basicblurDrawWindowTexture (CompWindow *w, CompTexture *texture, @@ -137,33 +220,34 @@ basicblurDrawWindowTexture (CompWindow *w, BASICBLUR_SCREEN (w->screen); BASICBLUR_WINDOW (w); - UNWRAP (ns, w->screen, drawWindowTexture); - //fsize = basicblurGetBlurFactor(w->screen); //fprintf(stderr, "%i", fsize); - if(nw->isBlured && !(mask & PAINT_WINDOW_DECORATION_MASK)) + if(nw->isBlured) { // We use a convolution filter glEnable(GL_CONVOLUTION_2D); glConvolutionFilter2D (GL_CONVOLUTION_2D, GL_RGBA, fsize, fsize, GL_RGBA, GL_FLOAT, convfilter); glConvolutionParameteri (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_REPLICATE_BORDER); - - (*w->screen->drawWindowTexture) (w, texture, attrib, mask); + UNWRAP (ns, w->screen, drawWindowTexture); + (*w->screen->drawWindowTexture) (w, w->texture, attrib, mask); + WRAP (ns, w->screen, drawWindowTexture, basicblurDrawWindowTexture); if(nw->first) { nw->first = FALSE; } glDisable(GL_CONVOLUTION_2D); + } else { - (*w->screen->drawWindowTexture)(w, texture, attrib, mask); + UNWRAP (ns, w->screen, drawWindowTexture); + (*w->screen->drawWindowTexture) (w, texture, attrib, mask); + WRAP (ns, w->screen, drawWindowTexture, basicblurDrawWindowTexture); } - WRAP (ns, w->screen, drawWindowTexture, basicblurDrawWindowTexture); - + DAMAGE_WIN_REGION; } static Bool @@ -180,6 +264,10 @@ basicblurDamageWindowRect (CompWindow *w, Bool initial, BoxPtr rect) basicblurToggleWindow (w); } + + DAMAGE_WIN_REGION; + + UNWRAP (ns, w->screen, damageWindowRect); status = (*w->screen->damageWindowRect) (w, initial, rect); WRAP (ns, w->screen, damageWindowRect, basicblurDamageWindowRect); @@ -241,6 +329,7 @@ basicblurInitScreen (CompPlugin *p, CompScreen *s) WRAP (ns, s, drawWindowTexture, basicblurDrawWindowTexture); WRAP (ns, s, damageWindowRect, basicblurDamageWindowRect); + WRAP (ns, s, paintWindow, basicblurPaintWindow); // We fill in the convolution filter (gaussian blur) @@ -293,6 +382,7 @@ basicblurFiniScreen (CompPlugin *p, CompScreen *s) freeWindowPrivateIndex (s, ns->windowPrivateIndex); UNWRAP (ns, s, drawWindowTexture); UNWRAP (ns, s, damageWindowRect); + UNWRAP (ns, s, paintWindow); free (ns); } -- cgit v1.1