[MPlayer-cvslog] r38174 - in trunk: Changelog gui/wm/ws.c libvo/gl_common.c libvo/gl_common.h libvo/vo_gl_tiled.c

ib subversion at mplayerhq.hu
Tue Feb 4 20:21:39 EET 2020


Author: ib
Date: Tue Feb  4 20:21:39 2020
New Revision: 38174

Log:
Pass visual information to OpenGL video output driver for X11.

The GUI and the OpenGL video output driver for X11 choose different
visuals which results in a BadMatch error from XChangeWindowAttributes()
in x11_common.c.

Since the GUI has to choose the visual first to create its main window,
it is necessary to tell it the drivers so that they can use this same
(hopefully suitable) visual.

Modified:
   trunk/Changelog
   trunk/gui/wm/ws.c
   trunk/libvo/gl_common.c
   trunk/libvo/gl_common.h
   trunk/libvo/vo_gl_tiled.c

Modified: trunk/Changelog
==============================================================================
--- trunk/Changelog	Tue Feb  4 16:03:18 2020	(r38173)
+++ trunk/Changelog	Tue Feb  4 20:21:39 2020	(r38174)
@@ -11,6 +11,7 @@ MPlayer
     * Enable video output drivers which write to files
     * Command line option -fs is now recognized in addition to the
       GUI option load_fullscreen
+    * Use correct visual in OpenGL video output driver for X11
 
   1.4: "SubCounter" April 18, 2019
 

Modified: trunk/gui/wm/ws.c
==============================================================================
--- trunk/gui/wm/ws.c	Tue Feb  4 16:03:18 2020	(r38173)
+++ trunk/gui/wm/ws.c	Tue Feb  4 20:21:39 2020	(r38174)
@@ -64,6 +64,8 @@ int wsOrgX;                          //
 int wsOrgY;                          // Screen origin y.
 
 Display *wsDisplay;
+XVisualInfo *gl_vinfo;
+
 static int wsScreen;
 static Window wsRootWin;
 
@@ -828,6 +830,8 @@ void wsWindowCreate(wsWindow *win, int x
 
     XMatchVisualInfo(wsDisplay, wsScreen, depth, TrueColor, &win->VisualInfo);
 
+    gl_vinfo = &win->VisualInfo;
+
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[ws] visual: ID %#lx\n", win->VisualInfo.visualid);
 
 /* --- */

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Tue Feb  4 16:03:18 2020	(r38173)
+++ trunk/libvo/gl_common.c	Tue Feb  4 20:21:39 2020	(r38174)
@@ -2769,6 +2769,13 @@ int mpglcontext_create_window(MPGLContex
 #endif
 #ifdef CONFIG_GL_X11
   if (ctx->type == GLTYPE_X11) {
+    XVisualInfo *vinfo = NULL;
+#ifdef CONFIG_GUI
+    int value;
+
+    if (glXGetConfig(mDisplay, gl_vinfo, GLX_USE_GL, &value) == 0 && value == True)
+      vinfo = gl_vinfo;
+#else
     int default_glx_attribs[] = {
       GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
       GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, (flags & VOFLAG_DEPTH) ? 1 : 0, None
@@ -2777,7 +2784,6 @@ int mpglcontext_create_window(MPGLContex
       GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
       GLX_DOUBLEBUFFER, GLX_STEREO, None
     };
-    XVisualInfo *vinfo = NULL;
     if (flags & VOFLAG_STEREO) {
       vinfo = glXChooseVisual(mDisplay, mScreen, stereo_glx_attribs);
       if (!vinfo)
@@ -2786,6 +2792,7 @@ int mpglcontext_create_window(MPGLContex
     }
     if (!vinfo)
       vinfo = glXChooseVisual(mDisplay, mScreen, default_glx_attribs);
+#endif
     if (!vinfo) {
       mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
       return -1;

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Tue Feb  4 16:03:18 2020	(r38173)
+++ trunk/libvo/gl_common.h	Tue Feb  4 20:21:39 2020	(r38174)
@@ -316,4 +316,6 @@ extern void (GLAPIENTRY *mpglTexImage3D)
 extern void* (GLAPIENTRY *mpglAllocateMemoryMESA)(void *, int, size_t, float, float, float);
 extern void (GLAPIENTRY *mpglFreeMemoryMESA)(void *, int, void *);
 
+extern XVisualInfo *gl_vinfo;
+
 #endif /* MPLAYER_GL_COMMON_H */

Modified: trunk/libvo/vo_gl_tiled.c
==============================================================================
--- trunk/libvo/vo_gl_tiled.c	Tue Feb  4 16:03:18 2020	(r38173)
+++ trunk/libvo/vo_gl_tiled.c	Tue Feb  4 20:21:39 2020	(r38174)
@@ -458,6 +458,15 @@ static void draw_alpha(int x0,int y0, in
 #ifdef CONFIG_GL_X11
 static int choose_glx_visual(Display *dpy, int scr, XVisualInfo *res_vi)
 {
+#ifdef CONFIG_GUI
+  int value;
+
+  if (glXGetConfig(mDisplay, gl_vinfo, GLX_USE_GL, &value) == 0 && value == True) {
+    *res_vi = *gl_vinfo;
+    return 0;
+  } else
+    return -1;
+#else
   XVisualInfo template, *vi_list;
   int vi_num, i, best_i, best_weight;
 
@@ -510,6 +519,7 @@ static int choose_glx_visual(Display *dp
   if (best_weight < 1000000) *res_vi = vi_list[best_i];
   XFree(vi_list);
   return (best_weight < 1000000) ? 0 : -1;
+#endif
 }
 
 static int config_glx(uint32_t d_width, uint32_t d_height, uint32_t flags, char *title) {
@@ -520,6 +530,8 @@ static int config_glx(uint32_t d_width,
       return -1;
     }
 
+  mp_msg(MSGT_VO, MSGL_V, "[gl_tiled] GLX chose visual with ID 0x%x\n", (int)vinfo->visualid);
+
   vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height,
           flags, vo_x11_create_colormap(vinfo), "gl_tiled", title);
 


More information about the MPlayer-cvslog mailing list