Commit Graph

224 Commits

Author SHA1 Message Date
Werner Lemberg 87ddad2007 Update or fix links to use the https protocol instead of http. 2017-12-04 20:43:30 +01:00
Alexei Podtelezhnikov ab6fe0768f * src/smooth/ftgrays.c (gray_set_cell): Fix uninitialized variables. 2017-11-06 21:34:56 -05:00
Alexei Podtelezhnikov 816516360c [smooth] Fix complex rendering at high ppem.
We used to split large glyphs into horizontal bands and continue
bisecting them still horizontally if that was not enough.  This is
guaranteed to fail when a single scanline cannot fit into the
rendering memory pool.  Now we bisect the bands vertically so that
the smallest unit is a column of the band height, which is guranteed
to fit into memory.

* src/smooth/ftgrays.c (gray_convert_glyph): Implement it.
2017-11-01 22:51:03 -04:00
Alexei Podtelezhnikov 91015cb41d [smooth] Improve complex rendering at high ppem.
At large sizes almost but not exactly horizontal segments can quickly
drain the rendering pool. This patch at least avoids filling the pool
with trivial cells. Beyond this, we can only increase the pool size.

Reported, analyzed, and tested by Colin Fahey.

* src/smooth/ftgrays.c (gray_set_cell): Do not record trivial cells.
2017-10-21 22:57:43 -04:00
Alexei Podtelezhnikov 6bea49e026 [base] Netpbm image tracing.
* src/base/ftobjs.c (FT_Load_Glyph): Trace bitmap size.
(FT_Render_Glyph_Internal): Trace bitmap in Netpbm format.

* src/smooth/ftgrays.c (gray_sweep): Sweep remnants of span tracing.
2017-10-14 22:45:11 -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 761d9e418b * src/smooth/ftgrays.c (gray_hline): Improve code. 2017-02-22 22:41:36 -05: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 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