[Lazarus] Smooth scrolling label (marquee)
Luca Olivetti
luca at wetron.es
Tue Nov 10 17:43:32 CET 2015
El 10/11/15 a les 16:55, Graeme Geldenhuys ha escrit:
> On 2015-11-10 12:28, Luca Olivetti wrote:
>> I guess codebot needs a newer fpc, it doesn't compile with 2.6.4.
>
> You can also take a look at AggPas, which can easily accomplish what you
> ask for - with out 0-1% CPU load (tested previously on my system).
> Lazarus includes a copy of AggPas as standard.
>
> Here are some examples to show you smoothness - and even warped text on
> a bezier curve.
>
> http://crossgl.com/aggpas/aggpas-demo.htm
>
> Take a look at the Trans_curve1.exe and Trans_curev2.exe example
> executables (if you have Windows).
Impressive, but I looked at the source and it uses its own kind of
application.
Anyway, I don't think that cpu is the limiting factor, the application
loop is.
Let me explain: I modified the application so that, instead of a big
background bitmap that needs to be redrawn every time the text moves, I
have two, the big one and a smaller one just where the scrolling label
is (I used BGRABitmap to split the previous one in two).
I then used a thread with a simple loop
while not terminated do
begin
sleep(FOwner.FScrollRefresh);
Synchronize(@SyncTimer);
end;
where synctimer just updates the offset and invalidates the label so
that it redraws itself.
On a virtualized windows xp I can use FScrollRefresh of 1 and it scrolls
very fast and the application is responsive.
On a real hardware windows 7 (in theory much more powerful) or a
virtualized one, not only the refresh cycle is much longer (I suppose
the limiting factor is the rate of the CheckSynchronize calls from the
main thread), but it cannot cope with the other messages (i.e., I update
a clock with a timer, but it doesn't update, it doesn't react once I
clicked on the button to confirm exit, etc.).
Before I thought it was cpu bound (since it had to repaint the whole
screen), but now that it only repaints 10% it works exactly the same.
The strange thing is, it seems to work fine (albeit not at the rate it
works under xp) if I start it as wsNormal (the application should be
wsFullScreen and BorderStyle bsNone).
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007
More information about the Lazarus
mailing list