From 80c5bed575d2e11325296feecd8fac8f387b647d Mon Sep 17 00:00:00 2001 From: Anuj Verma Date: Sat, 11 Jul 2020 08:53:28 +0530 Subject: [PATCH] [sdf] Completed the coarse grid optimization. * src/sdf/ftsdf.c (sdf_generate_coarse_grid): Fixed an issue with position calculation and upside down images. --- [GSoC]ChangeLog | 8 ++++++++ src/sdf/ftsdf.c | 24 +++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog index cc84e514e..713eadac4 100644 --- a/[GSoC]ChangeLog +++ b/[GSoC]ChangeLog @@ -1,3 +1,11 @@ +2020-07-11 Anuj Verma + + [sdf] Completed the coarse grid optimization. + + * src/sdf/ftsdf.c (sdf_generate_coarse_grid): Fixed + an issue with position calculation and upside down + images. + 2020-07-10 Anuj Verma [sdf] Partially completed the coarse grid optimization. diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c index 6b187ff7d..f8ae7b26c 100644 --- a/src/sdf/ftsdf.c +++ b/src/sdf/ftsdf.c @@ -45,7 +45,7 @@ /* then they will be checked for corner if they have ambiguity. */ #define CORNER_CHECK_EPSILON 32 - #define CG_DIMEN 8 + #define CG_DIMEN 10 /************************************************************************** * @@ -2816,8 +2816,8 @@ FT_26D6_Vec cpoint; coarse_grid[cindex] = NULL; - cpoint.x = FT_INT_26D6( i ) + FT_INT_26D6( c_width / 2 ); - cpoint.y = FT_INT_26D6( j ) + FT_INT_26D6( c_rows / 2 ); + cpoint.x = FT_INT_26D6( i * c_width ) + FT_INT_26D6( c_width / 2 ); + cpoint.y = FT_INT_26D6( j * c_rows ) + FT_INT_26D6( c_rows / 2 ); while ( cont ) { @@ -2831,18 +2831,16 @@ FT_CALL( sdf_edge_get_min_distance( edge, cpoint, &dist ) ); - if ( dist.distance > cg_sq ) + + if ( dist.distance < cg_sq ) { - edge = edge->next; - continue; + FT_CALL( sdf_edge_new( memory, &temp ) ); + ft_memcpy( temp, edge, sizeof( *edge ) ); + + temp->next = coarse_grid[cindex]; + coarse_grid[cindex] = temp; } - FT_CALL( sdf_edge_new( memory, &temp ) ); - ft_memcpy( temp, edge, sizeof( *edge ) ); - - temp->next = coarse_grid[cindex]; - coarse_grid[cindex] = temp; - edge = edge->next; } @@ -2904,7 +2902,7 @@ min_dist.distance /= 64; - buffer[ y * width + x ] = min_dist.distance; + buffer[ ( rows - y - 1 ) * width + x ] = min_dist.distance; } }