Changeset 19 for trunk/Packages/Kernel
- Timestamp:
- Jan 21, 2018, 11:33:15 PM (7 years ago)
- Location:
- trunk/Packages/Kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.