1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcalc.h */
|
|
|
|
/* */
|
|
|
|
/* Arithmetic computations (specification). */
|
|
|
|
/* */
|
2013-01-24 09:12:56 +01:00
|
|
|
/* Copyright 1996-2006, 2008, 2009, 2012-2013 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-07-18 08:50:03 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2000-12-01 00:12:33 +01:00
|
|
|
#ifndef __FTCALC_H__
|
|
|
|
#define __FTCALC_H__
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-12-09 01:45:38 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
|
2000-12-01 00:12:33 +01:00
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2013-08-27 21:36:03 +02:00
|
|
|
#if 0
|
|
|
|
|
2004-12-14 00:16:59 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2013-08-27 21:36:03 +02:00
|
|
|
/* FT_SqrtFixed */
|
2004-12-14 00:16:59 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2013-01-13 01:17:05 +01:00
|
|
|
/* Computes the square root of a 16.16 fixed-point value. */
|
2004-12-14 00:16:59 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* x :: The value to compute the root for. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The result of `sqrt(x)'. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* This function is not very fast. */
|
|
|
|
/* */
|
* src/base/ftcalc.c (FT_MulTo64): Commented out.
* include/freetype/internal/ftcalc.h (FT_SqrtFixed), src/base/ftcalc.c
(FT_SqrtFixed), include/freetype/internal/ftdebug.h
(FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message, FT_Panic),
src/base/ftdebug.c (FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message,
FT_Panic), include/freetype/internal/ftobjs.h (FT_New_Memory,
FT_Done_Memory), include/freetype/internal/ftstream.h
(FT_Stream_Open), src/base/ftsystem.c (FT_New_Memory, FT_Done_Memory,
FT_Stream_Open): s/FT_EXPORT/FT_BASE/.
* builds/exports.mk: Manually add TT_New_Context to EXPORTS_LIST too.
2005-11-17 02:53:07 +01:00
|
|
|
FT_BASE( FT_Int32 )
|
2003-11-25 19:15:56 +01:00
|
|
|
FT_SqrtFixed( FT_Int32 x );
|
2001-05-09 22:57:45 +02:00
|
|
|
|
2013-08-27 21:36:03 +02:00
|
|
|
#endif /* 0 */
|
|
|
|
|
2001-05-09 22:57:45 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_MulDiv_No_Round */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* A very simple function used to perform the computation `(a*b)/c' */
|
2012-03-11 13:48:25 +01:00
|
|
|
/* (without rounding) with maximum accuracy (it uses a 64-bit */
|
2003-11-25 19:15:56 +01:00
|
|
|
/* intermediate integer whenever necessary). */
|
|
|
|
/* */
|
|
|
|
/* This function isn't necessarily as fast as some processor specific */
|
|
|
|
/* operations, but is at least completely portable. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* a :: The first multiplier. */
|
|
|
|
/* b :: The second multiplier. */
|
|
|
|
/* c :: The divisor. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The result of `(a*b)/c'. This function never traps when trying to */
|
|
|
|
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
|
|
|
|
/* on the signs of `a' and `b'. */
|
|
|
|
/* */
|
|
|
|
FT_BASE( FT_Long )
|
|
|
|
FT_MulDiv_No_Round( FT_Long a,
|
|
|
|
FT_Long b,
|
|
|
|
FT_Long c );
|
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
/*
|
|
|
|
* A variant of FT_Matrix_Multiply which scales its result afterwards.
|
|
|
|
* The idea is that both `a' and `b' are scaled by factors of 10 so that
|
|
|
|
* the values are as precise as possible to get a correct result during
|
|
|
|
* the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
|
|
|
|
* `a' and `b', respectively, then the scaling factor of the result is
|
|
|
|
* `sa*sb'.
|
|
|
|
*/
|
|
|
|
FT_BASE( void )
|
|
|
|
FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
|
|
|
|
FT_Matrix *b,
|
|
|
|
FT_Long scaling );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A variant of FT_Vector_Transform. See comments for
|
|
|
|
* FT_Matrix_Multiply_Scaled.
|
|
|
|
*/
|
|
|
|
FT_BASE( void )
|
|
|
|
FT_Vector_Transform_Scaled( FT_Vector* vector,
|
|
|
|
const FT_Matrix* matrix,
|
|
|
|
FT_Long scaling );
|
|
|
|
|
|
|
|
|
2006-11-02 18:21:02 +01:00
|
|
|
/*
|
|
|
|
* Return -1, 0, or +1, depending on the orientation of a given corner.
|
|
|
|
* We use the Cartesian coordinate system, with positive vertical values
|
2006-11-03 10:40:12 +01:00
|
|
|
* going upwards. The function returns +1 if the corner turns to the
|
|
|
|
* left, -1 to the right, and 0 for undecidable cases.
|
2006-11-02 18:21:02 +01:00
|
|
|
*/
|
|
|
|
FT_BASE( FT_Int )
|
2006-11-03 10:40:12 +01:00
|
|
|
ft_corner_orientation( FT_Pos in_x,
|
|
|
|
FT_Pos in_y,
|
|
|
|
FT_Pos out_x,
|
|
|
|
FT_Pos out_y );
|
2006-11-02 18:21:02 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return TRUE if a corner is flat or nearly flat. This is equivalent to
|
|
|
|
* saying that the angle difference between the `in' and `out' vectors is
|
|
|
|
* very small.
|
|
|
|
*/
|
|
|
|
FT_BASE( FT_Int )
|
2006-11-03 10:40:12 +01:00
|
|
|
ft_corner_is_flat( FT_Pos in_x,
|
|
|
|
FT_Pos in_y,
|
|
|
|
FT_Pos out_x,
|
|
|
|
FT_Pos out_y );
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
|
2013-01-24 01:43:28 +01:00
|
|
|
/*
|
|
|
|
* Return the most significant bit index.
|
2013-01-24 13:33:06 +01:00
|
|
|
*/
|
2013-01-24 01:43:28 +01:00
|
|
|
FT_BASE( FT_Int )
|
2013-01-24 09:12:56 +01:00
|
|
|
FT_MSB( FT_UInt32 z );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
|
|
|
|
* two fixed-point arguments instead.
|
|
|
|
*/
|
|
|
|
FT_BASE( FT_Fixed )
|
|
|
|
FT_Hypot( FT_Fixed x,
|
|
|
|
FT_Fixed y );
|
2013-01-24 01:43:28 +01:00
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
|
|
|
|
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
|
|
|
|
#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
|
|
|
|
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
|
2000-07-18 08:50:03 +02:00
|
|
|
#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
|
2009-06-21 20:17:01 +02:00
|
|
|
#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-02 23:31:32 +02:00
|
|
|
#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
|
|
|
|
: ( -( ( 32 - (x) ) & -64 ) ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-12-09 01:45:38 +01:00
|
|
|
|
2000-12-01 00:12:33 +01:00
|
|
|
FT_END_HEADER
|
2000-07-18 08:50:03 +02:00
|
|
|
|
2000-12-01 00:12:33 +01:00
|
|
|
#endif /* __FTCALC_H__ */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|