From 2ffcf17e15a4f9c15609fb2e5a9c9942193e4a1f Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Wed, 8 Oct 2014 22:01:08 -0400 Subject: [PATCH] [base] Introduce and use new macro `FT_UPDATE_BBOX' * src/base/ftbbox.c (FT_UPDATE_BBOX): New macro. (FT_Outline_Get_BBox): Use it here. --- ChangeLog | 7 +++++++ src/base/ftbbox.c | 46 +++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e174549d..5b8a680c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-10-08 Alexei Podtelezhnikov + + [base] Introduce and use new macro `FT_UPDATE_BBOX' + + * src/base/ftbbox.c (FT_UPDATE_BBOX): New macro. + (FT_Outline_Get_BBox): Use it here. + 2014-10-02 Alexei Podtelezhnikov [base] Significant optimization of `ft_div64by32' diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c index 349cb9598..e400e250d 100644 --- a/src/base/ftbbox.c +++ b/src/base/ftbbox.c @@ -42,6 +42,25 @@ } TBBox_Rec; +#define FT_UPDATE_BBOX(p, bbox) \ + FT_BEGIN_STMNT \ + if ( p->x < bbox.xMin ) \ + bbox.xMin = p->x; \ + if ( p->x > bbox.xMax ) \ + bbox.xMax = p->x; \ + if ( p->y < bbox.yMin ) \ + bbox.yMin = p->y; \ + if ( p->y > bbox.yMax ) \ + bbox.yMax = p->y; \ + FT_END_STMNT + +#define CHECK_X( p, bbox ) \ + ( p->x < bbox.xMin || p->x > bbox.xMax ) + +#define CHECK_Y( p, bbox ) \ + ( p->y < bbox.yMin || p->y > bbox.yMax ) + + /*************************************************************************/ /* */ /* */ @@ -72,13 +91,6 @@ } -#define CHECK_X( p, bbox ) \ - ( p->x < bbox.xMin || p->x > bbox.xMax ) - -#define CHECK_Y( p, bbox ) \ - ( p->y < bbox.yMin || p->y > bbox.yMax ) - - /*************************************************************************/ /* */ /* */ @@ -420,26 +432,10 @@ FT_DEFINE_OUTLINE_FUNCS(bbox_interface, for ( n = 1; n < outline->n_points; n++ ) { - FT_Pos x = vec->x; - FT_Pos y = vec->y; - - - /* update control box */ - if ( x < cbox.xMin ) cbox.xMin = x; - if ( x > cbox.xMax ) cbox.xMax = x; - - if ( y < cbox.yMin ) cbox.yMin = y; - if ( y > cbox.yMax ) cbox.yMax = y; + FT_UPDATE_BBOX( vec, cbox); if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON ) - { - /* update bbox for `on' points only */ - if ( x < bbox.xMin ) bbox.xMin = x; - if ( x > bbox.xMax ) bbox.xMax = x; - - if ( y < bbox.yMin ) bbox.yMin = y; - if ( y > bbox.yMax ) bbox.yMax = y; - } + FT_UPDATE_BBOX( vec, bbox); vec++; }