From cdfb0214ba6e03f39af9dea94f120c9339838fce Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 21 Feb 2005 14:44:39 +0000 Subject: Remove a lot of duplicate code git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14748 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 7 ------ libvo/vo_gl2.c | 15 ------------- libvo/w32_common.c | 66 ++++++++++++++++++------------------------------------ 3 files changed, 22 insertions(+), 66 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index f84065d868..3011a5ce74 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -12,16 +12,9 @@ #include "font_load.h" #include "sub.h" -#include -#include -//#include -#include #include -#include - #include "gl_common.h" -#include "x11_common.h" #include "aspect.h" #ifdef HAVE_NEW_GUI #include "Gui/interface.h" diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index c4128d7415..03b894171b 100644 --- a/libvo/vo_gl2.c +++ b/libvo/vo_gl2.c @@ -20,23 +20,9 @@ #include "Gui/interface.h" #endif -#include -#ifdef GL_WIN32 - #include - #include -#else - #include - #include - #include -#endif #include #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 @@ static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_ vo_dwidth = d_width; vo_dheight = d_height; - destroyRenderingContext(); if (!createRenderingContext()) return -1; diff --git a/libvo/w32_common.c b/libvo/w32_common.c index 13b8839d29..60e38d3555 100644 --- a/libvo/w32_common.c +++ b/libvo/w32_common.c @@ -106,6 +106,22 @@ int vo_w32_check_events(void) { 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 @@ static void changeMode(void) { if (bestMode != -1) EnumDisplaySettings(0, bestMode, &dm); - } - - 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 @@ int createRenderingContext(void) { 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 @@ int createRenderingContext(void) { 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 @@ int vo_init(void) { 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 @@ int vo_init(void) { void vo_w32_fullscreen(void) { vo_fs = !vo_fs; - destroyRenderingContext(); createRenderingContext(); } @@ -279,7 +258,6 @@ void vo_w32_uninit() { resetMode(); ShowCursor(1); vo_depthonscreen = 0; - destroyRenderingContext(); DestroyWindow(vo_window); vo_window = 0; UnregisterClass(classname, 0); -- cgit v1.2.3