apophysis/2.10/Source/BucketFillerThread.pas

84 lines
1.6 KiB
ObjectPascal
Raw Normal View History

2005-09-11 06:20:56 -04:00
unit BucketFillerThread;
interface
uses
Classes, Windows,
ControlPoint, Render, XForm, RenderTypes;
2005-09-11 06:20:56 -04:00
type
TBucketFillerThread = class(TThread)
2005-09-11 06:20:56 -04:00
private
fcp: TControlPoint;
points: TPointsArray;
2005-09-11 06:20:56 -04:00
public
nrbatches: integer;
batchcounter: Pinteger;
ColorMap: TColorMapArray;
CriticalSection: TRTLCriticalSection;
AddPointsProc: procedure (const points: TPointsArray) of object;
2005-09-11 06:20:56 -04:00
constructor Create(cp: TControlPoint);
destructor Destroy; override;
procedure Execute; override;
end;
implementation
///////////////////////////////////////////////////////////////////////////////
constructor TBucketFillerThread.Create(cp: TControlPoint);
begin
inherited Create(True);
Self.FreeOnTerminate := True;
Fcp := cp.Clone;
SetLength(Points, SUB_BATCH_SIZE);
2006-03-02 12:27:20 -05:00
fcp.Prepare;
2005-09-11 06:20:56 -04:00
end;
///////////////////////////////////////////////////////////////////////////////
destructor TBucketFillerThread.Destroy;
begin
FCP.Free;
2005-09-11 06:20:56 -04:00
inherited;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TBucketFillerThread.Execute;
var
bc: integer;
begin
inherited;
bc := 0;
while (not Terminated) and (bc < Nrbatches) do begin
fcp.iterateXYC(SUB_BATCH_SIZE, points);
2005-09-11 06:20:56 -04:00
try
EnterCriticalSection(CriticalSection);
2006-03-02 12:27:20 -05:00
AddPointsProc(Points);
2005-09-11 06:20:56 -04:00
Inc(batchcounter^);
bc := batchcounter^
finally
LeaveCriticalSection(CriticalSection);
end;
end;
end;
///////////////////////////////////////////////////////////////////////////////
{ -- RENDER THREAD MUST *NOT* KNOW ANYTHING ABOUT BUCKETS!!! -- }
2005-09-11 06:20:56 -04:00
end.