Ignore:
Timestamp:
Nov 26, 2012, 7:38:56 AM (12 years ago)
Author:
chronos
Message:
  • Added: Now PixelFormat for tests where TBitmap is used can be changed.
  • Fixed: Stopping of test of all methods.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UMainForm.pas

    r453 r454  
    99  Graphics, Dialogs, ComCtrls, ExtCtrls, StdCtrls, DateUtils, UPlatform,
    1010  LCLType, IntfGraphics, fpImage, Math, GraphType, Contnrs, LclIntf, Spin,
    11   ActnList, Menus, StdActns, UFastBitmap, UDrawMethod;
     11  ActnList, Menus, StdActns, UFastBitmap, UDrawMethod, typinfo;
    1212
    1313const
     
    1919
    2020  TMainForm = class(TForm)
    21     Action1: TAction;
     21    AShowDrawForm: TAction;
     22    ATestAllMethods: TAction;
     23    ATestOneMethod: TAction;
     24    ATestStop: TAction;
    2225    AExportAsWikiText: TAction;
    2326    ActionList1: TActionList;
     
    2831    CheckBoxDoubleBuffered: TCheckBox;
    2932    CheckBoxEraseBackground: TCheckBox;
     33    ComboBox1: TComboBox;
    3034    FileExit1: TFileExit;
    3135    FloatSpinEdit1: TFloatSpinEdit;
     
    3438    Label3: TLabel;
    3539    Label4: TLabel;
     40    Label5: TLabel;
    3641    ListViewMethods: TListView;
    3742    MainMenu1: TMainMenu;
     
    4045    MenuItem2: TMenuItem;
    4146    MenuItem3: TMenuItem;
     47    MenuItem4: TMenuItem;
     48    MenuItem8: TMenuItem;
     49    MenuItemTest: TMenuItem;
     50    MenuItem5: TMenuItem;
     51    MenuItem6: TMenuItem;
     52    MenuItem7: TMenuItem;
    4253    PageControl1: TPageControl;
    4354    Panel1: TPanel;
     
    5263    TimerUpdateList: TTimer;
    5364    procedure AExportAsWikiTextExecute(Sender: TObject);
    54     procedure ButtonBenchmarkClick(Sender: TObject);
    55     procedure ButtonSingleTestClick(Sender: TObject);
    56     procedure ButtonStopClick(Sender: TObject);
     65    procedure AShowDrawFormExecute(Sender: TObject);
     66    procedure ATestAllMethodsExecute(Sender: TObject);
     67    procedure ATestOneMethodExecute(Sender: TObject);
     68    procedure ATestStopExecute(Sender: TObject);
    5769    procedure CheckBox1Change(Sender: TObject);
    5870    procedure CheckBoxDoubleBufferedChange(Sender: TObject);
    5971    procedure CheckBoxEraseBackgroundChange(Sender: TObject);
     72    procedure ComboBox1Change(Sender: TObject);
    6073    procedure FormCreate(Sender: TObject);
    6174    procedure FormDestroy(Sender: TObject);
     
    8194  public
    8295    FrameSize: TPoint;
     96    PixelFormat: TPixelFormat;
    8397    DrawMethods: TObjectList; // TObjectList<TDrawMethod>
    8498    Scenes: TObjectList; // TObjectList<TFastBitmap>
     
    114128  NewDrawMethod: TDrawMethod;
    115129  I: Integer;
     130  PF: TPixelFormat;
    116131begin
    117132  Scenes := TObjectList.Create;
     
    126141  end;
    127142
     143  for PF := Low(TPixelFormat) to High(TPixelFormat) do
     144    ComboBox1.Items.Add(GetEnumName(TypeInfo(TPixelFormat), Integer(PF)));
     145
    128146  PageControl1.TabIndex := 0;
    129147end;
     
    135153begin
    136154  with Method do begin
    137     Init(DrawForm, FrameSize);
    138     TestTerminated := False;
     155    Init(DrawForm, FrameSize, PixelFormat);
    139156    //Application.ProcessMessages;
    140157    StartTime := NowPrecise;
     
    154171    //FPS := GetFPS;
    155172    Done;
    156   end;
    157 end;
    158 
    159 procedure TMainForm.ButtonSingleTestClick(Sender: TObject);
    160 begin
    161   if Assigned(ListViewMethods.Selected) then
    162   try
    163     SingleTestActive := True;
    164     UpdateInterface;
    165     TimerUpdateList.Enabled := True;
    166     MethodIndex := ListViewMethods.Selected.Index;
    167     TestTimeout := -1;
    168     if MethodIndex >= 0 then
    169       TestMethod(TDrawMethod(DrawMethods[MethodIndex]));
    170   finally
    171     //TimerUpdateList.Enabled := False;
    172     SingleTestActive := False;
    173     UpdateInterface;
    174   end;
    175 end;
    176 
    177 procedure TMainForm.ButtonBenchmarkClick(Sender: TObject);
    178 var
    179   I: Integer;
    180 begin
    181   try
    182     AllTestActive := True;
    183     UpdateInterface;
    184     TimerUpdateList.Enabled := True;
    185     TestTerminated := False;
    186     TestTimeout := FloatSpinEdit1.Value;
    187     with ListViewMethods, Items do
    188     for I := 0 to DrawMethods.Count - 1 do
    189     with TDrawMethod(DrawMethods[I]) do begin
    190       TestMethod(TDrawMethod(DrawMethods[I]));
    191     end;
    192   finally
    193     TimerUpdateList.Enabled := False;
    194     AllTestActive := False;
    195     UpdateInterface;
    196173  end;
    197174end;
     
    225202end;
    226203
    227 procedure TMainForm.ButtonStopClick(Sender: TObject);
     204procedure TMainForm.AShowDrawFormExecute(Sender: TObject);
     205begin
     206  DrawForm.Show;
     207end;
     208
     209procedure TMainForm.ATestAllMethodsExecute(Sender: TObject);
     210var
     211  I: Integer;
     212begin
     213  try
     214    AllTestActive := True;
     215    UpdateInterface;
     216    TimerUpdateList.Enabled := True;
     217    TestTerminated := False;
     218    TestTimeout := FloatSpinEdit1.Value;
     219    with ListViewMethods, Items do
     220    for I := 0 to DrawMethods.Count - 1 do
     221    with TDrawMethod(DrawMethods[I]) do begin
     222      TestMethod(TDrawMethod(DrawMethods[I]));
     223      if TestTerminated then Break;
     224    end;
     225  finally
     226    TimerUpdateList.Enabled := False;
     227    AllTestActive := False;
     228    UpdateInterface;
     229  end;
     230end;
     231
     232procedure TMainForm.ATestOneMethodExecute(Sender: TObject);
     233begin
     234  if Assigned(ListViewMethods.Selected) then
     235  try
     236    SingleTestActive := True;
     237    UpdateInterface;
     238    TimerUpdateList.Enabled := True;
     239    TestTerminated := False;
     240    MethodIndex := ListViewMethods.Selected.Index;
     241    TestTimeout := -1;
     242    if MethodIndex >= 0 then
     243      TestMethod(TDrawMethod(DrawMethods[MethodIndex]));
     244  finally
     245    //TimerUpdateList.Enabled := False;
     246    SingleTestActive := False;
     247    UpdateInterface;
     248  end;
     249end;
     250
     251procedure TMainForm.ATestStopExecute(Sender: TObject);
    228252begin
    229253  TestTerminated := True;
     
    249273end;
    250274
     275procedure TMainForm.ComboBox1Change(Sender: TObject);
     276begin
     277  PixelFormat := TPixelFormat(ComboBox1.ItemIndex);
     278  UpdateInterface;
     279end;
     280
    251281procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    252282begin
    253   ButtonStopClick(Self);
     283  ATestStop.Execute;
    254284end;
    255285
     
    354384  CheckBoxEraseBackground.Checked := DrawForm.EraseBackgroundEnabled;
    355385  CheckBox1.Checked := csOpaque in DrawForm.ControlStyle;
     386  ComboBox1.ItemIndex := Integer(PixelFormat);
    356387end;
    357388
Note: See TracChangeset for help on using the changeset viewer.