Sunday, 15 August 2010

delphi - How can I access TCanvas.ClipRect? -



delphi - How can I access TCanvas.ClipRect? -

i'm trying port code delphi firemonkey (xe6).

i've run problem function draws tcanvas supplied caller. canvas tpaintbox, tpanel, tform or tbitmap. function reads tcanvas.cliprect property avoid doing cpu-intensive drawing outside of it. (the cliprect represents invalidated areas of tform, tpaintbox etc.)

unfortunately tcanvas cliprect property no longer seems exist. know how can access tcanvas.cliprect in firemonkey? did notice tpaintbox , tpanel have cliprect property, maybe utilize those, tform , tbitmap don't.

please note, i'm not trying create or alter cliprect in canvas, i'm trying read it.

the dobeginscene has parameter cliprects. there doesn't seem way retrieve value. in add-on there might additional clipping on canvas.

in order clip rects, need dc or cgcontext of canvas. using rtti. here's illustration osx:

function tcanvaschelper.getcgcontext: cgcontextref; var context: trtticontext; field: trttifield; begin // needs 1ms field := context.gettype(tcanvasquartz).getfield('fcontext'); // private field using rtti assert(field <> nil); result := ppointer(field.getvalue(self).getreferencetorawdata)^; end;

unfortunately using rtti might not fast required. ended having create re-create of fmx.canvas.* classes expose cgcontext or dc. you'll need anyway if want more advanced things canvas fmx not implement.

when have cgcontext or dc, can utilize functions of os cgcontextgetclipboundingbox or getclipbox retrieve cliprects if canvas supports them.

delphi firemonkey

No comments:

Post a Comment