freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] [patch] on the subject of better splines


From: Алексей Подтележников
Subject: Re: [ft-devel] [patch] on the subject of better splines
Date: Sun, 3 Oct 2010 21:35:06 -0400

Graham,

2010/10/3 Graham Asher <address@hidden>:
> there's a chance it might help at high resolutions where more than one band
> is needed.

True, I have nothing to show for it besides correctness.
The speed up is barely visible. Is 72 enough to cross bands?

BEFORE: ftbench -b c -s 72 /mnt/windows/WINDOWS/Fonts/times.ttf
Render                    : 38.585 us/op
Render                    : 34.794 us/op
Render                    : 34.773 us/op
Render                    : 35.419 us/op
Render                    : 34.757 us/op
Render                    : 35.333 us/op
Render                    : 35.395 us/op
Render                    : 35.239 us/op
Render                    : 34.947 us/op
AFTER: ftbench -b c -s 72 /mnt/windows/WINDOWS/Fonts/times.ttf
Render                    : 35.092 us/op
Render                    : 34.761 us/op
Render                    : 34.964 us/op
Render                    : 34.680 us/op
Render                    : 35.490 us/op
Render                    : 34.852 us/op
Render                    : 34.651 us/op
Render                    : 34.678 us/op
Render                    : 34.679 us/op

> Also, at first glance your code looks as if it might be subject to integer
> overflow or division by zero.
The division by zero is out of question, not under the imposed condition.
The patch below makes the overflow much less likely. The fact that this
band check matters so little makes me think that it is out of place there,
even though it is very cheap.

--- a/src/smooth/ftgrays.c      2010-10-03 14:16:22.726223420 -0400
+++ b/src/smooth/ftgrays.c      2010-10-03 18:07:11.189192598 -0400
@@ -926,16 +926,18 @@
         TPos  min, max, y;


+        /* consider the endpoints first */
         min = max = arc[0].y;

-        y = arc[1].y;
-        if ( y < min ) min = y;
-        if ( y > max ) max = y;
-
         y = arc[2].y;
         if ( y < min ) min = y;
         if ( y > max ) max = y;

+        /* amend the boundaries based on the control point */
+        y = arc[1].y;
+        if ( y < min ) min += (y - min) * (y - min) / (2 * y - max - min);
+        if ( y > max ) max += (y - max) * (y - max) / (2 * y - max - min);
+
         if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
           goto Draw;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]