Recent

Author Topic: What I've found about slowdown of CudaText rendering (qt5 now)  (Read 3459 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
What I've found about slowdown of CudaText rendering (qt5 now)
« on: January 30, 2021, 08:50:34 am »
https://github.com/Alexey-T/CudaText/issues/3089

Quote
I found that scale of window by X (800x600 -> 1800x600) don't slow down the rendering.
scale of window by Y (800x600 -> 800x1200) DOES slow down (600->1200, slower by 2 times).
so the reason is: Canvas.TextOut (or LCLIntf.ExtTextOut) is slowing down all render.
I also see that debugger stops inside the ExtTextOut (most of the time, in 80%).

I cannot solve it, TextOut (ExtTextOut) on linux is not known code to me.

the same slowdown occurs on gtk2 and qt5.
so it is mostly Lazarus issue of gtk2/qt5 codes.

balazsszekely

  • Guest
Re: What I've found about slowdown of CudaText rendering (qt5 now)
« Reply #1 on: January 30, 2021, 10:04:05 am »
Hi Alextp,

Why don't you use DrawText from LCLIntf? It has a lot more options then Canvas.TextOut and it works well in every widgetset(see: VirtualTreeView, OPM, etc...).
Here is a quick example:
Code: Pascal  [Select][+][-]
  1. uses LCLIntf, LCLType;
  2.  
  3. procedure TForm1.FormPaint(Sender: TObject);
  4. var
  5.   Txt: String;
  6.   R: TRect;
  7. begin
  8.   Txt := 'Cudatext editor';
  9.   R := ClientRect;
  10.   Self.Canvas.Brush.Style := bsClear;
  11.   DrawText(Self.Canvas.Handle, PChar(Txt), Length(Txt), R, DT_SINGLELINE or DT_CENTER or DT_VCENTER);
  12. end;
« Last Edit: January 30, 2021, 10:11:58 am by GetMem »

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: What I've found about slowdown of CudaText rendering (qt5 now)
« Reply #2 on: January 30, 2021, 10:16:57 am »
Why don't you use DrawText from LCLIntf? It has a lot more options then Canvas.TextOut and it works well in every widgetset(see: VirtualTreeView, OPM, etc...).
It's been a while since I tested DrawText's performance but, the last time I tested it (probably under XP), its performance was downright dismal.  In general, TextOut and ExtTextOut provide much better performance even when custom user code has to replicate some of the DrawText features.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: What I've found about slowdown of CudaText rendering (qt5 now)
« Reply #3 on: January 30, 2021, 10:30:13 am »
Quote
  DrawText(Self.Canvas.Handle, PChar(Txt), Length(Txt), R, DT_SINGLELINE or DT_CENTER or DT_VCENTER);

I need the Dx array of char offsets; DrawText isn't allowing it..

balazsszekely

  • Guest
Re: What I've found about slowdown of CudaText rendering (qt5 now)
« Reply #4 on: January 30, 2021, 10:44:55 am »
@440bx
Quote
It's been a while since I tested DrawText's performance but, the last time I tested it (probably under XP), its performance was downright dismal.  In general, TextOut and ExtTextOut provide much better performance even when custom user code has to replicate some of the DrawText features.
Fair enough. I did not run any performance test myself, but according to the documentation, the speed depends on the text type. Drawing multiline text should be faster with DrawText(at least on windows). Please see this: https://docs.microsoft.com/en-us/windows/win32/gdi/drawing-text


@Alextp
Quote
I need the Dx array of char offsets; DrawText isn't allowing it..
Can you please give an example where TextOut works and DrawText fails?
« Last Edit: January 30, 2021, 11:01:20 am by GetMem »

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: What I've found about slowdown of CudaText rendering (qt5 now)
« Reply #5 on: January 30, 2021, 12:43:37 pm »
Yes. Example is CudaText: it needs to output Emoji and some unicode, via special char offsets: by the option.


 

TinyPortal © 2005-2018