Commit 2ffcf17e15a4f9c15609fb2e5a9c9942193e4a1f

Alexei Podtelezhnikov 2014-10-08T22:01:08

[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.

diff --git a/ChangeLog b/ChangeLog
index 4e17454..5b8a680 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-10-08  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[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  <apodtele@gmail.com>
 
 	[base] Significant optimization of `ft_div64by32'
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 349cb95..e400e25 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 )
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -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 )
-
-
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -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++;
     }