[MPlayer-cvslog] r36315 - in trunk/libvo: gl_common.c gl_common.h video_out.h vo_gl.c vo_gl_tiled.c vo_matrixview.c

reimar subversion at mplayerhq.hu
Sun Jun 9 20:33:21 CEST 2013


Author: reimar
Date: Sun Jun  9 20:33:21 2013
New Revision: 36315

Log:
Extract window creation code to common file.

Modified:
   trunk/libvo/gl_common.c
   trunk/libvo/gl_common.h
   trunk/libvo/video_out.h
   trunk/libvo/vo_gl.c
   trunk/libvo/vo_gl_tiled.c
   trunk/libvo/vo_matrixview.c

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/gl_common.c	Sun Jun  9 20:33:21 2013	(r36315)
@@ -2700,6 +2700,61 @@ int init_mpglcontext(MPGLContext *ctx, e
   }
 }
 
+int mpglcontext_create_window(MPGLContext *ctx, uint32_t d_width, uint32_t d_height,
+                              uint32_t flags, const char *title)
+{
+#ifdef CONFIG_GL_WIN32
+  if (ctx->type == GLTYPE_W32 && !vo_w32_config(d_width, d_height, flags))
+    return -1;
+#endif
+#ifdef CONFIG_GL_OSX
+  if (ctx->type == GLTYPE_OSX && !vo_osx_config(d_width, d_height, flags))
+    return -1;
+#endif
+#ifdef CONFIG_GL_EGL_X11
+  if (ctx->type == GLTYPE_EGL_X11) {
+    XVisualInfo vinfo = { .visual = CopyFromParent, .depth = CopyFromParent };
+    vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, flags,
+            CopyFromParent, "gl", title);
+  }
+#endif
+#ifdef CONFIG_GL_X11
+  if (ctx->type == GLTYPE_X11) {
+    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
+    };
+    static const int stereo_glx_attribs[]  = {
+      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)
+        mp_msg(MSGT_VO, MSGL_ERR, "[gl] Could not find a stereo visual, "
+                                  "3D will probably not work!\n");
+    }
+    if (!vinfo)
+      vinfo = glXChooseVisual(mDisplay, mScreen, default_glx_attribs);
+    if (!vinfo) {
+      mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
+      return -1;
+    }
+    mp_msg(MSGT_VO, MSGL_V, "[gl] 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,
+            XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone),
+            "gl", title);
+  }
+#endif
+#ifdef CONFIG_GL_SDL
+  if (ctx->type == GLTYPE_SDL && !vo_sdl_config(d_width, d_height, flags, title))
+    return -1;
+#endif
+  return 0;
+}
+
 void uninit_mpglcontext(MPGLContext *ctx) {
   ctx->releaseGlContext(ctx);
   switch (ctx->type) {

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/gl_common.h	Sun Jun  9 20:33:21 2013	(r36315)
@@ -231,6 +231,7 @@ typedef struct MPGLContext {
 } MPGLContext;
 
 int init_mpglcontext(MPGLContext *ctx, enum MPGLType type);
+int mpglcontext_create_window(MPGLContext *ctx, uint32_t d_width, uint32_t d_height, uint32_t flags, const char *title);
 void uninit_mpglcontext(MPGLContext *ctx);
 
 extern GLenum (GLAPIENTRY *mpglGetError)(void);

Modified: trunk/libvo/video_out.h
==============================================================================
--- trunk/libvo/video_out.h	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/video_out.h	Sun Jun  9 20:33:21 2013	(r36315)
@@ -115,6 +115,7 @@ typedef struct {
 #define VOFLAG_FLIPPING           0x08
 #define VOFLAG_HIDDEN             0x10  //< Use to create a hidden window
 #define VOFLAG_STEREO             0x20  //< Use to create a stereo-capable window
+#define VOFLAG_DEPTH              0x40  //< Request a depth buffer
 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
 
 typedef struct vo_info_s

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/vo_gl.c	Sun Jun  9 20:33:21 2013	(r36315)
@@ -663,51 +663,6 @@ static int create_window(uint32_t d_widt
 {
   if (stereo_mode == GL_3D_QUADBUFFER)
     flags |= VOFLAG_STEREO;
-#ifdef CONFIG_GL_WIN32
-  if (glctx.type == GLTYPE_W32 && !vo_w32_config(d_width, d_height, flags))
-    return -1;
-#endif
-#ifdef CONFIG_GL_OSX
-  if (glctx.type == GLTYPE_OSX && !vo_osx_config(d_width, d_height, flags))
-    return -1;
-#endif
-#ifdef CONFIG_GL_EGL_X11
-  if (glctx.type == GLTYPE_EGL_X11) {
-    XVisualInfo vinfo = { .visual = CopyFromParent, .depth = CopyFromParent };
-    vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, flags,
-            CopyFromParent, "gl", title);
-  }
-#endif
-#ifdef CONFIG_GL_X11
-  if (glctx.type == GLTYPE_X11) {
-    static int default_glx_attribs[] = {
-      GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
-      GLX_DOUBLEBUFFER, None
-    };
-    static int stereo_glx_attribs[]  = {
-      GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
-      GLX_DOUBLEBUFFER, GLX_STEREO, None
-    };
-    XVisualInfo *vinfo = NULL;
-    if (stereo_mode == GL_3D_QUADBUFFER) {
-      vinfo = glXChooseVisual(mDisplay, mScreen, stereo_glx_attribs);
-      if (!vinfo)
-        mp_msg(MSGT_VO, MSGL_ERR, "[gl] Could not find a stereo visual, "
-                                  "3D will probably not work!\n");
-    }
-    if (!vinfo)
-      vinfo = glXChooseVisual(mDisplay, mScreen, default_glx_attribs);
-    if (!vinfo) {
-      mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
-      return -1;
-    }
-    mp_msg(MSGT_VO, MSGL_V, "[gl] 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,
-            XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone),
-            "gl", title);
-  }
-#endif
 #ifdef CONFIG_GL_SDL
   if (glctx.type == GLTYPE_SDL) {
     // Ugly to do this here, but SDL ignores it if set later
@@ -718,11 +673,9 @@ static int create_window(uint32_t d_widt
       SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, swap_interval);
 #endif
     }
-    if (!vo_sdl_config(d_width, d_height, flags, title))
-        return -1;
   }
 #endif
-  return 0;
+  return mpglcontext_create_window(&glctx, d_width, d_height, flags, title);
 }
 
 #ifdef CONFIG_GL_OSX

Modified: trunk/libvo/vo_gl_tiled.c
==============================================================================
--- trunk/libvo/vo_gl_tiled.c	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/vo_gl_tiled.c	Sun Jun  9 20:33:21 2013	(r36315)
@@ -456,17 +456,6 @@ static void draw_alpha(int x0,int y0, in
    draw(w,h,src,srca,stride,ImageData+bpp*(y0*image_width+x0),bpp*image_width);
 }
 
-#ifdef CONFIG_GL_WIN32
-
-static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) {
-  if (!vo_w32_config(d_width, d_height, flags))
-    return -1;
-
-  return 0;
-}
-
-#endif
-
 #ifdef CONFIG_GL_X11
 static int choose_glx_visual(Display *dpy, int scr, XVisualInfo *res_vi)
 {
@@ -614,12 +603,11 @@ config(uint32_t width, uint32_t height, 
 
   int_pause = 0;
 
-#ifdef CONFIG_GL_WIN32
-  if (config_w32(width, height, d_width, d_height, flags, title, format) == -1)
-#endif
 #ifdef CONFIG_GL_X11
-  if (config_glx(width, height, d_width, d_height, flags, title, format) == -1)
+  if (glctx.type == GLTYPE_X11 && config_glx(width, height, d_width, d_height, flags, title, format) == -1)
+    return -1;
 #endif
+  if (glctx.type != GLTYPE_X11 && mpglcontext_create_window(&glctx, d_width, d_height, flags, title) < 0)
     return -1;
 
   if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED)
@@ -822,11 +810,8 @@ static const opt_t subopts[] = {
 
 static int preinit(const char *arg)
 {
-  enum MPGLType gltype = GLTYPE_X11;
+  enum MPGLType gltype = GLTYPE_AUTO;
   // set defaults
-#ifdef CONFIG_GL_WIN32
-  gltype = GLTYPE_W32;
-#endif
   use_yuv = -1;
   use_glFinish = 1;
   if (subopt_parse(arg, subopts) != 0) {
@@ -848,13 +833,12 @@ static int preinit(const char *arg)
   }
     if(!init_mpglcontext(&glctx, gltype)) goto err_out;
     if (use_yuv == -1) {
-#ifdef CONFIG_GL_WIN32
-      if (config_w32(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1)
-#endif
 #ifdef CONFIG_GL_X11
-      if (config_glx(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1)
-#endif
+      if (glctx.type == GLTYPE_X11 && config_glx(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1)
         goto err_out;
+#endif
+      if (glctx.type != GLTYPE_X11 && mpglcontext_create_window(&glctx, 320, 200, VOFLAG_HIDDEN, "") < 0)
+        return -1;
       if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED)
         goto err_out;
       use_yuv = glAutodetectYUVConversion();

Modified: trunk/libvo/vo_matrixview.c
==============================================================================
--- trunk/libvo/vo_matrixview.c	Sun Jun  9 16:16:37 2013	(r36314)
+++ trunk/libvo/vo_matrixview.c	Sun Jun  9 20:33:21 2013	(r36315)
@@ -50,18 +50,6 @@ const LIBVO_EXTERN(matrixview)
 
 static MPGLContext glctx;
 
-#ifdef CONFIG_GL_X11
-static int wsGLXAttrib[] = {
-    GLX_RGBA,
-    GLX_RED_SIZE,1,
-    GLX_GREEN_SIZE,1,
-    GLX_BLUE_SIZE,1,
-    GLX_DEPTH_SIZE,1,
-    GLX_DOUBLEBUFFER,
-    None
-};
-#endif
-
 static int int_pause;
 static int eq_contrast;
 static int eq_brightness;
@@ -115,26 +103,9 @@ static int config(uint32_t width, uint32
 
     int_pause = 0;
 
-#ifdef CONFIG_GL_WIN32
-    if (glctx.type == GLTYPE_W32 && !vo_w32_config(d_width, d_height, flags))
+    flags |= VOFLAG_DEPTH;
+    if (mpglcontext_create_window(&glctx, d_width, d_height, flags, title) < 0)
         return -1;
-#endif
-#ifdef CONFIG_GL_X11
-    if (glctx.type == GLTYPE_X11) {
-        XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
-        if (vinfo == NULL) {
-            mp_msg(MSGT_VO, MSGL_ERR, "[matrixview] no GLX support present\n");
-            return -1;
-        }
-        mp_msg(MSGT_VO, MSGL_V, "[matrixview] 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,
-                                XCreateColormap(mDisplay, mRootWin,
-                                                vinfo->visual, AllocNone),
-                                "matrixview", title);
-    }
-#endif /* CONFIG_GL_WIN32 */
     if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED)
         return -1;
 
@@ -244,10 +215,7 @@ static const opt_t subopts[] =
 
 static int preinit(const char *arg)
 {
-    enum MPGLType gltype = GLTYPE_X11;
-#ifdef CONFIG_GL_WIN32
-    gltype = GLTYPE_W32;
-#endif
+    enum MPGLType gltype = GLTYPE_AUTO;
     if (!init_mpglcontext(&glctx, gltype))
         return -1;
 


More information about the MPlayer-cvslog mailing list