[Mplayer-cvslog] CVS: main/libvo vo_x11.c,1.116,1.117 x11_common.c,1.96,1.97 x11_common.h,1.26,1.27

Jürgen Keil jkeil at mplayerhq.hu
Tue Sep 3 20:11:01 CEST 2002


Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv4975

Modified Files:
	vo_x11.c x11_common.c x11_common.h 
Log Message:
Add the code that chooses a good X11 truecolor visual to the vo_x11 config()
function.  This is useful for framebuffers on Sun hardware, where we have
multiple truecolor visuals of different depths available, and the root
window typically runs at depth 8, yet there are 24 bit true color visuals
available as well.


Index: vo_x11.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_x11.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- vo_x11.c	28 Aug 2002 21:32:32 -0000	1.116
+++ vo_x11.c	3 Sep 2002 18:10:42 -0000	1.117
@@ -272,7 +272,10 @@
  XGetWindowAttributes( mDisplay,mRootWin,&attribs );
  depth=attribs.depth;
 
- if ( depth != 8 && depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24;
+ if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) {
+   Visual *visual;
+   depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual);
+ }
  XMatchVisualInfo( mDisplay,mScreen,depth,TrueColor,&vinfo );
 
  /* set image size (which is indeed neither the input nor output size), 

Index: x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- x11_common.c	28 Aug 2002 15:55:58 -0000	1.96
+++ x11_common.c	3 Sep 2002 18:10:42 -0000	1.97
@@ -40,14 +40,6 @@
 #include "../mplayer.h"
 #endif
 
-/*
- * If SCAN_VISUALS is defined, vo_init() scans all available TrueColor
- * visuals for the 'best' visual for MPlayer video display.  Note that
- * the 'best' visual might be different from the default visual that
- * is in use on the root window of the display/screen.
- */
-#define	SCAN_VISUALS
-
 #define vo_wm_Unknown     0
 #define vo_wm_NetWM       1
 #define vo_wm_KDE         2
@@ -108,55 +100,6 @@
  XDefineCursor( disp,win,0 ); 
 }
 
-#ifdef	SCAN_VISUALS
-/*
- * Scan the available visuals on this Display/Screen.  Try to find
- * the 'best' available TrueColor visual that has a decent color
- * depth (at least 15bit).  If there are multiple visuals with depth
- * >= 15bit, we prefer visuals with a smaller color depth.
- */
-int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
-{
-  XVisualInfo visual_tmpl;
-  XVisualInfo *visuals;
-  int nvisuals, i;
-  int bestvisual = -1;
-  int bestvisual_depth = -1;
-
-  visual_tmpl.screen = screen;
-  visual_tmpl.class = TrueColor;
-  visuals = XGetVisualInfo(dpy,
-			   VisualScreenMask | VisualClassMask, &visual_tmpl,
-			   &nvisuals);
-  if (visuals != NULL) {
-    for (i = 0; i < nvisuals; i++) {
-      mp_msg(MSGT_VO,MSGL_V,"vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n",
-	       visuals[i].visualid, visuals[i].depth,
-	       visuals[i].red_mask, visuals[i].green_mask,
-	       visuals[i].blue_mask);
-      /*
-       * save the visual index and it's depth, if this is the first
-       * truecolor visul, or a visual that is 'preferred' over the
-       * previous 'best' visual
-       */
-      if (bestvisual_depth == -1
-	  || (visuals[i].depth >= 15 
-	      && (   visuals[i].depth < bestvisual_depth
-		  || bestvisual_depth < 15))) {
-	bestvisual = i;
-	bestvisual_depth = visuals[i].depth;
-      }
-    }
-
-    if (bestvisual != -1 && visual_return != NULL)
-      *visual_return = visuals[bestvisual].visual;
-
-    XFree(visuals);
-  }
-  return bestvisual_depth;
-}
-#endif
-
 static int x11_errorhandler(Display *display, XErrorEvent *event)
 {
 #define MSGLEN 60
@@ -313,7 +256,6 @@
  XGetWindowAttributes(mDisplay, mRootWin, &attribs);
  depth=attribs.depth;
 
-#ifdef	SCAN_VISUALS
  if (depth != 15 && depth != 16 && depth != 24 && depth != 32) {
    Visual *visual;
 
@@ -322,8 +264,7 @@
      mXImage=XCreateImage(mDisplay, visual, depth, ZPixmap,
 			  0, NULL, 1, 1, 8, 1);
  } else
-#endif
- mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
+   mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
 
  vo_depthonscreen = depth;	// display depth on screen
 
@@ -953,4 +894,53 @@
 }
 #endif
 
-#endif
+#endif	/* X11_FULLSCREEN */
+
+
+/*
+ * Scan the available visuals on this Display/Screen.  Try to find
+ * the 'best' available TrueColor visual that has a decent color
+ * depth (at least 15bit).  If there are multiple visuals with depth
+ * >= 15bit, we prefer visuals with a smaller color depth.
+ */
+int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
+{
+  XVisualInfo visual_tmpl;
+  XVisualInfo *visuals;
+  int nvisuals, i;
+  int bestvisual = -1;
+  int bestvisual_depth = -1;
+
+  visual_tmpl.screen = screen;
+  visual_tmpl.class = TrueColor;
+  visuals = XGetVisualInfo(dpy,
+			   VisualScreenMask | VisualClassMask, &visual_tmpl,
+			   &nvisuals);
+  if (visuals != NULL) {
+    for (i = 0; i < nvisuals; i++) {
+      mp_msg(MSGT_VO,MSGL_V,"vo: X11 truecolor visual %#x, depth %d, R:%lX G:%lX B:%lX\n",
+	       visuals[i].visualid, visuals[i].depth,
+	       visuals[i].red_mask, visuals[i].green_mask,
+	       visuals[i].blue_mask);
+      /*
+       * save the visual index and it's depth, if this is the first
+       * truecolor visul, or a visual that is 'preferred' over the
+       * previous 'best' visual
+       */
+      if (bestvisual_depth == -1
+	  || (visuals[i].depth >= 15 
+	      && (   visuals[i].depth < bestvisual_depth
+		  || bestvisual_depth < 15))) {
+	bestvisual = i;
+	bestvisual_depth = visuals[i].depth;
+      }
+    }
+
+    if (bestvisual != -1 && visual_return != NULL)
+      *visual_return = visuals[bestvisual].visual;
+
+    XFree(visuals);
+  }
+  return bestvisual_depth;
+}
+

Index: x11_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- x11_common.h	9 Aug 2002 17:43:49 -0000	1.26
+++ x11_common.h	3 Sep 2002 18:10:42 -0000	1.27
@@ -61,3 +61,5 @@
 #endif
 
 #endif
+
+int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);




More information about the MPlayer-cvslog mailing list