⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wingdi.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
        p_vout->p_sys->i_pic_pitch = gxdisplayprop.cbyPitch;        return VLC_EGENERIC;    }    else    {        GXDisplayProperties gxdisplayprop;        RECT display_rect, dest_rect;        uint8_t *p_dest, *p_src = p_pic->p->p_pixels;        video_rect.left = i_x; video_rect.top = i_y;        video_rect.right = i_x + i_width;        video_rect.bottom = i_y + i_height;        gxdisplayprop = GXGetDisplayProperties();        display_rect.left = 0; display_rect.top = 0;        display_rect.right = gxdisplayprop.cxWidth;        display_rect.bottom = gxdisplayprop.cyHeight;        if( !IntersectRect( &dest_rect, &video_rect, &display_rect ) )        {            return VLC_EGENERIC;        }#if 0        msg_Err( p_vout, "video (%d,%d,%d,%d) display (%d,%d,%d,%d) "                 "dest (%d,%d,%d,%d)",                 video_rect.left, video_rect.right,                 video_rect.top, video_rect.bottom,                 display_rect.left, display_rect.right,                 display_rect.top, display_rect.bottom,                 dest_rect.left, dest_rect.right,                 dest_rect.top, dest_rect.bottom );#endif        if( !(p_dest = GXBeginDraw()) )        {#if 0            msg_Err( p_vout, "GXBeginDraw error %d ", GetLastError() );#endif            return VLC_EGENERIC;        }        p_src += (dest_rect.left - video_rect.left) * gxdisplayprop.cbxPitch +            (dest_rect.top - video_rect.top) * p_pic->p->i_pitch;        p_dest += dest_rect.left * gxdisplayprop.cbxPitch +            dest_rect.top * gxdisplayprop.cbyPitch;        i_width = dest_rect.right - dest_rect.left;        i_height = dest_rect.bottom - dest_rect.top;        p_pic->p->p_pixels = p_dest;    }    return VLC_SUCCESS;}static int GAPIUnlockSurface( vout_thread_t *p_vout, picture_t *p_pic ){    GXEndDraw();    return VLC_SUCCESS;}static void DisplayGAPI( vout_thread_t *p_vout, picture_t *p_pic ){}#endif#undef rect_src#undef rect_src_clipped#undef rect_dest#undef rect_dest_clipped/***************************************************************************** * SetPalette: sets an 8 bpp palette *****************************************************************************/static void SetPalette( vout_thread_t *p_vout,                        uint16_t *red, uint16_t *green, uint16_t *blue ){    msg_Err( p_vout, "FIXME: SetPalette unimplemented" );}/***************************************************************************** * EventThread: Event handling thread *****************************************************************************/static void EventThread ( vlc_object_t *p_event ){    vout_thread_t *p_vout;    vlc_value_t   val;    int        i_style;    WNDCLASS   wc;    MSG        msg;    /* Initialisations */    var_Get( p_event, "p_vout", &val );    p_vout = (vout_thread_t *)val.p_address;    /* Register window class */    memset( &wc, 0, sizeof(wc) );    wc.style          = CS_HREDRAW | CS_VREDRAW;    wc.lpfnWndProc    = (WNDPROC)WndProc;    wc.cbClsExtra     = 0;    wc.cbWndExtra     = 0;    wc.hInstance      = GetModuleHandle(NULL);    wc.hIcon          = 0;    wc.hCursor        = LoadCursor(NULL, IDC_ARROW);    wc.hbrBackground  = (HBRUSH)GetStockObject( BLACK_BRUSH );    wc.lpszMenuName   = 0;    wc.lpszClassName  = _T("VLC WinGDI");    RegisterClass( &wc );    /* Register the video sub-window class */    wc.lpszClassName = _T("VLC WinGDI video"); wc.hIcon = 0;    RegisterClass(&wc);    /* Create output window */    p_vout->p_sys->hparent = (HWND)        vout_RequestWindow( p_vout, &p_vout->p_sys->i_window_x,                            &p_vout->p_sys->i_window_y,                            (unsigned int *)&p_vout->p_sys->i_window_width,                            (unsigned int *)&p_vout->p_sys->i_window_height );    if( p_vout->p_sys->hparent )        ShowWindow( p_vout->p_sys->hparent, SW_SHOW );    if( p_vout->p_sys->hparent )        i_style = WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD;    else        i_style = WS_OVERLAPPEDWINDOW|WS_SIZEBOX|WS_VISIBLE|WS_CLIPCHILDREN;    p_vout->p_sys->i_window_style = i_style;    p_vout->p_sys->hwnd =        CreateWindow( _T("VLC WinGDI"), _T(VOUT_TITLE), i_style,                      (p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT :                      p_vout->p_sys->i_window_x,   /* default X coordinate */                      (p_vout->p_sys->i_window_y < 0) ? CW_USEDEFAULT :                      p_vout->p_sys->i_window_y,   /* default Y coordinate */                      p_vout->p_sys->i_window_width,                      p_vout->p_sys->i_window_height + 10,                      p_vout->p_sys->hparent, NULL,                      GetModuleHandle(NULL), (LPVOID)p_vout );    if( !p_vout->p_sys->hwnd )    {        msg_Warn( p_vout, "couldn't create window" );        return;    }    msg_Warn( p_vout, "Created WinGDI window" );    if( p_vout->p_sys->hparent )    {        LONG i_style;        /* We don't want the window owner to overwrite our client area */        i_style = GetWindowLong( p_vout->p_sys->hparent, GWL_STYLE );        if( !(i_style & WS_CLIPCHILDREN) )            /* Hmmm, apparently this is a blocking call... */            SetWindowLong( p_vout->p_sys->hparent, GWL_STYLE,                           i_style | WS_CLIPCHILDREN );        /* Create our fullscreen window */        p_vout->p_sys->hfswnd =            CreateWindowEx( WS_EX_APPWINDOW, _T("VLC WinGDI"),                            _T(VOUT_TITLE),                            WS_NONAVDONEBUTTON|WS_CLIPCHILDREN,                            CW_USEDEFAULT, CW_USEDEFAULT,                            CW_USEDEFAULT, CW_USEDEFAULT,                            NULL, NULL, GetModuleHandle(NULL), (LPVOID)p_vout);    }    /* Display our window */    ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );    UpdateWindow( p_vout->p_sys->hwnd );    /* Create video sub-window */    p_vout->p_sys->hvideownd =        CreateWindow( _T("VLC WinGDI video"), _T(""),   /* window class */                    WS_CHILD | WS_VISIBLE,                   /* window style */                    CW_USEDEFAULT, CW_USEDEFAULT,     /* default coordinates */                    CW_USEDEFAULT, CW_USEDEFAULT,                    p_vout->p_sys->hwnd,                  /* parent window */                    NULL, GetModuleHandle(NULL),                    (LPVOID)p_vout );            /* send p_vout to WM_CREATE */    /* Initialize offscreen buffer */    InitBuffers( p_vout );    p_vout->pf_control = Control;    /* Tell the video output we're ready to receive data */    vlc_thread_ready( p_event );    while( !p_event->b_die && GetMessage( &msg, 0, 0, 0 ) )    {        /* Check if we are asked to exit */        if( p_event->b_die ) break;        switch( msg.message )        {        case WM_KEYDOWN:            switch( msg.wParam )            {            case VK_ESCAPE:                p_event->p_vlc->b_die = VLC_TRUE;                break;            }            TranslateMessage( &msg );            break;        case WM_CHAR:            switch( msg.wParam )            {            case 'q':            case 'Q':                p_event->p_vlc->b_die = VLC_TRUE;                break;            }            break;        default:            TranslateMessage( &msg );            DispatchMessage( &msg );            break;        }    }    msg_Dbg( p_vout, "CloseWindow" );#ifdef MODULE_NAME_IS_wingapi    GXCloseDisplay();#else    DeleteDC( p_vout->p_sys->off_dc );    DeleteObject( p_vout->p_sys->off_bitmap );#endif    DestroyWindow( p_vout->p_sys->hwnd );    if( p_vout->p_sys->hfswnd ) DestroyWindow( p_vout->p_sys->hfswnd );    if( p_vout->p_sys->hparent )        vout_ReleaseWindow( p_vout, (void *)p_vout->p_sys->hparent );}/***************************************************************************** * UpdateRects: update clipping rectangles ***************************************************************************** * This function is called when the window position or size are changed, and * its job is to update the source and destination RECTs used to display the * picture. *****************************************************************************/static void UpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force ){#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    int i_width, i_height, i_x, i_y;    RECT  rect;    POINT point;    /* Retrieve the window size */    GetClientRect( p_vout->p_sys->hwnd, &rect );    /* Retrieve the window position */    point.x = point.y = 0;    ClientToScreen( p_vout->p_sys->hwnd, &point );    /* If nothing changed, we can return */    if( !b_force         && p_vout->p_sys->i_window_width == rect.right         && p_vout->p_sys->i_window_height == rect.bottom         && p_vout->p_sys->i_window_x == point.x         && p_vout->p_sys->i_window_y == point.y )    {        return;    }    /* Update the window position and size */    p_vout->p_sys->i_window_x = point.x;    p_vout->p_sys->i_window_y = point.y;    p_vout->p_sys->i_window_width = rect.right;    p_vout->p_sys->i_window_height = rect.bottom;    vout_PlacePicture( p_vout, rect.right, rect.bottom,                       &i_x, &i_y, &i_width, &i_height );    if( p_vout->p_sys->hvideownd )        SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,                      i_x, i_y, i_width, i_height, 0 );    /* Destination image position and dimensions */    rect_dest.left = point.x + i_x;    rect_dest.right = rect_dest.left + i_width;    rect_dest.top = point.y + i_y;    rect_dest.bottom = rect_dest.top + i_height;    /* Clip the destination window */    if( !IntersectRect( &rect_dest_clipped, &rect_dest,                        &p_vout->p_sys->rect_display ) )    {        SetRectEmpty( &rect_src_clipped );        return;    }#if 0    msg_Dbg( p_vout, "image_dst_clipped coords: %i,%i,%i,%i",                     rect_dest_clipped.left, rect_dest_clipped.top,                     rect_dest_clipped.right, rect_dest_clipped.bottom );#endif    /* the 2 following lines are to fix a bug when clicking on the desktop */    if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||        (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )    {        SetRectEmpty( &rect_src_clipped );        return;    }    /* src image dimensions */    rect_src.left = 0;    rect_src.top = 0;    rect_src.right = p_vout->output.i_width;    rect_src.bottom = p_vout->output.i_height;    /* Clip the source image */    rect_src_clipped.left = (rect_dest_clipped.left - rect_dest.left) *      p_vout->output.i_width / (rect_dest.right - rect_dest.left);    rect_src_clipped.right = p_vout->output.i_width -      (rect_dest.right - rect_dest_clipped.right) * p_vout->output.i_width /      (rect_dest.right - rect_dest.left);    rect_src_clipped.top = (rect_dest_clipped.top - rect_dest.top) *      p_vout->output.i_height / (rect_dest.bottom - rect_dest.top);    rect_src_clipped.bottom = p_vout->output.i_height -      (rect_dest.bottom - rect_dest_clipped.bottom) * p_vout->output.i_height /      (rect_dest.bottom - rect_dest.top);#if 0    msg_Dbg( p_vout, "image_src_clipped coords: %i,%i,%i,%i",                     rect_src_clipped.left, rect_src_clipped.top,                     rect_src_clipped.right, rect_src_clipped.bottom );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -