changeset 14747:d87cc822b343

Remove a lot of duplicate code
author reimar
date Mon, 21 Feb 2005 14:44:39 +0000
parents f769de2d18dc
children 85dc314b3d80
files libvo/vo_gl.c libvo/vo_gl2.c libvo/w32_common.c
diffstat 3 files changed, 23 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Mon Feb 21 09:26:06 2005 +0000
+++ b/libvo/vo_gl.c	Mon Feb 21 14:44:39 2005 +0000
@@ -12,16 +12,9 @@
 #include "font_load.h"
 #include "sub.h"
 
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-//#include <X11/keysym.h>
-#include <GL/glx.h>
 #include <errno.h>
 
-#include <GL/gl.h>
-
 #include "gl_common.h"
-#include "x11_common.h"
 #include "aspect.h"
 #ifdef HAVE_NEW_GUI
 #include "Gui/interface.h"
--- a/libvo/vo_gl2.c	Mon Feb 21 09:26:06 2005 +0000
+++ b/libvo/vo_gl2.c	Mon Feb 21 14:44:39 2005 +0000
@@ -20,23 +20,9 @@
 #include "Gui/interface.h"
 #endif
 
-#include <GL/gl.h>
-#ifdef GL_WIN32
-    #include <windows.h>
-    #include <GL/glext.h>
-#else
-    #include <X11/Xlib.h>
-    #include <X11/Xutil.h>
-    #include <GL/glx.h>
-#endif
 #include <errno.h>
 
 #include "gl_common.h"
-#ifdef GL_WIN32
-    #include "w32_common.h"
-#else
-    #include "x11_common.h"
-#endif
 #include "aspect.h"
 
 #define NDEBUG
@@ -632,7 +618,6 @@
     vo_dwidth = d_width;
     vo_dheight = d_height;
 
-    destroyRenderingContext();
     if (!createRenderingContext())
 	return -1;
 
--- a/libvo/w32_common.c	Mon Feb 21 09:26:06 2005 +0000
+++ b/libvo/w32_common.c	Mon Feb 21 14:44:39 2005 +0000
@@ -106,6 +106,22 @@
     return r;
 }
 
+static void updateScreenProperties() {
+    DEVMODE dm;
+    dm.dmSize = sizeof dm;
+    dm.dmDriverExtra = 0;
+    dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
+    if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
+	mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n");
+	return;
+    }
+
+    vo_screenwidth = dm.dmPelsWidth;
+    vo_screenheight = dm.dmPelsHeight;
+    vo_depthonscreen = dm.dmBitsPerPel;
+    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+}
+
 static void changeMode(void) {
     DEVMODE dm;
     dm.dmSize = sizeof dm;
@@ -134,38 +150,14 @@
 
 	if (bestMode != -1)
 	    EnumDisplaySettings(0, bestMode, &dm);
+
+    ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
     }
-
-    vo_screenwidth = dm.dmPelsWidth;
-    vo_screenheight = dm.dmPelsHeight;
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
-    vo_dwidth = vo_screenwidth;
-    vo_dheight = vo_screenheight;
-
-    if (vo_vm)
-    ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
 }
 
 static void resetMode(void) {
     if (vo_vm)
     ChangeDisplaySettings(0, 0);
-
-    DEVMODE dm;
-    dm.dmSize = sizeof dm;
-    dm.dmDriverExtra = 0;
-    dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-    if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
-	mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n");
-	return;
-    }
-
-    vo_screenwidth = dm.dmPelsWidth;
-    vo_screenheight = dm.dmPelsHeight;
-    vo_depthonscreen = dm.dmBitsPerPel;
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
-
-    vo_dwidth = o_dwidth;
-    vo_dheight = o_dheight;
 }
 
 int createRenderingContext(void) {
@@ -174,19 +166,21 @@
     if (vo_fs || vo_ontop) layer = HWND_TOPMOST;
     if (vo_fs) {
 	changeMode();
-	SetWindowPos(vo_window, layer, 0, 0, vo_screenwidth, vo_screenheight, SWP_SHOWWINDOW);
 	if (cursor) {
 	    ShowCursor(0);
 	    cursor = 0;
 	}
     } else {
 	resetMode();
-	SetWindowPos(vo_window, layer, (vo_screenwidth - vo_dwidth) / 2, (vo_screenheight - vo_dheight) / 2, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
 	if (!cursor) {
 	    ShowCursor(1);
 	    cursor = 1;
 	}
     }
+    updateScreenProperties();
+    vo_dwidth = vo_fs ? vo_screenwidth : o_dwidth;
+    vo_dheight = vo_fs ? vo_screenheight : o_dheight;
+    SetWindowPos(vo_window, layer, (vo_screenwidth - vo_dwidth) / 2, (vo_screenheight - vo_dheight) / 2, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
 
     PIXELFORMATDESCRIPTOR pfd;
     memset(&pfd, 0, sizeof pfd);
@@ -209,14 +203,9 @@
     return 1;
 }
 
-void destroyRenderingContext(void) {
-	resetMode();
-}
-
 int vo_init(void) {
     HICON 	mplayerIcon = 0;
     char 	exedir[MAX_PATH];
-    DEVMODE	dm;
 
     if (vo_window)
 	return 1;
@@ -243,16 +232,7 @@
 
     vo_hdc = GetDC(vo_window);
 
-    dm.dmSize = sizeof dm;
-    dm.dmDriverExtra = 0;
-    dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-    if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
-	mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n");
-	return 0;
-    }
-    vo_screenwidth = dm.dmPelsWidth;
-    vo_screenheight = dm.dmPelsHeight;
-    vo_depthonscreen = dm.dmBitsPerPel;
+    updateScreenProperties();
 
     return 1;
 }
@@ -260,7 +240,6 @@
 void vo_w32_fullscreen(void) {
     vo_fs = !vo_fs;
 
-    destroyRenderingContext();
     createRenderingContext();
 }
 
@@ -279,7 +258,6 @@
     resetMode();
     ShowCursor(1);
     vo_depthonscreen = 0;
-    destroyRenderingContext();
     DestroyWindow(vo_window);
     vo_window = 0;
     UnregisterClass(classname, 0);