[vlc-devel] [PATCH 2/8] direct3d11: use the libvlc rendering callbacks for the rendering
Steve Lhomme
robux4 at ycbcr.xyz
Thu May 9 16:28:01 CEST 2019
---
modules/video_output/win32/direct3d11.c | 44 ++++++++++++++++---------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 9eeb24f6b0..e7fbc9df8e 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -29,6 +29,12 @@
#include <vlc_plugin.h>
#include <vlc_vout_display.h>
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_picture.h>
+#include <vlc/libvlc_media.h>
+#include <vlc/libvlc_renderer_discoverer.h>
+#include <vlc/libvlc_media_player.h>
+
#include <assert.h>
#include <math.h>
@@ -52,7 +58,6 @@
#include "../../video_chroma/d3d11_fmt.h"
#include "d3d11_quad.h"
#include "d3d11_shaders.h"
-#include "d3d_render.h"
#include "common.h"
#include "../video_chroma/copy.h"
@@ -157,11 +162,11 @@ struct vout_display_sys_t
/* outside rendering */
void *outside_opaque;
- d3d_device_setup_cb setupDeviceCb;
- d3d_device_cleanup_cb cleanupDeviceCb;
- d3d_update_output_cb updateOutputCb;
- d3d_swap_cb swapCb;
- d3d_start_end_rendering_cb startEndRenderingCb;
+ libvlc_video_direct3d_device_setup_cb setupDeviceCb;
+ libvlc_video_direct3d_device_cleanup_cb cleanupDeviceCb;
+ libvlc_video_direct3d_update_output_cb updateOutputCb;
+ libvlc_video_swap_cb swapCb;
+ libvlc_video_direct3d_start_end_rendering_cb startEndRenderingCb;
};
static picture_pool_t *Pool(vout_display_t *, unsigned);
@@ -190,9 +195,9 @@ static void UpdatePicQuadPosition(vout_display_t *);
static int Control(vout_display_t *, int, va_list);
-static void SelectSwapchainColorspace(struct d3d11_local_swapchain *, const struct direct3d_cfg_t *);
+static void SelectSwapchainColorspace(struct d3d11_local_swapchain *, const libvlc_video_direct3d_cfg_t *);
-static int UpdateDisplayFormat(vout_display_t *vd, struct output_cfg_t *out,
+static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *out,
const video_format_t *input_fmt)
{
vout_display_sys_t *sys = vd->sys;
@@ -256,7 +261,7 @@ static int UpdateDisplayFormat(vout_display_t *vd, struct output_cfg_t *out,
static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
{
vout_display_sys_t *sys = vd->sys;
- struct direct3d_cfg_t cfg;
+ libvlc_video_direct3d_cfg_t cfg;
cfg.width = sys->area.vdcfg.display.width;
cfg.height = sys->area.vdcfg.display.height;
@@ -296,7 +301,7 @@ static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
cfg.colorspace = fmt->space;
cfg.transfer = fmt->transfer;
- struct output_cfg_t out;
+ libvlc_video_output_cfg_t out;
if (!sys->updateOutputCb( sys->outside_opaque, &cfg, &out ))
{
msg_Err(vd, "Failed to set format %dx%d %d bits on output", cfg.width, cfg.height, cfg.bitdepth);
@@ -407,7 +412,7 @@ static void CreateSwapchain(struct d3d11_local_swapchain *display, UINT width, U
}
#endif /* !VLC_WINSTORE_APP */
-static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const struct direct3d_cfg_t *cfg )
+static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc_video_direct3d_cfg_t *cfg )
{
ID3D11Texture2D* pBackBuffer;
HRESULT hr;
@@ -526,7 +531,7 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const struct
return true;
}
-static bool LocalSwapchainSetupDevice( void *opaque, const struct device_cfg_t *cfg, struct device_setup_t *out )
+static bool LocalSwapchainSetupDevice( void *opaque, const libvlc_video_direct3d_device_cfg_t *cfg, libvlc_video_direct3d_device_setup_t *out )
{
struct d3d11_local_swapchain *display = opaque;
HRESULT hr;
@@ -587,7 +592,7 @@ static void LocalSwapchainSwap( void *opaque )
}
}
-static bool LocalSwapchainUpdateOutput( void *opaque, const struct direct3d_cfg_t *cfg, struct output_cfg_t *out )
+static bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
{
struct d3d11_local_swapchain *display = opaque;
if ( !UpdateSwapchain( display, cfg ) )
@@ -635,6 +640,13 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (ret != VLC_SUCCESS)
return ret;
+ sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
+ sys->setupDeviceCb = var_InheritAddress( vd, "vout-cb-setup" );
+ sys->cleanupDeviceCb = var_InheritAddress( vd, "vout-cb-cleanup" );
+ sys->updateOutputCb = var_InheritAddress( vd, "vout-cb-update-output" );
+ sys->swapCb = var_InheritAddress( vd, "vout-cb-swap" );
+ sys->startEndRenderingCb = var_InheritAddress( vd, "vout-cb-make-current" );
+
bool uses_external_callbacks = true;
if (sys->swapCb == NULL || sys->startEndRenderingCb == NULL || sys->updateOutputCb == NULL)
{
@@ -1189,7 +1201,7 @@ static bool canHandleConversion(const dxgi_color_space *src, const dxgi_color_sp
}
#endif
-static void SelectSwapchainColorspace(struct d3d11_local_swapchain *display, const struct direct3d_cfg_t *cfg)
+static void SelectSwapchainColorspace(struct d3d11_local_swapchain *display, const libvlc_video_direct3d_cfg_t *cfg)
{
HRESULT hr;
int best = 0;
@@ -1324,10 +1336,10 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
vout_display_sys_t *sys = vd->sys;
HRESULT hr = E_FAIL;
- struct device_cfg_t cfg = {
+ libvlc_video_direct3d_device_cfg_t cfg = {
.hardware_decoding = is_d3d11_opaque( vd->source.i_chroma )
};
- struct device_setup_t out;
+ libvlc_video_direct3d_device_setup_t out;
ID3D11DeviceContext *d3d11_ctx = NULL;
if ( sys->setupDeviceCb( sys->outside_opaque, &cfg, &out ) )
d3d11_ctx = out.device_context;
--
2.17.1
More information about the vlc-devel
mailing list