shithub: freetype+ttf2subf

Download patch

ref: 2ffcf17e15a4f9c15609fb2e5a9c9942193e4a1f
parent: 7abdb8cceab1b8855548548c16e0ecc2136c3c33
author: Alexei Podtelezhnikov <[email protected]>
date: Wed Oct 8 18:01:08 EDT 2014

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

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-10-08  Alexei Podtelezhnikov  <[email protected]>
+
+	[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  <[email protected]>
 
 	[base] Significant optimization of `ft_div64by32'
--- 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 @@
 
     for ( n = 1; n < outline->n_points; n++ )
     {
-      FT_Pos  x = vec->x;
-      FT_Pos  y = vec->y;
+      FT_UPDATE_BBOX( vec, cbox);
 
-
-      /* 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;
-
       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++;
     }