1 | unit Kernel.Device;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Generics.Collections, Kernel.List, Kernel.Graphics, syncobjs;
|
---|
7 |
|
---|
8 | type
|
---|
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 |
|
---|
56 | implementation
|
---|
57 |
|
---|
58 | { TVideoMode }
|
---|
59 |
|
---|
60 | function TVideoMode.GetBytesPerPixel: Integer;
|
---|
61 | begin
|
---|
62 | if ColorFormat = cfRGBA8 then Result := 4
|
---|
63 | else if ColorFormat = cfGray8 then Result := 1
|
---|
64 | else Result := 0;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | function TVideoMode.GetBytesPerLine: Integer;
|
---|
68 | begin
|
---|
69 | Result := Size.X * GetBytesPerPixel;
|
---|
70 | end;
|
---|
71 |
|
---|
72 | function TVideoMode.GetBytesPerImage: Integer;
|
---|
73 | begin
|
---|
74 | Result := Size.Y * GetBytesPerLine;
|
---|
75 | end;
|
---|
76 |
|
---|
77 | procedure TVideoMode.Assign(Source: TVideoMode);
|
---|
78 | begin
|
---|
79 | Size := Source.Size;
|
---|
80 | ColorFormat := ColorFormat;
|
---|
81 | end;
|
---|
82 |
|
---|
83 | { TDeviceSerial }
|
---|
84 |
|
---|
85 | constructor TDeviceSerial.Create;
|
---|
86 | begin
|
---|
87 | inherited;
|
---|
88 | ClassName := 'Serial device';
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TDeviceSerial.WriteText(Text: string);
|
---|
92 | begin
|
---|
93 | end;
|
---|
94 |
|
---|
95 | { TDevice }
|
---|
96 |
|
---|
97 | constructor TDevice.Create;
|
---|
98 | begin
|
---|
99 | inherited;
|
---|
100 | end;
|
---|
101 |
|
---|
102 | { TDeviceVideo }
|
---|
103 |
|
---|
104 | constructor TDeviceVideo.Create;
|
---|
105 | begin
|
---|
106 | inherited Create;
|
---|
107 | ClassName := 'Video device';
|
---|
108 | FVideoMode := TVideoMode.Create;
|
---|
109 | Lock := TCriticalSection.Create;
|
---|
110 | end;
|
---|
111 |
|
---|
112 | destructor TDeviceVideo.Destroy;
|
---|
113 | begin
|
---|
114 | FreeAndNil(Lock);
|
---|
115 | FreeAndNil(FVideoMode);
|
---|
116 | inherited;
|
---|
117 | end;
|
---|
118 |
|
---|
119 | procedure TDeviceVideo.SetVideoMode(Mode: TVideoMode);
|
---|
120 | begin
|
---|
121 | end;
|
---|
122 |
|
---|
123 | procedure TDeviceVideo.GetSupportedModes(Modes: TVideoModes);
|
---|
124 | begin
|
---|
125 | Modes.Clear;
|
---|
126 | end;
|
---|
127 |
|
---|
128 | function TDeviceVideo.GetVideoMemory: PByte;
|
---|
129 | begin
|
---|
130 | Result := nil;
|
---|
131 | end;
|
---|
132 |
|
---|
133 | procedure TDeviceVideo.VideoMemoryChange;
|
---|
134 | begin
|
---|
135 | end;
|
---|
136 |
|
---|
137 | end.
|
---|
138 |
|
---|