Peter Tran
10/01/2024, 7:02 PMPeter Tran
10/01/2024, 7:07 PMPeter Tran
10/01/2024, 7:08 PMIvan Matkov
10/01/2024, 7:24 PMSergey Y.
10/01/2024, 7:52 PMGLES11Ext.GL_TEXTURE_EXTERNAL_OES
.
This is done through the GraphicsLayer
API from the latest Compose version.
You create an android.graphics.SurfaceTexture, attach it to an android.view.Surface, and get a hardware-accelerated canvas. Then, using CanvasDrawScope
, you can draw the Compose UI layer onto the canvas. In my current project, I use this approach extensively.
This writes the UI to the external texture in OpenGL memory. Then, in the layerExternalTexture.setOnFrameAvailableListener, you receive a callback when the frame is ready, and you can sample this texture in your shader as samplerExternalOES type.
Hopefully, my code isn’t too convoluted, but it might help give you some ideas 😄.
Feel free to explore my project and ask questions. I'll try to answer them.Peter Tran
10/01/2024, 7:59 PMSurfaceTexture
, and sampling with samplerExternalOES
, but in the pre-Compose days of Android.
I wonder if there is a similar pattern on iOS to configure a Metal-based canvas.Sergey Y.
10/01/2024, 8:07 PM