[vlc-devel] [PATCH 19/41] vout:win32: pass the common display_sys_t structure explicitly
Steve Lhomme
robux4 at ycbcr.xyz
Fri Mar 22 16:13:57 CET 2019
---
modules/video_output/win32/common.c | 62 ++++++++++---------------
modules/video_output/win32/common.h | 12 ++---
modules/video_output/win32/direct3d11.c | 16 +++----
modules/video_output/win32/direct3d9.c | 16 +++----
modules/video_output/win32/glwin32.c | 10 ++--
modules/video_output/win32/wingdi.c | 18 ++++---
6 files changed, 64 insertions(+), 70 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 729b6a7641..c95b21def4 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -43,9 +43,9 @@
#include "common.h"
#include "../video_chroma/copy.h"
-static void CommonChangeThumbnailClip(vout_display_t *, bool show);
+static void CommonChangeThumbnailClip(vout_display_t *, vout_display_sys_win32_t *, bool show);
#if !VLC_WINSTORE_APP
-static int CommonControlSetFullscreen(vout_display_t *, bool is_fullscreen);
+static int CommonControlSetFullscreen(vout_display_t *, vout_display_sys_win32_t *, bool is_fullscreen);
static bool GetRect(const vout_display_sys_win32_t *sys, RECT *out)
{
@@ -66,10 +66,8 @@ static unsigned int GetPictureHeight(const vout_display_t *vd)
}
/* */
-int CommonInit(vout_display_t *vd, bool b_windowless, const vout_display_cfg_t *vdcfg)
+int CommonInit(vout_display_t *vd, vout_display_sys_win32_t *sys, bool b_windowless, const vout_display_cfg_t *vdcfg)
{
- vout_display_sys_win32_t *sys = vd->sys;
-
sys->hwnd = NULL;
sys->hvideownd = NULL;
sys->hparent = NULL;
@@ -136,9 +134,8 @@ int CommonInit(vout_display_t *vd, bool b_windowless, const vout_display_cfg_t *
* its job is to update the source and destination RECTs used to display the
* picture.
*****************************************************************************/
-static void UpdateRectsInternal(vout_display_t *vd, bool is_forced)
+static void UpdateRectsInternal(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forced)
{
- vout_display_sys_win32_t *sys = vd->sys;
const video_format_t *source = &vd->source;
#define rect_src sys->area.rect_src
#define rect_src_clipped sys->area.rect_src_clipped
@@ -278,7 +275,7 @@ static void UpdateRectsInternal(vout_display_t *vd, bool is_forced)
rect_dest.right, rect_dest.bottom);
#endif
- CommonChangeThumbnailClip(vd, true);
+ CommonChangeThumbnailClip(vd, sys, true);
exit:
/* Signal the change in size/position */
@@ -289,26 +286,24 @@ exit:
#undef rect_dest
}
-void UpdateRects(vout_display_t *vd)
+void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys)
{
- UpdateRectsInternal(vd, true);
+ UpdateRectsInternal(vd, sys, true);
}
#if !VLC_WINSTORE_APP
/* */
-void CommonClean(vout_display_t *vd)
+void CommonClean(vout_display_t *vd, vout_display_sys_win32_t *sys)
{
- vout_display_sys_win32_t *sys = vd->sys;
if (sys->event) {
- CommonChangeThumbnailClip(vd, false);
+ CommonChangeThumbnailClip(vd, sys, false);
EventThreadStop(sys->event);
EventThreadDestroy(sys->event);
}
}
-void CommonManage(vout_display_t *vd)
+void CommonManage(vout_display_t *vd, vout_display_sys_win32_t *sys)
{
- vout_display_sys_win32_t *sys = vd->sys;
if (sys->b_windowless)
return;
@@ -345,22 +340,21 @@ void CommonManage(vout_display_t *vd)
RECTHeight(rect_parent),
SWP_NOZORDER);
- UpdateRectsInternal(vd, true);
+ UpdateRectsInternal(vd, sys, true);
}
}
/* HasMoved means here resize or move */
if (EventThreadGetAndResetHasMoved(sys->event))
- UpdateRectsInternal(vd, false);
+ UpdateRectsInternal(vd, sys, false);
}
/**
* It ensures that the video window is shown after the first picture
* is displayed.
*/
-void CommonDisplay(vout_display_t *vd)
+void CommonDisplay(vout_display_t *vd, vout_display_sys_win32_t *sys)
{
- vout_display_sys_win32_t *sys = vd->sys;
if (!sys->is_first_display)
return;
@@ -380,10 +374,8 @@ void CommonDisplay(vout_display_t *vd)
#if !VLC_WINSTORE_APP
/* */
-static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
+static void CommonChangeThumbnailClip(vout_display_t *vd, vout_display_sys_win32_t *sys, bool show)
{
- vout_display_sys_win32_t *sys = vd->sys;
-
/* Windows 7 taskbar thumbnail code */
OSVERSIONINFO winVer;
winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -427,10 +419,8 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
CoUninitialize();
}
-static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
+static int CommonControlSetFullscreen(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_fullscreen)
{
- vout_display_sys_win32_t *sys = vd->sys;
-
#ifdef MODULE_NAME_IS_direct3d9
if (sys->use_desktop && is_fullscreen)
return VLC_EGENERIC;
@@ -519,18 +509,16 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
#else
-void CommonManage(vout_display_t *vd) {
- UpdateRectsInternal(vd, false);
+void CommonManage(vout_display_t *vd, vout_display_sys_win32_t *sys) {
+ UpdateRectsInternal(vd, sys, false);
}
-void CommonClean(vout_display_t *vd) {}
-void CommonDisplay(vout_display_t *vd) {}
-void CommonChangeThumbnailClip(vout_display_t *vd, bool show) {}
+void CommonClean(vout_display_t *vd, vout_display_sys_win32_t *) {}
+void CommonDisplay(vout_display_t *vd, vout_display_sys_win32_t *) {}
+void CommonChangeThumbnailClip(vout_display_t *vd, vout_display_sys_win32_t *, bool show) {}
#endif
-int CommonControl(vout_display_t *vd, int query, va_list args)
+int CommonControl(vout_display_t *vd, vout_display_sys_win32_t *sys, int query, va_list args)
{
- vout_display_sys_win32_t *sys = vd->sys;
-
switch (query) {
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED: /* const vout_display_cfg_t *p_cfg */
case VOUT_DISPLAY_CHANGE_ZOOM: /* const vout_display_cfg_t *p_cfg */
@@ -538,7 +526,7 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
case VOUT_DISPLAY_CHANGE_SOURCE_CROP: {
const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
sys->area.vdcfg = *cfg;
- UpdateRectsInternal(vd, true);
+ UpdateRectsInternal(vd, sys, true);
return VLC_SUCCESS;
}
#if !VLC_WINSTORE_APP
@@ -559,7 +547,7 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
RECTHeight(rect_window), SWP_NOMOVE);
}
sys->area.vdcfg = *cfg;
- UpdateRectsInternal(vd, false);
+ UpdateRectsInternal(vd, sys, false);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_WINDOW_STATE: { /* unsigned state */
@@ -583,9 +571,9 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
}
case VOUT_DISPLAY_CHANGE_FULLSCREEN: {
bool fs = va_arg(args, int);
- if (CommonControlSetFullscreen(vd, fs))
+ if (CommonControlSetFullscreen(vd, sys, fs))
return VLC_EGENERIC;
- UpdateRectsInternal(vd, false);
+ UpdateRectsInternal(vd, sys, false);
return VLC_SUCCESS;
}
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 7d38977748..3bd022ca80 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -90,13 +90,13 @@ typedef struct vout_display_sys_win32_t
/*****************************************************************************
* Prototypes from common.c
*****************************************************************************/
-int CommonInit(vout_display_t *, bool b_windowless, const vout_display_cfg_t *vdcfg);
-void CommonClean(vout_display_t *);
-void CommonManage(vout_display_t *);
-int CommonControl(vout_display_t *, int , va_list );
-void CommonDisplay(vout_display_t *);
+int CommonInit(vout_display_t *, vout_display_sys_win32_t *, bool b_windowless, const vout_display_cfg_t *);
+void CommonClean(vout_display_t *, vout_display_sys_win32_t *);
+void CommonManage(vout_display_t *, vout_display_sys_win32_t *);
+int CommonControl(vout_display_t *, vout_display_sys_win32_t *, int , va_list );
+void CommonDisplay(vout_display_t *, vout_display_sys_win32_t *);
-void UpdateRects (vout_display_t *);
+void UpdateRects (vout_display_t *, vout_display_sys_win32_t *);
/*****************************************************************************
* Constants
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 1c0321d7ce..6522e5145f 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -224,7 +224,7 @@ static void Manage(vout_display_t *vd)
RECT before_src_clipped = sys->sys.area.rect_src_clipped;
RECT before_dest = sys->sys.area.rect_dest;
- CommonManage(vd);
+ CommonManage(vd, &sys->sys);
if (!RectEquals(&before_src_clipped, &sys->sys.area.rect_src_clipped) ||
!RectEquals(&before_dest, &sys->sys.area.rect_dest))
@@ -489,7 +489,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
goto error;
}
#endif
- if (CommonInit(vd, d3d11_ctx != NULL, cfg))
+ if (CommonInit(vd, &sys->sys, d3d11_ctx != NULL, cfg))
goto error;
#if VLC_WINSTORE_APP
@@ -549,7 +549,7 @@ error:
static void Close(vout_display_t *vd)
{
Direct3D11Close(vd);
- CommonClean(vd);
+ CommonClean(vd, &vd->sys->sys);
Direct3D11Destroy(vd);
}
@@ -752,7 +752,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
RECT before_src_clipped = sys->sys.area.rect_src_clipped;
RECT before_dest = sys->sys.area.rect_dest;
- int res = CommonControl( vd, query, args );
+ int res = CommonControl( vd, &sys->sys, query, args );
if (query == VOUT_DISPLAY_CHANGE_VIEWPOINT)
{
@@ -855,7 +855,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);
+ UpdateRects(vd, &sys->sys);
UpdateSize(vd);
}
}
@@ -957,7 +957,7 @@ static void Display(vout_display_t *vd, picture_t *picture)
sys->swapCb(sys->outside_opaque);
d3d11_device_unlock( &sys->d3d_dev );
- CommonDisplay(vd);
+ CommonDisplay(vd, &sys->sys);
}
static void Direct3D11Destroy(vout_display_t *vd)
@@ -1466,7 +1466,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
}
- UpdateRects(vd);
+ UpdateRects(vd, &sys->sys);
video_format_t surface_fmt = *fmt;
surface_fmt.i_width = sys->picQuad.i_width;
@@ -1569,7 +1569,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
ID3D11DepthStencilState_Release(pDepthStencilState);
}
- UpdateRects(vd);
+ UpdateRects(vd, &sys->sys);
hr = UpdateBackBuffer(vd);
if (FAILED(hr)) {
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 68a2243cda..1d72f4cd43 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -877,7 +877,7 @@ static int Direct3D9Reset(vout_display_t *vd, video_format_t *fmtp)
return VLC_EGENERIC;
}
- UpdateRects(vd);
+ UpdateRects(vd, &sys->sys);
/* re-create them */
if (Direct3D9CreateResources(vd, fmtp)) {
@@ -914,7 +914,7 @@ static void Manage (vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
- CommonManage(vd);
+ CommonManage(vd, &sys->sys);
/* Desktop mode change */
bool prev_desktop = sys->sys.use_desktop;
@@ -1337,7 +1337,7 @@ static void Display(vout_display_t *vd, picture_t *picture)
sys->swapCb(sys->outside_opaque);
- CommonDisplay(vd);
+ CommonDisplay(vd, &sys->sys);
}
/**
@@ -1491,7 +1491,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt,
fmt->i_bmask = d3dfmt->bmask;
sys->sw_texture_fmt = d3dfmt;
- UpdateRects(vd);
+ UpdateRects(vd, &sys->sys);
if (Direct3D9CreateResources(vd, fmt)) {
msg_Err(vd, "Failed to allocate resources");
@@ -1542,7 +1542,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
return VLC_SUCCESS;
}
default:
- return CommonControl(vd, query, args);
+ return CommonControl(vd, &sys->sys, query, args);
}
}
@@ -1666,7 +1666,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
sys->desktop_save.is_fullscreen = cfg->is_fullscreen;
sys->desktop_save.is_on_top = false;
- if (CommonInit(vd, d3d9_device != NULL, cfg))
+ if (CommonInit(vd, &sys->sys, d3d9_device != NULL, cfg))
goto error;
/* */
@@ -1714,7 +1714,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
return VLC_SUCCESS;
error:
Direct3D9Close(vd);
- CommonClean(vd);
+ CommonClean(vd, &sys->sys);
Direct3D9Destroy(sys);
free(vd->sys);
return VLC_EGENERIC;
@@ -1729,7 +1729,7 @@ static void Close(vout_display_t *vd)
Direct3D9Close(vd);
- CommonClean(vd);
+ CommonClean(vd, &vd->sys->sys);
Direct3D9Destroy(vd->sys);
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index edd6e4ada3..fb778810c5 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -80,7 +80,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
return vout_display_opengl_SetViewpoint(sys->vgl,
&va_arg (args, const vout_display_cfg_t* )->viewpoint);
- return CommonControl(vd, query, args);
+ return CommonControl(vd, &sys->sys, query, args);
}
static const struct vout_window_operations embedVideoWindow_Ops =
@@ -122,7 +122,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
return VLC_ENOMEM;
/* */
- if (CommonInit(vd, false, cfg))
+ if (CommonInit(vd, &sys->sys, false, cfg))
goto error;
if (!sys->sys.b_windowless)
@@ -193,7 +193,7 @@ static void Close(vout_display_t *vd)
vlc_object_delete(surface);
}
- CommonClean(vd);
+ CommonClean(vd, &sys->sys);
free(sys);
}
@@ -236,14 +236,14 @@ static void Display(vout_display_t *vd, picture_t *picture)
vlc_gl_ReleaseCurrent (sys->gl);
}
- CommonDisplay(vd);
+ CommonDisplay(vd, &sys->sys);
}
static void Manage (vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
- CommonManage(vd);
+ CommonManage(vd, &sys->sys);
const int width = RECTWidth(sys->sys.area.rect_dest);
const int height = RECTHeight(sys->sys.area.rect_dest);
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 6a66c75f16..9aa41b99d2 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -97,6 +97,12 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
picture_CopyPixels(&fake_pic, picture);
}
+static int Control(vout_display_t *vd, int query, va_list args)
+{
+ vout_display_sys_t *sys = vd->sys;
+ return CommonControl(vd, &sys->sys, query, args);
+}
+
/* */
static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
video_format_t *fmtp, vlc_video_context *context)
@@ -110,7 +116,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (!sys)
return VLC_ENOMEM;
- if (CommonInit(vd, false, cfg))
+ if (CommonInit(vd, &sys->sys, false, cfg))
goto error;
/* */
@@ -122,7 +128,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
vd->prepare = Prepare;
vd->display = Display;
- vd->control = CommonControl;
+ vd->control = Control;
return VLC_SUCCESS;
error:
@@ -135,7 +141,7 @@ static void Close(vout_display_t *vd)
{
Clean(vd);
- CommonClean(vd);
+ CommonClean(vd, &vd->sys->sys);
free(vd->sys);
}
@@ -171,8 +177,8 @@ static void Display(vout_display_t *vd, picture_t *picture)
#undef rect_src_clipped
#undef rect_dest
- CommonDisplay(vd);
- CommonManage(vd);
+ CommonDisplay(vd, &sys->sys);
+ CommonManage(vd, &sys->sys);
}
static int Init(vout_display_t *vd, video_format_t *fmt)
@@ -267,7 +273,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
if (!sys->sys.b_windowless)
EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (WinGDI output)");
- UpdateRects(vd);
+ UpdateRects(vd, &sys->sys);
return VLC_SUCCESS;
}
--
2.17.1
More information about the vlc-devel
mailing list