[vlc-devel] [PATCH 4/9] direct3d9: handle external callbacks to render into an external surface
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jan 18 16:32:15 CET 2019
Instead of the device backbuffer.
---
modules/video_output/win32/direct3d9.c | 44 +++++++++++++++++++-------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 6e3bcb799e..00f4b03086 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -166,6 +166,8 @@ struct vout_display_sys_t
void (*endRenderCb)(void* opaque);
bool (*starRenderCb)(void* opaque);
bool (*resizeCb)(void* opaque, unsigned, unsigned);
+ void *(*startCb)(void* opaque);
+ void (*finishCb)(void* opaque);
};
/* */
@@ -1364,6 +1366,9 @@ static void Direct3D9Destroy(vout_display_sys_t *sys)
FreeLibrary(sys->hxdll);
sys->hxdll = NULL;
}
+
+ if ( sys->finishCb != NULL )
+ sys->finishCb( sys->outside_opaque );
}
/**
@@ -1642,7 +1647,34 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (!sys)
return VLC_ENOMEM;
- IDirect3DDevice9 *d3d9_device = var_InheritAddress(vd, "vout-engine-ctx");
+ sys->outside_opaque = var_InheritAddress(vd, "vout-cb-opaque");
+ sys->swapCb = var_InheritAddress(vd, "vout-cb-swap");
+ sys->starRenderCb = var_InheritAddress(vd, "vout-cb-start-render");
+ sys->endRenderCb = var_InheritAddress(vd, "vout-cb-end-render");
+ sys->resizeCb = var_InheritAddress(vd, "vout-cb-update-output");
+ sys->startCb = var_InheritAddress(vd, "vout-cb-setup");
+ sys->finishCb = var_InheritAddress(vd, "vout-cb-cleanup");
+
+ if (!sys->swapCb || !sys->starRenderCb || !sys->endRenderCb)
+ {
+ /* use our own callbacks, since there isn't any external ones */
+ sys->outside_opaque = vd;
+ sys->swapCb = Swap;
+ sys->starRenderCb = StartRendering;
+ sys->endRenderCb = EndRendering;
+ sys->resizeCb = NULL;
+ }
+
+ IDirect3DDevice9 *d3d9_device = NULL;
+ if ( sys->startCb != NULL )
+ {
+ d3d9_device = sys->startCb( sys->outside_opaque );
+ if ( d3d9_device == NULL)
+ {
+ free(sys);
+ return VLC_EGENERIC;
+ }
+ }
if (d3d9_device != NULL)
{
if (D3D9_CreateExternal(vd, &sys->hd3d, d3d9_device)) {
@@ -1657,16 +1689,6 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
return VLC_EGENERIC;
}
- if (!sys->swapCb || !sys->starRenderCb || !sys->endRenderCb)
- {
- /* use our own callbacks, since there isn't any external ones */
- sys->outside_opaque = vd;
- sys->swapCb = Swap;
- sys->starRenderCb = StartRendering;
- sys->endRenderCb = EndRendering;
- sys->resizeCb = NULL;
- }
-
sys->hxdll = Direct3D9LoadShaderLibrary();
if (!sys->hxdll)
msg_Warn(vd, "cannot load Direct3D9 Shader Library; HLSL pixel shading will be disabled.");
--
2.17.1
More information about the vlc-devel
mailing list