[sdf] Added function to get contour orientation.
* src/sdf/ftsdf.c (SDF_Contour_Orientation): Added enum to hold the different orientations of a contour. * src/sdf/ftsdf.c (get_contour_orientation): Added function which can be used to compute the orientation of a contour. * src/sdf/ftbsdf.c (*): Remove completed `[TODO]'s.
This commit is contained in:
parent
5014394b3e
commit
06bbff76b9
|
@ -1,3 +1,16 @@
|
||||||
|
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
|
||||||
|
|
||||||
|
[sdf] Added function to get contour orientation.
|
||||||
|
|
||||||
|
* src/sdf/ftsdf.c (SDF_Contour_Orientation): Added
|
||||||
|
enum to hold the different orientations of a contour.
|
||||||
|
|
||||||
|
* src/sdf/ftsdf.c (get_contour_orientation): Added
|
||||||
|
function which can be used to compute the orientation
|
||||||
|
of a contour.
|
||||||
|
|
||||||
|
* src/sdf/ftbsdf.c (*): Remove completed `[TODO]'s.
|
||||||
|
|
||||||
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
|
2020-08-6 Anuj Verma <anujv@iitbhilai.ac.in>
|
||||||
|
|
||||||
[sdf -> bsdf] Added documentation for functions of the `bsdf' renderer.
|
[sdf -> bsdf] Added documentation for functions of the `bsdf' renderer.
|
||||||
|
|
|
@ -308,7 +308,6 @@
|
||||||
/* approximate direction of the edge, we can */
|
/* approximate direction of the edge, we can */
|
||||||
/* approximate the edge distance much better. */
|
/* approximate the edge distance much better. */
|
||||||
|
|
||||||
/* [TODO]: Add squared distance support. */
|
|
||||||
if ( g.x == 0 || g.y == 0 )
|
if ( g.x == 0 || g.y == 0 )
|
||||||
dist = ONE / 2 - alphas[4];
|
dist = ONE / 2 - alphas[4];
|
||||||
else
|
else
|
||||||
|
@ -509,7 +508,6 @@
|
||||||
/* convert the source bitmap to desired bpp. */
|
/* convert the source bitmap to desired bpp. */
|
||||||
switch ( source->pixel_mode ) {
|
switch ( source->pixel_mode ) {
|
||||||
case FT_PIXEL_MODE_MONO:
|
case FT_PIXEL_MODE_MONO:
|
||||||
/* [TODO] */
|
|
||||||
{
|
{
|
||||||
FT_Int t_width = worker->width;
|
FT_Int t_width = worker->width;
|
||||||
FT_Int t_rows = worker->rows;
|
FT_Int t_rows = worker->rows;
|
||||||
|
|
|
@ -151,7 +151,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MUL_26D6( a, b ) ( ( a * b ) / 64 )
|
#define MUL_26D6( a, b ) ( ( ( a ) * ( b ) ) / 64 )
|
||||||
#define VEC_26D6_DOT( p, q ) ( MUL_26D6( p.x, q.x ) + \
|
#define VEC_26D6_DOT( p, q ) ( MUL_26D6( p.x, q.x ) + \
|
||||||
MUL_26D6( p.y, q.y ) )
|
MUL_26D6( p.y, q.y ) )
|
||||||
|
|
||||||
|
@ -177,6 +177,16 @@
|
||||||
|
|
||||||
} SDF_Edge_Type;
|
} SDF_Edge_Type;
|
||||||
|
|
||||||
|
/* Enumeration for the orientation of a contour, remember */
|
||||||
|
/* the orientation is independent of the fill rule. */
|
||||||
|
typedef enum SDF_Contour_Orientation_
|
||||||
|
{
|
||||||
|
SDF_ORIENTATION_NONE = 0, /* undefined, used to initialize */
|
||||||
|
SDF_ORIENTATION_CW = 0, /* clockwise orientation */
|
||||||
|
SDF_ORIENTATION_ACW = 0, /* anti-clockwise orientation */
|
||||||
|
|
||||||
|
} SDF_Contour_Orientation;
|
||||||
|
|
||||||
/* represent a single edge in a contour */
|
/* represent a single edge in a contour */
|
||||||
typedef struct SDF_Edge_
|
typedef struct SDF_Edge_
|
||||||
{
|
{
|
||||||
|
@ -694,6 +704,67 @@
|
||||||
return cbox;
|
return cbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The function returns the orientation for a single contour. */
|
||||||
|
/* Note that the orientation is independent of the fill rule. */
|
||||||
|
/* So, for ttf the clockwise has to be filled and the opposite */
|
||||||
|
/* for otf fonts. */
|
||||||
|
static SDF_Contour_Orientation
|
||||||
|
get_contour_orientation ( SDF_Contour* contour )
|
||||||
|
{
|
||||||
|
SDF_Edge* head = NULL;
|
||||||
|
FT_26D6 area = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* return none if invalid parameters */
|
||||||
|
if ( !contour || !contour->edges )
|
||||||
|
return SDF_ORIENTATION_NONE;
|
||||||
|
|
||||||
|
head = contour->edges;
|
||||||
|
|
||||||
|
/* Simply calculate the area of the control box for */
|
||||||
|
/* all the edges. */
|
||||||
|
while ( head )
|
||||||
|
{
|
||||||
|
switch ( head->edge_type ) {
|
||||||
|
case SDF_EDGE_LINE:
|
||||||
|
{
|
||||||
|
area += MUL_26D6( ( head->end_pos.x - head->start_pos.x ),
|
||||||
|
( head->end_pos.y + head->start_pos.y ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDF_EDGE_CONIC:
|
||||||
|
{
|
||||||
|
area += MUL_26D6( head->control_a.x - head->start_pos.x,
|
||||||
|
head->control_a.y + head->start_pos.y );
|
||||||
|
area += MUL_26D6( head->end_pos.x - head->control_a.x,
|
||||||
|
head->end_pos.y + head->control_a.y );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDF_EDGE_CUBIC:
|
||||||
|
{
|
||||||
|
area += MUL_26D6( head->control_a.x - head->start_pos.x,
|
||||||
|
head->control_a.y + head->start_pos.y );
|
||||||
|
area += MUL_26D6( head->control_b.x - head->control_a.x,
|
||||||
|
head->control_b.y + head->control_a.y );
|
||||||
|
area += MUL_26D6( head->end_pos.x - head->control_b.x,
|
||||||
|
head->end_pos.y + head->control_b.y );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return SDF_ORIENTATION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
head = head->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clockwise contour cover a positive area, and Anti-Clockwise */
|
||||||
|
/* contour cover a negitive area. */
|
||||||
|
if ( area > 0 )
|
||||||
|
return SDF_ORIENTATION_CW;
|
||||||
|
else
|
||||||
|
return SDF_ORIENTATION_ACW;
|
||||||
|
}
|
||||||
|
|
||||||
/* The function is exactly same as the one */
|
/* The function is exactly same as the one */
|
||||||
/* in the smooth renderer. It splits a conic */
|
/* in the smooth renderer. It splits a conic */
|
||||||
/* into two conic exactly half way at t = 0.5 */
|
/* into two conic exactly half way at t = 0.5 */
|
||||||
|
|
Loading…
Reference in New Issue