[vlc-devel] [PATCH v2 16/19] vout: win32: use the placed picture dimensions from the core

Steve Lhomme robux4 at ycbcr.xyz
Tue Aug 25 16:20:29 CEST 2020


Only the glwin32 module needs to compute a different placement than the core.

No need to keep our own anymore. It's always updated for us.
---
 modules/video_output/win32/common.c     | 12 ++--------
 modules/video_output/win32/common.h     |  5 +----
 modules/video_output/win32/direct3d11.c | 30 ++++++++++++-------------
 modules/video_output/win32/direct3d9.c  | 22 +++++++++---------
 modules/video_output/win32/glwin32.c    | 10 +++++----
 modules/video_output/win32/wingdi.c     | 14 ++++++------
 6 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index b2ad670d0c3..64f635cb578 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, enum vout_place_origin origin)
+void CommonInit(display_win32_area_t *area)
 {
     area->place_changed = false;
-    area->origin = origin;
 }
 
 #if !VLC_WINSTORE_APP
@@ -97,13 +96,6 @@ int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
 void CommonPlacePicture(vout_display_t *vd, display_win32_area_t *area)
 {
     /* Update the window position and size */
-    vout_display_cfg_t place_cfg = *vd->cfg;
-
-    vout_display_place_t before_place = area->place;
-    vout_display_PlacePicture(&area->place, &vd->source, &place_cfg, area->origin);
-
-    /* Signal the change in size/position */
-    if (!vout_display_PlaceEquals(&before_place, &area->place))
     {
         area->place_changed |= true;
 
@@ -113,7 +105,7 @@ void CommonPlacePicture(vout_display_t *vd, display_win32_area_t *area)
             vd->source.i_visible_width, vd->source.i_visible_height,
             vd->source.i_width, vd->source.i_height);
         msg_Dbg(vd, "UpdateRects image_dst coords: %i,%i %ix%i",
-            area->place.x, area->place.y, area->place.width, area->place.height);
+            vd->place->x, vd->place->y, vd->place->width, vd->place->height);
 #endif
     }
 }
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 639b459e076..c741bdecf83 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -32,10 +32,7 @@ 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;
-    enum vout_place_origin origin;
 } display_win32_area_t;
 
 #define RECTWidth(r)   (LONG)((r).right - (r).left)
@@ -74,7 +71,7 @@ int  CommonControl(vout_display_t *, display_win32_area_t *, vout_display_sys_wi
 
 void CommonPlacePicture (vout_display_t *, display_win32_area_t *);
 
-void CommonInit(display_win32_area_t *, enum vout_place_origin origin);
+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 54848fc6fbe..3eae603ded8 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -264,8 +264,8 @@ static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
 static void UpdateSize(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
-    msg_Dbg(vd, "Detected size change %dx%d", sys->area.place.width,
-            sys->area.place.height);
+    msg_Dbg(vd, "Detected size change %dx%d", vd->place->width,
+            vd->place->height);
 
     QueryDisplayFormat(vd, &vd->fmt);
 
@@ -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, VOUT_ORIGIN_TOP_LEFT);
+    CommonInit(&sys->area);
 
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = var_InheritAddress( vd, "vout-cb-update-output" );
@@ -979,10 +979,10 @@ static void UpdatePicQuadPosition(vout_display_t *vd)
     vout_display_sys_t *sys = vd->sys;
 
     RECT rect_dst = {
-        .left   = sys->area.place.x,
-        .right  = sys->area.place.x + sys->area.place.width,
-        .top    = sys->area.place.y,
-        .bottom = sys->area.place.y + sys->area.place.height
+        .left   = vd->place->x,
+        .right  = vd->place->x + vd->place->width,
+        .top    = vd->place->y,
+        .bottom = vd->place->y + vd->place->height
     };
 
     D3D11_UpdateViewport( &sys->picQuad, &rect_dst, sys->display.pixelFormat );
@@ -1388,10 +1388,10 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
         d3d_quad_t *quad = (d3d_quad_t *) quad_picture->p_sys;
 
         RECT spuViewport;
-        spuViewport.left   = (FLOAT) r->i_x * sys->area.place.width  / subpicture->i_original_picture_width;
-        spuViewport.top    = (FLOAT) r->i_y * sys->area.place.height / subpicture->i_original_picture_height;
-        spuViewport.right  = (FLOAT) (r->i_x + r->fmt.i_visible_width)  * sys->area.place.width  / subpicture->i_original_picture_width;
-        spuViewport.bottom = (FLOAT) (r->i_y + r->fmt.i_visible_height) * sys->area.place.height / subpicture->i_original_picture_height;
+        spuViewport.left   = (FLOAT) r->i_x * vd->place->width  / subpicture->i_original_picture_width;
+        spuViewport.top    = (FLOAT) r->i_y * vd->place->height / subpicture->i_original_picture_height;
+        spuViewport.right  = (FLOAT) (r->i_x + r->fmt.i_visible_width)  * vd->place->width  / subpicture->i_original_picture_width;
+        spuViewport.bottom = (FLOAT) (r->i_y + r->fmt.i_visible_height) * vd->place->height / subpicture->i_original_picture_height;
 
         if (r->zoom_h.num != 0 && r->zoom_h.den != 0)
         {
@@ -1405,10 +1405,10 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
         }
 
         /* move the SPU inside the video area */
-        spuViewport.left   += sys->area.place.x;
-        spuViewport.right  += sys->area.place.x;
-        spuViewport.top    += sys->area.place.y;
-        spuViewport.bottom += sys->area.place.y;
+        spuViewport.left   += vd->place->x;
+        spuViewport.right  += vd->place->x;
+        spuViewport.top    += vd->place->y;
+        spuViewport.bottom += vd->place->y;
 
         D3D11_UpdateViewport( quad, &spuViewport, sys->display.pixelFormat );
 
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 1c2dc79fc0d..7ee3c24fe04 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -416,10 +416,10 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
         .bottom = vd->source.i_height,
     };
     RECT rect_in_display = {
-        .left   = sys->area.place.x,
-        .right  = sys->area.place.x + sys->area.place.width,
-        .top    = sys->area.place.y,
-        .bottom = sys->area.place.y + sys->area.place.height,
+        .left   = vd->place->x,
+        .right  = vd->place->x + vd->place->width,
+        .top    = vd->place->y,
+        .bottom = vd->place->y + vd->place->height,
     };
     RECT texture_visible_rect = {
         .left   = 0,
@@ -980,8 +980,8 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
         }
 
         /* Map the subpicture to sys->sys.sys.place */
-        const float scale_w = (float)(sys->area.place.width)  / subpicture->i_original_picture_width;
-        const float scale_h = (float)(sys->area.place.height) / subpicture->i_original_picture_height;
+        const float scale_w = (float)(vd->place->width)  / subpicture->i_original_picture_width;
+        const float scale_h = (float)(vd->place->height) / subpicture->i_original_picture_height;
 
         RECT rect_in_display;
         rect_in_display.left   =            scale_w * r->i_x,
@@ -989,10 +989,10 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
         rect_in_display.top    =            scale_h * r->i_y,
         rect_in_display.bottom = rect_in_display.top  + scale_h * r->fmt.i_visible_height;
 
-        rect_in_display.left   += sys->area.place.x;
-        rect_in_display.right  += sys->area.place.x;
-        rect_in_display.top    += sys->area.place.y;
-        rect_in_display.bottom += sys->area.place.y;
+        rect_in_display.left   += vd->place->x;
+        rect_in_display.right  += vd->place->x;
+        rect_in_display.top    += vd->place->y;
+        rect_in_display.bottom += vd->place->y;
 
         RECT texture_rect;
         texture_rect.left   = 0;
@@ -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, VOUT_ORIGIN_TOP_LEFT);
+    CommonInit(&sys->area);
 
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = var_InheritAddress( vd, "vout-cb-update-output" );
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index fb9e7791431..dc8b746472c 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, VOUT_ORIGIN_BOTTOM_LEFT);
+    CommonInit(&sys->area);
     if (CommonWindowInit(vd, &sys->area, &sys->sys,
                    vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR))
         goto error;
@@ -211,11 +211,13 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         return;
     if (sys->area.place_changed)
     {
-        const int width  = sys->area.place.width;
-        const int height = sys->area.place.height;
+        vout_display_place_t place;
+        vout_display_PlacePicture(&place, &vd->source, vd->cfg, VOUT_ORIGIN_BOTTOM_LEFT);
+        const int width  = place.width;
+        const int height = place.height;
         vlc_gl_Resize (sys->gl, width, height);
         vout_display_opengl_SetWindowAspectRatio(sys->vgl, (float)width / height);
-        vout_display_opengl_Viewport(sys->vgl, sys->area.place.x, sys->area.place.y, width, height);
+        vout_display_opengl_Viewport(sys->vgl, place.x, place.y, width, height);
         sys->area.place_changed = false;
     }
     vout_display_opengl_Prepare (sys->vgl, picture, subpicture);
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 82b9b5fd5b5..38cefe0de59 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, VOUT_ORIGIN_TOP_LEFT);
+    CommonInit(&sys->area);
     if (CommonWindowInit(vd, &sys->area, &sys->sys, false))
         goto error;
 
@@ -172,20 +172,20 @@ static void Display(vout_display_t *vd, picture_t *picture)
 
     SelectObject(sys->off_dc, sys->off_bitmap);
 
-    if (sys->area.place.width  != vd->source.i_visible_width ||
-        sys->area.place.height != vd->source.i_visible_height) {
+    if (vd->place->width  != vd->source.i_visible_width ||
+        vd->place->height != vd->source.i_visible_height) {
         SetStretchBltMode(hdc, COLORONCOLOR);
 
-        StretchBlt(hdc, sys->area.place.x, sys->area.place.y,
-                   sys->area.place.width, sys->area.place.height,
+        StretchBlt(hdc, vd->place->x, vd->place->y,
+                   vd->place->width, vd->place->height,
                    sys->off_dc,
                    vd->source.i_x_offset, vd->source.i_y_offset,
                    vd->source.i_x_offset + vd->source.i_visible_width,
                    vd->source.i_y_offset + vd->source.i_visible_height,
                    SRCCOPY);
     } else {
-        BitBlt(hdc, sys->area.place.x, sys->area.place.y,
-               sys->area.place.width, sys->area.place.height,
+        BitBlt(hdc, vd->place->x, vd->place->y,
+               vd->place->width, vd->place->height,
                sys->off_dc,
                vd->source.i_x_offset, vd->source.i_y_offset,
                SRCCOPY);
-- 
2.26.2



More information about the vlc-devel mailing list