Changeset 71 for trunk


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.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r69 r71  
    11object FormMain: TFormMain
    2   Left = 102
     2  Left = 278
    33  Height = 621
    4   Top = 0
     4  Top = 84
    55  Width = 775
    66  Caption = 'xTactics'
     
    2121    Width = 735
    2222    Align = alClient
     23    ParentColor = False
    2324    OnMouseDown = PaintBox1MouseDown
    2425    OnMouseMove = PaintBox1MouseMove
  • 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
  • trunk/UGame.pas

    r70 r71  
    193193    procedure LoadFromNode(Node: TDOMNode);
    194194    procedure SaveToNode(Node: TDOMNode);
    195     procedure Paint(PaintBox: TPaintBox);
     195    procedure Paint(Canvas: TCanvas);
    196196    constructor Create;
    197197    destructor Destroy; override;
     
    13931393end;
    13941394
    1395 procedure TPlayer.Paint(PaintBox: TPaintBox);
    1396 begin
    1397   Game.Map.Paint(PaintBox.Canvas, View);
     1395procedure TPlayer.Paint(Canvas: TCanvas);
     1396begin
     1397  Game.Map.Paint(Canvas, View);
    13981398end;
    13991399
     
    21082108            Brush.Color := clPurple
    21092109          else Brush.Color := Cell.GetColor;
    2110         Pen.Color := clBlack;
     2110        //Pen.Color := clBlack;
    21112111        PaintCell(Canvas, Cell.PosPx, IntToStr(Cell.GetAvialPower), View, Cell);
    21122112      end;
Note: See TracChangeset for help on using the changeset viewer.