[vlc-commits] vout: win32: use vd->cfg directly

Steve Lhomme git at videolan.org
Mon Sep 7 08:36:04 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Sep  2 11:15:11 2020 +0200| [898c93509bc32d478424be783bff4cd91a472c69] | committer: Steve Lhomme

vout: win32: use vd->cfg directly

vd->cfg is only used in the vout thread so we don't need a local copy. We don't
need to modify it either.

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

 modules/video_output/win32/common.c     | 29 +++++++++++------------------
 modules/video_output/win32/common.h     |  8 +++-----
 modules/video_output/win32/direct3d11.c | 29 ++++++++++++++---------------
 modules/video_output/win32/direct3d9.c  | 15 ++++++++-------
 modules/video_output/win32/glwin32.c    |  6 +++---
 modules/video_output/win32/wingdi.c     | 10 ++++++----
 6 files changed, 45 insertions(+), 52 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 88c1fc4a9a..e1f6c3f502 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -41,10 +41,9 @@
 #include "common.h"
 #include "../../video_chroma/copy.h"
 
-void CommonInit(display_win32_area_t *area, const vout_display_cfg_t *vdcfg)
+void CommonInit(display_win32_area_t *area)
 {
     area->place_changed = false;
-    area->vdcfg = *vdcfg;
 }
 
 #if !VLC_WINSTORE_APP
@@ -52,7 +51,7 @@ void CommonInit(display_win32_area_t *area, const vout_display_cfg_t *vdcfg)
 int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
                      vout_display_sys_win32_t *sys, bool projection_gestures)
 {
-    if (unlikely(area->vdcfg.window == NULL))
+    if (unlikely(vd->cfg->window == NULL))
         return VLC_EGENERIC;
 
     /* */
@@ -63,15 +62,15 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
     sys->hparent   = NULL;
 
     /* */
-    sys->event = EventThreadCreate(VLC_OBJECT(vd), area->vdcfg.window);
+    sys->event = EventThreadCreate(VLC_OBJECT(vd), vd->cfg->window);
     if (!sys->event)
         return VLC_EGENERIC;
 
     /* */
     event_cfg_t cfg;
     memset(&cfg, 0, sizeof(cfg));
-    cfg.width  = area->vdcfg.display.width;
-    cfg.height = area->vdcfg.display.height;
+    cfg.width  = vd->cfg->display.width;
+    cfg.height = vd->cfg->display.height;
     cfg.is_projected = projection_gestures;
 
     event_hwnd_t hwnd;
@@ -81,7 +80,7 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
     sys->hparent       = hwnd.hparent;
     sys->hvideownd     = hwnd.hvideownd;
 
-    CommonPlacePicture(vd, area, sys);
+    CommonPlacePicture(vd, area);
 
     return VLC_SUCCESS;
 }
@@ -94,13 +93,11 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
 * its job is to update the source and destination RECTs used to display the
 * picture.
 *****************************************************************************/
-void CommonPlacePicture(vout_display_t *vd, display_win32_area_t *area, vout_display_sys_win32_t *sys)
+void CommonPlacePicture(vout_display_t *vd, display_win32_area_t *area)
 {
     /* Update the window position and size */
-    vout_display_cfg_t place_cfg = area->vdcfg;
-
     vout_display_place_t before_place = area->place;
-    vout_display_PlacePicture(&area->place, vd->source, &place_cfg);
+    vout_display_PlacePicture(&area->place, vd->source, vd->cfg);
 
     /* Signal the change in size/position */
     if (!vout_display_PlaceEquals(&before_place, &area->place))
@@ -129,34 +126,30 @@ void CommonWindowClean(vout_display_sys_win32_t *sys)
 }
 #endif /* !VLC_WINSTORE_APP */
 
-int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_sys_win32_t *sys, int query, va_list args)
+int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_sys_win32_t *sys, int query)
 {
     switch (query) {
     case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
     case VOUT_DISPLAY_CHANGE_ZOOM:
     case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
     case VOUT_DISPLAY_CHANGE_SOURCE_CROP: {
-        area->vdcfg = *vd->cfg;
-        CommonPlacePicture(vd, area, sys);
+        CommonPlacePicture(vd, area);
         return VLC_SUCCESS;
     }
     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
     {   /* Update dimensions */
-        area->vdcfg = *vd->cfg;
 #if !VLC_WINSTORE_APP
         if (sys->event != NULL)
         {
             RECT clientRect;
             GetClientRect(sys->hparent, &clientRect);
-            area->vdcfg.display.width  = RECTWidth(clientRect);
-            area->vdcfg.display.height = RECTHeight(clientRect);
 
             SetWindowPos(sys->hvideownd, 0, 0, 0,
                          RECTWidth(clientRect),
                          RECTHeight(clientRect), SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
         }
 #endif /* !VLC_WINSTORE_APP */
-        CommonPlacePicture(vd, area, sys);
+        CommonPlacePicture(vd, area);
         return VLC_SUCCESS;
     }
 
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 8eb48f7243..4df23573c2 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -35,8 +35,6 @@ typedef struct display_win32_area_t
     /* Coordinates of dest images (used when blitting to display) */
     vout_display_place_t  place;
     bool                  place_changed;
-
-    vout_display_cfg_t    vdcfg;
 } display_win32_area_t;
 
 #define RECTWidth(r)   (LONG)((r).right - (r).left)
@@ -71,11 +69,11 @@ int  CommonWindowInit(vout_display_t *, display_win32_area_t *, vout_display_sys
                       bool projection_gestures);
 void CommonWindowClean(vout_display_sys_win32_t *);
 #endif /* !VLC_WINSTORE_APP */
-int  CommonControl(vout_display_t *, display_win32_area_t *, vout_display_sys_win32_t *, int , va_list );
+int  CommonControl(vout_display_t *, display_win32_area_t *, vout_display_sys_win32_t *, int );
 
-void CommonPlacePicture (vout_display_t *, display_win32_area_t *, vout_display_sys_win32_t *);
+void CommonPlacePicture (vout_display_t *, display_win32_area_t *);
 
-void CommonInit(display_win32_area_t *, const vout_display_cfg_t *);
+void CommonInit(display_win32_area_t *);
 
 # ifdef __cplusplus
 extern "C" {
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index e116fff9c7..c4d5b488ab 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -149,8 +149,8 @@ static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
     vout_display_sys_t *sys = vd->sys;
     libvlc_video_render_cfg_t cfg;
 
-    cfg.width  = sys->area.vdcfg.display.width;
-    cfg.height = sys->area.vdcfg.display.height;
+    cfg.width  = vd->cfg->display.width;
+    cfg.height = vd->cfg->display.height;
 
     switch (fmt->i_chroma)
     {
@@ -279,8 +279,8 @@ static void UpdateSize(vout_display_t *vd)
     D3D11_UpdateQuadPosition(vd, sys->d3d_dev, &sys->picQuad, &source_rect,
                              vd->source->orientation);
 
-    D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &sys->area.vdcfg.viewpoint,
-                          (float) sys->area.vdcfg.display.width / sys->area.vdcfg.display.height );
+    D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &vd->cfg->viewpoint,
+                          (float) vd->cfg->display.width / vd->cfg->display.height );
 
     d3d11_device_unlock( sys->d3d_dev );
 
@@ -302,7 +302,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     if (ret != VLC_SUCCESS)
         goto error;
 
-    CommonInit(&sys->area, cfg);
+    CommonInit(&sys->area);
 
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = var_InheritAddress( vd, "vout-cb-update-output" );
@@ -403,17 +403,16 @@ static void Close(vout_display_t *vd)
 static int Control(vout_display_t *vd, int query, va_list args)
 {
     vout_display_sys_t *sys = vd->sys;
-    int res = CommonControl( vd, &sys->area, &sys->sys, query, args );
+    int res = CommonControl( vd, &sys->area, &sys->sys, query );
 
     if (query == VOUT_DISPLAY_CHANGE_VIEWPOINT)
     {
         if ( sys->picQuad.pVertexShaderConstants )
         {
             const vlc_viewpoint_t *viewpoint = va_arg(args, const vlc_viewpoint_t*);
-            sys->area.vdcfg.viewpoint = *viewpoint;
             d3d11_device_lock( sys->d3d_dev );
             D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, viewpoint,
-                                   (float) sys->area.vdcfg.display.width / sys->area.vdcfg.display.height );
+                                   (float) vd->cfg->display.width / vd->cfg->display.height );
             d3d11_device_unlock( sys->d3d_dev );
             res = VLC_SUCCESS;
         }
@@ -532,7 +531,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;
 
-                CommonPlacePicture(vd, &sys->area, &sys->sys);
+                CommonPlacePicture(vd, &sys->area);
                 UpdateSize(vd);
             }
         }
@@ -606,7 +605,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         uint32_t i_height;
         if (LocalSwapchainWinstoreSize( sys->outside_opaque, &i_width, &i_height ))
         {
-            if (i_width != sys->area.vdcfg.display.width || i_height != sys->area.vdcfg.display.height)
+            if (i_width != vd->cfg->display.width || i_height != vd->cfg->display.height)
                 vout_display_SetSize(vd, i_width, i_height);
         }
     }
@@ -729,7 +728,7 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_co
         sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
     }
 
-    CommonPlacePicture(vd, &sys->area, &sys->sys);
+    CommonPlacePicture(vd, &sys->area);
 
     err = UpdateDisplayFormat(vd, &fmt);
     if (err != VLC_SUCCESS) {
@@ -990,8 +989,8 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
 
     if ( vd->source->projection_mode == PROJECTION_MODE_EQUIRECTANGULAR ||
          vd->source->projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD )
-        D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &sys->area.vdcfg.viewpoint,
-                               (float) sys->area.vdcfg.display.width / sys->area.vdcfg.display.height );
+        D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &vd->cfg->viewpoint,
+                               (float) vd->cfg->display.width / vd->cfg->display.height );
 
     if (is_d3d11_opaque(fmt->i_chroma)) {
         ID3D10Multithread *pMultithread;
@@ -1118,8 +1117,8 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
              sys->picQuad.cropViewport[0].Width, sys->picQuad.cropViewport[0].Height );
 #endif
 
-    D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &sys->area.vdcfg.viewpoint,
-                          (float) sys->area.vdcfg.display.width / sys->area.vdcfg.display.height );
+    D3D11_UpdateViewpoint( vd, sys->d3d_dev, &sys->picQuad, &vd->cfg->viewpoint,
+                          (float) vd->cfg->display.width / vd->cfg->display.height );
 
     msg_Dbg(vd, "Direct3D11 resources created");
     return VLC_SUCCESS;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 60217fe3e5..2c25078919 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -499,8 +499,8 @@ static int UpdateOutput(vout_display_t *vd, const video_format_t *fmt,
 {
     vout_display_sys_t *sys = vd->sys;
     libvlc_video_render_cfg_t cfg;
-    cfg.width  = sys->area.vdcfg.display.width;
-    cfg.height = sys->area.vdcfg.display.height;
+    cfg.width  = vd->cfg->display.width;
+    cfg.height = vd->cfg->display.height;
 
     switch (fmt->i_chroma)
     {
@@ -1268,9 +1268,9 @@ static void Swap(vout_display_t *vd)
     // No stretching should happen here !
     RECT src = {
         .left   = 0,
-        .right  = sys->area.vdcfg.display.width,
+        .right  = vd->cfg->display.width,
         .top    = 0,
-        .bottom = sys->area.vdcfg.display.height
+        .bottom = vd->cfg->display.height
     };
 
     HRESULT hr;
@@ -1691,8 +1691,9 @@ static void Direct3D9Close(vout_display_t *vd)
 
 static int Control(vout_display_t *vd, int query, va_list args)
 {
+    VLC_UNUSED(args);
     vout_display_sys_t *sys = vd->sys;
-    return CommonControl(vd, &sys->area, &sys->sys, query, args);
+    return CommonControl(vd, &sys->area, &sys->sys, query);
 }
 
 typedef struct
@@ -1790,7 +1791,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     if (!sys)
         return VLC_ENOMEM;
 
-    CommonInit(&sys->area, cfg);
+    CommonInit(&sys->area);
 
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = var_InheritAddress( vd, "vout-cb-update-output" );
@@ -1838,7 +1839,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     }
 
     if (sys->swapCb == LocalSwapchainSwap)
-        CommonPlacePicture(vd, &sys->area, &sys->sys);
+        CommonPlacePicture(vd, &sys->area);
 
     sys->hxdll = Direct3D9LoadShaderLibrary();
     if (!sys->hxdll)
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index a0f486bffe..b88c994c48 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -81,7 +81,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
         return vout_display_opengl_SetViewpoint(sys->vgl,
                                                 va_arg(args, const vlc_viewpoint_t*));
 
-    return CommonControl(vd, &sys->area, &sys->sys, query, args);
+    return CommonControl(vd, &sys->area, &sys->sys, query);
 }
 
 static const struct vout_window_operations embedVideoWindow_Ops =
@@ -120,7 +120,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         return VLC_ENOMEM;
 
     /* */
-    CommonInit(&sys->area, cfg);
+    CommonInit(&sys->area);
     if (CommonWindowInit(vd, &sys->area, &sys->sys,
                    vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR))
         goto error;
@@ -208,7 +208,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         return;
     if (sys->area.place_changed)
     {
-        vout_display_cfg_t place_cfg = sys->area.vdcfg;
+        vout_display_cfg_t place_cfg = *vd->cfg;
         vout_display_place_t place;
 
         /* Reverse vertical alignment as the GL tex are Y inverted */
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index c1e39dc9f9..5ea9246b2a 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -99,14 +99,16 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 
 static int Control(vout_display_t *vd, int query, va_list args)
 {
+    VLC_UNUSED(args);
     vout_display_sys_t *sys = vd->sys;
-    return CommonControl(vd, &sys->area, &sys->sys, query, args);
+    return CommonControl(vd, &sys->area, &sys->sys, query);
 }
 
 /* */
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
+    VLC_UNUSED(context);
     vout_display_sys_t *sys;
 
     if ( !vd->obj.force && vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR)
@@ -116,7 +118,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     if (!sys)
         return VLC_ENOMEM;
 
-    CommonInit(&sys->area, cfg);
+    CommonInit(&sys->area);
     if (CommonWindowInit(vd, &sys->area, &sys->sys, false))
         goto error;
 
@@ -160,9 +162,9 @@ static void Display(vout_display_t *vd, picture_t *picture)
         /* clear the background */
         RECT display = {
             .left   = 0,
-            .right  = sys->area.vdcfg.display.width,
+            .right  = vd->cfg->display.width,
             .top    = 0,
-            .bottom = sys->area.vdcfg.display.height,
+            .bottom = vd->cfg->display.height,
         };
         FillRect(hdc, &display, GetStockObject(BLACK_BRUSH));
         sys->area.place_changed = false;



More information about the vlc-commits mailing list