[vlc-devel] [PATCH 2/3] direct3d9: render subpictures in display dimensions

Salah-Eddin Shaban salah at videolan.org
Fri Mar 3 18:05:52 CET 2017


---
 modules/video_output/win32/common.c    | 14 +++++++++++++-
 modules/video_output/win32/direct3d9.c | 20 ++++++++++++--------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index f2b97b8..5fca339 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -202,13 +202,25 @@ void UpdateRects(vout_display_t *vd,
     EventThreadUpdateSourceAndPlace(sys->event, source, &place);
 
     if (sys->hvideownd)
+#if defined(MODULE_NAME_IS_direct3d9)
+        /* let the video window fill the whole display */
+        SetWindowPos(sys->hvideownd, 0,
+                     rect.left, rect.top, rect.right, rect.bottom,
+                     SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS);
+#else
         SetWindowPos(sys->hvideownd, 0,
             place.x, place.y, place.width, place.height,
             SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS);
 #endif
+#endif
 
     /* Destination image position and dimensions */
-#if (defined(MODULE_NAME_IS_direct3d9) || defined(MODULE_NAME_IS_direct3d11)) && !VLC_WINSTORE_APP
+#if defined(MODULE_NAME_IS_direct3d9) && !VLC_WINSTORE_APP
+    rect_dest.left = place.x;
+    rect_dest.right = rect_dest.left + place.width;
+    rect_dest.top = place.y;
+    rect_dest.bottom = rect_dest.top + place.height;
+#elif defined(MODULE_NAME_IS_direct3d11) && !VLC_WINSTORE_APP
     rect_dest.left = 0;
     rect_dest.right = place.width;
     rect_dest.top = 0;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index f190e65..ef22af7 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -262,6 +262,7 @@ static int Open(vlc_object_t *object)
     info.has_double_click = true;
     info.has_hide_mouse = false;
     info.has_pictures_invalid = !is_d3d9_opaque(fmt.i_chroma);
+    info.scale_spu_to_display = true;
     if (var_InheritBool(vd, "direct3d9-hw-blending") &&
         sys->d3dregion_format != D3DFMT_UNKNOWN &&
         (sys->d3dcaps.SrcBlendCaps  & D3DPBLENDCAPS_SRCALPHA) &&
@@ -428,6 +429,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         return;
     }
 
+    IDirect3DDevice9_Clear(vd->sys->d3ddev, 0, NULL, D3DCLEAR_TARGET,
+                           D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
+
     d3d_region_t picture_region;
     if (!Direct3D9ImportPicture(vd, &picture_region, surface)) {
         picture_region.width = picture->format.i_visible_width;
@@ -460,8 +464,8 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 
     // Present the back buffer contents to the display
     // No stretching should happen here !
-    const RECT src = sys->sys.rect_dest_clipped;
-    const RECT dst = sys->sys.rect_dest_clipped;
+    RECT src = { 0, 0, vd->cfg->display.width, vd->cfg->display.height };
+    RECT dst = src;
 
     HRESULT hr;
     if (sys->use_d3d9ex) {
@@ -1766,15 +1770,15 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
             msg_Err(vd, "Failed to lock the texture");
         }
 
-        /* Map the subpicture to sys->sys.rect_dest */
-        const RECT video = sys->sys.rect_dest;
-        const float scale_w = (float)(video.right  - video.left) / subpicture->i_original_picture_width;
-        const float scale_h = (float)(video.bottom - video.top)  / subpicture->i_original_picture_height;
+        /* Map the subpicture to the display */
+        RECT display = { 0, 0, vd->cfg->display.width, vd->cfg->display.height };
+        const float scale_w = (float)(display.right  - display.left) / subpicture->i_original_picture_width;
+        const float scale_h = (float)(display.bottom - display.top)  / subpicture->i_original_picture_height;
 
         RECT dst;
-        dst.left   = video.left + scale_w * r->i_x,
+        dst.left   = display.left + scale_w * r->i_x,
         dst.right  = dst.left + scale_w * r->fmt.i_visible_width,
-        dst.top    = video.top  + scale_h * r->i_y,
+        dst.top    = display.top  + scale_h * r->i_y,
         dst.bottom = dst.top  + scale_h * r->fmt.i_visible_height,
         Direct3D9SetupVertices(d3dr->vertex,
                               &dst, subpicture->i_alpha * r->i_alpha / 255, ORIENT_NORMAL);
-- 
2.10.2



More information about the vlc-devel mailing list