diff options
Diffstat (limited to 'src/sdf/ftbsdf.c')
-rw-r--r-- | src/sdf/ftbsdf.c | 82 |
1 files changed, 76 insertions, 6 deletions
diff --git a/src/sdf/ftbsdf.c b/src/sdf/ftbsdf.c index 805feea3d..48d1f3d3c 100644 --- a/src/sdf/ftbsdf.c +++ b/src/sdf/ftbsdf.c @@ -22,22 +22,87 @@ * */ + /************************************************************************** + * + * @Struct: + * BSDF_TRaster + * + * @Description: + * This struct is used in place of `FT_Raster' and is stored within + * the internal freetype renderer struct. While rasterizing this is + * passed to the `FT_Raster_Render_Func' function, which then can be + * used however we want. + * + * @Fields: + * memory :: + * Used internally to allocate intermediate memory while raterizing. + * + */ typedef struct BSDF_TRaster_ { - FT_Memory memory; /* used internally to allocate memory */ + FT_Memory memory; } BSDF_TRaster; - /* Euclidean distance used for euclidean distance transform */ - /* can also be interpreted as edge distance. */ + /************************************************************************** + * + * @Struct: + * ED + * + * @Description: + * Euclidean distance used for euclidean distance transform can also be + * interpreted as edge distance. + * + * @Fields: + * dist :: + * Vector length of the `near' parameter. Can be squared or absolute + * depending on the `USE_SQUARED_DISTANCES' parameter defined in + * `ftsdfcommon.h'. + * + * near :: + * Vector to the nearest edge. Can also be interpreted as shortest + * distance of a point. + * + * alpha :: + * Alpha value of the original bitmap from which we generate SDF. + * While computing the gradient and determining the proper sign + * of a pixel this field is used. + * + */ typedef struct ED_ { - FT_16D16 dist; /* distance at `near' */ - FT_16D16_Vec near; /* nearest point */ - FT_Byte alpha; /* alpha of the source */ + FT_16D16 dist; + FT_16D16_Vec near; + FT_Byte alpha; } ED; + /************************************************************************** + * + * @Struct: + * BSDF_Worker + * + * @Description: + * Just a convenient struct which is passed to most of the functions + * while generating SDF. This makes it easier to pass parameters because + * most functions require the same parameters. + * + * @Fields: + * distance_map :: + * A 1D array which is interpreted as 2D array. This array contains + * the Euclidean distance of all the points of the bitmap. + * + * width :: + * Width of the above `distance_map'. + * + * rows :: + * Number of rows in the above `distance_map'. + * + * params :: + * Internal params and properties required by the rasterizer. See + * `ftsdf.h' for the fields of this struct. + * + */ typedef struct BSDF_Worker_ { ED* distance_map; @@ -977,6 +1042,7 @@ * */ + /* called when adding a new module through `FT_Add_Module' */ static FT_Error bsdf_raster_new( FT_Memory memory, FT_Raster* araster) @@ -995,6 +1061,7 @@ return error; } + /* unused */ static void bsdf_raster_reset( FT_Raster raster, unsigned char* pool_base, @@ -1006,6 +1073,7 @@ FT_UNUSED( pool_size ); } + /* unused */ static FT_Error bsdf_raster_set_mode( FT_Raster raster, unsigned long mode, @@ -1019,6 +1087,7 @@ return FT_Err_Ok; } + /* called while rendering through `FT_Render_Glyph' */ static FT_Error bsdf_raster_render( FT_Raster raster, const FT_Raster_Params* params ) @@ -1112,6 +1181,7 @@ return error; } + /* called while deleting a `FT_Library' only if the module is added */ static void bsdf_raster_done( FT_Raster raster ) { |