On 28/03/2012, at 11:45 PM, Kenneth Baxter wrote: > The contents of about half the layers seldom change, so from that > perspective, caching contents as either NSImages, CIImages, CGLayers or using > CALayers would seem to be a good idea. The other half of the layers are > simple, and just consist of some bezier curves, and change a bit more > frequently.
One thing, just to be clear: CGLayer and CALayer are two completely different beasts, and are not in any way equivalent. CGLayer is basically an image caching mechanism, CALayer is a lot richer. > The other day I wrote asking about technology choices and outlined why layer > backed views didn't seem to be an option (can't guarantee z order), and why a > CALayer hosting view didn't seem to be an option (show stopper drawing bug > during animation of large layers, inability to add subviews leading to > problems with overlay windows, problems with CAShapeLayers etc). > > If I understand you correctly, you might be suggesting using CALayers purely > for drawing and using my own animations for moving the layers around, and > triggering layer redraws when necessary. That may avoid some of the bugs that > I have run into with layer animations, but I would still have to use overlay > windows instead of using subviews, and work out issues with the tiled > background and zooming etc. > > If I could find a way to guarantee the z order of layer backed views, then I > would love to go that route, but I believe that's impossible based on my own > and others' findings. > > If I just can't get the performance I need by any means using an NSView, then > it looks as if I will just have to tackle all the issues I have encountered > trying to work with a layer hosting view and CALayers. > > From what both of you are saying, it very much sounds as if I am just not > going to be able to get the performance I need for decent animations by > redrawing parts of an NSView when dealing with a large number of objects, and > that the only solution is going to be the user of a layer hosting view and > making things work with CALayer. > I have done a few projects using CALayers now, and have found them really good for getting good drawing performance. I wouldn't claim to be an expert, but I certainly can't see why they can't be used here, notwithstanding the problems you say you're having. You don't want a layer-backed view, you want a layer-hosting view. Then add the objects as siblings and use the zPosition parameter to control their relative z ordering. I found this number needs to be large to work properly - making it 1, 2, 3 doesn't do anything, but 10000, 20000, 30000, etc should work. I haven't run into any problems doing this - it works well (though my objects have never been as large as yours). The animation features of CALayer work great, and simply driving their x, y position will allow you to move static graphics around very efficiently. If you need to have more complex graphics, just write a CALayer delegate callback and build the image there. Works fine for me. If you want to have a look at one of my CALayer-based projects, which is an iTunes visualizer, you can download it free here: http://apptree.net/ledsa.htm. The main display consists of about 100 layers and framerates are throttled to 30fps. --Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com