Commit Graph

17 Commits

Author SHA1 Message Date
Anuj Verma 6218c942ad [sdf] Fix compiler warnings.
* src/sdf/ftsdf.c (get_control_box): Use goto instead of letting the next case statement
  execute to avoid compiler warning [-Wimplicit-fallthrough=].

* src/sdf/ftsdf.c (sdf_generate_bounding_box): Fix compiler warning due to signed
  unsigned mismatch.

* src/sdf/ftsdfrend.c (ft_sdf_done): The function must have a return type of `void'
  to match the signature of `FT_Module_Destructor'.
2020-08-24 09:40:46 +05:30
Anuj Verma d2d939098d [sdf, bsdf] Fix compiler warnings.
* src/sdf/ftsdf.c, src/sdf/ftbsdf.c (*): Fix compiler warnings caused due to signed
  unsigned mismatch (-Wsign-compare).
2020-08-23 18:03:39 +05:30
Anuj Verma 7c2a64b709 [sdf] Added debugging function.
* src/sdf/ftsdf.c (sdf_shape_dump): Added a debugging function which can be used
  to debug issues with the outline, contours, edges etc.
2020-08-21 04:59:08 -07:00
Anuj Verma ed49facfe0 [sdf] Bug fix.
* src/sdf/ftsdf.c (*): Only track memory when `FT_DEBUG_MEMORY' is defined. Some
  variables used internally by the freetype memory debugger are only defined when
  we are tracking memory. If `FT_DEBUG_MEMORY' is not defined those variable
  are not defined and we get undefined reference error.
2020-08-21 04:55:15 -07:00
Anuj Verma 644a6c24fd [sdf] Added brief technical overview of both the rasterizers.
* src/sdf/ftsdf.c (*): Added a technical overview of the working of the `sdf' rasterizer.

* src/sdf/ftbsdf,c (*) : Added a technical overview of the working of the `bsdf'
  rasterizer.
2020-08-21 03:59:23 -07:00
Anuj Verma d5397730b4 [sdf] Added basic overlapping contour support.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Added another `sdf_generate_' 
  function which can generate SDF for glyphs with overlapping contour. Note that
  it cannot generate proper SDF for glyphs with self intersecting contours.
2020-08-20 07:54:13 +05:30
Anuj Verma 8359cb3501 [sdf] Added the interface functions for the `sdf' rasterizer.
* src/sdf/ftsdf.c (sdf_raster_): Added interface functions which are called from the
  FreeType core library to rasterize and do various other stuff with the rasterizer.
2020-08-19 16:29:51 +05:30
Anuj Verma 5cee930937 [sdf] Added the subdivision and bounding box optimization.
* src/sdf/ftsdf.c (sdf_generate_bounding_box): Added function to generate SDF by
  only checking grid point around the bounding box of any edge.

* src/sdf/ftsdf.c (sdf_generate_subdivision): Added function to generate SDF by 
  splitting the shape into a number of line segments and then only checking grid
  points around the neighborhood of the lines.
2020-08-19 16:25:08 +05:30
Anuj Verma 596bcfd340 [sdf] Added function to generate SDF.
* src/sdf/ftsdf.c (sdf_generate): Added function to generate SDF. This one doesn't use
  any optimization, it simply check all grid point against all contours.
2020-08-19 12:56:58 +05:30
Anuj Verma 75182d8ad1 [sdf] Added functions to get shortest distance from any edge/contour.
* src/sdf/ftsdf,c (sdf_edge_get_min_distance): Added function to get shortest distance
  from any arbitary edge.

* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Added function to get shortest
  distance from a contour. It basically returns the shortest distance from the nearest
  edge.
2020-08-19 12:22:34 +05:30
Anuj Verma c39b5dd849 [sdf] Added shortest distance finding functions.
* src/sdf/ftsdf.c (get_min_distance_): Added function to find the closest distance
  from a point to a curves of all three different types (i.e. line segment, conic
  bezier and cubic bezier).
2020-08-18 17:49:56 +05:30
Anuj Verma 68032a77e3 [sdf] Added function to resolve corner distances.
* src/sdf/ftsdf.c (resolve_corner): Added function to resolve corner distances
  because at corner two equal distance can have opposite sign.
2020-08-18 10:28:16 +05:30
Anuj Verma 0fcd73fb4a [sdf] Added essential math functions.
* src/sdf/ftsdf.c (cube_root, arc_cos): Added functions to compute cube root and
  cosine inverse of a 16.16 fixed point number.

* src/sdf/ftsdf.c (solve_quadratic_equation, solve_cubic_equation): Added
  functions to find roots of quadratic and cubic polynomial equations.
2020-08-18 10:17:46 +05:30
Anuj Verma 4dc90dc8d0 [sdf] Added utility functions for contours.
* src/sdf/ftsdf.c (get_control_box, get_contour_orientation): Added functions to
  get control box and orientation of any `SDF_Contour'.

* src/sdf/ftsdf.c (split_sdf_shape): Added function to split a complete shape (i.e.
  a collection of contours) into a number of small lines.
2020-08-18 10:14:20 +05:30
Anuj Verma e4e81c0168 [sdf] Added functions to decompose `FT_Outline'.
* src/sdf/ftsdf.c (sdf_outline_decompose): Added a function which decompose
  a `FT_Outline' using `FT_Outline_Decompose' and adds the outline data to a
  `SDF_Shape' for easier handling later on.
2020-08-17 16:36:30 +05:30
Anuj Verma 286fc7e42c [sdf] Added essential structs, enums and macros for `sdf' rasterizer.
* src/sdf/ftsdf.c (SDF_): Added the essential structures and enums which will
  be used internally by the `sdf' rasterizer. Also added allocator and deallocator
  functions for the structs.

* src/sdf/ftsdf.c (SDF_MemoryUser): Added a custom memory allocator which
  is used to track intermediate memory usage while generate SDF.

* src/sdf/ftsdf.c (definations): Added various definitions which can be used to
  modify the `sdf' rasterizer and also added a few helper macros.
2020-08-17 16:24:39 +05:30
Anuj Verma 29de1ff668 [sdf] Added all the necessary filed required by the module.
Added the necessary files required by the `sdf' module. These include files
for both the `sdf' and the `bsdf' renderers. Here is breakdown of what the
specific files will contain:

* src/sdf/ftsdfrend.*: Both the renderers.

* src/sdf/ftsdf.*: The rasterizer for the `sdf' renderer.

* src/sdf/ftbsdf.c: The rasterizer for the `bsdf' renderer.

* src/sdf/ftsdfcommon.h: Commmon properties and functions for both the
  rasterizers.

* src/sdf/ftsdferrs.h: Common error define.

* src/sdf/sdf.c: For building a single object of the entire module.
2020-08-16 17:09:22 +05:30