source: trunk/Packages/Kernel/Kernel.Device.pas

Last change on this file was 60, checked in by chronos, 8 months ago
  • Modified: Remove U prefix from unit names.
File size: 2.5 KB
Line 
1unit Kernel.Device;
2
3interface
4
5uses
6 Classes, SysUtils, Generics.Collections, Kernel.List, Kernel.Graphics, syncobjs;
7
8type
9 { TDevice }
10
11 TDevice = class(TNamedObject)
12 ClassName: string;
13 constructor Create; virtual;
14 end;
15
16 { TVideoMode }
17
18 TVideoMode = class
19 Size: TPoint;
20 ColorFormat: TColorFormat;
21 function GetBytesPerPixel: Integer;
22 function GetBytesPerLine: Integer;
23 function GetBytesPerImage: Integer;
24 procedure Assign(Source: TVideoMode);
25 end;
26
27 TVideoModes = class(TObjectList<TVideoMode>)
28 end;
29
30 { TDeviceVideo }
31
32 TDeviceVideo = class(TDevice)
33 private
34 FVideoMode: TVideoMode;
35 protected
36 procedure SetVideoMode(Mode: TVideoMode); virtual;
37 function GetVideoMemory: PByte; virtual;
38 public
39 Lock: TCriticalSection;
40 constructor Create; override;
41 destructor Destroy; override;
42 procedure GetSupportedModes(Modes: TVideoModes); virtual;
43 procedure VideoMemoryChange; virtual;
44 property VideoMode: TVideoMode read FVideoMode write SetVideoMode;
45 property VideoMemory: PByte read GetVideoMemory;
46 end;
47
48 { TDeviceSerial }
49
50 TDeviceSerial = class(TDevice)
51 constructor Create; override;
52 procedure WriteText(Text: string); virtual;
53 end;
54
55
56implementation
57
58{ TVideoMode }
59
60function TVideoMode.GetBytesPerPixel: Integer;
61begin
62 if ColorFormat = cfRGBA8 then Result := 4
63 else if ColorFormat = cfGray8 then Result := 1
64 else Result := 0;
65end;
66
67function TVideoMode.GetBytesPerLine: Integer;
68begin
69 Result := Size.X * GetBytesPerPixel;
70end;
71
72function TVideoMode.GetBytesPerImage: Integer;
73begin
74 Result := Size.Y * GetBytesPerLine;
75end;
76
77procedure TVideoMode.Assign(Source: TVideoMode);
78begin
79 Size := Source.Size;
80 ColorFormat := ColorFormat;
81end;
82
83{ TDeviceSerial }
84
85constructor TDeviceSerial.Create;
86begin
87 inherited;
88 ClassName := 'Serial device';
89end;
90
91procedure TDeviceSerial.WriteText(Text: string);
92begin
93end;
94
95{ TDevice }
96
97constructor TDevice.Create;
98begin
99 inherited;
100end;
101
102{ TDeviceVideo }
103
104constructor TDeviceVideo.Create;
105begin
106 inherited Create;
107 ClassName := 'Video device';
108 FVideoMode := TVideoMode.Create;
109 Lock := TCriticalSection.Create;
110end;
111
112destructor TDeviceVideo.Destroy;
113begin
114 FreeAndNil(Lock);
115 FreeAndNil(FVideoMode);
116 inherited;
117end;
118
119procedure TDeviceVideo.SetVideoMode(Mode: TVideoMode);
120begin
121end;
122
123procedure TDeviceVideo.GetSupportedModes(Modes: TVideoModes);
124begin
125 Modes.Clear;
126end;
127
128function TDeviceVideo.GetVideoMemory: PByte;
129begin
130 Result := nil;
131end;
132
133procedure TDeviceVideo.VideoMemoryChange;
134begin
135end;
136
137end.
138
Note: See TracBrowser for help on using the repository browser.