[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master 6eb5f2be4: Update 2 files
From: |
Werner Lemberg |
Subject: |
[freetype2] master 6eb5f2be4: Update 2 files |
Date: |
Wed, 13 Sep 2023 13:02:44 -0400 (EDT) |
branch: master
commit 6eb5f2be40b1c780dab3fbff3c9f19a7339bcab3
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
Update 2 files
- /src/base/ftcalc.c
- /include/freetype/internal/ftcalc.h
---
include/freetype/internal/ftcalc.h | 4 ++--
src/base/ftcalc.c | 37 +++++++++++++++----------------------
2 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/include/freetype/internal/ftcalc.h
b/include/freetype/internal/ftcalc.h
index d9aea2360..fa5e4050f 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -509,8 +509,8 @@ FT_BEGIN_HEADER
* @note:
* This function is not very fast.
*/
- FT_BASE( FT_Int32 )
- FT_SqrtFixed( FT_Int32 x );
+ FT_BASE( FT_UInt32 )
+ FT_SqrtFixed( FT_UInt32 x );
#endif /* 0 */
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index c5bc7e3b1..ba4d5e3fd 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -917,36 +917,29 @@
/* documentation is in ftcalc.h */
- FT_BASE_DEF( FT_Int32 )
- FT_SqrtFixed( FT_Int32 x )
+ /* Algorithm and code by Christophe Meessen (1993). */
+ FT_BASE_DEF( FT_UInt32 )
+ FT_SqrtFixed( FT_UInt32 r )
{
- FT_UInt32 root, rem_hi, rem_lo, test_div;
- FT_Int count;
+ FT_UInt32 t, q, b;
- root = 0;
+ q = 0;
- if ( x > 0 )
+ b = 0x40000000;
+ while ( b > 0x40 )
{
- rem_hi = 0;
- rem_lo = (FT_UInt32)x;
- count = 24;
- do
+ t = q + b;
+ if ( r >= t )
{
- rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 );
- rem_lo <<= 2;
- root <<= 1;
- test_div = ( root << 1 ) + 1;
-
- if ( rem_hi >= test_div )
- {
- rem_hi -= test_div;
- root += 1;
- }
- } while ( --count );
+ r -= t;
+ q = t + b; /* equivalent to q += 2*b */
+ }
+ r <<= 1;
+ b >>= 1;
}
- return (FT_Int32)root;
+ return q >> 8;
}
#endif /* 0 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master 6eb5f2be4: Update 2 files,
Werner Lemberg <=