[vlc-commits] vout:win32: store the source format in display_win32_area_t

Steve Lhomme git at videolan.org
Tue Apr 30 11:13:55 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Apr 15 16:08:56 2019 +0200| [1abcf92bccc255b2845ea6a1fa71d457466cd0ba] | committer: Steve Lhomme

vout:win32: store the source format in display_win32_area_t

So we don't have to pass the display module at each UpdateRects nor the source
video_format_t. It may also change if the texture is bigger than the decoded
size (D3D11 extra padding).

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

 modules/video_output/win32/common.c     | 31 ++++++++++++++-----------------
 modules/video_output/win32/common.h     |  4 +++-
 modules/video_output/win32/direct3d11.c | 31 +++++++++++++------------------
 modules/video_output/win32/direct3d9.c  |  4 ++--
 modules/video_output/win32/wingdi.c     |  2 +-
 5 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index ca203b5e72..510a7a462a 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -59,6 +59,8 @@ void InitArea(vout_display_t *vd, display_win32_area_t *area, const vout_display
     area->opaque_dimensions = vd;
     area->vdcfg = *vdcfg;
 
+    area->texture_source = vd->source;
+
     var_Create(vd, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
 }
 
@@ -124,16 +126,14 @@ int CommonInit(vlc_object_t *obj, display_win32_area_t *area,
 * its job is to update the source and destination RECTs used to display the
 * picture.
 *****************************************************************************/
-void UpdateRects(vout_display_t *vd, display_win32_area_t *area, vout_display_sys_win32_t *sys)
+void UpdateRects(vlc_object_t *obj, display_win32_area_t *area, vout_display_sys_win32_t *sys)
 {
-    const video_format_t *source = &vd->source;
-
     UINT  display_width, display_height;
 
     /* Retrieve the window size */
     if (!area->pf_GetDisplayDimensions(area->opaque_dimensions, &display_width, &display_height))
     {
-        msg_Err(vd, "could not get the window dimensions");
+        msg_Err(obj, "could not get the window dimensions");
         return;
     }
 
@@ -151,7 +151,7 @@ void UpdateRects(vout_display_t *vd, display_win32_area_t *area, vout_display_sy
 #endif
 
     vout_display_place_t before_place = area->place;
-    vout_display_PlacePicture(&area->place, source, &place_cfg);
+    vout_display_PlacePicture(&area->place, &area->texture_source, &place_cfg);
 
     /* Signal the change in size/position */
     if (!vout_display_PlaceEquals(&before_place, &area->place))
@@ -159,21 +159,18 @@ void UpdateRects(vout_display_t *vd, display_win32_area_t *area, vout_display_sy
         area->place_changed |= true;
 
 #ifndef NDEBUG
-        msg_Dbg(vd, "DirectXUpdateRects source"
-            " offset: %i,%i visible: %ix%i decoded: %ix%i",
-            source->i_x_offset, source->i_y_offset,
-            source->i_visible_width, source->i_visible_height,
-            source->i_width, source->i_height);
-        msg_Dbg(vd, "DirectXUpdateRects image_dst"
-            " coords: %i,%i,%i,%i",
-            area->place.x, area->place.y,
-            area->place.x + area->place.width, area->place.y + area->place.height);
+        msg_Dbg(obj, "UpdateRects source offset: %i,%i visible: %ix%i decoded: %ix%i",
+            area->texture_source.i_x_offset, area->texture_source.i_y_offset,
+            area->texture_source.i_visible_width, area->texture_source.i_visible_height,
+            area->texture_source.i_width, area->texture_source.i_height);
+        msg_Dbg(obj, "UpdateRects image_dst coords: %i,%i %ix%i",
+            area->place.x, area->place.y, area->place.width, area->place.height);
 #endif
 
 #if !VLC_WINSTORE_APP
         if (sys->event != NULL)
         {
-            CommonChangeThumbnailClip(VLC_OBJECT(vd), sys, true);
+            CommonChangeThumbnailClip(obj, sys, true);
         }
 #endif
     }
@@ -245,7 +242,7 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
     case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
     case VOUT_DISPLAY_CHANGE_SOURCE_CROP: {
         area->vdcfg = *va_arg(args, const vout_display_cfg_t *);
-        UpdateRects(vd, area, sys);
+        UpdateRects(VLC_OBJECT(vd), area, sys);
         return VLC_SUCCESS;
     }
     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:   /* const vout_display_cfg_t *p_cfg */
@@ -259,7 +256,7 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
                          area->vdcfg.display.height, SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
         }
 #endif /* !VLC_WINSTORE_APP */
-        UpdateRects(vd, area, sys);
+        UpdateRects(VLC_OBJECT(vd), area, sys);
         return VLC_SUCCESS;
     }
 
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 1f0d217a47..6310cb4e3e 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -36,6 +36,8 @@ typedef struct display_win32_area_t
     vout_display_place_t  place;
     bool                  place_changed;
 
+    video_format_t        texture_source;
+
     vout_display_cfg_t    vdcfg;
 
     bool (*pf_GetDisplayDimensions)(void *opaque, UINT *w, UINT *h);
@@ -76,7 +78,7 @@ void CommonClean(vlc_object_t *, 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 );
 
-void UpdateRects (vout_display_t *, display_win32_area_t *, vout_display_sys_win32_t *);
+void UpdateRects (vlc_object_t *, display_win32_area_t *, vout_display_sys_win32_t *);
 
 void InitArea(vout_display_t *, display_win32_area_t *, const vout_display_cfg_t *);
 
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index f8decb1ccf..4a24c9cad8 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -280,7 +280,7 @@ static bool StartRendering(void *opaque)
 
 #if VLC_WINSTORE_APP
     /* TODO read the swapchain size and call VOUT_DISPLAY_CHANGE_DISPLAY_SIZE */
-    UpdateRects(vd, &sys->area, &sys->sys);
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 #endif
 
     if ( sys->area.place_changed )
@@ -554,10 +554,6 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
     if (sys->pool)
         return sys->pool;
 
-    video_format_t surface_fmt = vd->fmt;
-    surface_fmt.i_width  = sys->picQuad.i_width;
-    surface_fmt.i_height = sys->picQuad.i_height;
-
     ID3D11Texture2D  *textures[pool_size * D3D11_MAX_SHADER_VIEW];
     memset(textures, 0, sizeof(textures));
     unsigned slices = pool_size;
@@ -565,7 +561,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
         /* only provide enough for the filters, we can still do direct rendering */
         slices = __MIN(slices, 6);
 
-    if (AllocateTextures(vd, &sys->d3d_dev, sys->picQuad.textureFormat, &surface_fmt, slices, textures))
+    if (AllocateTextures(vd, &sys->d3d_dev, sys->picQuad.textureFormat, &sys->area.texture_source, slices, textures))
         goto error;
 
     pictures = calloc(pool_size, sizeof(*pictures));
@@ -585,7 +581,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
             .pf_destroy = DestroyDisplayPoolPicture,
         };
 
-        picture = picture_NewFromResource(&surface_fmt, &resource);
+        picture = picture_NewFromResource(&sys->area.texture_source, &resource);
         if (unlikely(picture == NULL)) {
             free(picsys);
             msg_Err( vd, "Failed to create picture %d in the pool.", picture_count );
@@ -630,7 +626,7 @@ error:
         sys->pool = picture_pool_New( 0, NULL );
     } else {
         msg_Dbg(vd, "D3D11 pool succeed with %d surfaces (%dx%d) context 0x%p",
-                pool_size, surface_fmt.i_width, surface_fmt.i_height, sys->d3d_dev.d3dcontext);
+                pool_size, sys->area.texture_source.i_width, sys->area.texture_source.i_height, sys->d3d_dev.d3dcontext);
     }
     return sys->pool;
 }
@@ -837,10 +833,10 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
             {
                 /* the decoder produced different sizes than the vout, we need to
                  * adjust the vertex */
-                sys->picQuad.i_height = texDesc.Height;
-                sys->picQuad.i_width = texDesc.Width;
+                sys->area.texture_source.i_width  = sys->picQuad.i_height = texDesc.Height;
+                sys->area.texture_source.i_height = sys->picQuad.i_width = texDesc.Width;
 
-                UpdateRects(vd, &sys->area, &sys->sys);
+                UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
                 UpdateSize(vd);
             }
         }
@@ -1456,11 +1452,10 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
         sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
     }
 
-    UpdateRects(vd, &sys->area, &sys->sys);
+    sys->area.texture_source.i_width  = sys->picQuad.i_width;
+    sys->area.texture_source.i_height = sys->picQuad.i_height;
 
-    video_format_t surface_fmt = *fmt;
-    surface_fmt.i_width  = sys->picQuad.i_width;
-    surface_fmt.i_height = sys->picQuad.i_height;
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 
     if (D3D11_AllocateQuad(vd, &sys->d3d_dev, vd->source.projection_mode, &sys->picQuad) != VLC_SUCCESS)
     {
@@ -1474,7 +1469,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
         .top    = vd->source.i_y_offset,
         .bottom = vd->source.i_y_offset + vd->source.i_visible_height,
     };
-    if (D3D11_SetupQuad( vd, &sys->d3d_dev, &surface_fmt, &sys->picQuad, &sys->display,
+    if (D3D11_SetupQuad( vd, &sys->d3d_dev, &sys->area.texture_source, &sys->picQuad, &sys->display,
                          &source_rect,
                          vd->source.orientation ) != VLC_SUCCESS) {
         msg_Err(vd, "Could not Create the main quad picture.");
@@ -1500,7 +1495,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
         /* we need a staging texture */
         ID3D11Texture2D *textures[D3D11_MAX_SHADER_VIEW] = {0};
 
-        if (AllocateTextures(vd, &sys->d3d_dev, sys->picQuad.textureFormat, &surface_fmt, 1, textures))
+        if (AllocateTextures(vd, &sys->d3d_dev, sys->picQuad.textureFormat, &sys->area.texture_source, 1, textures))
         {
             msg_Err(vd, "Failed to allocate the staging texture");
             return VLC_EGENERIC;
@@ -1566,7 +1561,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
         ID3D11DepthStencilState_Release(pDepthStencilState);
     }
 
-    UpdateRects(vd, &sys->area, &sys->sys);
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 
     hr = UpdateBackBuffer(vd);
     if (FAILED(hr)) {
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 89ae1e5fcf..0e93d187aa 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -915,7 +915,7 @@ static int Direct3D9Reset(vout_display_t *vd, video_format_t *fmtp)
         return VLC_EGENERIC;
     }
 
-    UpdateRects(vd, &sys->area, &sys->sys);
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 
     /* re-create them */
     if (Direct3D9CreateResources(vd, fmtp)) {
@@ -1494,7 +1494,7 @@ static int Direct3D9Open(vout_display_t *vd, video_format_t *fmt,
     fmt->i_bmask  = d3dfmt->bmask;
     sys->sw_texture_fmt = d3dfmt;
 
-    UpdateRects(vd, &sys->area, &sys->sys);
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 
     if (Direct3D9CreateResources(vd, fmt)) {
         msg_Err(vd, "Failed to allocate resources");
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 322839448f..0e7453a8ab 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -272,7 +272,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
 
     vout_window_SetTitle(sys->area.vdcfg.window, VOUT_TITLE " (WinGDI output)");
 
-    UpdateRects(vd, &sys->area, &sys->sys);
+    UpdateRects(VLC_OBJECT(vd), &sys->area, &sys->sys);
 
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list