Ignore:
Timestamp:
Sep 28, 2014, 8:53:50 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Tested csOpaque direct drawing with temporary bitmap buffer. Not significant improvement over non opaque mode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r69 r71  
    8989    procedure Timer1Timer(Sender: TObject);
    9090  private
     91    TempBitmap: TBitmap;
    9192    StartMousePoint: TPoint;
    9293    StartViewPoint: TPoint;
    9394    MoveActive: Boolean;
    9495    RedrawPending: Boolean;
     96    DrawDuration: TDateTime;
    9597  public
    9698    procedure LoadConfig(Config: TXmlConfig; Path: string);
     
    116118
    117119procedure TFormMain.PaintBox1Paint(Sender: TObject);
    118 begin
     120var
     121  DrawStart: TDateTime;
     122begin
     123  DrawStart := Now;
    119124  //if Core.Game.Running then
    120125  if Assigned(Core.Game.CurrentPlayer) then
    121126  with Core.Game.CurrentPlayer do begin
    122127    View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
    123     Paint(PaintBox1);
    124   end;
     128    if csOpaque in PaintBox1.ControlStyle then begin
     129      TempBitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
     130      TempBitmap.Canvas.Brush.Color := clBackground; //PaintBox1.GetColorResolvingParent;
     131      TempBitmap.Canvas.FillRect(0, 0, PaintBox1.Width, PaintBox1.Height);
     132      Paint(TempBitmap.Canvas);
     133      PaintBox1.Canvas.Draw(0, 0, TempBitmap);
     134    end else Paint(PaintBox1.Canvas);
     135  end;
     136  DrawDuration := Now - DrawStart;
    125137end;
    126138
    127139procedure TFormMain.EraseBackground(DC: HDC);
    128140begin
     141  // Do nothing, all background space covered by controls
    129142end;
    130143
     
    144157  if RedrawPending then begin
    145158    RedrawPending := False;
    146     DrawStart := Now;
    147159    PaintBox1.Repaint;
    148     StatusBar1.Panels[1].Text := IntToStr(Trunc((Now - DrawStart) / OneMillisecond)) + ' ms';
    149 
     160    StatusBar1.Panels[1].Text := IntToStr(Trunc(DrawDuration / OneMillisecond)) + ' ms';
    150161    NewCaption := 'xTactics';
    151162    if Assigned(Core.Game.CurrentPlayer) then
     
    199210procedure TFormMain.FormCreate(Sender: TObject);
    200211begin
     212  //PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque];
     213  //DoubleBuffered := True;
     214  TempBitmap := TBitmap.Create;
    201215end;
    202216
     
    274288procedure TFormMain.FormDestroy(Sender: TObject);
    275289begin
     290  TempBitmap.Free;
    276291end;
    277292
Note: See TracChangeset for help on using the changeset viewer.