mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:20:49 +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)
|
TQtDeviceContext = class(TObject)
|
||||||
private
|
private
|
||||||
|
FPenPos: TQtPoint;
|
||||||
FOwnPainter: Boolean;
|
FOwnPainter: Boolean;
|
||||||
SelFont: TQTFont;
|
SelFont: TQTFont;
|
||||||
SelBrush: TQTBrush;
|
SelBrush: TQTBrush;
|
||||||
@ -273,6 +274,9 @@ type
|
|||||||
|
|
||||||
procedure setBrushOrigin(x, y: Integer);
|
procedure setBrushOrigin(x, y: Integer);
|
||||||
procedure brushOrigin(retval: PPoint);
|
procedure brushOrigin(retval: PPoint);
|
||||||
|
procedure getPenPos(retval: PPoint);
|
||||||
|
procedure setPenPos(x, y: Integer);
|
||||||
|
|
||||||
function font: TQtFont;
|
function font: TQtFont;
|
||||||
procedure setFont(f: TQtFont);
|
procedure setFont(f: TQtFont);
|
||||||
function brush: TQtBrush;
|
function brush: TQtBrush;
|
||||||
@ -1266,6 +1270,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
FOwnPainter := True;
|
FOwnPainter := True;
|
||||||
CreateObjects;
|
CreateObjects;
|
||||||
|
FPenPos.X := 0;
|
||||||
|
FPenPos.Y := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH);
|
constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH);
|
||||||
@ -1653,6 +1659,18 @@ begin
|
|||||||
retval^.y := QtPoint.y;
|
retval^.y := QtPoint.y;
|
||||||
end;
|
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
|
Function: TQtDeviceContext.font
|
||||||
Params: None
|
Params: None
|
||||||
|
@ -3272,7 +3272,7 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
|
function TQtWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
BrushPos: TPoint;
|
PenPos: TPoint;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI LineTo]');
|
WriteLn('[WinAPI LineTo]');
|
||||||
@ -3282,11 +3282,9 @@ begin
|
|||||||
|
|
||||||
if not IsValidDC(DC) then Exit;
|
if not IsValidDC(DC) then Exit;
|
||||||
|
|
||||||
//TODO: check this brushorigin stuff, don't smell good.
|
TQtDeviceContext(DC).getPenPos(@PenPos);
|
||||||
// replace with DC local point.
|
|
||||||
TQtDeviceContext(DC).brushOrigin(@BrushPos);
|
|
||||||
|
|
||||||
TQtDeviceContext(DC).drawLine( BrushPos.X, BrushPos.Y, X, Y);
|
TQtDeviceContext(DC).drawLine( PenPos.X, PenPos.Y, X, Y);
|
||||||
|
|
||||||
MoveToEx(DC, X, Y, nil);
|
MoveToEx(DC, X, Y, nil);
|
||||||
|
|
||||||
@ -3326,9 +3324,9 @@ begin
|
|||||||
|
|
||||||
if not IsValidDC(DC) then Exit;
|
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;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user