From: Dana Jansens Date: Sun, 16 Mar 2008 03:42:53 +0000 (-0400) Subject: speed up moving a lot with glxrender and fix its stacking of shadows X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=4dbc2adcf5aa7aff516d2f1dd6635e4a08c16ae8;p=dana%2Fdcompmgr.git speed up moving a lot with glxrender and fix its stacking of shadows --- diff --git a/glxrender.c b/glxrender.c index ed17279..e0c1cce 100644 --- a/glxrender.c +++ b/glxrender.c @@ -33,7 +33,6 @@ typedef struct { void (*screen_root_pixmap_change)(d_screen_t *sc); void (*window_show)(d_window_t *w); void (*window_zombie_dead)(d_window_t *w); - void (*window_move)(d_window_t *w); void (*window_resize)(d_window_t *w); void (*window_reshape)(d_window_t *w); @@ -66,8 +65,9 @@ static void glxrender_paint(d_screen_t *sc); static void glxrender_root_pixmap_change(d_screen_t *sc); static void paint_root(d_screen_t *sc, data_t *d); static void paint_window(d_window_t *window, data_t *d, window_data_t *wd, + int x, int y, GLfloat z); +static void paint_shadow(data_t *d, window_data_t *wd, int x, int y, GLfloat z); -static void paint_shadow(data_t *d, window_data_t *wd, GLfloat z); static void glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd); static void glxrender_update_window_region(d_window_t *w, window_data_t *wd); @@ -78,7 +78,6 @@ static void glxrender_update_root_pixmap(d_screen_t *sc, data_t *d); static void glxrender_window_show(d_window_t *window); static void glxrender_window_zombie_dead(d_window_t *window); -static void glxrender_window_move(d_window_t *window); static void glxrender_window_resize(d_window_t *window); static void glxrender_window_reshape(d_window_t *window); @@ -102,7 +101,6 @@ glxrender_init(d_screen_t *sc, int id) d->window_show = sc->window_show; d->window_zombie_dead = sc->window_zombie_dead; d->window_resize = sc->window_resize; - d->window_move = sc->window_move; d->window_reshape = sc->window_reshape; screen_add_plugin_data(sc, plugin_id, d); @@ -111,7 +109,6 @@ glxrender_init(d_screen_t *sc, int id) sc->window_show = glxrender_window_show; sc->window_zombie_dead = glxrender_window_zombie_dead; sc->window_resize = glxrender_window_resize; - sc->window_move = glxrender_window_move; sc->window_reshape = glxrender_window_reshape; d->shadowalpha = 0.2f; /* 20% */ @@ -450,10 +447,10 @@ glxrender_update_window_region(d_window_t *w, window_data_t *wd) (GLfloat)(rects[i].y - area.y + rects[i].height) / (GLfloat)area.height; - wd->vertices[i+LEFT] = rects[i].x; - wd->vertices[i+TOP] = rects[i].y; - wd->vertices[i+RIGHT] = rects[i].x + rects[i].width; - wd->vertices[i+BOTTOM] = rects[i].y + rects[i].height; + wd->vertices[i+LEFT] = rects[i].x - x; + wd->vertices[i+TOP] = rects[i].y - y; + wd->vertices[i+RIGHT] = rects[i].x - x + rects[i].width; + wd->vertices[i+BOTTOM] = rects[i].y - y + rects[i].height; } if (rep) @@ -513,22 +510,6 @@ glxrender_window_resize(d_window_t *w) glxrender_update_window_pixmap(w, d, wd); } -static void -glxrender_window_move(d_window_t *w) -{ - data_t *d; - window_data_t *wd; - - d = screen_find_plugin_data(w->sc, plugin_id); - wd = window_find_plugin_data(w, plugin_id); - - /* pass it on */ - d->window_move(w); - - assert(wd != NULL); - glxrender_update_window_region(w, wd); -} - static void glxrender_window_reshape(d_window_t *w) { @@ -598,7 +579,7 @@ glxrender_paint(d_screen_t *sc) //glPushMatrix(); - paint_window(w, d, wd, z + 0.05f); + paint_window(w, d, wd, x, y, z - 0.05f); //glPopMatrix(); } @@ -647,12 +628,12 @@ glxrender_paint(d_screen_t *sc) alpha /= 0xffff; if (alpha >= 0.01) { glColor4f(0.0f, 0.0f, 0.0f, alpha); - paint_shadow(d, wd, z); + paint_shadow(d, wd, x, y, z); } if (!opaque) { glColor4us(opac, opac, opac, opac); - paint_window(w, d, wd, z + 0.05f); + paint_window(w, d, wd, x, y, z + 0.05f); } //glPopMatrix(); @@ -694,7 +675,8 @@ paint_root(d_screen_t *sc, data_t *d) } static void -paint_window(d_window_t *w, data_t *d, window_data_t *wd, GLfloat z) +paint_window(d_window_t *w, data_t *d, window_data_t *wd, int x, int y, + GLfloat z) { int i; @@ -708,13 +690,13 @@ paint_window(d_window_t *w, data_t *d, window_data_t *wd, GLfloat z) glBegin(GL_QUADS); for (i = 0; i < wd->nrects * 4; i += 4) { glTexCoord2f(wd->texcoords[i+LEFT], wd->texcoords[i+TOP]); - glVertex3f(wd->vertices[i+LEFT], wd->vertices[i+TOP], z); + glVertex3f(x+wd->vertices[i+LEFT], y+wd->vertices[i+TOP], z); glTexCoord2f(wd->texcoords[i+RIGHT], wd->texcoords[i+TOP]); - glVertex3f(wd->vertices[i+RIGHT], wd->vertices[i+TOP], z); + glVertex3f(x+wd->vertices[i+RIGHT], y+wd->vertices[i+TOP], z); glTexCoord2f(wd->texcoords[i+RIGHT], wd->texcoords[i+BOTTOM]); - glVertex3f(wd->vertices[i+RIGHT], wd->vertices[i+BOTTOM], z); + glVertex3f(x+wd->vertices[i+RIGHT], y+wd->vertices[i+BOTTOM], z); glTexCoord2f(wd->texcoords[i+LEFT], wd->texcoords[i+BOTTOM]); - glVertex3f(wd->vertices[i+LEFT], wd->vertices[i+BOTTOM], z); + glVertex3f(x+wd->vertices[i+LEFT], y+wd->vertices[i+BOTTOM], z); } glEnd(); @@ -722,10 +704,8 @@ paint_window(d_window_t *w, data_t *d, window_data_t *wd, GLfloat z) } static void -paint_shadow(data_t *d, window_data_t *wd, GLfloat z) +paint_shadow(data_t *d, window_data_t *wd, int x, int y, GLfloat z) { - int xoff = d->xshadowoff; - int yoff = d->yshadowoff; int i; if (wd->nrects < 1) return; @@ -733,16 +713,19 @@ paint_shadow(data_t *d, window_data_t *wd, GLfloat z) /* shape the shadow to the window */ glBindTexture(GL_TEXTURE_2D, wd->texname); + x += d->xshadowoff; + y += d->yshadowoff; + glBegin(GL_QUADS); for (i = 0; i < wd->nrects * 4; i += 4) { glTexCoord2f(wd->texcoords[i+LEFT], wd->texcoords[i+TOP]); - glVertex3f(xoff+wd->vertices[i+LEFT], yoff+wd->vertices[i+TOP], z); + glVertex3f(x+wd->vertices[i+LEFT], y+wd->vertices[i+TOP], z); glTexCoord2f(wd->texcoords[i+RIGHT], wd->texcoords[i+TOP]); - glVertex3f(xoff+wd->vertices[i+RIGHT], yoff+wd->vertices[i+TOP], z); + glVertex3f(x+wd->vertices[i+RIGHT], y+wd->vertices[i+TOP], z); glTexCoord2f(wd->texcoords[i+RIGHT], wd->texcoords[i+BOTTOM]); - glVertex3f(xoff+wd->vertices[i+RIGHT], yoff+wd->vertices[i+BOTTOM], z); + glVertex3f(x+wd->vertices[i+RIGHT], y+wd->vertices[i+BOTTOM], z); glTexCoord2f(wd->texcoords[i+LEFT], wd->texcoords[i+BOTTOM]); - glVertex3f(xoff+wd->vertices[i+LEFT], yoff+wd->vertices[i+BOTTOM], z); + glVertex3f(x+wd->vertices[i+LEFT], y+wd->vertices[i+BOTTOM], z); } glEnd();