draw the root pixmap with the gl renderer, and honor windows restacking when they...
authorDana Jansens <danakj@orodu.net>
Sat, 15 Mar 2008 22:47:59 +0000 (18:47 -0400)
committerDana Jansens <danakj@orodu.net>
Sat, 15 Mar 2008 22:47:59 +0000 (18:47 -0400)
dcompmgr.c
glxrender.c

index 0c7ecc9..fc18efe 100644 (file)
@@ -184,9 +184,9 @@ event(d_display_t *dpy)
                 }
             }
             above = screen_find_window(sc, cev->above_sibling);
+            sc->window_restack(w, above);
             if (window_is_mapped(w))
-                sc->window_restack(w, above);
-            screen_refresh(w->sc);
+                screen_refresh(w->sc);
             break;
         }
         case XCB_PROPERTY_NOTIFY:
index 663522e..ff7e79b 100644 (file)
@@ -38,6 +38,8 @@ typedef struct {
     GLXFBConfig fbconfig[MAX_DEPTH + 1];
 
     GLXContext context;
+    GLuint root_texname;
+    GLXPixmap root_glpixmap;
 
     BindEXTFunc bind_func;
     ReleaseEXTFunc release_func;
@@ -62,6 +64,7 @@ static void glxrender_update_window_pixmap(d_window_t *w, data_t *d,
                                            window_data_t *wd);
 static void glxrender_free_window_pixmap(d_window_t *w, data_t *d,
                                          window_data_t *wd);
+static void glxrender_free_root_pixmap(d_screen_t *sc, data_t *d);
 static void glxrender_update_root_pixmap(d_screen_t *sc, data_t *d);
 
 static void glxrender_window_show(d_window_t *window);
@@ -139,6 +142,9 @@ glxrender_init(d_screen_t *sc, int id)
         glXGetProcAddress((const guchar*)"glXBindTexImageEXT");
     d->release_func = (ReleaseEXTFunc)
         glXGetProcAddress((const guchar*)"glXReleaseTexImageEXT");
+
+    glGenTextures(1, &d->root_texname);
+    d->root_glpixmap = XCB_NONE;
 }
 
 static gboolean
@@ -231,6 +237,7 @@ void
 glxrender_free(d_screen_t *sc)
 {
     data_t *d = screen_find_plugin_data(sc, plugin_id);
+    glxrender_free_root_pixmap(sc, d);
     free(d);
     screen_remove_plugin_data(sc, plugin_id);
 }
@@ -302,33 +309,8 @@ glxrender_free_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
     /* this might cause an error, oh well */
     if (wd->glpixmap) {
         glBindTexture(GL_TEXTURE_2D, wd->texname);
-
-        {
-            /*
-              ReleaseTexImageEXT
-              1           CARD8           opcode (X assigned)
-              1           16              GLX opcode (glXVendorPrivate)
-              2           5               request length
-              4           1331            vendor specific opcode
-              4           CARD32          context tag
-              4           GLX_DRAWABLE    drawable
-              4           INT32           buffer
-            */
-            /*
-            unsigned int len = (2 + 0) * sizeof(uint32_t);
-            uint32_t data[] = {
-                wd->glpixmap,
-                GLX_FRONT_LEFT_EXT
-            };
-            xcb_glx_vendor_private(w->sc->dpy->conn,
-                                   1331,
-                                   d->context_tag,
-                                   len, (uint8_t*)data);
-            */
-            d->release_func(w->sc->dpy->xlib_dpy,
-                            wd->glpixmap, GLX_FRONT_LEFT_EXT);
-        }
-
+        d->release_func(w->sc->dpy->xlib_dpy,
+                        wd->glpixmap, GLX_FRONT_LEFT_EXT);
         glBindTexture(GL_TEXTURE_2D, 0);
 
         //xcb_glx_destroy_pixmap(w->sc->dpy->conn, wd->glpixmap);
@@ -338,6 +320,22 @@ glxrender_free_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
 }
 
 static void
+glxrender_free_root_pixmap(d_screen_t *sc, data_t *d)
+{
+    /* this might cause an error, oh well */
+    if (d->root_glpixmap) {
+        glBindTexture(GL_TEXTURE_2D, d->root_texname);
+        d->release_func(sc->dpy->xlib_dpy,
+                        d->root_glpixmap, GLX_FRONT_LEFT_EXT);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+        //xcb_glx_destroy_pixmap(w->sc->dpy->conn, wd->glpixmap);
+        glXDestroyPixmap(sc->dpy->xlib_dpy, d->root_glpixmap);
+        d->root_glpixmap = XCB_NONE;
+    }
+}
+
+static void
 glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
 {
     xcb_pixmap_t px;
@@ -354,7 +352,6 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
 
     if (!px) return;
 
-    //printf("%x %d %x\n", px, depth, d->fbconfig[depth]);
     if (!d->fbconfig[depth]) {
         printf("no GL visual for depth %d\n", depth);
         return;
@@ -365,68 +362,20 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
     else
         attrs[1] = GLX_TEXTURE_FORMAT_RGB_EXT;
 
-/*
-        wd->glpixmap = xcb_generate_id(w->sc->dpy->conn);
-        printf("bind config 0x%x screen %d pixmap 0x%x glpixmap 0x%x "
-               "nattr %d\n",
-               d->fbconfig[depth], w->sc->num, px, wd->glpixmap,
-               sizeof(attrs)/sizeof(attrs[0]));
-        xcb_void_cookie_t ck =
-        xcb_glx_create_pixmap_checked(w->sc->dpy->conn, w->sc->num,
-                              d->fbconfig[depth],
-                              px, wd->glpixmap,
-                              sizeof(attrs)/sizeof(attrs[0] - 1),
-                              attrs);
-        xcb_generic_error_t *err = xcb_request_check(w->sc->dpy->conn, ck);
-        if (err) {
-            display_error(w->sc->dpy, err);
-            free(err);
-            wd->glpixmap = XCB_NONE;
-            return;
-        }
-/*/
     wd->glpixmap = glXCreatePixmap(w->sc->dpy->xlib_dpy,
                                    d->fbconfig[depth],
                                    px, attrs);
 
 
     glBindTexture(GL_TEXTURE_2D, wd->texname);
-
-    {
-        /*
-          BindTexImageEXT
-          1           CARD8                   opcode (X assigned)
-          1           16                      GLX opcode (glXVendorPrivate)
-          2           6+n                     request length
-          4           1330                    vendor specific opcode
-          4           CARD32                  context tag
-          4           GLX_DRAWABLE            drawable
-          4           INT32                   buffer
-          4           CARD32                  num_attributes
-          4*n         LISTofATTRIBUTE_PAIR    attribute, value pairs.
-        */
-        /*
-          unsigned int len = (3 + 0) * sizeof(uint32_t);
-          uint32_t data[] = {
-            wd->glpixmap,
-            GLX_FRONT_LEFT_EXT,
-            0
-          };
-          xcb_glx_vendor_private(w->sc->dpy->conn,
-                                 1330,
-                                 d->context_tag,
-                                 len, (uint8_t*)data);
-        */
-        d->bind_func(w->sc->dpy->xlib_dpy,
-                     wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL);
-    }
+    d->bind_func(w->sc->dpy->xlib_dpy,
+                 wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL);
 
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
     glBindTexture(GL_TEXTURE_2D, 0);
 }
@@ -435,10 +384,36 @@ static void
 glxrender_update_root_pixmap(d_screen_t *sc, data_t *d)
 {
     xcb_pixmap_t px;
+    static int attrs[] = {
+        GLX_TEXTURE_FORMAT_EXT,
+        GLX_TEXTURE_FORMAT_RGB_EXT,
+        XCB_NONE
+    };
 
     px = screen_get_root_pixmap(sc);
-    if (px) {
+    if (!px) return;
+
+    if (!d->fbconfig[sc->super->root_depth]) {
+        printf("no GL visual for depth %d\n", sc->super->root_depth);
+        return;
     }
+
+    d->root_glpixmap = glXCreatePixmap(sc->dpy->xlib_dpy,
+                                       d->fbconfig[sc->super->root_depth],
+                                       px, attrs);
+
+
+    glBindTexture(GL_TEXTURE_2D, d->root_texname);
+    d->bind_func(sc->dpy->xlib_dpy,
+                 d->root_glpixmap, GLX_FRONT_LEFT_EXT, NULL);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    glBindTexture(GL_TEXTURE_2D, 0);
 }
 
 static void
@@ -479,11 +454,7 @@ glxrender_root_pixmap_change(d_screen_t *sc)
     data_t *d;
 
     d = screen_find_plugin_data(sc, plugin_id);
-    int a; /* XXX free things here */
-    //if (d->root_picture) {
-    //    xcb_render_free_picture(sc->dpy->conn, d->root_picture);
-    //    d->root_picture = XCB_NONE;
-    //}
+    glxrender_free_root_pixmap(sc, d);
 
     /* pass it on */
     d->screen_root_pixmap_change(sc);
@@ -538,10 +509,24 @@ glxrender_paint(d_screen_t *sc)
 static void
 paint_root(d_screen_t *sc, data_t *d)
 {
-    //if (!d->root_picture)
-    glxrender_update_root_pixmap(sc, d);
+    if (!d->root_glpixmap)
+        glxrender_update_root_pixmap(sc, d);
 
     glClear(GL_COLOR_BUFFER_BIT);
+
+    glBindTexture(GL_TEXTURE_2D, d->root_texname);
+    glBegin(GL_QUADS);
+    glVertex2i(0, 0);
+    glTexCoord2f(1, 0);
+    glVertex2i(sc->super->width_in_pixels, 0);
+    glTexCoord2f(1, 1);
+    glVertex2i(sc->super->width_in_pixels, sc->super->height_in_pixels);
+    glTexCoord2f(0, 1);
+    glVertex2i(0, sc->super->height_in_pixels);
+    glTexCoord2f(0, 0);
+    glEnd();
+
+    glBindTexture(GL_TEXTURE_2D, 0);
 }
 
 static void