Index: libvo/vo_direct3d.c =================================================================== --- libvo/vo_direct3d.c (revision 28127) +++ libvo/vo_direct3d.c (working copy) @@ -202,14 +202,6 @@ mp_msg(MSGT_VO, MSGL_V, "destroy_d3d_surfaces called\r\n"); /* Let's destroy the old (if any) D3D Surfaces */ - if (priv->locked_rect.pBits) - IDirect3DSurface9_UnlockRect(priv->d3d_surface); - priv->locked_rect.pBits = NULL; - - if (priv->d3d_surface) - IDirect3DSurface9_Release(priv->d3d_surface); - priv->d3d_surface = NULL; - /* kill the OSD texture and its shadow copy */ if (priv->d3d_texture_osd) IDirect3DTexture9_Release(priv->d3d_texture_osd); @@ -218,10 +210,6 @@ if (priv->d3d_texture_system) IDirect3DTexture9_Release(priv->d3d_texture_system); priv->d3d_texture_system = NULL; - - if (priv->d3d_backbuf) - IDirect3DSurface9_Release(priv->d3d_backbuf); - priv->d3d_backbuf = NULL; } /** @brief Create D3D Offscreen and Backbuffer surfaces. @@ -233,21 +221,6 @@ int tex_width = osd_width, tex_height = osd_height; mp_msg(MSGT_VO, MSGL_V, "create_d3d_surfaces called.\n"); - if (FAILED(IDirect3DDevice9_CreateOffscreenPlainSurface( - priv->d3d_device, priv->src_width, priv->src_height, - priv->movie_src_fmt, D3DPOOL_DEFAULT, &priv->d3d_surface, NULL))) { - mp_msg(MSGT_VO, MSGL_ERR, - "IDirect3D9_CreateOffscreenPlainSurface Failed.\n"); - return 0; - } - - if (FAILED(IDirect3DDevice9_GetBackBuffer(priv->d3d_device, 0, 0, - D3DBACKBUFFER_TYPE_MONO, - &priv->d3d_backbuf))) { - mp_msg(MSGT_VO, MSGL_ERR, "Back Buffer address get failed\n"); - return 0; - } - /* calculate the best size for the OSD depending on the factors from the device */ if (priv->device_caps_power2_only) { tex_width = 1; @@ -332,8 +305,8 @@ present_params->SwapEffect = D3DSWAPEFFECT_COPY; present_params->Flags = D3DPRESENTFLAG_VIDEO; present_params->hDeviceWindow = vo_w32_window; /* w32_common var */ - present_params->BackBufferWidth = 0; /* Fill up window Width */ - present_params->BackBufferHeight = 0; /* Fill up window Height */ + present_params->BackBufferWidth = priv->max_texture_width; /* Fill up window Width */ + present_params->BackBufferHeight = priv->max_texture_height; /* Fill up window Height */ present_params->MultiSampleType = D3DMULTISAMPLE_NONE; /* D3DPRESENT_INTERVAL_ONE = vsync */ present_params->PresentationInterval = D3DPRESENT_INTERVAL_ONE; @@ -350,6 +323,7 @@ { D3DPRESENT_PARAMETERS present_params; D3DDISPLAYMODE disp_mode; + D3DVIEWPORT9 vp = {0, 0, vo_dwidth, vo_dheight, 0, 1}; mp_msg(MSGT_VO, MSGL_V, "configure_d3d called\n"); @@ -382,11 +356,27 @@ if (!create_d3d_surfaces()) return 0; - mp_msg(MSGT_VO, MSGL_V, - "New BackBuffer: Width: %d, Height:%d. VO Dest Width:%d, Height: %d\n", - present_params.BackBufferWidth, present_params.BackBufferHeight, - vo_dwidth, vo_dheight); + if (FAILED(IDirect3DDevice9_CreateOffscreenPlainSurface( + priv->d3d_device, priv->src_width, priv->src_height, + priv->movie_src_fmt, D3DPOOL_DEFAULT, &priv->d3d_surface, NULL))) { + mp_msg(MSGT_VO, MSGL_ERR, + "IDirect3D9_CreateOffscreenPlainSurface Failed.\n"); + return 0; + } + if (FAILED(IDirect3DDevice9_GetBackBuffer(priv->d3d_device, 0, 0, + D3DBACKBUFFER_TYPE_MONO, + &priv->d3d_backbuf))) { + mp_msg(MSGT_VO, MSGL_ERR, "Back Buffer address get failed\n"); + return 0; + } + + if (FAILED(IDirect3DDevice9_SetViewport(priv->d3d_device, + &vp))) { + mp_msg(MSGT_VO, MSGL_ERR, "Unable to set the viewport\n"); + return VO_ERROR; + } + calc_fs_rect(); return 1; @@ -400,6 +390,14 @@ { mp_msg(MSGT_VO, MSGL_V, "reconfigure_d3d called.\n"); + if (priv->locked_rect.pBits) + IDirect3DSurface9_UnlockRect(priv->d3d_surface); + priv->locked_rect.pBits = NULL; + + if (priv->d3d_surface) + IDirect3DSurface9_Release(priv->d3d_surface); + priv->d3d_surface = NULL; + /* Destroy the Offscreen and Backbuffer surfaces */ destroy_d3d_surfaces(); @@ -431,30 +429,21 @@ */ static int resize_d3d(void) { - D3DPRESENT_PARAMETERS present_params; + D3DVIEWPORT9 vp = {0, 0, vo_dwidth, vo_dheight, 0, 1}; mp_msg(MSGT_VO, MSGL_V, "resize_d3d called.\n"); + if (FAILED(IDirect3DDevice9_SetViewport(priv->d3d_device, + &vp))) { + mp_msg(MSGT_VO, MSGL_ERR, "Unable to set the viewport\n"); + return VO_ERROR; + } + destroy_d3d_surfaces(); - /* Reset the D3D Device with all parameters the same except the new - * width/height. - */ - fill_d3d_presentparams(&present_params); - if (FAILED(IDirect3DDevice9_Reset(priv->d3d_device, &present_params))) { - mp_msg(MSGT_VO, MSGL_ERR, - "Could not reset the D3D device\n"); - return 0; - } - if (!create_d3d_surfaces()) return 0; - mp_msg(MSGT_VO, MSGL_V, - "New BackBuffer: Width: %d, Height:%d. VO Dest Width:%d, Height: %d\n", - present_params.BackBufferWidth, present_params.BackBufferHeight, - vo_dwidth, vo_dheight); - calc_fs_rect(); #ifdef CONFIG_FREETYPE @@ -473,6 +462,18 @@ { mp_msg(MSGT_VO, MSGL_V, "uninit_d3d called\r\n"); + if (priv->locked_rect.pBits) + IDirect3DSurface9_UnlockRect(priv->d3d_surface); + priv->locked_rect.pBits = NULL; + + if (priv->d3d_surface) + IDirect3DSurface9_Release(priv->d3d_surface); + priv->d3d_surface = NULL; + + if (priv->d3d_backbuf) + IDirect3DSurface9_Release(priv->d3d_backbuf); + priv->d3d_backbuf = NULL; + destroy_d3d_surfaces(); /* Destroy the D3D Device */ @@ -787,7 +788,8 @@ */ static void flip_page(void) { - if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, 0, 0, 0, 0))) { + RECT rect = {0, 0, vo_dwidth, vo_dheight}; + if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) { mp_msg(MSGT_VO, MSGL_V, "Video adapter became uncooperative.\n"); mp_msg(MSGT_VO, MSGL_ERR, "Trying to reinitialize it...\n"); @@ -795,7 +797,7 @@ mp_msg(MSGT_VO, MSGL_V, "Reinitialization Failed.\n"); return; } - if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, 0, 0, 0, 0))) { + if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) { mp_msg(MSGT_VO, MSGL_V, "Reinitialization Failed.\n"); return; }