From 2e54dd5e2eebeb1dcaeabd67707e8b14bdce08db Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Fri, 16 Mar 2012 06:47:45 +0000 Subject: [PATCH] LCL-CustomDrawn-X11: Buffer all invalidate calls and execute at most one per form per event git-svn-id: trunk@36065 - --- .../customdrawn/customdrawndefines.inc | 4 +-- lcl/interfaces/customdrawn/customdrawnint.pas | 1 + .../customdrawn/customdrawnobject.inc | 2 +- .../customdrawn/customdrawnobject_x11.inc | 25 ++++++++++++++++++- .../customdrawn/customdrawnproc.pas | 1 + .../customdrawn/customdrawnwinapi_x11.inc | 5 ++-- .../customdrawn/customdrawnwsforms_x11.inc | 1 + 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/customdrawn/customdrawndefines.inc b/lcl/interfaces/customdrawn/customdrawndefines.inc index feba39857d..e7467d628d 100644 --- a/lcl/interfaces/customdrawn/customdrawndefines.inc +++ b/lcl/interfaces/customdrawn/customdrawndefines.inc @@ -46,10 +46,10 @@ // This option makes the drawing faster by buffering previous drawing operations {$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 // ================== -//{$define VerboseCDPaintProfiler} +{$define VerboseCDPaintProfiler} diff --git a/lcl/interfaces/customdrawn/customdrawnint.pas b/lcl/interfaces/customdrawn/customdrawnint.pas index b74562c1aa..20a7e405ee 100644 --- a/lcl/interfaces/customdrawn/customdrawnint.pas +++ b/lcl/interfaces/customdrawn/customdrawnint.pas @@ -164,6 +164,7 @@ type function FindWindowByXID(XWindowID: X.TWindow; out AWindowInfo: TX11WindowInfo): TWinControl; procedure AppProcessMessage; + procedure AppProcessInvalidates; {$endif} {$ifdef CD_Android} CombiningAccent: Cardinal; diff --git a/lcl/interfaces/customdrawn/customdrawnobject.inc b/lcl/interfaces/customdrawn/customdrawnobject.inc index ae65a7291a..8902b53f65 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject.inc @@ -126,7 +126,7 @@ begin BackendDestroy; {$ifndef CD_UseNativeText} - TT_Done_FreeType; + //TT_Done_FreeType; Causes crashes =( Uncomment when bug 21470 is fixed FFontPaths.Free; FFontList.Free; {$endif} diff --git a/lcl/interfaces/customdrawn/customdrawnobject_x11.inc b/lcl/interfaces/customdrawn/customdrawnobject_x11.inc index 9e74404038..bf6cf14fc6 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_x11.inc @@ -288,7 +288,8 @@ procedure TCDWidgetSet.AppProcessMessages; begin while True do 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(); end; end; @@ -395,6 +396,27 @@ begin DebugLn('LCL-CustomDrawn-X11: Unhandled X11 event received: ', GetXEventName(XEvent._type)); 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; @@ -490,6 +512,7 @@ begin if lTimer.NativeHandle >= lTimer.Interval then begin lTimer.TimerFunc(); + AppProcessInvalidates(); lTimer.NativeHandle := 0; end; end; diff --git a/lcl/interfaces/customdrawn/customdrawnproc.pas b/lcl/interfaces/customdrawn/customdrawnproc.pas index 21eefb53be..fc9683cb05 100644 --- a/lcl/interfaces/customdrawn/customdrawnproc.pas +++ b/lcl/interfaces/customdrawn/customdrawnproc.pas @@ -80,6 +80,7 @@ type FocusedControl: TWinControl; // The 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 + InvalidateRequestedInAnyControl: Boolean; // painting objects which represent the composed form image, don't confuse with ControlImage/ControlCanvas Image: TLazIntfImage; Canvas: TLazCanvas; diff --git a/lcl/interfaces/customdrawn/customdrawnwinapi_x11.inc b/lcl/interfaces/customdrawn/customdrawnwinapi_x11.inc index 0a7615688a..c66740b64c 100644 --- a/lcl/interfaces/customdrawn/customdrawnwinapi_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnwinapi_x11.inc @@ -631,7 +631,8 @@ begin end;*) {$ifndef CD_UseNativeText} -procedure TCDWidgetSet.BackendListFontPaths(var AFontPaths: TStringList; var AFontList: THashedStringList); +procedure TCDWidgetSet.BackendListFontPaths(var AFontPaths: TStringList; + var AFontList: THashedStringList); var Doc: TXMLDocument; lFontDirectories: TStringList; @@ -4651,7 +4652,7 @@ var lFormHandle: TX11WindowInfo; begin lFormHandle := TX11WindowInfo(AHandle); - TCDWSCustomForm.EvPaint(lFormHandle.LCLForm, lFormHandle); + lFormHandle.InvalidateRequestedInAnyControl := True; Result := True; end; diff --git a/lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc b/lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc index f18b026ed5..ac16de37f8 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc +++ b/lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc @@ -696,6 +696,7 @@ begin //SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN, SIZEZOOMSHOW, SIZEZOOMHIDE. LCLSendSizeMsg(AWinControl, Event.Width, Event.Height, SIZENORMAL); + AWinControl.Invalidate; // TX11Canvas(Canvas).Resized(ClientWidth, ClientHeight); seams unnecessary here end; end;