From: Derek Foreman Date: Sat, 7 Jun 2003 22:12:42 +0000 (+0000) Subject: compress glLineWidth changes X-Git-Tag: gl-oldtheme~40 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=82cbf89e1e64f5860da1b320c189fc33f032437d;p=dana%2Fopenbox.git compress glLineWidth changes --- diff --git a/render2/instance.c b/render2/instance.c index 996344f6..e0dd8496 100644 --- a/render2/instance.c +++ b/render2/instance.c @@ -119,6 +119,8 @@ struct RrInstance *RrInstanceNew(Display *display, int screen) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + inst->gl_linewidth = 1.0; + return inst; } diff --git a/render2/instance.h b/render2/instance.h index a9b7833e..18ae26f1 100644 --- a/render2/instance.h +++ b/render2/instance.h @@ -13,7 +13,7 @@ struct RrInstance { XVisualInfo visinfo; Colormap cmap; GLXContext glx_context; - + int gl_linewidth; Window shape_window; GHashTable *surface_map; diff --git a/render2/planar.c b/render2/planar.c index ab3f252e..e760fa79 100644 --- a/render2/planar.c +++ b/render2/planar.c @@ -4,10 +4,19 @@ #include "color.h" #include "debug.h" #include "font.h" +#include "instance.h" #include #include #include +static void RrLineWidth(struct RrInstance *i, int w) +{ + if (i->gl_linewidth != w) { + glLineWidth(w); + i->gl_linewidth = w; + } +} + void RrPlanarSet(struct RrSurface *sur, enum RrSurfaceColorType type, enum RrBevelType bevel, @@ -49,11 +58,16 @@ static void copy_parent(struct RrSurface *sur) } } -static void RrBevelPaint(int x, int y, int w, int h, int bwidth, - int inset, int raise) +static void RrBevelPaint(struct RrSurface *s, int inset, int raise) { - int offset = bwidth + inset; - h--; w--; + int offset = RrPlanarBorderWidth(s) + inset; + int x, y, w, h; + x = RrSurfaceX(s); + y = RrSurfaceY(s); + w = RrSurfaceWidth(s) - 1; + h = RrSurfaceHeight(s) - 1; + + RrLineWidth(RrSurfaceInstance(s), 1); if (raise) glColor4f(1.0, 1.0, 1.0, 0.25); @@ -80,21 +94,26 @@ static void RrBevelPaint(int x, int y, int w, int h, int bwidth, glEnd(); } -static void RrBorderPaint(int x, int y, int w, int h, int bwidth, - struct RrColor *color) +static void RrBorderPaint(struct RrSurface *s) { - int offset = bwidth / 2; - h--; w--; + int x, y, w, h, offset, bwidth; + + offset = RrPlanarBorderWidth(s) / 2; + bwidth = RrPlanarBorderWidth(s); + x = RrSurfaceX(s); + y = RrSurfaceY(s); + w = RrSurfaceWidth(s) - 1; + h = RrSurfaceHeight(s) - 1; + + RrColor4f(&RrPlanarBorderColor(s)); - RrColor4f(color); + RrLineWidth(RrSurfaceInstance(s), bwidth); glBegin(GL_LINE_LOOP); - glLineWidth(bwidth); glVertex2i(x + offset, y + offset); glVertex2i(x + offset, y + h - offset); glVertex2i(x + w - offset, y + h - offset); glVertex2i(x + w - offset, y + offset); - glLineWidth(1.0); /* XXX is this needed? */ glEnd(); } @@ -322,33 +341,23 @@ void RrPlanarPaint(struct RrSurface *sur, int absx, int absy) switch (RrPlanarBevelType(sur)) { case RR_SUNKEN_OUTER: - RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur), - RrSurfaceWidth(sur), RrSurfaceHeight(sur), - RrPlanarBorderWidth(sur), 0, 0); + RrBevelPaint(sur, 0, 0); break; case RR_SUNKEN_INNER: - RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur), - RrSurfaceWidth(sur), RrSurfaceHeight(sur), - RrPlanarBorderWidth(sur), 1, 0); + RrBevelPaint(sur, 1, 0); break; case RR_RAISED_OUTER: - RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur), - RrSurfaceWidth(sur), RrSurfaceHeight(sur), - RrPlanarBorderWidth(sur), 0, 1); + RrBevelPaint(sur, 0, 1); break; case RR_RAISED_INNER: - RrBevelPaint(RrSurfaceX(sur), RrSurfaceY(sur), - RrSurfaceWidth(sur), RrSurfaceHeight(sur), - RrPlanarBorderWidth(sur), 1, 1); + RrBevelPaint(sur, 1, 1); break; case RR_BEVEL_NONE: break; } if (RrPlanarBorderWidth(sur)) - RrBorderPaint(RrSurfaceX(sur), RrSurfaceY(sur), - RrSurfaceWidth(sur), RrSurfaceHeight(sur), - RrPlanarBorderWidth(sur), &RrPlanarBorderColor(sur)); + RrBorderPaint(sur); } int RrPlanarEdgeWidth(struct RrSurface *sur)