On Oct 11, 2007, at 10:34 AM, Giuliano Colla wrote:

If Lazarus is intended to be Delphi compatible, Delphi provides for Tcontrol descendants (and also for a number of other of visual objects not descending from TControl, such as TPanel) an Invalidate method which, according the manuals "completely repaints the control" providing a flicker free update of the control, if multiple regions must be repainted simultaneously. Always according the manual, "there's no performance penalty for calling invalidate multiple times before the control is actually repainted".
Could this be an answer to the question?

Giuliano

Hi Giuliano

The Carbon Lazarus works great with invalidate and the OnPaint events, as far as I've been able to tell. Mac double-buffering on the screen well-guarantees no flicker. And it is true that invalidate can be called multiple times before the event loop gets around to calling OnPaint.

But there is an expense with the double-buffering and 'delayed flush'-- Sometimes this circuitous route involving many messages, can cause 'slightly slow' screen updates. If an OnPaint does a lot of drawing and calculating (which sometimes can't be done in advance), the new screen draw appears very quick and clean onscreen, but there is some latency where nothing happens on the screen, before this quick clean change suddenly appears.

The Delphi/Lazarus Invalidate/OnPaint mechanism works great, but there are some cases where a more direct screen draw would be desirable.

In the very old Mac days with quickdraw, for instance to track a mouse-drag region-hilite, one might 'short circuit' the message loop. Enter a 'while mousedown do' loop, which polls mouse position and draws a marching-ants rectangle until the user releases the mouse button. Nasty stuff which Apple recommends against nowadays, but the screen response was quick and clean.

I'm not advocating that such nasty things would be good to use in Lazarus, but a faster way to get the screen to change could be useful.

That LCL TCanvas.AutoRedraw property looks 'barely wired in' at the moment. I don't know the original intention of that property.

If the intention of TCanvas.AutoRedraw would be to tell a canvas to automatically flush after every draw operation, then that might suffice for cases where immediate drawing is needed. In other words, one could leave AutoRedraw = False in most ordinary cases, but for situations where immediate screen flush is desirable, one might use code like this:

procedure ThePaintBoxMouseMove(...);
begin
ThePaintBox.Canvas.AutoRedraw := True;
ThePaintBox.Canvas.MoveTo(x0, y0);
ThePaintBox.Canvas.LineTo(x1, y1);
//with AutoRedraw turned on, the canvas would call CGContextFlush() after LineTo
ThePaintBox.Canvas.AutoRedraw := False;

Its just an idea. Maybe there are much better ideas.

jcjr

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to