From d40fc55dad4eee6a54dc949576e34f981e16a47d Mon Sep 17 00:00:00 2001 From: Anuj Verma Date: Tue, 14 Jul 2020 17:20:05 +0530 Subject: [PATCH] [sdf] Temporary change. Added new property to dynamically change the optimization to be used to generate the SDF. This can be used to compare the performance of different optimization techniques without going and recompiling the program. And will also be used in the demo to check the performance. --- [GSoC]ChangeLog | 12 ++++++++++++ src/sdf/ftsdf.c | 19 +++++++++++++++++-- src/sdf/ftsdf.h | 13 +++++++++++++ src/sdf/ftsdfrend.c | 16 ++++++++++++++++ src/sdf/ftsdfrend.h | 3 +++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog index fc25667e1..09d0bdd3e 100644 --- a/[GSoC]ChangeLog +++ b/[GSoC]ChangeLog @@ -1,3 +1,15 @@ +2020-07-14 Anuj Verma + + [sdf] Temporary change. + + Added new property to dynamically change the + optimization to be used to generate the SDF. + This can be used to compare the performance of + different optimization techniques without going + and recompiling the program. + And will also be used in the demo to check the + performance. + 2020-07-13 Anuj Verma [sdf] Added more properties. diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c index 4797be880..f8e6f60d2 100644 --- a/src/sdf/ftsdf.c +++ b/src/sdf/ftsdf.c @@ -3129,8 +3129,23 @@ FT_CALL( sdf_outline_decompose( outline, shape ) ); - FT_CALL( sdf_generate_subdivision( internal_params, shape, sdf_params->spread, - sdf_params->root.target ) ); + /* TEMPORARY */ + if ( sdf_params->optimization == OPTIMIZATION_BB ) + FT_CALL( sdf_generate_bounding_box( internal_params, + shape, sdf_params->spread, + sdf_params->root.target ) ); + else if ( sdf_params->optimization == OPTIMIZATION_SUB ) + FT_CALL( sdf_generate_subdivision( internal_params, + shape, sdf_params->spread, + sdf_params->root.target ) ); + else if ( sdf_params->optimization == OPTIMIZATION_CG ) + FT_CALL( sdf_generate_coarse_grid( internal_params, + shape, sdf_params->spread, + sdf_params->root.target ) ); + else + FT_CALL( sdf_generate( internal_params, + shape, sdf_params->spread, + sdf_params->root.target ) ); if ( shape ) sdf_shape_done( &shape ); diff --git a/src/sdf/ftsdf.h b/src/sdf/ftsdf.h index edad03587..475393aed 100644 --- a/src/sdf/ftsdf.h +++ b/src/sdf/ftsdf.h @@ -17,6 +17,16 @@ FT_BEGIN_HEADER /* maximum spread supported by the rasterizer. */ #define MAX_SPREAD 32 + /* TEMPORARY */ + typedef enum Optimizations_ { + OPTIMIZATION_NONE = 0, /* default: check all points against all edges */ + OPTIMIZATION_BB = 1, /* use bounding box to check nearby grid points */ + OPTIMIZATION_SUB = 2, /* subdivide then use bounding box */ + OPTIMIZATION_CG = 3, /* use coarse grid to only check relevant edges */ + + } Optimizations; + /* --------- */ + /************************************************************************** * * @struct: @@ -38,6 +48,9 @@ FT_BEGIN_HEADER FT_Bool flip_sign; FT_Bool flip_y; + /* TEMPORARY */ + FT_Int optimization; + } SDF_Raster_Params; FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_sdf_raster; diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c index 0b0bd5ac6..44b2fc056 100644 --- a/src/sdf/ftsdfrend.c +++ b/src/sdf/ftsdfrend.c @@ -79,6 +79,16 @@ FT_TRACE7(( "[sdf] sdf_property_set: " "updated property `flip_y' to %d\n", val )); } + /* TEMPORARY */ + else if ( ft_strcmp( property_name, "optimization" ) == 0 ) + { + FT_Int val = *(const FT_Int*)value; + + + render->optimization = val ? 1 : 0; + FT_TRACE7(( "[sdf] sdf_property_set: " + "updated property `optimization' to %d\n", val )); + } else { FT_TRACE0(( "[sdf] sdf_property_set: " @@ -167,6 +177,9 @@ sdf_render->flip_sign = 0; sdf_render->flip_y = 0; + /* TEMPORARY */ + sdf_render->optimization = OPTIMIZATION_NONE; + return FT_Err_Ok; } @@ -280,6 +293,9 @@ params.flip_sign = sdf_module->flip_sign; params.flip_y = sdf_module->flip_y; + /* TEMPORARY */ + params.optimization = sdf_module->optimization; + /* render the outline */ error = render->raster_render( render->raster, (const FT_Raster_Params*)¶ms ); diff --git a/src/sdf/ftsdfrend.h b/src/sdf/ftsdfrend.h index 3f0f83118..262a2a11c 100644 --- a/src/sdf/ftsdfrend.h +++ b/src/sdf/ftsdfrend.h @@ -29,6 +29,9 @@ FT_BEGIN_HEADER FT_Bool flip_sign; FT_Bool flip_y; + /* TEMPORARY */ + FT_Int optimization; + } SDF_Renderer_Module, *SDF_Renderer;