Commit Graph

136 Commits

Author SHA1 Message Date
Werner Lemberg a50a045890 Minor. 2015-07-28 07:37:19 +02:00
Alexei Podtelezhnikov e8b186eedb * src/base/ftcalc.c (FT_Vector_NormLen): Explicate type conversions. 2015-07-27 23:22:34 -04:00
Alexei Podtelezhnikov 884e4e67ee [base] Implement fast vector normalization.
The function uses Newton's iterations instead of dividing vector
components by its length, which needs a square root. This is,
literally, a bit less accurate but a lot faster.

* src/base/ftcalc.c (FT_Vector_NormLen): New function.
2015-06-29 22:32:05 -04:00
Werner Lemberg d3240c56e5 [base] Fix Savannah bug #44284.
* src/base/ftcalc.c (FT_MulFix): Typos.
2015-02-17 20:30:36 +01:00
Werner Lemberg 6d7d636b46 [base] Clean up signedness in arithmetic functions.
This makes the code more readable and reduces compiler warnings.

* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round, FT_MulFix,
FT_DivFix): Convert input parameters to unsigned, do the
computation, then convert the result back to signed.
(ft_corner_orientation): Fix casts.
2015-02-15 12:30:42 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Alexei Podtelezhnikov 7024155328 [base] Formatting and nanooptimizations.
* src/base/ftcalc.c,
* src/base/fttrigon.c: Revise sign restoration.
2014-12-24 12:11:46 -05:00
Werner Lemberg 9870d6dacf */*: Decorate hex constants with `U' and `L' where appropriate. 2014-12-07 09:40:47 +01:00
Alexei Podtelezhnikov 237c0abfdc Trailing space. 2014-11-19 22:10:29 -05:00
Werner Lemberg d8632a842e Improve comments, remove dead code. 2014-10-25 06:28:18 +02:00
Alexei Podtelezhnikov aba0f498c3 Improve flat corner definition.
* include/internal/ftcalc.h (FT_HYPOT): Macro to approximate Euclidean
distance with the alpha max plus beta min algorithm.
* src/base/ftcalc.c (ft_corner_is_flat): Use it instead of Taxicab metric.
2014-10-24 23:50:57 -04:00
Alexei Podtelezhnikov 7abdb8ccea [base] Significant optimization of `ft_div64by32'
We shift as many bits as we can into the high register, perform
32-bit division with modulo there, then work through the remaining
bits with long division. This optimization is especially noticeable
for smaller dividends that barely use the high register.

* src/base/ftcalc.c (ft_div64by32): Updated.
2014-10-02 23:13:33 -04:00
Werner Lemberg c0ce72a6de Formatting. 2014-10-02 06:44:43 +02:00
Alexei Podtelezhnikov 74d0aad22c * src/base/ftcalc.c: Remove miscellaneous type casts. 2014-10-01 23:27:15 -04:00
Alexei Podtelezhnikov 418e18f3df [base] Use more common `FT_MSB' implementation with masks.
* src/base/ftcalc.c (FT_MSB): Updated.
2014-10-01 22:36:40 -04:00
Alexei Podtelezhnikov 955aff12c0 [base] Clean up.
* src/base/ftcalc.c (FT_MOVE_SIGN): New macro for frequently used code.
2014-09-30 23:09:39 -04:00
Alexei Podtelezhnikov f78ca0dbb9 Remove commented out code. 2014-09-30 22:53:38 -04:00
Alexei Podtelezhnikov 7f49111f81 [base] Avoid unnecessary long division.
This applies to `FT_MulDiv' but not to `FT_DivFix', where overflows or
lack thereof are predicted accurately.

* src/base/ftcalc.c (ft_div64by32): Improve readability.
(FT_MulDiv, FT_MulDiv_No_Round) [!FT_LONG64]: Use straight division
when multiplication stayed within 32 bits.
2014-09-25 22:54:38 -04:00
Alexei Podtelezhnikov 5c894842d3 * src/base/ftcalc.c: Harmonize code. 2014-09-19 22:03:15 -04:00
Alexei Podtelezhnikov ef070d458b [base] Tighten the overflow check in `FT_MulDiv'.
* src/base/ftcalc.c (FT_MulDiv) [!FT_LONG64]: Updated.
2014-09-15 22:06:19 -04:00
Alexei Podtelezhnikov 336735d8de [base] Tighten the overflow check in `FT_DivFix'.
This fixes a 13-year old bug. The original overflow check should have
been updated when rounding was introduced into this function
(c2cd00443b).

* src/base/ftcalc.c (FT_DivFix) [!FT_LONG64]: Updated.
* include/freetype.h (FT_DivFix): Updated documentation.
2014-09-03 22:55:26 -04:00
Alexei Podtelezhnikov 3212852cce [base] Tighten the overflow check in `FT_MulFix'.
* src/base/ftcalc.c (FT_MulFix) [!FT_LONG64]: Updated.
2014-09-03 21:57:42 -04:00
Behdad Esfahbod 1ec98b29ec Don't use `register' keyword. Fixes compiler warnings.
* src/base/ftcalc.c (FT_Add64) [!FT_LONG64]: Do it.
* src/gzip/inftrees.c (huft_build): Ditto.
* src/truetype/ttinterp.c (TT_MulFix14_arm): Ditto.
2014-08-31 08:47:11 +02:00
Werner Lemberg 70961e5772 Minor. 2014-08-20 16:19:32 +02:00
Alexei Podtelezhnikov 8fd87d4e69 [base] Small optimization of `FT_MulFix'.
* src/base/ftcalc.c (FT_MulFix): Loosen up the condition for direct
32-bit calculations.
2014-08-20 00:57:22 -04:00
Alexei Podtelezhnikov f09326a1a6 [base] Use unsigned calculation in `FT_MulDiv'.
* src/base/ftcalc.c (FT_MulDiv): Updated to expand 32-bit range.
2014-08-20 00:08:38 -04:00
Alexei Podtelezhnikov 382f3155f6 [base] Remove truncation in `FT_DivFix'.
* src/base/ftcalc.c (FT_DivFix): Updated.
2014-08-18 23:16:15 -04:00
Alexei Podtelezhnikov 5ef2023c45 Minor refactoring.
* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
2014-08-14 23:21:46 -04:00
Alexei Podtelezhnikov c7022467d2 Turn FT_MSB into a macro when using gcc builtins.
* src/base/ftcalc.c, include/internal/ftcalc.h: Updated.
2014-08-14 23:01:01 -04:00
Alexei Podtelezhnikov 4728993fa8 [base] Restore FT_MulFix inlining.
* include/freetype.h (FT_MulFix): Unconditionally defined.

* src/base/ftcalc.c [FT_MULFIX_ASSEMBLER]: Move code from here...

* include/internal/ftcalc.h [FT_MULFIX_ASSEMBLER]: ... to here,
which conditionally replaces the function with an inline version
through the macro.
2014-08-11 23:39:34 -04:00
Werner Lemberg cbbf26b705 Whitespace. 2014-07-17 17:27:12 +09:00
Alexei Podtelezhnikov 177982e933 * src/base/ftcalc.c (FT_MSB): Utilize gcc builtins. 2014-07-15 23:54:34 -04:00
Alexei Podtelezhnikov 71330ceb50 [base] Move assembler code back in the source file.
FT_MulFix assembler used to reside in ftcalc.c before f47d263f1b.

* include/config/ftconfig.h, builds/unix/ftconfig.in,
builds/vms/ftconfig.h [FT_MULFIX_ASSEMBLER]: Move code from here...

* src/base/ftcalc.c [FT_MULFIX_ASSEMBLER]: ... to here.
2014-07-15 23:30:45 -04:00
Alexei Podtelezhnikov 2f52df4a0d [base] Improve comment. 2014-07-05 22:29:26 -04:00
Alexei Podtelezhnikov ceab95a649 [base] Small optimization of the ancient code.
* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Loosen up the
condition for direct 32-bit calculations.
2014-07-04 23:01:32 -04:00
Werner Lemberg d515992587 Another revert for the change from 2014-03-18.
Problem reported by Nikolaus Waxweiler <madigens@gmail.com>.

* src/base/ftcalc.c (FT_MulFix): Ensure that an `FT_MulFix' symbol
gets always exported.
2014-03-22 06:20:54 +01:00
Sean McBride 87628724a9 Fix clang warnings.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Initialize
some variables.

* src/base/ftcalc.c (FT_MulFix): Only use code if
`FT_MULFIX_INLINED' is not defined.

* src/bdf/bdfdrivr.c (bdf_cmap_class), src/cache/ftcbasic.c
(ftc_basic_image_family_class, ftc_basic_image_cache_class,
ftc_basic_sbit_family_class, ftc_basic_sbit_cache_class),
src/cache/ftccmap.c (ftc_cmap_cache_class), src/cache/ftcmanag.c
(ftc_size_list_class, ftc_face_list_class), src/pcf/pcfdrivr.c
(pcf_cmap_class), src/pfr/pfrdrivr.c (pfr_metrics_service_rec): Make
function static.

* src/type1/t1driver.c (t1_ps_get_font_value): Remove redundant
code.
2014-03-18 08:39:35 +01:00
Sean McBride 7be2a94a50 Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.

* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.

* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.

* src/base/ftrfork.c: Include `ftbase.h'.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.

* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
Werner Lemberg bcd8c0b0eb Remove `FT_SqrtFixed' function.
It's no longer used.

* include/freetype/internal/ftcalc.h, src/base/ftcalc.c: Do it.
2013-08-27 21:36:03 +02:00
Werner Lemberg ba9cf52d3b Comment typo. 2013-08-05 07:00:59 +02:00
Werner Lemberg fb09a51f0f Add comments to `ft_corner_is_flat'. 2013-08-04 18:24:02 +02:00
Werner Lemberg b112fa4190 Fix Savannah bug #38967.
* src/base/ftcalc.c (FT_DivFix) [FT_LONG64]: Fix cast.
2013-05-12 07:29:04 +02:00
Werner Lemberg f6aa089f12 */* [FT_CONFIG_OPTION_OLD_INTERNALS]: Remove macro and guarded code. 2013-05-10 07:58:47 +02:00
Werner Lemberg d135e27c23 Fix 64bit compilation issues.
* include/freetype/config/ftconfig.h [FT_LONG64]: Typedef
`FT_Int64' here.

* src/base/ftcalc.c: Remove typedef of `FT_Int64'.
(FT_DivFix): Fix cast.
* src/base/fttrigon.c: Remove typedef of `FT_Int64'.
2013-05-05 10:44:21 +02:00
Werner Lemberg 94152819b0 More fixes for clang's `sanitize' feature.
* src/base/ftcalc.c (FT_DivFix): Use unsigned values for
computations which use the left shift operator and convert to signed
as the last step.
* src/base/fttrigon.c (ft_trig_prenorm, FT_Vector_Rotate,
FT_Vector_Length, FT_Vector_Polarize): Ditto.

* src/cff/cffgload.c (cff_decoder_parse_charstrings): Simplify.
* src/cff/cffload.c (cff_subfont_load): Fix constant.
* src/cff/cffparse.c (cff_parse_integer, cff_parse_real, do_fixed,
cff_parse_fixed_dynamic): Use unsigned values for computations which
use the left shift operator and convert to signed as the last step.

* src/cid/cidload.c (cid_get_offset): Ditto.

* src/psaux/psconv.c (PS_Conv_ToFixed): Ditto.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Ditto.

* src/truetype/ttinterp.c (TT_MulFix14, TT_DotFix14): Ditto.
2013-05-04 16:40:12 +02:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.

To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code.  Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
2013-03-14 10:27:35 +01:00
Werner Lemberg 30f1e6ca45 Fix Savannah bug #38221.
This complements commit 83c0ebab.

* src/base/ftcalc.c (FT_MulDiv_No_Round): Don't enclose with
`TT_USE_BYTECODE_INTERPRETER'.
2013-02-01 14:50:08 +01:00
Werner Lemberg e9f330adf6 [base] Make `FT_Hypot' really internal.
* include/freetype/fttrigon.h (FT_Hypot): Move to...
* include/freetype/internal/ftcalc.h: This file.

* src/base/fttrigon.c (FT_Hypot): Move to...
* src/base/ftcalc.c: This file.
Include FT_TRIGONOMETRY_H.

* src/truetype/ttgload.c: Don't include FT_TRIGONOMETRY_H.
2013-01-24 09:12:56 +01:00
Alexei Podtelezhnikov 869fb8c49d [base] Split out MSB function.
* src/base/fttrigon.c (ft_trig_prenorm): Borrow from here.
* include/freetype/internal/ftcalc.h (FT_MSB): Declare here.
* src/base/ftcalc.c (FT_MSB): Define here.
2013-01-23 19:43:28 -05:00
Werner Lemberg ba67957d5e Fix Savannah bug #35660.
For some divisions, we use casts to 32bit entities.  Always guard
against division by zero with these casts also.

* src/base/ftcalc.c (ft_div64by32): Remove redundant cast.
(FT_MulDiv, FT_MulDiv_No_Round): Add 32bit cast.
(FT_DivFix): Add 32bit cast (this omission triggered the bug).
2012-03-03 12:27:18 +01:00