mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 09:40:21 +02:00
(Qt): Use local DC point instead of brushOrigin for pen operations, it's cheaper then brushOrigin() & setBrushOrigin() and possibly better solution.
git-svn-id: trunk@12096 -
This commit is contained in:
parent
854be67841
commit
fb0e89d0ad
@ -226,6 +226,7 @@ type
|
||||
|
||||
TQtDeviceContext = class(TObject)
|
||||
private
|
||||
FPenPos: TQtPoint;
|
||||
FOwnPainter: Boolean;
|
||||
SelFont: TQTFont;
|
||||
SelBrush: TQTBrush;
|
||||
@ -273,6 +274,9 @@ type
|
||||
|
||||
procedure setBrushOrigin(x, y: Integer);
|
||||
procedure brushOrigin(retval: PPoint);
|
||||
procedure getPenPos(retval: PPoint);
|
||||
procedure setPenPos(x, y: Integer);
|
||||
|
||||
function font: TQtFont;
|
||||
procedure setFont(f: TQtFont);
|
||||
function brush: TQtBrush;
|
||||
@ -1266,6 +1270,8 @@ begin
|
||||
end;
|
||||
FOwnPainter := True;
|
||||
CreateObjects;
|
||||
FPenPos.X := 0;
|
||||
FPenPos.Y := 0;
|
||||
end;
|
||||
|
||||
constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH);
|
||||
@ -1653,6 +1659,18 @@ begin
|
||||
retval^.y := QtPoint.y;
|
||||
end;
|
||||
|
||||
procedure TQtDeviceContext.getPenPos(retval: PPoint);
|
||||
begin
|
||||
retval^.x := FPenPos.x;
|
||||
retval^.y := FPenPos.y;
|
||||
end;
|
||||
|
||||
procedure TQtDeviceContext.setPenPos(x, y: Integer);
|
||||
begin
|
||||
FPenPos.X := x;
|
||||
FPenPos.Y := y;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtDeviceContext.font
|
||||
Params: None
|
||||
|
@ -3272,7 +3272,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
|
||||
var
|
||||
BrushPos: TPoint;
|
||||
PenPos: TPoint;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('[WinAPI LineTo]');
|
||||
@ -3282,11 +3282,9 @@ begin
|
||||
|
||||
if not IsValidDC(DC) then Exit;
|
||||
|
||||
//TODO: check this brushorigin stuff, don't smell good.
|
||||
// replace with DC local point.
|
||||
TQtDeviceContext(DC).brushOrigin(@BrushPos);
|
||||
TQtDeviceContext(DC).getPenPos(@PenPos);
|
||||
|
||||
TQtDeviceContext(DC).drawLine( BrushPos.X, BrushPos.Y, X, Y);
|
||||
TQtDeviceContext(DC).drawLine( PenPos.X, PenPos.Y, X, Y);
|
||||
|
||||
MoveToEx(DC, X, Y, nil);
|
||||
|
||||
@ -3326,9 +3324,9 @@ begin
|
||||
|
||||
if not IsValidDC(DC) then Exit;
|
||||
|
||||
if (OldPoint <> nil) then TQtDeviceContext(DC).brushOrigin(OldPoint);
|
||||
if (OldPoint <> nil) then TQtDeviceContext(DC).getPenPos(OldPoint);
|
||||
|
||||
TQtDeviceContext(DC).setBrushOrigin(X, Y);
|
||||
TQtDeviceContext(DC).setPenPos(X, Y);
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user