Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why wouldn't you want layer backed views

I'm coming primarily from iOS development.

Why would you NOT want to make all your NSView's layer backed? Is there some kind of performance hit? What is different than iOS where every UIView is layer backed?

like image 763
David Beck Avatar asked Feb 20 '23 17:02

David Beck


1 Answers

On iOS, the graphics hardware is based on tiled rendering. The layer-backed-view configuration very closely matches the way the hardware composites content to the screen.

On Mac OS, the hardware does not use tiled rendering. When you ask for layer-backed views, you increase your program's memory footprint. On Mac OS, the screen is normally double-buffered, so there are 2 copies of the screen at any one time. I believe that the layer backed views are also double-buffered (could be wrong about that bit) so you use quite a bit more memory. When you turn on layer backed views you do it for all the subviews of a view, recursively. If you have views with lots of overlapping subviews, you can push up the memory requirements quite a bit.

I don't know, but I suspect, that in Mac OS layer backed views are slightly slower to render than non layer-backed-views. There are a lot of factors to rendering performance, so it may depend on the specifics.

I'd suggest doing some testing yourself, both of video memory use and real-world performance. The new OpenGL tools in Xcode and instruments will let you track video memory usage. (It is not the same as main memory.)

like image 92
Duncan C Avatar answered Feb 28 '23 10:02

Duncan C