Commit Graph

403 Commits

Author SHA1 Message Date
Alexei Podtelezhnikov 410f3799b6 [smooth] Harmony LCD rendering.
This is a new technology for LCD-optimized rendering. It capitalizes
on the fact that each color channel grid is shifted by a third of a
pixel.  Therefore it is logical to render 3 separate monochrome
bitmaps shifting the outline by 1/3 pixel, and then combine them.
Importantly, the resulting output does not require additional LCD
filtering.

* src/smooth/ftsmooth.c (ft_smooth_render_generic)
[!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Implement new LCD-optimized
rendering.

* include/freetype/ftlcdfil.h, include/freetype/freetype.h,
include/freetype/config/ftoption.h, devel/ftoption.h: Updated
documentation.
2017-08-08 22:29:51 -04:00
Alexei Podtelezhnikov 5710ef989d * src/smooth/ftsmooth.c (ft_smooth_render_generic): Clean up. 2017-08-08 22:00:35 -04:00
Alexei Podtelezhnikov 7b7278334c [base, smooth] LCD filtering cleanups.
* src/base/ftlcdlil.c (ft_lcd_filter_fir, _ft_lcd_filter_legacy):
Clean up, start filtering from the bottom-left origin.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Updated.
2017-06-17 23:28:14 -04:00
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg cd02d359a6 [smooth] Some 32bit integer overflow run-time errors.
* src/smooth/ftgrays.c [STANDALONE] (OVERFLOW_ADD_LONG,
OVERFLOW_SUB_LONG, OVERFLOW_MUL_LONG, NEG_LONG): New macros.
[!STANDALONE]: Include FT_INTERNAL_CALC_H.
(gray_render_cubic): Use those macros where appropriate.
2017-06-01 17:05:39 +02:00
Alexei Podtelezhnikov ab2599ea3f [smooth] Implement minimal dynamic padding for LCD filtering.
Extra bitmap padding for LCD filtering depends on the filter.  The
default 5-tap filter needs 2 extra subpixels.  The light 3-tap filter
needs only 1 extra subpixel.  This space could be already available
due to rounding.  In order to optimize the padding, we now expand
CBox for the given filter weights before rounding.

This change breakes current Skia (and Firefox).

* include/freetype/internal/ftobjs.h (FT_LibraryRec)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Remove `lcd_extra' field.

* src/base/ftlcdfil.c (FT_Library_SetLcdFilterWeights,
FT_Library_SetLcdFilter): Remove `lcd_extra' initializations.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Implement dymanic
LCD padding.
2017-05-20 00:35:21 -04:00
Werner Lemberg e99b26aada Remove remnants of raster pool.
* include/freetype/internal/ftobjs.h (FT_LibraryRec): Remove
`raster_pool' and `raster_pool_size' fields.

* src/base/ftobjs.c (FT_New_Library), src/raster/ftrend1.c
(ft_raster1_init), src/smooth/ftsmooth.c (ft_smooth_init): Updated.
2017-05-14 21:57:27 +02:00
Werner Lemberg ba40054c2d [autofit] Remove `slight' auto-hint mode again.
A poll on freetype-devel favoured changes directly applied to
`light'.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT,
FT_RENDER_MODE_SLIGHT): Removed.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2.c
(af_latin2_hints_init): Revert change from 2017-04-22.

* src/autofit/afloader.c (af_loader_load_glyph) Remove references to
FT_RENDER_MODE_SLIGHT.
[AF_CONFIG_OPTION_TT_SIZE_METRICS]: Enable TrueType-like metrics
unconditionally.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Revert change from
2017-04-22.

* src/base/ftobjs.c (FT_Load_Glyph): Revert change from 2017-04-22.

* src/pshinter/pshalgo.c (ps_hints_apply): Revert change from
2017-04-22.

* src/smooth/ftsmooth.c (ft_smooth_render): Revert change from
2017-04-22.

* docs/CHANGES: Updated.
2017-05-02 12:32:19 +02:00
Werner Lemberg 5aa6716a5e Add new `slight' auto-hinting mode.
This mode uses fractional advance widths and doesn't scale glyphs
horizontally, only applying vertical scaling and hinting.

At the same time, the behaviour of the `light' auto-hinter gets
restored for backwards compatibility: Both vertical and horizontal
scaling is again based on rounded metrics values (this was changed
in a commit from 2017-03-30 as a side effect).  To be more precise,
the behaviour is restored for TrueType fonts only; for other font
formats like Type 1, this is a new feature of the `light' hinting
mode.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro.
(FT_RENDER_MODE_SLIGHT): New render mode.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add
`autohint_mode' and `autohint_metrics' fields.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init):
Updated.

* src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use
`autohint_metrics'.
(af_loader_load_glyph): s/internal/slot_internal/.
Initialize `autohint_metrics' and `autohint_mode' depending on
current auto-hint mode.
Use `autohint_metrics'.
Updated.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated.

* src/base/ftobjs.c (FT_Load_Glyph): Updated.
(FT_New_Size): Allocate `internal' object.

* src/pshinter/pshalgo.c (ps_hints_apply): Updated.

* src/smooth/ftsmooth.c (ft_smooth_render): Updated.
2017-04-26 11:39:53 +02:00
Alexei Podtelezhnikov eb5e0fb7ee * src/smooth/ftsmooth.h: Remove unused guards and declaration. 2017-04-21 22:53:39 -04:00
Alexei Podtelezhnikov 71d289da3b Typos. 2017-04-19 23:50:29 -04:00
Werner Lemberg 9931175dcc Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.

* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.

* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.

* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.

* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.

* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.

* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.

* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.

* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
Alexei Podtelezhnikov 761d9e418b * src/smooth/ftgrays.c (gray_hline): Improve code. 2017-02-22 22:41:36 -05:00
Nikolaus Waxweiler 2e9519885b Add face property for LCD filter weights.
* include/freetype/ftlcdfil.h (FT_PARAM_TAG_LCD_FILTER_WEIGHTS,
FT_LCD_FILTER_FIVE_TAPS): New macros.
(FT_LcdFiveTapFilter): New typedef.

* include/freetype/ftobjs.h (FT_Face_InternalRec)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Add `lcd_weights' field.
(FT_Bitmap_LcdFilterFunc): Change third argument to weights array.
(ft_lcd_filter_fir): New prototype.
(FT_LibraryRec): Updated.

* src/base/ftlcdfil.c (_ft_lcd_filter_fir): Renamed to...
(ft_lcd_filter_dir): ... this base function.
Updated.
(_ft_lcd_filter_legacy): Updated.
(FT_Library_SetLcdFilterWeights, FT_Library_SetLcdFilter): Updated.

* src/base/ftobjs.c (ft_open_face_internal): Updated.
(FT_Face_Properties): Handle FT_PARAM_TAG_LCD_FILTER_WEIGHTS.

* src/smooth/ftsmooth.c (ft_smooth_render_generic)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING: Handle LCD weights from
`FT_Face_Internal'.
2017-02-16 20:45:45 +01:00
Alexei Podtelezhnikov fcd47b3d3e * src/smooth/ftgrays.c (gray_sweep): Improve code. 2017-02-12 23:07:29 -05:00
Alexei Podtelezhnikov a3754d6626 Comment. 2017-02-01 22:36:16 -05:00
Alexei Podtelezhnikov 2ca5b07d4f * src/smooth/ftgrays.c (gray_render_scanline): Improve code. 2017-01-31 23:13:50 -05:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 24be60b5f1 */*: Use hex numbers for errors in tracing messages. 2017-01-01 08:20:38 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg 1d28f697d2 [smooth] Revert previous commit. Already fixed with 6ca54c64. 2016-11-29 18:45:22 +01:00
Werner Lemberg d949a3db58 [smooth] Avoid conditional jump on uninitialized value (#49711).
* src/smooth/ftgrays.c (gray_raster_render): Initialize `worker'.
2016-11-29 12:09:56 +01:00
Alexei Podtelezhnikov b0aacff474 [smooth] Remove impossibility.
* src/smooth/ftgrays.c (TWorker): Rearrange fields.
(gray_convert_glyph): Remove impossible condition and clean up.
2016-10-01 12:55:33 -04:00
Werner Lemberg 45cad2e5e1 More FT_ZERO usage.
* src/gxvalid/gxvcommn.c (gxv_ClassTable_validate):
s/ft_memset/FT_MEM_ZERO/.

* src/psaux/t1decode.c (t1_decoder_parse_charstrings):
s/ft_memset/FT_ARRAY_ZERO/.

* src/raster/ftraster.c (FT_ZERO): Define.
(ft_black_new): Use it.
* src/raster/ftrend1.c (ft_raster1_get_cbox):
s/FT_MEM_ZERO/FT_ZERO/.

* src/smooth/ftgrays.c (FT_ZERO): Define.
(gray_raster_new): Use it.
* src/smooth/ftsmooth.c (ft_smooth_get_cbox):
s/FT_MEM_ZERO/FT_ZERO/.
2016-09-28 19:10:52 +02:00
Alexei Podtelezhnikov 53ae7a542d [smooth] Reduce divisions in the line renderer.
We don't need some divisions if a line segments stays within a single
row or a single column of pixels.

* src/smooth/ftgrays.c (gray_render_line) [FT_LONG64]: Make divisions
conditional.
2016-09-22 22:48:15 -04:00
Werner Lemberg c95b7652d8 s/0/NULL/ for function pointers; comments, formatting. 2016-09-17 17:12:50 +02:00
Alexei Podtelezhnikov d5f7533e8e * src/smooth/ftgrays.c (gray_sweep): Remove check for empty table. 2016-09-15 00:13:36 -04:00
Alexei Podtelezhnikov ad47550b80 [smooth] Another tiny speed-up.
* src/smooth/ftgrays.c (gray_find_cell): Merge into...
(gray_record_cell): ... this function.
2016-09-14 23:15:03 -04:00
Alexei Podtelezhnikov c38be52bf8 * src/smooth/ftgrays.c (gray_{find,set}_cell): Remove dubious code. 2016-09-11 22:44:44 -04:00
Alexei Podtelezhnikov 6ca54c6430 [smooth] Fix valgrind warning and reoptimize.
The algorithm calls `gray_set_cell' at the start of each new contour
or when the contours cross the cell boundaries. Double-checking for
that is wasteful.

* src/smooth/ftgrays.c (gray_set_cell): Remove check for a new cell.
(gray_convert_glyph): Remove initialization introduced by 44b172e88.
2016-09-11 16:00:52 -04:00
Alexei Podtelezhnikov a0b92bcb47 * src/smooth/ftgrays.c (gray_hline): Microptimize. 2016-09-07 23:19:57 -04:00
Alexei Podtelezhnikov 9d0a3bd848 [smooth] Operate in absolute bitmap coordinates.
Simpler bitmap addressing improves performance by 1.5%.

* src/smooth/ftgrays.c (gray_TWorker): Remove count fields.
(gray_dump_cells, gray_find_cell, gray_set_cell, gray_hline,
gray_sweep, gray_convert_glyph, gray_raster_render): Updated.
2016-09-06 23:59:33 -04:00
Alexei Podtelezhnikov 44b172e883 [smooth] Improve contour start (take 2).
* src/smooth/ftgrays.c (gray_move_to): Call `gray_set_cell' directly
instead of...
(gray_start_cell): ... this function, which is removed.
(gray_convert_glyph): Make initial y-coordinate invalid.
2016-09-06 23:24:17 -04:00
Alexei Podtelezhnikov 9773d5f721 * src/smooth/ftgrays.c (gray_move_to, gray_start_cell): Revert. 2016-09-05 23:33:35 -04:00
Alexei Podtelezhnikov 7effc279b0 [smooth] Improve contour start.
* src/smooth/ftgrays.c (gray_move_to): Call `gray_set_cell' directly
instead of...
(gray_start_cell): ... this function, which is removed.
2016-09-05 21:58:56 -04:00
Werner Lemberg 16583ccde9 * src/smooth/ftgrays.c (gray_hline): Fix clang compiler warnings. 2016-09-02 22:45:14 +02:00
Alexei Podtelezhnikov 11d3336af3 [smooth] Simplify span rendering more.
It turns out that there is significant cost associated with `FT_Span'
creation and calls to `gray_render_span' because it happerns so
frequently. This removes these steps from our internal use but leaves
it alone for `FT_RASTER_FLAG_DIRECT" to preserve API. The speed gain
is about 5%.

* src/smooth/ftgrays.c (gray_render_span): Removed. The code is
migrated to...
(gray_hline): ... here.
2016-09-01 22:56:24 -04:00
Alexei Podtelezhnikov f44ddfda45 [smooth] Streamline pixmap drawing a bit more.
Zero coverage is unlikely (1 out of 256) to warrant checking. This
gives 0.5% speed improvement in dendering simple glyphs.

* src/smooth/ftgrays.c (gray_hline, gray_render_span): Remove checks.
2016-08-30 23:21:23 -04:00
Alexei Podtelezhnikov e73055c791 [smooth] Streamline pixmap drawing.
This gives 2% speed improvement in rendering simple glyphs.

* src/smooth/ftgrays.c (TPixmap): Reduced pixmap descriptor with a
pointer to its bottom-left and pitch to be used in...
(gray_TWorker): ... here.
(gray_render_span): Move pixmap flow check from here...
(gray_raster_render): .. to here.
2016-08-29 23:15:35 -04:00
Alexei Podtelezhnikov 4d3f7ca8ce [smooth] Reduce stack of band boundaries.
* src/smooth/ftgrays.c (gray_TBand): Removed.
(gray_convert_glyph): Updated to stack band boundaries concisely.
2016-08-27 23:25:54 -04:00
Alexei Podtelezhnikov 9a444f0547 * src/smooth/ftgrays.c (gray_raster_render): Minor tweaks. 2016-08-25 22:36:01 -04:00
Alexei Podtelezhnikov cb4388783c [smooth] Simplify span rendering.
This removes unnecessary complexity of span merging and buffering.
Instead, the spans are rendered as they come, speeding up the
rendering by about 5% percents as a result.

* src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed.
(gray_TWorker): Remove span buffer and related fields.
(gray_sweep, gray_hline): Updated.

* include/freetype/ftimage.h: Remove documentation note about
`FT_MAX_GRAY_SPANS', which was never in `ftoption.h' and is now gone.
2016-08-22 23:06:45 -04:00
Peter Klotz 3b37bfc4b5 * src/smooth/ftgrays.c (gray_hline): Fix uninitialized access. 2016-08-10 22:38:08 -04:00
Alexei Podtelezhnikov 97718f3c91 [smooth] Minor refactoring.
* src/smooth/ftgrays.c (gray_render_scanline, gray_render_line):
Updated.
2016-08-05 23:36:16 -04:00
Werner Lemberg 971f10b63a Formatting. 2016-07-08 06:59:31 +02:00
Werner Lemberg 109d1662d4 Revert "Formatting."
This reverts commit a0f3a1f25a.
2016-07-08 06:58:46 +02:00
Werner Lemberg a0f3a1f25a Formatting. 2016-07-08 06:53:46 +02:00
Alexei Podtelezhnikov 4a2f8f1faf [smooth] Sub-banding protocol revision.
Rasterization sub-banding is utilized at large sizes while using
rather small fixed memory pool. Indeed it is possible to make an
educated guess how much memory is necessary at a given size for a
given glyph. It turns out that, for large majority of European glyphs,
you should store about 8 times more boundary pixels than their height.
Or, vice versa, if your memory pool can hold 800 pixels the band
height should be 100 and you should sub-band anything larger than
that. Should you still run out of memory, FreeType bisects the band
but you have wasted some time. This is what has been implemented in
FreeType since the beginning.

It was overlooked, however, that the top band could grow to twice the
default band size leading to unnecessary memory overflows there. This
commit fixes that. Now the bands are distributed more evenly and
cannot exceed the default size.

Now the magic number 8 is really suitable for rather simple European
scripts. For complex Chinese logograms the magic number should be 13
but that is subject for another day.

* src/smooth/ftgrays.c (gray_convert_glyph): Revise sub-banding
protocol.
2016-07-08 00:16:07 -04:00
Alexei Podtelezhnikov d1876e5832 [smooth] Variable type revision (part 2).
* src/smooth/ftgrays.c (TArea): Restore original definition as `int'.
(gray_render_line) [FT_LONG64]: Updated.
(gray_convert_glyph): 32-bit band bisection stack should be 32 bands.
(gray_convert_glyph_inner): Trace successes and failures.
2016-07-04 23:46:53 -04:00
Alexei Podtelezhnikov 597c69596c [smooth] Variable type revision (part 1).
This patch restores original `TCoord' definition as `int' so that the
rendering pool is used more efficiently on LP64 platforms (unix).

* src/smooth/ftgrays.c (gray_TWorker, TCell, gray_TBand): Switch some
fields to `TCoord'.
(gray_find_cell, gray_render_scanline, gray_render_line, gray_hline,
gray_sweep, gray_convert_glyph): Updated.
2016-07-01 23:27:41 -04:00
Alexei Podtelezhnikov ef0a3e7e65 [smooth] Minor clean-ups.
* src/smooth/ftgrays.c (gray_TWorker): Remove redundant `ycount'.
(gray_sweep, gray_convert_glyph, gray_dump_cells): Updated.
2016-06-28 22:56:22 -04:00
Alexei Podtelezhnikov c9cf359fd2 [smooth] Minor clean-ups.
* src/smooth/ftgrays.c (gray_convert_glyph): Do not use volatile
qualifier.
(gray_raster_render): Move span initializations from here.
(gray_sweep): ... to here and remove unused `target' argument.
2016-06-28 00:30:58 -04:00
Alexei Podtelezhnikov 25e82bc2b5 [smooth] Consolidate memory management.
* src/smooth/ftgrays.c (gray_init_cells): Remove function.
(gray_TWorker): Remove fields that become local variables.
(gray_raster_render): Move rendering buffer declaration from here.
(gray_convert_glyph): ... to here and update accordingly.
2016-06-23 23:17:39 -04:00
Alexei Podtelezhnikov e22334812f [smooth] Consolidate boundary checks.
Removing the checks from `gray_hline' shaves 1% off rendering speed.

* src/smooth/ftgrays.c [STANDALONE_]: Duplicate `FT_MIN' and `FT_MAX'.
(gray_TWorker): No need to store `clip_box'.
(gray_hline): Remove unnecessary boundary checks.
(gray_convert_glyph): Move boundary checks from here.
(gray_raster_render): ... to here and consolidate.
2016-06-22 23:14:26 -04:00
Alexei Podtelezhnikov 78e8fc0dad [smooth] Use `FT_Outline_Get_CBox'.
* src/smooth/ftgrays.c [STANDALONE_]: Duplicate `FT_Outline_Get_CBox'.
(gray_compute_cbox): Remove this function.
(gray_convert_glyph): Update to use `FT_Outline_Get_CBox'.
2016-06-22 00:04:08 -04:00
Werner Lemberg 20c6ef4c25 [smooth] Remove compiler warnings.
* src/smooth/ftgrays.c (gray_convert_glyph): Fix reports from clang.
2016-06-21 11:39:34 +02:00
Alexei Podtelezhnikov 3c64af98ff [smooth] Sanitize memory managenent.
* src/smooth/ftgrays.c (gray_convert_glyph): Cleaned up.
2016-06-20 00:01:55 -04:00
Alexei Podtelezhnikov 74fd251b4a [smooth] Remove `band_shoot' that never worked.
* src/smooth/ftgrays.c (gray_TWorker): Remove `band_shoot'.
(gray_convert_glyph): Updated.
2016-06-18 22:31:26 -04:00
Alexei Podtelezhnikov 3e1f7bc506 Fresh typos. 2016-06-18 22:13:23 -04:00
Alexei Podtelezhnikov 72a0653142 [raster, smooth] Handle FT_RENDER_POOL_SIZE better.
* src/raster/ftraster.c (FT_MAX_BLACK_POOL): New macro.
(ft_black_render): Updated.
* src/smooth/ftgrays.c (FT_MAX_GRAY_POOL): New macro.
(gray_raster_render): Updated.
2016-06-17 23:10:22 -04:00
Alexei Podtelezhnikov 7f569f4574 Move function. 2016-06-14 23:49:31 -04:00
Alexei Podtelezhnikov 32acceff83 * src/smooth/ftgrays.c (gray_hline): Optimize if-condition. 2016-06-14 23:38:17 -04:00
Alexei Podtelezhnikov 77180c7adc [smooth] Re-enable new line renderer on 64-bit archs.
* src/smooth/ftgrays (gray_render_line): Conditionally re-enable new
implementation, where it is safe from overflows.
2016-06-08 23:31:28 -04:00
Alexei Podtelezhnikov 9cf232ed66 [smooth] Minor clean-ups.
* src/smooth/ftgrays.c (gray_dump_cells): Move out of the way.
(gray_render_span): Remove spurious casts and streamline.
2016-06-08 23:19:41 -04:00
Alexei Podtelezhnikov e9f950938f [smooth] Shrink bisection stack.
The convergence of Bézier flatteners is fast with the deviation
from straight line being assymptotically cut 4-fold on each bisection.
This justifies smaller bisection stack size.

* src/smooth/ftgrays.c (gray_TWorker): Remove common `bez_stack'.
(gray_render_conic): Create and use conic `bez_stack'. Move back the
band analysis from...
(gray_conic_to): ... here.
(gray_render_cubic): Create and use cubic `bez_stack'. Move back the
band analysis from...
(gray_cubic_to): ... here.
(gray_move_to): Updated.
2016-05-26 23:46:38 -04:00
Alexei Podtelezhnikov 6e88087d69 [smooth] More efficient accounting of conic splits and draws.
A single decrement counter of segments to draw, instead of an array,
contains all the information necessary to decide when to split and
when to draw a conic segment. The number of splits before each draw is
equal to the number of trailing zeros in the counter.

* src/smooth/ftgrays.c (gray_TWorker): Remove `lev_stack'.
(gray_render_conic): Updated to use decrement counter of segments.
2016-05-05 23:41:03 -04:00
Alexei Podtelezhnikov 98967b77e5 Add comment. 2016-03-23 23:07:24 -04:00
Werner Lemberg 31f2dc1946 [raster, smooth] Directly test outline size (#47500).
This improves stand-alone compilation.

* src/base/ftoutln.c (FT_Outline_Render): Move cbox size test to...

* src/raster/ftraster.c (ft_black_render), src/smooth/ftgrays.c
(gray_raster_render): ...these functions.
2016-03-23 07:31:59 +01:00
Werner Lemberg e9181aba2c [raster, smooth] Fix some clang sanitizer runtime issues.
* src/raster/ftraster.c (ft_black_reset, ft_black_set_mode,
ft_black_render): Harmonize signatures with `ftimage.h'.

* src/smooth/ftgrays.c (gray_raster_render, gray_raster_reset):
Ditto.
2016-03-23 06:58:20 +01:00
Alexei Podtelezhnikov 3beccbdf39 [smooth] Partly revert recent changes.
* src/smooth/ftgrays.c (gray_conic_to, gray_cubic_to): Rework
conditions to fix rendering issues.
2016-03-21 00:07:47 -04:00
Alexei Podtelezhnikov 8e8bb126d1 [smooth] Minor refactoring and microoptimizations.
* src/smooth/ftgrays.c (gray_render_conic, gray_render_cubic): Move
band clipping from here.
(gray_conic_to, gray_cubic_to): ... to here.
(gray_rander_line, gray_render_scanline): Initialize variables closer
to their use.
2016-03-18 23:21:59 -04:00
Alexei Podtelezhnikov 84b2c63374 [smooth] Minor refactoring.
* src/smooth/ftgrays.c (gray_render_conic, gray_render_cubic): Move
upscaling from here...
(gray_conic_to, gray_cubic_to):... to here.
2016-03-17 00:53:09 -04:00
Alexei Podtelezhnikov 1865575a71 [smooth] Temporarily revert 6eb6158dd7 (#47114).
* src/smooth/ftgrays.c (gray_render_line): Old implementation.
2016-03-14 22:39:22 -04:00
Alexei Podtelezhnikov d0b0e31ed7 [smooth] Replace left shifts with multiplications (#47114).
* src/smooth/ftgrays.c (SUBPIXELS, UPSCALE, DOWNSCALE): Do it.
2016-03-06 23:01:50 -05:00
Werner Lemberg 015c6e08a1 Fix clang warnings.
* src/autofit/aflatin.c (af_latin_hints_compute_segments): Use
FT_UShort for `min_flags' and `max_flags'.
Initialize `prev_*' variables.

* src/cff/cffobjs.c (cff_face_init) [FT_DEBUG_LEVEL_TRACE]: Fix
types of local variables.

* src/smooth/ftgrays.c (gray_dump_cells) [FT_DEBUG_LEVEL_TRACE]:
Update `printf' format string.

* src/tools/ftfuzzer/ftfuzzer.cc (setIntermediateAxis): Add cast.
(LLVMFuzzerTestOneInput): Fix loop type.
2016-03-01 06:45:52 +01:00
Alexei Podtelezhnikov 08e89b734c [smooth] Fix integer overflow (#47114).
* src/smooth/ftgrays.c (TArea): Make it unconditionally `long'.
2016-02-16 22:32:13 -05:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 9d0b76d7f6 Don't use macro names that start with `_[A-Z]' [2/3].
Such macro names are reserved for both C and C++.

* include/freetype/ftimage.h, src/raster/ftraster.c,
src/smooth/ftgrays.c, src/smooth/ftgrays.h:
s/_STANDALONE_/STANDALONE_/.
2016-01-12 22:27:29 +01:00
Werner Lemberg 37412ff9f4 Don't use macro names that contain `__' [1/2].
Such macro names are reserved for both C and C++.

*/*: Replace macros of the form `__XXX_H__' with `XXX_H_'.
2016-01-12 21:37:13 +01:00
Alexei Podtelezhnikov 6eb6158dd7 [smooth] Faster alternative line renderer.
This implementation renders the entire line segment at once without
subdividing it into scanlines.  The main speed improvement comes from
reducing the number of divisions to just two per line segment, which
is a bare minimum to calculate cell coverage in a smooth rasterizer.
Notably, the progression from cell to cell does not itself require any
divisions at all.  The speed improvement is more noticeable at larger
sizes.

* src/smooth/ftgrays.c (gray_render_line): New implementation.
2015-10-06 22:39:54 -04:00
Alexei Podtelezhnikov e2dae8fead [smooth] Clean up worker.
* src/smooth/ftgrays.c (gray_TWorker): Remove never used fields.
2015-10-01 22:03:34 -04:00
Alexei Podtelezhnikov 8bbcfb2c2f [smooth] Clean up worker.
* src/smooth/ftgrays.c (gray_TWorker): Remove lightly used `last_ey'.
(gray_start_cell, gray_render_line): Update.
2015-09-30 23:08:53 -04:00
Alexei Podtelezhnikov d8a44ff932 Remove unused macro. 2015-09-26 22:33:55 -04:00
Alexei Podtelezhnikov b002f6882d * src/smooth/ftgrays.c (gray_render_line): Simplify clipping. 2015-09-07 13:47:36 -04:00
Alexei Podtelezhnikov 5a6dc87240 [raster,smooth] Microoptimizations.
* src/raster/ftraster.c (Insert_Y_Turn, Finalize_Profile_Table,
Beziier_Up, ): Use do-while loops.

* src/smooth/ftgrays.c (gray_render_scanline, gray_render_line,
gray_convert_glyph): Ditto.
2015-09-04 23:14:46 -04:00
Werner Lemberg f9be567f5f Better support of user-supplied C++ namespaces.
See

  http://lists.nongnu.org/archive/html/freetype-devel/2015-07/msg00008.html

for a rationale.

* src/autofit/afpic.h, src/base/basepic.h, src/cff/cffpic.h,
src/pshinter/pshpic.h, src/psnames/pspic.h, src/raster/rastpic.h,
src/sfnt/sfntpic.h, src/smooth/ftspic.h, src/truetype/ttpic.h
(FT_BEGIN_HEADER, FT_END_HEADER): Move macro calls to not enclose
header files that contain FT_{BEGIN,END}_HEADER macros by
themselves.

* src/autofit/aftypes.h [FT_DEBUG_AUTOFIT]: Include
FT_CONFIG_STANDARD_LIBRARY_H earlier.

* src/truetype/ttpic.h: Include FT_INTERNL_PIC_H.
2015-07-09 15:10:31 +02:00
Werner Lemberg 392cf22f8a Another adjustment to header locations.
This change is a result of a discussion thread on freetype-devel

  http://lists.nongnu.org/archive/html/freetype-devel/2015-06/msg00041.html

Re-introduce the `freetype2' subdirectory for all FreeType header
files after installation, and rename the `freetype2' subdirectory in
the git repository to `freetype'.

* include/freetype2: Renamed to...
* include/freetype: This.

* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS): Updated.
Update creation of `ftconfig.h'.
Install generated `ftconfig.h'.

* Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.

* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/freetype2.in: Updated.

* builds/unix/freetype-config.in: Updated.
* builds/unix/configure.raw: Don't check for `rmdir'.
* builds/unix/unix-def.in (DELDIR): Use `rm -rf', which is portable
according to the autoconf info manual.
* builds/unix/install.mk (install, uninstall,
distclean_project_unix): Update and simplify.

* builds/wince/*, builds/windows/*: Updated.

* devel/ft2build.h, include/ft2build.h: Updated.

* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.

* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.

* docs/*: Updated.
2015-06-26 06:48:00 +02:00
Werner Lemberg 8502c98b15 Fix Savannah bug #45097.
We no longer `pollute' the namespace of possible header file names;
instead we move `ft2build.h' up by one level so that it gets
installed in the default include directory (e.g.,
/usr/local/include).  After this commit, only `ft2build.h' stays in
the compiler's include path.

No visible changes for the user who follows the standard FreeType
header inclusion rules.

* include/*: Move to ...
* include/freetype2/*: This directory, except `ft2build.h'.

* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS), Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.

* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/install.mk (install, uninstall),
builds/unix/freetype2.in: Updated.

* builds/unix/freetype-config.in: Updated.
Emit -I directory only if it is not `/usr/include'.

* builds/wince/*, builds/windows/*: Updated.

* devel/ft2build.h, include/ft2build.h: Updated.

* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.

* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.

* docs/*: Updated.
2015-06-22 06:35:23 +02:00
Werner Lemberg 31d97df99f Make Jam support work again.
This is just very basic stuff and just a little bit tested on
GNU/Linux only.  I won't delve into this since I'm not a Jam user.

* Jamfile: Call `HDRMACRO' for `ftserv.h' also.
(DEFINES): Replace with...
(CCFLAGS): ... this.

* src/Jamfile: Don't call `HDRMACRO' for `internal.h'; this is
already handled in the top-level Jamfile.

* src/autofit/Jamfile (DEFINES): Replace with...
(CCFLAGS): ... this.
(_sources): Add missing files.

* src/cache/Jamfile: Don't call `HDRMACRO' for `ftcache.h'; it no
longer contains macro header definitions.

* src/base/Jamfile, src/cff/Jamfile, src/sfnt/Jamfile,
src/truetype/Jamfile (_sources): Add missing files.
2015-06-21 19:12:12 +02:00
Werner Lemberg 4d1f7af17b [smooth, raster] Re-enable standalone compilation.
* src/raster/ftraster.c (FT_RENDER_POOL_SIZE, FT_MAX)
[_STANDALONE_]: Define macros.

* src/smooth/ftgrays.c (FT_RENDER_POOL_SIZE, FT_MAX, FT_ABS,
FT_HYPOT) [_STANDALONE_]: Define macros.
2015-02-23 07:04:36 +01:00
Werner Lemberg cb13e7109c [smooth] Signedness fixes.
* src/smooth/ftgrays.c, src/smooth/ftsmooth.c: Apply.
2015-02-23 06:41:52 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Behdad Esfahbod b2ba68665f [smooth] Fix uninitialized memory access.
Looks like `ras.span_y' could always be used without initialization.
This was never detected by valgrind before because the library-wide
`raster_pool' was used for the worker object and `raster_pool' was
originally zero'ed.  But subsequent reuses of it were using `span_y'
uninitialized.  With the recent change to not use `render_pool' and
allocate worker and buffer on the stack, valgrind now detects this
uninitialized access.

* src/smooth/ftgrays.c (gray_raster_render): Initialize
`ras.span_y'.
2015-01-14 18:43:13 +01:00
Behdad Esfahbod 747ae2c8aa [smooth] Allocate render pool for smooth rasterizer on the stack.
Instead of using the `render_pool' member of `FT_Library' that is
provided down to the rasterizer, completely ignore that and allocate
needed objects on the stack instead.

With this patch, rasterizing glyphs from different faces from
different threads doesn't crash in the smooth rasterizer.

Bugs:

  https://bugzilla.redhat.com/show_bug.cgi?id=678397
  https://bugzilla.redhat.com/show_bug.cgi?id=1004315
  https://bugzilla.redhat.com/show_bug.cgi?id=1165471
  https://bugs.freedesktop.org/show_bug.cgi?id=69034

* src/smooth/ftgrays.c (gray_TRaster): Remove `buffer',
`buffer_size', `band_size', and `worker' members.

(gray_raster_render): Create `buffer', `buffer_size', and
`band_size' locally.
(gray_raster_reset): Updated.
2015-01-14 17:54:26 +01:00
Werner Lemberg 36d03c9f58 Fix Savannah bug #43976.
Assure that FreeType's internal include directories are found before
`CPPFLAGS' (which might be set by the user in the environment), and
`CPPFLAGS' before `CFLAGS'.

* builds/freetype.mk (FT_CFLAGS): Don't add `INCLUDE_FLAGS'.
(FT_COMPILE): Make this a special variable for compiling only the
files handled in `freetype.mk'.
(.c.$O): Removed, unused.

* src/*/rules.mk (*_COMPILE): Fix order of include directories.
2015-01-12 11:26:30 +01:00
Werner Lemberg 553c9672b3 Work around a bug in Borland's C++ compiler.
See

  http://qc.embarcadero.com/wc/qcmain.aspx?d=118998

for Borland's bug tracker entry.

Reported by Yuliana Zigangirova <zigangirova@inbox.ru>,
http://lists.gnu.org/archive/html/freetype-devel/2014-04/msg00001.html.

* include/internal/ftvalid.h (FT_ValidatorRec), src/smooth/ftgrays.c
(gray_TWorker_): Move `ft_jmp_buf' field to be the first element.
2014-12-07 19:29:52 +01:00
suzuki toshiya 2676e07aa4 * src/smooth/ftsmooth.c (ft_smooth_render_generic): Remove
unrequired negative value check for `width' and `height'.
2014-11-28 00:58:25 +09:00
suzuki toshiya 1b057040d8 Prevent too negative values (< FT_INT_MIN) in bitmap metrics,
suggested by Alexei.

* src/pfr/pfrsbit.c (pfr_slot_load_bitmap): Prevent too
negative values in `xpos' and `ypos + ysize'.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Prevent
too negative values in `x_left' and `y_top'.  Either negative
values in `width' and `height' are checked.
2014-11-27 17:53:20 +09:00
Werner Lemberg 04c2aa18bf */*: s/Invalid_Argument/Invalid_Outline/ where appropriate. 2014-11-25 10:22:12 +01:00
Werner Lemberg 3e86711ebf [Savannah bug #43682] Adjust some renderer callbacks.
* src/raster/ftraster.c (ft_black_set_mode): Change return type to
`int' to stay in sync with `FT_Renderer_SetModeFunc' prototype.

* src/smooth/ftgrays.c (gray_raster_set_mode): New dummy function
for orthogonality.
(ft_grays_raster): Use it.
2014-11-25 09:01:07 +01:00
Alexei Podtelezhnikov 525d4876be [smooth] Improve code readability.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Rearrange code.
2014-10-31 22:12:37 -04:00
Alexei Podtelezhnikov e1efe0a2fc [smooth] Reduce outline translations during rendering.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Translate origin
virtually by modifying cbox, actually translate outline if cumulative
shift is not zero.
2014-10-31 00:07:14 -04:00
Alexei Podtelezhnikov c7fd93565c [smooth] Fix Savannah bug #35604 (cont'd).
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Remove checks and
casts that became unnecessary after the variable type upgrades.
2014-10-30 22:43:01 -04:00
Alexei Podtelezhnikov 465ab99585 [smooth] Improve code readability.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Rearrange code.
2014-10-29 23:45:23 -04:00
Alexei Podtelezhnikov 74916997de Unify hypotenuse approximations.
* include/internal/ftcalc.h (FT_HYPOT): Move macro from here...
* include/internal/ftobjs.h: ... to here, next to required `FT_ABS'.
* src/smooth/ftgrays.c (gray_render_cubic): Use it here.
2014-10-29 22:24:24 -04:00
David Weber 7630787a6a [smooth] Fix stand-alone compilation.
* src/smooth/ftgrays.c (FT_BEGIN_STMNT, FT_END_STMNT): Define.
2014-04-13 15:41:13 +02: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 fae3820764 Simplify header file hierarchy.
This large patch changes the header file directory layout from
`include/freetype/...' to `include/...', effectively removing one
level.  Since the file `ft2build.h' is also located in `include'
(and it stays there even after installation), all FreeType header
files are now in a single directory.

Applications that use (a) `freetype-config' or FreeType's
`pkg-config' file to get the include directory for the compiler, and
(b) the documented way for header inclusion like

  #include <ft2build.h>
  #include FT_FREETYPE_H
  ...

don't need any change to the source code.

* include/freetype/*: Move up to...
* include/*: ... this directory.

* builds/amiga/include/freetype/*: Move up to...
* builds/amiga/include/*: ... this directory.

*/*: Essentially do `s@/freetype/@/@' where appropriate.

* CMakeList.txt: Simplify.
* builds/unix/freetype-config.in, builds/unix/freetype2.in: For
`--cflags', return a single directory.
* builds/unix/install.mk (install): No longer try to remove `cache'
and `internal' subdirectories; instead, remove the `freetype'
subdirectory.
2013-11-13 08:55:46 +01:00
Werner Lemberg 9a7951d99b [smooth] Fix segfault caused by previous commit.
* src/smooth/ftgrays.c (gray_set_cell): Always compute
`ras.invalid'.
2013-07-16 15:25:24 +02:00
David Turner 89929ec6b9 [smooth] Improve performance.
Provide a work-around for an ARM-specific performance bug in GCC.
This speeds up the rasterizer by more than 5%.

Also slightly optimize `set_gray_cell' and `gray_record_cell' (which
also improves performance on other platforms by a tiny bit (<1%).

* src/smooth/ftgrays.c (FT_DIV_MOD): New macro.
Use it where appropriate.

(gray_record_cell, gray_set_cell, gray_move_to,
gray_convert_glyph_inner): Streamline condition handling.
2013-07-16 13:36:07 +02:00
Werner Lemberg d7e3444b8a * src/smooth/ftgrays.c One final pragma to silence 64-bit MSVC. 2013-06-14 18:33:39 +02:00
Werner Lemberg 45392b77a8 Fix compiler warnings.
* include/freetype/internal/ftmemory.h: Decorate memory allocation
macros with `FT_Long' where appropriate.
Remove duplicate of FT_MEM_QRENEW_ARRAY definition.

* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
cast.

* src/base/ftobjs.c: Add warning disabling pragma for MSVC while
including `md5.c'.

* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdESC>: Add
cast.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_compound): Fix casts.
(tt_sbit_decoder_load_bitmap): Beautification.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Initialize
variables (earlier).

* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Pacify compiler.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use unsigned constants
where appropriate.

* src/type1/t1load.c (T1_Get_MM_Var): Ditto.
2013-06-05 13:43:20 +02:00
Werner Lemberg dc624ca4dc Apply fixes for cppcheck nitpicks.
http://cppcheck.sourceforge.net/

Note that the current version heavily chokes on FreeType, delivering
even wrong results.  I will report those issues to the cppcheck team
so that a newer version gives improved results hopefully.

*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.

* src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
Remove unused variable.

* src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.

* src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate):
Remove functionless code.

* src/tools/ftrandom.c (main): Fix memory leak.
2013-06-04 10:30:48 +02:00
Werner Lemberg 5ea06ce017 Whitespace. 2013-03-17 08:14:46 +01:00
Werner Lemberg 706fc83370 Remove dead code.
* src/raster/rastpic.c (ft_raster1_renderer_class_pic_init)
src/smooth/ftspic.c (ft_smooth_renderer_class_pic_init): Do it.
2013-03-17 08:09:17 +01:00
Werner Lemberg e3c9301581 */*: Use FT_Err_Ok only.
This is a purely mechanical conversion.
2013-03-14 11:21:17 +01: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 4cd5fd463e Remove trailing whitespace. 2013-01-24 13:33:06 +01:00
Werner Lemberg fdcbaf19fe [smooth] Improve tracing.
* src/smooth/ftgrays.c (gray_sweep): Trace last sweep line of
current band also.
2012-10-21 10:40:12 +02:00
Werner Lemberg 328aa3b203 [FT_CONFIG_OPTION_PIC] Fix g++ 4.6.2 compiler warnings.
* include/freetype/internal/ftdriver.h (FT_DEFINE_DRIVER),
include/freetype/internal/ftobjs.h (FT_DEFINE_RENDERER,
FT_DEFINE_MODULE), include/freetype/internal/ftserv.h
(FT_DEFINE_SERVICEDESCREC1, FT_DEFINE_SERVICEDESCREC2,
FT_DEFINE_SERVICEDESCREC3, FT_DEFINE_SERVICEDESCREC4,
FT_DEFINE_SERVICEDESCREC5, FT_DEFINE_SERVICEDESCREC6),
src/autofit/afpic.c (autofit_module_class_pic_init),
src/base/basepic.c (ft_base_pic_init), src/base/ftinit.c
(ft_create_default_module_classes), src/cff/cffparse.c
(FT_Create_Class_cff_field_handlers), src/cff/cffpic.c
(cff_driver_class_pic_init), src/pshinter/pshpic.c
(pshinter_module_class_pic_init), src/psnames/pspic.c
(psnames_module_class_pic_init), src/raster/rastpic.c
(ft_raster1_renderer_class_pic_init), src/sfnt/sfntpic.c
(sfnt_module_class_pic_init), src/sfnt/ttcmap.c
(FT_Create_Class_tt_cmap_classes), src/smooth/ftspic.c
(ft_smooth_renderer_class_pic_init), src/truetype/ttpic.c
(tt_driver_class_pic_init): Initialize allocation variable.
2012-08-27 11:23:41 +02:00
Alexei Podtelezhnikov 9ea55c7c33 Fix Savannah bug #37017.
* src/smooth/ftgrays.c (gray_render_cubic): Use a different set of
checks when detecting super curvy splines to be split.
2012-08-12 11:14:46 -04:00
Werner Lemberg e7454a47e2 [smooth] Avoid memory like in case of failure.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Use flags to
indicate what to clean up after finishing the function, with and
without errors.
2012-07-11 12:05:58 +02:00
Werner Lemberg f1ec084292 s/maximal/maximum/ everywhere, s/minimal/minimum/ where appropriate. 2012-03-11 13:48:25 +01:00
Vinnie Falco 26dfeb6d63 Prepare source code for amalgamation.
* src\autofit\aferrors.h, src\bdf\bdferror.h, src\bzip2\ftbzip2.c,
src\cache\ftcerror.h, src\cff\cfferrs.h, src\cid\ciderrs.h,
src\gxvalid\gxverror.h, src\gzip\ftgzip.c, src\lzw\ftlzw.c,
src\otvalid\otverror.h, src\pcf\pcferror.h, src\pfr\pfrerror.h,
src\psaux\psauxerr.h, src\pshinter\pshnterr.h,
src\psnames\psnamerr.h, src\raster\rasterrs.h, src\sfnt\sferrors.h,
src\smooth\ftsmerrs.h, src\truetype\tterrors.h,
src\type1\t1errors.h, src\type42\t42error.h, src\winfonts\fnterrs.h:
Add #undef FT_ERR_PREFIX before #define FT_ERR_PREFIX.
2012-03-08 06:04:03 +01:00
Werner Lemberg fcbc82e69e [smooth] Fix Savannah bug #35604.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Use `FT_Pos'
instead of `FT_UInt' for some variables and update comparisons
accordingly.  A detailed analysis can be found in the bug report.
2012-02-26 20:54:19 +01:00
Vinnie Falco 9511143385 Prepare source code for amalgamation (4/6).
* src/smooth/ftgrays.c, src/raster/ftraster.c: Undefine RAS_ARG,
RAS_ARGS, RAS_VAR, and RAS_VARS before defining it.

* src/smooth/ftgrays.c: s/TRaster/black_TRaster/,
s/PRaster/black_PRaster/.
* src/raster/ftraster.c: s/TRaster/gray_TRaster/,
s/PRaster/gray_PRaster/.
2012-02-22 07:01:35 +01:00
Vinnie Falco d55f16df11 Prepare source code for amalgamation (3/6).
* src/smooth/ftgrays.c: s/TWorker/black_TWorker/,
s/PWorker/black_PWorker/.
* src/raster/ftraster.c: s/TWorker/gray_TWorker/,
s/PWorker/gray_PWorker/
2012-02-21 09:21:19 +01:00
Vinnie Falco 5ccebc4e1e Prepare source code for amalgamation (2/6).
* src/smooth/ftgrays.c, src/raster/ftraster.c: Undefine FLOOR,
CEILING, TRUNC, and SCALED before defining it.
2012-02-21 08:54:55 +01:00
Vinnie Falco 126405adde Prepare source code for amalgamation (1/6).
See discussion starting at

  http://lists.gnu.org/archive/html/freetype-devel/2012-01/msg00037.html

* src/smooth/ftgrays.c: s/TBand/gray_TBand/.
* src/raster/ftraster.c: s/TBand/black_TBand/.
2012-02-21 08:48:39 +01:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
suzuki toshiya c24f77ac76 Formatting PIC related sources.
* src/autofit/afpic.c: Harmonize to FT2 coding conventions.
* src/base/basepic.c: Ditto.
* src/base/ftpic.c: Ditto.
* src/cff/cffpic.c: Ditto.
* src/pshinter/pshpic.c: Ditto.
* src/psnames/pspic.c: Ditto.
* src/raster/rastpic.c: Ditto.
* src/sfnt/sfntpic.c: Ditto.
* src/smooth/ftspic.c: Ditto.
* src/truetype/ttpic.c: Ditto.
2012-01-16 21:13:05 +09:00
suzuki toshiya 3c96681856 Fix redundant declaration warning in PIC mode.
Originally FT_DEFINE_{DRIVER,MODULE,RENDERER}() macros were
designed to declare xxx_pic_{free,init} by themselves.
Because these macros are used at the end of the module
interface (e.g. ttdriver.c) and the wrapper source to build
a module as a single object (e.g. truetype.c) includes
the PIC file (e.g. ttpic.c) before the module interface,
these macros are expanded AFTER xxx_pic_{free,init} body
when the modules are built as single object.
The declaration after the implementation causes the redundant
declaration warnings, so the declarations are moved to module
PIC headers (e.g. ttpic.h).  Separating to other header files
are needed for multi build.

* include/freetype/internal/ftdriver.h (FT_DEFINE_DRIVER):
Remove class_##_pic_free and class_##_pic_init declarations.
* include/freetype/internal/ftobjs.h (FT_DEFINE_RENDERER,
FT_DEFINE_MODULE): Ditto.

* src/base/basepic.h: Insert a comment and fix coding style.
* src/autofit/afpic.h: Declare autofit_module_class_pic_{free,
init}.
* src/cff/cffpic.h: Declare cff_driver_class_pic_{free,init}.
* src/pshinter/pshpic.h: Declare pshinter_module_class_pic_{free,
init}.
* src/psnames/pspic.h: Declare psnames_module_class_pic_{free,
init}.
* src/raster/rastpic.h: Declare
ft_raster{1,5}_renderer_class_pic_{free,init}
* src/sfnt/sfntpic.h: Declare sfnt_module_class_pic_{free,init}.
* src/smooth/ftspic.h: Declare
ft_smooth_{,lcd_,lcdv_}renderer_class_pic_{free,init}.
* src/truetype/ttpic.h: Declare tt_driver_class_pic_{free,init}.
2012-01-15 23:35:31 +09:00
suzuki toshiya 4b733517d7 Make PIC files to include module error headers, to use the
error codes with per-module prefix.

* src/autofit/afpic.c: Include `aferrors.h'.
* src/cff/cffpic.c: Include `cfferrs.h'.
* src/pshinter/pshpic.c: Include `pshnterr.h'.
* src/raster/rastpic.c: Include `rasterrs.h'.
* src/sfnt/sfntpic.c: Include `sferrors.h'.
* src/smooth/ftspic.c: Include `ftsmerrs.h'.
* src/truetype/ttpic.c: Include `tterrors.h'.
2012-01-14 06:32:50 +09:00
Werner Lemberg 5cb356405e Add some variable initializations.
Reported by Richard COOK <rscook@unicode.org>.

* src/type1/t1driver.c (t1_ps_get_font_value): Initialize `val'.
* src/smooth/ftgrays.c (gray_render_conic): Initialize `levels'
earlier.
2011-12-10 23:16:04 +01:00
Werner Lemberg c52f44d4fd Whitespace. 2011-11-30 10:46:53 +01:00
Werner Lemberg e9e93d1b19 [smooth] Slightly optimize conic and cubic flatterners.
* src/smooth/ftgrays.c (gray_render_conic, gray_render_cubic): Move
out some code from the main loop to speed it up.
2011-09-17 09:21:25 +02:00
Werner Lemberg 71cc1a83d8 Fix gcc 4.6 compiler warnings.
* src/autofit/afcjk.c (af_cjk_metrics_init_blues): Use casts and
remove unused variables.
* src/autofit/aflatin.c (af_latin_hints_compute_edges): Comment out
`up_dir'.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Use `height_org'
and `width_org' conditionalized.
2011-05-30 07:20:37 +02:00
Alexei Podtelezhnikov 8fb8841430 A better fix for Savannah bug #32671.
* src/smooth/ftgrays.c (gray_render_conic): Clean up code and
replace WHILE loop with a more natural DO-WHILE construct.
2011-03-17 20:24:57 +01:00
Werner Lemberg 6c045535ea Quick fix for Savannah bug #32671.
This isn't the optimal solution yet, but it restores the previous
rendering quality (more or less).

* src/smooth/ftgrays.c (gray_render_conic): Do more splitting.
2011-03-07 05:40:42 +01:00
Werner Lemberg f3ce237027 */rules.mk: Handle `*pic.c' files. 2011-01-03 07:11:54 +01:00
Алексей Подтележников 7c4ac3cb0c [ftsmooth]: Minor code simplification.
* src/smooth/ftgrays (gray_render_cubic): Do only one comparison
instead of two.
2010-11-28 08:23:40 +01:00
Alexei Podtelezhnikov 6aee69096f [ftsmooth] Improve rendering.
* src/smooth/ftsmooth.c (gray_render_conic): Since version 2.4.3,
cubic deviations have been estimated _after_ UPSCALE, whereas
conic ones have been evaluated _before_ UPSCALE, which produces
inferior rendering results.  Fix this.
Partially undo change from 2010-10-15 by using ONE_PIXEL/4; this has
been tested with demo images sent to the mailing list.  See

  http://lists.gnu.org/archive/html/freetype-devel/2010-10/msg00055.html

and later mails in this thread.
2010-11-02 16:01:03 +01:00
Werner Lemberg 34d61e8637 Fix thinko in spline flattening.
FT_MAX_CURVE_DEVIATION is dependent on the value of ONE_PIXEL.

* src/smooth/ftgrays.c (FT_MAX_CURVE_DEVIATION): Remove it and
replace it everywhere with ONE_PIXEL/8.
2010-10-15 20:44:15 +02:00
Werner Lemberg 0e6fc09134 [smooth] Fix splitting of cubics for negative values.
Reported by Róbert Márki <gsmiko@gmail.com>; see
http://lists.gnu.org/archive/html/freetype/2010-09/msg00019.html.

* src/smooth/ftgrays.c (gray_render_cubic): Fix thinko.
2010-10-02 09:05:46 +02:00
Graham Asher e0a9a93330 [smooth] Fix and improve spline flattening.
This fixes the flattening of cubic, S-shaped curves and speeds up
the handling of both the conic and cubic arcs.

See the discussions on the freetype-devel mailing list in late
August and September 2010 for details.

* src/smooth/ftgrays.c (FT_MAX_CURVE_DEVIATION): New macro.
(TWorker): Remove `conic_level' and `cubic_level' elements.
(gray_render_conic): Simplify algorithm.
(gray_render_cubic): New algorithm; details are given in the code
comments.
(gray_convert_glyph): Remove heuristics.
2010-09-20 09:29:23 +02:00
Werner Lemberg a205b3ca85 Try to fix Savannah bug #30717 (and probably #30719 too).
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Add another
overflow test for `width' and `height'.
2010-08-10 02:59:12 +02:00
Werner Lemberg c8f5b98be2 Remove C++ warnings.
*/*: Initialize pointers where necessary to make g++ happy.
2010-07-12 21:13:22 +02:00
Werner Lemberg e017639710 Make ftgrays.c compile stand-alone again.
* src/smooth/ftgrays.c [_STANDALONE_]: Include `stddef.h'.
(FT_INT_MAX, FT_PtrDist)[_STANDALONE_]: Define.
2010-07-03 15:31:38 +02:00
Werner Lemberg 6305b869d8 Fix Savannah bug #30263.
* src/smooth/ftgrays.c (gray_render_span): Use cast to `unsigned
int' to avoid integer overflow.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Use smaller
threshold values for `width' and `height'.  This is not directly
related to the bug fix but makes sense anyway.
2010-06-30 18:24:33 +02:00