Keep surface upon orientation change (using GLSurfaceView)

142 Views Asked by At

I'm trying to keep some rendering going on (without resetting it) even upon destroy and re-creation of my activity (due to an orientation change).

I took a look into Grafika's DoubleDecodeActivity, which is very clarifying on how to do it. However, it does it by using a TextureView, which is less efficient, since the drawn frames don't get passed directly to the surface compositor (SurfaceFlinger). My user experience becomes compromised. What I need is a GLSurfaceView (or maybe a SurfaceView).

The problem is I don't know how to persist the SurfaceView's "SurfaceTexture" (if that's a thing) across different instances of my activity.

Can someone please help me out with this?

1

There are 1 best solutions below

0
Robson de Paula On

Following your line of reasoning I think if you render to a TextureView instead of directly in the GLSurfaceView you can achieve the desired behavior.

Please take a look at https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/TextureViewGLActivity.java

Best Regards