[vlc-devel] [PATCH 12/20] vout: win32: use the placed picture dimensions from the core

Steve Lhomme robux4 at ycbcr.xyz
Tue Aug 25 09:30:00 CEST 2020


Don't keep a local copy of the display configuration.
---
 modules/video_output/win32/common.c     | 25 ++++++++++---------------
 modules/video_output/win32/common.h     |  6 ++----
 modules/video_output/win32/direct3d11.c | 18 +++++++++---------
 modules/video_output/win32/direct3d9.c  | 12 ++++++------
 modules/video_output/win32/glwin32.c    |  2 +-
 modules/video_output/win32/wingdi.c     |  6 +++---
 6 files changed, 31 insertions(+), 38 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 3b072e9074f..4a84c658370 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,10 +93,10 @@ 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_cfg_t place_cfg = *vd->cfg;
 
 #if (defined(MODULE_NAME_IS_glwin32))
     /* Reverse vertical alignment as the GL tex are Y inverted */
@@ -144,27 +143,23 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
     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 f6254b707bd..4df23573c2d 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)
@@ -73,9 +71,9 @@ 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 );
 
-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 0e79a50aeab..3ce14bb3681 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -213,8 +213,8 @@ static int QueryDisplayFormat(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)
     {
@@ -296,7 +296,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" );
@@ -468,7 +468,7 @@ static void SetQuadVSProjection(vout_display_t *vd, d3d_quad_t *quad, const vlc_
          f_fovx < -0.001f )
         return;
 
-    float f_sar = (float) sys->area.vdcfg.display.width / sys->area.vdcfg.display.height;
+    float f_sar = (float) vd->cfg->display.width / vd->cfg->display.height;
     float f_fovy = UpdateFOVy(f_fovx, f_sar);
     float f_z = UpdateZ(f_fovx, f_fovy);
 
@@ -615,7 +615,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);
             }
         }
@@ -689,7 +689,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);
         }
     }
@@ -812,7 +812,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 = QueryDisplayFormat(vd, &fmt);
     if (err != VLC_SUCCESS) {
@@ -987,7 +987,7 @@ static void UpdatePicQuadPosition(vout_display_t *vd)
 
     D3D11_UpdateViewport( &sys->picQuad, &rect_dst, sys->display.pixelFormat );
 
-    SetQuadVSProjection(vd, &sys->picQuad, &sys->area.vdcfg.viewpoint);
+    SetQuadVSProjection(vd, &sys->picQuad, &vd->cfg->viewpoint);
 
 #ifndef NDEBUG
     msg_Dbg( vd, "picQuad position (%.02f,%.02f) %.02fx%.02f",
@@ -1090,7 +1090,7 @@ 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 )
-        SetQuadVSProjection( vd, &sys->picQuad, &sys->area.vdcfg.viewpoint );
+        SetQuadVSProjection( vd, &sys->picQuad, &vd->cfg->viewpoint );
 
     if (is_d3d11_opaque(fmt->i_chroma)) {
         ID3D10Multithread *pMultithread;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index a750876a8a7..1b2ba2ff152 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -497,8 +497,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)
     {
@@ -1262,9 +1262,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;
@@ -1802,7 +1802,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" );
@@ -1850,7 +1850,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 efa771f036a..064aa4ce0aa 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -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;
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 6ba98d9a920..ef7655571b7 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -118,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;
 
@@ -162,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;
-- 
2.26.2



More information about the vlc-devel mailing list