📄 wingdi.c
字号:
static int Init( vout_thread_t *p_vout ){ picture_t *p_pic; p_vout->p_sys->rect_display.left = 0; p_vout->p_sys->rect_display.top = 0; p_vout->p_sys->rect_display.right = GetSystemMetrics(SM_CXSCREEN); p_vout->p_sys->rect_display.bottom = GetSystemMetrics(SM_CYSCREEN); p_vout->p_sys->b_video_display = VLC_TRUE; p_vout->p_sys->p_event->b_die = VLC_FALSE; I_OUTPUTPICTURES = 0; /* Initialize the output structure */ switch( p_vout->p_sys->i_depth ) { case 8: p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2'); p_vout->output.pf_setpalette = SetPalette; break; case 15: p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5'); p_vout->output.i_rmask = 0x7c00; p_vout->output.i_gmask = 0x03e0; p_vout->output.i_bmask = 0x001f; break; case 16: p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6'); p_vout->output.i_rmask = 0xf800; p_vout->output.i_gmask = 0x07e0; p_vout->output.i_bmask = 0x001f; break; case 24: p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4'); p_vout->output.i_rmask = 0x00ff0000; p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_bmask = 0x000000ff; break; case 32: p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2'); p_vout->output.i_rmask = 0x00ff0000; p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_bmask = 0x000000ff; break; default: msg_Err( p_vout, "screen depth %i not supported", p_vout->p_sys->i_depth ); return VLC_EGENERIC; break; } p_pic = &p_vout->p_picture[0];#ifdef MODULE_NAME_IS_wingapi p_vout->output.i_width = 0; p_vout->output.i_height = 0; p_pic->pf_lock = GAPILockSurface; p_pic->pf_unlock = GAPIUnlockSurface; Manage( p_vout ); GAPILockSurface( p_vout, p_pic ); p_vout->i_changes = 0; p_vout->output.i_width = p_vout->p_sys->render_width; p_vout->output.i_height = p_vout->p_sys->render_height;#else p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_height = p_vout->render.i_height; p_vout->fmt_out = p_vout->fmt_in; p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;#endif p_vout->output.i_aspect = p_vout->render.i_aspect; p_pic->p->p_pixels = p_vout->p_sys->p_pic_buffer; p_pic->p->i_lines = p_vout->output.i_height; p_pic->p->i_visible_lines = p_vout->output.i_height; p_pic->p->i_pitch = p_vout->p_sys->i_pic_pitch; p_pic->p->i_pixel_pitch = p_vout->p_sys->i_pic_pixel_pitch; p_pic->p->i_visible_pitch = p_vout->output.i_width * p_pic->p->i_pixel_pitch; p_pic->i_planes = 1; p_pic->i_status = DESTROYED_PICTURE; p_pic->i_type = DIRECT_PICTURE; PP_OUTPUTPICTURE[ I_OUTPUTPICTURES++ ] = p_pic; return VLC_SUCCESS;}/***************************************************************************** * End: terminate video thread output method *****************************************************************************/static void End( vout_thread_t *p_vout ){}/***************************************************************************** * Manage: handle events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/static int Manage( vout_thread_t *p_vout ){#ifndef UNDER_CE WINDOWPLACEMENT window_placement;#endif /* If we do not control our window, we check for geometry changes * ourselves because the parent might not send us its events. */ if( p_vout->p_sys->hparent && !p_vout->b_fullscreen ) { RECT rect_parent; POINT point; GetClientRect( p_vout->p_sys->hparent, &rect_parent ); point.x = point.y = 0; ClientToScreen( p_vout->p_sys->hparent, &point ); OffsetRect( &rect_parent, point.x, point.y ); if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) ) { int i_x, i_y, i_width, i_height; p_vout->p_sys->rect_parent = rect_parent; /* This one is to force the update even if only * the position has changed */ SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, 0 ); SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, 0 ); vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, &i_x, &i_y, &i_width, &i_height ); SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP, i_x, i_y, i_width, i_height, 0 ); } } /* We used to call the Win32 PeekMessage function here to read the window * messages. But since window can stay blocked into this function for a * long time (for example when you move your window on the screen), I * decided to isolate PeekMessage in another thread. */ /* * Fullscreen change */ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE ) { int i_style = 0; vlc_value_t val; HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ? p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd; p_vout->b_fullscreen = ! p_vout->b_fullscreen; /* We need to switch between Maximized and Normal sized window */#ifndef UNDER_CE window_placement.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement( hwnd, &window_placement );#endif if( p_vout->b_fullscreen ) {#ifndef UNDER_CE /* Change window style, no borders and no title bar */ int i_style = WS_CLIPCHILDREN | WS_VISIBLE; SetWindowLong( hwnd, GWL_STYLE, i_style ); if( p_vout->p_sys->hparent ) { /* Retrieve current window position so fullscreen will happen * on the right screen */ POINT point = {0,0}; RECT rect; ClientToScreen( p_vout->p_sys->hwnd, &point ); GetClientRect( p_vout->p_sys->hwnd, &rect ); SetWindowPos( hwnd, 0, point.x, point.y, rect.right, rect.bottom, SWP_NOZORDER|SWP_FRAMECHANGED ); GetWindowPlacement( hwnd, &window_placement ); } /* Maximize window */ window_placement.showCmd = SW_SHOWMAXIMIZED; SetWindowPlacement( hwnd, &window_placement ); SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);#endif if( p_vout->p_sys->hparent ) { RECT rect; GetClientRect( hwnd, &rect ); SetParent( p_vout->p_sys->hwnd, hwnd ); SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, rect.right, rect.bottom, SWP_NOZORDER|SWP_FRAMECHANGED ); } ShowWindow( hwnd, SW_SHOW ); SetForegroundWindow( hwnd ); } else { /* Change window style, no borders and no title bar */ //SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );#ifndef UNDER_CE /* Normal window */ window_placement.showCmd = SW_SHOWNORMAL; SetWindowPlacement( hwnd, &window_placement ); SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);#endif if( p_vout->p_sys->hparent ) { RECT rect; GetClientRect( p_vout->p_sys->hparent, &rect ); SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent ); SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, rect.right, rect.bottom, SWP_NOZORDER|SWP_FRAMECHANGED ); ShowWindow( hwnd, SW_HIDE ); SetForegroundWindow( p_vout->p_sys->hparent ); } /* Make sure the mouse cursor is displayed */ //PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 ); } /* Change window style, borders and title bar */ ShowWindow( p_vout->p_sys->hwnd, SW_SHOW ); UpdateWindow( p_vout->p_sys->hwnd ); /* Update the object variable and trigger callback */ val.b_bool = p_vout->b_fullscreen; var_Set( p_vout, "fullscreen", val ); p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE; } return VLC_SUCCESS;}/***************************************************************************** * Render: render previously calculated output *****************************************************************************/static void Render( vout_thread_t *p_vout, picture_t *p_pic ){ /* No need to do anything, the fake direct buffers stay as they are */}/***************************************************************************** * Display: displays previously rendered output *****************************************************************************/#define rect_src p_vout->p_sys->rect_src#define rect_src_clipped p_vout->p_sys->rect_src_clipped#define rect_dest p_vout->p_sys->rect_dest#define rect_dest_clipped p_vout->p_sys->rect_dest_clipped#ifndef MODULE_NAME_IS_wingapistatic void DisplayGDI( vout_thread_t *p_vout, picture_t *p_pic ){ vout_sys_t *p_sys = p_vout->p_sys; RECT rect_dst = rect_dest_clipped; HDC hdc = GetDC( p_sys->hvideownd ); OffsetRect( &rect_dst, -rect_dest.left, -rect_dest.top ); SelectObject( p_sys->off_dc, p_sys->off_bitmap ); if( rect_dest_clipped.right - rect_dest_clipped.left != rect_src_clipped.right - rect_src_clipped.left || rect_dest_clipped.bottom - rect_dest_clipped.top != rect_src_clipped.bottom - rect_src_clipped.top ) { StretchBlt( hdc, rect_dst.left, rect_dst.top, rect_dst.right, rect_dst.bottom, p_sys->off_dc, rect_src_clipped.left, rect_src_clipped.top, rect_src_clipped.right, rect_src_clipped.bottom, SRCCOPY ); } else { BitBlt( hdc, rect_dst.left, rect_dst.top, rect_dst.right, rect_dst.bottom, p_sys->off_dc, rect_src_clipped.left, rect_src_clipped.top, SRCCOPY ); } ReleaseDC( p_sys->hwnd, hdc );}#elsestatic int GAPILockSurface( vout_thread_t *p_vout, picture_t *p_pic ){ vout_sys_t *p_sys = p_vout->p_sys; int i_x, i_y, i_width, i_height; RECT video_rect; POINT point; /* Undo the display */ if( ( GetForegroundWindow() != GetParent(p_sys->hwnd) ) || ( p_sys->b_video_display == VLC_FALSE ) ) { //return VLC_EGENERIC; } GetClientRect( p_sys->hwnd, &video_rect); vout_PlacePicture( p_vout, video_rect.right - video_rect.left, video_rect.bottom - video_rect.top, &i_x, &i_y, &i_width, &i_height ); point.x = point.y = 0; ClientToScreen( p_sys->hwnd, &point ); i_x += point.x + video_rect.left; i_y += point.y + video_rect.top; if( i_width != p_vout->output.i_width || i_height != p_vout->output.i_height ) { GXDisplayProperties gxdisplayprop = GXGetDisplayProperties(); p_sys->render_width = i_width; p_sys->render_height = i_height; p_vout->i_changes |= VOUT_SIZE_CHANGE; msg_Dbg( p_vout, "vout size change (%ix%i -> %ix%i)", i_width, i_height, p_vout->output.i_width, p_vout->output.i_height ); p_vout->p_sys->i_pic_pixel_pitch = gxdisplayprop.cbxPitch;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -