summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2011-11-01 03:11:46 +0100
committerwm4 <wm4@mplayer2.org>2012-03-17 20:58:16 +0100
commitcd713b4bebbb5a2e3200fa18790ad5b7ed3a6eb6 (patch)
tree70fc8c45fb40d37ec5154375b785e218d0f878ad
parent968cb269f36032e24a22753f3caa0cf77c36dfa6 (diff)
downloadmpv-cd713b4bebbb5a2e3200fa18790ad5b7ed3a6eb6.tar.bz2
mpv-cd713b4bebbb5a2e3200fa18790ad5b7ed3a6eb6.tar.xz
vo_direct3d: reduce number of lock calls in OSD rendering
The code locked the texture once for each OSD object that was rendered. But there doesn't seem to be any good reason to do that, so lock it only once during OSD rendering.
-rw-r--r--libvo/vo_direct3d.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index c48dabbac9..a1124f5412 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -1138,29 +1138,21 @@ static void vo_draw_alpha_l8a8(int w, int h, unsigned char* src,
}
}
+struct draw_osd_closure {
+ D3DLOCKED_RECT locked_rect;
+};
+
/** @brief Callback function to render the OSD to the texture
*/
-static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
- unsigned char *srca, int stride)
+static void draw_alpha(void *pctx, int x0, int y0, int w, int h,
+ unsigned char *src, unsigned char *srca, int stride)
{
- D3DLOCKED_RECT locked_rect; /**< Offscreen surface we lock in order
- to copy MPlayer's frame inside it.*/
-
- if (FAILED(IDirect3DTexture9_LockRect(priv->texture_osd.system, 0,
- &locked_rect, NULL, 0))) {
- mp_msg(MSGT_VO,MSGL_ERR,"<vo_direct3d>OSD texture lock failed.\n");
- return;
- }
+ struct draw_osd_closure *ctx = pctx;
+ D3DLOCKED_RECT locked_rect = ctx->locked_rect;
vo_draw_alpha_l8a8(w, h, src, srca, stride,
(unsigned char *)locked_rect.pBits + locked_rect.Pitch*y0 + 2*x0, locked_rect.Pitch);
- /* this unlock is used for both slice_draw path and D3DRenderFrame path */
- if (FAILED(IDirect3DTexture9_UnlockRect(priv->texture_osd.system, 0))) {
- mp_msg(MSGT_VO,MSGL_ERR,"<vo_direct3d>OSD texture unlock failed.\n");
- return;
- }
-
priv->is_osd_populated = 1;
}
@@ -1173,32 +1165,32 @@ static void draw_osd(void)
return;
if (vo_osd_changed(0)) {
- D3DLOCKED_RECT locked_rect; /**< Offscreen surface we lock in order
- to copy MPlayer's frame inside it.*/
+ struct draw_osd_closure ctx;
/* clear the OSD */
if (FAILED(IDirect3DTexture9_LockRect(priv->texture_osd.system, 0,
- &locked_rect, NULL, 0))) {
+ &ctx.locked_rect, NULL, 0))) {
mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>OSD texture lock failed.\n");
return;
}
/* clear the whole texture to avoid issues due to interpolation */
- memset(locked_rect.pBits, 0, locked_rect.Pitch * priv->texture_osd.tex_h);
-
- if (FAILED(IDirect3DTexture9_UnlockRect(priv->texture_osd.system, 0))) {
- mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>OSD texture unlock failed.\n");
- return;
- }
+ memset(ctx.locked_rect.pBits, 0,
+ ctx.locked_rect.Pitch * priv->texture_osd.tex_h);
priv->is_osd_populated = 0;
/* required for if subs are in the boarder region */
priv->is_clear_needed = 1;
- vo_draw_text_ext(priv->texture_osd.w, priv->texture_osd.h,
- priv->border_x, priv->border_y,
- priv->border_x, priv->border_y,
- priv->src_width, priv->src_height, draw_alpha);
+ osd_draw_text_ext(global_osd, priv->texture_osd.w, priv->texture_osd.h,
+ priv->border_x, priv->border_y,
+ priv->border_x, priv->border_y,
+ priv->src_width, priv->src_height, draw_alpha, &ctx);
+
+ if (FAILED(IDirect3DTexture9_UnlockRect(priv->texture_osd.system, 0))) {
+ mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>OSD texture unlock failed.\n");
+ return;
+ }
d3dtex_update(&priv->texture_osd);
}