mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:59:20 +02:00
gtk2: ifdef textout speed improvement - it brings some problems (#0011523)
git-svn-id: trunk@15735 -
This commit is contained in:
parent
c6197e81fe
commit
012a16ffd7
@ -34,20 +34,25 @@ uses
|
|||||||
glib2, gdk2pixbuf, pango, gdk2, gtk2,
|
glib2, gdk2pixbuf, pango, gdk2, gtk2,
|
||||||
GtkExtra, GtkDef;
|
GtkExtra, GtkDef;
|
||||||
|
|
||||||
|
//paul: this improvement brings an issue: 0011523
|
||||||
|
{off $define gtk2_improve_TextOut_speed}
|
||||||
|
|
||||||
type
|
type
|
||||||
|
{$ifdef gtk2_improve_TextOut_speed}
|
||||||
TSetTextArgs = record
|
TSetTextArgs = record
|
||||||
Font: PPangoLayout;
|
Font: PPangoLayout;
|
||||||
Len: LongInt;
|
Len: LongInt;
|
||||||
Text: array of char;
|
Text: array of char;
|
||||||
end;
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{ TGtk2DeviceContext }
|
{ TGtk2DeviceContext }
|
||||||
|
|
||||||
TGtk2DeviceContext = class(TGtkDeviceContext)
|
TGtk2DeviceContext = class(TGtkDeviceContext)
|
||||||
private
|
private
|
||||||
|
{$ifdef gtk2_improve_TextOut_speed}
|
||||||
OldText: TSetTextArgs;
|
OldText: TSetTextArgs;
|
||||||
|
{$endif}
|
||||||
protected
|
protected
|
||||||
function GetFunction: TGdkFunction; override;
|
function GetFunction: TGdkFunction; override;
|
||||||
public
|
public
|
||||||
@ -57,7 +62,6 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$i gtk2devicecontext.inc}
|
{$i gtk2devicecontext.inc}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -34,19 +34,25 @@ end;
|
|||||||
constructor TGtk2DeviceContext.Create;
|
constructor TGtk2DeviceContext.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
{$ifdef gtk2_improve_TextOut_speed}
|
||||||
FillChar(OldText, SizeOf(OldText), 0);
|
FillChar(OldText, SizeOf(OldText), 0);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk2DeviceContext.SetText(AFont: PPangoLayout; AText: PChar; ALength: LongInt);
|
procedure TGtk2DeviceContext.SetText(AFont: PPangoLayout; AText: PChar; ALength: LongInt);
|
||||||
begin
|
begin
|
||||||
if (OldText.Font <> AFont) or (OldText.Len <> ALength) or (CompareChar(AText^, OldText.Text[0], ALength) <> 0) then
|
{$ifdef gtk2_improve_TextOut_speed}
|
||||||
|
if (OldText.Font <> AFont) or (OldText.Len <> ALength) or (CompareChar(AText^, PChar(OldText.Text)^, ALength) <> 0) then
|
||||||
begin
|
begin
|
||||||
pango_layout_set_text(AFont, AText, ALength);
|
pango_layout_set_text(AFont, AText, ALength);
|
||||||
OldText.Font := AFont;
|
OldText.Font := AFont;
|
||||||
OldText.Len := ALength;
|
OldText.Len := ALength;
|
||||||
SetLength(OldText.Text, ALength);
|
SetLength(OldText.Text, ALength);
|
||||||
Move(AText^, OldText.Text[0], ALength);
|
Move(AText^, PChar(OldText.Text)^, ALength);
|
||||||
end;
|
end;
|
||||||
|
{$else}
|
||||||
|
pango_layout_set_text(AFont, AText, ALength);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk2DeviceContext.DrawTextWithColors(AText: PChar; ALength: LongInt;
|
procedure TGtk2DeviceContext.DrawTextWithColors(AText: PChar; ALength: LongInt;
|
||||||
|
Loading…
Reference in New Issue
Block a user