Changeset 201 for GraphicTest
- Timestamp:
- Mar 17, 2011, 7:40:35 AM (14 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 1 1 lib 2 2 GraphicTest 3 GraphicTest.exe
-
- Property svn:ignore
-
GraphicTest/GraphicTest.lpi
r200 r201 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count=" 17">41 <Units Count="20"> 42 42 <Unit0> 43 43 <Filename Value="GraphicTest.lpr"/> … … 47 47 <TopLine Value="1"/> 48 48 <CursorPos X="17" Y="3"/> 49 <UsageCount Value="2 6"/>49 <UsageCount Value="28"/> 50 50 </Unit0> 51 51 <Unit1> … … 58 58 <EditorIndex Value="0"/> 59 59 <WindowIndex Value="0"/> 60 <TopLine Value=" 325"/>61 <CursorPos X="7 " Y="335"/>62 <UsageCount Value="2 6"/>60 <TopLine Value="104"/> 61 <CursorPos X="76" Y="111"/> 62 <UsageCount Value="28"/> 63 63 <Loaded Value="True"/> 64 64 <LoadedDesigner Value="True"/> … … 76 76 <IsPartOfProject Value="True"/> 77 77 <UnitName Value="UPlatform"/> 78 <EditorIndex Value=" 13"/>78 <EditorIndex Value="4"/> 79 79 <WindowIndex Value="0"/> 80 80 <TopLine Value="43"/> 81 81 <CursorPos X="1" Y="1"/> 82 <UsageCount Value="2 6"/>82 <UsageCount Value="28"/> 83 83 <Loaded Value="True"/> 84 84 </Unit3> … … 86 86 <Filename Value="../../lazarus/lcl/intfgraphics.pas"/> 87 87 <UnitName Value="IntfGraphics"/> 88 <EditorIndex Value="7"/>89 88 <WindowIndex Value="0"/> 90 89 <TopLine Value="244"/> 91 90 <CursorPos X="49" Y="262"/> 92 91 <UsageCount Value="13"/> 93 <Loaded Value="True"/>94 92 </Unit4> 95 93 <Unit5> 96 94 <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-image/src/fpimage.pp"/> 97 95 <UnitName Value="FPimage"/> 98 <EditorIndex Value="4"/>99 96 <WindowIndex Value="0"/> 100 97 <TopLine Value="121"/> 101 98 <CursorPos X="57" Y="142"/> 102 99 <UsageCount Value="13"/> 103 <Loaded Value="True"/>104 100 </Unit5> 105 101 <Unit6> 106 102 <Filename Value="../../lazarus/lcl/include/lclintfh.inc"/> 107 <EditorIndex Value="9"/>108 103 <WindowIndex Value="0"/> 109 104 <TopLine Value="85"/> 110 105 <CursorPos X="10" Y="102"/> 111 106 <UsageCount Value="13"/> 112 <Loaded Value="True"/>113 107 </Unit6> 114 108 <Unit7> 115 109 <Filename Value="../../lazarus/lcl/include/lclintf.inc"/> 116 <EditorIndex Value="10"/>117 110 <WindowIndex Value="0"/> 118 111 <TopLine Value="153"/> 119 112 <CursorPos X="1" Y="160"/> 120 113 <UsageCount Value="13"/> 121 <Loaded Value="True"/>122 114 </Unit7> 123 115 <Unit8> 124 116 <Filename Value="../../lazarus/lcl/graphics.pp"/> 125 117 <UnitName Value="Graphics"/> 126 <EditorIndex Value="2"/>127 118 <WindowIndex Value="0"/> 128 119 <TopLine Value="1282"/> 129 120 <CursorPos X="15" Y="1299"/> 130 121 <UsageCount Value="13"/> 131 <Loaded Value="True"/>132 122 </Unit8> 133 123 <Unit9> 134 124 <Filename Value="../../lazarus/lcl/include/rasterimage.inc"/> 135 <EditorIndex Value="3"/>136 125 <WindowIndex Value="0"/> 137 126 <TopLine Value="546"/> 138 127 <CursorPos X="11" Y="553"/> 139 128 <UsageCount Value="13"/> 140 <Loaded Value="True"/>141 129 </Unit9> 142 130 <Unit10> … … 149 137 <Unit11> 150 138 <Filename Value="../../lazarus/lcl/interfaces/gtk2/gtk2lclintf.inc"/> 151 <EditorIndex Value="11"/>152 139 <WindowIndex Value="0"/> 153 140 <TopLine Value="444"/> 154 141 <CursorPos X="1" Y="461"/> 155 142 <UsageCount Value="13"/> 156 <Loaded Value="True"/>157 143 </Unit11> 158 144 <Unit12> 159 145 <Filename Value="/usr/share/fpcsrc/2.4.0/packages/gtk2/src/gtk+/gdk/gdkimage.inc"/> 160 <EditorIndex Value="12"/>161 146 <WindowIndex Value="0"/> 162 147 <TopLine Value="14"/> 163 148 <CursorPos X="24" Y="21"/> 164 149 <UsageCount Value="13"/> 165 <Loaded Value="True"/>166 150 </Unit12> 167 151 <Unit13> 168 152 <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-image/src/fpimage.inc"/> 169 <EditorIndex Value="6"/>170 153 <WindowIndex Value="0"/> 171 154 <TopLine Value="313"/> 172 155 <CursorPos X="24" Y="316"/> 173 156 <UsageCount Value="13"/> 174 <Loaded Value="True"/>175 157 </Unit13> 176 158 <Unit14> 177 159 <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-image/src/fppalette.inc"/> 178 <EditorIndex Value="5"/>179 160 <WindowIndex Value="0"/> 180 161 <TopLine Value="149"/> 181 162 <CursorPos X="3" Y="151"/> 182 163 <UsageCount Value="13"/> 183 <Loaded Value="True"/>184 164 </Unit14> 185 165 <Unit15> 186 166 <Filename Value="../../lazarus/lcl/graphtype.pp"/> 187 167 <UnitName Value="GraphType"/> 188 <EditorIndex Value="8"/>189 168 <WindowIndex Value="0"/> 190 169 <TopLine Value="171"/> 191 170 <CursorPos X="3" Y="188"/> 192 171 <UsageCount Value="12"/> 193 <Loaded Value="True"/>194 172 </Unit15> 195 173 <Unit16> 196 174 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/inc/systemh.inc"/> 197 <EditorIndex Value="1"/>198 175 <WindowIndex Value="0"/> 199 176 <TopLine Value="300"/> 200 177 <CursorPos X="3" Y="317"/> 201 178 <UsageCount Value="10"/> 202 <Loaded Value="True"/>203 179 </Unit16> 180 <Unit17> 181 <Filename Value="UDrawMethod.pas"/> 182 <IsPartOfProject Value="True"/> 183 <UnitName Value="UDrawMethod"/> 184 <EditorIndex Value="3"/> 185 <WindowIndex Value="0"/> 186 <TopLine Value="152"/> 187 <CursorPos X="13" Y="162"/> 188 <UsageCount Value="22"/> 189 <Loaded Value="True"/> 190 </Unit17> 191 <Unit18> 192 <Filename Value="UFastBitmap.pas"/> 193 <IsPartOfProject Value="True"/> 194 <UnitName Value="UFastBitmap"/> 195 <EditorIndex Value="2"/> 196 <WindowIndex Value="0"/> 197 <TopLine Value="1"/> 198 <CursorPos X="30" Y="45"/> 199 <UsageCount Value="22"/> 200 <Loaded Value="True"/> 201 </Unit18> 202 <Unit19> 203 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/rasterimage.inc"/> 204 <EditorIndex Value="1"/> 205 <WindowIndex Value="0"/> 206 <TopLine Value="292"/> 207 <CursorPos X="1" Y="305"/> 208 <UsageCount Value="10"/> 209 <Loaded Value="True"/> 210 </Unit19> 204 211 </Units> 205 212 <JumpHistory Count="30" HistoryIndex="29"> 206 213 <Position1> 207 <Filename Value=" ../../lazarus/lcl/graphtype.pp"/>208 <Caret Line=" 188" Column="12" TopLine="173"/>214 <Filename Value="UDrawMethod.pas"/> 215 <Caret Line="94" Column="8" TopLine="72"/> 209 216 </Position1> 210 217 <Position2> 211 <Filename Value="U MainForm.pas"/>212 <Caret Line=" 278" Column="30" TopLine="253"/>218 <Filename Value="UDrawMethod.pas"/> 219 <Caret Line="81" Column="20" TopLine="68"/> 213 220 </Position2> 214 221 <Position3> 215 <Filename Value="U MainForm.pas"/>216 <Caret Line="2 65" Column="6" TopLine="253"/>222 <Filename Value="UDrawMethod.pas"/> 223 <Caret Line="29" Column="24" TopLine="13"/> 217 224 </Position3> 218 225 <Position4> 219 <Filename Value="U MainForm.pas"/>220 <Caret Line=" 272" Column="42" TopLine="256"/>226 <Filename Value="UDrawMethod.pas"/> 227 <Caret Line="36" Column="1" TopLine="16"/> 221 228 </Position4> 222 229 <Position5> 223 <Filename Value="U MainForm.pas"/>224 <Caret Line=" 278" Column="54" TopLine="256"/>230 <Filename Value="UDrawMethod.pas"/> 231 <Caret Line="61" Column="1" TopLine="40"/> 225 232 </Position5> 226 233 <Position6> 227 <Filename Value="U MainForm.pas"/>228 <Caret Line=" 277" Column="54" TopLine="255"/>234 <Filename Value="UDrawMethod.pas"/> 235 <Caret Line="68" Column="17" TopLine="55"/> 229 236 </Position6> 230 237 <Position7> 231 238 <Filename Value="UMainForm.pas"/> 232 <Caret Line=" 254" Column="27" TopLine="231"/>239 <Caret Line="164" Column="1" TopLine="140"/> 233 240 </Position7> 234 241 <Position8> 235 <Filename Value="U MainForm.pas"/>236 <Caret Line=" 281" Column="13" TopLine="264"/>242 <Filename Value="UFastBitmap.pas"/> 243 <Caret Line="13" Column="7" TopLine="4"/> 237 244 </Position8> 238 245 <Position9> 239 246 <Filename Value="UMainForm.pas"/> 240 <Caret Line=" 286" Column="1" TopLine="260"/>247 <Caret Line="90" Column="23" TopLine="78"/> 241 248 </Position9> 242 249 <Position10> 243 250 <Filename Value="UMainForm.pas"/> 244 <Caret Line=" 279" Column="42" TopLine="253"/>251 <Caret Line="91" Column="17" TopLine="78"/> 245 252 </Position10> 246 253 <Position11> 247 254 <Filename Value="UMainForm.pas"/> 248 <Caret Line=" 10" Column="18" TopLine="1"/>255 <Caret Line="48" Column="1" TopLine="33"/> 249 256 </Position11> 250 257 <Position12> 251 258 <Filename Value="UMainForm.pas"/> 252 <Caret Line=" 282" Column="40" TopLine="260"/>259 <Caret Line="96" Column="1" TopLine="74"/> 253 260 </Position12> 254 261 <Position13> 255 262 <Filename Value="UMainForm.pas"/> 256 <Caret Line="1 0" Column="27" TopLine="1"/>263 <Caret Line="161" Column="7" TopLine="139"/> 257 264 </Position13> 258 265 <Position14> 259 266 <Filename Value="UMainForm.pas"/> 260 <Caret Line=" 60" Column="36" TopLine="36"/>267 <Caret Line="146" Column="7" TopLine="101"/> 261 268 </Position14> 262 269 <Position15> 263 270 <Filename Value="UMainForm.pas"/> 264 <Caret Line=" 168" Column="9" TopLine="166"/>271 <Caret Line="84" Column="3" TopLine="82"/> 265 272 </Position15> 266 273 <Position16> 267 274 <Filename Value="UMainForm.pas"/> 268 <Caret Line=" 293" Column="1" TopLine="270"/>275 <Caret Line="88" Column="1" TopLine="82"/> 269 276 </Position16> 270 277 <Position17> 271 278 <Filename Value="UMainForm.pas"/> 272 <Caret Line="1 19" Column="46" TopLine="102"/>279 <Caret Line="156" Column="35" TopLine="26"/> 273 280 </Position17> 274 281 <Position18> 275 282 <Filename Value="UMainForm.pas"/> 276 <Caret Line=" 135" Column="78" TopLine="118"/>283 <Caret Line="88" Column="1" TopLine="75"/> 277 284 </Position18> 278 285 <Position19> 279 286 <Filename Value="UMainForm.pas"/> 280 <Caret Line=" 183" Column="1" TopLine="166"/>287 <Caret Line="89" Column="1" TopLine="75"/> 281 288 </Position19> 282 289 <Position20> 283 290 <Filename Value="UMainForm.pas"/> 284 <Caret Line=" 311" Column="7" TopLine="278"/>291 <Caret Line="91" Column="89" TopLine="69"/> 285 292 </Position20> 286 293 <Position21> 287 <Filename Value="U MainForm.pas"/>288 <Caret Line=" 202" Column="1" TopLine="185"/>294 <Filename Value="UDrawMethod.pas"/> 295 <Caret Line="194" Column="40" TopLine="182"/> 289 296 </Position21> 290 297 <Position22> 291 <Filename Value="U MainForm.pas"/>292 <Caret Line=" 228" Column="1" TopLine="211"/>298 <Filename Value="UDrawMethod.pas"/> 299 <Caret Line="170" Column="1" TopLine="157"/> 293 300 </Position22> 294 301 <Position23> 295 <Filename Value="U MainForm.pas"/>296 <Caret Line=" 252" Column="1" TopLine="235"/>302 <Filename Value="UDrawMethod.pas"/> 303 <Caret Line="193" Column="3" TopLine="189"/> 297 304 </Position23> 298 305 <Position24> 299 <Filename Value="U MainForm.pas"/>300 <Caret Line=" 290" Column="3" TopLine="277"/>306 <Filename Value="UDrawMethod.pas"/> 307 <Caret Line="71" Column="34" TopLine="60"/> 301 308 </Position24> 302 309 <Position25> 303 <Filename Value="U MainForm.pas"/>304 <Caret Line=" 302" Column="30" TopLine="277"/>310 <Filename Value="UDrawMethod.pas"/> 311 <Caret Line="21" Column="17" TopLine="8"/> 305 312 </Position25> 306 313 <Position26> 307 <Filename Value="U MainForm.pas"/>308 <Caret Line="2 97" Column="62" TopLine="280"/>314 <Filename Value="UDrawMethod.pas"/> 315 <Caret Line="248" Column="3" TopLine="245"/> 309 316 </Position26> 310 317 <Position27> 311 <Filename Value="U MainForm.pas"/>312 <Caret Line=" 301" Column="17" TopLine="280"/>318 <Filename Value="UDrawMethod.pas"/> 319 <Caret Line="195" Column="1" TopLine="182"/> 313 320 </Position27> 314 321 <Position28> 315 <Filename Value="U MainForm.pas"/>316 <Caret Line="1 32" Column="38" TopLine="115"/>322 <Filename Value="UDrawMethod.pas"/> 323 <Caret Line="196" Column="1" TopLine="182"/> 317 324 </Position28> 318 325 <Position29> 319 326 <Filename Value="UMainForm.pas"/> 320 <Caret Line=" 347" Column="19" TopLine="325"/>327 <Caret Line="91" Column="89" TopLine="69"/> 321 328 </Position29> 322 329 <Position30> 323 330 <Filename Value="UMainForm.pas"/> 324 <Caret Line="1 44" Column="1" TopLine="114"/>331 <Caret Line="119" Column="1" TopLine="101"/> 325 332 </Position30> 326 333 </JumpHistory> -
GraphicTest/GraphicTest.lpr
r200 r201 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UMainForm, UPlatform 10 Forms, UMainForm, UPlatform, UDrawMethod, UFastBitmap 11 11 { you can add units after this }; 12 12 -
GraphicTest/UMainForm.lfm
r200 r201 1 1 object MainForm: TMainForm 2 Left = 3572 Left = 291 3 3 Height = 452 4 4 Top = 127 5 Width = 6275 Width = 731 6 6 Caption = 'Graphic test' 7 7 ClientHeight = 452 8 ClientWidth = 627 8 ClientWidth = 731 9 OnClose = FormClose 9 10 OnCreate = FormCreate 10 11 OnDestroy = FormDestroy 11 12 LCLVersion = '0.9.31' 12 13 object PageControl1: TPageControl 13 Left = 24814 Left = 312 14 15 Height = 432 15 16 Top = 16 16 Width = 37617 Width = 416 17 18 ActivePage = TabSheet1 18 19 Anchors = [akTop, akLeft, akRight, akBottom] … … 21 22 object TabSheet1: TTabSheet 22 23 Caption = 'TImage' 23 ClientHeight = 40 524 ClientWidth = 37224 ClientHeight = 406 25 ClientWidth = 408 25 26 object Image1: TImage 26 27 Left = 6 27 Height = 39 228 Height = 393 28 29 Top = 7 29 Width = 3 6230 Width = 398 30 31 Anchors = [akTop, akLeft, akRight, akBottom] 31 32 end … … 57 58 Height = 14 58 59 Top = 95 59 Width = 2 460 Width = 23 60 61 Caption = 'FPS:' 61 62 ParentColor = False … … 65 66 Height = 14 66 67 Top = 95 67 Width = 3868 Caption = ' Label2'68 Width = 10 69 Caption = ' ' 69 70 ParentColor = False 70 71 end … … 83 84 Height = 14 84 85 Top = 112 85 Width = 8386 Width = 74 86 87 Caption = 'Frame duration' 87 88 ParentColor = False … … 91 92 Height = 14 92 93 Top = 112 93 Width = 3894 Caption = ' Label4'94 Width = 10 95 Caption = ' ' 95 96 ParentColor = False 96 97 end … … 99 100 Height = 240 100 101 Top = 208 101 Width = 232 102 Width = 296 103 Anchors = [akTop, akLeft, akBottom] 102 104 Columns = < 103 105 item … … 107 109 item 108 110 Caption = 'Duration' 109 Width = 111 111 Width = 60 112 end 113 item 114 Caption = 'FPS' 115 Width = 60 110 116 end> 111 117 TabOrder = 3 112 118 ViewStyle = vsReport 113 119 end 114 object Button 1: TButton120 object ButtonBenchmark: TButton 115 121 Left = 11 116 122 Height = 25 … … 118 124 Width = 75 119 125 Caption = 'Benchmark' 120 OnClick = Button 1Click126 OnClick = ButtonBenchmarkClick 121 127 TabOrder = 4 122 128 end 123 129 object ComboBox1: TComboBox 124 130 Left = 7 125 Height = 2 5131 Height = 21 126 132 Top = 64 127 133 Width = 233 128 ItemHeight = 0134 ItemHeight = 13 129 135 Items.Strings = ( 130 136 'TBitmap.Canvas.Pixels' … … 142 148 Height = 14 143 149 Top = 47 144 Width = 4 6150 Width = 41 145 151 Caption = 'Method:' 146 152 ParentColor = False … … 149 155 OnTimer = Timer1Timer 150 156 left = 209 151 top = 37157 top = 16 152 158 end 153 159 end -
GraphicTest/UMainForm.pas
r200 r201 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 9 ExtCtrls, StdCtrls, DateUtils, UPlatform, LCLType, IntfGraphics, fpImage, 10 Math, GraphType, Contnrs, LclIntf ;10 Math, GraphType, Contnrs, LclIntf, UFastBitmap, UDrawMethod; 11 11 12 12 const 13 SceneFrameCount = 20;13 SceneFrameCount = 100; 14 14 15 15 type 16 16 17 { TScene }18 19 TScene = class20 private21 function GetSize: TPoint;22 procedure SetSize(const AValue: TPoint);23 public24 Pixels: array of array of Byte;25 procedure RandomImage;26 property Size: TPoint read GetSize write SetSize;27 end;28 17 29 18 { TMainForm } 30 19 31 20 TMainForm = class(TForm) 32 Button 1: TButton;21 ButtonBenchmark: TButton; 33 22 ButtonStart: TButton; 34 23 ButtonStop: TButton; … … 46 35 TabSheet2: TTabSheet; 47 36 Timer1: TTimer; 48 procedure Button 1Click(Sender: TObject);37 procedure ButtonBenchmarkClick(Sender: TObject); 49 38 procedure ButtonStartClick(Sender: TObject); 50 39 procedure ButtonStopClick(Sender: TObject); 40 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 51 41 procedure FormCreate(Sender: TObject); 52 42 procedure FormDestroy(Sender: TObject); 53 43 procedure Timer1Timer(Sender: TObject); 54 44 private 55 procedure Draw1;56 procedure Draw2;57 procedure Draw3;58 procedure Draw4;59 procedure Draw5;60 procedure Draw6;61 { private declarations }62 45 public 46 DrawMethod: TDrawMethod; 63 47 Bitmap: TBitmap; 64 Frames: Integer; 65 Scenes: TObjectList; // TObjectList<TScene> 48 Scenes: TObjectList; // TObjectList<TFastBitmap> 66 49 SceneIndex: Integer; 67 StartTime: TDateTime;68 FrameDuration: TDateTime;69 50 end; 70 51 … … 74 55 implementation 75 56 76 { TScene }77 78 function TScene.GetSize: TPoint;79 begin80 Result.X := Length(Pixels);81 if Result.X > 0 then Result.Y := Length(Pixels[0])82 else Result.Y := 0;83 end;84 85 procedure TScene.SetSize(const AValue: TPoint);86 begin87 SetLength(Pixels, AValue.X, AValue.Y);88 end;89 90 procedure TScene.RandomImage;91 var92 X, Y: Integer;93 begin94 for Y := 0 to Size.Y - 1 do95 for X := 0 to Size.X - 1 do96 Pixels[X, Y] := Random(256);97 end;98 99 57 {$R *.lfm} 100 58 … … 103 61 procedure TMainForm.FormCreate(Sender: TObject); 104 62 var 105 NewScene: T Scene;63 NewScene: TFastBitmap; 106 64 I: Integer; 107 65 begin 66 TabSheet1.DoubleBuffered := True; 108 67 Randomize; 109 68 Scenes := TObjectList.Create; 110 69 for I := 0 to SceneFrameCount - 1 do begin 111 NewScene := T Scene.Create;70 NewScene := TFastBitmap.Create; 112 71 NewScene.Size := Point(320, 240); 113 72 NewScene.RandomImage; … … 116 75 Bitmap := TBitmap.Create; 117 76 Bitmap.PixelFormat := pf24bit; 118 Image1.Picture.Bitmap.SetSize(TScene(Scenes[0]).Size.X, TScene(Scenes[0]).Size.Y); 119 Bitmap.SetSize(TScene(Scenes[0]).Size.X, TScene(Scenes[0]).Size.Y); 77 Image1.Picture.Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 78 Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 79 ComboBox1.ItemIndex := 0; 120 80 end; 121 81 … … 125 85 ButtonStart.Enabled := False; 126 86 Timer1.Enabled := True; 127 Frames := 0; 128 if ComboBox1.ItemIndex = 0 then Draw1; 129 if ComboBox1.ItemIndex = 1 then Draw3; 130 if ComboBox1.ItemIndex = 2 then Draw2; 131 if ComboBox1.ItemIndex = 3 then Draw4; 132 if ComboBox1.ItemIndex = 4 then Draw5; 133 if ComboBox1.ItemIndex = 5 then Draw6; 87 DrawMethod.Free; 88 if ComboBox1.ItemIndex >= 0 then begin 89 DrawMethod := DrawMethodClasses[ComboBox1.ItemIndex].Create; 90 DrawMethod.Bitmap := Image1.Picture.Bitmap; 91 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 92 repeat 93 DrawMethod.DrawFrameTiming(TFastBitmap(Scenes[SceneIndex])); 94 SceneIndex := (SceneIndex + 1) mod Scenes.Count; 95 Application.ProcessMessages; 96 until not ButtonStop.Enabled; 97 end; 98 ButtonStopClick(Self); 134 99 end; 135 100 136 procedure TMainForm.Button 1Click(Sender: TObject);101 procedure TMainForm.ButtonBenchmarkClick(Sender: TObject); 137 102 var 138 103 NewItem: TListItem; 104 I: Integer; 139 105 begin 140 106 with ListView1, Items do … … 142 108 BeginUpdate; 143 109 Clear; 144 Draw1; 145 NewItem := Add; 146 NewItem.Caption := ComboBox1.Items[0]; 147 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 148 Draw3; 149 NewItem := Add; 150 NewItem.Caption := ComboBox1.Items[1]; 151 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 152 Draw2; 153 NewItem := Add; 154 NewItem.Caption := ComboBox1.Items[2]; 155 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 156 Draw4; 157 NewItem := Add; 158 NewItem.Caption := ComboBox1.Items[3]; 159 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 160 Draw5; 161 NewItem := Add; 162 NewItem.Caption := ComboBox1.Items[4]; 163 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 164 Draw6; 165 NewItem := Add; 166 NewItem.Caption := ComboBox1.Items[5]; 167 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 110 for I := 0 to High(DrawMethodClasses) do begin 111 DrawMethod.Free; 112 DrawMethod := DrawMethodClasses[I].Create; 113 DrawMethod.Bitmap := Image1.Picture.Bitmap; 114 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 115 DrawMethod.DrawFrameTiming(TFastBitmap(Scenes[0])); 116 NewItem := Add; 117 NewItem.Caption := DrawMethod.Caption; 118 NewItem.SubItems.Add(FloatToStr(RoundTo(DrawMethod.FrameDuration / OneMillisecond, -3))); 119 NewItem.SubItems.Add(FloatToStr(RoundTo(1 / (DrawMethod.FrameDuration / OneSecond), -3))); 120 end; 168 121 finally 169 122 EndUpdate; … … 177 130 end; 178 131 132 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 133 begin 134 ButtonStopClick(Self); 135 end; 136 179 137 procedure TMainForm.FormDestroy(Sender: TObject); 180 138 begin … … 185 143 procedure TMainForm.Timer1Timer(Sender: TObject); 186 144 begin 187 Label2.Caption := IntToStr(Frames); 188 Label4.Caption := FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3)); 189 Frames := 0; 190 end; 191 192 procedure TMainForm.Draw1; 193 var 194 Y, X: Integer; 195 begin 196 repeat 197 StartTime := NowPrecise; 198 Inc(Frames); 199 with TScene(Scenes[SceneIndex]) do begin 200 for X := 0 to Size.X - 1 do 201 for Y := 0 to Size.Y - 1 do 202 Image1.Picture.Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101; 203 FrameDuration := NowPrecise - StartTime; 204 end; 205 SceneIndex := (SceneIndex + 1) mod Scenes.Count; 206 Application.ProcessMessages; 207 until ButtonStart.Enabled; 208 end; 209 210 procedure TMainForm.Draw2; 211 var 212 Y, X: Integer; 213 TempIntfImage: TLazIntfImage; 214 begin 215 try 216 TempIntfImage := TLazIntfImage.Create(0, 0); 217 repeat 218 StartTime := NowPrecise; 219 Inc(Frames); 220 with TScene(Scenes[SceneIndex]) do begin 221 TempIntfImage.LoadFromBitmap(Image1.Picture.Bitmap.Handle, 222 Image1.Picture.Bitmap.MaskHandle); 223 for X := 0 to Size.X - 1 do 224 for Y := 0 to Size.Y - 1 do 225 TempIntfImage.Colors[X, Y] := TColorToFPColor(Pixels[X, Y] * $010101); 226 Image1.Picture.Bitmap.LoadFromIntfImage(TempIntfImage); 227 FrameDuration := NowPrecise - StartTime; 228 end; 229 SceneIndex := (SceneIndex + 1) mod Scenes.Count; 230 Application.ProcessMessages; 231 until ButtonStart.Enabled; 232 finally 233 TempIntfImage.Free; 145 if Assigned(DrawMethod) then begin 146 if (DrawMethod.FrameDuration > 0) then 147 Label2.Caption := FloatToStr(RoundTo(1 / (DrawMethod.FrameDuration / OneSecond), -3)) 148 else Label2.Caption := '0'; 149 Label4.Caption := FloatToStr(RoundTo(DrawMethod.FrameDuration / OneMillisecond, -3)) + ' ms'; 234 150 end; 235 end;236 237 procedure TMainForm.Draw3;238 var239 Y, X: Integer;240 begin241 repeat242 StartTime := NowPrecise;243 Inc(Frames);244 with TScene(Scenes[SceneIndex]) do245 try246 Image1.Picture.Bitmap.BeginUpdate(True);247 for X := 0 to Size.X - 1 do248 for Y := 0 to Size.Y - 1 do249 Image1.Picture.Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101;250 finally251 Image1.Picture.Bitmap.EndUpdate(False);252 end;253 FrameDuration := NowPrecise - StartTime;254 SceneIndex := (SceneIndex + 1) mod Scenes.Count;255 Application.ProcessMessages;256 until ButtonStart.Enabled;257 end;258 259 procedure TMainForm.Draw4;260 var261 Y, X: Integer;262 TempIntfImage: TLazIntfImage;263 C: TFPColor;264 begin265 try266 TempIntfImage := Image1.Picture.Bitmap.CreateIntfImage;267 repeat268 StartTime := NowPrecise;269 Inc(Frames);270 271 with TScene(Scenes[SceneIndex]) do begin272 for X := 0 to Size.X - 1 do273 for Y := 0 to Size.Y - 1 do begin274 C := TColorToFPColor(Pixels[X, Y] * $010101);275 TempIntfImage.Colors[X, Y] := C;276 end;277 Image1.Picture.Bitmap.LoadFromIntfImage(TempIntfImage);278 end;279 FrameDuration := NowPrecise - StartTime;280 SceneIndex := (SceneIndex + 1) mod Scenes.Count;281 Application.ProcessMessages;282 until ButtonStart.Enabled;283 finally284 TempIntfImage.Free;285 end;286 end;287 288 procedure TMainForm.Draw5;289 var290 Y, X: Integer;291 PixelPtr: PInteger;292 P: TPixelFormat;293 RawImage: TRawImage;294 BytePerPixel: Integer;295 begin296 P := Image1.Picture.Bitmap.PixelFormat;297 repeat298 StartTime := NowPrecise;299 Inc(Frames);300 with TScene(Scenes[SceneIndex]) do301 try302 Image1.Picture.Bitmap.BeginUpdate(False);303 RawImage := Image1.Picture.Bitmap.RawImage;304 PixelPtr := PInteger(RawImage.Data);305 BytePerPixel := RawImage.Description.BitsPerPixel div 8;306 for X := 0 to Size.X - 1 do307 for Y := 0 to Size.Y - 1 do begin308 PixelPtr^ := Pixels[X, Y] * $010101;309 Inc(PByte(PixelPtr), BytePerPixel);310 end;311 finally312 Image1.Picture.Bitmap.EndUpdate(False);313 end;314 FrameDuration := NowPrecise - StartTime;315 SceneIndex := (SceneIndex + 1) mod Scenes.Count;316 Application.ProcessMessages;317 until ButtonStart.Enabled;318 end;319 320 procedure TMainForm.Draw6;321 var322 Y, X: Integer;323 PixelPtr: PInteger;324 P: TPixelFormat;325 RawImage: TRawImage;326 BytePerPixel: Integer;327 hPaint, hBmp: HDC;328 begin329 P := Image1.Picture.Bitmap.PixelFormat;330 repeat331 StartTime := NowPrecise;332 Inc(Frames);333 with TScene(Scenes[SceneIndex]) do334 try335 Bitmap.BeginUpdate(False);336 RawImage := Bitmap.RawImage;337 PixelPtr := PInteger(RawImage.Data);338 BytePerPixel := RawImage.Description.BitsPerPixel div 8;339 for X := 0 to Size.X - 1 do340 for Y := 0 to Size.Y - 1 do begin341 PixelPtr^ := Pixels[X, Y] * $010101;342 Inc(PByte(PixelPtr), BytePerPixel);343 end;344 finally345 Bitmap.EndUpdate(False);346 end;347 hBmp := Bitmap.Canvas.Handle;348 hPaint := PaintBox1.Canvas.Handle;349 BitBlt(hPaint, 0, 0, Bitmap.Width, Bitmap.Height, hBmp, 0, 0, srcCopy);350 351 FrameDuration := NowPrecise - StartTime;352 SceneIndex := (SceneIndex + 1) mod Scenes.Count;353 Application.ProcessMessages;354 until ButtonStart.Enabled;355 151 end; 356 152
Note:
See TracChangeset
for help on using the changeset viewer.