Changeset 454 for GraphicTest
- Timestamp:
- Nov 26, 2012, 7:38:56 AM (12 years ago)
- Location:
- GraphicTest
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/GraphicTest.lpi
r453 r454 223 223 <UseMsgFile Value="True"/> 224 224 </CompilerMessages> 225 <CustomOptions Value="-dopengl"/> 225 <CustomOptions Value="-dopengl 226 -dGR32"/> 226 227 <CompilerPath Value="$(CompPath)"/> 227 228 </Other> -
GraphicTest/Methods/UBGRABitmapPaintBox.pas
r447 r454 7 7 uses 8 8 Classes, SysUtils, UDrawMethod, UFastBitmap, BGRABitmap, BGRABitmapTypes, 9 Controls ;9 Controls, Graphics; 10 10 11 11 type … … 15 15 BGRABitmap: TBGRABitmap; 16 16 procedure Paint(Sender: TObject); override; 17 procedure Init(Parent: TWinControl; Size: TPoint ); override;17 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 18 18 constructor Create; override; 19 19 destructor Destroy; override; … … 32 32 end; 33 33 34 procedure TBGRABitmapPaintBox.Init(Parent: TWinControl; Size: TPoint );34 procedure TBGRABitmapPaintBox.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 35 35 begin 36 inherited Init(Parent, Size);36 inherited; 37 37 BGRABitmap.SetSize(PaintBox.Width, PaintBox.Height); 38 38 end; -
GraphicTest/Methods/UCanvasPixels.pas
r447 r454 25 25 inherited; 26 26 Caption := 'TBitmap.Canvas.Pixels'; 27 Description.Add('This is simple naive approach to copy image by accessing Pixels property. ' + 28 'Method is slow because of much of overhead in access methods like multiple nested method calls, ' + 29 'pixel format conversion, update notification, etc.'); 27 30 end; 28 31 -
GraphicTest/Methods/UCanvasPixelsUpdateLock.pas
r447 r454 25 25 inherited; 26 26 Caption := 'TBitmap.Canvas.Pixels Update locking'; 27 Description.Add('This method improves basic canvas pixel access by eliminating ' + 28 'updating of visible area during complete operation. Image data is ' + 29 'painted only one at the end of complete operation'); 27 30 end; 28 31 -
GraphicTest/Methods/UDummyMethod.pas
r447 r454 25 25 inherited Create; 26 26 Caption := 'Dummy'; 27 Description.Add('This method doesn''t draw anything. It''s purpose is to measure ' + 28 'and compare speed of system and event handling.'); 27 29 end; 28 30 -
GraphicTest/Methods/UGraphics32Method.pas
r450 r454 6 6 7 7 uses 8 Classes, SysUtils, UFastBitmap, UDrawMethod, GR32, GR32_Image, Controls; 8 Classes, SysUtils, UFastBitmap, UDrawMethod, GR32, GR32_Image, Controls, 9 Graphics; 9 10 10 11 type … … 16 17 destructor Destroy; override; 17 18 procedure DrawFrame(FastBitmap: TFastBitmap); override; 18 procedure Init(Parent: TWinControl; Size: TPoint ); override;19 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 19 20 procedure Done; override; 20 21 end; … … 29 30 inherited Create; 30 31 Caption := 'TGR32Image'; 32 Description.Add('Graphics32 is well implemented highly optimized Delphi graphic ' + 33 'library also ported to Lazarus/LCL. It uses static 32-bit wide pixel:'); 34 Description.Add('TColor32Entry = packed record'); 35 Description.Add(' case Integer of'); 36 Description.Add(' 0: (B, G, R, A: Byte);'); 37 Description.Add(' 1: (ARGB: TColor32);'); 38 Description.Add(' 2: (Planes: array[0..3] of Byte);'); 39 Description.Add(' 3: (Components: array[TColor32Component] of Byte);'); 40 Description.Add('end;'); 31 41 end; 32 42 … … 66 76 end; 67 77 68 procedure TGraphics32Method.Init(Parent: TWinControl; Size: TPoint );78 procedure TGraphics32Method.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 69 79 begin 70 inherited Init(Parent, Size);80 inherited; 71 81 Image := TImage32.Create(Parent); 72 82 Image.Parent := Parent; -
GraphicTest/Methods/ULazIntfImageColorsNoCopy.pas
r447 r454 13 13 TLazIntfImageColorsNoCopy = class(TDrawMethodImage) 14 14 TempIntfImage: TLazIntfImage; 15 procedure Init(Parent: TWinControl; Size: TPoint ); override;15 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 16 16 constructor Create; override; 17 17 destructor Destroy; override; … … 24 24 { TLazIntfImageColorsNoCopy } 25 25 26 procedure TLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint );26 procedure TLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 27 27 begin 28 inherited Init(Parent, Size);28 inherited; 29 29 TempIntfImage.Free; 30 30 TempIntfImage := Image.Picture.Bitmap.CreateIntfImage; -
GraphicTest/Methods/UOpenGLPBOMethod.pas
r452 r454 6 6 7 7 uses 8 Classes, SysUtils, UDrawMethod, UFastBitmap, Controls 8 Classes, SysUtils, UDrawMethod, UFastBitmap, Controls, Graphics 9 9 {$IFDEF opengl}, GL, GLExt, OpenGLContext{$ENDIF}; 10 10 … … 16 16 pboIds: array[0..1] of GLuint; 17 17 Index, NextIndex: Integer; 18 procedure Init(AParent: TWinControl; Size: TPoint ); override;18 procedure Init(AParent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 19 19 constructor Create; override; 20 20 destructor Destroy; override; … … 31 31 //procedure glGenBuffersARB2 : procedure(n : GLsizei; buffers : PGLuint); extdecl; 32 32 33 procedure TOpenGLPBOMethod.Init(AParent: TWinControl; Size: TPoint );33 procedure TOpenGLPBOMethod.Init(AParent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 34 34 var 35 35 DataSize: Integer; -
GraphicTest/UDrawMethod.pas
r453 r454 33 33 function GetFPS: Real; 34 34 property FPS: Real read FFPS write FFPS; 35 procedure Init(Parent: TWinControl; Size: TPoint ); virtual;35 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); virtual; 36 36 procedure Done; virtual; 37 37 constructor Create; virtual; … … 48 48 TDrawMethodImage = class(TDrawMethod) 49 49 Image: TImage; 50 procedure Init(Parent: TWinControl; Size: TPoint ); override;50 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 51 51 procedure Done; override; 52 52 end; … … 57 57 PaintBox: TPaintBox; 58 58 procedure Paint(Sender: TObject); virtual; 59 procedure Init(Parent: TWinControl; Size: TPoint ); override;59 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 60 60 procedure Done; override; 61 61 end; … … 71 71 procedure InitGL; 72 72 procedure OpenGLControlResize(Sender: TObject); 73 procedure Init(AParent: TWinControl; Size: TPoint ); override;73 procedure Init(AParent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override; 74 74 procedure Done; override; 75 75 end; … … 88 88 end; 89 89 90 procedure TDrawMethodPaintBox.Init(Parent: TWinControl; Size: TPoint );91 begin 92 inherited Init(Parent, Size);90 procedure TDrawMethodPaintBox.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 91 begin 92 inherited; 93 93 PaintBox := TPaintBox.Create(Parent); 94 94 PaintBox.Parent := Parent; … … 106 106 { TDrawMethodImage } 107 107 108 procedure TDrawMethodImage.Init(Parent: TWinControl; Size: TPoint );109 begin 110 inherited Init(Parent, Size);108 procedure TDrawMethodImage.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 109 begin 110 inherited; 111 111 Image := TImage.Create(Parent); 112 112 Image.Parent := Parent; 113 113 Image.SetBounds(0, 0, Size.X, Size.Y); 114 114 Image.Picture.Bitmap.SetSize(Size.X, Size.Y); 115 Image.Picture.Bitmap.PixelFormat := pf24bit;115 Image.Picture.Bitmap.PixelFormat := PixelFormat; 116 116 Image.Show; 117 117 end; … … 128 128 { TDrawMethodOpenGL } 129 129 130 procedure TDrawMethodOpenGL.Init(AParent: TWinControl; Size: TPoint );131 begin 132 inherited Init(aParent, Size);130 procedure TDrawMethodOpenGL.Init(AParent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 131 begin 132 inherited; 133 133 OpenGLControl := TOpenGLControl.Create(AParent); 134 134 with OpenGLControl do begin … … 193 193 end; 194 194 195 procedure TDrawMethod.Init(Parent: TWinControl; Size: TPoint );195 procedure TDrawMethod.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); 196 196 begin 197 197 if (TempBitmap.Width <> Size.X) or (TempBitmap.Height <> Size.Y) then -
GraphicTest/UMainForm.lfm
r453 r454 1 1 object MainForm: TMainForm 2 Left = 1652 Left = 258 3 3 Height = 444 4 Top = 1 174 Top = 176 5 5 Width = 857 6 6 Caption = 'Graphic test' … … 24 24 object TabSheet1: TTabSheet 25 25 Caption = 'Description' 26 ClientHeight = 3 8826 ClientHeight = 399 27 27 ClientWidth = 390 28 28 object Memo1: TMemo 29 29 Left = 0 30 Height = 3 8830 Height = 399 31 31 Top = 0 32 32 Width = 390 … … 534 534 TabOrder = 1 535 535 object ListViewMethods: TListView 536 Left = 9537 Height = 3 49538 Top = 8539 Width = 44 3536 Left = 4 537 Height = 324 538 Top = 4 539 Width = 448 540 540 Anchors = [akTop, akLeft, akRight, akBottom] 541 541 Columns = < … … 579 579 Left = 8 580 580 Height = 25 581 Top = 3 64581 Top = 336 582 582 Width = 115 583 Anchors = [akLeft, akBottom] 584 Caption = 'Test one method' 585 OnClick = ButtonSingleTestClick 583 Action = ATestOneMethod 584 Anchors = [akLeft, akBottom] 586 585 TabOrder = 1 587 586 end … … 589 588 Left = 136 590 589 Height = 25 591 Top = 3 64590 Top = 336 592 591 Width = 112 593 Anchors = [akLeft, akBottom] 594 Caption = 'Test all methods' 595 OnClick = ButtonBenchmarkClick 592 Action = ATestAllMethods 593 Anchors = [akLeft, akBottom] 596 594 TabOrder = 2 597 595 end 598 596 object FloatSpinEdit1: TFloatSpinEdit 599 597 Left = 88 600 Height = 2 3601 Top = 3 94598 Height = 21 599 Top = 368 602 600 Width = 58 603 601 Anchors = [akLeft, akBottom] … … 611 609 Left = 256 612 610 Height = 25 613 Top = 3 64611 Top = 336 614 612 Width = 75 615 Anchors = [akLeft, akBottom] 616 Caption = 'Stop' 617 OnClick = ButtonStopClick 613 Action = ATestStop 614 Anchors = [akLeft, akBottom] 618 615 TabOrder = 4 619 616 end 620 617 object Label1: TLabel 621 618 Left = 8 622 Height = 1 5623 Top = 3 98624 Width = 78619 Height = 13 620 Top = 372 621 Width = 69 625 622 Anchors = [akLeft, akBottom] 626 623 Caption = 'Step duration:' … … 629 626 object Label2: TLabel 630 627 Left = 152 631 Height = 1 5632 Top = 3 98628 Height = 13 629 Top = 372 633 630 Width = 5 634 631 Anchors = [akLeft, akBottom] … … 638 635 object SpinEditWidth: TSpinEdit 639 636 Left = 204 640 Height = 2 3641 Top = 3 94637 Height = 21 638 Top = 368 642 639 Width = 58 643 640 Anchors = [akLeft, akBottom] … … 649 646 object SpinEditHeight: TSpinEdit 650 647 Left = 273 651 Height = 2 3652 Top = 3 94648 Height = 21 649 Top = 368 653 650 Width = 58 654 651 Anchors = [akLeft, akBottom] … … 660 657 object Label3: TLabel 661 658 Left = 169 662 Height = 1 5663 Top = 3 99664 Width = 2 5659 Height = 13 660 Top = 373 661 Width = 23 665 662 Anchors = [akLeft, akBottom] 666 663 Caption = 'Size:' … … 669 666 object Label4: TLabel 670 667 Left = 265 671 Height = 1 5672 Top = 3 98668 Height = 13 669 Top = 372 673 670 Width = 6 674 671 Anchors = [akLeft, akBottom] … … 678 675 object CheckBoxDoubleBuffered: TCheckBox 679 676 Left = 336 680 Height = 24681 Top = 3 57682 Width = 118677 Height = 17 678 Top = 336 679 Width = 98 683 680 Anchors = [akLeft, akBottom] 684 681 Caption = 'Double buffered' … … 688 685 object CheckBoxEraseBackground: TCheckBox 689 686 Left = 336 690 Height = 24691 Top = 3 74692 Width = 1 24687 Height = 17 688 Top = 353 689 Width = 106 693 690 Anchors = [akLeft, akBottom] 694 691 Caption = 'Erase background' … … 698 695 object CheckBox1: TCheckBox 699 696 Left = 336 700 Height = 24701 Top = 3 94702 Width = 69697 Height = 17 698 Top = 369 699 Width = 58 703 700 Anchors = [akLeft, akBottom] 704 701 Caption = 'Opaque' 705 702 OnChange = CheckBox1Change 706 703 TabOrder = 9 704 end 705 object Label5: TLabel 706 Left = 8 707 Height = 13 708 Top = 399 709 Width = 61 710 Anchors = [akLeft, akBottom] 711 Caption = 'Pixel format:' 712 ParentColor = False 713 end 714 object ComboBox1: TComboBox 715 Left = 89 716 Height = 21 717 Top = 394 718 Width = 100 719 Anchors = [akLeft, akBottom] 720 ItemHeight = 13 721 OnChange = ComboBox1Change 722 Style = csDropDownList 723 TabOrder = 10 707 724 end 708 725 end … … 747 764 OnExecute = AExportAsWikiTextExecute 748 765 end 749 object Action1: TAction 750 Caption = 'Action1' 766 object ATestOneMethod: TAction 767 Caption = 'Test one method' 768 OnExecute = ATestOneMethodExecute 769 ShortCut = 113 751 770 end 752 771 object FileExit1: TFileExit … … 755 774 Hint = 'Exit' 756 775 ShortCut = 32883 776 end 777 object ATestStop: TAction 778 Caption = 'Stop' 779 Hint = 'Stop' 780 OnExecute = ATestStopExecute 781 ShortCut = 114 782 end 783 object ATestAllMethods: TAction 784 Caption = 'Test all methods' 785 Hint = 'Test all methods' 786 OnExecute = ATestAllMethodsExecute 787 ShortCut = 114 788 end 789 object AShowDrawForm: TAction 790 Caption = 'Draw form' 791 OnExecute = AShowDrawFormExecute 757 792 end 758 793 end … … 769 804 end 770 805 end 806 object MenuItemTest: TMenuItem 807 Caption = 'Test' 808 object MenuItem5: TMenuItem 809 Action = ATestOneMethod 810 end 811 object MenuItem6: TMenuItem 812 Action = ATestAllMethods 813 end 814 object MenuItem7: TMenuItem 815 Action = ATestStop 816 end 817 end 818 object MenuItem4: TMenuItem 819 Caption = 'View' 820 object MenuItem8: TMenuItem 821 Action = AShowDrawForm 822 end 823 end 771 824 end 772 825 object SaveDialog1: TSaveDialog -
GraphicTest/UMainForm.pas
r453 r454 9 9 Graphics, Dialogs, ComCtrls, ExtCtrls, StdCtrls, DateUtils, UPlatform, 10 10 LCLType, IntfGraphics, fpImage, Math, GraphType, Contnrs, LclIntf, Spin, 11 ActnList, Menus, StdActns, UFastBitmap, UDrawMethod ;11 ActnList, Menus, StdActns, UFastBitmap, UDrawMethod, typinfo; 12 12 13 13 const … … 19 19 20 20 TMainForm = class(TForm) 21 Action1: TAction; 21 AShowDrawForm: TAction; 22 ATestAllMethods: TAction; 23 ATestOneMethod: TAction; 24 ATestStop: TAction; 22 25 AExportAsWikiText: TAction; 23 26 ActionList1: TActionList; … … 28 31 CheckBoxDoubleBuffered: TCheckBox; 29 32 CheckBoxEraseBackground: TCheckBox; 33 ComboBox1: TComboBox; 30 34 FileExit1: TFileExit; 31 35 FloatSpinEdit1: TFloatSpinEdit; … … 34 38 Label3: TLabel; 35 39 Label4: TLabel; 40 Label5: TLabel; 36 41 ListViewMethods: TListView; 37 42 MainMenu1: TMainMenu; … … 40 45 MenuItem2: TMenuItem; 41 46 MenuItem3: TMenuItem; 47 MenuItem4: TMenuItem; 48 MenuItem8: TMenuItem; 49 MenuItemTest: TMenuItem; 50 MenuItem5: TMenuItem; 51 MenuItem6: TMenuItem; 52 MenuItem7: TMenuItem; 42 53 PageControl1: TPageControl; 43 54 Panel1: TPanel; … … 52 63 TimerUpdateList: TTimer; 53 64 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); 57 69 procedure CheckBox1Change(Sender: TObject); 58 70 procedure CheckBoxDoubleBufferedChange(Sender: TObject); 59 71 procedure CheckBoxEraseBackgroundChange(Sender: TObject); 72 procedure ComboBox1Change(Sender: TObject); 60 73 procedure FormCreate(Sender: TObject); 61 74 procedure FormDestroy(Sender: TObject); … … 81 94 public 82 95 FrameSize: TPoint; 96 PixelFormat: TPixelFormat; 83 97 DrawMethods: TObjectList; // TObjectList<TDrawMethod> 84 98 Scenes: TObjectList; // TObjectList<TFastBitmap> … … 114 128 NewDrawMethod: TDrawMethod; 115 129 I: Integer; 130 PF: TPixelFormat; 116 131 begin 117 132 Scenes := TObjectList.Create; … … 126 141 end; 127 142 143 for PF := Low(TPixelFormat) to High(TPixelFormat) do 144 ComboBox1.Items.Add(GetEnumName(TypeInfo(TPixelFormat), Integer(PF))); 145 128 146 PageControl1.TabIndex := 0; 129 147 end; … … 135 153 begin 136 154 with Method do begin 137 Init(DrawForm, FrameSize); 138 TestTerminated := False; 155 Init(DrawForm, FrameSize, PixelFormat); 139 156 //Application.ProcessMessages; 140 157 StartTime := NowPrecise; … … 154 171 //FPS := GetFPS; 155 172 Done; 156 end;157 end;158 159 procedure TMainForm.ButtonSingleTestClick(Sender: TObject);160 begin161 if Assigned(ListViewMethods.Selected) then162 try163 SingleTestActive := True;164 UpdateInterface;165 TimerUpdateList.Enabled := True;166 MethodIndex := ListViewMethods.Selected.Index;167 TestTimeout := -1;168 if MethodIndex >= 0 then169 TestMethod(TDrawMethod(DrawMethods[MethodIndex]));170 finally171 //TimerUpdateList.Enabled := False;172 SingleTestActive := False;173 UpdateInterface;174 end;175 end;176 177 procedure TMainForm.ButtonBenchmarkClick(Sender: TObject);178 var179 I: Integer;180 begin181 try182 AllTestActive := True;183 UpdateInterface;184 TimerUpdateList.Enabled := True;185 TestTerminated := False;186 TestTimeout := FloatSpinEdit1.Value;187 with ListViewMethods, Items do188 for I := 0 to DrawMethods.Count - 1 do189 with TDrawMethod(DrawMethods[I]) do begin190 TestMethod(TDrawMethod(DrawMethods[I]));191 end;192 finally193 TimerUpdateList.Enabled := False;194 AllTestActive := False;195 UpdateInterface;196 173 end; 197 174 end; … … 225 202 end; 226 203 227 procedure TMainForm.ButtonStopClick(Sender: TObject); 204 procedure TMainForm.AShowDrawFormExecute(Sender: TObject); 205 begin 206 DrawForm.Show; 207 end; 208 209 procedure TMainForm.ATestAllMethodsExecute(Sender: TObject); 210 var 211 I: Integer; 212 begin 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; 230 end; 231 232 procedure TMainForm.ATestOneMethodExecute(Sender: TObject); 233 begin 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; 249 end; 250 251 procedure TMainForm.ATestStopExecute(Sender: TObject); 228 252 begin 229 253 TestTerminated := True; … … 249 273 end; 250 274 275 procedure TMainForm.ComboBox1Change(Sender: TObject); 276 begin 277 PixelFormat := TPixelFormat(ComboBox1.ItemIndex); 278 UpdateInterface; 279 end; 280 251 281 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 252 282 begin 253 ButtonStopClick(Self);283 ATestStop.Execute; 254 284 end; 255 285 … … 354 384 CheckBoxEraseBackground.Checked := DrawForm.EraseBackgroundEnabled; 355 385 CheckBox1.Checked := csOpaque in DrawForm.ControlStyle; 386 ComboBox1.ItemIndex := Integer(PixelFormat); 356 387 end; 357 388
Note:
See TracChangeset
for help on using the changeset viewer.