Index: libvo/vo_direct3d.c =================================================================== --- libvo/vo_direct3d.c (revision 28117) +++ libvo/vo_direct3d.c (working copy) @@ -73,8 +73,19 @@ priv->movie_src_fmt */ IDirect3DSurface9 *d3d_backbuf; /**< Video card's back buffer (used to display next frame) */ + int last_resize_ms; /**< Milliseconds at which the last resize + event occured. 0 if none. */ } *priv; +/* Don't recreate the rendering context immediately after a resize event, but + wait exactly VO_DIRECT3D_RESIZE_PERIOD milliseconds from the last resize + event. A new resize event before this this time has elapsed, resets the timer + for another VO_DIRECT3D_RESIZE_PERIOD milliseconds. Reason: recreating + the rendering context many times per second is quite expensive and we + should delay it until the window is not resized anymore. */ + +#define VO_DIRECT3D_RESIZE_PERIOD 100 + typedef struct { const unsigned int mplayer_fmt; /**< Given by MPlayer */ const D3DFORMAT fourcc; /**< Required by D3D's test function */ @@ -387,6 +398,15 @@ * if (mpi->flags & MP_IMGFLAG_DIRECT) ... */ + /* Check for a delayed resize event */ + if (WinID >=0 && priv->last_resize_ms) + { + if (GetTickCount() - priv->last_resize_ms > VO_DIRECT3D_RESIZE_PERIOD) { + resize_d3d(); + priv->last_resize_ms = 0; + } + } + if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) goto skip_upload; @@ -432,7 +452,7 @@ priv->d3d_backbuf, &priv->fs_movie_rect, D3DTEXF_LINEAR))) { - mp_msg(MSGT_VO, MSGL_ERR, + mp_msg(MSGT_VO, MSGL_V, "Unable to copy the frame to the back buffer\n"); return VO_ERROR; } @@ -696,8 +716,15 @@ * with the new window width/height. */ flags = vo_w32_check_events(); - if (flags & VO_EVENT_RESIZE) - resize_d3d(); + if (flags & VO_EVENT_RESIZE) { + /* Schedule a resize by saving current milliseconds. A real resize will be + performed when no new resize have been scheduled for at least + VO_DIRECT3D_RESIZE_PERIOD given in milliseconds. Valid for slave mode only. */ + if (WinID >= 0) + priv->last_resize_ms = GetTickCount(); + else + resize_d3d(); + } if ((flags & VO_EVENT_EXPOSE) && priv->is_paused) flip_page();