comparison libvo/w32_common.c @ 24314:20359547f3c3

Remove global vo_hdc, since it is recommended to release a DC as soon as possible.
author reimar
date Mon, 03 Sep 2007 08:44:36 +0000
parents 58bd3640c0c2
children 12f2487fb845
comparison
equal deleted inserted replaced
24313:2624fefeee1a 24314:20359547f3c3
18 #define MONITOR_DEFAULTTOPRIMARY 1 18 #define MONITOR_DEFAULTTOPRIMARY 1
19 #endif 19 #endif
20 20
21 static const char* classname = "MPlayer - Media player for Win32"; 21 static const char* classname = "MPlayer - Media player for Win32";
22 int vo_vm = 0; 22 int vo_vm = 0;
23 HDC vo_hdc = 0;
24 23
25 // last non-fullscreen extends 24 // last non-fullscreen extends
26 int prev_width; 25 int prev_width;
27 int prev_height; 26 int prev_height;
28 int prev_x; 27 int prev_x;
248 } 247 }
249 248
250 static int createRenderingContext(void) { 249 static int createRenderingContext(void) {
251 HWND layer = HWND_NOTOPMOST; 250 HWND layer = HWND_NOTOPMOST;
252 PIXELFORMATDESCRIPTOR pfd; 251 PIXELFORMATDESCRIPTOR pfd;
252 HDC vo_hdc = GetDC(vo_window);
253 RECT r; 253 RECT r;
254 int pf; 254 int pf;
255 if (WinID < 0) { 255 if (WinID < 0) {
256 int style = (vo_border && !vo_fs) ? 256 int style = (vo_border && !vo_fs) ?
257 (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP; 257 (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP;
306 pfd.cColorBits = 24; 306 pfd.cColorBits = 24;
307 pfd.iLayerType = PFD_MAIN_PLANE; 307 pfd.iLayerType = PFD_MAIN_PLANE;
308 pf = ChoosePixelFormat(vo_hdc, &pfd); 308 pf = ChoosePixelFormat(vo_hdc, &pfd);
309 if (!pf) { 309 if (!pf) {
310 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n"); 310 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
311 ReleaseDC(vo_hdc);
311 return 0; 312 return 0;
312 } 313 }
313 314
314 SetPixelFormat(vo_hdc, pf, &pfd); 315 SetPixelFormat(vo_hdc, pf, &pfd);
315 316
316 mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen); 317 mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
317 318
319 ReleaseDC(vo_hdc);
318 return 1; 320 return 1;
319 } 321 }
320 322
321 int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) { 323 int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) {
322 // store original size for videomode switching 324 // store original size for videomode switching
367 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to create window!\n"); 369 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to create window!\n");
368 return 0; 370 return 0;
369 } 371 }
370 } 372 }
371 373
372 vo_hdc = GetDC(vo_window);
373
374 myMonitorFromWindow = NULL; 374 myMonitorFromWindow = NULL;
375 myGetMonitorInfo = NULL; 375 myGetMonitorInfo = NULL;
376 myEnumDisplayMonitors = NULL; 376 myEnumDisplayMonitors = NULL;
377 user32 = GetModuleHandle("user32.dll"); 377 user32 = GetModuleHandle("user32.dll");
378 if (user32) { 378 if (user32) {