[Xfce4-commits] [xfce/xfwm4] 01/01: compositor: bind/release texture on each GLX swap

noreply at xfce.org noreply at xfce.org
Sat Sep 21 16:17:14 CEST 2019


This is an automated email from the git hooks/post-receive script.

o   l   i   v   i   e   r       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfwm4.

commit e5462de37a4b0a18c051e9a92ea6dce7cd7b79a8
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Sat Sep 21 16:06:52 2019 +0200

    compositor: bind/release texture on each GLX swap
    
    The documentation for `EXT_texture_from_pixmap` states that a
    compositor should bind and release the texture each time:
    
        [...]
        glXBindTexImageEXT()
    
        <Do rendering/compositing>
    
        glXReleaseTexImageEXT()
        [...]
    
    Fix the compositor to adhere to the specification.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/compositor.c | 117 +++++++++++++++++++++++++++++++------------------------
 1 file changed, 66 insertions(+), 51 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 0f48872..d70bb72 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1382,32 +1382,6 @@ init_glx (ScreenInfo *screen_info)
     return TRUE;
 }
 
-static GLXDrawable
-create_glx_drawable (ScreenInfo *screen_info, gushort buffer)
-{
-    int pixmap_attribs[] = {
-        GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-        GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
-        None
-    };
-    GLXDrawable glx_drawable;
-
-    g_return_val_if_fail (screen_info != NULL, None);
-    TRACE ("entering");
-
-    pixmap_attribs[1] = screen_info->texture_target;
-    pixmap_attribs[3] = screen_info->texture_format;
-
-    glx_drawable = glXCreatePixmap (myScreenGetXDisplay (screen_info),
-                                    screen_info->glx_fbconfig,
-                                    screen_info->rootPixmap[buffer],
-                                    pixmap_attribs);
-    check_gl_error();
-    TRACE ("created GLX pixmap 0x%lx for buffer %i", glx_drawable, buffer);
-
-    return glx_drawable;
-}
-
 static void
 enable_glx_texture (ScreenInfo *screen_info)
 {
@@ -1429,30 +1403,6 @@ disable_glx_texture (ScreenInfo *screen_info)
 }
 
 static void
-destroy_glx_drawable (ScreenInfo *screen_info)
-{
-    g_return_if_fail (screen_info != NULL);
-    TRACE ("entering");
-
-    if (screen_info->glx_drawable)
-    {
-        TRACE ("unbinding GLX drawable 0x%lx", screen_info->glx_drawable);
-        glXReleaseTexImageEXT (myScreenGetXDisplay (screen_info),
-                               screen_info->glx_drawable, GLX_FRONT_EXT);
-        glXDestroyPixmap(myScreenGetXDisplay (screen_info), screen_info->glx_drawable);
-        screen_info->glx_drawable = None;
-    }
-
-    if (screen_info->rootTexture)
-    {
-        disable_glx_texture (screen_info);
-        glDeleteTextures (1, &screen_info->rootTexture);
-        screen_info->rootTexture = None;
-    }
-    check_gl_error();
-}
-
-static void
 fence_create (ScreenInfo *screen_info, gushort buffer)
 {
 #ifdef HAVE_XSYNC
@@ -1532,6 +1482,32 @@ fence_destroy (ScreenInfo *screen_info, gushort buffer)
 #endif /* HAVE_XSYNC */
 }
 
+static GLXDrawable
+create_glx_drawable (ScreenInfo *screen_info, gushort buffer)
+{
+    int pixmap_attribs[] = {
+        GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+        GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
+        None
+    };
+    GLXDrawable glx_drawable;
+
+    g_return_val_if_fail (screen_info != NULL, None);
+    TRACE ("entering");
+
+    pixmap_attribs[1] = screen_info->texture_target;
+    pixmap_attribs[3] = screen_info->texture_format;
+
+    glx_drawable = glXCreatePixmap (myScreenGetXDisplay (screen_info),
+                                    screen_info->glx_fbconfig,
+                                    screen_info->rootPixmap[buffer],
+                                    pixmap_attribs);
+    check_gl_error();
+    TRACE ("created GLX pixmap 0x%lx for buffer %i", glx_drawable, buffer);
+
+    return glx_drawable;
+}
+
 static void
 bind_glx_texture (ScreenInfo *screen_info, gushort buffer)
 {
@@ -1557,6 +1533,42 @@ bind_glx_texture (ScreenInfo *screen_info, gushort buffer)
 }
 
 static void
+unbind_glx_texture (ScreenInfo *screen_info)
+{
+    g_return_if_fail (screen_info != NULL);
+    TRACE ("entering");
+
+    if (screen_info->glx_drawable)
+    {
+        TRACE ("unbinding GLX drawable 0x%lx", screen_info->glx_drawable);
+        glXReleaseTexImageEXT (myScreenGetXDisplay (screen_info),
+                               screen_info->glx_drawable, GLX_FRONT_EXT);
+    }
+}
+
+static void
+destroy_glx_drawable (ScreenInfo *screen_info)
+{
+    g_return_if_fail (screen_info != NULL);
+    TRACE ("entering");
+
+    if (screen_info->glx_drawable)
+    {
+        unbind_glx_texture (screen_info);
+        glXDestroyPixmap(myScreenGetXDisplay (screen_info), screen_info->glx_drawable);
+        screen_info->glx_drawable = None;
+    }
+
+    if (screen_info->rootTexture)
+    {
+        disable_glx_texture (screen_info);
+        glDeleteTextures (1, &screen_info->rootTexture);
+        screen_info->rootTexture = None;
+    }
+    check_gl_error();
+}
+
+static void
 set_glx_scale (ScreenInfo *screen_info, gint width, gint height, double scale)
 {
     if (screen_info->texture_type == GL_TEXTURE_RECTANGLE_ARB)
@@ -1623,6 +1635,8 @@ redraw_glx_texture (ScreenInfo *screen_info, XserverRegion region, gushort buffe
     TRACE ("(re)Drawing GLX pixmap 0x%lx/texture 0x%x",
            screen_info->glx_drawable, screen_info->rootTexture);
 
+    bind_glx_texture (screen_info, buffer);
+
     glDrawBuffer (GL_BACK);
     glViewport(0, 0, screen_info->width, screen_info->height);
 
@@ -1672,6 +1686,8 @@ redraw_glx_texture (ScreenInfo *screen_info, XserverRegion region, gushort buffe
 
     glPopMatrix();
 
+    unbind_glx_texture (screen_info);
+
     check_gl_error();
 }
 #endif /* HAVE_EPOXY */
@@ -2135,7 +2151,6 @@ paint_all (ScreenInfo *screen_info, XserverRegion region, gushort buffer)
 #ifdef HAVE_EPOXY
         if (screen_info->use_glx)
         {
-            bind_glx_texture (screen_info, buffer);
             fence_create (screen_info, buffer);
         }
 #endif /* HAVE_EPOXY */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list