summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-11-23 18:42:29 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-11-23 18:42:29 +0000
commitcc7e0dae7e0b0fef51da848cf728c5a4defcd310 (patch)
tree718cf55b79a85bb471fce3306dd6bd3656b753b2 /libvo
parent161092eb35730a37c2c867814b105b5b5f1079de (diff)
downloadmpv-cc7e0dae7e0b0fef51da848cf728c5a4defcd310.tar.bz2
mpv-cc7e0dae7e0b0fef51da848cf728c5a4defcd310.tar.xz
Lock/unlock surface only once even when drawing many slices.
Patch originally by Jim Hauxwell [james dattrax co.uk] git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28003 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_direct3d.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index d0b1ae4211..a2884010f6 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -162,6 +162,11 @@ static void destroy_d3d_context(void)
mp_msg(MSGT_VO,MSGL_V,"<vo_direct3d>destroy_d3d_context called\r\n");
/* Let's destroy the old (if any) D3D Content */
+ if (priv->locked_rect.pBits) {
+ IDirect3DSurface9_UnlockRect(priv->d3d_surface);
+ priv->locked_rect.pBits = NULL;
+ }
+
if (priv->d3d_surface != NULL) {
IDirect3DSurface9_Release (priv->d3d_surface);
priv->d3d_surface = NULL;
@@ -295,22 +300,26 @@ static uint32_t render_d3d_frame(mp_image_t *mpi)
goto skip_upload;
}
- /* If the previous if failed, we should draw a packed frame */
+ /* If we're here, then we should lock the rect and copy a packed frame */
+ if (!priv->locked_rect.pBits) {
if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface,
&priv->locked_rect, NULL, 0))) {
mp_msg(MSGT_VO,MSGL_ERR,"<vo_direct3d>Surface lock failure\n");
return VO_ERROR;
}
+ }
memcpy_pic(priv->locked_rect.pBits, mpi->planes[0], mpi->stride[0],
mpi->height, priv->locked_rect.Pitch, mpi->stride[0]);
+skip_upload:
+ /* This unlock is used for both slice_draw path and render_d3d_frame path. */
if (FAILED(IDirect3DSurface9_UnlockRect(priv->d3d_surface))) {
mp_msg(MSGT_VO,MSGL_V,"<vo_direct3d>Surface unlock failure\n");
return VO_ERROR;
}
+ priv->locked_rect.pBits = NULL;
-skip_upload:
if (FAILED(IDirect3DDevice9_BeginScene(priv->d3d_device))) {
mp_msg(MSGT_VO,MSGL_ERR,"<vo_direct3d>BeginScene failed\n");
return VO_ERROR;
@@ -596,11 +605,14 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y )
char *Dst; /**< Pointer to the destination image */
int UVstride; /**< Stride of the U/V planes */
+ /* Lock the offscreen surface if it's not already locked. */
+ if (!priv->locked_rect.pBits) {
if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface,
&priv->locked_rect, NULL, 0))) {
mp_msg(MSGT_VO,MSGL_V,"<vo_direct3d>Surface lock failure\n");
return VO_FALSE;
}
+ }
UVstride = priv->locked_rect.Pitch / 2;
@@ -634,11 +646,6 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y )
memcpy_pic(Dst, Src, w, h, UVstride, stride[2]);
- if (FAILED(IDirect3DSurface9_UnlockRect(priv->d3d_surface))) {
- mp_msg(MSGT_VO,MSGL_V,"<vo_direct3d>Surface unlock failure\n");
- return VO_ERROR;
- }
-
return 0; /* Success */
}