summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authordrewski207 <drewski207@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-09 01:12:47 +0000
committerdrewski207 <drewski207@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-09 01:12:47 +0000
commit03e2be3d9c130b02d5cc605de884aa2fe2162db9 (patch)
tree408f825d4269c279eb51783a9c35e685eb75f579 /src/corelib
parent4e85bd67c3e3e65dd66c2f44594394d86d204d72 (diff)
downloadfpGUI-03e2be3d9c130b02d5cc605de884aa2fe2162db9.tar.xz
* moved FastDoubleBuffer to TfpgCanvasBase
* implemented FastDoubleBuffer for gdi - not tested * start of listview resiazable headers
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/gdi/gfx_gdi.pas42
-rw-r--r--src/corelib/gfxbase.pas5
-rw-r--r--src/corelib/x11/gfx_x11.pas4
3 files changed, 36 insertions, 15 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas
index 2dcade7e..de097c02 100644
--- a/src/corelib/gdi/gfx_gdi.pas
+++ b/src/corelib/gdi/gfx_gdi.pas
@@ -69,12 +69,15 @@ type
end;
+ { TfpgCanvasImpl }
+
TfpgCanvasImpl = class(TfpgCanvasBase)
private
FDrawing: boolean;
FBufferBitmap: HBitmap;
FDrawWindow: TfpgWindowImpl;
- Fgc: TfpgGContext;
+ Fgc,
+ fBufgc: TfpgGContext;
FWinGC: TfpgGContext;
FBackgroundColor: TfpgColor;
FCurFontRes: TfpgFontResourceImpl;
@@ -85,6 +88,9 @@ type
FPen: HPEN;
FClipRegion: HRGN;
FIntLineStyle: integer;
+ FBufWidth,
+ FBufHeight: Integer;
+ procedure TryFreeBackBuffer;
protected
procedure DoSetFontRes(fntres: TfpgFontResourceBase); override;
procedure DoSetTextColor(cl: TfpgColor); override;
@@ -1120,6 +1126,7 @@ destructor TfpgCanvasImpl.Destroy;
begin
if FDrawing then
DoEndDraw;
+ TryFreeBackBuffer;
inherited;
end;
@@ -1146,10 +1153,14 @@ begin
if buffered then
begin
- DoGetWinRect(ARect);
- FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, (ARect.Right-ARect.Left+1), (ARect.Bottom-ARect.Top+1));
- Fgc := CreateCompatibleDC(FWinGC);
- SelectObject(Fgc, FBufferBitmap);
+ if (FastDoubleBuffer = False) or (FBufferBitmap = 0) or (FBufWidth <> w) or (FBufHeight <> h) then begin
+ TryFreeBackBuffer;
+ DoGetWinRect(ARect);
+ FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, (ARect.Right-ARect.Left+1), (ARect.Bottom-ARect.Top+1));
+ FBufgc := CreateCompatibleDC(FWinGC);
+ Fgc := FBufgc;
+ end;
+ SelectObject(FBufgc, FBufferBitmap);
end
else
begin
@@ -1181,13 +1192,9 @@ begin
DeleteObject(FPen);
DeleteObject(FClipRegion);
- if FBufferBitmap > 0 then
- DeleteObject(FBufferBitmap);
- FBufferBitmap := 0;
-
- if Fgc <> FWinGC then
- DeleteDC(Fgc);
-
+ if FastDoubleBuffer = False then
+ TryFreeBackBuffer;
+
Windows.ReleaseDC(FDrawWindow.FWinHandle, FWingc);
FDrawing := False;
@@ -1404,6 +1411,17 @@ begin
Windows.SetTextColor(Fgc, fpgColorToWin(cl));
end;
+procedure TfpgCanvasImpl.TryFreeBackBuffer;
+begin
+ if FBufferBitmap > 0 then
+ DeleteObject(FBufferBitmap);
+ FBufferBitmap := 0;
+
+ if FBufgc > 0 then
+ DeleteDC(FBufgc);
+ FBufgc := 0;
+end;
+
procedure TfpgCanvasImpl.DoSetFontRes(fntres: TfpgFontResourceBase);
begin
if fntres = nil then
diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas
index b668277e..8ab864c7 100644
--- a/src/corelib/gfxbase.pas
+++ b/src/corelib/gfxbase.pas
@@ -217,8 +217,11 @@ type
end;
+ { TfpgCanvasBase }
+
TfpgCanvasBase = class(TObject)
private
+ FFastDoubleBuffer: Boolean;
FInterpolation: TfpgCustomInterpolation;
procedure SetInterpolation(const AValue: TfpgCustomInterpolation);
protected
@@ -293,6 +296,7 @@ type
property Font: TfpgFontBase read FFont write SetFont;
property Pixels[X, Y: integer]: TfpgColor read GetPixel write SetPixel;
property InterpolationFilter: TfpgCustomInterpolation read FInterpolation write SetInterpolation;
+ property FastDoubleBuffer: Boolean read FFastDoubleBuffer write FFastDoubleBuffer;
end;
@@ -742,6 +746,7 @@ end;
constructor TfpgCanvasBase.Create;
begin
FBufferedDraw := True;
+ FFastDoubleBuffer := True;
end;
destructor TfpgCanvasBase.Destroy;
diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas
index e26550c3..03f3c945 100644
--- a/src/corelib/x11/gfx_x11.pas
+++ b/src/corelib/x11/gfx_x11.pas
@@ -88,7 +88,6 @@ type
FDrawWindow: TfpgWindowImpl;
FBufferPixmap: TPixmap;
FDrawHandle: TXID;
- FFastDoubleBuffer: Boolean;
Fgc: TfpgGContext;
FCurFontRes: TfpgFontResourceImpl;
FClipRect: TfpgRect;
@@ -127,7 +126,7 @@ type
public
constructor Create; override;
destructor Destroy; override;
- property FastDoubleBuffer: Boolean read FFastDoubleBuffer write FFastDoubleBuffer;
+
end;
@@ -1250,7 +1249,6 @@ begin
Fgc := nil;
FXftDraw := nil;
FClipRegion := nil;
- FFastDoubleBuffer := True;
end;
destructor TfpgCanvasImpl.Destroy;