I would like to create a custom NSView that takes a layered approach to painting. I imagine the majority of the layers would be the same width and height as the backing view.
Is it appropriate to use the Core Animation classes like CALayer for this task, even though I don't expect to need much animation? Is there a more appropriate approach?
To clarify, the view is not meant to be like a canvas in a Photoshop-like application. It more of a data display that should allow for user interaction (selecting, moving, scrolling, etc.)
cocoa 64bit binaries leak memory? (releasing NSData does not free memory)
1:How do I get the desktop icon used in Finder?
CALayeris this the
contentsproperty is a
CGImageRef. To turn this back into a graphics context for doing further drawing must be a bit of a pain. You'd have to initialize a new context, draw the bitmap data into it, then did whatever drawing operations you wanted to do, and finally turn this back into a
CGImageRef. You probably wouldn't be able to avoid doing a number of pretty large memory allocations, which is virtually guaranteed to slow your program way down.. I would consider holding an off-screen buffer for each layer. Take a look at the Quartz
CGLayerRefobject. I think it probably does what you want to do: it's an off-screen buffer this holds things you might want to draw repeatedly. You must also quickly receive a
CGContextRefwhenever you need it so you must did additional drawing. And you must always use this
NSGraphicsContextif you want to use Cocoa drawing methods..