From 7264e2ac56111001b1a1faf96a64ff6f4d08b6f8 Mon Sep 17 00:00:00 2001 From: zueuk Date: Wed, 22 Mar 2006 13:52:27 +0000 Subject: [PATCH] fixed MM renderer, MM renderer classes are now derived from non-MM ones --- 2.10/Source/Render.pas | 2 +- 2.10/Source/Render64.pas | 39 ++--- 2.10/Source/Render64MT.pas | 60 +++---- 2.10/Source/RenderMM.pas | 226 +++----------------------- 2.10/Source/RenderMM_MT.pas | 311 ++---------------------------------- 5 files changed, 90 insertions(+), 548 deletions(-) diff --git a/2.10/Source/Render.pas b/2.10/Source/Render.pas index 93692c5..03d1852 100644 --- a/2.10/Source/Render.pas +++ b/2.10/Source/Render.pas @@ -1,7 +1,7 @@ { Flame screensaver Copyright (C) 2002 Ronald Hordijk Apophysis Copyright (C) 2001-2004 Mark Townsend - Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov + Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/2.10/Source/Render64.pas b/2.10/Source/Render64.pas index 5acbd5d..4d081b4 100644 --- a/2.10/Source/Render64.pas +++ b/2.10/Source/Render64.pas @@ -1,7 +1,7 @@ { Flame screensaver Copyright (C) 2002 Ronald Hordijk Apophysis Copyright (C) 2001-2004 Mark Townsend - Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov + Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,28 +23,28 @@ interface uses Windows, Forms, Graphics, ImageMaker, - Render, xform, Controlpoint; + Render, xform, Controlpoint; type TRenderer64 = class(TBaseRenderer) - private - oversample: integer; - - BucketWidth, BucketHeight: integer; - BucketSize: integer; - - gutter_width: Integer; - max_gutter_width: Integer; - - sample_density: extended; - - Buckets: TBucketArray; - ColorMap: TColorMapArray; + protected camX0, camX1, camY0, camY1, // camera bounds camW, camH, // camera sizes bws, bhs, cosa, sina, rcX, rcY: double; ppux, ppuy: extended; + + BucketWidth, BucketHeight: int64; + BucketSize: int64; + + sample_density: extended; + oversample: integer; + gutter_width: Integer; + max_gutter_width: Integer; + + Buckets: TBucketArray; + ColorMap: TColorMapArray; + FImageMaker: TImageMaker; procedure InitValues; @@ -57,7 +57,7 @@ type procedure SetPixels; - private + protected PropTable: array[0..SUB_BATCH_SIZE] of TXform; finalXform: TXform; UseFinalXform: boolean; @@ -216,8 +216,10 @@ begin try SetLength(buckets, BucketSize); except - on EOutOfMemory do - Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48) + on EOutOfMemory do begin + Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48); + FStop := true; + end; end; // share the buffer with imagemaker @@ -241,7 +243,6 @@ var i: integer; nsamples: Int64; nrbatches: Integer; - //points: TPointsArray; IterateBatchProc: procedure of object; begin Prepare; diff --git a/2.10/Source/Render64MT.pas b/2.10/Source/Render64MT.pas index 1a70d89..c00429f 100644 --- a/2.10/Source/Render64MT.pas +++ b/2.10/Source/Render64MT.pas @@ -1,7 +1,7 @@ { Flame screensaver Copyright (C) 2002 Ronald Hordijk Apophysis Copyright (C) 2001-2004 Mark Townsend - Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov + Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,34 +22,32 @@ unit Render64MT; interface uses - Windows, Classes, Graphics, - Render, Controlpoint, ImageMaker, BucketFillerthread; + Windows, Forms, Classes, Graphics, + Render, Controlpoint, ImageMaker, BucketFillerthread; type TRenderer64MT = class(TBaseRenderer) - private - oversample: Int64; - batchcounter: Integer; - FNrBatches: Int64; - BucketWidth: Int64; - BucketHeight: Int64; + protected + camX0, camX1, camY0, camY1, // camera bounds + camW, camH, // camera sizes + bws, bhs, cosa, sina, rcX, rcY: double; + ppux, ppuy: extended; + + BucketWidth, BucketHeight: Int64; BucketSize: Int64; + + sample_density: extended; + oversample: integer; gutter_width: Integer; max_gutter_width: Integer; - sample_density: extended; + batchcounter: Integer; + FNrBatches: Int64; Buckets: TBucketArray; ColorMap: TColorMapArray; - camX0, camX1, camY0, camY1, // camera bounds - camW, camH, // camera sizes - Xsize, Ysize: double; - bws, bhs, cosa, sina, rcX, rcY: double; -// bounds: array[0..3] of extended; -// size: array[0..1] of extended; - ppux, ppuy: extended; FNrOfTreads: integer; WorkingThreads: array of TBucketFillerThread; CriticalSection: TRTLCriticalSection; @@ -119,7 +117,7 @@ var scale: double; t0, t1: double; t2, t3: double; - corner_x, corner_y: double; + corner_x, corner_y, Xsize, Ysize: double; shift: Integer; begin scale := power(2, fcp.zoom); @@ -184,6 +182,14 @@ begin {$ENDIF} end; +/////////////////////////////////////////////////////////////////////////////// +constructor TRenderer64MT.Create; +begin + inherited Create; + + FImageMaker := TImageMaker.Create; +end; + /////////////////////////////////////////////////////////////////////////////// destructor TRenderer64MT.Destroy; begin @@ -210,8 +216,14 @@ begin Bucketwidth := oversample * fcp.width + 2 * max_gutter_width; BucketSize := BucketWidth * BucketHeight; - if high(buckets) <> (BucketSize - 1) then begin + if high(buckets) <> (BucketSize - 1) then + try SetLength(buckets, BucketSize); + except + on EOutOfMemory do begin + Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48); + FStop := true; + end; end; // share the buffer with imagemaker @@ -238,7 +250,7 @@ var begin nsamples := Round(sample_density * bucketSize / (oversample * oversample)); FNrBatches := Round(nsamples / (fcp.nbatches * SUB_BATCH_SIZE)); - batchcounter := 0; + batchcounter := 0; Randomize; InitializeCriticalSection(CriticalSection); @@ -295,14 +307,6 @@ begin end; end; -/////////////////////////////////////////////////////////////////////////////// -constructor TRenderer64MT.Create; -begin - inherited Create; - - FImageMaker := TImageMaker.Create; -end; - /////////////////////////////////////////////////////////////////////////////// procedure TRenderer64MT.Render; begin diff --git a/2.10/Source/RenderMM.pas b/2.10/Source/RenderMM.pas index a07e070..22759e0 100644 --- a/2.10/Source/RenderMM.pas +++ b/2.10/Source/RenderMM.pas @@ -1,7 +1,7 @@ { Flame screensaver Copyright (C) 2002 Ronald Hordijk Apophysis Copyright (C) 2001-2004 Mark Townsend - Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov + Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,61 +22,31 @@ unit RenderMM; interface uses - Windows, Graphics, - Render, Controlpoint, ImageMaker, XForm; + Windows, Forms, Graphics, + Render64, Controlpoint, ImageMaker, XForm; type - TRendererMM64 = class(TBaseRenderer) + TRendererMM64 = class(TRenderer64) + private - oversample: Integer; + image_Width, image_Height: Int64; + image_Center_X, image_Center_Y: double; - image_Width: Int64; - image_Height: Int64; - BucketWidth: Integer; - BucketHeight: Integer; - BucketSize: Integer; - gutter_width: Integer; - - sample_density: extended; - - Buckets: TBucketArray; - ColorMap: TColorMapArray; - - camX0, camX1, camY0, camY1, // camera bounds - camW, camH, // camera sizes - bws, bhs, cosa, sina, rcX, rcY: double; -// bounds: array[0..3] of extended; -// size: array[0..1] of extended; -// FRotationCenter: array[0..1] of extended; - ppux, ppuy: extended; - nrSlices: int64; - Slice: int64; - FImageMaker: TImageMaker; + Slice, nrSlices: integer; procedure InitValues; procedure InitBuffers; - procedure ClearBuffers; - procedure ClearBuckets; - procedure CreateColorMap; procedure CreateCamera; - procedure AddPointsToBuckets(const points: TPointsArray); - procedure AddPointsToBucketsAngle(const points: TPointsArray); - - procedure SetPixels; protected function GetSlice: integer; override; function GetNrSlices: integer; override; public - constructor Create; override; - destructor Destroy; override; - function GetImage: TBitmap; override; procedure SaveImage(const FileName: String); override; procedure Render; override; - end; implementation @@ -86,25 +56,6 @@ uses { TRendererMM64 } -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.ClearBuckets; -var - i: integer; -begin - for i := 0 to BucketSize - 1 do begin - buckets[i].Red := 0; - buckets[i].Green := 0; - buckets[i].Blue := 0; - buckets[i].Count := 0; - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.ClearBuffers; -begin - ClearBuckets; -end; - /////////////////////////////////////////////////////////////////////////////// procedure TRendererMM64.CreateCamera; var @@ -123,24 +74,12 @@ begin t1 := gutter_width / (oversample * ppuy); corner_x := fcp.center[0] - image_width / ppux / 2.0; corner_y := fcp.center[1] - image_height / ppuy / 2.0; -{ - bounds[0] := corner0 - t0; - bounds[1] := corner1 - t1 + shift; - bounds[2] := corner0 + image_width / ppux + t0; - bounds[3] := corner1 + image_height / ppuy + t1; //+ shift; - if abs(bounds[2] - bounds[0]) > 0.01 then - size[0] := 1.0 / (bounds[2] - bounds[0]) - else - size[0] := 1; - if abs(bounds[3] - bounds[1]) > 0.01 then - size[1] := 1.0 / (bounds[3] - bounds[1]) - else - size[1] := 1; -} + camX0 := corner_x - t0; camY0 := corner_y - t1 + shift; - camX1 := corner_x + image_width / ppux / 2.0; + camX1 := corner_x + image_width / ppux + t0; camY1 := corner_y + image_height / ppuy + t1; //+ shift; + camW := camX1 - camX0; if abs(camW) > 0.01 then Xsize := 1.0 / camW @@ -158,32 +97,11 @@ begin begin cosa := cos(FCP.FAngle); sina := sin(FCP.FAngle); - rcX := FCP.Center[0]*(1 - cosa) - FCP.Center[1]*sina - camX0; - rcY := FCP.Center[1]*(1 - cosa) + FCP.Center[0]*sina - camY0; + rcX := image_Center_X*(1 - cosa) - image_Center_X*sina - camX0; + rcY := image_Center_Y*(1 - cosa) + image_Center_Y*sina - camY0; end; end; -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.CreateColorMap; -var - i: integer; -begin - for i := 0 to 255 do begin - ColorMap[i].Red := (fcp.CMap[i][0] * fcp.white_level) div 256; - ColorMap[i].Green := (fcp.CMap[i][1] * fcp.white_level) div 256; - ColorMap[i].Blue := (fcp.CMap[i][2] * fcp.white_level) div 256; -// cmap[i][3] := fcp.white_level; - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -destructor TRendererMM64.Destroy; -begin - FImageMaker.Free; - - inherited; -end; - /////////////////////////////////////////////////////////////////////////////// function TRendererMM64.GetImage: TBitmap; begin @@ -199,8 +117,14 @@ begin Bucketwidth := oversample * image_width + 2 * gutter_width; BucketSize := BucketWidth * BucketHeight; - if high(buckets) <> (BucketSize - 1) then begin + if high(buckets) <> (BucketSize - 1) then + try SetLength(buckets, BucketSize); + except + on EOutOfMemory do begin + Application.MessageBox('Error: not enough memory for this render!', 'Apophysis', 48); + FStop := true; + end; end; // share the buffer with imagemaker @@ -214,7 +138,6 @@ begin image_Width := fcp.Width; CreateCamera; - InitBuffers; CreateColorMap; @@ -222,111 +145,6 @@ begin fcp.Prepare; end; -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.AddPointsToBuckets(const points: TPointsArray); -var - i: integer; - px, py: double; -// R: double; -// V1, v2, v3: integer; - Bucket: PBucket; - MapColor: PColorMapColor; -begin - for i := SUB_BATCH_SIZE - 1 downto 0 do begin -// if FStop then Exit; - - px := points[i].x - camX0; - if (px < 0) or (px > camW) then continue; - py := points[i].y - camY0; - if (py < 0) or (py > camH) then continue; - - Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth]; - MapColor := @ColorMap[Round(points[i].c * 255)]; - - Inc(Bucket.Red, MapColor.Red); - Inc(Bucket.Green, MapColor.Green); - Inc(Bucket.Blue, MapColor.Blue); - Inc(Bucket.Count); - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.AddPointsToBucketsAngle(const points: TPointsArray); -var - i: integer; - px, py: double; - Bucket: PBucket; - MapColor: PColorMapColor; -begin - for i := SUB_BATCH_SIZE - 1 downto 0 do begin -// if FStop then Exit; - - px := points[i].x * cosa + points[i].y * sina + rcX; - if (px < 0) or (px > camW) then continue; - py := points[i].y * cosa - points[i].x * sina + rcY; - if (py < 0) or (py > camH) then continue; - - Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth]; - MapColor := @ColorMap[Round(points[i].c * 255)]; - - Inc(Bucket.Red, MapColor.Red); - Inc(Bucket.Green, MapColor.Green); - Inc(Bucket.Blue, MapColor.Blue); - Inc(Bucket.Count); - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64.SetPixels; -var - i: integer; - nsamples: Int64; - nrbatches: Integer; - points: TPointsArray; -begin - SetLength(Points, SUB_BATCH_SIZE); - - nsamples := Round(sample_density * bucketSize / (oversample * oversample)); - nrbatches := Round(nsamples / (fcp.nbatches * SUB_BATCH_SIZE)); - Randomize; - - for i := 0 to nrbatches do begin - if FStop then - Exit; - - if (i and $F = 0) then - if nrbatches > 0 then - Progress(i / nrbatches) - else - Progress(0); - - // generate points -{ - case Compatibility of - 0: fcp.iterate_Old(SUB_BATCH_SIZE, points); - 1: fcp.iterateXYC(SUB_BATCH_SIZE, points); - end; -} - fcp.IterateXYC(SUB_BATCH_SIZE, points); - - if FCP.FAngle = 0 then - AddPointsToBuckets(points) - else - AddPointsToBucketsAngle(points); - end; - - Progress(1); -end; - - -/////////////////////////////////////////////////////////////////////////////// -constructor TRendererMM64.Create; -begin - inherited Create; - - FImageMaker := TImageMaker.Create; -end; - /////////////////////////////////////////////////////////////////////////////// procedure TRendererMM64.Render; const @@ -338,8 +156,8 @@ var begin FStop := False; -// FRotationCenter[0] := fcp.center[0]; -// FRotationCenter[1] := fcp.center[1]; + image_Center_X := fcp.center[0]; + image_Center_Y := fcp.center[1]; image_height := fcp.Height; image_Width := fcp.Width; diff --git a/2.10/Source/RenderMM_MT.pas b/2.10/Source/RenderMM_MT.pas index 8c52152..c855690 100644 --- a/2.10/Source/RenderMM_MT.pas +++ b/2.10/Source/RenderMM_MT.pas @@ -1,7 +1,7 @@ { Flame screensaver Copyright (C) 2002 Ronald Hordijk Apophysis Copyright (C) 2001-2004 Mark Townsend - Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov + Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,75 +23,32 @@ interface uses Windows, Graphics, - Render, Controlpoint, ImageMaker, BucketFillerThread, XForm; + Render64MT, Controlpoint, ImageMaker, BucketFillerThread, XForm; type - TRendererMM64_MT = class(TBaseRenderer) + TRendererMM64_MT = class(TRenderer64MT) + private - oversample: Integer; + image_Width, image_Height: integer; + image_Center_X, image_Center_Y: double; - image_Width, image_Height: integer; // we're not going to render images - BucketWidth, BucketHeight: integer; // more then 2^32 pixels wide, are we? :) - BucketSize: Integer; - gutter_width: Integer; - - sample_density: extended; - - Buckets: TBucketArray; - ColorMap: TColorMapArray; - - camX0, camX1, camY0, camY1, // camera bounds - camW, camH, // camera sizes - bws, bhs, cosa, sina, rcX, rcY: double; -// bounds: array[0..3] of extended; -// size: array[0..1] of extended; -// FRotationCenter: array[0..1] of extended; - - ppux, ppuy: extended; - nrSlices: int64; - Slice: int64; - FImageMaker: TImageMaker; - FNrBatches: int64; - batchcounter: Integer; - - FNrOfTreads: integer; - WorkingThreads: array of TBucketFillerThread; - CriticalSection: TRTLCriticalSection; + Slice, nrSlices: integer; procedure InitValues; procedure InitBuffers; - procedure ClearBuffers; - procedure ClearBuckets; - procedure CreateColorMap; procedure CreateCamera; - procedure AddPointsToBuckets(const points: TPointsArray); - procedure AddPointsToBucketsAngle(const points: TPointsArray); - - procedure SetPixels; - procedure SetPixelsMT; - procedure SetNrOfTreads(const Value: integer); - - function NewThread: TBucketFillerThread; protected function GetSlice: integer; override; function GetNrSlices: integer; override; public - constructor Create; override; - destructor Destroy; override; - function GetImage: TBitmap; override; - procedure SaveImage(const FileName: String); override; procedure Render; override; procedure Stop; override; procedure Pause(paused: boolean); override; - - property NrOfTreads: integer - read FNrOfTreads - write SetNrOfTreads; end; implementation @@ -101,25 +58,6 @@ uses { TRendererMM64_MT } -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.ClearBuckets; -var - i: integer; -begin - for i := 0 to BucketSize - 1 do begin - buckets[i].Red := 0; - buckets[i].Green := 0; - buckets[i].Blue := 0; - buckets[i].Count := 0; - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.ClearBuffers; -begin - ClearBuckets; -end; - /////////////////////////////////////////////////////////////////////////////// procedure TRendererMM64_MT.CreateCamera; var @@ -160,32 +98,11 @@ begin begin cosa := cos(FCP.FAngle); sina := sin(FCP.FAngle); - rcX := FCP.Center[0]*(1 - cosa) - FCP.Center[1]*sina - camX0; - rcY := FCP.Center[1]*(1 - cosa) + FCP.Center[0]*sina - camY0; + rcX := image_Center_X*(1 - cosa) - image_Center_X*sina - camX0; + rcY := image_Center_Y*(1 - cosa) + image_Center_Y*sina - camY0; end; end; -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.CreateColorMap; -var - i: integer; -begin - for i := 0 to 255 do begin - ColorMap[i].Red := (fcp.CMap[i][0] * fcp.white_level) div 256; - ColorMap[i].Green := (fcp.CMap[i][1] * fcp.white_level) div 256; - ColorMap[i].Blue := (fcp.CMap[i][2] * fcp.white_level) div 256; -// cmap[i][3] := fcp.white_level; - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -destructor TRendererMM64_MT.Destroy; -begin - FImageMaker.Free; - - inherited; -end; - /////////////////////////////////////////////////////////////////////////////// function TRendererMM64_MT.GetImage: TBitmap; begin @@ -215,111 +132,7 @@ begin image_height := fcp.Height; image_Width := fcp.Width; - CreateCamera; - - InitBuffers; - - CreateColorMap; - - fcp.Prepare; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.AddPointsToBuckets(const points: TPointsArray); -var - i: integer; - px, py: double; -// R: double; -// V1, v2, v3: integer; - Bucket: PBucket; - MapColor: PColorMapColor; -begin - for i := SUB_BATCH_SIZE - 1 downto 0 do begin -// if FStop then Exit; - - px := points[i].x - camX0; - if (px < 0) or (px > camW) then continue; - py := points[i].y - camY0; - if (py < 0) or (py > camH) then continue; - - Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth]; - MapColor := @ColorMap[Round(points[i].c * 255)]; - - Inc(Bucket.Red, MapColor.Red); - Inc(Bucket.Green, MapColor.Green); - Inc(Bucket.Blue, MapColor.Blue); - Inc(Bucket.Count); - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.AddPointsToBucketsAngle(const points: TPointsArray); -var - i: integer; - px, py: double; - Bucket: PBucket; - MapColor: PColorMapColor; -begin - for i := SUB_BATCH_SIZE - 1 downto 0 do begin -// if FStop then Exit; - - px := points[i].x * cosa + points[i].y * sina + rcX; - if (px < 0) or (px > camW) then continue; - py := points[i].y * cosa - points[i].x * sina + rcY; - if (py < 0) or (py > camH) then continue; - - Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth]; - MapColor := @ColorMap[Round(points[i].c * 255)]; - - Inc(Bucket.Red, MapColor.Red); - Inc(Bucket.Green, MapColor.Green); - Inc(Bucket.Blue, MapColor.Blue); - Inc(Bucket.Count); - end; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.SetPixels; -var - i: integer; - nsamples: Int64; - nrbatches: Integer; - points: TPointsArray; - AddPointsProc: procedure (const points: TPointsArray) of object; -begin - if FCP.FAngle = 0 then - AddPointsProc := AddPointsToBuckets - else - AddPointsProc := AddPointsToBucketsAngle; - - SetLength(Points, SUB_BATCH_SIZE); - - nsamples := Round(sample_density * bucketSize / (oversample * oversample)); - nrbatches := Round(nsamples / (fcp.nbatches * SUB_BATCH_SIZE)); - Randomize; - - for i := 0 to nrbatches do begin - if FStop then - Exit; - - if (i and $F = 0) then - if nrbatches > 0 then - Progress(i / nrbatches) - else - Progress(0); - - // generate points -{ case Compatibility of - 0: fcp.iterate_Old(SUB_BATCH_SIZE, points); - 1: fcp.iterateXYC(SUB_BATCH_SIZE, points); - end; -} - fcp.IterateXYC(SUB_BATCH_SIZE, points); - - AddPointsProc(points) - end; - - Progress(1); + inherited; end; /////////////////////////////////////////////////////////////////////////////// @@ -333,6 +146,7 @@ begin inherited; end; +/////////////////////////////////////////////////////////////////////////////// procedure TRendererMM64_MT.Pause(paused: boolean); var i: integer; @@ -347,14 +161,6 @@ begin end; end; -/////////////////////////////////////////////////////////////////////////////// -constructor TRendererMM64_MT.Create; -begin - inherited Create; - - FImageMaker := TImageMaker.Create; -end; - /////////////////////////////////////////////////////////////////////////////// procedure TRendererMM64_MT.Render; const @@ -366,17 +172,17 @@ var begin FStop := False; -// FRotationCenter[0] := fcp.center[0]; -// FRotationCenter[1] := fcp.center[1]; + image_Center_X := fcp.center[0]; + image_Center_Y := fcp.center[1]; image_height := fcp.Height; image_Width := fcp.Width; oversample := fcp.spatial_oversample; // entered memory - imagesize - MaxMemory := FMaxMem * 1024 * 1024 - 4 * image_height * image_width; + MaxMemory := FMaxMem * 1024 * 1024 - 4 * image_height * int64(image_width); - ApproxMemory := 32 * oversample * oversample * image_height * image_width; + ApproxMemory := 32 * oversample * oversample * image_height * int64(image_width); if (MaxMemory < 0) then Exit; @@ -444,93 +250,6 @@ begin Result := NrSlices; end; -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.SaveImage(const FileName: String); -begin - FImageMaker.SaveImage(FileName); -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.SetNrOfTreads(const Value: integer); -begin - FNrOfTreads := Value; -end; - -/////////////////////////////////////////////////////////////////////////////// -procedure TRendererMM64_MT.SetPixelsMT; -var - i: integer; - nsamples: Int64; - bc : integer; -begin - nsamples := Round(sample_density * bucketSize / (oversample * oversample)); - FNrBatches := Round(nsamples / (fcp.nbatches * SUB_BATCH_SIZE)); - batchcounter := 0; - Randomize; - - InitializeCriticalSection(CriticalSection); - - SetLength(WorkingThreads, NrOfTreads); - for i := 0 to NrOfTreads - 1 do - WorkingThreads[i] := NewThread; - - for i := 0 to NrOfTreads - 1 do - WorkingThreads[i].Resume; - - bc := 0; - while (Not FStop) and (bc < FNrBatches) do begin - sleep(200); - try - EnterCriticalSection(CriticalSection); - if batchcounter > 0 then - Progress(batchcounter / FNrBatches) - else - Progress(0); - - bc := batchcounter; - finally - LeaveCriticalSection(CriticalSection); - end; - end; - - DeleteCriticalSection(CriticalSection); - Progress(1); -end; - -/////////////////////////////////////////////////////////////////////////////// -function TRendererMM64_MT.NewThread: TBucketFillerThread; -begin - Result := TBucketFillerThread.Create(fcp); - Result.BucketWidth := BucketWidth; - Result.BucketHeight := BucketHeight; - Result.Buckets := @Buckets; -{ - Result.size[0] := size[0]; - Result.size[1] := size[1]; - Result.bounds[0] := Bounds[0]; - Result.bounds[1] := Bounds[1]; - Result.bounds[2] := Bounds[2]; - Result.bounds[3] := Bounds[3]; - Result.RotationCenter[0] := FRotationCenter[0]; - Result.RotationCenter[1] := FRotationCenter[1]; -} - Result.camX0 := camX0; - Result.camY0 := camY0; - Result.camW := camW; - Result.camH := camH; - Result.bws := bws; - Result.bhs := bhs; - Result.cosa := cosa; - Result.sina := sina; - Result.rcX := rcX; - Result.rcY := rcY; - - Result.ColorMap := colorMap; - Result.CriticalSection := CriticalSection; - Result.Nrbatches := FNrBatches; - Result.batchcounter := @batchcounter; -end; - /////////////////////////////////////////////////////////////////////////////// end.