Commit Graph

46 Commits

Author SHA1 Message Date
Anuj Verma d9eeac807e [sdf] Remove use of `FT_List'.
Simply use a `next' pointer inside `SDF_Edge' and
`SDF_Contour' to create a linked list. This reduces
the number of allocations due to `FT_ListNode', also
we don't need a doubly linked list.

* src/sdf/ftsdf.c (SDF_Edge, SDF_Contour): Remove the
  `FT_List' and use a `next' pointer to create the
  linked list.

* src/sdf/ftsdf.c(sdf_edge_destructor, sdf_contour_destructor):
  Removed, not needed any more.

* src/sdf/ftsdf.c (*): Remove the use of `FT_List_'
  functions wherever necessary and sync with the new
  list.
2020-08-02 16:33:19 +05:30
Anuj Verma 8bf9da21e0 [sdf] Added subdivision optimization.
* src/sdf/ftsdfrend.c (sdf_generate_subdivision): The
  function generate SDF just like the `sdf_generate'
  function, but subdivide the curve into a number of
  lines and then use the `sdf_generate_bounding_box'
  function to generate SDF.
2020-08-02 16:33:19 +05:30
Anuj Verma fa7251ba35 [sdf] Added functions to subdivide a cubic curve.
* src/sdf/ftsdf.c (split_cubic, split_sdf_cubic):
  These functions can be used to subdivide a
  cubic bezier curve into line segments which can
  then be used to generate the SDF.

* src/sdf/ftsdf.c (split_sdf_shape): Added function
  to split a cubic into a line segments.

* src/sdf/ftsdf.c (sdf_shape_done): No need to pass
  `FT_Memory' as a parameter, it can be accessed
  from the `shape' struct.
2020-08-02 16:33:19 +05:30
Anuj Verma 1ba3da86e1 * src/sdf/ftsdf.c (split_sdf_shape): Typo. 2020-08-02 16:33:18 +05:30
Anuj Verma 90abe41ead * src/sdf/ftsdf.c (split_sdf_shape): Memory leak.
* src/sdf/ftsdf.c (split_sdf_shape): Memory leak.
  After recursion the edges variable becomes `NULL'
  so reassign it to deallocate the list completely.
2020-08-02 16:33:18 +05:30
Anuj Verma 470d02aa60 [sdf] Added functions to subdivide a conic curve.
* src/sdf/ftsdf.c (split_conic, split_sdf_conic):
  These functions can be used to subdivide a
  conic bezier curve into line segments which can
  then be used to generate the SDF.

* src/sdf/ftsdf.c (split_sdf_shape): Added function
  to split a outline into a line segments.
2020-08-02 16:33:18 +05:30
Anuj Verma de86a14b32 *[GSoC]ChangeLog: Fix typos. 2020-08-02 16:33:18 +05:30
Anuj Verma c4f64fc0e1 * src/sdf/ftsdfrend.c (sdf_generate_bounding_box): Add buffer for signs. 2020-08-02 16:33:18 +05:30
Anuj Verma e6576cc0e7 [sdf] Precompute the orthogonality. 2020-08-02 16:33:18 +05:30
Anuj Verma 1e3c41d19e [sdf] Added bounding box optimization. 2020-08-02 16:33:18 +05:30
preversewharf45 1d5d8ff288 * src/sdf/ftsdfrend.c (sdf_shape_dump): Use `%ld' to printf `signed long'. 2020-08-02 16:33:18 +05:30
Anuj Verma 44e16a0be6 * src/sdf/ftsdfrend.c (ft_sdf_render): Don't negate unsigned integers. 2020-08-02 16:33:18 +05:30
Anuj Verma 4fcc1653ca * src/sdf/ftsdf.c: Use ASCII single quote ('). 2020-08-02 16:33:18 +05:30
Anuj Verma ddf631729e [sdf] Added function to find shortest distance from a point to a cubic. 2020-08-02 16:33:18 +05:30
Anuj Verma 5baa2cefc6 * src/sdf/ftsdf.c (sdf_contour_get_min_distance): Use epsilon. 2020-08-02 16:33:18 +05:30
Anuj Verma 76e67227ec * src/sdf/ftsdf.c (sdf_shape_dump): Add more info to the debug output. 2020-08-02 16:33:18 +05:30
Anuj Verma 3e52d1a7a8 * src/sdf/ftsdf.c (MAX_NEWTON_DIVISIONS): Renamed to avoid confusion. 2020-08-02 16:33:18 +05:30
Anuj Verma 363f1e8de1 [sdf] Added Newton's method for conic curve. 2020-08-02 16:33:17 +05:30
Anuj Verma be3b7d7945 * src/sdf/ftsdf.c: More comments and code style fix. 2020-08-02 16:33:17 +05:30
Anuj Verma d0e3074738 [sdf] Make squared distances toggleable. 2020-08-02 16:33:17 +05:30
Anuj Verma 97474a7072 * src/sdf/ftsdf.c (get_min_distance_conic): Use 0, 1 in case of 0 roots. 2020-08-02 16:33:17 +05:30
Anuj Verma f9b4f37433 [sdf] Added function to find shortest distance from a point to a conic. 2020-08-02 16:33:17 +05:30
Anuj Verma 5cbcab183a * src/sdf/ftsdf.c (get_min_distance_line): Minor bug 2020-08-02 16:33:17 +05:30
Anuj Verma c8e3c5a420 * src/sdf/ftsdf.c: Refactored the code. 2020-08-02 16:33:17 +05:30
Anuj Verma f1de833a9d [sdf] Added functions to solve polynomial equations. 2020-08-02 16:33:17 +05:30
Anuj Verma 92a5312036 * src/sdf/ftsdf.c: Use FT_16D16 instead of FT_Fixed to avoid confusion. 2020-08-02 16:33:17 +05:30
Anuj Verma 811b6a7177 * src/sdf/ftsdf.c (cube_root, arc_cos): Added a few math functions. 2020-08-02 16:33:17 +05:30
Anuj Verma 38df99a1b4 [sdf] Fixed compilation under gnumake. 2020-08-02 16:33:17 +05:30
Anuj Verma 96883decbb [sdf] Added function to resolve corners. 2020-08-02 16:33:17 +05:30
Anuj Verma 03e6debb80 [sdf] The module can now generate SDF for outline with only lines. 2020-08-02 16:33:17 +05:30
Anuj Verma 063b65d583 [sdf] Added function to find shortest distance from a point to a line. 2020-08-02 16:33:17 +05:30
Anuj Verma 186cc478ae * src/sdf/ftsdf.c: Manually iterate through the lists. 2020-08-02 16:33:17 +05:30
Anuj Verma e9fce03032 [sdf] Added basic outline of the functions required to generate sdf. 2020-08-02 16:33:17 +05:30
Anuj Verma 6d4e00ae37 [sdf] Added `SDF_Raster_Params'. 2020-08-02 16:33:17 +05:30
Anuj Verma 3ebcbd7066 * include/freetype/ftimage.h (FT_RASTER_FLAG_): Added a new raster flag. 2020-08-02 16:33:16 +05:30
Anuj Verma f02d1acb89 * src/sdf/ftsdf.c (sdf_shape_dump): Use `FT_TRACEX' instead of `printf'. 2020-08-02 16:33:16 +05:30
Anuj Verma 63c2ac5fae * src/sdf/ftsdf.c (sdf_shape_dump): Added debugging function. 2020-08-02 16:33:16 +05:30
Anuj Verma 2f0d349d8c [sdf] Added functions to de-allocate `SDF_' structs. 2020-08-02 16:33:16 +05:30
Anuj Verma 54ff90398a [sdf] Decompose outline and store it in a `SDF_Shape'. 2020-08-02 16:33:16 +05:30
Anuj Verma 38bc88ae6f [sdf] Added essential enums and structs required. 2020-08-02 16:33:16 +05:30
Anuj Verma d21ceef7b4 [sdf] Added functionality to set and get module properties. 2020-08-02 16:33:16 +05:30
Anuj Verma 29c92db771 [sdf] Implemented a few functions required by a renderer module. 2020-08-02 16:33:16 +05:30
Anuj Verma c9d1149923 * include/freetype/ftimage.h (FT_Render_Mode_): Added new pixel mode. 2020-08-02 16:33:16 +05:30
Anuj Verma 08ba8d1422 added new `FT_RENDER_MODE_SDF' 2020-08-02 16:33:16 +05:30
Anuj Verma e408bda4f9 author check 2020-08-02 16:33:16 +05:30
preversewharf45 185d07b0cd added the structure of new `sdf' module 2020-08-02 16:33:16 +05:30