LCL-CustomDrawn-X11: Buffer all invalidate calls and execute at most one per form per event

git-svn-id: trunk@36065 -
This commit is contained in:
sekelsenmat 2012-03-16 06:47:45 +00:00
parent cd63f40bc8
commit 2e54dd5e2e
7 changed files with 33 additions and 6 deletions

View File

@ -46,10 +46,10 @@
// This option makes the drawing faster by buffering previous drawing operations // This option makes the drawing faster by buffering previous drawing operations
{$define CD_BufferControlImages} // for all wincontrols except the form {$define CD_BufferControlImages} // for all wincontrols except the form
//{$define CD_BufferFormImage} // for the form itself (excluding child wincontrols) { $define CD_BufferFormImage} // for the form itself (excluding child wincontrols)
// ================== // ==================
// Debug options // Debug options
// ================== // ==================
//{$define VerboseCDPaintProfiler} {$define VerboseCDPaintProfiler}

View File

@ -164,6 +164,7 @@ type
function FindWindowByXID(XWindowID: X.TWindow; out AWindowInfo: TX11WindowInfo): TWinControl; function FindWindowByXID(XWindowID: X.TWindow; out AWindowInfo: TX11WindowInfo): TWinControl;
procedure AppProcessMessage; procedure AppProcessMessage;
procedure AppProcessInvalidates;
{$endif} {$endif}
{$ifdef CD_Android} {$ifdef CD_Android}
CombiningAccent: Cardinal; CombiningAccent: Cardinal;

View File

@ -126,7 +126,7 @@ begin
BackendDestroy; BackendDestroy;
{$ifndef CD_UseNativeText} {$ifndef CD_UseNativeText}
TT_Done_FreeType; //TT_Done_FreeType; Causes crashes =( Uncomment when bug 21470 is fixed
FFontPaths.Free; FFontPaths.Free;
FFontList.Free; FFontList.Free;
{$endif} {$endif}

View File

@ -288,7 +288,8 @@ procedure TCDWidgetSet.AppProcessMessages;
begin begin
while True do while True do
begin begin
if XPending(FDisplay) <= 0 then Exit; // There are no more X messages to process // There are no more X messages to process
if XPending(FDisplay) <= 0 then Exit;
AppProcessMessage(); AppProcessMessage();
end; end;
end; end;
@ -395,6 +396,27 @@ begin
DebugLn('LCL-CustomDrawn-X11: Unhandled X11 event received: ', GetXEventName(XEvent._type)); DebugLn('LCL-CustomDrawn-X11: Unhandled X11 event received: ', GetXEventName(XEvent._type));
end; end;
AppProcessInvalidates();
end;
end;
procedure TCDWidgetSet.AppProcessInvalidates;
var
i: Integer;
CurWindowInfo: TX11WindowInfo;
lForm: TForm;
begin
for i := 0 to Screen.FormCount-1 do
begin
lForm := Screen.Forms[i];
if (not lForm.HandleObjectShouldBeVisible) or
(not lForm.HandleAllocated) then Continue;
CurWindowInfo := TX11WindowInfo(Screen.Forms[i].Handle);
if CurWindowInfo.InvalidateRequestedInAnyControl then
begin
TCDWSCustomForm.EvPaint(lForm, CurWindowInfo);
CurWindowInfo.InvalidateRequestedInAnyControl := False;
end;
end; end;
end; end;
@ -490,6 +512,7 @@ begin
if lTimer.NativeHandle >= lTimer.Interval then if lTimer.NativeHandle >= lTimer.Interval then
begin begin
lTimer.TimerFunc(); lTimer.TimerFunc();
AppProcessInvalidates();
lTimer.NativeHandle := 0; lTimer.NativeHandle := 0;
end; end;
end; end;

View File

@ -80,6 +80,7 @@ type
FocusedControl: TWinControl; // The control focused in the form FocusedControl: TWinControl; // The control focused in the form
FocusedIntfControl: TWinControl; // The intf control focused in the form FocusedIntfControl: TWinControl; // The intf control focused in the form
LayoutAutoAdjusted: Boolean; // Indicates if the form layout was already auto-adjusted once LayoutAutoAdjusted: Boolean; // Indicates if the form layout was already auto-adjusted once
InvalidateRequestedInAnyControl: Boolean;
// painting objects which represent the composed form image, don't confuse with ControlImage/ControlCanvas // painting objects which represent the composed form image, don't confuse with ControlImage/ControlCanvas
Image: TLazIntfImage; Image: TLazIntfImage;
Canvas: TLazCanvas; Canvas: TLazCanvas;

View File

@ -631,7 +631,8 @@ begin
end;*) end;*)
{$ifndef CD_UseNativeText} {$ifndef CD_UseNativeText}
procedure TCDWidgetSet.BackendListFontPaths(var AFontPaths: TStringList; var AFontList: THashedStringList); procedure TCDWidgetSet.BackendListFontPaths(var AFontPaths: TStringList;
var AFontList: THashedStringList);
var var
Doc: TXMLDocument; Doc: TXMLDocument;
lFontDirectories: TStringList; lFontDirectories: TStringList;
@ -4651,7 +4652,7 @@ var
lFormHandle: TX11WindowInfo; lFormHandle: TX11WindowInfo;
begin begin
lFormHandle := TX11WindowInfo(AHandle); lFormHandle := TX11WindowInfo(AHandle);
TCDWSCustomForm.EvPaint(lFormHandle.LCLForm, lFormHandle); lFormHandle.InvalidateRequestedInAnyControl := True;
Result := True; Result := True;
end; end;

View File

@ -696,6 +696,7 @@ begin
//SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN, SIZEZOOMSHOW, SIZEZOOMHIDE. //SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN, SIZEZOOMSHOW, SIZEZOOMHIDE.
LCLSendSizeMsg(AWinControl, Event.Width, Event.Height, SIZENORMAL); LCLSendSizeMsg(AWinControl, Event.Width, Event.Height, SIZENORMAL);
AWinControl.Invalidate;
// TX11Canvas(Canvas).Resized(ClientWidth, ClientHeight); seams unnecessary here // TX11Canvas(Canvas).Resized(ClientWidth, ClientHeight); seams unnecessary here
end; end;
end; end;