[vlc-commits] [Git][videolan/vlc][master] 22 commits: vout/win32: assume the video placement changed on VOUT_DISPLAY_CHANGE_SOURCE_PLACE

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Jan 20 12:24:51 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a91b4a00 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: assume the video placement changed on VOUT_DISPLAY_CHANGE_SOURCE_PLACE

- - - - -
fb945883 by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d11: always assume the placement has been used in UpdateSize

- - - - -
3e852cf2 by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d11: don't update the placement when padding size changes

The placement only uses the visible parts of the video, so it makes no difference.

- - - - -
238acb6a by Steve Lhomme at 2025-01-20T12:12:36+00:00
d3d11_scaler: use already placed video

It should not have to know how to place picture.

The external placement is always on the output size anyway.

- - - - -
7b1c9747 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: use a function to handle display size changes

We don't need to place the picture, we will receive a
VOUT_DISPLAY_CHANGE_SOURCE_PLACE if needed.

- - - - -
c015e19f by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d9: move the CommonControl() inline

- - - - -
9d137dbb by Steve Lhomme at 2025-01-20T12:12:36+00:00
wingdi: move the CommonControl() inline

- - - - -
0d25cef0 by Steve Lhomme at 2025-01-20T12:12:36+00:00
glwin32: move the CommonControl() inline

- - - - -
d6d89cc0 by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d11: move the CommonControl() inline

- - - - -
6c911fe8 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: remove unused CommonControl()

- - - - -
92018c23 by Steve Lhomme at 2025-01-20T12:12:36+00:00
glwin32: don't compute local placement

It's already computed by the core.

- - - - -
70b497ed by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d9: use already computed placement

Our computed placement was always the same as the core.

We don't need special control handling about from the internal window resizing.

- - - - -
7e410c15 by Steve Lhomme at 2025-01-20T12:12:36+00:00
wingdi: use already computed placement

Our computed placement was always the same as the core.

We don't need special control handling about from the internal window resizing.

- - - - -
b6cc36e8 by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d11: do the picture placement locally

We may not have to do it all the time.

The code is equivalent, minus the log for each placement change detected.

- - - - -
ca5259fd by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: remove unused CommonPlacePicture()

- - - - -
96a86a67 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: remove always NULL parameter

- - - - -
cad5bb0d by Steve Lhomme at 2025-01-20T12:12:36+00:00
direct3d11: use a video placement for upscaled pictures

Otherwise we use the already computed placement.

- - - - -
5d14f7e7 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: remove unused code/parameters

- - - - -
87cda50c by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: handle the placement changed flag locally

There is no common code using it.

- - - - -
42ddc2a8 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: remove display_win32_area_t common structure

We only need to deal with a event_thread_t.

- - - - -
fa571bb5 by Steve Lhomme at 2025-01-20T12:12:36+00:00
vout/win32: only compile common.c for desktop Windows

It's a gateway to the private events.c API for HWND.

- - - - -
abd96b82 by Steve Lhomme at 2025-01-20T12:12:36+00:00
wingdi: split the placement and window size actions

We only need to refesh the background when the size changes.

- - - - -


10 changed files:

- modules/video_output/Makefile.am
- modules/video_output/win32/common.c
- modules/video_output/win32/common.h
- modules/video_output/win32/d3d11_scaler.cpp
- modules/video_output/win32/d3d11_scaler.h
- modules/video_output/win32/direct3d11.cpp
- modules/video_output/win32/direct3d9.c
- modules/video_output/win32/glwin32.c
- modules/video_output/win32/meson.build
- modules/video_output/win32/wingdi.c


Changes:

=====================================
modules/video_output/Makefile.am
=====================================
@@ -217,8 +217,7 @@ libdirect3d11_plugin_la_SOURCES = video_output/win32/direct3d11.cpp \
  video_output/win32/d3d11_shaders.cpp video_output/win32/d3d11_shaders.h \
  video_output/win32/d3d11_tonemap.cpp video_output/win32/d3d11_tonemap.h \
  video_output/win32/d3d_shaders.c video_output/win32/d3d_shaders.h \
- video_output/win32/d3d_dynamic_shader.c video_output/win32/d3d_dynamic_shader.h \
- video_output/win32/common.c video_output/win32/common.h
+ video_output/win32/d3d_dynamic_shader.c video_output/win32/d3d_dynamic_shader.h
 libdirect3d11_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
 libdirect3d11_plugin_la_LIBADD = libchroma_copy.la libd3d11_common.la $(LIBCOM) -luuid -ldxgi -ld3d11
 libdirect3d11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
@@ -226,6 +225,7 @@ if !HAVE_WINSTORE
 libdirect3d11_plugin_la_CPPFLAGS += -DHAVE_WIN32_SENSORS
 libdirect3d11_plugin_la_SOURCES += video_output/win32/events.c \
  video_output/win32/events.h \
+ video_output/win32/common.c video_output/win32/common.h \
  video_output/win32/d3d11_swapchain.cpp video_output/win32/d3d11_swapchain.h \
  video_output/win32/dxgi_swapchain.cpp video_output/win32/dxgi_swapchain.h \
  video_output/win32/sensors.cpp \


=====================================
modules/video_output/win32/common.c
=====================================
@@ -41,93 +41,40 @@
 #include "common.h"
 #include "../../video_chroma/copy.h"
 
-void CommonInit(display_win32_area_t *area, const video_format_t *src_fmt)
-{
-    ZeroMemory(&area->place, sizeof(area->place));
-    area->place_changed = false;
-    area->src_fmt = src_fmt;
-}
-
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
 /* */
-int CommonWindowInit(vout_display_t *vd, display_win32_area_t *area,
+int CommonWindowInit(vout_display_t *vd, struct event_thread_t **event,
                      bool projection_gestures)
 {
+    *event = NULL;
     if (unlikely(vd->cfg->window == NULL))
         return VLC_EGENERIC;
 
     /* */
-    area->event = EventThreadCreate(VLC_OBJECT(vd), vd->cfg->window,
-                                    &vd->cfg->display,
-                                    projection_gestures ? &vd->owner : NULL);
-    if (!area->event)
+    *event = EventThreadCreate(VLC_OBJECT(vd), vd->cfg->window,
+                               &vd->cfg->display,
+                               projection_gestures ? &vd->owner : NULL);
+    if (!*event)
         return VLC_EGENERIC;
 
     return VLC_SUCCESS;
 }
 
-HWND CommonVideoHWND(const display_win32_area_t *area)
-{
-    return EventThreadVideoHWND(area->event);
-}
-#endif /* WINAPI_PARTITION_DESKTOP */
-
-/*****************************************************************************
-* UpdateRects: update clipping rectangles
-*****************************************************************************
-* This function is called when the window position or size are changed, and
-* 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)
+HWND CommonVideoHWND(const struct event_thread_t *event)
 {
-    /* Update the window position and size */
-    vout_display_place_t before_place = area->place;
-    vout_display_PlacePicture(&area->place, area->src_fmt, &vd->cfg->display);
-
-    /* Signal the change in size/position */
-    if (!vout_display_PlaceEquals(&before_place, &area->place))
-    {
-        area->place_changed |= true;
-
-#ifndef NDEBUG
-        msg_Dbg(vd, "UpdateRects source offset: %i,%i visible: %ix%i decoded: %ix%i",
-            area->src_fmt->i_x_offset, area->src_fmt->i_y_offset,
-            area->src_fmt->i_visible_width, area->src_fmt->i_visible_height,
-            area->src_fmt->i_width, area->src_fmt->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);
-#endif
-    }
+    return EventThreadVideoHWND(event);
 }
 
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
 /* */
-void CommonWindowClean(display_win32_area_t *sys)
+void CommonWindowClean(struct event_thread_t *event)
 {
-    EventThreadDestroy(sys->event);
+    EventThreadDestroy(event);
 }
-#endif /* WINAPI_PARTITION_DESKTOP */
 
-void CommonControl(vout_display_t *vd, display_win32_area_t *area, int query)
+void CommonDisplaySizeChanged(struct event_thread_t *event)
 {
-    switch (query) {
-    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-        // Update dimensions
-        if (area->event != NULL)
-        {
-            EventThreadUpdateSize(area->event);
-        }
-#endif /* WINAPI_PARTITION_DESKTOP */
-        // fallthrough
-    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
-    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
-    case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
-        CommonPlacePicture(vd, area);
-        break;
-
-    default:
-        vlc_assert_unreachable();
+    // Update dimensions
+    if (event != NULL)
+    {
+        EventThreadUpdateSize(event);
     }
 }


=====================================
modules/video_output/win32/common.h
=====================================
@@ -30,37 +30,21 @@
 extern "C" {
 #endif// __cplusplus
 
-/*****************************************************************************
- * event_thread_t: event thread
- *****************************************************************************/
-
-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
-
-    const video_format_t  *src_fmt;
-} display_win32_area_t;
-
 #define RECTWidth(r)   (LONG)((r).right - (r).left)
 #define RECTHeight(r)  (LONG)((r).bottom - (r).top)
 
+struct event_thread_t;
+
 /*****************************************************************************
- * Prototypes from common.c
+ * event_thread_t: event thread
  *****************************************************************************/
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-int  CommonWindowInit(vout_display_t *, display_win32_area_t *,
-                      bool projection_gestures);
-void CommonWindowClean(display_win32_area_t *);
-HWND CommonVideoHWND(const display_win32_area_t *);
-#endif /* WINAPI_PARTITION_DESKTOP */
-void CommonControl(vout_display_t *, display_win32_area_t *, int );
 
-void CommonPlacePicture (vout_display_t *, display_win32_area_t *);
+int  CommonWindowInit(vout_display_t *, struct event_thread_t **,
+                      bool projection_gestures);
+void CommonWindowClean(struct event_thread_t *);
+HWND CommonVideoHWND(const struct event_thread_t *);
+void CommonDisplaySizeChanged(struct event_thread_t *);
 
-void CommonInit(display_win32_area_t *, const video_format_t *);
 # ifdef __cplusplus
 }
 # endif


=====================================
modules/video_output/win32/d3d11_scaler.cpp
=====================================
@@ -232,7 +232,8 @@ static void ReleaseSRVs(d3d11_scaler *scaleProc)
 
 int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device_t*d3d_dev,
                          const video_format_t *fmt, video_format_t *quad_fmt,
-                         const vout_display_placement *cfg)
+                         unsigned display_width, unsigned display_height,
+                         const vout_display_place_t *video_place)
 {
     HRESULT hr;
     ID3D11Texture2D *_upscaled[DXGI_MAX_SHADER_VIEW];
@@ -242,14 +243,9 @@ int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device
     black.RGBA.A = 1.f;
     bool upscale = false;
 
-    vout_display_place_t place{};
-    auto display = *cfg;
-    display.fitting = VLC_VIDEO_FIT_SMALLER;
-    vout_display_PlacePicture(&place, fmt, &display);
-
     unsigned out_width, out_height;
-    out_width  = (display.width + (scaleProc->d3d_fmt->widthDenominator-1)) & ~(scaleProc->d3d_fmt->widthDenominator-1);
-    out_height = (display.height + (scaleProc->d3d_fmt->heightDenominator-1)) & ~(scaleProc->d3d_fmt->heightDenominator-1);
+    out_width  = (display_width + (scaleProc->d3d_fmt->widthDenominator-1)) & ~(scaleProc->d3d_fmt->widthDenominator-1);
+    out_height = (display_height + (scaleProc->d3d_fmt->heightDenominator-1)) & ~(scaleProc->d3d_fmt->heightDenominator-1);
 
     quad_fmt->i_x_offset = 0;
     quad_fmt->i_width = quad_fmt->i_visible_width = out_width;
@@ -259,10 +255,10 @@ int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device
     quad_fmt->i_sar_den = 1;
 
     if (scaleProc->Width == out_width && scaleProc->Height == out_height &&
-        vout_display_PlaceEquals(&scaleProc->place, &place))
+        vout_display_PlaceEquals(&scaleProc->place, video_place))
         // do nothing
         return VLC_SUCCESS;
-    scaleProc->place = place;
+    scaleProc->place = *video_place;
 
     scaleProc->usable = false;
 
@@ -439,10 +435,10 @@ int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device
     srcRect.bottom = srcRect.top  + fmt->i_visible_height;
 
     RECT dstRect;
-    dstRect.left   = place.x;
-    dstRect.top    = place.y;
-    dstRect.right  = dstRect.left + place.width;
-    dstRect.bottom = dstRect.top  + place.height;
+    dstRect.left   = video_place->x;
+    dstRect.top    = video_place->y;
+    dstRect.right  = dstRect.left + video_place->width;
+    dstRect.bottom = dstRect.top  + video_place->height;
 
     d3d11_device_lock(d3d_dev);
     scaleProc->d3dvidctx->VideoProcessorSetStreamSourceRect(scaleProc->processor.Get(),
@@ -457,8 +453,8 @@ int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device
     if (scaleProc->super_res)
     {
         // only use super resolution when source is smaller than display
-        upscale = fmt->i_visible_width < place.width
-               || fmt->i_visible_height < place.height;
+        upscale = fmt->i_visible_width < video_place->width
+               || fmt->i_visible_height < video_place->height;
 
         if (d3d_dev->adapterDesc.VendorId == GPU_MANUFACTURER_NVIDIA)
         {


=====================================
modules/video_output/win32/d3d11_scaler.h
=====================================
@@ -24,7 +24,8 @@ struct d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *, d3d11_device_t*, vlc_f
 void D3D11_UpscalerDestroy(struct d3d11_scaler *);
 int D3D11_UpscalerUpdate(vlc_object_t *, struct d3d11_scaler *, d3d11_device_t*,
                          const video_format_t *, video_format_t *,
-                         const vout_display_placement *);
+                         unsigned display_width, unsigned display_height,
+                         const vout_display_place_t *);
 int D3D11_UpscalerScale(vlc_object_t *, struct d3d11_scaler *, picture_sys_d3d11_t *);
 bool D3D11_UpscalerUsed(const struct d3d11_scaler *);
 void D3D11_UpscalerGetSRV(const struct d3d11_scaler *, ID3D11ShaderResourceView *SRV[DXGI_MAX_SHADER_VIEW]);


=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -49,9 +49,9 @@
 #include "d3d11_tonemap.h"
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
 #include "d3d11_swapchain.h"
+#include "common.h"
 #endif
 
-#include "common.h"
 #include "../../video_chroma/copy.h"
 
 #include <dxgi1_6.h>
@@ -119,7 +119,10 @@ enum d3d11_hdr
 
 typedef struct vout_display_sys_t
 {
-    display_win32_area_t     area = {};
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+    struct event_thread_t    *video_wnd = nullptr;
+#endif
+    bool                     place_changed = false;
 
     int                      log_level = 1;
 
@@ -166,6 +169,7 @@ typedef struct vout_display_sys_t
     // upscaling
     enum d3d11_upscale       upscaleMode = upscale_LinearSampler;
     d3d11_scaler             *scaleProc = nullptr;
+    vout_display_place_t     scalePlace;
 
     // HDR mode
     enum d3d11_hdr           hdrMode = hdr_Auto;
@@ -266,7 +270,9 @@ static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
     if (sys->upscaleMode == upscale_VideoProcessor || sys->upscaleMode == upscale_SuperResolution)
     {
         D3D11_UpscalerUpdate(VLC_OBJECT(vd), sys->scaleProc, sys->d3d_dev,
-                             vd->source, &sys->picQuad.quad_fmt, &vd->cfg->display);
+                             vd->source, &sys->picQuad.quad_fmt,
+                             vd->cfg->display.width, vd->cfg->display.height,
+                             vd->place);
 
         if (D3D11_UpscalerUsed(sys->scaleProc))
         {
@@ -280,7 +286,12 @@ static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
             sys->picQuad.generic.i_width = sys->picQuad.quad_fmt.i_width;
             sys->picQuad.generic.i_height = sys->picQuad.quad_fmt.i_height;
 
-            CommonPlacePicture(vd, &sys->area);
+            vout_display_place_t before_place = sys->scalePlace;
+            sys->scalePlace.x = 0;
+            sys->scalePlace.y = 0;
+            sys->scalePlace.width = sys->picQuad.quad_fmt.i_width;
+            sys->scalePlace.height = sys->picQuad.quad_fmt.i_height;
+            sys->place_changed |= !vout_display_PlaceEquals(&before_place, &sys->scalePlace);
         }
     }
 
@@ -337,12 +348,17 @@ static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
 static void UpdateSize(vout_display_t *vd)
 {
     vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(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->cfg->display.width,
+            vd->cfg->display.height);
 
     UpdateDisplayFormat(vd, vd->fmt);
 
-    sys->picQuad.UpdateViewport( &sys->area.place, sys->display.pixelFormat );
+    const vout_display_place_t *quad_place;
+    if (sys->scaleProc && D3D11_UpscalerUsed(sys->scaleProc))
+        quad_place = &sys->scalePlace;
+    else
+        quad_place = vd->place;
+    sys->picQuad.UpdateViewport( quad_place, sys->display.pixelFormat );
 
     d3d11_device_lock( sys->d3d_dev );
 
@@ -354,6 +370,8 @@ static void UpdateSize(vout_display_t *vd)
 
     d3d11_device_unlock( sys->d3d_dev );
 
+    sys->place_changed = false;
+
 #ifndef NDEBUG
     msg_Dbg( vd, "picQuad position (%.02f,%.02f) %.02fx%.02f",
              sys->picQuad.cropViewport[0].TopLeftX, sys->picQuad.cropViewport[0].TopLeftY,
@@ -530,8 +548,6 @@ static int Open(vout_display_t *vd,
     if (ret != VLC_SUCCESS)
         goto error;
 
-    CommonInit(&sys->area, &sys->picQuad.quad_fmt);
-
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = (libvlc_video_update_output_cb)var_InheritAddress( vd, "vout-cb-update-output" );
     sys->swapCb              = (libvlc_video_swap_cb)var_InheritAddress( vd, "vout-cb-swap" );
@@ -563,7 +579,7 @@ static int Open(vout_display_t *vd,
 #else // WINAPI_PARTITION_DESKTOP
         if (vd->cfg->window->type == VLC_WINDOW_TYPE_HWND)
         {
-            if (CommonWindowInit(vd, &sys->area,
+            if (CommonWindowInit(vd, &sys->video_wnd,
                        sys->projection_mode != PROJECTION_MODE_RECTANGULAR))
                 goto error;
         }
@@ -575,7 +591,7 @@ static int Open(vout_display_t *vd,
                                                         vd->cfg->window->display.dcomp_device,
                                                         vd->cfg->window->handle.dcomp_visual);
         else
-            swap = DXGI_CreateLocalSwapchainHandleHwnd(VLC_OBJECT(vd), CommonVideoHWND(&sys->area));
+            swap = DXGI_CreateLocalSwapchainHandleHwnd(VLC_OBJECT(vd), CommonVideoHWND(sys->video_wnd));
         if (unlikely(swap == NULL))
             goto error;
 
@@ -629,7 +645,7 @@ static void Close(vout_display_t *vd)
     vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
     D3D_ReleaseShaderCompiler(sys->shaders);
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-    CommonWindowClean(&sys->area);
+    CommonWindowClean(sys->video_wnd);
 #endif
     Direct3D11Close(vd);
     delete sys;
@@ -642,7 +658,9 @@ static int Control(vout_display_t *vd, int query)
     if (sys->upscaleMode == upscale_VideoProcessor || sys->upscaleMode == upscale_SuperResolution)
     {
         D3D11_UpscalerUpdate(VLC_OBJECT(vd), sys->scaleProc, sys->d3d_dev,
-                             vd->source, &sys->picQuad.quad_fmt, &vd->cfg->display);
+                             vd->source, &sys->picQuad.quad_fmt,
+                             vd->cfg->display.width, vd->cfg->display.height,
+                             vd->place);
 
         if (sys->scaleProc && D3D11_UpscalerUsed(sys->scaleProc))
         {
@@ -670,12 +688,32 @@ static int Control(vout_display_t *vd, int query)
         sys->picQuad.quad_fmt.i_visible_height = vd->source->i_visible_height;
     }
 
-    CommonControl( vd, &sys->area, query );
+    switch (query) {
+    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+        CommonDisplaySizeChanged(sys->video_wnd);
+#endif /* WINAPI_PARTITION_DESKTOP */
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
+        sys->place_changed = true;
+        // fallthrough
+    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
+    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
+    if (use_scaler)
+    {
+        vout_display_place_t before_place = sys->scalePlace;
+        sys->scalePlace.x = 0;
+        sys->scalePlace.y = 0;
+        sys->scalePlace.width = sys->picQuad.quad_fmt.i_width;
+        sys->scalePlace.height = sys->picQuad.quad_fmt.i_height;
+        sys->place_changed |= !vout_display_PlaceEquals(&before_place, &sys->scalePlace);
+        break;
+    }
+    }
 
-    if ( sys->area.place_changed )
+    if ( sys->place_changed )
     {
         UpdateSize(vd);
-        sys->area.place_changed =false;
     }
 
     return VLC_SUCCESS;
@@ -863,7 +901,6 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture,
                 sys->picQuad.generic.i_width  = sys->picQuad.quad_fmt.i_width;
                 sys->picQuad.generic.i_height = sys->picQuad.quad_fmt.i_height;
 
-                CommonPlacePicture(vd, &sys->area);
                 UpdateSize(vd);
             }
         }
@@ -1108,7 +1145,11 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_co
 
     InitScaleProcessor(vd);
 
-    CommonPlacePicture(vd, &sys->area);
+    sys->scalePlace.x = 0;
+    sys->scalePlace.y = 0;
+    sys->scalePlace.width = vd->cfg->display.width;
+    sys->scalePlace.height = vd->cfg->display.height;
+    sys->place_changed = true;
 
     err = UpdateDisplayFormat(vd, &sys->picQuad.quad_fmt);
     if (err != VLC_SUCCESS) {
@@ -1551,7 +1592,12 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
       return VLC_EGENERIC;
     }
 
-    sys->picQuad.UpdateViewport( &sys->area.place, sys->display.pixelFormat );
+    const vout_display_place_t *quad_place;
+    if (sys->scaleProc && D3D11_UpscalerUsed(sys->scaleProc))
+        quad_place = &sys->scalePlace;
+    else
+        quad_place = vd->place;
+    sys->picQuad.UpdateViewport( quad_place, sys->display.pixelFormat );
 
 #ifndef NDEBUG
     msg_Dbg( vd, "picQuad position (%.02f,%.02f) %.02fx%.02f",


=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -119,7 +119,8 @@ static const vlc_fourcc_t d3d_subpicture_chromas[] = {
 
 typedef struct vout_display_sys_t
 {
-    display_win32_area_t     area;
+    struct event_thread_t    *video_wnd;
+    bool                     place_changed;
 
     bool allow_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
 
@@ -413,7 +414,7 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
     /* */
     region->texture = sys->sceneTexture;
     Direct3D9SetupVertices(region->vertex, &texture_visible_rect, vd->source,
-                           &sys->area.place, 255, vd->source->orientation);
+                           vd->place, 255, vd->source->orientation);
     return VLC_SUCCESS;
 }
 
@@ -1107,12 +1108,12 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
     vout_display_sys_t *sys = vd->sys;
 
     /* Position Change */
-    if (sys->area.place_changed) {
+    if (sys->place_changed) {
 #if 0 /* need that when bicubic filter is available */
         RECT rect;
         UINT width, height;
 
-        GetClientRect(CommonVideoHWND(&sys->area), &rect);
+        GetClientRect(CommonVideoHWND(sys->video_wnd), &rect);
         width  = RECTWidth(rect);
         height = RECTHeight(rect);
 
@@ -1127,7 +1128,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         UpdateOutput(vd, vd->fmt, NULL);
 
         sys->clear_scene = true;
-        sys->area.place_changed = false;
+        sys->place_changed = false;
     }
 
     d3d9_device_t *p_d3d9_dev = &sys->d3d9_device->d3ddev;
@@ -1241,9 +1242,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->area), NULL, 0);
+        hr = IDirect3DDevice9Ex_PresentEx(p_d3d9_dev->devex, &src, &src, CommonVideoHWND(sys->video_wnd), NULL, 0);
     } else {
-        hr = IDirect3DDevice9_Present(p_d3d9_dev->dev, &src, &src, CommonVideoHWND(&sys->area), NULL);
+        hr = IDirect3DDevice9_Present(p_d3d9_dev->dev, &src, &src, CommonVideoHWND(sys->video_wnd), NULL);
     }
     if (FAILED(hr)) {
         msg_Dbg(vd, "Failed Present: 0x%lX", hr);
@@ -1663,7 +1664,17 @@ 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, query);
+    switch (query) {
+    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+        CommonDisplaySizeChanged(sys->video_wnd);
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
+        sys->place_changed = true;
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
+    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
+        break;
+    }
     return VLC_SUCCESS;
 }
 
@@ -1759,7 +1770,8 @@ static int Open(vout_display_t *vd,
     if (!sys)
         return VLC_ENOMEM;
 
-    CommonInit(&sys->area, vd->source);
+    sys->place_changed = false;
+    sys->video_wnd = NULL;
 
     sys->outside_opaque = var_InheritAddress( vd, "vout-cb-opaque" );
     sys->updateOutputCb      = var_InheritAddress( vd, "vout-cb-update-output" );
@@ -1769,7 +1781,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, false))
+        if (CommonWindowInit(vd, &sys->video_wnd, false))
             goto error;
 
         sys->outside_opaque = vd;
@@ -1778,8 +1790,6 @@ static int Open(vout_display_t *vd,
         sys->startEndRenderingCb = NULL;
     }
 
-    CommonPlacePicture(vd, &sys->area);
-
     sys->dec_device = context ? vlc_video_context_HoldDevice(context) : NULL;
     sys->d3d9_device = GetD3D9OpaqueDevice(sys->dec_device);
     if ( sys->d3d9_device == NULL )
@@ -1846,7 +1856,7 @@ static int Open(vout_display_t *vd,
     return VLC_SUCCESS;
 error:
     Direct3D9Close(vd);
-    CommonWindowClean(&sys->area);
+    CommonWindowClean(sys->video_wnd);
     Direct3D9Destroy(sys);
     free(vd->sys);
     return VLC_EGENERIC;
@@ -1861,7 +1871,7 @@ static void Close(vout_display_t *vd)
 
     Direct3D9Close(vd);
 
-    CommonWindowClean(&sys->area);
+    CommonWindowClean(sys->video_wnd);
 
     Direct3D9Destroy(sys);
 


=====================================
modules/video_output/win32/glwin32.c
=====================================
@@ -62,7 +62,8 @@ vlc_module_end()
  *****************************************************************************/
 typedef struct vout_display_sys_t
 {
-    display_win32_area_t     area;
+    struct event_thread_t    *video_wnd;
+    bool                     place_changed;
 
     vlc_gl_t              *gl;
     vout_display_opengl_t *vgl;
@@ -85,7 +86,17 @@ 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, query);
+    switch (query) {
+    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+        CommonDisplaySizeChanged(sys->video_wnd);
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
+        sys->place_changed = true;
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
+    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
+        break;
+    }
     return VLC_SUCCESS;
 }
 
@@ -102,7 +113,7 @@ static vlc_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
         return NULL;
 
     wnd->type = VLC_WINDOW_TYPE_HWND;
-    wnd->handle.hwnd = CommonVideoHWND(&sys->area);
+    wnd->handle.hwnd = CommonVideoHWND(sys->video_wnd);
     wnd->ops = &embedVideoWindow_Ops;
     return wnd;
 }
@@ -120,7 +131,7 @@ UpdateFormat(vout_display_t *vd, const video_format_t *fmt,
     ret = vout_display_opengl_UpdateFormat(sys->vgl, fmt, vctx);
 
     // /* Force to recompute the viewport on next picture */
-    sys->area.place_changed = true;
+    sys->place_changed = true;
 
     /* Restore viewpoint */
     int vp_ret = vout_display_opengl_SetViewpoint(sys->vgl, &sys->viewpoint);
@@ -160,11 +171,10 @@ static int Open(vout_display_t *vd,
         return VLC_ENOMEM;
 
     /* */
-    CommonInit(&sys->area, vd->source);
-    if (CommonWindowInit(vd, &sys->area,
+    sys->place_changed = false;
+    if (CommonWindowInit(vd, &sys->video_wnd,
                    vd->source->projection_mode != PROJECTION_MODE_RECTANGULAR))
         goto error;
-    CommonPlacePicture(vd, &sys->area);
 
     vlc_window_SetTitle(vd->cfg->window, VOUT_TITLE " (OpenGL output)");
 
@@ -228,7 +238,7 @@ static void Close(vout_display_t *vd)
         vlc_object_delete(surface);
     }
 
-    CommonWindowClean(&sys->area);
+    CommonWindowClean(sys->video_wnd);
 
     free(sys);
 }
@@ -243,7 +253,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
 
     if (vlc_gl_MakeCurrent (sys->gl) != VLC_SUCCESS)
         return;
-    if (sys->area.place_changed)
+    if (sys->place_changed)
     {
         vout_display_place_t place = *vd->place;
 
@@ -253,7 +263,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         vlc_gl_Resize (sys->gl, place.width, place.height);
         vout_display_opengl_SetOutputSize(sys->vgl, vd->cfg->display.width, vd->cfg->display.height);
         vout_display_opengl_Viewport(sys->vgl, place.x, place.y, place.width, place.height);
-        sys->area.place_changed = false;
+        sys->place_changed = false;
     }
     vout_display_opengl_Prepare (sys->vgl, picture, subpicture);
     vlc_gl_ReleaseCurrent (sys->gl);


=====================================
modules/video_output/win32/meson.build
=====================================
@@ -5,7 +5,7 @@
 # Direct3D11 video output
 d3d11_sources = files('direct3d11.cpp', 'd3d11_quad.cpp', 'd3d11_scaler.cpp',
                       'd3d11_shaders.cpp', 'd3d11_tonemap.cpp',
-                      'd3d_shaders.c', 'd3d_dynamic_shader.c', 'common.c')
+                      'd3d_shaders.c', 'd3d_dynamic_shader.c')
 d3d11_link_with = [ d3d11_common_lib, chroma_copy_lib ]
 d3d11_cargs = []
 d3d11_cxxargs = [ libcom_cppflags ]
@@ -15,7 +15,7 @@ if have_win_store
         cc.find_library('d3dcompiler_47')
     ]
 else
-    d3d11_sources += files('d3d11_swapchain.cpp', 'dxgi_swapchain.cpp', 'events.c', 'sensors.cpp', 'win32touch.c')
+    d3d11_sources += files('d3d11_swapchain.cpp', 'dxgi_swapchain.cpp', 'common.c', 'events.c', 'sensors.cpp', 'win32touch.c')
     d3d11_cargs += '-DHAVE_WIN32_SENSORS'
     d3d11_deps += [
         cc.find_library('user32')


=====================================
modules/video_output/win32/wingdi.c
=====================================
@@ -59,7 +59,9 @@ vlc_module_end ()
  *****************************************************************************/
 typedef struct vout_display_sys_t
 {
-    display_win32_area_t     area;
+    struct event_thread_t    *video_wnd;
+    bool                     size_changed;
+    bool                     place_changed;
 
     /* Our offscreen bitmap and its framebuffer */
     HDC        off_dc;
@@ -75,10 +77,8 @@ static void           Display(vout_display_t *, picture_t *);
 static int            Init(vout_display_t *, video_format_t *);
 static void           Clean(vout_display_t *);
 
-static int ChangeSize(vout_display_t *vd, HDC hdc)
+static bool ChangeSize(vout_display_t *vd, HDC hdc)
 {
-    vout_display_sys_t *sys = vd->sys;
-
     // clear the background, even if creating the writable buffer fails
     RECT display = {
         .left   = 0,
@@ -86,7 +86,12 @@ static int ChangeSize(vout_display_t *vd, HDC hdc)
         .top    = 0,
         .bottom = vd->cfg->display.height,
     };
-    FillRect(hdc, &display, GetStockObject(BLACK_BRUSH));
+    return FillRect(hdc, &display, GetStockObject(BLACK_BRUSH)) == 0;
+}
+
+static bool ChangePlace(vout_display_t *vd, HDC hdc)
+{
+    vout_display_sys_t *sys = vd->sys;
 
     video_format_t fmt_rot;
     video_format_ApplyRotation(&fmt_rot, vd->source);
@@ -106,7 +111,7 @@ static int ChangeSize(vout_display_t *vd, HDC hdc)
                                            DIB_RGB_COLORS,
                                            &p_pic_buffer, NULL, 0);
         if (unlikely(sys->off_bitmap == NULL))
-            return VLC_EINVAL;
+            return true;
         sys->pic_buf.p_pixels = p_pic_buffer;
         sys->pic_buf.i_pixel_pitch = (bih->biBitCount + 7) / 8;
         sys->pic_buf.i_pitch = sys->pic_buf.i_visible_pitch =
@@ -114,7 +119,7 @@ static int ChangeSize(vout_display_t *vd, HDC hdc)
         sys->pic_buf.i_lines = sys->pic_buf.i_visible_lines =
             fmt_rot.i_visible_height;
     }
-    return VLC_SUCCESS;
+    return false;
 }
 
 static void Prepare(vout_display_t *vd, picture_t *picture,
@@ -125,16 +130,22 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
     VLC_UNUSED(date);
     vout_display_sys_t *sys = vd->sys;
 
-    if (sys->area.place_changed)
+    if (sys->place_changed || sys->size_changed)
     {
-        HDC hdc = GetDC(CommonVideoHWND(&sys->area));
-        int err = ChangeSize(vd, hdc);
-        ReleaseDC(CommonVideoHWND(&sys->area), hdc);
-
-        if (unlikely(err != VLC_SUCCESS))
+        bool err = false;
+        HWND hwnd = CommonVideoHWND(sys->video_wnd);
+        HDC hdc = GetDC(hwnd);
+        if (sys->size_changed)
+            err |= ChangeSize(vd, hdc);
+        if (sys->place_changed)
+            err |= ChangePlace(vd, hdc);
+        ReleaseDC(hwnd, hdc);
+
+        if (unlikely(err))
             return;
 
-        sys->area.place_changed = false;
+        sys->place_changed = false;
+        sys->size_changed = false;
     }
 
     assert((LONG)picture->format.i_visible_width  == sys->bmiInfo.bmiHeader.biWidth &&
@@ -146,7 +157,18 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
 static int Control(vout_display_t *vd, int query)
 {
     vout_display_sys_t *sys = vd->sys;
-    CommonControl(vd, &sys->area, query);
+    switch (query) {
+    case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
+        CommonDisplaySizeChanged(sys->video_wnd);
+        sys->size_changed = true;
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
+        sys->place_changed = true;
+        break;
+    case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
+    case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
+        break;
+    }
     return VLC_SUCCESS;
 }
 
@@ -171,10 +193,10 @@ static int Open(vout_display_t *vd,
     if (!sys)
         return VLC_ENOMEM;
 
-    CommonInit(&sys->area, vd->source);
-    if (CommonWindowInit(vd, &sys->area, false))
+    sys->size_changed = true;
+    sys->place_changed = true;
+    if (CommonWindowInit(vd, &sys->video_wnd, false))
         goto error;
-    CommonPlacePicture(vd, &sys->area);
 
     /* */
     if (Init(vd, fmtp))
@@ -198,7 +220,7 @@ static void Close(vout_display_t *vd)
 
     Clean(vd);
 
-    CommonWindowClean(&sys->area);
+    CommonWindowClean(sys->video_wnd);
 
     free(sys);
 }
@@ -208,33 +230,33 @@ 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->area));
+    HDC hdc = GetDC(CommonVideoHWND(sys->video_wnd));
 
     SelectObject(sys->off_dc, sys->off_bitmap);
 
     video_format_t fmt_rot;
     video_format_ApplyRotation(&fmt_rot, vd->source);
 
-    if (sys->area.place.width  != fmt_rot.i_visible_width ||
-        sys->area.place.height != fmt_rot.i_visible_height) {
+    if (vd->place->width  != fmt_rot.i_visible_width ||
+        vd->place->height != fmt_rot.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,
                    fmt_rot.i_x_offset, fmt_rot.i_y_offset,
                    fmt_rot.i_x_offset + fmt_rot.i_visible_width,
                    fmt_rot.i_y_offset + fmt_rot.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,
                fmt_rot.i_x_offset, fmt_rot.i_y_offset,
                SRCCOPY);
     }
 
-    ReleaseDC(CommonVideoHWND(&sys->area), hdc);
+    ReleaseDC(CommonVideoHWND(sys->video_wnd), hdc);
 }
 
 static int Init(vout_display_t *vd, video_format_t *fmt)
@@ -244,7 +266,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->area));
+    HDC window_dc = GetDC(CommonVideoHWND(sys->video_wnd));
 
     /* */
     int i_depth = GetDeviceCaps(window_dc, PLANES) *
@@ -276,7 +298,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
         break;
     default:
         msg_Err(vd, "screen depth %i not supported", i_depth);
-        ReleaseDC(CommonVideoHWND(&sys->area), window_dc);
+        ReleaseDC(CommonVideoHWND(sys->video_wnd), window_dc);
         return VLC_EGENERIC;
     }
 
@@ -294,7 +316,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
     if (err != VLC_SUCCESS)
         DeleteDC(sys->off_dc);
 
-    ReleaseDC(CommonVideoHWND(&sys->area), window_dc);
+    ReleaseDC(CommonVideoHWND(sys->video_wnd), window_dc);
 
     return err;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3c8ec534e26513c6ce769b2aa9a34e3f831d43fc...abd96b82d7230996f3eba0698d749f19c47d7dbe

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3c8ec534e26513c6ce769b2aa9a34e3f831d43fc...abd96b82d7230996f3eba0698d749f19c47d7dbe
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list