Re: Quickest Drawing Method
Re: Quickest Drawing Method
- Subject: Re: Quickest Drawing Method
- From: arri <email@hidden>
- Date: Fri, 27 Jul 2007 03:38:47 +0200
On Jul 25, 2007, at 2:33 AM, spiderlama wrote:
...I think it can't get any faster...
it can!
i was struggling with a similair performance issue,
but after some experiments i've come to very promising results;
my approach at this point is;
- create a tiny bitmap (CGBitmapContext) that containst all elements
needed to draw the 'big image'
- from that image, create tiles (corners, borders body etc..) and
cache those as CGLayers
the docs teach us that those are actually cached on the graphics-card
where approreate/needed/possible..
- in the drawrect:-routine, check what needs to be drawn, and draw
only that.
right now i'm just using NSViews' needsToDrawRect: to check for only
9 areas;
the corners (4), borders (4) and the body/fill.
and then i simply draw (if/as needed)
the corner-tiles on a 1:1 scale,
the border-tiles streched to fill whatever area needs to be filled,
and same for the body.
i guess this could be further improved using NSViews'
getRectsBeingDrawn:count:
but this is already blazing fast. i'm happy :)
i suspect that these CGLayers actually did the trick..
i didn't profile with shark, but my home-made fps-counter showed an
improvement of around 300%,
and memory consumption is not even worth mentioning anymore...
On Jul 22, 2007, at 4:52 PM, Alan Smith wrote:
Spider,
Instead of using images which you composite together and draw every
time I would suggest using a NSBezierPath as a clipping path and
filling it with a semi-transparent color for the dock background or,
whatever you want. That should be faster than compositing images and
drawing them, it will certainly be more memory efficient. Not to
mention being much more simple.
i might be wrong, please tell me if i am (i'm not exactly an expert..),
but i find it a very strange idea that 'rendering' vectors (into
bitmaps),
and then using those for compositing,
would be faster than just copying exisiting bitmap-data around.
especially when that bitmap data can be cached in hardware,
and even more when this compositing, and btw. also scaling can all be
done on the GPU.
i don't believe NSBezierpaths can benefit from hardware acceleration..
€.02
.a_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden