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

Steve Lhomme git at videolan.org
Thu Feb 8 10:41:26 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Feb  8 09:38:56 2018 +0100| [9a736c2175ecfffda68a7f9535968c774cd767b2] | committer: Steve Lhomme

direct3d11: simplify the math to compute the quad corners position

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

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

 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