[vlc-commits] direct3d9: Fix spu texture mapping

Hugo Beauzée-Luyssen git at videolan.org
Tue May 23 20:26:17 CEST 2017


vlc/vlc-2.2 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue May 23 20:25:47 2017 +0200| [ae86342ec2bb743585e57613f33f5d0309e7141c] | committer: Hugo Beauzée-Luyssen

direct3d9: Fix spu texture mapping

(cherry-picked from commit bec643e42c8f831c0f9e6fd615797a6d6eef699a)

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 modules/video_output/msw/direct3d.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index 1fab5c23ca..98e9eef368 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -1399,7 +1399,6 @@ static void Direct3DSetupVertices(CUSTOMVERTEX *vertices,
         { dst.right, dst.bottom },
         { dst.left,  dst.bottom },
     };
-    bool has_src = src != NULL && src_clipped != NULL;
 
     /* Compute index remapping necessary to implement the rotation. */
     int vertex_order[4];
@@ -1410,10 +1409,10 @@ static void Direct3DSetupVertices(CUSTOMVERTEX *vertices,
         vertices[i].y  = vertices_coords[vertex_order[i]][1];
     }
 
-    float right = has_src ? (float)src_clipped->right / (float)src->right : 1.0f;
-    float left = has_src ? (float)src_clipped->left / (float)src->right : .0f;
-    float top = has_src ? (float)src_clipped->top / (float)src->bottom : .0f;
-    float bottom = has_src ? (float)src_clipped->bottom / (float)src->bottom : 1.0f;
+    float right = (float)src_clipped->right / (float)src->right;
+    float left = (float)src_clipped->left / (float)src->right;
+    float top = (float)src_clipped->top / (float)src->bottom;
+    float bottom = (float)src_clipped->bottom / (float)src->bottom;
 
     vertices[0].tu = left;
     vertices[0].tv = top;
@@ -1591,12 +1590,24 @@ static void Direct3DImportSubpicture(vout_display_t *vd,
 
         RECT dst;
         dst.left   = video.left + scale_w * r->i_x,
-        dst.right  = dst.left + scale_w * r->fmt.i_width,
+        dst.right  = dst.left + scale_w * r->fmt.i_visible_width,
         dst.top    = video.top  + scale_h * r->i_y,
-        dst.bottom = dst.top  + scale_h * r->fmt.i_height,
-        Direct3DSetupVertices(d3dr->vertex, NULL, NULL,
-                              dst,
-                              subpicture->i_alpha * r->i_alpha / 255, ORIENT_NORMAL);
+        dst.bottom = dst.top  + scale_h * r->fmt.i_visible_height;
+
+        RECT src;
+        src.left = 0;
+        src.right = r->fmt.i_width;
+        src.top = 0;
+        src.bottom = r->fmt.i_height;
+
+        RECT src_clipped;
+        src_clipped.left = r->fmt.i_x_offset;
+        src_clipped.right = r->fmt.i_x_offset + r->fmt.i_visible_width;
+        src_clipped.top = r->fmt.i_y_offset;
+        src_clipped.bottom = r->fmt.i_y_offset + r->fmt.i_visible_height;
+
+        Direct3DSetupVertices(d3dr->vertex, &src, &src_clipped,
+                              dst, subpicture->i_alpha * r->i_alpha / 255, ORIENT_NORMAL);
     }
 }
 



More information about the vlc-commits mailing list