osx - Multiple calls to drawRect: in a content view of NSScrollView -
i designing quartz composer-like interface, user can connect nodes wires. nodes subclasses of nsview
, wires drawn nsbezierpaths
on canvas (also subclass of nsview), in -drawrect:
. canvas placed within nsscrollview
.
i facing issue canvas view redraw. when canvas view needs redrawn ( -setneedsdisplay:
or -setneedsdisplayinrect:
), there several calls -drawrect:
beingness made, instead of single one, 1 expect. slows downwards redrawing of canvas significantly. i've done quite optimization of drawing of bezier paths, still multiple redraw thing killing performance (as paths still need blitted screen least).
here's log of nsrect
s coming in -drawrect:
, after single -setneedsdisplayinrect:
phone call :
origin: 245.783616, 410.382009; size: 740.000000, 813.000000 origin: 768.000000, 410.000000; size: 218.000000, 102.000000 origin: 512.000000, 410.000000; size: 256.000000, 102.000000 origin: 256.000000, 410.000000; size: 256.000000, 102.000000 origin: 245.000000, 410.000000; size: 11.000000, 102.000000
740 813 (first update) actual size of viewport, have no thought rest of updates coming from, nor can create sense out of sizes , locations (in fact, of rectangles overlapping).
i have since checked , double checked code, , there no redundant calls drawing functions, single phone call -setneedsdisplayinrect:
.
here questions:
why happening?
i'd alter behaviour, have 1 update per call. how can accomplish this?
or, least, there way know when "group" of these updates begin (so more efficiently plan drawing)?
any alternative strategies/suggestions deal more welcome.
thanks
osx cocoa drawrect nsscrollview
No comments:
Post a Comment