w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ftcalc.c File Reference
#include <freetype/ftglyph.h>
#include <freetype/fttrigon.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
Include dependency graph for ftcalc.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FT_Int64_
 

Macros

#define FT_COMPONENT   calc
 
#define FT_MOVE_SIGN(x, x_unsigned, s)
 

Typedefs

typedef struct FT_Int64_ FT_Int64
 

Functions

 FT_RoundFix (FT_Fixed a)
 
 FT_CeilFix (FT_Fixed a)
 
 FT_FloorFix (FT_Fixed a)
 
 FT_MSB (FT_UInt32 z)
 
 FT_Hypot (FT_Fixed x, FT_Fixed y)
 
static void ft_multo64 (FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
 
static FT_UInt32 ft_div64by32 (FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 y)
 
static void FT_Add64 (FT_Int64 *x, FT_Int64 *y, FT_Int64 *z)
 
 FT_MulDiv (FT_Long a_, FT_Long b_, FT_Long c_)
 
 FT_MulDiv_No_Round (FT_Long a_, FT_Long b_, FT_Long c_)
 
 FT_MulFix (FT_Long a_, FT_Long b_)
 
 FT_DivFix (FT_Long a_, FT_Long b_)
 
 FT_Matrix_Multiply (const FT_Matrix *a, FT_Matrix *b)
 
 FT_Matrix_Invert (FT_Matrix *matrix)
 
 FT_Matrix_Multiply_Scaled (const FT_Matrix *a, FT_Matrix *b, FT_Long scaling)
 
 FT_Matrix_Check (const FT_Matrix *matrix)
 
 FT_Vector_Transform_Scaled (FT_Vector *vector, const FT_Matrix *matrix, FT_Long scaling)
 
 FT_Vector_NormLen (FT_Vector *vector)
 
 ft_corner_orientation (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 
 ft_corner_is_flat (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   calc

The macro FT_COMPONENT is used in trace mode. It is an implicit parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log messages during execution.

Definition at line 67 of file ftcalc.c.

◆ FT_MOVE_SIGN

#define FT_MOVE_SIGN (   x,
  x_unsigned,
  s 
)
Value:
if ( x < 0 ) \
{ \
x_unsigned = 0U - (x_unsigned); \
s = -s; \
} \
FT_END_STMNT
#define s
Definition: afcover.h:80
float x
Definition: cordic.py:15
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
#define U(a)
Definition: twiddle.h:1

Definition at line 72 of file ftcalc.c.

Typedef Documentation

◆ FT_Int64

typedef struct FT_Int64_ FT_Int64

ftcalc.c

Arithmetic computations (body).

Copyright (C) 1996-2020 by David Turner, Robert Wilhelm, and Werner Lemberg.

This file is part of the FreeType project, and may only be used, modified, and distributed under the terms of the FreeType project 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. Support for 1-complement arithmetic has been totally dropped in this release. You can still write your own code if you need it. Implementing basic computation routines.

FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), and FT_FloorFix() are declared in freetype.h.

Function Documentation

◆ FT_Add64()

static void FT_Add64 ( FT_Int64 x,
FT_Int64 y,
FT_Int64 z 
)
static

Definition at line 350 of file ftcalc.c.

References cordic::x, y, and z.

Referenced by FT_DivFix(), and FT_MulDiv().

◆ FT_CeilFix()

FT_CeilFix ( FT_Fixed  a)

@function: FT_CeilFix

@description: Compute the smallest following integer of a 16.16 fixed number.

@input: a :: The number for which the ceiling function is to be computed.

Returns
: a rounded towards plus infinity.
Note
: The function uses wrap-around arithmetic.

Definition at line 96 of file ftcalc.c.

◆ ft_corner_is_flat()

ft_corner_is_flat ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 1046 of file ftcalc.c.

◆ ft_corner_orientation()

ft_corner_orientation ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 980 of file ftcalc.c.

◆ ft_div64by32()

static FT_UInt32 ft_div64by32 ( FT_UInt32  hi,
FT_UInt32  lo,
FT_UInt32  y 
)
static

Definition at line 311 of file ftcalc.c.

References FT_MSB(), i, q, r, and y.

Referenced by FT_DivFix(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_DivFix()

FT_DivFix ( FT_Long  a,
FT_Long  b 
)

@function: FT_DivFix

@description: Compute (a*0x10000)/b with maximum accuracy. Its main use is to divide a given value by a 16.16 fixed-point factor.

@input: a :: The numerator.

b :: The denominator. Use a 16.16 factor here.

Returns
: The result of (a*0x10000)/b.

Definition at line 607 of file ftcalc.c.

Referenced by FT_Matrix_Check(), and FT_Matrix_Invert().

◆ FT_FloorFix()

FT_FloorFix ( FT_Fixed  a)

@function: FT_FloorFix

@description: Compute the largest previous integer of a 16.16 fixed number.

@input: a :: The number for which the floor function is to be computed.

Returns
: a rounded towards minus infinity.

Definition at line 105 of file ftcalc.c.

◆ FT_Hypot()

FT_Hypot ( FT_Fixed  x,
FT_Fixed  y 
)

Definition at line 154 of file ftcalc.c.

◆ FT_Matrix_Check()

FT_Matrix_Check ( const FT_Matrix matrix)

Definition at line 750 of file ftcalc.c.

◆ FT_Matrix_Invert()

FT_Matrix_Invert ( FT_Matrix matrix)

@function: FT_Matrix_Invert

@description: Invert a 2x2 matrix. Return an error if it can't be inverted.

@inout: matrix :: A pointer to the target matrix. Remains untouched in case of error.

Returns
: FreeType error code. 0~means success.

Definition at line 688 of file ftcalc.c.

◆ FT_Matrix_Multiply()

FT_Matrix_Multiply ( const FT_Matrix a,
FT_Matrix b 
)

Definition at line 660 of file ftcalc.c.

◆ FT_Matrix_Multiply_Scaled()

FT_Matrix_Multiply_Scaled ( const FT_Matrix a,
FT_Matrix b,
FT_Long  scaling 
)

Definition at line 719 of file ftcalc.c.

◆ FT_MSB()

FT_MSB ( FT_UInt32  z)

Definition at line 113 of file ftcalc.c.

Referenced by ft_div64by32(), and FT_Vector_NormLen().

◆ FT_MulDiv()

FT_MulDiv ( FT_Long  a,
FT_Long  b,
FT_Long  c 
)

Definition at line 415 of file ftcalc.c.

Referenced by FT_Matrix_Multiply_Scaled(), and FT_Vector_Transform_Scaled().

◆ FT_MulDiv_No_Round()

FT_MulDiv_No_Round ( FT_Long  a,
FT_Long  b,
FT_Long  c 
)

ftcalc.h

Arithmetic computations (specification).

Copyright (C) 1996-2020 by David Turner, Robert Wilhelm, and Werner Lemberg.

This file is part of the FreeType project, and may only be used, modified, and distributed under the terms of the FreeType project 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. FT_MulDiv() and FT_MulFix() are declared in freetype.h. @function: FT_MulDiv_No_Round

@description: A very simple function used to perform the computation '(a*b)/c' (without rounding) with maximum accuracy (it uses a 64-bit 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.

Returns
: 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'.

Definition at line 463 of file ftcalc.c.

◆ FT_MulFix()

FT_MulFix ( FT_Long  a,
FT_Long  b 
)

@function: FT_MulFix

@description: Compute (a*b)/0x10000 with maximum accuracy. Its main use is to multiply a given value by a 16.16 fixed-point factor.

@input: a :: The first multiplier.

b :: The second multiplier. Use a 16.16 factor here whenever possible (see note below).

Returns
: The result of (a*b)/0x10000.
Note
: This function has been optimized for the case where the absolute value of a is less than 2048, and b is a 16.16 scaling factor. As this happens mainly when scaling from notional units to fractional pixels in FreeType, it resulted in noticeable speed improvements between versions 2.x and 1.x.

As a conclusion, always try to place a 16.16 factor as the second argument of this function; this can make a great difference.

Definition at line 508 of file ftcalc.c.

Referenced by FT_Matrix_Invert(), and FT_Matrix_Multiply().

◆ ft_multo64()

static void ft_multo64 ( FT_UInt32  x,
FT_UInt32  y,
FT_Int64 z 
)
static

Definition at line 279 of file ftcalc.c.

References cordic::x, y, and z.

Referenced by ft_corner_orientation(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_RoundFix()

FT_RoundFix ( FT_Fixed  a)

@function: FT_RoundFix

@description: Round a 16.16 fixed number.

@input: a :: The number to be rounded.

Returns
: a rounded to the nearest 16.16 fixed integer, halfway cases away from zero.
Note
: The function uses wrap-around arithmetic.

Definition at line 87 of file ftcalc.c.

◆ FT_Vector_NormLen()

FT_Vector_NormLen ( FT_Vector vector)

Definition at line 845 of file ftcalc.c.

◆ FT_Vector_Transform_Scaled()

FT_Vector_Transform_Scaled ( FT_Vector vector,
const FT_Matrix matrix,
FT_Long  scaling 
)

Definition at line 820 of file ftcalc.c.