[Xfce4-commits] [xfce/xfwm4] 01/02: compositor: add command line option for vblank

noreply at xfce.org noreply at xfce.org
Fri Dec 8 20:01:13 CET 2017


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 7d6cddd70eb0df96a86a8f2da288658c21e396a8
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri Dec 8 19:58:25 2017 +0100

    compositor: add command line option for vblank
    
    vblank method can be selected using a command line option.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/compositor.c | 24 ++++++++++------------
 src/compositor.h |  8 ++++++++
 src/display.h    |  2 ++
 src/main.c       | 62 +++++++++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 69 insertions(+), 27 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index eaa4d66..94e177f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4305,7 +4305,9 @@ compositorManageScreen (ScreenInfo *screen_info)
     TRACE ("Manual compositing enabled");
 
 #ifdef HAVE_PRESENT_EXTENSION
-    screen_info->use_present = display_info->have_present && !screen_info->use_glx;
+    screen_info->use_present = display_info->have_present &&
+                               (display_info->vblank_method == VBLANK_AUTO ||
+                                display_info->vblank_method == VBLANK_XPRESENT);
     if (screen_info->use_present)
     {
         screen_info->present_pending = FALSE;
@@ -4313,16 +4315,16 @@ compositorManageScreen (ScreenInfo *screen_info)
                              screen_info->output,
                              PresentCompleteNotifyMask);
     }
-    else
-    {
-        g_warning ("XPresent not available");
-    }
 #else /* HAVE_PRESENT_EXTENSION */
     screen_info->use_present = FALSE;
 #endif /* HAVE_PRESENT_EXTENSION */
 
 #ifdef HAVE_EPOXY
-    if (!screen_info->use_present)
+    screen_info->use_glx = !screen_info->use_present &&
+                           (display_info->vblank_method == VBLANK_AUTO ||
+                            display_info->vblank_method == VBLANK_GLX);
+
+    if (screen_info->use_glx)
     {
         screen_info->glx_context = None;
         screen_info->glx_window = None;
@@ -4331,25 +4333,21 @@ compositorManageScreen (ScreenInfo *screen_info)
         screen_info->texture_filter = GL_LINEAR;
         screen_info->use_glx = init_glx (screen_info);
     }
-    else
-    {
-        g_warning ("GL not available");
-    }
 #else /* HAVE_EPOXY */
     screen_info->use_glx = FALSE;
 #endif /* HAVE_EPOXY */
 
     if (screen_info->use_present)
     {
-        DBG ("Compositor using XPresent for vsync");
+        g_info ("Compositor using XPresent for vsync");
     }
     else if (screen_info->use_glx)
     {
-        DBG ("Compositor using GLX for vsync");
+        g_info ("Compositor using GLX for vsync");
     }
     else
     {
-        g_warning ("No vsync support in compositor");
+        g_info ("No vsync support in compositor");
     }
 
     XFixesSelectCursorInput (display_info->dpy,
diff --git a/src/compositor.h b/src/compositor.h
index 74e6703..9212d66 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -34,6 +34,14 @@
 #include "screen.h"
 #include "client.h"
 
+enum
+{
+    VBLANK_OFF = 0,
+    VBLANK_AUTO,
+    VBLANK_XPRESENT,
+    VBLANK_GLX
+};
+
 gboolean                 compositorIsUsable                     (DisplayInfo *);
 gboolean                 compositorIsActive                     (ScreenInfo *);
 void                     compositorAddWindow                    (DisplayInfo *,
diff --git a/src/display.h b/src/display.h
index 59670c3..37c2086 100644
--- a/src/display.h
+++ b/src/display.h
@@ -319,6 +319,8 @@ struct _DisplayInfo
     guint32 last_user_time;
 
     gboolean enable_compositor;
+    gint vblank_method;
+
 #ifdef HAVE_RENDER
     gint render_error_base;
     gint render_event_base;
diff --git a/src/main.c b/src/main.c
index 254ed54..06b22db 100644
--- a/src/main.c
+++ b/src/main.c
@@ -89,12 +89,20 @@ enum {
 };
 
 static gint compositor = COMPOSITOR_MODE_MANUAL;
+static gint vblank_method = VBLANK_AUTO;
+#define XFWM4_ERROR      (xfwm4_error_quark ())
 
 #ifndef DEBUG
 /* For what, IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.*/
 static char revision[]="@(#)$ " PACKAGE " version " VERSION " revision " REVISION " $";
 #endif
 
+GQuark
+xfwm4_error_quark (void)
+{
+  return g_quark_from_static_string ("xfwm4-error-quark");
+}
+
 #ifdef DEBUG
 static gboolean
 setupLog (void)
@@ -419,17 +427,6 @@ get_default_compositor (DisplayInfo *display_info)
         return 0;
     }
 
-#if 0
-    /*
-     * Test if the XRender implementation is fast enough for the
-     * compositor.
-     */
-    if (!myDisplayTestXrender (display_info, 0.025))
-    {
-        g_warning ("The XRender implementation currently in use on this system is too slow for the compositor");
-        return 0;
-    }
-#endif
     return 2;
 }
 #endif /* HAVE_COMPOSITOR */
@@ -459,7 +456,44 @@ compositor_callback (const gchar  *name,
     }
     else
     {
-        g_set_error (error, 0, 0, "Unrecognized compositor option \"%s\"", value);
+        g_set_error (error, XFWM4_ERROR, 0, "Unrecognized compositor option \"%s\"", value);
+        succeed = FALSE;
+    }
+
+    return succeed;
+}
+
+static gboolean
+vblank_callback (const gchar  *name,
+                     const gchar  *value,
+                     gpointer      user_data,
+                     GError      **error)
+{
+    gboolean succeed = TRUE;
+
+    g_return_val_if_fail (value != NULL, FALSE);
+
+#ifdef HAVE_PRESENT_EXTENSION
+    if (strcmp (value, "xpresent") == 0)
+    {
+        vblank_method = VBLANK_XPRESENT;
+    }
+    else
+#endif /* HAVE_PRESENT_EXTENSION */
+#ifdef HAVE_EPOXY
+    if (strcmp (value, "glx") == 0)
+    {
+        vblank_method = VBLANK_GLX;
+    }
+    else
+#endif /* HAVE_EPOXY */
+    if (strcmp (value, "off") == 0)
+    {
+        vblank_method = VBLANK_OFF;
+    }
+    else
+    {
+        g_set_error (error, XFWM4_ERROR, 0, "Unrecognized compositor option \"%s\"", value);
         succeed = FALSE;
     }
 
@@ -505,6 +539,7 @@ initialize (gint compositor_mode, gboolean replace_wm)
     {
         display_info->enable_compositor = FALSE;
     }
+    display_info->vblank_method = vblank_method;
     compositorSetCompositeMode (display_info, (compositor_mode == COMPOSITOR_MODE_MANUAL));
 #else /* HAVE_COMPOSITOR */
     display_info->enable_compositor = FALSE;
@@ -658,8 +693,7 @@ main (int argc, char **argv)
         { "daemon", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, daemon_callback, N_("Fork to the background (not supported)"), NULL },
 #ifdef HAVE_COMPOSITOR
         { "compositor", '\0', 0, G_OPTION_ARG_CALLBACK, compositor_callback, N_("Set the compositor mode"), "on|off|auto" },
-#else
-        { "compositor", '\0', 0, G_OPTION_ARG_STRING, &compositor_foo, N_("Set the compositor mode (not supported)"), "on|off|auto" },
+        { "vblank", '\0', 0, G_OPTION_ARG_CALLBACK, vblank_callback, N_("Set the vblank mode"), "off|present|glx" },
 #endif
         { "replace", '\0', 0, G_OPTION_ARG_NONE, &replace_wm, N_("Replace the existing window manager"), NULL },
         { "version", 'V', 0, G_OPTION_ARG_NONE, &version, N_("Print version information and exit"), NULL },

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


More information about the Xfce4-commits mailing list