Mercurial > mplayer.hg
comparison libvo/vo_directx.c @ 33569:8e70a224c411
Change vo_directx to use w32_common.c
While I tested it quite thoroughly, with and without
-wid, -vm, -fs, ... it is _very_ likely to break
something, please report any regressions!
In the worst case it can still be reverted, however
since it has very little relevance nowadays it will
rot all the faster if not at least some code is shared.
author | reimar |
---|---|
date | Sun, 19 Jun 2011 12:51:36 +0000 |
parents | ddb45e9443ec |
children | deedeb235cac |
comparison
equal
deleted
inserted
replaced
33568:276ab400eb1c | 33569:8e70a224c411 |
---|---|
38 #include "mp_msg.h" | 38 #include "mp_msg.h" |
39 #include "aspect.h" | 39 #include "aspect.h" |
40 #include "geometry.h" | 40 #include "geometry.h" |
41 #include "mp_fifo.h" | 41 #include "mp_fifo.h" |
42 #include "sub/sub.h" | 42 #include "sub/sub.h" |
43 #include "w32_common.h" | |
43 | 44 |
44 #ifdef CONFIG_GUI | 45 #ifdef CONFIG_GUI |
45 #include "gui/interface.h" | 46 #include "gui/interface.h" |
46 #endif | 47 #endif |
47 | 48 |
63 static LPDIRECTDRAWCLIPPER g_lpddclipper; //clipper object, can only be used without overlay | 64 static LPDIRECTDRAWCLIPPER g_lpddclipper; //clipper object, can only be used without overlay |
64 static DDSURFACEDESC2 ddsdsf; //surface descripiton needed for locking | 65 static DDSURFACEDESC2 ddsdsf; //surface descripiton needed for locking |
65 static HINSTANCE hddraw_dll; //handle to ddraw.dll | 66 static HINSTANCE hddraw_dll; //handle to ddraw.dll |
66 static RECT rd; //rect of our stretched image | 67 static RECT rd; //rect of our stretched image |
67 static RECT rs; //rect of our source image | 68 static RECT rs; //rect of our source image |
68 static HWND hWnd=NULL; //handle to the window | |
69 static HWND hWndFS=NULL; //fullscreen window | |
70 static HBRUSH colorbrush = NULL; // Handle to colorkey brush | 69 static HBRUSH colorbrush = NULL; // Handle to colorkey brush |
71 static HBRUSH blackbrush = NULL; // Handle to black brush | 70 static HBRUSH blackbrush = NULL; // Handle to black brush |
72 static HICON mplayericon = NULL; // Handle to mplayer icon | 71 static HICON mplayericon = NULL; // Handle to mplayer icon |
73 static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor | 72 static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor |
74 static uint32_t image_width, image_height; //image width and height | 73 static uint32_t image_width, image_height; //image width and height |
353 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>overlay surface released\n"); | 352 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>overlay surface released\n"); |
354 } | 353 } |
355 if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); | 354 if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); |
356 g_lpddsPrimary = NULL; | 355 g_lpddsPrimary = NULL; |
357 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>primary released\n"); | 356 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>primary released\n"); |
358 if(hWndFS)DestroyWindow(hWndFS); | |
359 hWndFS = NULL; | |
360 if((WinID == -1) && hWnd) DestroyWindow(hWnd); | |
361 hWnd = NULL; | |
362 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>window destroyed\n"); | |
363 UnregisterClass(WNDCLASSNAME_WINDOWED, GetModuleHandle(NULL)); | 357 UnregisterClass(WNDCLASSNAME_WINDOWED, GetModuleHandle(NULL)); |
364 UnregisterClass(WNDCLASSNAME_FULLSCREEN, GetModuleHandle(NULL)); | 358 UnregisterClass(WNDCLASSNAME_FULLSCREEN, GetModuleHandle(NULL)); |
365 if (mplayericon) DestroyIcon(mplayericon); | 359 if (mplayericon) DestroyIcon(mplayericon); |
366 mplayericon = NULL; | 360 mplayericon = NULL; |
367 if (mplayercursor) DestroyCursor(mplayercursor); | 361 if (mplayercursor) DestroyCursor(mplayercursor); |
368 mplayercursor = NULL; | 362 mplayercursor = NULL; |
369 if (blackbrush) DeleteObject(blackbrush); | |
370 blackbrush = NULL; | |
371 if (colorbrush) DeleteObject(colorbrush); | 363 if (colorbrush) DeleteObject(colorbrush); |
372 colorbrush = NULL; | 364 colorbrush = NULL; |
373 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>GDI resources deleted\n"); | 365 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>GDI resources deleted\n"); |
374 if (g_lpdd != NULL){ | 366 if (g_lpdd != NULL){ |
375 if(vidmode)g_lpdd->lpVtbl->RestoreDisplayMode(g_lpdd); | 367 if(vidmode)g_lpdd->lpVtbl->RestoreDisplayMode(g_lpdd); |
378 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>directdrawobject released\n"); | 370 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>directdrawobject released\n"); |
379 FreeLibrary( hddraw_dll); | 371 FreeLibrary( hddraw_dll); |
380 hddraw_dll= NULL; | 372 hddraw_dll= NULL; |
381 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>ddraw.dll freed\n"); | 373 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>ddraw.dll freed\n"); |
382 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>uninitialized\n"); | 374 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>uninitialized\n"); |
375 vo_w32_uninit(); | |
383 } | 376 } |
384 | 377 |
385 static BOOL WINAPI EnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) | 378 static BOOL WINAPI EnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) |
386 { | 379 { |
387 mp_msg(MSGT_VO, MSGL_INFO ,"<vo_directx> adapter %d: ", adapter_count); | 380 mp_msg(MSGT_VO, MSGL_INFO ,"<vo_directx> adapter %d: ", adapter_count); |
500 | 493 |
501 if(vo_dbpp)vm_bpp=vo_dbpp; | 494 if(vo_dbpp)vm_bpp=vo_dbpp; |
502 else vm_bpp=ddsd.ddpfPixelFormat.dwRGBBitCount; | 495 else vm_bpp=ddsd.ddpfPixelFormat.dwRGBBitCount; |
503 | 496 |
504 if(vidmode){ | 497 if(vidmode){ |
505 if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN) != DD_OK) | 498 if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, vo_w32_window, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN) != DD_OK) |
506 { | 499 { |
507 mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't set cooperativelevel for exclusive mode\n"); | 500 mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't set cooperativelevel for exclusive mode\n"); |
508 return 1; | 501 return 1; |
509 } | 502 } |
510 /*SetDisplayMode(ddobject,width,height,bpp,refreshrate,aditionalflags)*/ | 503 /*SetDisplayMode(ddobject,width,height,bpp,refreshrate,aditionalflags)*/ |
514 return 1; | 507 return 1; |
515 } | 508 } |
516 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><INFO>Initialized adapter %i for %i x %i @ %i \n",vo_adapter_num,vm_width,vm_height,vm_bpp); | 509 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><INFO>Initialized adapter %i for %i x %i @ %i \n",vo_adapter_num,vm_width,vm_height,vm_bpp); |
517 return 0; | 510 return 0; |
518 } | 511 } |
519 if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, hWnd, DDSCL_NORMAL) != DD_OK) // or DDSCL_SETFOCUSWINDOW | 512 if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, vo_w32_window, DDSCL_NORMAL) != DD_OK) // or DDSCL_SETFOCUSWINDOW |
520 { | 513 { |
521 mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>could not set cooperativelevel for hardwarecheck\n"); | 514 mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>could not set cooperativelevel for hardwarecheck\n"); |
522 return 1; | 515 return 1; |
523 } | 516 } |
524 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>DirectDraw Initialized\n"); | 517 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>DirectDraw Initialized\n"); |
525 return 0; | 518 return 0; |
526 } | 519 } |
527 | 520 |
521 static uint32_t Directx_ManageDisplay(void); | |
522 | |
528 static void check_events(void) | 523 static void check_events(void) |
529 { | 524 { |
530 MSG msg; | 525 int evt = vo_w32_check_events(); |
531 while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) | 526 if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE)) |
532 { | 527 Directx_ManageDisplay(); |
533 TranslateMessage(&msg); | 528 if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE | VO_EVENT_EXPOSE)) { |
534 DispatchMessage(&msg); | 529 HDC dc = vo_w32_get_dc(vo_w32_window); |
530 RECT r; | |
531 GetClientRect(vo_w32_window, &r); | |
532 FillRect(dc, &r, vo_fs || vidmode ? blackbrush : colorbrush); | |
533 vo_w32_release_dc(vo_w32_window, dc); | |
535 } | 534 } |
536 } | 535 } |
537 | 536 |
538 static uint32_t Directx_ManageDisplay(void) | 537 static uint32_t Directx_ManageDisplay(void) |
539 { | 538 { |
541 DDCAPS capsDrv; | 540 DDCAPS capsDrv; |
542 DDOVERLAYFX ovfx; | 541 DDOVERLAYFX ovfx; |
543 DWORD dwUpdateFlags=0; | 542 DWORD dwUpdateFlags=0; |
544 int width,height; | 543 int width,height; |
545 | 544 |
546 if(!vidmode && !vo_fs && WinID!=-1) { | 545 rd.left = vo_dx - xinerama_x; |
547 RECT current_rect = {0, 0, 0, 0}; | 546 rd.top = vo_dy - xinerama_y; |
548 GetWindowRect(hWnd, ¤t_rect); | 547 width = vo_dwidth; |
549 if ((current_rect.left == last_rect.left) | 548 height = vo_dheight; |
550 && (current_rect.top == last_rect.top) | 549 |
551 && (current_rect.right == last_rect.right) | 550 aspect(&width, &height, A_WINZOOM); |
552 && (current_rect.bottom == last_rect.bottom)) | 551 panscan_calc_windowed(); |
553 return 0; | 552 width += vo_panscan_x; |
554 last_rect = current_rect; | 553 height += vo_panscan_y; |
555 } | 554 width = FFMIN(width, vo_screenwidth); |
556 | 555 height = FFMIN(height, vo_screenheight); |
557 if(vo_fs || vidmode){ | 556 rd.left += (vo_dwidth - width ) / 2; |
558 aspect(&width,&height,A_ZOOM); | 557 rd.top += (vo_dheight - height) / 2; |
559 rd.left=(vo_screenwidth-width)/2; | 558 |
560 rd.top=(vo_screenheight-height)/2; | |
561 if (WinID == -1) | |
562 if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){} | |
563 } | |
564 else if (WinID != -1 && vo_geometry) { | |
565 POINT pt; | |
566 pt.x = vo_dx; | |
567 pt.y = vo_dy; | |
568 ClientToScreen(hWnd,&pt); | |
569 width=d_image_width; | |
570 height=d_image_height; | |
571 rd.left = pt.x; | |
572 rd.top = pt.y; | |
573 while(ShowCursor(TRUE)<=0){} | |
574 } | |
575 else { | |
576 POINT pt; | |
577 pt.x = 0; //overlayposition relative to the window | |
578 pt.y = 0; | |
579 ClientToScreen(hWnd,&pt); | |
580 GetClientRect(hWnd, &rd); | |
581 width=rd.right - rd.left; | |
582 height=rd.bottom - rd.top; | |
583 pt.x -= monitor_rect.left; /* move coordinates from global to local monitor space */ | |
584 pt.y -= monitor_rect.top; | |
585 rd.right -= monitor_rect.left; | |
586 rd.bottom -= monitor_rect.top; | |
587 rd.left = pt.x; | |
588 rd.top = pt.y; | |
589 if(!nooverlay && (!width || !height)){ | |
590 /*window is minimized*/ | |
591 ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay,NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL); | |
592 return 0; | |
593 } | |
594 if(vo_keepaspect){ | |
595 int tmpheight=((float)width/window_aspect); | |
596 tmpheight+=tmpheight%2; | |
597 if(tmpheight > height){ | |
598 width=((float)height*window_aspect); | |
599 width+=width%2; | |
600 } | |
601 else height=tmpheight; | |
602 } | |
603 if (WinID == -1) | |
604 while(ShowCursor(TRUE)<=0){} | |
605 } | |
606 rd.right=rd.left+width; | 559 rd.right=rd.left+width; |
607 rd.bottom=rd.top+height; | 560 rd.bottom=rd.top+height; |
608 | 561 |
609 /*ok, let's workaround some overlay limitations*/ | 562 /*ok, let's workaround some overlay limitations*/ |
610 if(!nooverlay) | 563 if(!nooverlay) |
685 if(capsDrv.dwCKeyCaps & DDCKEYCAPS_DESTOVERLAY) dwUpdateFlags |= DDOVER_KEYDESTOVERRIDE; | 638 if(capsDrv.dwCKeyCaps & DDCKEYCAPS_DESTOVERLAY) dwUpdateFlags |= DDOVER_KEYDESTOVERRIDE; |
686 else if (!tmp_image) vo_ontop = 1; | 639 else if (!tmp_image) vo_ontop = 1; |
687 } | 640 } |
688 else | 641 else |
689 { | 642 { |
690 g_lpddclipper->lpVtbl->SetHWnd(g_lpddclipper, 0,(vo_fs && !vidmode)?hWndFS: hWnd); | 643 g_lpddclipper->lpVtbl->SetHWnd(g_lpddclipper, 0, vo_w32_window); |
691 } | 644 } |
692 | |
693 if(!vidmode && !vo_fs){ | |
694 if(WinID == -1) { | |
695 RECT rdw=rd; | |
696 if (vo_border) | |
697 AdjustWindowRect(&rdw,WNDSTYLE,FALSE); | |
698 // printf("window: %i %i %ix%i\n",rdw.left,rdw.top,rdw.right - rdw.left,rdw.bottom - rdw.top); | |
699 rdw.left += monitor_rect.left; /* move to global coordinate space */ | |
700 rdw.top += monitor_rect.top; | |
701 rdw.right += monitor_rect.left; | |
702 rdw.bottom += monitor_rect.top; | |
703 SetWindowPos(hWnd,(vo_ontop)?HWND_TOPMOST:(vo_rootwin?HWND_BOTTOM:HWND_NOTOPMOST),rdw.left,rdw.top,rdw.right-rdw.left,rdw.bottom-rdw.top,SWP_NOOWNERZORDER); | |
704 } | |
705 } | |
706 else SetWindowPos(vidmode?hWnd:hWndFS,vo_rootwin?HWND_BOTTOM:HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER|SWP_NOCOPYBITS); | |
707 | 645 |
708 /*make sure the overlay is inside the screen*/ | 646 /*make sure the overlay is inside the screen*/ |
709 if(rd.left<0)rd.left=0; | 647 if(rd.left<0)rd.left=0; |
710 if(rd.right>vo_screenwidth)rd.right=vo_screenwidth; | 648 if(rd.right>vo_screenwidth)rd.right=vo_screenwidth; |
711 if(rd.top<0)rd.top=0; | 649 if(rd.top<0)rd.top=0; |
892 return 1; | 830 return 1; |
893 } | 831 } |
894 return 0; | 832 return 0; |
895 } | 833 } |
896 | 834 |
897 //function handles input | |
898 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
899 { | |
900 switch (message) | |
901 { | |
902 case WM_MOUSEACTIVATE: | |
903 return MA_ACTIVATEANDEAT; | |
904 case WM_NCACTIVATE: | |
905 { | |
906 if(vidmode && adapter_count > 2) //only disable if more than one adapter. | |
907 return 0; | |
908 break; | |
909 } | |
910 case WM_DESTROY: | |
911 { | |
912 PostQuitMessage(0); | |
913 return 0; | |
914 } | |
915 case WM_CLOSE: | |
916 { | |
917 mplayer_put_key(KEY_CLOSE_WIN); | |
918 return 0; | |
919 } | |
920 case WM_WINDOWPOSCHANGED: | |
921 { | |
922 //printf("Windowposchange\n"); | |
923 if(g_lpddsBack != NULL) //or it will crash with -vm | |
924 { | |
925 Directx_ManageDisplay(); | |
926 } | |
927 break; | |
928 } | |
929 case WM_SYSCOMMAND: | |
930 { | |
931 switch (wParam) | |
932 { //kill screensaver etc. | |
933 //note: works only when the window is active | |
934 //you can workaround this by disabling the allow screensaver option in | |
935 //the link to the app | |
936 case SC_SCREENSAVE: | |
937 case SC_MONITORPOWER: | |
938 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>killing screensaver\n" ); | |
939 return 0; | |
940 case SC_MAXIMIZE: | |
941 if (!vo_fs) control(VOCTRL_FULLSCREEN, NULL); | |
942 return 0; | |
943 } | |
944 break; | |
945 } | |
946 case WM_KEYDOWN: | |
947 { | |
948 switch (wParam) | |
949 { | |
950 case VK_LEFT: | |
951 {mplayer_put_key(KEY_LEFT);break;} | |
952 case VK_UP: | |
953 {mplayer_put_key(KEY_UP);break;} | |
954 case VK_RIGHT: | |
955 {mplayer_put_key(KEY_RIGHT);break;} | |
956 case VK_DOWN: | |
957 {mplayer_put_key(KEY_DOWN);break;} | |
958 case VK_TAB: | |
959 {mplayer_put_key(KEY_TAB);break;} | |
960 case VK_BACK: | |
961 {mplayer_put_key(KEY_BS);break;} | |
962 case VK_DELETE: | |
963 {mplayer_put_key(KEY_DELETE);break;} | |
964 case VK_INSERT: | |
965 {mplayer_put_key(KEY_INSERT);break;} | |
966 case VK_HOME: | |
967 {mplayer_put_key(KEY_HOME);break;} | |
968 case VK_END: | |
969 {mplayer_put_key(KEY_END);break;} | |
970 case VK_PRIOR: | |
971 {mplayer_put_key(KEY_PAGE_UP);break;} | |
972 case VK_NEXT: | |
973 {mplayer_put_key(KEY_PAGE_DOWN);break;} | |
974 case VK_ESCAPE: | |
975 {mplayer_put_key(KEY_ESC);break;} | |
976 } | |
977 break; | |
978 } | |
979 case WM_CHAR: | |
980 { | |
981 mplayer_put_key(wParam); | |
982 break; | |
983 } | |
984 case WM_LBUTTONDOWN: | |
985 { | |
986 if (!vo_nomouse_input) | |
987 mplayer_put_key(MOUSE_BTN0); | |
988 break; | |
989 } | |
990 case WM_MBUTTONDOWN: | |
991 { | |
992 if (!vo_nomouse_input) | |
993 mplayer_put_key(MOUSE_BTN1); | |
994 break; | |
995 } | |
996 case WM_RBUTTONDOWN: | |
997 { | |
998 if (!vo_nomouse_input) | |
999 mplayer_put_key(MOUSE_BTN2); | |
1000 break; | |
1001 } | |
1002 case WM_LBUTTONDBLCLK: | |
1003 { | |
1004 if(!vo_nomouse_input) | |
1005 mplayer_put_key(MOUSE_BTN0_DBL); | |
1006 break; | |
1007 } | |
1008 case WM_MBUTTONDBLCLK: | |
1009 { | |
1010 if(!vo_nomouse_input) | |
1011 mplayer_put_key(MOUSE_BTN1_DBL); | |
1012 break; | |
1013 } | |
1014 case WM_RBUTTONDBLCLK: | |
1015 { | |
1016 if(!vo_nomouse_input) | |
1017 mplayer_put_key(MOUSE_BTN2_DBL); | |
1018 break; | |
1019 } | |
1020 case WM_MOUSEWHEEL: | |
1021 { | |
1022 int x; | |
1023 if (vo_nomouse_input) | |
1024 break; | |
1025 x = GET_WHEEL_DELTA_WPARAM(wParam); | |
1026 if (x > 0) | |
1027 mplayer_put_key(MOUSE_BTN3); | |
1028 else | |
1029 mplayer_put_key(MOUSE_BTN4); | |
1030 break; | |
1031 } | |
1032 case WM_XBUTTONDOWN: | |
1033 { | |
1034 if (vo_nomouse_input) | |
1035 break; | |
1036 if (HIWORD(wParam) == 1) | |
1037 mplayer_put_key(MOUSE_BTN5); | |
1038 else | |
1039 mplayer_put_key(MOUSE_BTN6); | |
1040 break; | |
1041 } | |
1042 case WM_XBUTTONDBLCLK: | |
1043 { | |
1044 if (vo_nomouse_input) | |
1045 break; | |
1046 if (HIWORD(wParam) == 1) | |
1047 mplayer_put_key(MOUSE_BTN5_DBL); | |
1048 else | |
1049 mplayer_put_key(MOUSE_BTN6_DBL); | |
1050 break; | |
1051 } | |
1052 | |
1053 } | |
1054 return DefWindowProc(hWnd, message, wParam, lParam); | |
1055 } | |
1056 | |
1057 | |
1058 static int preinit(const char *arg) | 835 static int preinit(const char *arg) |
1059 { | 836 { |
1060 HINSTANCE hInstance = GetModuleHandle(NULL); | 837 HINSTANCE hInstance = GetModuleHandle(NULL); |
1061 char exedir[MAX_PATH]; | 838 char exedir[MAX_PATH]; |
1062 WNDCLASS wc; | |
1063 if(arg) | 839 if(arg) |
1064 { | 840 { |
1065 if(strstr(arg,"noaccel")) | 841 if(strstr(arg,"noaccel")) |
1066 { | 842 { |
1067 mp_msg(MSGT_VO,MSGL_V,"<vo_directx><INFO>disabled overlay\n"); | 843 mp_msg(MSGT_VO,MSGL_V,"<vo_directx><INFO>disabled overlay\n"); |
1079 monitor_rect.bottom=GetSystemMetrics(SM_CYSCREEN); | 855 monitor_rect.bottom=GetSystemMetrics(SM_CYSCREEN); |
1080 | 856 |
1081 windowcolor = vo_colorkey; | 857 windowcolor = vo_colorkey; |
1082 colorbrush = CreateSolidBrush(windowcolor); | 858 colorbrush = CreateSolidBrush(windowcolor); |
1083 blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); | 859 blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); |
1084 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | 860 if (!vo_w32_init()) |
1085 wc.lpfnWndProc = WndProc; | 861 return 1; |
1086 wc.cbClsExtra = 0; | 862 if (!vo_w32_config(100, 100, VOFLAG_HIDDEN)) |
1087 wc.cbWndExtra = 0; | 863 return 1; |
1088 wc.hInstance = hInstance; | |
1089 wc.hCursor = mplayercursor; | |
1090 wc.hIcon = mplayericon; | |
1091 wc.hbrBackground = vidmode ? blackbrush : colorbrush; | |
1092 wc.lpszClassName = WNDCLASSNAME_WINDOWED; | |
1093 wc.lpszMenuName = NULL; | |
1094 RegisterClass(&wc); | |
1095 if (WinID != -1) hWnd = WinID; | |
1096 else | |
1097 hWnd = CreateWindowEx(vidmode?WS_EX_TOPMOST:0, | |
1098 WNDCLASSNAME_WINDOWED,"",(vidmode || !vo_border)?WS_POPUP:WNDSTYLE, | |
1099 CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,NULL,NULL,hInstance,NULL); | |
1100 wc.hbrBackground = blackbrush; | |
1101 wc.lpszClassName = WNDCLASSNAME_FULLSCREEN; | |
1102 RegisterClass(&wc); | |
1103 | 864 |
1104 if (Directx_InitDirectDraw()!= 0)return 1; //init DirectDraw | 865 if (Directx_InitDirectDraw()!= 0)return 1; //init DirectDraw |
1105 | |
1106 if(!vidmode)hWndFS = CreateWindow(WNDCLASSNAME_FULLSCREEN,"MPlayer Fullscreen",WS_POPUP,monitor_rect.left,monitor_rect.top,monitor_rect.right-monitor_rect.left,monitor_rect.bottom-monitor_rect.top,hWnd,NULL,hInstance,NULL); | |
1107 mp_msg(MSGT_VO, MSGL_DBG3 ,"<vo_directx><INFO>initial mplayer windows created\n"); | |
1108 | 866 |
1109 if (Directx_CheckPrimaryPixelformat()!=0)return 1; | 867 if (Directx_CheckPrimaryPixelformat()!=0)return 1; |
1110 if (!nooverlay && Directx_CheckOverlayPixelformats() == 0) //check for supported hardware | 868 if (!nooverlay && Directx_CheckOverlayPixelformats() == 0) //check for supported hardware |
1111 { | 869 { |
1112 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>hardware supports overlay\n"); | 870 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>hardware supports overlay\n"); |
1244 uint32_t x = mpi->x; | 1002 uint32_t x = mpi->x; |
1245 uint32_t y = mpi->y; | 1003 uint32_t y = mpi->y; |
1246 uint32_t w = mpi->w; | 1004 uint32_t w = mpi->w; |
1247 uint32_t h = mpi->h; | 1005 uint32_t h = mpi->h; |
1248 | 1006 |
1249 if (WinID != -1) Directx_ManageDisplay(); | |
1250 | |
1251 if((mpi->flags&MP_IMGFLAG_DIRECT)||(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) | 1007 if((mpi->flags&MP_IMGFLAG_DIRECT)||(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) |
1252 { | 1008 { |
1253 mp_msg(MSGT_VO, MSGL_DBG3 ,"<vo_directx><INFO>put_image: nothing to do: drawslices\n"); | 1009 mp_msg(MSGT_VO, MSGL_DBG3 ,"<vo_directx><INFO>put_image: nothing to do: drawslices\n"); |
1254 return VO_TRUE; | 1010 return VO_TRUE; |
1255 } | 1011 } |
1283 } | 1039 } |
1284 | 1040 |
1285 static int | 1041 static int |
1286 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t options, char *title, uint32_t format) | 1042 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t options, char *title, uint32_t format) |
1287 { | 1043 { |
1288 RECT rd; | |
1289 vo_fs = options & 0x01; | |
1290 image_format = format; | 1044 image_format = format; |
1291 image_width = width; | 1045 image_width = width; |
1292 image_height = height; | 1046 image_height = height; |
1293 d_image_width = d_width; | 1047 d_image_width = d_width; |
1294 d_image_height = d_height; | 1048 d_image_height = d_height; |
1312 g_lpddsOverlay = NULL; | 1066 g_lpddsOverlay = NULL; |
1313 if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); | 1067 if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); |
1314 g_lpddsPrimary = NULL; | 1068 g_lpddsPrimary = NULL; |
1315 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>overlay surfaces released\n"); | 1069 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>overlay surfaces released\n"); |
1316 | 1070 |
1317 if(!vidmode){ | 1071 if (!vo_w32_config(d_width, d_height, options)) |
1318 if(!vo_geometry){ | 1072 return 1; |
1319 GetWindowRect(hWnd,&rd); | 1073 |
1320 vo_dx=rd.left; | |
1321 vo_dy=rd.top; | |
1322 } | |
1323 vo_dx += monitor_rect.left; /* move position to global window space */ | |
1324 vo_dy += monitor_rect.top; | |
1325 rd.left = vo_dx; | |
1326 rd.top = vo_dy; | |
1327 rd.right = rd.left + d_image_width; | |
1328 rd.bottom = rd.top + d_image_height; | |
1329 if (WinID == -1) { | |
1330 if (vo_border) | |
1331 AdjustWindowRect(&rd,WNDSTYLE,FALSE); | |
1332 SetWindowPos(hWnd,NULL, vo_dx, vo_dy,rd.right-rd.left,rd.bottom-rd.top,SWP_SHOWWINDOW|SWP_NOOWNERZORDER); | |
1333 } | |
1334 } | |
1335 else ShowWindow(hWnd,SW_SHOW); | |
1336 | |
1337 if(vo_fs && !vidmode)ShowWindow(hWndFS,SW_SHOW); | |
1338 if (WinID == -1) | 1074 if (WinID == -1) |
1339 SetWindowText(hWnd,title); | 1075 SetWindowText(vo_w32_window,title); |
1340 | |
1341 | |
1342 if(vidmode)vo_fs=0; | |
1343 | 1076 |
1344 | 1077 |
1345 /*create the surfaces*/ | 1078 /*create the surfaces*/ |
1346 if(Directx_CreatePrimarySurface())return 1; | 1079 if(Directx_CreatePrimarySurface())return 1; |
1347 | 1080 |
1379 } | 1112 } |
1380 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><INFO>back surface created\n"); | 1113 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><INFO>back surface created\n"); |
1381 vo_doublebuffering = 0; | 1114 vo_doublebuffering = 0; |
1382 /*create clipper for nonoverlay mode*/ | 1115 /*create clipper for nonoverlay mode*/ |
1383 if(g_lpdd->lpVtbl->CreateClipper(g_lpdd, 0, &g_lpddclipper,NULL)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't create clipper\n");return 1;} | 1116 if(g_lpdd->lpVtbl->CreateClipper(g_lpdd, 0, &g_lpddclipper,NULL)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't create clipper\n");return 1;} |
1384 if(g_lpddclipper->lpVtbl->SetHWnd (g_lpddclipper, 0, hWnd)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't associate clipper with window\n");return 1;} | 1117 if(g_lpddclipper->lpVtbl->SetHWnd (g_lpddclipper, 0, vo_w32_window)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't associate clipper with window\n");return 1;} |
1385 if(g_lpddsPrimary->lpVtbl->SetClipper (g_lpddsPrimary,g_lpddclipper)!=DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't associate primary surface with clipper\n");return 1;} | 1118 if(g_lpddsPrimary->lpVtbl->SetClipper (g_lpddsPrimary,g_lpddclipper)!=DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"<vo_directx><FATAL ERROR>can't associate primary surface with clipper\n");return 1;} |
1386 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>clipper succesfully created\n"); | 1119 mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx><INFO>clipper succesfully created\n"); |
1387 }else{ | 1120 }else{ |
1388 if(DD_OK != g_lpddsOverlay->lpVtbl->QueryInterface(g_lpddsOverlay,&IID_IDirectDrawColorControl,(void**)&g_cc)) | 1121 if(DD_OK != g_lpddsOverlay->lpVtbl->QueryInterface(g_lpddsOverlay,&IID_IDirectDrawColorControl,(void**)&g_cc)) |
1389 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><WARN>unable to get DirectDraw ColorControl interface\n"); | 1122 mp_msg(MSGT_VO, MSGL_V,"<vo_directx><WARN>unable to get DirectDraw ColorControl interface\n"); |
1485 last_rect.left = 0xDEADC0DE; // reset window position cache | 1218 last_rect.left = 0xDEADC0DE; // reset window position cache |
1486 return query_format(*((uint32_t*)data)); | 1219 return query_format(*((uint32_t*)data)); |
1487 case VOCTRL_DRAW_IMAGE: | 1220 case VOCTRL_DRAW_IMAGE: |
1488 return put_image(data); | 1221 return put_image(data); |
1489 case VOCTRL_BORDER: | 1222 case VOCTRL_BORDER: |
1490 if(WinID != -1) return VO_TRUE; | 1223 vo_w32_border(); |
1491 if(vidmode) | 1224 Directx_ManageDisplay(); |
1492 { | |
1493 mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>border has no meaning in exclusive mode\n"); | |
1494 } | |
1495 else | |
1496 { | |
1497 if(vo_border) { | |
1498 vo_border = 0; | |
1499 SetWindowLong(hWnd, GWL_STYLE, WS_POPUP); | |
1500 } else { | |
1501 vo_border = 1; | |
1502 SetWindowLong(hWnd, GWL_STYLE, WNDSTYLE); | |
1503 } | |
1504 // needed AFAICT to force the window to | |
1505 // redisplay with the new style. --Joey | |
1506 if (!vo_fs) { | |
1507 ShowWindow(hWnd,SW_HIDE); | |
1508 ShowWindow(hWnd,SW_SHOW); | |
1509 } | |
1510 last_rect.left = 0xDEADC0DE; // reset window position cache | |
1511 Directx_ManageDisplay(); | |
1512 } | |
1513 return VO_TRUE; | 1225 return VO_TRUE; |
1514 case VOCTRL_ONTOP: | 1226 case VOCTRL_ONTOP: |
1515 if(WinID != -1) return VO_TRUE; | 1227 vo_w32_ontop(); |
1516 if(vidmode) | |
1517 { | |
1518 mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>ontop has no meaning in exclusive mode\n"); | |
1519 } | |
1520 else | |
1521 { | |
1522 if(vo_ontop) vo_ontop = 0; | |
1523 else vo_ontop = 1; | |
1524 last_rect.left = 0xDEADC0DE; // reset window position cache | |
1525 Directx_ManageDisplay(); | |
1526 } | |
1527 return VO_TRUE; | 1228 return VO_TRUE; |
1528 case VOCTRL_ROOTWIN: | 1229 case VOCTRL_ROOTWIN: |
1529 if(WinID != -1) return VO_TRUE; | 1230 if(WinID != -1) return VO_TRUE; |
1530 if(vidmode) | 1231 if(vidmode) |
1531 { | 1232 { |
1539 Directx_ManageDisplay(); | 1240 Directx_ManageDisplay(); |
1540 } | 1241 } |
1541 return VO_TRUE; | 1242 return VO_TRUE; |
1542 case VOCTRL_FULLSCREEN: | 1243 case VOCTRL_FULLSCREEN: |
1543 { | 1244 { |
1544 if(vidmode) | 1245 vo_w32_fullscreen(); |
1545 { | 1246 Directx_ManageDisplay(); |
1546 mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>currently we do not allow to switch from exclusive to windowed mode\n"); | |
1547 } | |
1548 else | |
1549 { | |
1550 if(!vo_fs) | |
1551 { | |
1552 vo_fs=1; | |
1553 ShowWindow(hWndFS,SW_SHOW); | |
1554 ShowWindow(hWnd,SW_HIDE); | |
1555 SetForegroundWindow(hWndFS); | |
1556 } | |
1557 else | |
1558 { | |
1559 vo_fs=0; | |
1560 ShowWindow(hWndFS,SW_HIDE); | |
1561 ShowWindow(hWnd,SW_SHOW); | |
1562 } | |
1563 last_rect.left = 0xDEADC0DE; // reset window position cache | |
1564 Directx_ManageDisplay(); | |
1565 break; | |
1566 } | |
1567 return VO_TRUE; | 1247 return VO_TRUE; |
1568 } | 1248 } |
1569 case VOCTRL_SET_EQUALIZER: { | 1249 case VOCTRL_SET_EQUALIZER: { |
1570 vf_equalizer_t *eq=data; | 1250 vf_equalizer_t *eq=data; |
1571 return color_ctrl_set(eq->item, eq->value); | 1251 return color_ctrl_set(eq->item, eq->value); |
1573 case VOCTRL_GET_EQUALIZER: { | 1253 case VOCTRL_GET_EQUALIZER: { |
1574 vf_equalizer_t *eq=data; | 1254 vf_equalizer_t *eq=data; |
1575 return color_ctrl_get(eq->item, &eq->value); | 1255 return color_ctrl_get(eq->item, &eq->value); |
1576 } | 1256 } |
1577 case VOCTRL_UPDATE_SCREENINFO: | 1257 case VOCTRL_UPDATE_SCREENINFO: |
1578 if (vidmode) { | 1258 w32_update_xinerama_info(); |
1579 vo_screenwidth = vm_width; | |
1580 vo_screenheight = vm_height; | |
1581 } else { | |
1582 vo_screenwidth = monitor_rect.right - monitor_rect.left; | |
1583 vo_screenheight = monitor_rect.bottom - monitor_rect.top; | |
1584 } | |
1585 aspect_save_screenres(vo_screenwidth, vo_screenheight); | |
1586 return VO_TRUE; | 1259 return VO_TRUE; |
1587 case VOCTRL_RESET: | 1260 case VOCTRL_RESET: |
1588 last_rect.left = 0xDEADC0DE; // reset window position cache | 1261 last_rect.left = 0xDEADC0DE; // reset window position cache |
1589 // fall-through intended | 1262 // fall-through intended |
1590 }; | 1263 }; |