rendering fixes for gl
authorDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 19:58:09 +0000 (19:58 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 3 Jun 2003 19:58:09 +0000 (19:58 +0000)
render2/instance.c
render2/paint.c
render2/planar.c
render2/planar.h
render2/render.h
render2/surface.c
render2/test.c
render2/theme.c
render2/theme.h

index 311a86e0186a9a23a99d7fac642335ea3a377ec7..996344f6fe21ce7c403bffd6f59f6710bd233cf0 100644 (file)
@@ -97,9 +97,10 @@ struct RrInstance *RrInstanceNew(Display *display, int screen)
                                      RrVisual(inst), AllocNone);
         inst->glx_context = glXCreateContext(display, &vilist[best],
                                              NULL, True);
-        inst->shape_window = XCreateSimpleWindow(display,
-                                                 RootWindow(display, screen),
-                                                 0, 0, 1, 1, 0, 0, 0);
+        inst->shape_window = XCreateWindow(display,RootWindow(display, screen),
+                                           0, 0, 1, 1, 0,
+                                           RrInstanceDepth(inst), InputOutput,
+                                           RrInstanceVisual(inst), 0, NULL);
         /* make the context current on anything we can so we can dl 
            textures */
 
index 135ae79e881fe1e62d0c076c8d8db3b2d5d66ac5..dbdff14080a9ad705288a6bbbd7cd345ce775eb8 100644 (file)
@@ -30,16 +30,33 @@ void RrExpose(struct RrInstance *inst, XExposeEvent *e)
     win = e->window;
 
     if ((sur = RrInstaceLookupSurface(inst, win))) {
-        while (XCheckTypedWindowEvent(RrDisplay(inst), Expose, win, &e2));
-        while (sur->parent && RrSurfaceType(sur->parent) != RR_SURFACE_NONE)
-            sur = sur->parent;
-        RrPaint(sur);
+        while (1) {
+            struct RrSurface *p = NULL;
+
+            while (XCheckTypedWindowEvent(RrDisplay(inst), Expose,
+                                          sur->win, &e2));
+
+            switch (RrSurfaceType(sur)) {
+            case RR_SURFACE_NONE:
+                break;
+            case RR_SURFACE_PLANAR:
+                if (RrPlanarHasAlpha(sur))
+                    p = RrSurfaceParent(sur);
+                break;
+            case RR_SURFACE_NONPLANAR:
+                assert(0);
+            }
+
+            if (p) sur = p;
+            else break;
+        }
+        RrPaint(sur, 0);
     } else
         RrDebug("Unable to find surface for window 0x%lx\n", win);
 }
 
 /*! Paints the surface, and all its children */
-void RrPaint(struct RrSurface *sur)
+void RrPaint(struct RrSurface *sur, int recurse_always)
 {
     struct RrInstance *inst;
     struct RrSurface *p;
@@ -55,10 +72,6 @@ void RrPaint(struct RrSurface *sur)
 
     if (!RrSurfaceVisible(sur)) return;
 
-    /* recurse and paint children */
-    for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it))
-        RrPaint(it->data);
-
     ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
     assert(ok);
 
@@ -103,4 +116,23 @@ void RrPaint(struct RrSurface *sur)
     glPopMatrix();
 
     glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));
+
+    /* recurse and paint children */
+    for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it)) {
+        if (recurse_always)
+            RrPaint(it->data, 1);
+        else {
+            switch (RrSurfaceType(((struct RrSurface*)it->data))) {
+            case RR_SURFACE_NONE:
+                break;
+            case RR_SURFACE_PLANAR:
+                if (RrPlanarHasAlpha(it->data))
+                    RrPaint(it->data, 0);
+                break;
+            case RR_SURFACE_NONPLANAR:
+                assert(0);
+                break;
+            }
+        }
+    }
 }
index bc36e205e1699f2abff45a9548801a3742534b35..ba6ef899d295939bdfbbe8efbc58c509d93b8603 100644 (file)
@@ -27,6 +27,15 @@ void RrPlanarSet(struct RrSurface *sur,
         sur->data.planar.border = *border;
 }
 
+int RrPlanarHasAlpha(struct RrSurface *sur)
+{
+    if (RrColorHasAlpha(RrPlanarPrimaryColor(sur))) return 1;
+    if (!(RrPlanarColorType(sur) == RR_PLANAR_NONE ||
+          RrPlanarColorType(sur) == RR_PLANAR_SOLID))
+        if (RrColorHasAlpha(RrPlanarSecondaryColor(sur))) return 1;
+    return 0;
+}
+
 static void copy_parent(struct RrSurface *sur)
 {
     int ncols;
@@ -115,19 +124,12 @@ static void RrBorderPaint(int x, int y, int w, int h, int bwidth,
 
     RrColor4f(color);
 
-    glBegin(GL_LINES);
+    glBegin(GL_LINE_LOOP);
     glLineWidth(bwidth);
     glVertex2i(x + offset, y + offset);
-    glVertex2i(x + offset, y + h - offset);
-
     glVertex2i(x + offset, y + h - offset);
     glVertex2i(x + w - offset, y + h - offset);
-
-    glVertex2i(x + w - offset, y + h - offset);
-    glVertex2i(x + w - offset,  y + offset);
-               
     glVertex2i(x + w - offset, y + offset);
-    glVertex2i(x + offset, y + offset);
     glLineWidth(1.0); /* XXX is this needed? */
     glEnd();
 }
index e1009a4fc25408e92ca45c3735997917ebb115b2..acaae8120404b150b754f3768909222d0be1f120 100644 (file)
@@ -21,6 +21,8 @@ struct RrPlanarSurface {
 #define RrPlanarBorderWidth(sur) ((sur)->data.planar.borderwidth)
 #define RrPlanarBorderColor(sur) ((sur)->data.planar.border)
 
+int RrPlanarHasAlpha(struct RrSurface *sur);
+
 void RrPlanarPaint(struct RrSurface *sur, int absx, int absy);
 
 void RrPlanarMinSize(struct RrSurface *sur, int *w, int *h);
index 701b712a49fce6e932c7a91ba922408881705f7a..57def775e03d923098cc7e45f850dc2e8bbcd8d6 100644 (file)
@@ -222,8 +222,8 @@ void RrTextureSetNone(struct RrSurface *sur,
 
 /* drawing */
 
-/*! Paints the surface, and all its children */
-void RrPaint(struct RrSurface *sur);
+/*! Paints the surface, and optionally all its children */
+void RrPaint(struct RrSurface *sur, int recurse_always);
 
 void RrExpose(struct RrInstance *inst, XExposeEvent *e);
 
index 2ead9fb9c0cb3c296f232422a73290cfe9386108..b1da31580e326c80e1c906860aa3a6058546270c 100644 (file)
@@ -155,15 +155,26 @@ void RrSurfaceSetArea(struct RrSurface *sur,
                       int w,
                       int h)
 {
+    int m, r;
+
     assert(w > 0 && h > 0);
     if (!(w > 0 && h > 0)) return;
 
+    m = sur->x != x || sur->y != y;
+    r = sur->w != w || sur->h != h;
+
     sur->x = x;
     sur->y = y;
     sur->w = w;
     sur->h = h;
-    if (sur->win)
-        XMoveResizeWindow(RrDisplay(sur->inst), sur->win, x, y, w, h);
+    if (sur->win) {
+        if (m && r)
+            XMoveResizeWindow(RrDisplay(sur->inst), sur->win, x, y, w, h);
+        else if (m)
+            XMoveWindow(RrDisplay(sur->inst), sur->win, x, y);
+        else if (r)
+            XResizeWindow(RrDisplay(sur->inst), sur->win, w, h);
+    }
 }
 
 Window RrSurfaceWindow(struct RrSurface *sur)
@@ -206,9 +217,11 @@ void RrSurfaceMinSize(struct RrSurface *sur, int *w, int *h)
             minh = MAX(minh, 0);
             break;
         case RR_TEXTURE_TEXT:
-            /* XXX MEASUER STRING PLS */
-            minw = MAX(minw, 100 /*MEASURESTRING*/); 
-            minh = MAX(minh, 10  /*HEIGHTOFFONT*/);
+            minw =
+                MAX(minw,
+                    RrFontMeasureString(sur->texture[i].data.text.font,
+                                        sur->texture[i].data.text.string)); 
+            minh = MAX(minh, RrFontHeight(sur->texture[i].data.text.font));
             break;
         case RR_TEXTURE_RGBA:
             minw = MAX(minw, (sur->texture[i].data.rgba.x +
index eb76e5c9f96bb39f9c880cc37b05ede335a2ab77..a96a95dba302be04ca5c2310ffb55b8a9233152d 100644 (file)
@@ -86,7 +86,7 @@ int main()
                 /* fall through ... */
             } else {
                 while (XCheckTypedWindowEvent(display, win, Expose, &report));
-                RrPaint(sur);
+                RrPaint(sur, 0);
                 break;
             }
         case ConfigureNotify:
index be961bd21037a296cb3382f482d8b5fd70bac6bd..9539902cac1e24731901a99947c263e6678e655b 100644 (file)
@@ -22,7 +22,7 @@ struct RrTheme *RrThemeLoad(struct RrInstance *inst, const char *name)
 
     theme->title_font = RrFontOpen(inst,
                                   "arial:bold:pixelsize=10:"
-                                  "shadow:shadowoffset=1:shadowtint=0.1");
+                                  "shadow=true:shadowoffset=1:shadowtint=0.1");
     theme->title_justify = RR_CENTER;
 
     RrColorSet(&theme->b_color, 0, 0, 0, 1);
@@ -135,6 +135,15 @@ struct RrTheme *RrThemeLoad(struct RrInstance *inst, const char *name)
     RrPlanarSet(theme->title_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
                 &pri, NULL, 1, &bor);
 
+    theme->plate = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
+    theme->plate_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
+
+    RrColorSet(&pri, 0, 0, 0, 1);
+    RrPlanarSet(theme->plate, RR_PLANAR_SOLID, RR_BEVEL_NONE,
+                &pri, NULL, 0, NULL);
+    RrPlanarSet(theme->plate_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
+                &pri, NULL, 0, NULL);
+
     theme->label = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
     theme->label_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
 
index 3d309e2e24c76569a51aae4dcaf05b1075fea7d7..6637b948ff203f889ebc45f3cd3bba717154b7c8 100644 (file)
@@ -62,6 +62,9 @@ struct RrTheme {
 
     struct RrSurface *frame;
 
+    struct RrSurface *plate;
+    struct RrSurface *plate_f; /* focused */
+
     struct RrSurface *title;
     struct RrSurface *title_f; /* focused */