Changeset 17


Ignore:
Timestamp:
Jan 21, 2018, 10:01:14 PM (6 years ago)
Author:
chronos
Message:
  • Added: Resize virtual screen according form size.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r14 r17  
    55  Width = 932
    66  Caption = 'Screen 1 - ChronOS'
    7   ClientHeight = 656
     7  ClientHeight = 653
    88  ClientWidth = 932
    99  Menu = MainMenu1
     
    1616  object PaintBox1: TPaintBox
    1717    Left = 0
    18     Height = 656
     18    Height = 653
    1919    Top = 0
    2020    Width = 932
  • trunk/Forms/UFormMain.pas

    r15 r17  
    9292  VideoDevice.OnRedraw := VideoDeviceRedraw;
    9393  VideoDevice.DPI := Screen.PixelsPerInch;
    94   VideoDevice.VideoMemorySize := TPoint.Create(PaintBox1.Width, PaintBox1.Height);
    9594  VideoDevice.OnModeChanged := VideoDeviceRedraw;
     95  PaintBox1Resize(Self);
    9696  Kernel.Devices.Add(VideoDevice);
    9797
     
    215215
    216216procedure TFormMain.PaintBox1Resize(Sender: TObject);
    217 begin
     217var
     218  VideoMode: TVideoMode;
     219begin
     220  VideoMode := TVideoMode.Create;
     221  VideoMode.Assign(VideoDevice.VideoMode);
     222  VideoMode.Size := TPoint.Create(Width, Height);
     223  VideoDevice.VideoMode := VideoMode;
    218224end;
    219225
  • trunk/Packages/Kernel/UDevice.pas

    r13 r17  
    2424    function GetBytesPerLine: Integer;
    2525    function GetBytesPerImage: Integer;
     26    procedure Assign(Source: TVideoMode);
    2627  end;
    2728
     
    2930
    3031  TDeviceVideo = class(TDevice)
     32  private
     33    FVideoMode: TVideoMode;
     34  protected
     35    procedure SetVideoMode(Mode: TVideoMode); virtual;
     36    function GetVideoMemory: PByte; virtual;
     37  public
    3138    constructor Create; override;
    32     procedure SetMode(Mode: TVideoMode); virtual;
    3339    procedure GetSupportedModes(Modes: TObjectList); virtual;
    34     function GetVideoMemory: PByte; virtual;
    3540    procedure VideoMemoryChange; virtual;
     41    property VideoMode: TVideoMode read FVideoMode write SetVideoMode;
     42    property VideoMemory: PByte read GetVideoMemory;
    3643  end;
    3744
     
    6471end;
    6572
     73procedure TVideoMode.Assign(Source: TVideoMode);
     74begin
     75  Size := Source.Size;
     76  ColorFormat := ColorFormat;
     77end;
     78
    6679{ TDeviceSerial }
    6780
     
    90103  inherited Create;
    91104  ClassName := 'Video device';
     105  FVideoMode := TVideoMode.Create;
    92106end;
    93107
    94 procedure TDeviceVideo.SetMode(Mode: TVideoMode);
     108procedure TDeviceVideo.SetVideoMode(Mode: TVideoMode);
    95109begin
    96110end;
  • trunk/Packages/Kernel/UKernel.pas

    r15 r17  
    7474  if Assigned(VideoDevice) then begin
    7575    NewScreen := TScreen.Create;
    76     NewScreen.VideoMemory := nil;
    7776    Modes := TObjectList.Create;
    7877    VideoDevice.GetSupportedModes(Modes);
    7978    if Modes.Count > 0 then begin
    8079      VideoMode := TVideoMode(Modes.Last);
    81       VideoDevice.SetMode(VideoMode);
     80      VideoDevice.VideoMode := VideoMode;
    8281      NewScreen.Size := VideoMode.Size;
    8382      NewScreen.ColorFormat := VideoMode.ColorFormat;
    84       NewScreen.VideoMemory := VideoDevice.GetVideoMemory;
    85       NewScreen.BytesPerPixel := VideoMode.GetBytesPerPixel;
    86       NewScreen.BytesPerLine := VideoMode.GetBytesPerLine;
    8783      NewScreen.Device := VideoDevice;
    8884      NewScreen.Canvas := TScreenCanvas.Create;
  • trunk/Packages/Kernel/UScreen.pas

    r16 r17  
    2525
    2626  TScreen = class
     27  private
     28    function GetBytesPerLine: Integer;
     29    function GetBytesPerPixel: Integer;
     30    function GetVideoMemory: PByte;
     31  public
    2732    Device: TObject; // TDeviceVideo;
    2833    Size: TPoint;
    2934    DPI: Integer;
    3035    ColorFormat: TColorFormat;
    31     BytesPerPixel: Integer;
    32     BytesPerLine: Integer;
    33     VideoMemory: PByte;
    3436    Canvas: TCanvas;
    3537    procedure VideoMemoryUpdated;
     38    property BytesPerPixel: Integer read GetBytesPerPixel;
     39    property BytesPerLine: Integer read GetBytesPerLine;
     40    property VideoMemory: PByte read GetVideoMemory;
    3641  end;
    3742
     
    99104{ TScreen }
    100105
     106function TScreen.GetBytesPerLine: Integer;
     107begin
     108  Result := TDeviceVideo(Device).VideoMode.GetBytesPerLine;
     109end;
     110
     111function TScreen.GetBytesPerPixel: Integer;
     112begin
     113  Result := TDeviceVideo(Device).VideoMode.GetBytesPerPixel;
     114end;
     115
     116function TScreen.GetVideoMemory: PByte;
     117begin
     118  Result := TDeviceVideo(Device).VideoMemory;
     119end;
     120
    101121procedure TScreen.VideoMemoryUpdated;
    102122begin
  • trunk/Platform/Base/UPlatformBase.pas

    r14 r17  
    6464    FOnRedraw: TNotifyEvent;
    6565    procedure DoRedraw;
     66  protected
     67    procedure SetVideoMode(Mode: TVideoMode); override;
    6668  public
    6769    VideoMemory: PByte;
    68     VideoMemorySize: TPoint;
    6970    DPI: Integer;
    7071    Canvas: TCanvas;
    71     VideoMode: TVideoMode;
    72     procedure SetMode(Mode: TVideoMode); override;
    7372    procedure GetSupportedModes(Modes: TObjectList); override;
    7473    function GetVideoMemory: PByte; override;
     
    8988end;
    9089
    91 procedure TDeviceVideoBase.SetMode(Mode: TVideoMode);
     90procedure TDeviceVideoBase.SetVideoMode(Mode: TVideoMode);
    9291begin
    9392  if (VideoMode.Size.X <> Mode.Size.X) or
     
    9695      VideoMode.Size := Mode.Size;
    9796      VideoMode.ColorFormat := Mode.ColorFormat;
     97      ReAllocMem(VideoMemory, VideoMode.GetBytesPerImage);
     98      FillDWord(VideoMemory^, VideoMode.GetBytesPerImage div 4, $ffffff);
    9899      if Assigned(FOnModeChanged) then
    99100        FOnModeChanged(Self);
     
    135136function TDeviceVideoBase.GetVideoMemory: PByte;
    136137begin
    137   VideoMemory := GetMem(VideoMode.GetBytesPerImage);
    138   FillDWord(VideoMemory^, VideoMode.GetBytesPerImage div 4, $ffffff);
    139138  Result := VideoMemory;
    140139end;
     
    148147begin
    149148  inherited Create;
    150   VideoMode := TVideoMode.Create;
    151149end;
    152150
Note: See TracChangeset for help on using the changeset viewer.