0
votes

A TCanvasGPU is used for mobile platforms on FireMonkey. Unfortunately, as someone discovered: FMX on iOS: how to perform partial invalidation? , this canvas does not support cliprects and Canvas.InvalidateRect(TRectF) always invalidates the whole canvas.

This wouldn't be so bad, except that the canvas background is always erased before an OnPaint event. Which means any attempt to update just a rectangle in an OnPaint is doomed, as the whole area is cleared first. So even the smallest update requires the entire canvas be drawn.

Does anyone know if it's possible to stop a control (specifically TPaintBox) background being erased in FireMonkey? It used to be possible in VCL by setting ControlStyle := ControlStyle + [csOpaque].

I found TCustomForm.PaintBackground in FMX.Forms, made a local copy and commented out the call to this in TCustomForm.PaintRects, thinking it would stop controls being erased, but the TPaintBox canvas still got cleared somehow.

1

1 Answers

0
votes

To answer my own question...

TForm by default is styled to include a TRectangle as the first component, and this is filled with light gray in any paint event.

On commenting out this fill in FMX.Objects.TRectangle.Paint sure enough, on Windows, the TPaintBox Canvas retains its image on any Invalidate.

Unfortunately on Android, the screen now just clears to black instead of light gray. So it seems the TCanvasGPU image is not maintained between paint events on mobile, which is probably why cliprects are not supported.