[vlc-commits] vout: win32: don't run the HWND thread in windowless mode
Steve Lhomme
git at videolan.org
Thu Nov 15 14:20:05 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 15 12:04:47 2018 +0100| [4c2779a496a3b3b12ff2b7832b527390fcc57dae] | committer: Steve Lhomme
vout: win32: don't run the HWND thread in windowless mode
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c2779a496a3b3b12ff2b7832b527390fcc57dae
---
modules/video_output/win32/common.c | 56 ++++++++++++++++++++++++---------
modules/video_output/win32/direct3d11.c | 6 +++-
modules/video_output/win32/direct3d9.c | 8 +++--
modules/video_output/win32/directdraw.c | 23 ++++++++------
modules/video_output/win32/glwin32.c | 3 +-
modules/video_output/win32/wingdi.c | 3 +-
6 files changed, 69 insertions(+), 30 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index d2ff2150bb..b24428de09 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -52,6 +52,8 @@ static int CommonControlSetFullscreen(vout_display_t *, bool is_fullscreen);
static bool GetRect(const vout_display_sys_t *sys, RECT *out)
{
+ if (sys->b_windowless)
+ return false;
return GetClientRect(sys->hwnd, out);
}
#endif
@@ -91,9 +93,13 @@ int CommonInit(vout_display_t *vd, bool b_windowless)
SetRectEmpty(&sys->rect_display);
SetRectEmpty(&sys->rect_parent);
- var_Create(vd, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
var_Create(vd, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
+ if (b_windowless)
+ return VLC_SUCCESS;
+
+ var_Create(vd, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
+
/* */
sys->event = EventThreadCreate(vd);
if (!sys->event)
@@ -151,21 +157,30 @@ void UpdateRects(vout_display_t *vd,
#define rect_dest_clipped sys->rect_dest_clipped
RECT rect;
- POINT point;
+ POINT point = { 0 };
/* */
if (!cfg)
cfg = vd->cfg;
/* Retrieve the window size */
- if (!sys->pf_GetRect(sys, &rect))
- return;
+ if (sys->b_windowless)
+ {
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = vd->source.i_visible_width;
+ rect.bottom = vd->source.i_visible_height;
+ }
+ else
+ {
+ if (!sys->pf_GetRect(sys, &rect))
+ return;
- /* Retrieve the window position */
- point.x = point.y = 0;
#if !VLC_WINSTORE_APP
- ClientToScreen(sys->hwnd, &point);
+ /* Retrieve the window position */
+ ClientToScreen(sys->hwnd, &point);
#endif
+ }
/* If nothing changed, we can return */
bool has_moved;
@@ -180,6 +195,11 @@ void UpdateRects(vout_display_t *vd,
vout_display_SendEventDisplaySize(vd, rect.right, rect.bottom);
#endif
#else
+ if (sys->b_windowless)
+ {
+ has_moved = is_resized = false;
+ }
+ else
EventThreadUpdateWindowPosition(sys->event, &has_moved, &is_resized,
point.x, point.y,
rect.right, rect.bottom);
@@ -204,12 +224,15 @@ void UpdateRects(vout_display_t *vd,
vout_display_PlacePicture(&place, source, &place_cfg, false);
#if !VLC_WINSTORE_APP
- EventThreadUpdateSourceAndPlace(sys->event, source, &place);
-
- if (sys->hvideownd)
- SetWindowPos(sys->hvideownd, 0,
- place.x, place.y, place.width, place.height,
- SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS);
+ if (!sys->b_windowless)
+ {
+ EventThreadUpdateSourceAndPlace(sys->event, source, &place);
+
+ if (sys->hvideownd)
+ SetWindowPos(sys->hvideownd, 0,
+ place.x, place.y, place.width, place.height,
+ SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS);
+ }
#endif
/* Destination image position and dimensions */
@@ -353,6 +376,8 @@ void CommonClean(vout_display_t *vd)
void CommonManage(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
+ if (sys->b_windowless)
+ return;
/* We used to call the Win32 PeekMessage function here to read the window
* messages. But since window can stay blocked into this function for a
@@ -514,6 +539,9 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
if (sys->parent_window)
return VLC_EGENERIC;
+ if(sys->b_windowless)
+ return VLC_SUCCESS;
+
/* */
HWND hwnd = sys->hparent && sys->hfswnd ? sys->hfswnd : sys->hwnd;
@@ -629,7 +657,7 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
.bottom = cfg->display.height,
};
- if (!cfg->is_fullscreen) {
+ if (!cfg->is_fullscreen && !sys->b_windowless) {
AdjustWindowRect(&rect_window, EventThreadGetWindowStyle(sys->event), 0);
SetWindowPos(sys->hwnd, 0, 0, 0,
rect_window.right - rect_window.left,
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 311b921e19..5b1ed23eb9 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -291,7 +291,8 @@ static int Open(vlc_object_t *object)
}
#if !VLC_WINSTORE_APP
- EventThreadUpdateTitle(vd->sys->sys.event, VOUT_TITLE " (Direct3D11 output)");
+ if (!vd->sys->sys.b_windowless)
+ EventThreadUpdateTitle(vd->sys->sys.event, VOUT_TITLE " (Direct3D11 output)");
#endif
msg_Dbg(vd, "Direct3D11 device adapter successfully initialized");
@@ -1240,6 +1241,9 @@ static int Direct3D11Open(vout_display_t *vd)
FillSwapChainDesc(vd, &scd);
+ if (sys->sys.hvideownd == 0)
+ return VLC_EGENERIC;
+
hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)sys->d3d_dev.d3ddevice,
sys->sys.hvideownd, &scd, NULL, NULL, &sys->dxgiswapChain);
if (hr == DXGI_ERROR_INVALID_CALL && scd.Format == DXGI_FORMAT_R10G10B10A2_UNORM)
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index eb3b6120b4..19cd570f84 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -625,7 +625,8 @@ static int ControlReopenDevice(vout_display_t *vd)
/* */
Direct3D9Close(vd);
- EventThreadStop(sys->sys.event);
+ if (!sys->sys.b_windowless)
+ EventThreadStop(sys->sys.event);
/* */
vlc_mutex_lock(&sys->lock);
@@ -645,7 +646,7 @@ static int ControlReopenDevice(vout_display_t *vd)
}
event_hwnd_t hwnd;
- if (EventThreadStart(sys->sys.event, &hwnd, &cfg)) {
+ if (!sys->sys.b_windowless && EventThreadStart(sys->sys.event, &hwnd, &cfg)) {
msg_Err(vd, "Failed to restart event thread");
return VLC_EGENERIC;
}
@@ -812,7 +813,8 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt)
}
/* Change the window title bar text */
- EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (Direct3D9 output)");
+ if (!vd->sys->sys.b_windowless)
+ EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (Direct3D9 output)");
msg_Dbg(vd, "Direct3D9 device adapter successfully initialized");
return VLC_SUCCESS;
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index d28f1c275c..0b29e9da79 100644
--- a/modules/video_output/win32/directdraw.c
+++ b/modules/video_output/win32/directdraw.c
@@ -438,17 +438,20 @@ static int DirectXOpen(vout_display_t *vd, video_format_t *fmt)
/* */
if (sys->sys.use_overlay)
DirectXUpdateOverlay(vd, NULL);
- EventThreadUseOverlay(sys->sys.event, sys->sys.use_overlay);
+ if (!sys->sys.b_windowless)
+ {
+ EventThreadUseOverlay(sys->sys.event, sys->sys.use_overlay);
- /* Change the window title bar text */
- const char *fallback;
- if (sys->sys.use_overlay)
- fallback = VOUT_TITLE " (hardware YUV overlay DirectX output)";
- else if (vlc_fourcc_IsYUV(fmt->i_chroma))
- fallback = VOUT_TITLE " (hardware YUV DirectX output)";
- else
- fallback = VOUT_TITLE " (software RGB DirectX output)";
- EventThreadUpdateTitle(sys->sys.event, fallback);
+ /* Change the window title bar text */
+ const char *fallback;
+ if (sys->sys.use_overlay)
+ fallback = VOUT_TITLE " (hardware YUV overlay DirectX output)";
+ else if (vlc_fourcc_IsYUV(fmt->i_chroma))
+ fallback = VOUT_TITLE " (hardware YUV DirectX output)";
+ else
+ fallback = VOUT_TITLE " (software RGB DirectX output)";
+ EventThreadUpdateTitle(sys->sys.event, fallback);
+ }
return VLC_SUCCESS;
}
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index a22afec660..212901622f 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -127,7 +127,8 @@ static int Open(vlc_object_t *object)
if (CommonInit(vd, false))
goto error;
- EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (OpenGL output)");
+ if (!sys->sys.b_windowless)
+ EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (OpenGL output)");
vout_window_t *surface = EmbedVideoWindow_Create(vd);
if (!surface)
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 6014a9ff0d..c6fde3641a 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -290,7 +290,8 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
SelectObject(sys->off_dc, sys->off_bitmap);
ReleaseDC(sys->sys.hvideownd, window_dc);
- EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (WinGDI output)");
+ if (!sys->sys.b_windowless)
+ EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (WinGDI output)");
/* */
picture_resource_t rsc;
More information about the vlc-commits
mailing list