summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2013-05-01 12:24:44 +0100
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2013-05-01 12:24:44 +0100
commitf2be5b248a4428f03afeb80392e12326e857715a (patch)
treefdff437047bb866dbfd21cde0c2026be8e09edfb /src/corelib
parentc27a9a98b41a0de20787f29375c63cb35029ad35 (diff)
downloadfpGUI-f2be5b248a4428f03afeb80392e12326e857715a.tar.xz
Adds much faster Canvas.CopyRect() implemenation for the GDI backend.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_base.pas2
-rw-r--r--src/corelib/gdi/fpg_gdi.pas22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index aecd3b08..ae55637b 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -389,7 +389,7 @@ type
procedure DrawPolygon(Points: PPoint; NumPts: Integer; Winding: boolean = False); virtual;
procedure DrawPolygon(const Points: array of TPoint);
procedure StretchDraw (x, y, w, h: TfpgCoord; ASource: TfpgImageBase);
- procedure CopyRect(ADest_x, ADest_y: TfpgCoord; ASrcCanvas: TfpgCanvasBase; var ASrcRect: TfpgRect);
+ procedure CopyRect(ADest_x, ADest_y: TfpgCoord; ASrcCanvas: TfpgCanvasBase; var ASrcRect: TfpgRect); virtual;
// x,y is the top/left corner of where the text output will start.
procedure DrawString(x, y: TfpgCoord; const txt: string);
procedure FillRectangle(x, y, w, h: TfpgCoord); overload;
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas
index abeecbca..c8460a4c 100644
--- a/src/corelib/gdi/fpg_gdi.pas
+++ b/src/corelib/gdi/fpg_gdi.pas
@@ -147,6 +147,7 @@ type
public
constructor Create(awin: TfpgWindowBase); override;
destructor Destroy; override;
+ procedure CopyRect(ADest_x, ADest_y: TfpgCoord; ASrcCanvas: TfpgCanvasBase; var ASrcRect: TfpgRect); override;
end;
@@ -2131,6 +2132,27 @@ begin
inherited;
end;
+procedure TfpgGDICanvas.CopyRect(ADest_x, ADest_y: TfpgCoord; ASrcCanvas: TfpgCanvasBase;
+ var ASrcRect: TfpgRect);
+var
+ srcdc: HDC;
+ destdc: HDC;
+begin
+ if (TfpgWindow(FWindow).WinHandle <= 0) or (TfpgWindow(TfpgGDICanvas(ASrcCanvas).FWindow).WinHandle <= 0) then
+ begin
+ debugln(' no winhandle available');
+ exit;
+ end;
+
+ destdc := Windows.GetDC(TfpgWindow(FWindow).WinHandle);
+ srcdc := Windows.GetDC(TfpgWindow(TfpgGDICanvas(ASrcCanvas).FWindow).WinHandle);
+
+ BitBlt(destdc, ADest_x, ADest_y, ASrcRect.Width, ASrcRect.Height, srcdc, ASrcRect.Left, ASrcRect.Top, SRCCOPY);
+
+ ReleaseDC(TfpgWindow(TfpgGDICanvas(ASrcCanvas).FWindow).WinHandle, srcdc);
+ ReleaseDC(TfpgWindow(FWindow).WinHandle, destdc);
+end;
+
procedure TfpgGDICanvas.DoBeginDraw(awin: TfpgWindowBase; buffered: boolean);
var
ARect: TfpgRect;