freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master bec4ef415: [base] Round values in `FT_MulAdd_Fix`.


From: Werner Lemberg
Subject: [freetype2] master bec4ef415: [base] Round values in `FT_MulAdd_Fix`.
Date: Fri, 1 Jul 2022 08:02:11 -0400 (EDT)

branch: master
commit bec4ef415ef07ad1fa9542978136d9863dd7a6d0
Author: Dominik Röttsches <drott@chromium.org>
Commit: Werner Lemberg <wl@gnu.org>

    [base] Round values in `FT_MulAdd_Fix`.
    
    This avoids regressing Blink layout tests and makes `FT_MulAdd_Fix` delta
    retrieval implementation consistent with the previous implementation, which
    used `FT_fixedToInt` and included rounding.
    
    * src/base/ftcalc.c (FT_MulAdd_Fix): Implement it.
    Also fix remaining `temp` initialization compilation issue.
    
    Fixes #1169.
---
 src/base/ftcalc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 34170a582..55d2f7cc8 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -1091,18 +1091,20 @@
                 FT_UInt    count )
   {
     FT_UInt   i;
-    FT_Int64  temp = 0;
+    FT_Int64  temp;
+#ifndef FT_INT64
+    FT_Int64  halfUnit;
+#endif
 
 
 #ifdef FT_INT64
+    temp = 0;
 
     for ( i = 0; i < count; ++i )
       temp += (FT_Int64)s[i] * f[i];
 
-    return temp >> 16;
-
+    return ( temp + 0x8000 ) >> 16;
 #else
-
     temp.hi = 0;
     temp.lo = 0;
 
@@ -1137,6 +1139,11 @@
       FT_Add64( &temp, &multResult, &temp );
     }
 
+    /* Round value. */
+    halfUnit.hi = 0;
+    halfUnit.lo = 0x8000;
+    FT_Add64( &temp, &halfUnit, &temp );
+
     return (FT_Int32)( ( (FT_Int32)( temp.hi & 0xFFFF ) << 16 ) |
                                    ( temp.lo >> 16 )            );
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]