[vlc-devel] [PATCH 05/24] vout: win32: refactor for next changes
Thomas Guillem
thomas at gllm.fr
Wed Oct 31 17:50:00 CET 2018
vd->fmt and vd->cfg will be removed.
fmt and cfg will be passed by Open() and controls.
---
modules/video_output/win32/common.c | 46 ++++++++-----------
modules/video_output/win32/common.h | 5 +-
modules/video_output/win32/direct3d11.c | 38 +++++++--------
modules/video_output/win32/direct3d9.c | 61 ++++++++++++++-----------
modules/video_output/win32/directdraw.c | 22 ++++++---
modules/video_output/win32/events.c | 21 +++++----
modules/video_output/win32/events.h | 2 +-
modules/video_output/win32/glwin32.c | 12 +++--
modules/video_output/win32/wingdi.c | 10 ++--
9 files changed, 115 insertions(+), 102 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index eb2c08a54c..c192035646 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -58,16 +58,17 @@ static bool GetRect(const vout_display_sys_t *sys, RECT *out)
static unsigned int GetPictureWidth(const vout_display_t *vd)
{
- return vd->fmt.i_width;
+ return vd->source.i_width;
}
static unsigned int GetPictureHeight(const vout_display_t *vd)
{
- return vd->fmt.i_height;
+ return vd->source.i_height;
}
/* */
-int CommonInit(vout_display_t *vd)
+int CommonInit(vout_display_t *vd, const vout_display_cfg_t *vdcfg,
+ const video_format_t *fmt)
{
vout_display_sys_t *sys = vd->sys;
@@ -90,7 +91,7 @@ int CommonInit(vout_display_t *vd)
var_Create(vd, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
/* */
- sys->event = EventThreadCreate(vd);
+ sys->event = EventThreadCreate(vd, vdcfg);
if (!sys->event)
return VLC_EGENERIC;
#endif
@@ -106,8 +107,9 @@ int CommonInit(vout_display_t *vd)
#endif
cfg.x = var_InheritInteger(vd, "video-x");
cfg.y = var_InheritInteger(vd, "video-y");
- cfg.width = vd->cfg->display.width;
- cfg.height = vd->cfg->display.height;
+ cfg.width = vdcfg->display.width;
+ cfg.height = vdcfg->display.height;
+ sys->vdcfg = *vdcfg;
event_hwnd_t hwnd;
if (EventThreadStart(sys->event, &hwnd, &cfg))
@@ -119,7 +121,7 @@ int CommonInit(vout_display_t *vd)
sys->hvideownd = hwnd.hvideownd;
sys->hfswnd = hwnd.hfswnd;
- if (vd->cfg->is_fullscreen) {
+ if (vdcfg->is_fullscreen) {
if (CommonControlSetFullscreen(vd, true))
vout_display_SendEventFullscreen(vd, false);
}
@@ -140,7 +142,6 @@ int CommonInit(vout_display_t *vd)
* picture.
*****************************************************************************/
void UpdateRects(vout_display_t *vd,
- const vout_display_cfg_t *cfg,
bool is_forced)
{
vout_display_sys_t *sys = vd->sys;
@@ -154,8 +155,7 @@ void UpdateRects(vout_display_t *vd,
POINT point;
/* */
- if (!cfg)
- cfg = vd->cfg;
+ const vout_display_cfg_t *cfg = &sys->vdcfg;
/* Retrieve the window size */
if (!sys->pf_GetRect(sys, &rect))
@@ -175,10 +175,6 @@ void UpdateRects(vout_display_t *vd,
is_resized = rect.right != (sys->rect_display.right - sys->rect_display.left) ||
rect.bottom != (sys->rect_display.bottom - sys->rect_display.top);
sys->rect_display = rect;
-#if 0 /* this may still be needed */
- if (is_resized)
- vout_display_SendEventDisplaySize(vd, rect.right, rect.bottom);
-#endif
#else
EventThreadUpdateWindowPosition(sys->event, &has_moved, &is_resized,
point.x, point.y,
@@ -387,13 +383,13 @@ void CommonManage(vout_display_t *vd)
rect_parent.bottom - rect_parent.top,
SWP_NOZORDER);
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
}
}
/* HasMoved means here resize or move */
if (EventThreadGetAndResetHasMoved(sys->event))
- UpdateRects(vd, NULL, false);
+ UpdateRects(vd, false);
}
/**
@@ -591,7 +587,7 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
#else
void CommonManage(vout_display_t *vd) {
- UpdateRects(vd, NULL, false);
+ UpdateRects(vd, false);
}
void CommonClean(vout_display_t *vd) {}
void CommonDisplay(vout_display_t *vd) {}
@@ -607,15 +603,10 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
case VOUT_DISPLAY_CHANGE_ZOOM: /* const vout_display_cfg_t *p_cfg */
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
case VOUT_DISPLAY_CHANGE_SOURCE_CROP: {
- const vout_display_cfg_t *cfg;
+ const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
- if (query == VOUT_DISPLAY_CHANGE_SOURCE_CROP ||
- query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT) {
- cfg = vd->cfg;
- } else {
- cfg = va_arg(args, const vout_display_cfg_t *);
- }
- UpdateRects(vd, cfg, true);
+ sys->vdcfg = *cfg;
+ UpdateRects(vd, true);
return VLC_SUCCESS;
}
#if !VLC_WINSTORE_APP
@@ -635,7 +626,8 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
rect_window.right - rect_window.left,
rect_window.bottom - rect_window.top, SWP_NOMOVE);
}
- UpdateRects(vd, cfg, false);
+ sys->vdcfg = *cfg;
+ UpdateRects(vd, false);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_WINDOW_STATE: { /* unsigned state */
@@ -661,7 +653,7 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
bool fs = va_arg(args, int);
if (CommonControlSetFullscreen(vd, fs))
return VLC_EGENERIC;
- UpdateRects(vd, NULL, false);
+ UpdateRects(vd, false);
return VLC_SUCCESS;
}
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 17d7275c2a..5baa499b63 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -69,6 +69,7 @@ typedef struct vout_display_sys_win32_t
RECT rect_dest_clipped;
picture_pool_t *pool;
+ vout_display_cfg_t vdcfg;
bool use_desktop; /* show video on desktop window ? */
@@ -88,7 +89,8 @@ typedef struct vout_display_sys_win32_t
/*****************************************************************************
* Prototypes from common.c
*****************************************************************************/
-int CommonInit(vout_display_t *);
+int CommonInit(vout_display_t *, const vout_display_cfg_t *vdcfg,
+ const video_format_t *fmt);
void CommonClean(vout_display_t *);
void CommonManage(vout_display_t *);
int CommonControl(vout_display_t *, int , va_list );
@@ -96,7 +98,6 @@ void CommonDisplay(vout_display_t *);
int CommonUpdatePicture(picture_t *, picture_t **fallback, uint8_t *plane, unsigned pitch);
void UpdateRects (vout_display_t *,
- const vout_display_cfg_t *,
bool is_forced);
void AlignRect(RECT *, int align_boundary, int align_size);
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 1a708e613e..f49737854d 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -127,7 +127,7 @@ static void Display(vout_display_t *, picture_t *);
static void Direct3D11Destroy(vout_display_t *);
-static int Direct3D11Open (vout_display_t *);
+static int Direct3D11Open (vout_display_t *, video_format_t *fmtp);
static void Direct3D11Close(vout_display_t *);
static int SetupOutputFormat(vout_display_t *, video_format_t *);
@@ -253,6 +253,8 @@ static unsigned int GetPictureHeight(const vout_display_t *vd)
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ const vout_display_cfg_t *cfg = vd->cfg;
+ video_format_t *fmtp = &vd->fmt;
#if !VLC_WINSTORE_APP
/* Allow using D3D11 automatically starting from Windows 8.1 */
@@ -276,7 +278,7 @@ static int Open(vlc_object_t *object)
if (ret != VLC_SUCCESS)
return ret;
- if (CommonInit(vd))
+ if (CommonInit(vd, cfg, fmtp))
goto error;
#if VLC_WINSTORE_APP
@@ -285,7 +287,7 @@ static int Open(vlc_object_t *object)
vd->sys->sys.pf_GetPictureWidth = GetPictureWidth;
vd->sys->sys.pf_GetPictureHeight = GetPictureHeight;
- if (Direct3D11Open(vd)) {
+ if (Direct3D11Open(vd, fmtp)) {
msg_Err(vd, "Direct3D11 could not be opened");
goto error;
}
@@ -359,14 +361,14 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
}
if (D3D11_SetupQuad( vd, &sys->d3d_dev, &surface_fmt, &sys->picQuad, &sys->display, &sys->sys.rect_src_clipped,
- vd->fmt.orientation ) != VLC_SUCCESS) {
+ vd->source.orientation ) != VLC_SUCCESS) {
msg_Err(vd, "Could not Create the main quad picture.");
return NULL;
}
- if ( vd->fmt.projection_mode == PROJECTION_MODE_EQUIRECTANGULAR ||
- vd->fmt.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD )
- SetQuadVSProjection( vd, &sys->picQuad, &vd->cfg->viewpoint );
+ if ( vd->source.projection_mode == PROJECTION_MODE_EQUIRECTANGULAR ||
+ vd->source.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD )
+ SetQuadVSProjection( vd, &sys->picQuad, &sys->sys.vdcfg.viewpoint );
if (!vd->info.is_slow) {
HRESULT hr;
@@ -694,6 +696,7 @@ static float UpdateZ(float f_fovx, float f_fovy)
static void SetQuadVSProjection(vout_display_t *vd, d3d_quad_t *quad, const vlc_viewpoint_t *p_vp)
{
+ vout_display_sys_t *sys = vd->sys;
if (!quad->pVertexShaderConstants)
return;
@@ -703,14 +706,13 @@ static void SetQuadVSProjection(vout_display_t *vd, d3d_quad_t *quad, const vlc_
f_fovx < -0.001f )
return;
- float f_sar = (float) vd->cfg->display.width / vd->cfg->display.height;
+ float f_sar = (float) sys->sys.vdcfg.display.width / sys->sys.vdcfg.display.height;
float f_teta = RAD(p_vp->yaw) - (float) M_PI_2;
float f_phi = RAD(p_vp->pitch);
float f_roll = RAD(p_vp->roll);
float f_fovy = UpdateFOVy(f_fovx, f_sar);
float f_z = UpdateZ(f_fovx, f_fovy);
- vout_display_sys_t *sys = vd->sys;
HRESULT hr;
D3D11_MAPPED_SUBRESOURCE mapped;
hr = ID3D11DeviceContext_Map(sys->d3d_dev.d3dcontext, (ID3D11Resource *)quad->pVertexShaderConstants, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
@@ -739,7 +741,7 @@ static void UpdateSize(vout_display_t *vd)
UpdatePicQuadPosition(vd);
D3D11_UpdateQuadPosition(vd, &sys->d3d_dev, &sys->picQuad, &sys->sys.rect_src_clipped,
- vd->fmt.orientation);
+ vd->source.orientation);
d3d11_device_unlock( &sys->d3d_dev );
}
@@ -887,7 +889,7 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
sys->picQuad.i_height = texDesc.Height;
sys->picQuad.i_width = texDesc.Width;
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
UpdateSize(vd);
}
}
@@ -934,7 +936,7 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
renderSrc = p_sys->renderSrc;
}
DisplayPicture(sys, &sys->picQuad,
- vd->fmt.projection_mode == PROJECTION_MODE_RECTANGULAR ? &sys->flatVShader : &sys->projectionVShader,
+ vd->source.projection_mode == PROJECTION_MODE_RECTANGULAR ? &sys->flatVShader : &sys->projectionVShader,
renderSrc);
if (subpicture) {
@@ -1193,7 +1195,7 @@ static const d3d_format_t *GetBlendableFormat(vout_display_t *vd, vlc_fourcc_t i
return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, false, supportFlags );
}
-static int Direct3D11Open(vout_display_t *vd)
+static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
{
vout_display_sys_t *sys = vd->sys;
IDXGIFactory2 *dxgifactory;
@@ -1292,8 +1294,8 @@ static int Direct3D11Open(vout_display_t *vd)
return VLC_EGENERIC;
}
- video_format_Clean(&vd->fmt);
- vd->fmt = fmt;
+ video_format_Clean(fmtp);
+ *fmtp = fmt;
return VLC_SUCCESS;
}
@@ -1423,7 +1425,7 @@ static void UpdatePicQuadPosition(vout_display_t *vd)
D3D11_UpdateViewport( &sys->picQuad, &sys->sys.rect_dest_clipped, sys->display.pixelFormat );
- SetQuadVSProjection(vd, &sys->picQuad, &vd->cfg->viewpoint);
+ SetQuadVSProjection(vd, &sys->picQuad, &sys->sys.vdcfg.viewpoint);
#ifndef NDEBUG
msg_Dbg( vd, "picQuad position (%.02f,%.02f) %.02fx%.02f",
@@ -1486,7 +1488,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
}
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
#ifdef HAVE_ID3D11VIDEODECODER
if (!is_d3d11_opaque(fmt->i_chroma) || sys->legacy_shader)
@@ -1559,7 +1561,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
ID3D11DepthStencilState_Release(pDepthStencilState);
}
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
hr = UpdateBackBuffer(vd);
if (FAILED(hr)) {
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index f37ba7cac2..a8af44160f 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -167,7 +167,7 @@ struct vout_display_sys_t
bool desktop_requested;
};
-static const d3d9_format_t *Direct3DFindFormat(vout_display_t *vd, vlc_fourcc_t chroma, D3DFORMAT target);
+static const d3d9_format_t *Direct3DFindFormat(vout_display_t *vd, const video_format_t *fmt, D3DFORMAT target);
static int Open(vlc_object_t *);
@@ -180,7 +180,7 @@ static picture_pool_t*DisplayPool(vout_display_t *, unsigned);
static int Control(vout_display_t *, int, va_list);
static void Manage (vout_display_t *);
-static int Direct3D9Reset (vout_display_t *);
+static int Direct3D9Reset (vout_display_t *, video_format_t *fmt);
static void Direct3D9Destroy(vout_display_sys_t *);
static int Direct3D9Open (vout_display_t *, video_format_t *);
@@ -245,6 +245,8 @@ static HINSTANCE Direct3D9LoadShaderLibrary(void)
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ const vout_display_cfg_t *cfg = vd->cfg;
+ video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
if ( !vd->obj.force && vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR)
@@ -286,14 +288,14 @@ static int Open(vlc_object_t *object)
sys->reopen_device = false;
sys->lost_not_ready = false;
sys->allow_hw_yuv = var_CreateGetBool(vd, "directx-hw-yuv");
- sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen;
+ sys->desktop_save.is_fullscreen = cfg->is_fullscreen;
sys->desktop_save.is_on_top = false;
sys->desktop_save.win.left = var_InheritInteger(vd, "video-x");
- sys->desktop_save.win.right = vd->cfg->display.width;
+ sys->desktop_save.win.right = cfg->display.width;
sys->desktop_save.win.top = var_InheritInteger(vd, "video-y");
- sys->desktop_save.win.bottom = vd->cfg->display.height;
+ sys->desktop_save.win.bottom = cfg->display.height;
- if (CommonInit(vd))
+ if (CommonInit(vd, cfg, fmtp))
goto error;
/* */
@@ -328,8 +330,8 @@ static int Open(vlc_object_t *object)
var_AddCallback(vd, "video-wallpaper", DesktopCallback, NULL);
/* Setup vout_display now that everything is fine */
- video_format_Clean(&vd->fmt);
- video_format_Copy(&vd->fmt, &fmt);
+ video_format_Clean(fmtp);
+ video_format_Copy(fmtp, &fmt);
vd->info = info;
vd->pool = DisplayPool;
@@ -338,7 +340,7 @@ static int Open(vlc_object_t *object)
vd->control = Control;
/* Fix state in case of desktop mode */
- if (sys->sys.use_desktop && vd->cfg->is_fullscreen)
+ if (sys->sys.use_desktop && cfg->is_fullscreen)
vout_display_SendEventFullscreen(vd, false);
return VLC_SUCCESS;
@@ -608,13 +610,13 @@ static void Display(vout_display_t *vd, picture_t *picture)
CommonDisplay(vd);
}
-static int ControlReopenDevice(vout_display_t *vd)
+static int ControlReopenDevice(vout_display_t *vd, video_format_t *fmtp)
{
vout_display_sys_t *sys = vd->sys;
if (!sys->sys.use_desktop) {
/* Save non-desktop state */
- sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen;
+ sys->desktop_save.is_fullscreen = sys->sys.vdcfg.is_fullscreen;
sys->desktop_save.is_on_top = sys->sys.is_on_top;
WINDOWPLACEMENT wp = { .length = sizeof(wp), };
@@ -662,7 +664,7 @@ static int ControlReopenDevice(vout_display_t *vd)
msg_Err(vd, "Failed to reopen device");
return VLC_EGENERIC;
}
- vd->fmt = fmt;
+ *fmtp = fmt;
sys->sys.is_first_display = true;
if (sys->sys.use_desktop) {
@@ -686,21 +688,26 @@ static int Control(vout_display_t *vd, int query, va_list args)
switch (query) {
case VOUT_DISPLAY_RESET_PICTURES:
+ {
+ const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
+ video_format_t *fmt = va_arg(args, video_format_t *);
/* FIXME what to do here in case of failure */
if (sys->reset_device) {
- if (Direct3D9Reset(vd)) {
+ if (Direct3D9Reset(vd, fmt)) {
msg_Err(vd, "Failed to reset device");
return VLC_EGENERIC;
}
sys->reset_device = false;
} else if(sys->reopen_device) {
- if (ControlReopenDevice(vd)) {
+ if (ControlReopenDevice(vd, fmt)) {
msg_Err(vd, "Failed to reopen device");
return VLC_EGENERIC;
}
sys->reopen_device = false;
}
+ (void) cfg;
return VLC_SUCCESS;
+ }
default:
return CommonControl(vd, query, args);
}
@@ -792,7 +799,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt)
/* Find the appropriate D3DFORMAT for the render chroma, the format will be the closest to
* the requested chroma which is usable by the hardware in an offscreen surface, as they
* typically support more formats than textures */
- const d3d9_format_t *d3dfmt = Direct3DFindFormat(vd, fmt->i_chroma, p_d3d9_dev->pp.BackBufferFormat);
+ const d3d9_format_t *d3dfmt = Direct3DFindFormat(vd, fmt, p_d3d9_dev->pp.BackBufferFormat);
if (!d3dfmt) {
msg_Err(vd, "surface pixel format is not supported.");
goto error;
@@ -803,7 +810,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt)
fmt->i_bmask = d3dfmt->bmask;
sys->d3dtexture_format = d3dfmt;
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
if (Direct3D9CreateResources(vd, fmt)) {
msg_Err(vd, "Failed to allocate resources");
@@ -835,7 +842,7 @@ static void Direct3D9Close(vout_display_t *vd)
/**
* It reset the Direct3D9 device and its resources.
*/
-static int Direct3D9Reset(vout_display_t *vd)
+static int Direct3D9Reset(vout_display_t *vd, video_format_t *fmtp)
{
vout_display_sys_t *sys = vd->sys;
d3d9_device_t *p_d3d9_dev = &sys->d3d_dev;
@@ -861,10 +868,10 @@ static int Direct3D9Reset(vout_display_t *vd)
return VLC_EGENERIC;
}
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
/* re-create them */
- if (Direct3D9CreateResources(vd, &vd->fmt)) {
+ if (Direct3D9CreateResources(vd, fmtp)) {
msg_Dbg(vd, "Direct3D9CreateResources failed !");
return VLC_EGENERIC;
}
@@ -976,23 +983,23 @@ static const d3d9_format_t d3d_formats[] = {
/**
* It returns the format (closest to chroma) that can be converted to target */
-static const d3d9_format_t *Direct3DFindFormat(vout_display_t *vd, vlc_fourcc_t chroma, D3DFORMAT target)
+static const d3d9_format_t *Direct3DFindFormat(vout_display_t *vd, const video_format_t *fmt, D3DFORMAT target)
{
vout_display_sys_t *sys = vd->sys;
- bool hardware_scale_ok = !(vd->fmt.i_visible_width & 1) && !(vd->fmt.i_visible_height & 1);
+ bool hardware_scale_ok = !(fmt->i_visible_width & 1) && !(fmt->i_visible_height & 1);
if( !hardware_scale_ok )
msg_Warn( vd, "Disabling hardware chroma conversion due to odd dimensions" );
for (unsigned pass = 0; pass < 2; pass++) {
const vlc_fourcc_t *list;
- const vlc_fourcc_t dxva_chroma[] = {chroma, 0};
+ const vlc_fourcc_t dxva_chroma[] = {fmt->i_chroma, 0};
- if (pass == 0 && is_d3d9_opaque(chroma))
+ if (pass == 0 && is_d3d9_opaque(fmt->i_chroma))
list = dxva_chroma;
- else if (pass == 0 && hardware_scale_ok && sys->allow_hw_yuv && vlc_fourcc_IsYUV(chroma))
- list = vlc_fourcc_GetYUVFallback(chroma);
+ else if (pass == 0 && hardware_scale_ok && sys->allow_hw_yuv && vlc_fourcc_IsYUV(fmt->i_chroma))
+ list = vlc_fourcc_GetYUVFallback(fmt->i_chroma);
else if (pass == 1)
- list = vlc_fourcc_GetRGBFallback(chroma);
+ list = vlc_fourcc_GetRGBFallback(fmt->i_chroma);
else
continue;
@@ -1477,7 +1484,7 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
/* */
region->texture = sys->d3dtex;
Direct3D9SetupVertices(region->vertex, &vd->sys->sys.rect_src, &vd->sys->sys.rect_src_clipped,
- &vd->sys->sys.rect_dest_clipped, 255, vd->fmt.orientation);
+ &vd->sys->sys.rect_dest_clipped, 255, vd->source.orientation);
return VLC_SUCCESS;
}
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index b74e17d125..80747e81c9 100644
--- a/modules/video_output/win32/directdraw.c
+++ b/modules/video_output/win32/directdraw.c
@@ -187,6 +187,8 @@ static void WallpaperChange(vout_display_t *vd, bool use_wallpaper);
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ const vout_display_cfg_t *cfg = vd->cfg;
+ video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
/* Allocate structure */
@@ -210,11 +212,11 @@ static int Open(vlc_object_t *object)
var_Create(vd, "directx-device", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
/* Initialisation */
- if (CommonInit(vd))
+ if (CommonInit(vd, cfg, fmtp))
goto error;
/* */
- video_format_t fmt = vd->fmt;
+ video_format_t fmt = *fmtp;
if (DirectXOpen(vd, &fmt))
goto error;
@@ -235,8 +237,8 @@ static int Open(vlc_object_t *object)
var_AddCallback(vd, "video-wallpaper", WallpaperCallback, NULL);
/* Setup vout_display now that everything is fine */
- video_format_Clean(&vd->fmt);
- video_format_Copy(&vd->fmt, &fmt);
+ video_format_Clean(fmtp);
+ video_format_Copy(fmtp, &fmt);
vd->info = info;
vd->pool = Pool;
@@ -346,9 +348,13 @@ static int Control(vout_display_t *vd, int query, va_list args)
switch (query) {
case VOUT_DISPLAY_RESET_PICTURES:
+ {
+ const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
+ video_format_t *fmt = va_arg(args, video_format_t *);
DirectXClose(vd);
/* Make sure the wallpaper is restored */
if (sys->use_wallpaper) {
+
vlc_mutex_lock(&sys->lock);
if (!sys->ch_wallpaper) {
sys->ch_wallpaper = true;
@@ -358,7 +364,9 @@ static int Control(vout_display_t *vd, int query, va_list args)
WallpaperChange(vd, false);
}
- return DirectXOpen(vd, &vd->fmt);
+ (void) cfg;
+ return DirectXOpen(vd, fmt);
+ }
default:
return CommonControl(vd, query, args);
}
@@ -427,7 +435,7 @@ static int DirectXOpen(vout_display_t *vd, video_format_t *fmt)
msg_Err(vd, "cannot initialize DirectX DirectDraw");
return VLC_EGENERIC;
}
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
/* Create the picture pool */
if (DirectXCreatePool(vd, &sys->sys.use_overlay, fmt)) {
@@ -1341,7 +1349,7 @@ static int DirectXUpdateOverlay(vout_display_t *vd, LPDIRECTDRAWSURFACE2 surface
src.bottom = vd->source.i_y_offset + vd->source.i_visible_height;
AlignRect(&src, sys->sys.i_align_src_boundary, sys->sys.i_align_src_size);
- vout_display_cfg_t cfg = *vd->cfg;
+ vout_display_cfg_t cfg = sys->sys.vdcfg;
cfg.display.width = sys->sys.rect_display.right;
cfg.display.height = sys->sys.rect_display.bottom;
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index ecb2451514..626e75d1c5 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -53,6 +53,7 @@
struct event_thread_t
{
vout_display_t *vd;
+ vout_display_cfg_t cfg;
/* */
vlc_thread_t thread;
@@ -313,7 +314,7 @@ static void *EventThread( void *p_this )
i_key |= KEY_MODIFIER_ALT;
}
- vout_display_SendEventKey(vd, i_key);
+ vout_window_ReportKeyPress(p_event->parent_window, i_key);
}
break;
}
@@ -343,7 +344,7 @@ static void *EventThread( void *p_this )
{
i_key |= KEY_MODIFIER_ALT;
}
- vout_display_SendEventKey(vd, i_key);
+ vout_window_ReportKeyPress(p_event->parent_window, i_key);
}
break;
}
@@ -456,8 +457,11 @@ bool EventThreadGetAndResetHasMoved( event_thread_t *p_event )
return atomic_exchange(&p_event->has_moved, false);
}
-event_thread_t *EventThreadCreate( vout_display_t *vd)
+event_thread_t *EventThreadCreate( vout_display_t *vd, const vout_display_cfg_t *cfg )
{
+
+ if (cfg->window->type != VOUT_WINDOW_TYPE_HWND)
+ return NULL;
/* Create the Vout EventThread, this thread is created by us to isolate
* the Win32 PeekMessage function calls. We want to do this because
* Windows can stay blocked inside this call for a long time, and when
@@ -474,13 +478,14 @@ event_thread_t *EventThreadCreate( vout_display_t *vd)
vlc_mutex_init( &p_event->lock );
vlc_cond_init( &p_event->wait );
+ p_event->parent_window = cfg->window;
p_event->is_cursor_hidden = false;
p_event->button_pressed = 0;
p_event->psz_title = NULL;
p_event->source = vd->source;
p_event->hwnd = NULL;
atomic_init(&p_event->has_moved, false);
- vout_display_PlacePicture(&p_event->place, &vd->source, vd->cfg, false);
+ vout_display_PlacePicture(&p_event->place, &vd->source, cfg, false);
_sntprintf( p_event->class_main, sizeof(p_event->class_main)/sizeof(*p_event->class_main),
_T("VLC video main %p"), (void *)p_event );
@@ -690,11 +695,7 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
#endif
{
/* If an external window was specified, we'll draw in it. */
- p_event->parent_window = vout_display_NewWindow(vd, VOUT_WINDOW_TYPE_HWND);
- if( p_event->parent_window )
- p_event->hparent = p_event->parent_window->handle.hwnd;
- else
- p_event->hparent = NULL;
+ p_event->hparent = p_event->parent_window->handle.hwnd;
}
#if defined(MODULE_NAME_IS_direct3d9) || defined(MODULE_NAME_IS_direct3d11)
else
@@ -1012,7 +1013,7 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
/* the user wants to close the window */
case WM_CLOSE:
- vout_display_SendEventClose(vd);
+ vout_window_ReportClose(p_event->parent_window);
return 0;
/* the window has been closed so shut down everything now */
diff --git a/modules/video_output/win32/events.h b/modules/video_output/win32/events.h
index 55c261b796..35650cb9a4 100644
--- a/modules/video_output/win32/events.h
+++ b/modules/video_output/win32/events.h
@@ -47,7 +47,7 @@ typedef struct {
HWND hfswnd;
} event_hwnd_t;
-event_thread_t *EventThreadCreate( vout_display_t *);
+event_thread_t *EventThreadCreate( vout_display_t *, const vout_display_cfg_t * );
void EventThreadDestroy( event_thread_t * );
int EventThreadStart( event_thread_t *, event_hwnd_t *, const event_cfg_t * );
void EventThreadStop( event_thread_t * );
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index ecc8dee939..3126aedbd5 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -112,6 +112,8 @@ static vout_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ const vout_display_cfg_t *cfg = vd->cfg;
+ video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
/* do not use OpenGL on XP unless forced */
@@ -124,7 +126,7 @@ static int Open(vlc_object_t *object)
return VLC_ENOMEM;
/* */
- if (CommonInit(vd))
+ if (CommonInit(vd, cfg, fmtp))
goto error;
EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (OpenGL output)");
@@ -142,14 +144,14 @@ static int Open(vlc_object_t *object)
goto error;
}
- vlc_gl_Resize (sys->gl, vd->cfg->display.width, vd->cfg->display.height);
+ vlc_gl_Resize (sys->gl, cfg->display.width, cfg->display.height);
- video_format_t fmt = vd->fmt;
+ video_format_t fmt = *fmtp;
const vlc_fourcc_t *subpicture_chromas;
if (vlc_gl_MakeCurrent (sys->gl))
goto error;
sys->vgl = vout_display_opengl_New(&fmt, &subpicture_chromas, sys->gl,
- &vd->cfg->viewpoint);
+ &cfg->viewpoint);
vlc_gl_ReleaseCurrent (sys->gl);
if (!sys->vgl)
goto error;
@@ -159,7 +161,7 @@ static int Open(vlc_object_t *object)
info.subpicture_chromas = subpicture_chromas;
/* Setup vout_display now that everything is fine */
- vd->fmt = fmt;
+ *fmtp = fmt;
vd->info = info;
vd->pool = Pool;
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 9521febc24..637a0a2866 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -88,6 +88,8 @@ static void Clean(vout_display_t *);
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ const vout_display_cfg_t *cfg = vd->cfg;
+ video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
if ( !vd->obj.force && vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR)
@@ -97,12 +99,11 @@ static int Open(vlc_object_t *object)
if (!sys)
return VLC_ENOMEM;
- if (CommonInit(vd))
+ if (CommonInit(vd, cfg, fmtp))
goto error;
/* */
- video_format_t fmt = vd->fmt;
- if (Init(vd, &fmt))
+ if (Init(vd, fmtp))
goto error;
vout_display_info_t info = vd->info;
@@ -111,7 +112,6 @@ static int Open(vlc_object_t *object)
info.has_pictures_invalid = true;
/* */
- vd->fmt = fmt;
vd->info = info;
vd->pool = Pool;
@@ -305,7 +305,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
else
sys->sys.pool = NULL;
- UpdateRects(vd, NULL, true);
+ UpdateRects(vd, true);
return VLC_SUCCESS;
}
--
2.19.1
More information about the vlc-devel
mailing list