freetype: Prevent lose of data when fixed point divide calculation.

Summary:
In environments that long is 4byte, fixed-point division calculations will cause data loss.
fixed-point division need to more space.
Therefore, change all long types to long long types.

Test Plan: N/A

Reviewers: Hermet, kimcinoo, smohanty

Reviewed By: Hermet

Subscribers: vtorri, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9817
This commit is contained in:
junsu choi 2019-09-04 12:07:08 +09:00 committed by Hermet Park
parent a2f846bffc
commit 9e3aabe43b
3 changed files with 29 additions and 30 deletions

View File

@ -41,54 +41,53 @@ SW_FT_END_STMNT
SW_FT_Long
SW_FT_MulFix( SW_FT_Long a,
SW_FT_Long b )
SW_FT_Int64
SW_FT_MulFix( SW_FT_Int64 a,
SW_FT_Int64 b )
{
SW_FT_Int s = 1;
SW_FT_Long c;
SW_FT_Int64 c;
SW_FT_MOVE_SIGN( a, s );
SW_FT_MOVE_SIGN( b, s );
c = (SW_FT_Long)( ( (SW_FT_Int64)a * b + 0x8000L ) >> 16 );
c = ( a * b + 0x8000L ) >> 16;
return ( s > 0 ) ? c : -c;
}
SW_FT_Long
SW_FT_MulDiv( SW_FT_Long a,
SW_FT_Long b,
SW_FT_Long c )
SW_FT_Int64
SW_FT_MulDiv( SW_FT_Int64 a,
SW_FT_Int64 b,
SW_FT_Int64 c )
{
SW_FT_Int s = 1;
SW_FT_Long d;
SW_FT_Int64 d;
SW_FT_MOVE_SIGN( a, s );
SW_FT_MOVE_SIGN( b, s );
SW_FT_MOVE_SIGN( c, s );
d = (SW_FT_Long)( c > 0 ? ( (SW_FT_Int64)a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFL );
d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFL;
return ( s > 0 ) ? d : -d;
}
SW_FT_Long
SW_FT_DivFix( SW_FT_Long a,
SW_FT_Long b )
SW_FT_Int64
SW_FT_DivFix( SW_FT_Int64 a,
SW_FT_Int64 b )
{
SW_FT_Int s = 1;
SW_FT_Long q;
SW_FT_Int64 q;
SW_FT_MOVE_SIGN( a, s );
SW_FT_MOVE_SIGN( b, s );
q = (SW_FT_Long)( b > 0 ? ( ( (SW_FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b
: 0x7FFFFFFFL );
q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
: 0x7FFFFFFFL;
return ( s < 0 ? -q : q );
}

View File

@ -71,9 +71,9 @@
/* _second_ argument of this function; this can make a great */
/* difference. */
/* */
SW_FT_Long
SW_FT_MulFix( SW_FT_Long a,
SW_FT_Long b );
SW_FT_Int64
SW_FT_MulFix( SW_FT_Int64 a,
SW_FT_Int64 b );
/*************************************************************************/
/* */
@ -98,10 +98,10 @@ SW_FT_MulFix( SW_FT_Long a,
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
/* on the signs of `a' and `b'. */
/* */
SW_FT_Long
SW_FT_MulDiv( SW_FT_Long a,
SW_FT_Long b,
SW_FT_Long c );
SW_FT_Int64
SW_FT_MulDiv( SW_FT_Int64 a,
SW_FT_Int64 b,
SW_FT_Int64 c );
/*************************************************************************/
/* */
@ -120,9 +120,9 @@ SW_FT_MulDiv( SW_FT_Long a,
/* <Return> */
/* The result of `(a*0x10000)/b'. */
/* */
SW_FT_Long
SW_FT_DivFix( SW_FT_Long a,
SW_FT_Long b );
SW_FT_Int64
SW_FT_DivFix( SW_FT_Int64 a,
SW_FT_Int64 b );

View File

@ -10,7 +10,7 @@
/* This type is used to store 16.16 fixed-point values, like scaling */
/* values or matrix coefficients. */
/* */
typedef signed long SW_FT_Fixed;
typedef signed long long SW_FT_Fixed;
/*************************************************************************/