Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType
Commits:
-
babe6af1
by Alexei Podtelezhnikov at 2023-09-18T15:01:26+00:00
1 changed file:
Changes:
... | ... | @@ -917,17 +917,18 @@ |
917 | 917 | |
918 | 918 | /* documentation is in ftcalc.h */
|
919 | 919 | |
920 | - /* Algorithm and code by Christophe Meessen (1993). */
|
|
920 | + /* Algorithm and code by Christophe Meessen (1993) */
|
|
921 | + /* with overflow fixed. */
|
|
921 | 922 | FT_BASE_DEF( FT_UInt32 )
|
922 | - FT_SqrtFixed( FT_UInt32 r )
|
|
923 | + FT_SqrtFixed( FT_UInt32 v )
|
|
923 | 924 | {
|
924 | - FT_UInt32 t, q, b;
|
|
925 | + FT_UInt32 r = v >> 1;
|
|
926 | + FT_UInt32 q = ( v & 1 ) << 15;
|
|
927 | + FT_UInt32 b = 0x20000000;
|
|
928 | + FT_UInt32 t;
|
|
925 | 929 | |
926 | 930 | |
927 | - q = 0;
|
|
928 | - |
|
929 | - b = 0x40000000;
|
|
930 | - while ( b > 0x40 )
|
|
931 | + do
|
|
931 | 932 | {
|
932 | 933 | t = q + b;
|
933 | 934 | if ( r >= t )
|
... | ... | @@ -938,8 +939,9 @@ |
938 | 939 | r <<= 1;
|
939 | 940 | b >>= 1;
|
940 | 941 | }
|
942 | + while ( b > 0x20 );
|
|
941 | 943 | |
942 | - return q >> 8;
|
|
944 | + return q >> 7;
|
|
943 | 945 | }
|
944 | 946 | |
945 | 947 | #endif /* 0 */
|