[vlc-commits] direct3d11: simplify the math to compute the quad corners position

Steve Lhomme git at videolan.org
Thu Feb 8 14:14:51 CET 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Feb  8 09:38:56 2018 +0100| [d739edee241f690c0c8b90f3f400932ff7a2a20c] | committer: Jean-Baptiste Kempf

direct3d11: simplify the math to compute the quad corners position

This is only valid for left aligned textures (ie not rotated)

(cherry picked from commit 9a736c2175ecfffda68a7f9535968c774cd767b2)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/win32/direct3d11.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 949419fcfe..137205eeca 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -2298,18 +2298,16 @@ static void SetupQuadFlat(d3d_vertex_t *dst_data, const RECT *output,
                           const d3d_quad_t *quad,
                           WORD *triangle_pos, video_orientation_t orientation)
 {
-    unsigned int dst_x = output->left;
-    unsigned int dst_y = output->top;
     unsigned int src_width = quad->i_width;
     unsigned int src_height = quad->i_height;
-    LONG MidY = output->top + output->bottom; // /2
-    LONG MidX = output->left + output->right; // /2
+    float MidY = (output->top + output->bottom) / 2.f;
+    float MidX = (output->left + output->right) / 2.f;
 
     float top, bottom, left, right;
-    top    =  (float)MidY / (float)(MidY - 2*dst_y);
-    bottom = -(2.f*src_height - MidY) / (float)(MidY - 2*dst_y);
-    right  =  (2.f*src_width  - MidX) / (float)(MidX - 2*dst_x);
-    left   = -(float)MidX / (float)(MidX - 2*dst_x);
+    top    =  MidY / (MidY - output->top);
+    bottom = -(src_height - MidY) / (output->bottom - MidY);
+    left   = -MidX / (MidX - output->left);
+    right  =  (src_width  - MidX) / (output->right - MidX);
 
     const float vertices_coords[4][2] = {
         { left,  bottom },



More information about the vlc-commits mailing list