mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 04:39:36 +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,
|
||||
GtkExtra, GtkDef;
|
||||
|
||||
//paul: this improvement brings an issue: 0011523
|
||||
{off $define gtk2_improve_TextOut_speed}
|
||||
|
||||
type
|
||||
|
||||
{$ifdef gtk2_improve_TextOut_speed}
|
||||
TSetTextArgs = record
|
||||
Font: PPangoLayout;
|
||||
Len: LongInt;
|
||||
Text: array of char;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{ TGtk2DeviceContext }
|
||||
|
||||
TGtk2DeviceContext = class(TGtkDeviceContext)
|
||||
private
|
||||
{$ifdef gtk2_improve_TextOut_speed}
|
||||
OldText: TSetTextArgs;
|
||||
{$endif}
|
||||
protected
|
||||
function GetFunction: TGdkFunction; override;
|
||||
public
|
||||
@ -57,7 +62,6 @@ type
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$i gtk2devicecontext.inc}
|
||||
|
||||
end.
|
||||
|
@ -34,19 +34,25 @@ end;
|
||||
constructor TGtk2DeviceContext.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
{$ifdef gtk2_improve_TextOut_speed}
|
||||
FillChar(OldText, SizeOf(OldText), 0);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TGtk2DeviceContext.SetText(AFont: PPangoLayout; AText: PChar; ALength: LongInt);
|
||||
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
|
||||
pango_layout_set_text(AFont, AText, ALength);
|
||||
OldText.Font := AFont;
|
||||
OldText.Len := ALength;
|
||||
SetLength(OldText.Text, ALength);
|
||||
Move(AText^, OldText.Text[0], ALength);
|
||||
Move(AText^, PChar(OldText.Text)^, ALength);
|
||||
end;
|
||||
{$else}
|
||||
pango_layout_set_text(AFont, AText, ALength);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TGtk2DeviceContext.DrawTextWithColors(AText: PChar; ALength: LongInt;
|
||||
|
Loading…
Reference in New Issue
Block a user