[vlc-commits] vout: win32: refactor for next changes

Steve Lhomme git at videolan.org
Tue Nov 27 15:48:47 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Nov 12 14:54:45 2018 +0100| [ad94e8a23fd72e39f75179f7d8bdcd43e54a4daa] | committer: Steve Lhomme

vout: win32: refactor for next changes

vd->fmt and vd->cfg will be removed.
fmt and cfg will be passed by Open() and controls.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad94e8a23fd72e39f75179f7d8bdcd43e54a4daa
---

 modules/video_output/win32/common.c     | 49 ++++++++++++-----------------
 modules/video_output/win32/common.h     |  7 ++---
 modules/video_output/win32/direct3d11.c | 40 ++++++++++++------------
 modules/video_output/win32/direct3d9.c  | 55 +++++++++++++++++++--------------
 modules/video_output/win32/directdraw.c | 22 ++++++++-----
 modules/video_output/win32/events.c     |  4 +--
 modules/video_output/win32/events.h     |  2 +-
 modules/video_output/win32/glwin32.c    | 12 ++++---
 modules/video_output/win32/wingdi.c     | 10 +++---
 9 files changed, 104 insertions(+), 97 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index b24428de09..faec2600a3 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -60,16 +60,16 @@ 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, bool b_windowless)
+int CommonInit(vout_display_t *vd, bool b_windowless, const vout_display_cfg_t *vdcfg)
 {
     vout_display_sys_t *sys = vd->sys;
 
@@ -101,7 +101,7 @@ int CommonInit(vout_display_t *vd, bool b_windowless)
     var_Create(vd, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
 
     /* */
-    sys->event = EventThreadCreate(vd);
+    sys->event = EventThreadCreate(vd, vdcfg);
     if (!sys->event)
         return VLC_EGENERIC;
 
@@ -115,8 +115,9 @@ int CommonInit(vout_display_t *vd, bool b_windowless)
 #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))
@@ -128,7 +129,7 @@ int CommonInit(vout_display_t *vd, bool b_windowless)
     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);
     }
@@ -145,9 +146,7 @@ int CommonInit(vout_display_t *vd, bool b_windowless)
 * its job is to update the source and destination RECTs used to display the
 * picture.
 *****************************************************************************/
-void UpdateRects(vout_display_t *vd,
-    const vout_display_cfg_t *cfg,
-    bool is_forced)
+void UpdateRects(vout_display_t *vd, bool is_forced)
 {
     vout_display_sys_t *sys = vd->sys;
     const video_format_t *source = &vd->source;
@@ -160,8 +159,7 @@ void UpdateRects(vout_display_t *vd,
     POINT point = { 0 };
 
     /* */
-    if (!cfg)
-        cfg = vd->cfg;
+    const vout_display_cfg_t *cfg = &sys->vdcfg;
 
     /* Retrieve the window size */
     if (sys->b_windowless)
@@ -190,10 +188,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
     if (sys->b_windowless)
     {
@@ -412,13 +406,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);
 }
 
 /**
@@ -619,7 +613,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) {}
@@ -635,15 +629,9 @@ 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;
-
-        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);
+        const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
+        sys->vdcfg = *cfg;
+        UpdateRects(vd, true);
         return VLC_SUCCESS;
     }
 #if !VLC_WINSTORE_APP
@@ -663,7 +651,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 */
@@ -689,7 +678,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 90168a992b..f23fa9edd6 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -71,6 +71,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 ? */
 
@@ -90,16 +91,14 @@ typedef struct vout_display_sys_win32_t
 /*****************************************************************************
  * Prototypes from common.c
  *****************************************************************************/
-int  CommonInit(vout_display_t *, bool b_windowless);
+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  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 UpdateRects (vout_display_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 c8e383e042..d0e1462ca3 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 *);
 static void Direct3D11Close(vout_display_t *);
 
 static int SetupOutputFormat(vout_display_t *, video_format_t *);
@@ -306,7 +306,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 );
 }
@@ -341,6 +341,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 */
@@ -368,7 +370,7 @@ static int Open(vlc_object_t *object)
     if (ret != VLC_SUCCESS)
         return ret;
 
-    if (CommonInit(vd, false))
+    if (CommonInit(vd, false, cfg))
         goto error;
 
 #if VLC_WINSTORE_APP
@@ -377,7 +379,7 @@ static int Open(vlc_object_t *object)
     sys->sys.pf_GetPictureWidth  = GetPictureWidth;
     sys->sys.pf_GetPictureHeight = GetPictureHeight;
 
-    if (Direct3D11Open(vd)) {
+    if (Direct3D11Open(vd, fmtp)) {
         msg_Err(vd, "Direct3D11 could not be opened");
         goto error;
     }
@@ -445,21 +447,21 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
     surface_fmt.i_width  = sys->picQuad.i_width;
     surface_fmt.i_height = sys->picQuad.i_height;
 
-    if (D3D11_AllocateQuad(vd, &sys->d3d_dev, vd->fmt.projection_mode, &sys->picQuad) != VLC_SUCCESS)
+    if (D3D11_AllocateQuad(vd, &sys->d3d_dev, vd->source.projection_mode, &sys->picQuad) != VLC_SUCCESS)
     {
         msg_Err(vd, "Could not allocate quad buffers.");
         return NULL;
     }
 
     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;
@@ -725,6 +727,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;
 
@@ -734,14 +737,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);
@@ -871,7 +873,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);
             }
         }
@@ -918,7 +920,7 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
         renderSrc = p_sys->renderSrc;
     }
     D3D11_RenderQuad(&sys->d3d_dev, &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, sys->swapchainTargetView);
 
     if (subpicture) {
@@ -1187,7 +1189,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;
@@ -1289,8 +1291,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;
 }
@@ -1420,7 +1422,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",
@@ -1483,7 +1485,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)
@@ -1560,7 +1562,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 174bb4addc..e7e6df78f5 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -863,7 +863,7 @@ static int Direct3D9CreateResources(vout_display_t *vd, video_format_t *fmt)
 /**
  * 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;
@@ -889,10 +889,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;
     }
@@ -1366,23 +1366,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;
 
@@ -1434,7 +1434,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;
@@ -1445,7 +1445,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");
@@ -1475,13 +1475,13 @@ static void Direct3D9Close(vout_display_t *vd)
     D3D9_ReleaseDevice(&sys->d3d_dev);
 }
 
-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), };
@@ -1530,7 +1530,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) {
@@ -1555,21 +1555,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);
     }
@@ -1640,6 +1645,8 @@ static int Open(vlc_object_t *object)
 {
     vout_display_t *vd = (vout_display_t *)object;
     vout_display_sys_t *sys;
+    const vout_display_cfg_t *cfg = vd->cfg;
+    video_format_t *fmtp = &vd->fmt;
 
     if ( !vd->obj.force && vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR)
         return VLC_EGENERIC; /* let a module who can handle it do it */
@@ -1678,14 +1685,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, false))
+    if (CommonInit(vd, false, cfg))
         goto error;
 
     /* */
@@ -1720,8 +1727,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;
@@ -1730,7 +1737,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;
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index 0b29e9da79..091e2a580c 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, false))
+    if (CommonInit(vd, false, cfg))
         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)) {
@@ -1344,7 +1352,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..9db4afdb06 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -456,7 +456,7 @@ 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 *vdcfg)
 {
      /* Create the Vout EventThread, this thread is created by us to isolate
      * the Win32 PeekMessage function calls. We want to do this because
@@ -480,7 +480,7 @@ event_thread_t *EventThreadCreate( vout_display_t *vd)
     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, vdcfg, false);
 
     _sntprintf( p_event->class_main, sizeof(p_event->class_main)/sizeof(*p_event->class_main),
                _T("VLC video main %p"), (void *)p_event );
diff --git a/modules/video_output/win32/events.h b/modules/video_output/win32/events.h
index 55c261b796..993660184f 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 212901622f..43eca43c7f 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, false))
+    if (CommonInit(vd, false, cfg))
         goto error;
 
     if (!sys->sys.b_windowless)
@@ -143,14 +145,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;
@@ -160,7 +162,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 c6fde3641a..611e7201c9 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, false))
+    if (CommonInit(vd, false, cfg))
         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;
@@ -306,7 +306,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;
 }



More information about the vlc-commits mailing list