What does compose for desktop use for rendering? A...
# compose-desktop
z
What does compose for desktop use for rendering? Am I able to set it to always use OpenGL? I'm trying to access the opengl context for a video render library. Is there a single context for the whole application, or is it split into areas, that i can access independently?
e
Compose may use different Skia backends (software, OpenGL, Vulkan, Metal), and I don't think it makes sense to use the same OpenGL context anyway, that would tie you to doing work in the same thread/frame
ideally there would be some way to render from a texture, I'm not sure if compose desktop has that though
z
would that be like a bitmap or different
e
basically a bitmap (ideally in video ram, if compositing is also done there)
e.g. what TextureView does on Android
z
I'm using MPV, and the two ways I can render is by passing an opengl context to it, or MPV can do software rendering and it returns a pointer to the pixel data
l
I have definitely used a pointer to pixel data to render to a nativeBitmap on desktop (and iOS) before. I don't remember the exact code, but it's doable. I used FFmpeg to render directly to a Composable on iOS at my last job.
Here's a link to some old code I wrote that writes to a Bitmap on iOS (desktop should have the same method).
z
oh neat ill be sure to take a look at that
l
There's definitely several ways to do this, with different performance/code complexity implications.
e
yeah that looks like it involves the CPU copying the bitmap around, which has performance limits, but it is simple
a
z
kinda stuck, @ephemient. I'm so close to getting video actually visible. Currently I have a SkiaBackedCanvas instance. The problem is how do i pass that to a compose Canvas composable? I looked through the source code of compose multiplatform to try to figure it out and drawing api seems to be really deeply nested. I'm unsure what to do but i'm so close
theres a single
LayoutNodeDrawScope
for the application that's contained in
SkiaBasedOwner
which all drawing stuff uses. Or maybe theres some simpler route I'm overlooking?
281 Views