Changeset 15


Ignore:
Timestamp:
Dec 27, 2017, 8:28:45 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Drawing of TWindow background.
  • Fixed: Initialize TGraphicObject canvas only once.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r14 r15  
    3939    procedure Timer1Timer(Sender: TObject);
    4040  private
     41    TempBitmap: TBitmap;
    4142    RedrawPending: Boolean;
    4243    VideoDevice: TDeviceVideoBase;
     
    7374  NewApp2: TApp;
    7475begin
     76  TempBitmap := TBitmap.Create;
    7577  PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque];
    7678
     
    164166begin
    165167  FreeAndNil(Kernel);
     168  FreeAndNil(TempBitmap);
    166169end;
    167170
     
    186189  X, Y: Integer;
    187190  DX, DY: Integer;
    188   Bitmap: TBitmap;
    189191  P, PR: PByte;
    190192begin
    191193  try
    192     Bitmap := TBitmap.Create;
    193     Bitmap.BeginUpdate;
    194     Bitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
     194    TempBitmap.BeginUpdate;
     195    TempBitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
    195196
    196197    if Assigned(VideoDevice.VideoMemory) then begin
     
    201202        PR := P;
    202203        for X := 0 to VideoDevice.VideoMode.Size.X - 1 do begin
    203           Bitmap.Canvas.Pixels[X, Y] := PInteger(PR)^ and $ffffff;
     204          TempBitmap.Canvas.Pixels[X, Y] := PInteger(PR)^ and $ffffff;
    204205          Inc(PR, DX);
    205206        end;
     
    208209    end;
    209210  finally
    210     PaintBox1.Canvas.Draw(0, 0, Bitmap);
    211     Bitmap.EndUpdate;
    212     Bitmap.Free;
     211    PaintBox1.Canvas.Draw(0, 0, TempBitmap);
     212    TempBitmap.EndUpdate;
    213213  end;
    214214end;
  • trunk/Packages/Kernel/UAPI.pas

    r13 r15  
    252252  if Assigned(Window) then begin
    253253    Canvas := Window.Canvas;
    254     Canvas.Parent := TKernel(Kernel).Screens.First.Canvas;
    255254    Result := Canvas.Id;
    256255  end else Result := -1;
  • trunk/Packages/Kernel/UGraphics.pas

    r13 r15  
    7070    Id: Integer;
    7171    Visible: Boolean;
     72    constructor Create;
    7273    procedure Paint; virtual;
    7374    property Canvas: TCanvas read GetCanvas;
     
    102103    Objects: TFPGObjectList<TGraphicObject>;
    103104    Canvases: TFPGObjectList<TCanvas>;
     105    ParentCanvas: TCanvas;
    104106    function CreateWindow: TWindow;
    105107    function CreateCanvas: TCanvas;
     
    225227function TGraphicObject.GetCanvas: TCanvas;
    226228begin
    227   FCanvas := Desktop.CreateCanvas;
     229  if not Assigned(FCanvas) then
     230    FCanvas := Desktop.CreateCanvas;
    228231  Result := FCanvas;
     232end;
     233
     234constructor TGraphicObject.Create;
     235begin
     236  FCanvas := nil;
    229237end;
    230238
     
    257265  Result := TWindow.Create;
    258266  Result.Id := ObjectLastId;
     267  Result.Desktop := Self;
     268  Result.Canvas.Parent := ParentCanvas;
    259269  Objects.Add(Result);
     270  Paint;
    260271end;
    261272
  • trunk/Packages/Kernel/UKernel.pas

    r13 r15  
    8989      TScreenCanvas(NewScreen.Canvas).Screen := NewScreen;
    9090      Screens.Add(NewScreen);
     91      Desktop.ParentCanvas := Screens.First.Canvas;
    9192    end;
    9293    Modes.Free;
  • trunk/Packages/Kernel/UScreen.pas

    r13 r15  
    6868  for X := Rect.Left to Rect.Right do
    6969    SetPixel(TPoint.Create(X, Y), Color);
     70  Screen.VideoMemoryUpdated;
    7071end;
    7172
Note: See TracChangeset for help on using the changeset viewer.