shithub: freetype+ttf2subf

Download patch

ref: 32a7d87050bf891d476892d441a56921eda299b0
parent: 1a9c3d14fbc068671480eb4b4d4e66620b366d8f
author: Alexei Podtelezhnikov <[email protected]>
date: Sat Aug 17 18:19:21 EDT 2013

[base] Clean up BBox_Conic_Check.

* src/base/ftbbox.c (BBox_Conic_Check): Remove redundant checks for
extremum at the segment ends, which are already within the bbox.
Slightly modify calculations.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-17  Alexei Podtelezhnikov  <[email protected]>
+
+	[base] Clean up BBox_Conic_Check.
+
+	* src/base/ftbbox.c (BBox_Conic_Check): Remove redundant checks for
+	extremum at the segment ends, which are already within the bbox.
+	Slightly modify calculations. 
+
 2013-08-15  Alexei Podtelezhnikov  <[email protected]>
 
 	[base] Finish experimental (disabled) BBox_Cubic_Check implementation.
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -108,30 +108,19 @@
                     FT_Pos*  min,
                     FT_Pos*  max )
   {
-    if ( y1 <= y3 && y2 == y1 )     /* flat arc */
-      goto Suite;
+    /* This function is only called when a control off-point is outside  */
+    /* the bbox. This also means there must be a local extremum within   */
+    /* the segment with the value of (y1*y3 - y2*y2)/(y1 - 2*y2 + y3).   */
+    /* Offsetting from the closest point to the extermum, y2, we get     */
 
-    if ( y1 < y3 )
-    {
-      if ( y2 >= y1 && y2 <= y3 )   /* ascending arc */
-        goto Suite;
-    }
-    else
-    {
-      if ( y2 >= y3 && y2 <= y1 )   /* descending arc */
-      {
-        y2 = y1;
-        y1 = y3;
-        y3 = y2;
-        goto Suite;
-      }
-    }
+    y1 -= y2;
+    y3 -= y2;
+    y2 += FT_MulDiv( y1, y3, y1 + y3 );
 
-    y1 = y3 = y1 - FT_MulDiv( y2 - y1, y2 - y1, y1 - 2*y2 + y3 );
-
-  Suite:
-    if ( y1 < *min ) *min = y1;
-    if ( y3 > *max ) *max = y3;
+    if ( y2 < *min )
+      *min = y2;
+    if ( y2 > *max )
+      *max = y2;
   }