renderthread bugfixes

This commit is contained in:
zueuk 2006-09-06 12:36:16 +00:00
parent 0d6de238b2
commit f3662ecc7e
2 changed files with 124 additions and 61 deletions

View File

@ -1,5 +1,6 @@
{
Apophysis Copyright (C) 2001-2004 Mark Townsend
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
@ -41,6 +42,7 @@ type
procedure TimelimiterOnTimer(Sender: TObject);
procedure RenderStopClick(Sender: TObject);
procedure RenderMoreClick(Sender: TObject);
private
Remainder, StartTime, t: double;
imgLeft, imgTop,
@ -57,11 +59,14 @@ type
message WM_THREAD_COMPLETE;
procedure HandleThreadTermination(var Message: TMessage);
message WM_THREAD_TERMINATE;
public
Calculate : boolean;
cp: TControlPoint;
Zoom: double;
center: array[0..1] of double;
ActiveForm: TForm;
end;
var
@ -69,10 +74,23 @@ var
implementation
uses Main, Math, Global;
uses
Main, Math, Global,
Tracer;
{$R *.DFM}
procedure Trace1(const str: string);
begin
if TraceLevel >= 1 then
TraceForm.FullscreenTrace.Lines.Add('. ' + str);
end;
procedure Trace2(const str: string);
begin
if TraceLevel >= 2 then
TraceForm.FullscreenTrace.Lines.Add('. . ' + str);
end;
procedure TFullscreenForm.DrawFlame;
var
@ -104,6 +122,7 @@ begin
Remainder := 1;
if Assigned(Renderer) then begin // hmm...
Trace2('Killing previous RenderThread #' + inttostr(Renderer.ThreadID));
Renderer.Terminate;
Renderer.WaitFor;
@ -117,6 +136,7 @@ begin
Renderer.TargetHandle := Handle;
Renderer.OnProgress := OnProgress;
Renderer.NrThreads := NrTreads;
if TraceLevel > 0 then Renderer.Output := TraceForm.FullscreenTrace.Lines;
Renderer.SetCP(cp);
if FullscreenTimeLimit > 0 then begin
@ -135,18 +155,25 @@ procedure TFullscreenForm.HandleThreadCompletion(var Message: TMessage);
var
bm: TBitmap;
begin
Trace2(MsgComplete + IntToStr(message.LParam));
if not Assigned(Renderer) then begin
Trace2(MsgNotAssigned);
exit;
end;
if Renderer.ThreadID <> message.LParam then begin
Trace2(MsgAnotherRunning);
exit;
end;
if Assigned(Renderer) then
begin
bm := TBitmap.Create;
bm.assign(Renderer.GetImage);
Image.SetBounds(imgLeft, imgTop, imgWidth, imgHeight);
Image.Picture.Graphic := bm;
// Canvas.StretchDraw(Rect(0, 0, ClientWidth, ClientHeight), bm);
//Renderer.Free;
//Renderer := nil;
bm.Free;
end;
RenderStop.Enabled := false;
RenderMore.Enabled := true;
@ -157,6 +184,16 @@ procedure TFullscreenForm.HandleThreadTermination(var Message: TMessage);
var
bm: TBitmap;
begin
Trace2(MsgTerminated + IntToStr(message.LParam));
if not Assigned(Renderer) then begin
Trace2(MsgNotAssigned);
exit;
end;
if Renderer.ThreadID <> message.LParam then begin
Trace2(MsgAnotherRunning);
exit;
end;
RenderStop.Enabled := false;
RenderMore.Enabled := false;
@ -202,6 +239,8 @@ end;
procedure TFullscreenForm.FormShow(Sender: TObject);
begin
Trace1('--- Opening Fullscreen View ---');
if Image.Width < ClientWidth then
Image.Left := (ClientWidth - Image.Width) div 2;
if Image.Height < ClientHeight then
@ -229,13 +268,19 @@ begin
Renderer.WaitForMore := false;
Renderer.Resume;
end;
Trace2('Form closing: killing RenderThread #' + inttostr(Renderer.ThreadID));
Renderer.Terminate;
Renderer.WaitFor;
Trace2('Destroying RenderThread #' + IntToStr(Renderer.ThreadID));
Renderer.Free;
Renderer := nil;
end;
Trace1('--- Closing Fullscreen View ---');
Trace1('');
ShowTaskbar;
ActiveForm.SetFocus;
end;
procedure TFullscreenForm.FormCreate(Sender: TObject);
@ -275,7 +320,7 @@ end;
procedure TFullscreenForm.RenderStopClick(Sender: TObject);
begin
if assigned(Renderer) then Renderer.Break;
if assigned(Renderer) then Renderer.BreakRender;
end;
procedure TFullscreenForm.RenderMoreClick(Sender: TObject);

View File

@ -290,6 +290,22 @@ object MainForm: TMainForm
Style = tbsCheck
OnClick = tbRotateClick
end
object ToolButton2: TToolButton
Left = 571
Top = 0
Width = 8
Caption = 'ToolButton2'
ImageIndex = 39
Style = tbsSeparator
end
object tbShowTrace: TToolButton
Left = 579
Top = 0
Hint = 'Show trace window'
Caption = 'tbShowTrace'
ImageIndex = 38
OnClick = tbShowTraceClick
end
end
object ListView: TListView
Left = 0
@ -327,8 +343,10 @@ object MainForm: TMainForm
Width = 555
Height = 433
Align = alClient
AutoSize = True
Anchors = []
Center = True
PopupMenu = DisplayPopup
Proportional = True
OnDblClick = ImageDblClick
OnMouseDown = ImageMouseDown
OnMouseMove = ImageMouseMove
@ -355,7 +373,7 @@ object MainForm: TMainForm
Left = 8
Top = 56
Bitmap = {
494C010135003600040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
494C010135003600040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
000000000000360000002800000040000000E0000000010020000000000000E0
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000292B2F00000000002F3236000000
@ -889,105 +907,105 @@ object MainForm: TMainForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000A0A0A000A0A0A00000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFF0E700FFEA
A000A0A0A000A0A0A0000000000000000000CC66000066666600666666006666
6600666666006666660066666600666666006666660066666600666666006666
6600666666009999990000000000000000000000000000000000FFF0E700FFEA
DD00FFE9DC00FFEBDF00FFEDE300FFEFE500FDEFE70000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000A0A0A000A0A0A000000000000000000000000000000000007B7B7B00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000FEEBE000FFE4
A000A0A0A000A0A0A0000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000006666660000000000000000000000000000000000FEEBE000FFE4
D200FFE2D100FFE4D400FFE6D700FFE8DA00FCE6DA0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
FF00A0A0A000A0A0A0000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF0000000000000000000000000000000000FEE7D900FFDD
0000000000006666660000000000000000000000000000000000FEE7D900FFDD
C800FFDBC600FFDDC900FFDFCC00FFE0D000FCDFD00000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFE4D300FFD6
FF00A0A0A000A0A0A0000000000000000000CC6600000000000000FF00000000
000000FF000000FF00000000000000FF00000000000000000000000000000000
0000000000006666660000000000000000000000000000000000FFE4D300FFD6
BE00FFD4BB00FFD6BE00FFDEC700FFE3CE00FCE2D00000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDFCD00FFD0
FF00A0A0A000A0A0A0000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000006666660000000000000000000000000000000000FFDFCD00FFD0
B500FFCDAF00FFD0B400F2CCB400EFD3C200ECD5C70000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDBC700FFCA
FF00A0A0A000A0A0A0000000000000000000CC6600000000000000FF000000FF
00000000000000FF000000FF000000FF00000000000000FF0000000000000000
0000000000006666660000000000000000000000000000000000FFDBC700FFCA
AB00FFC7A500FFD4B20000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDAC500FFCB
A000FFFFFF00FFFFFF000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000006666660000000000000000000000000000000000FFDAC500FFCB
AC00FFC6A500FFD3B20000000000F5A779000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FDE2D300FEDC
A000FFFFFF00FFFFFF000000000000000000CC6600000000000000FF00000000
000000FF000000FF00000000000000FF000000FF000000000000000000000000
0000000000006666660000000000000000000000000000000000FDE2D300FEDC
C600FED9C300FEE3CD003D2F2800000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000000000000000
A000FFFFFF00FFFFFF000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000006666660000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000000000000000
A000FFFFFF00FFFFFF000000000000000000CC66000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000006666660000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
FF00FFFFFF00FFFFFF000000000000000000CC660000CC660000CC660000CC66
0000CC660000CC660000CC660000CC660000CC660000CC660000CC660000CC66
0000CC660000CC66000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000707A81002D3134002D31
34000B0C0D002D3134002D3134004F565B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B007B7B
7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B
7B007B7B7B007B7B7B0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
FF00FFFFFF00FFFFFF000000000000000000CC66000000000000FFCC9900FFCC
9900FFCC9900FFCC9900FFCC9900FFCC9900FFCC9900FFCC9900FFCC99000000
0000CC6600000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000CC660000CC660000CC660000CC66
0000CC660000CC660000CC660000CC660000CC660000CC660000CC660000CC66
0000CC660000CC660000CC660000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -2167,11 +2185,11 @@ object MainForm: TMainForm
FFE7F81F803FE7FFE000F3CF803FE1FFE000EFEF803FE07FE3E7CFFF800FE01F
E5E7DFFF8007E007E6E7DFFF8003E003E767DFFF8001E007E7A7DFC38040E01F
E7C7CFE380E0E07F0007EFE381E0E1FF0007F39BFFF0E7FFE7FBF83FFFF8FFFF
E7FDFFFFFFFCFFFFE7FFFFFFFFFEFFFFFFFFFFFFFFFF803FFFFF8001FFFF803F
FFFF8001FFFF803FE0078001C003803FE0078001CFFB803FE0078001C00B803F
E0078001C00B803FE0078001C00B803FE0078001C00B807FE0078001C00B80FF
E0078001C00B81FFE0078001C00BFFFFE0078001C003FF80FFFF8001C003FFFF
FFFF8001FFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFF001DFFBC000FFFF
E7FDFFFFFFFCFFFFE7FFFFFFFFFEFFFFFFFFFFFFFFFF803FFFFF80010001803F
FFFF80010001803FE00780010001803FE00780010001803FE00780010001803F
E00780010001803FE00780010001803FE00780010001807FE0078001000180FF
E0078001000181FFE00780010001FFFFE00780010001FF80FFFF80014015FFFF
FFFF80010001FFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFF001DFFBC000FFFF
F80187FBC000FE7FFC0103FBC000E667BE0103E1C000E0079F0103C0C000C003
8F0103C0C000C003860187C0C000C0038061EFC0C000C00380F1EFE1C000E007
80F9EFF7C000E007807DF7EFC000E427803FF7EFC000FC3F801FFBDFC000FE7F
@ -2207,7 +2225,8 @@ object MainForm: TMainForm
C003000F80018000C003000780018000C003000380018000C003000180018000
C003000180018000C003001F80018000C003001F80018001C003001F80018001
C0038FF180018001C007FFF980018001C00FFF7580018001C01FFF8F80018001
C03FFFFF80018001FFFFFFFFFFFFFFFF}
C03FFFFF80018001FFFFFFFFFFFFFFFF00000000000000000000000000000000
000000000000}
end
object SmallImages: TImageList
Left = 40
@ -2905,19 +2924,17 @@ object MainForm: TMainForm
object N6: TMenuItem
Caption = '-'
end
object mnuPopCopyUPR: TMenuItem
Caption = 'Copy as UPR'
Hint =
'Copies the IFS in Ultra Fractal paremeter format to the clipboar' +
'd.'
ImageIndex = 23
ShortCut = 16451
OnClick = mnuCopyUPRClick
object mnuPopFullscreen: TMenuItem
Caption = 'Fullscreen View'
Hint = 'Show the flame in fullscreen mode'
ImageIndex = 52
ShortCut = 114
OnClick = mnuFullScreenClick
end
end
object RedrawTimer: TTimer
Enabled = False
Interval = 20
Interval = 50
OnTimer = RedrawTimerTimer
Left = 104
Top = 56
@ -2944,6 +2961,7 @@ object MainForm: TMainForm
Normalize = False
OnStartTag = XMLScannerStartTag
OnEmptyTag = XMLScannerEmptyTag
OnContent = XmlScannerContent
Left = 72
Top = 120
end