- Timestamp:
- Jan 21, 2018, 11:33:15 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChronOS.lpi
r14 r19 9 9 <ResourceType Value="res"/> 10 10 <UseXPManifest Value="True"/> 11 <XPManifest> 12 <DpiAware Value="True"/> 13 </XPManifest> 11 14 <Icon Value="0"/> 12 15 </General> … … 24 27 <SearchPaths> 25 28 <IncludeFiles Value="$(ProjOutDir)"/> 26 <OtherUnitFiles Value="Apps;Platform/Base "/>27 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS) "/>29 <OtherUnitFiles Value="Apps;Platform/Base;Forms"/> 30 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-${BuildMode}"/> 28 31 </SearchPaths> 29 32 <Parsing> … … 117 120 <IncludeFiles Value="$(ProjOutDir)"/> 118 121 <OtherUnitFiles Value="Apps;Platform/Base;Forms"/> 119 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS) "/>122 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-${BuildMode}"/> 120 123 </SearchPaths> 121 124 <Parsing> -
trunk/Forms/UFormMain.pas
r18 r19 200 200 SizeY: Integer; 201 201 begin 202 { var203 X, Y: Integer;204 PixelPtr: PInteger;205 PixelRowPtr: PInteger;206 RawImage: TRawImage;207 BytePerPixel: Integer;208 SourcePixelPtr: Integer;209 begin210 try211 Bitmap.BeginUpdate;212 RawImage := Bitmap.RawImage;213 PixelRowPtr := PInteger(RawImage.Data);214 BytePerPixel := RawImage.Description.BitsPerPixel div 8;215 for Y := 0 to Bitmap.Height - 1 do begin216 PixelPtr := PixelRowPtr;217 for X := 0 to Bitmap.Width - 1 do begin218 SourcePixelPtr := TMatter(Matter[Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X),219 Trunc(Y / Bitmap.Height * Surface.Count.Y)]]).Color;220 PixelPtr^ := SwapBRComponent(SourcePixelPtr);221 Inc(PByte(PixelPtr), BytePerPixel);222 end;223 Inc(PByte(PixelRowPtr), RawImage.Description.BytesPerLine);224 end;225 finally226 Bitmap.EndUpdate;227 end;228 }229 202 try 230 203 TempBitmap.SetSize(VideoDevice.VideoMode.Size.X, VideoDevice.VideoMode.Size.Y); … … 234 207 DestBytePerPixel := RawImage.Description.BitsPerPixel div 8; 235 208 DestBytePerLine := RawImage.Description.BytesPerLine; 209 VideoDevice.Lock.Acquire; 236 210 if Assigned(VideoDevice.VideoMemory) then begin 237 211 SourceBytePerPixel := VideoDevice.VideoMode.GetBytesPerPixel; … … 252 226 end; 253 227 end; 228 VideoDevice.Lock.Release; 254 229 finally 255 230 TempBitmap.EndUpdate; … … 266 241 VideoMode.Size := TPoint.Create(Width, Height); 267 242 VideoDevice.VideoMode := VideoMode; 243 VideoMode.Free; 268 244 end; 269 245 -
trunk/Packages/Kernel/UDevice.pas
r17 r19 6 6 7 7 uses 8 Classes, SysUtils, Contnrs, UList, UGraphics ;8 Classes, SysUtils, Contnrs, UList, UGraphics, syncobjs; 9 9 10 10 type … … 36 36 function GetVideoMemory: PByte; virtual; 37 37 public 38 Lock: TCriticalSection; 38 39 constructor Create; override; 40 destructor Destroy; override; 39 41 procedure GetSupportedModes(Modes: TObjectList); virtual; 40 42 procedure VideoMemoryChange; virtual; … … 104 106 ClassName := 'Video device'; 105 107 FVideoMode := TVideoMode.Create; 108 Lock := TCriticalSection.Create; 109 end; 110 111 destructor TDeviceVideo.Destroy; 112 begin 113 Lock.Free; 114 FVideoMode.Free; 115 inherited Destroy; 106 116 end; 107 117 -
trunk/Packages/Kernel/UScreen.pas
r17 r19 14 14 15 15 TScreenCanvas = class(TCanvas) 16 private 17 procedure SetPixelInternal(P: TPoint; Color: TColor); 18 public 16 19 Screen: TScreen; 17 20 procedure DrawText(Pos: TPoint; Text: string; Color: TColor); override; … … 57 60 I: Integer; 58 61 begin 59 if Abs(P2.X - P1.X) > Abs(P2.Y - P1.Y) then begin 60 for I := 0 to Abs(P2.X - P1.X) - 1 do 61 SetPixel(TPoint.Create(Trunc(P1.X + I * Sign(P2.X - P1.X)), 62 Trunc(P1.Y + (P2.Y - P1.Y) / Abs(P2.X - P1.X) * I)), Color); 63 end else begin 64 for I := 0 to Abs(P2.Y - P1.Y) - 1 do 65 SetPixel(TPoint.Create(Trunc(P1.X + (P2.X - P1.X) / Abs(P2.Y - P1.Y) * I), 66 Trunc(P1.Y + I * Sign(P2.Y - P1.Y))), Color); 62 TDeviceVideo(Screen.Device).Lock.Acquire; 63 try 64 if Abs(P2.X - P1.X) > Abs(P2.Y - P1.Y) then begin 65 for I := 0 to Abs(P2.X - P1.X) - 1 do 66 SetPixelInternal(TPoint.Create(Trunc(P1.X + I * Sign(P2.X - P1.X)), 67 Trunc(P1.Y + (P2.Y - P1.Y) / Abs(P2.X - P1.X) * I)), Color); 68 end else begin 69 for I := 0 to Abs(P2.Y - P1.Y) - 1 do 70 SetPixelInternal(TPoint.Create(Trunc(P1.X + (P2.X - P1.X) / Abs(P2.Y - P1.Y) * I), 71 Trunc(P1.Y + I * Sign(P2.Y - P1.Y))), Color); 72 end; 73 finally 74 TDeviceVideo(Screen.Device).Lock.Release; 67 75 end; 68 76 Screen.VideoMemoryUpdated; … … 73 81 X, Y: Integer; 74 82 begin 75 for Y := Rect.Top to Rect.Bottom do 76 for X := Rect.Left to Rect.Right do 77 SetPixel(TPoint.Create(X, Y), Color); 83 TDeviceVideo(Screen.Device).Lock.Acquire; 84 try 85 for Y := Rect.Top to Rect.Bottom do 86 for X := Rect.Left to Rect.Right do 87 SetPixelInternal(TPoint.Create(X, Y), Color); 88 finally 89 TDeviceVideo(Screen.Device).Lock.Release; 90 end; 78 91 Screen.VideoMemoryUpdated; 79 92 end; … … 83 96 X, Y: Integer; 84 97 begin 85 for Y := Rect.Top to Rect.Bottom do begin 86 SetPixel(TPoint.Create(Rect.Left, Y), Color); 87 SetPixel(TPoint.Create(Rect.Right, Y), Color); 88 end; 89 for X := Rect.Left to Rect.Right do begin 90 SetPixel(TPoint.Create(X, Rect.Top), Color); 91 SetPixel(TPoint.Create(X, Rect.Bottom), Color); 98 TDeviceVideo(Screen.Device).Lock.Acquire; 99 try 100 for Y := Rect.Top to Rect.Bottom do begin 101 SetPixelInternal(TPoint.Create(Rect.Left, Y), Color); 102 SetPixelInternal(TPoint.Create(Rect.Right, Y), Color); 103 end; 104 for X := Rect.Left to Rect.Right do begin 105 SetPixelInternal(TPoint.Create(X, Rect.Top), Color); 106 SetPixelInternal(TPoint.Create(X, Rect.Bottom), Color); 107 end; 108 finally 109 TDeviceVideo(Screen.Device).Lock.Release; 92 110 end; 93 111 Screen.VideoMemoryUpdated; … … 95 113 96 114 procedure TScreenCanvas.SetPixel(P: TPoint; Color: TColor); 115 begin 116 TDeviceVideo(Screen.Device).Lock.Acquire; 117 try 118 if Assigned(Screen.VideoMemory) and 119 TRectangle.Create(TPoint.Create(0, 0), Screen.Size).PointInside(P) then 120 PInteger(Screen.VideoMemory + P.X * Screen.BytesPerPixel + P.Y * Screen.BytesPerLine)^ := Color; 121 finally 122 TDeviceVideo(Screen.Device).Lock.Release; 123 end; 124 end; 125 126 procedure TScreenCanvas.SetPixelInternal(P: TPoint; Color: TColor); 97 127 begin 98 128 if Assigned(Screen.VideoMemory) and -
trunk/Platform/Base/UPlatformBase.pas
r18 r19 93 93 (VideoMode.Size.Y <> Mode.Size.Y) or 94 94 (VideoMode.ColorFormat <> Mode.ColorFormat) then begin 95 VideoMode.Size := Mode.Size; 96 VideoMode.ColorFormat := Mode.ColorFormat; 97 ReAllocMem(VideoMemory, VideoMode.GetBytesPerImage); 98 FillDWord(VideoMemory^, VideoMode.GetBytesPerImage div 4, $ffffff); 95 Lock.Acquire; 96 try 97 if Mode.GetBytesPerImage <> VideoMode.GetBytesPerImage then begin 98 ReAllocMem(VideoMemory, Mode.GetBytesPerImage); 99 FillDWord(VideoMemory^, Mode.GetBytesPerImage div 4, $ffffff); 100 end; 101 VideoMode.Size := Mode.Size; 102 VideoMode.ColorFormat := Mode.ColorFormat; 103 finally 104 Lock.Release; 105 end; 99 106 if Assigned(FOnModeChanged) then 100 107 FOnModeChanged(Self); … … 151 158 destructor TDeviceVideoBase.Destroy; 152 159 begin 153 VideoMode.Free;154 160 inherited Destroy; 155 161 end;
Note:
See TracChangeset
for help on using the changeset viewer.