Browse Source

win32/common: move the opaque event_thread_t in the area structure

We don't need to have them separated, they are closely tied.
pull/162/head
Steve Lhomme 3 years ago
parent
commit
1a0dbb0c1b
  1. 26
      modules/video_output/win32/common.c
  2. 11
      modules/video_output/win32/common.h
  3. 13
      modules/video_output/win32/direct3d11.cpp
  4. 15
      modules/video_output/win32/direct3d9.c
  5. 11
      modules/video_output/win32/glwin32.c
  6. 15
      modules/video_output/win32/wingdi.c

26
modules/video_output/win32/common.c

@ -49,14 +49,14 @@ void CommonInit(display_win32_area_t *area)
#ifndef VLC_WINSTORE_APP
/* */
int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
event_thread_t **sys, bool projection_gestures)
bool projection_gestures)
{
if (unlikely(vd->cfg->window == NULL))
return VLC_EGENERIC;
/* */
*sys = EventThreadCreate(VLC_OBJECT(vd), vd->cfg->window);
if (!*sys)
area->event = EventThreadCreate(VLC_OBJECT(vd), vd->cfg->window);
if (!area->event)
return VLC_EGENERIC;
/* */
@ -66,7 +66,7 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
cfg.height = vd->cfg->display.height;
cfg.is_projected = projection_gestures;
if (EventThreadStart(*sys, &cfg))
if (EventThreadStart(area->event, &cfg))
return VLC_EGENERIC;
CommonPlacePicture(vd, area);
@ -74,9 +74,9 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
return VLC_SUCCESS;
}
HWND CommonVideoHWND(const event_thread_t *sys)
HWND CommonVideoHWND(const display_win32_area_t *area)
{
return EventThreadVideoHWND(sys);
return EventThreadVideoHWND(area->event);
}
#endif /* !VLC_WINSTORE_APP */
@ -111,24 +111,24 @@ void CommonPlacePicture(vout_display_t *vd, display_win32_area_t *area)
#ifndef VLC_WINSTORE_APP
/* */
void CommonWindowClean(event_thread_t *sys)
void CommonWindowClean(display_win32_area_t *sys)
{
if (sys) {
EventThreadStop(sys);
EventThreadDestroy(sys);
if (sys->event) {
EventThreadStop(sys->event);
EventThreadDestroy(sys->event);
}
}
#endif /* !VLC_WINSTORE_APP */
void CommonControl(vout_display_t *vd, display_win32_area_t *area, event_thread_t *sys, int query)
void CommonControl(vout_display_t *vd, display_win32_area_t *area, int query)
{
switch (query) {
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
#ifndef VLC_WINSTORE_APP
// Update dimensions
if (sys != NULL)
if (area->event != NULL)
{
EventThreadUpdateSize(sys);
EventThreadUpdateSize(area->event);
}
#endif /* !VLC_WINSTORE_APP */
// fallthrough

11
modules/video_output/win32/common.h

@ -32,13 +32,12 @@ extern "C" {
* event_thread_t: event thread
*****************************************************************************/
typedef struct event_thread_t event_thread_t;
typedef struct display_win32_area_t
{
/* Coordinates of dest images (used when blitting to display) */
vout_display_place_t place;
bool place_changed;
struct event_thread_t *event; // only use if sys.event is not NULL
} display_win32_area_t;
#define RECTWidth(r) (LONG)((r).right - (r).left)
@ -48,12 +47,12 @@ typedef struct display_win32_area_t
* Prototypes from common.c
*****************************************************************************/
#ifndef VLC_WINSTORE_APP
int CommonWindowInit(vout_display_t *, display_win32_area_t *, event_thread_t **,
int CommonWindowInit(vout_display_t *, display_win32_area_t *,
bool projection_gestures);
void CommonWindowClean(event_thread_t *);
void CommonWindowClean(display_win32_area_t *);
HWND CommonVideoHWND(const display_win32_area_t *);
#endif /* !VLC_WINSTORE_APP */
void CommonControl(vout_display_t *, display_win32_area_t *, event_thread_t *, int );
HWND CommonVideoHWND(const event_thread_t *);
void CommonControl(vout_display_t *, display_win32_area_t *, int );
void CommonPlacePicture (vout_display_t *, display_win32_area_t *);

13
modules/video_output/win32/direct3d11.cpp

@ -73,7 +73,6 @@ vlc_module_end ()
typedef struct vout_display_sys_t
{
event_thread_t *sys; /* only use if sys.event is not NULL */
display_win32_area_t area;
int log_level;
@ -371,7 +370,7 @@ static int Open(vout_display_t *vd,
#ifndef VLC_WINSTORE_APP
if (vd->cfg->window->type == VLC_WINDOW_TYPE_HWND)
{
if (CommonWindowInit(vd, &sys->area, &sys->sys,
if (CommonWindowInit(vd, &sys->area,
vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR))
goto error;
}
@ -387,7 +386,7 @@ static int Open(vout_display_t *vd,
vd->cfg->window->handle.dcomp_visual, sys->d3d_dev);
else
#endif
sys->outside_opaque = D3D11_CreateLocalSwapchainHandleHwnd(VLC_OBJECT(vd), CommonVideoHWND(sys->sys), sys->d3d_dev);
sys->outside_opaque = D3D11_CreateLocalSwapchainHandleHwnd(VLC_OBJECT(vd), CommonVideoHWND(&sys->area), sys->d3d_dev);
if (unlikely(sys->outside_opaque == NULL))
goto error;
sys->updateOutputCb = D3D11_LocalSwapchainUpdateOutput;
@ -398,8 +397,8 @@ static int Open(vout_display_t *vd,
}
#ifndef VLC_WINSTORE_APP
if (vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR && CommonVideoHWND(sys->sys))
sys->p_sensors = HookWindowsSensors(vd, CommonVideoHWND(sys->sys));
if (vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR && CommonVideoHWND(&sys->area))
sys->p_sensors = HookWindowsSensors(vd, CommonVideoHWND(&sys->area));
#endif // !VLC_WINSTORE_APP
if (Direct3D11Open(vd, fmtp, context)) {
@ -439,7 +438,7 @@ static void Close(vout_display_t *vd)
D3D_ReleaseShaderCompiler(sys->shaders);
#ifndef VLC_WINSTORE_APP
UnhookWindowsSensors(sys->p_sensors);
CommonWindowClean(sys->sys);
CommonWindowClean(&sys->area);
#endif
Direct3D11Close(vd);
delete sys;
@ -447,7 +446,7 @@ static void Close(vout_display_t *vd)
static int Control(vout_display_t *vd, int query)
{
vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
CommonControl( vd, &sys->area, sys->sys, query );
CommonControl( vd, &sys->area, query );
if ( sys->area.place_changed )
{

15
modules/video_output/win32/direct3d9.c

@ -131,7 +131,6 @@ typedef struct
typedef struct vout_display_sys_t
{
event_thread_t *sys; /* only use if sys.event is not NULL */
display_win32_area_t area;
bool allow_hw_yuv; /* Should we use hardware YUV->RGB conversions */
@ -1139,7 +1138,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
RECT rect;
UINT width, height;
GetClientRect(CommonVideoHWND(sys->sys), &rect);
GetClientRect(CommonVideoHWND(&sys->area), &rect);
width = RECTWidth(rect);
height = RECTHeight(rect);
@ -1263,9 +1262,9 @@ static void Swap(vout_display_t *vd)
HRESULT hr;
if (sys->d3d9_device->hd3d.use_ex) {
hr = IDirect3DDevice9Ex_PresentEx(p_d3d9_dev->devex, &src, &src, CommonVideoHWND(sys->sys), NULL, 0);
hr = IDirect3DDevice9Ex_PresentEx(p_d3d9_dev->devex, &src, &src, CommonVideoHWND(&sys->area), NULL, 0);
} else {
hr = IDirect3DDevice9_Present(p_d3d9_dev->dev, &src, &src, CommonVideoHWND(sys->sys), NULL);
hr = IDirect3DDevice9_Present(p_d3d9_dev->dev, &src, &src, CommonVideoHWND(&sys->area), NULL);
}
if (FAILED(hr)) {
msg_Dbg(vd, "Failed Present: 0x%lX", hr);
@ -1688,7 +1687,7 @@ static void Direct3D9Close(vout_display_t *vd)
static int Control(vout_display_t *vd, int query)
{
vout_display_sys_t *sys = vd->sys;
CommonControl(vd, &sys->area, sys->sys, query);
CommonControl(vd, &sys->area, query);
return VLC_SUCCESS;
}
@ -1794,7 +1793,7 @@ static int Open(vout_display_t *vd,
if ( sys->swapCb == NULL || sys->startEndRenderingCb == NULL || sys->updateOutputCb == NULL )
{
/* use our own callbacks, since there isn't any external ones */
if (CommonWindowInit(vd, &sys->area, &sys->sys, false))
if (CommonWindowInit(vd, &sys->area, false))
goto error;
sys->outside_opaque = vd;
@ -1872,7 +1871,7 @@ static int Open(vout_display_t *vd,
return VLC_SUCCESS;
error:
Direct3D9Close(vd);
CommonWindowClean(sys->sys);
CommonWindowClean(&sys->area);
Direct3D9Destroy(sys);
free(vd->sys);
return VLC_EGENERIC;
@ -1887,7 +1886,7 @@ static void Close(vout_display_t *vd)
Direct3D9Close(vd);
CommonWindowClean(sys->sys);
CommonWindowClean(&sys->area);
Direct3D9Destroy(sys);

11
modules/video_output/win32/glwin32.c

@ -62,7 +62,6 @@ vlc_module_end()
*****************************************************************************/
typedef struct vout_display_sys_t
{
event_thread_t *sys;
display_win32_area_t area;
vlc_gl_t *gl;
@ -84,7 +83,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
static int Control(vout_display_t *vd, int query)
{
vout_display_sys_t *sys = vd->sys;
CommonControl(vd, &sys->area, sys->sys, query);
CommonControl(vd, &sys->area, query);
return VLC_SUCCESS;
}
@ -101,7 +100,7 @@ static vlc_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
return NULL;
wnd->type = VLC_WINDOW_TYPE_HWND;
wnd->handle.hwnd = CommonVideoHWND(sys->sys);
wnd->handle.hwnd = CommonVideoHWND(&sys->area);
wnd->ops = &embedVideoWindow_Ops;
return wnd;
}
@ -133,12 +132,12 @@ static int Open(vout_display_t *vd,
/* */
CommonInit(&sys->area);
if (CommonWindowInit(vd, &sys->area, &sys->sys,
if (CommonWindowInit(vd, &sys->area,
vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR))
goto error;
if (vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR)
sys->p_sensors = HookWindowsSensors(vd, CommonVideoHWND(sys->sys));
sys->p_sensors = HookWindowsSensors(vd, CommonVideoHWND(&sys->area));
vlc_window_SetTitle(vd->cfg->window, VOUT_TITLE " (OpenGL output)");
@ -201,7 +200,7 @@ static void Close(vout_display_t *vd)
}
UnhookWindowsSensors(sys->p_sensors);
CommonWindowClean(sys->sys);
CommonWindowClean(&sys->area);
free(sys);
}

15
modules/video_output/win32/wingdi.c

@ -59,7 +59,6 @@ vlc_module_end ()
*****************************************************************************/
typedef struct vout_display_sys_t
{
event_thread_t *sys;
display_win32_area_t area;
int i_depth;
@ -99,7 +98,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
static int Control(vout_display_t *vd, int query)
{
vout_display_sys_t *sys = vd->sys;
CommonControl(vd, &sys->area, sys->sys, query);
CommonControl(vd, &sys->area, query);
return VLC_SUCCESS;
}
@ -125,7 +124,7 @@ static int Open(vout_display_t *vd,
return VLC_ENOMEM;
CommonInit(&sys->area);
if (CommonWindowInit(vd, &sys->area, &sys->sys, false))
if (CommonWindowInit(vd, &sys->area, false))
goto error;
/* */
@ -150,7 +149,7 @@ static void Close(vout_display_t *vd)
Clean(vd);
CommonWindowClean(sys->sys);
CommonWindowClean(&sys->area);
free(sys);
}
@ -160,7 +159,7 @@ static void Display(vout_display_t *vd, picture_t *picture)
vout_display_sys_t *sys = vd->sys;
VLC_UNUSED(picture);
HDC hdc = GetDC(CommonVideoHWND(sys->sys));
HDC hdc = GetDC(CommonVideoHWND(&sys->area));
if (sys->area.place_changed)
{
@ -196,7 +195,7 @@ static void Display(vout_display_t *vd, picture_t *picture)
SRCCOPY);
}
ReleaseDC(CommonVideoHWND(sys->sys), hdc);
ReleaseDC(CommonVideoHWND(&sys->area), hdc);
}
static int Init(vout_display_t *vd, video_format_t *fmt)
@ -206,7 +205,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
/* Initialize an offscreen bitmap for direct buffer operations. */
/* */
HDC window_dc = GetDC(CommonVideoHWND(sys->sys));
HDC window_dc = GetDC(CommonVideoHWND(&sys->area));
/* */
sys->i_depth = GetDeviceCaps(window_dc, PLANES) *
@ -279,7 +278,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
sys->off_dc = CreateCompatibleDC(window_dc);
SelectObject(sys->off_dc, sys->off_bitmap);
ReleaseDC(CommonVideoHWND(sys->sys), window_dc);
ReleaseDC(CommonVideoHWND(&sys->area), window_dc);
return VLC_SUCCESS;
}

Loading…
Cancel
Save