summaryrefslogtreecommitdiffstats
path: root/video/out/vo_direct3d.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vo_direct3d.c')
-rw-r--r--video/out/vo_direct3d.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index 02572a8c53..91e962faa1 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -80,12 +80,12 @@ struct d3dtex {
typedef struct d3d_priv {
struct mp_log *log;
- int opt_disable_texture_align;
+ bool opt_disable_texture_align;
// debugging
- int opt_force_power_of_2;
+ bool opt_force_power_of_2;
int opt_texture_memory;
- int opt_swap_discard;
- int opt_exact_backbuffer;
+ bool opt_swap_discard;
+ bool opt_exact_backbuffer;
struct vo *vo;
@@ -98,10 +98,11 @@ typedef struct d3d_priv {
RECT fs_panscan_rect; /**< PanScan source surface cropping in
fullscreen */
int src_width; /**< Source (movie) width */
- int src_height; /**< Source (movie) heigth */
+ int src_height; /**< Source (movie) height */
struct mp_osd_res osd_res;
int image_format; /**< mplayer image format */
struct mp_image_params params;
+ struct mp_image_params dst_params;
D3DFORMAT movie_src_fmt; /**< Movie colorspace format (depends on
the movie's codec) */
@@ -570,7 +571,7 @@ static bool change_d3d_backbuffer(d3d_priv *priv)
}
} else {
if (FAILED(IDirect3DDevice9_Reset(priv->d3d_device, &present_params))) {
- MP_ERR(priv, "Reseting Direct3D device failed.\n");
+ MP_ERR(priv, "Resetting Direct3D device failed.\n");
return 0;
}
}
@@ -850,9 +851,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
d3d_priv *priv = vo->priv;
switch (request) {
- case VOCTRL_REDRAW_FRAME:
- d3d_draw_frame(priv);
- return VO_TRUE;
case VOCTRL_SET_PANSCAN:
calc_fs_rect(priv);
priv->vo->want_redraw = true;
@@ -899,6 +897,18 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
if (!resize_d3d(priv))
return VO_ERROR;
+ priv->dst_params = *params;
+ for (const struct fmt_entry *cur = &fmt_table[0]; cur->mplayer_fmt; ++cur) {
+ if (cur->fourcc == priv->desktop_fmt) {
+ priv->dst_params.imgfmt = cur->mplayer_fmt;
+ break;
+ }
+ }
+ mp_image_params_guess_csp(&priv->dst_params);
+ mp_mutex_lock(&vo->params_mutex);
+ vo->target_params = &priv->dst_params;
+ mp_mutex_unlock(&vo->params_mutex);
+
return 0; /* Success */
}
@@ -993,27 +1003,27 @@ static bool get_video_buffer(d3d_priv *priv, struct mp_image *out)
return true;
}
-static void draw_image(struct vo *vo, mp_image_t *mpi)
+static void draw_frame(struct vo *vo, struct vo_frame *frame)
{
d3d_priv *priv = vo->priv;
if (!priv->d3d_device)
- goto done;
+ return;
struct mp_image buffer;
if (!get_video_buffer(priv, &buffer))
- goto done;
+ return;
+
+ if (!frame->current)
+ return;
- mp_image_copy(&buffer, mpi);
+ mp_image_copy(&buffer, frame->current);
d3d_unlock_video_objects(priv);
priv->have_image = true;
- priv->osd_pts = mpi->pts;
+ priv->osd_pts = frame->current->pts;
d3d_draw_frame(priv);
-
-done:
- talloc_free(mpi);
}
static mp_image_t *get_window_screenshot(d3d_priv *priv)
@@ -1081,8 +1091,7 @@ static mp_image_t *get_window_screenshot(d3d_priv *priv)
return image;
error_exit:
- if (image)
- talloc_free(image);
+ talloc_free(image);
if (surface)
IDirect3DSurface9_Release(surface);
return NULL;
@@ -1222,16 +1231,16 @@ static void draw_osd(struct vo *vo)
#define OPT_BASE_STRUCT d3d_priv
static const struct m_option opts[] = {
- {"force-power-of-2", OPT_FLAG(opt_force_power_of_2)},
- {"disable-texture-align", OPT_FLAG(opt_disable_texture_align)},
+ {"force-power-of-2", OPT_BOOL(opt_force_power_of_2)},
+ {"disable-texture-align", OPT_BOOL(opt_disable_texture_align)},
{"texture-memory", OPT_CHOICE(opt_texture_memory,
{"default", 0},
{"managed", 1},
{"default-pool", 2},
{"default-pool-shadow", 3},
{"scratch", 4})},
- {"swap-discard", OPT_FLAG(opt_swap_discard)},
- {"exact-backbuffer", OPT_FLAG(opt_exact_backbuffer)},
+ {"swap-discard", OPT_BOOL(opt_swap_discard)},
+ {"exact-backbuffer", OPT_BOOL(opt_exact_backbuffer)},
{0}
};
@@ -1242,7 +1251,7 @@ const struct vo_driver video_out_direct3d = {
.query_format = query_format,
.reconfig = reconfig,
.control = control,
- .draw_image = draw_image,
+ .draw_frame = draw_frame,
.flip_page = flip_page,
.uninit = uninit,
.priv_size = sizeof(d3d_priv),