mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 16:19:27 +02:00
LCL/PostscriptCanvas: Avoid separate calls to sin() and cos() with the same argument. Issue #39984.
This commit is contained in:
parent
969ac2a4bf
commit
2c8140696d
@ -1879,6 +1879,7 @@ var xScale : Real;
|
|||||||
ang : Integer;
|
ang : Integer;
|
||||||
//fs:TFormatSettings;
|
//fs:TFormatSettings;
|
||||||
pp1,pp2:TpsPoint;
|
pp1,pp2:TpsPoint;
|
||||||
|
sinAng, cosAng: Real;
|
||||||
begin
|
begin
|
||||||
Changing;
|
Changing;
|
||||||
RequiredState([csHandleValid, csBrushValid, csPenValid]);
|
RequiredState([csHandleValid, csBrushValid, csPenValid]);
|
||||||
@ -1915,7 +1916,8 @@ begin
|
|||||||
//move current point to start of arc, note negative
|
//move current point to start of arc, note negative
|
||||||
//angle because y increases down
|
//angle because y increases down
|
||||||
ClearBuffer;
|
ClearBuffer;
|
||||||
WriteB(Format('%.3f %.3f moveto',[cX+(rX*Cos(StAng*-1)),cY+(rY*Sin(StAng*-1))],FFs));
|
SinCos(-StAng, sinAng, cosAng);
|
||||||
|
WriteB(Format('%.3f %.3f moveto',[cX+rX*cosAng,cY+rY*sinAng],FFs));
|
||||||
WriteB(Code);
|
WriteB(Code);
|
||||||
SetBrushFillPattern(True,False);
|
SetBrushFillPattern(True,False);
|
||||||
|
|
||||||
@ -1930,6 +1932,7 @@ var xScale : Real;
|
|||||||
yScale : Real;
|
yScale : Real;
|
||||||
cX, cY : Real;
|
cX, cY : Real;
|
||||||
rX,Ry : Real;
|
rX,Ry : Real;
|
||||||
|
sinAngle1, cosAngle1: Real;
|
||||||
Code : string;
|
Code : string;
|
||||||
ang : string;
|
ang : string;
|
||||||
//fs:TFormatSettings;
|
//fs:TFormatSettings;
|
||||||
@ -1962,6 +1965,8 @@ begin
|
|||||||
Code:=Format('matrix currentmatrix %.3f %.3f translate %.3f %.3f scale 0 0 1 %.3f %.3f %s setmatrix',
|
Code:=Format('matrix currentmatrix %.3f %.3f translate %.3f %.3f scale 0 0 1 %.3f %.3f %s setmatrix',
|
||||||
[cX,cY,xScale,yScale,Angle1/16,Angle2/16,ang], FFs);
|
[cX,cY,xScale,yScale,Angle1/16,Angle2/16,ang], FFs);
|
||||||
|
|
||||||
|
SinCos(-Angle1/16, sinAngle1, cosAngle1);
|
||||||
|
|
||||||
if (Pen.Color<>clNone) and ((Pen.Color<>Brush.Color) or (Brush.Style<>bsSolid)) then
|
if (Pen.Color<>clNone) and ((Pen.Color<>Brush.Color) or (Brush.Style<>bsSolid)) then
|
||||||
begin
|
begin
|
||||||
UpdateLineColor(clNone);
|
UpdateLineColor(clNone);
|
||||||
@ -1970,7 +1975,7 @@ begin
|
|||||||
|
|
||||||
//move current point to start of arc, note negative
|
//move current point to start of arc, note negative
|
||||||
//angle because y increases down
|
//angle because y increases down
|
||||||
write(Format('%.3f %.3f moveto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
write(Format('%.3f %.3f moveto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
Write(Code);
|
Write(Code);
|
||||||
write('stroke');
|
write('stroke');
|
||||||
end;
|
end;
|
||||||
@ -1987,6 +1992,7 @@ var xScale : Real;
|
|||||||
rX,Ry : Real;
|
rX,Ry : Real;
|
||||||
Code : string;
|
Code : string;
|
||||||
ang : string;
|
ang : string;
|
||||||
|
SinAngle1, CosAngle1: Real;
|
||||||
begin
|
begin
|
||||||
Changing;
|
Changing;
|
||||||
RequiredState([csHandleValid, csBrushValid, csPenValid]);
|
RequiredState([csHandleValid, csBrushValid, csPenValid]);
|
||||||
@ -2014,20 +2020,21 @@ begin
|
|||||||
|
|
||||||
//move current point to start of arc, note negative
|
//move current point to start of arc, note negative
|
||||||
//angle because y increases down
|
//angle because y increases down
|
||||||
|
SinCos(-Angle1/16, sinAngle1, cosAngle1);
|
||||||
ClearBuffer;
|
ClearBuffer;
|
||||||
writeB(Format('%.3f %.3f moveto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
writeB(Format('%.3f %.3f moveto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
WriteB(Code);
|
WriteB(Code);
|
||||||
writeB(Format('%d %d lineto',[Left,Top]));
|
writeB(Format('%d %d lineto',[Left,Top]));
|
||||||
writeB(Format('%.3f %.3f lineto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
writeB(Format('%.3f %.3f lineto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
SetBrushFillPattern(False,True);
|
SetBrushFillPattern(False,True);
|
||||||
|
|
||||||
//move current point to start of arc, note negative
|
//move current point to start of arc, note negative
|
||||||
//angle because y increases down
|
//angle because y increases down
|
||||||
ClearBuffer;
|
ClearBuffer;
|
||||||
writeB(Format('%.3f %.3f moveto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
writeB(Format('%.3f %.3f moveto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
WriteB(Code);
|
WriteB(Code);
|
||||||
writeB(Format('%d %d lineto',[Left,Top]));
|
writeB(Format('%d %d lineto',[Left,Top]));
|
||||||
writeB(Format('%.3f %.3f lineto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
writeB(Format('%.3f %.3f lineto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
SetBrushFillPattern(True,False);
|
SetBrushFillPattern(True,False);
|
||||||
|
|
||||||
MoveToLastPos;
|
MoveToLastPos;
|
||||||
@ -2240,6 +2247,7 @@ var xScale : Real;
|
|||||||
rX,Ry : Real;
|
rX,Ry : Real;
|
||||||
Code : string;
|
Code : string;
|
||||||
ang : string;
|
ang : string;
|
||||||
|
sinAngle1, cosAngle1: Real;
|
||||||
//pp:TpsPoint;
|
//pp:TpsPoint;
|
||||||
begin
|
begin
|
||||||
Changing;
|
Changing;
|
||||||
@ -2268,9 +2276,10 @@ begin
|
|||||||
|
|
||||||
//move current point to start of arc, note negative
|
//move current point to start of arc, note negative
|
||||||
//angle because y increases down.ClosePath for draw chord
|
//angle because y increases down.ClosePath for draw chord
|
||||||
|
SinCos(-Angle1/16, SinAngle1, CosAngle1);
|
||||||
ClearBuffer;
|
ClearBuffer;
|
||||||
writeB('newpath');
|
writeB('newpath');
|
||||||
writeB(Format('%.3f %.3f moveto',[cX+(rX*Cos((Angle1/16)*-1)),cY+(rY*Sin((Angle1/16)*-1))],FFs));
|
writeB(Format('%.3f %.3f moveto',[cX+rX*CosAngle1,cY+rY*SinAngle1],FFs));
|
||||||
WriteB(Code);
|
WriteB(Code);
|
||||||
writeB('closepath');
|
writeB('closepath');
|
||||||
SetBrushFillPattern(True,True);
|
SetBrushFillPattern(True,True);
|
||||||
|
Loading…
Reference in New Issue
Block a user