[vlc-commits] direct3d: Fix green lines.

Hugo Beauzée-Luyssen git at videolan.org
Fri Feb 26 20:11:20 CET 2016


vlc/vlc-2.2 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Feb 26 18:39:48 2016 +0100| [73e43a953b40507db0a929ff93fbab3624003edc] | committer: Hugo Beauzée-Luyssen

direct3d: Fix green lines.

This patch reworks a bit the way we handle textures & surfaces.
The surface is the size of the decoder buffer (i_width/i_height)
The texture is the size of the visible picture (i_visible_*)
StretchRect is now copying only the valuable parts of the decoder
buffer (ie. it includes offsets & visible_*)
Fix #16597

(Manually cherry-picked from: 44ed9ffc36cfbce7d178b9f8b93b8bc73373d542)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=73e43a953b40507db0a929ff93fbab3624003edc
---

 modules/video_output/msw/direct3d.c |   45 ++++++++++-------------------------
 1 file changed, 13 insertions(+), 32 deletions(-)

diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index 804560f..c5de2df 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -1054,8 +1054,8 @@ static int Direct3DCreateScene(vout_display_t *vd, const video_format_t *fmt)
      */
     LPDIRECT3DTEXTURE9 d3dtex;
     hr = IDirect3DDevice9_CreateTexture(d3ddev,
-                                        fmt->i_width,
-                                        fmt->i_height,
+                                        fmt->i_visible_width,
+                                        fmt->i_visible_height,
                                         1,
                                         D3DUSAGE_RENDERTARGET,
                                         sys->d3dpp.BackBufferFormat,
@@ -1386,15 +1386,10 @@ static void orientationVertexOrder(video_orientation_t orientation, int vertex_o
 }
 
 static void Direct3DSetupVertices(CUSTOMVERTEX *vertices,
-                                  const RECT src_full,
-                                  const RECT src_crop,
                                   const RECT dst,
                                   int alpha,
                                   video_orientation_t orientation)
 {
-    const float src_full_width  = src_full.right  - src_full.left;
-    const float src_full_height = src_full.bottom - src_full.top;
-
     /* Vertices of the dst rectangle in the unrotated (clockwise) order. */
     const int vertices_coords[4][2] = {
         { dst.left,  dst.top    },
@@ -1412,17 +1407,17 @@ static void Direct3DSetupVertices(CUSTOMVERTEX *vertices,
         vertices[i].y  = vertices_coords[vertex_order[i]][1];
     }
 
-    vertices[0].tu = src_crop.left / src_full_width;
-    vertices[0].tv = src_crop.top  / src_full_height;
+    vertices[0].tu = .0f;
+    vertices[0].tv = .0f;
 
-    vertices[1].tu = src_crop.right / src_full_width;
-    vertices[1].tv = src_crop.top   / src_full_height;
+    vertices[1].tu = 1.f;
+    vertices[1].tv = .0f;
 
-    vertices[2].tu = src_crop.right  / src_full_width;
-    vertices[2].tv = src_crop.bottom / src_full_height;
+    vertices[2].tu = 1.f;
+    vertices[2].tv = 1.f;
 
-    vertices[3].tu = src_crop.left   / src_full_width;
-    vertices[3].tv = src_crop.bottom / src_full_height;
+    vertices[3].tu = .0f;
+    vertices[3].tv = 1.f;
 
     for (int i = 0; i < 4; i++) {
         /* -0.5f is a "feature" of DirectX and it seems to apply to Direct3d also */
@@ -1461,12 +1456,7 @@ static int Direct3DImportPicture(vout_display_t *vd,
 
     /* Copy picture surface into texture surface
      * color space conversion happen here */
-    RECT cropSource;
-    cropSource.left = 0;
-    cropSource.top = 0;
-    cropSource.right = vd->fmt.i_visible_width;
-    cropSource.bottom = vd->fmt.i_visible_height;
-    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &cropSource, destination, NULL, D3DTEXF_LINEAR);
+    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &vd->sys->rect_src_clipped, destination, NULL, D3DTEXF_LINEAR);
     IDirect3DSurface9_Release(destination);
     if (FAILED(hr)) {
         msg_Dbg(vd, "%s:%d (hr=0x%0lX)", __FUNCTION__, __LINE__, hr);
@@ -1475,10 +1465,7 @@ static int Direct3DImportPicture(vout_display_t *vd,
 
     /* */
     region->texture = sys->d3dtex;
-    Direct3DSetupVertices(region->vertex,
-                          vd->sys->rect_src,
-                          vd->sys->rect_src_clipped,
-                          vd->sys->rect_dest_clipped, 255, vd->fmt.orientation);
+    Direct3DSetupVertices(region->vertex, vd->sys->rect_dest_clipped, 255, vd->fmt.orientation);
     return VLC_SUCCESS;
 }
 
@@ -1584,12 +1571,6 @@ static void Direct3DImportSubpicture(vout_display_t *vd,
         }
 
         /* Map the subpicture to sys->rect_dest */
-        RECT src;
-        src.left   = 0;
-        src.right  = src.left + r->fmt.i_visible_width;
-        src.top    = 0;
-        src.bottom = src.top  + r->fmt.i_visible_height;
-
         const RECT video = 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;
@@ -1600,7 +1581,7 @@ static void Direct3DImportSubpicture(vout_display_t *vd,
         dst.top    = video.top  + scale_h * r->i_y,
         dst.bottom = dst.top  + scale_h * r->fmt.i_visible_height,
         Direct3DSetupVertices(d3dr->vertex,
-                              src, src, dst,
+                              dst,
                               subpicture->i_alpha * r->i_alpha / 255, ORIENT_NORMAL);
     }
 }



More information about the vlc-commits mailing list