diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog index 6daa543e2..ae3ba0c94 100644 --- a/[GSoC]ChangeLog +++ b/[GSoC]ChangeLog @@ -1,3 +1,13 @@ +2020-07-09 Anuj Verma + + [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-07-09 Anuj Verma [sdf] Added functions to subdivide a cubic curve. diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c index 18e1699d8..3313556a2 100644 --- a/src/sdf/ftsdf.c +++ b/src/sdf/ftsdf.c @@ -2722,6 +2722,38 @@ return error; } + /************************************************************************** + * + * @Function: + * sdf_generate_bounding_box + * + * @Description: + * This function subdivide the shape into a number of straight lines + * and then simply use the above `sdf_generate_bounding_box' to generate + * the SDF. + * Note: After calling this function the `shape' will no longer have the + * original edges, it will only contain lines. + * + * @Input: + * [TODO] + * + * @Return: + * [TODO] + */ + static FT_Error + sdf_generate_subdivision( const SDF_Shape* shape, + FT_UInt spread, + const FT_Bitmap* bitmap ) + { + FT_Error error = FT_Err_Ok; + + FT_CALL( split_sdf_shape( shape ) ); + FT_CALL( sdf_generate_bounding_box( shape, spread, bitmap ) ); + + Exit: + return error; + } + /************************************************************************** * * interface functions @@ -2840,9 +2872,7 @@ FT_CALL( sdf_outline_decompose( outline, shape ) ); - split_sdf_shape( shape ); - - FT_CALL( sdf_generate_bounding_box( shape, sdf_params->spread, + FT_CALL( sdf_generate_subdivision( shape, sdf_params->spread, sdf_params->root.target ) ); Exit: