compress glLineWidth changes
authorDerek Foreman <manmower@gmail.com>
Sat, 7 Jun 2003 22:12:42 +0000 (22:12 +0000)
committerDerek Foreman <manmower@gmail.com>
Sat, 7 Jun 2003 22:12:42 +0000 (22:12 +0000)
render2/instance.c
render2/instance.h
render2/planar.c

index 996344f6fe21ce7c403bffd6f59f6710bd233cf0..e0dd849690013a42139daf5df1052a89148793e6 100644 (file)
@@ -119,6 +119,8 @@ struct RrInstance *RrInstanceNew(Display *display, int screen)
         glMatrixMode(GL_MODELVIEW);
         glLoadIdentity();
 
+        inst->gl_linewidth = 1.0;
+
         return inst;
     }
 
index a9b7833e66255438b819a00b38542ae4d8b58cdc..18ae26f1c9b523d62efa6c1b4561e6898263facd 100644 (file)
@@ -13,7 +13,7 @@ struct RrInstance {
     XVisualInfo visinfo;
     Colormap cmap;
     GLXContext glx_context;
-
+    int gl_linewidth;
     Window shape_window;
 
     GHashTable *surface_map;
index ab3f252e78d6a30454234475f4cc935bda110c4c..e760fa79044da5fc83c6f2936d74d2e1f7f8e0eb 100644 (file)
@@ -4,10 +4,19 @@
 #include "color.h"
 #include "debug.h"
 #include "font.h"
+#include "instance.h"
 #include <string.h>
 #include <assert.h>
 #include <GL/glx.h>
 
+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)