Generally, it’s not advisable to overlay views on top of hardware accelerated views, such as the OS provided movie player, OpenGL or Metal. These views can gain maximum performance by not being composited with other views or windows.
If you do want to overlay content on top of these views, it’s best to use Layer-Backed Views (the Xojo movie player does this). On older hardware it will struggle a little, but it helps with compositing multiple views/layers atop each other.
Would anyone have some more info or an example? I ran into trouble with MapKitMBS and am currently looking at subviews as a way of implementing a control on too, but I hadn’t come across layered views.
Layered views are a macOS thing
But to be honest @samRowlands is probably one of, if not THE, bets source for a lot of this
Not sure if you can use a canvas and declares to make it layer backed ?
I used OverlayMBS to layer something over a movie player. Worked well. And I think you can put controls on those too but my needs were pretty simple so can’t say with 100% certainty that it would look okay.
In theory any control can use Layer-backed Views (Triple buffering).
You can even set up every control on a window to layer-backed by using
[[NSWindow contentView] wantsLayer:YES].
In the case of a movie player, Xojo already uses Layer-Backed Views as they use a “player layer”. I use a similar technique in my photo editors where I may need to use OpenGL (while Metal was added in 10.11, only 10.14 ensures all machines use Metal) or Metal. It has a cost to it because the content has to be buffered and then composited, instead of being drawn directly into the window buffer.
It has two advantages.
- I can use a single control on my window, which will create the appropriate layer at construction time.
- it allows me to easily add overlaid controls (via a Canvas and standard Xojo graphics API) on top a Metal view. Which I couldn’t do when I first started experimenting with Metal.