mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-13 23:42:40 +02:00
TAChart: Fix freeze for very long line series drawn with wide pen
git-svn-id: trunk@31242 -
This commit is contained in:
parent
6d440e4535
commit
452f12804c
@ -394,6 +394,27 @@ var
|
||||
breaks: TIntegerDynArray;
|
||||
breakCount: Integer = 0;
|
||||
|
||||
// Drawing long polylines with wide pen is very inefficient on Windows and GTK.
|
||||
// On Windows it is so bad that trying to draw polyline with 50000 points
|
||||
// will cause hard freeze of entire OS. (!)
|
||||
// So, split long polylines into segments.
|
||||
function PolylineIsTooLong: Boolean; inline;
|
||||
const
|
||||
// There is a trade-off between the call overhead for short serment and
|
||||
// the above-mentioned inefficiency for long ones.
|
||||
// This value was selected by some experiments as "optimal enough" for
|
||||
// both affected platforms.
|
||||
MAX_LENGTH = 50;
|
||||
begin
|
||||
{$IF defined(WIN32) or defined(GTK2)}
|
||||
Result :=
|
||||
(LinePen.Width > 1) and (breakCount > 0) and
|
||||
(pointCount - breaks[breakCount - 1] > MAX_LENGTH);
|
||||
{$ELSE}
|
||||
Result := false;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure CacheLine(AA, AB: TDoublePoint);
|
||||
var
|
||||
ai, bi: TPoint;
|
||||
@ -404,7 +425,9 @@ var
|
||||
ai := ParentChart.GraphToImage(AA);
|
||||
bi := ParentChart.GraphToImage(AB);
|
||||
if ai = bi then exit;
|
||||
if (pointCount = 0) or (points[pointCount - 1] <> ai) then begin
|
||||
if
|
||||
(pointCount = 0) or (points[pointCount - 1] <> ai) or PolylineIsTooLong
|
||||
then begin
|
||||
breaks[breakCount] := pointCount;
|
||||
breakCount += 1;
|
||||
points[pointCount] := ai;
|
||||
|
Loading…
Reference in New Issue
Block a user