# HG changeset patch # User reimar # Date 1227464036 0 # Node ID ad71ce76c6ceeab9c26155b2dde5c1fe6cd7a431 # Parent 2a7bdb921eee0dbd0aec6726f6a23671aeba85fc Move the StretchRect call from draw_slices to render_d3d_frame. This avoids calling it (and BeginScene/EndScene) many times with slices and also avoids code duplication. diff -r 2a7bdb921eee -r ad71ce76c6ce libvo/vo_direct3d.c --- a/libvo/vo_direct3d.c Sun Nov 23 17:25:46 2008 +0000 +++ b/libvo/vo_direct3d.c Sun Nov 23 18:13:56 2008 +0000 @@ -290,19 +290,14 @@ */ if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) - return VO_TRUE; + goto skip_upload; if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Copy a planar frame. */ draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,0,0); - return VO_TRUE; + goto skip_upload; } /* If the previous if failed, we should draw a packed frame */ - if (FAILED(IDirect3DDevice9_BeginScene(priv->d3d_device))) { - mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); - return VO_ERROR; - } - if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface, &locked_rect, NULL, 0))) { mp_msg(MSGT_VO,MSGL_ERR,"Surface lock failure\n"); @@ -317,6 +312,12 @@ return VO_ERROR; } +skip_upload: + if (FAILED(IDirect3DDevice9_BeginScene(priv->d3d_device))) { + mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); + return VO_ERROR; + } + if (FAILED(IDirect3DDevice9_StretchRect(priv->d3d_device, priv->d3d_surface, &priv->fs_panscan_rect, @@ -599,11 +600,6 @@ char *Dst; /**< Pointer to the destination image */ int UVstride; /**< Stride of the U/V planes */ - if (FAILED(IDirect3DDevice9_BeginScene(priv->d3d_device))) { - mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); - return VO_ERROR; - } - if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface, &locked_rect, NULL, 0))) { mp_msg(MSGT_VO,MSGL_V,"Surface lock failure\n"); @@ -647,22 +643,6 @@ return VO_ERROR; } - if (FAILED(IDirect3DDevice9_StretchRect(priv->d3d_device, - priv->d3d_surface, - &priv->fs_panscan_rect, - priv->d3d_backbuf, - &priv->fs_movie_rect, - D3DTEXF_LINEAR))) { - mp_msg(MSGT_VO,MSGL_V, - "Unable to copy the frame to the back buffer\n"); - return VO_ERROR; - } - - if (FAILED(IDirect3DDevice9_EndScene(priv->d3d_device))) { - mp_msg(MSGT_VO,MSGL_ERR,"EndScene failed\n"); - return VO_ERROR; - } - return 0; /* Success */ }