When I add the code below just at the end of BezierTexOut procedure, I have not this issue anymore.Code: [Select] //reset font orientation ACanvas.Font.Orientation := 0; <<<<<<<< add this line //debug only - draw the path from the points ... //with flatPts[0] do ACanvas.moveto(X,Y); //for i := 1 to ptCnt -1 do with flatPts[i] do ACanvas.lineto(X,Y);
//reset font orientation ACanvas.Font.Orientation := 0; <<<<<<<< add this line //debug only - draw the path from the points ... //with flatPts[0] do ACanvas.moveto(X,Y); //for i := 1 to ptCnt -1 do with flatPts[i] do ACanvas.lineto(X,Y);
BezierTextOut(Canvas, [Point(200, 50), Point(400, 50), Point(400, 350), Point(200, 350), Point(0, 350), Point(0, 50), Point(200, 50)], S);
Find attached the project with some benchmark added to it. The following enhancements where made 1) all drawing takes place on to a bitmap no one draws directly to the form canvas any more.2) changed the agg version removing the font manager creation and management and attaching it directly to the output bitmap to avoid triple buffering. even with this changes agg version seems to be about 2 times slower than the native one on windows as the screen shot shows. One more think I observed. If I execute the timing loop for agg multiple times I get wildly different results. What that means I'm unclear at the moment
Quote from: taazz on April 20, 2015, 06:54:09 amFind attached the project with some benchmark added to it. The following enhancements where made 1) all drawing takes place on to a bitmap no one draws directly to the form canvas any more.2) changed the agg version removing the font manager creation and management and attaching it directly to the output bitmap to avoid triple buffering. even with this changes agg version seems to be about 2 times slower than the native one on windows as the screen shot shows. One more think I observed. If I execute the timing loop for agg multiple times I get wildly different results. What that means I'm unclear at the momentHi Taazz,The AGG version is slower because it does a lot more work. This is how it works:1. extract the glyph outlines from the font2. convert the outlines from curves to line segments3. cut the line segments to smaller line segments so they can be distorted by a curve4. use the caller supplied bezier curve to warp the vertices of the glyph5. rasterize the glyph's polygon into scanlines6. fill the scanlines with the specified colorThis gives more accurate result when the font is large and curve has sharp turns.The speed variation you observed is probably due to font caching.
Quote from: finalpatch on April 20, 2015, 08:41:05 amQuote from: taazz on April 20, 2015, 06:54:09 amFind attached the project with some benchmark added to it. The following enhancements where made 1) all drawing takes place on to a bitmap no one draws directly to the form canvas any more.2) changed the agg version removing the font manager creation and management and attaching it directly to the output bitmap to avoid triple buffering. even with this changes agg version seems to be about 2 times slower than the native one on windows as the screen shot shows. One more think I observed. If I execute the timing loop for agg multiple times I get wildly different results. What that means I'm unclear at the momentHi Taazz,The AGG version is slower because it does a lot more work. This is how it works:1. extract the glyph outlines from the font2. convert the outlines from curves to line segments3. cut the line segments to smaller line segments so they can be distorted by a curve4. use the caller supplied bezier curve to warp the vertices of the glyph5. rasterize the glyph's polygon into scanlines6. fill the scanlines with the specified colorThis gives more accurate result when the font is large and curve has sharp turns.The speed variation you observed is probably due to font caching.I'm guessing that steps 5. 6. are done in the native api as well at some point so lets say they are on both. As you can see on the measuring procedure isn't the font cached the first time on the agg drawing as well? Or I'm missing something vital? when I say I'm seeing wild differences I mean if I execute the 1.000.000 iteration test on your procedure 3 consecutive times I got the results of 1)436,1215 2)427,8211 3)445,1853 (measurement in seconds (ticks/freq)) while thenative routine gives (1)209,2781 (2) 211,0545 (3) 210,3242 respectively. As you can see the time fluctuation is a bit too much on agg (it should be less as the iterations rise I think). In 10.000 iterations things are pretty unstable I got readings from 1.2 times slower up to 2.5 times slower that is why I jumped in to 1M iteration for my tests.
procedure CircleTextOut(ACanvas :TCanvas; Center :TPoint; Radius :integer; S :string);var Points :array[0..6] of TPoint; dx, dy :integer;begin // horizontal dx := Center.X - Radius; dy := Center.Y; Points[0] := Point(dx, dy); Points[1] := Point(dx + Round(0.05*dx), dy - 4*Radius div 3); Points[2] := Point(dx + 2*Radius - Round(0.05*dx), dy - 4*Radius div 3); Points[3] := Point(dx + 2*Radius, dy); Points[4] := Point(dx + 2*Radius - Round(0.05*dx), dy + 4*Radius div 3); Points[5] := Point(dx + Round(0.05*dx), dy + 4*Radius div 3); Points[6] := Point(dx, dy); BezierTextOut(ACanvas, Points, S);end;
download aggpas from their website, the zip archive contains the full source code to all examples.