SurfaceTexture AttachToGLContext and Surface

只谈情不闲聊 提交于 2021-02-18 08:48:31

问题


I'm trying to find out whether I need to remake a Surface if I want to call the attachToGLContext method from a SurfaceTexture. I tried to look in the android documentation, but there is no mention.

I'm guessing not because as far as I'm aware, Surface is a buffer for a SurfaceTexture which can act as an external texture for an OpenGL context. So attaching the SurfaceTexture to a different context should not affect this.

Does anybody know for sure?


回答1:


The internal name for SurfaceTexture is "GLConsumer". Surfaces have a producer-consumer relationship, and SurfaceTexture is a consumer that takes whatever it gets and makes it available as a GLES texture.

The Surface attached to it (usually by using the Surface constructor that takes a SurfaceTexture as an argument) is the producer side. While there is a queue of buffers involved in the communication between the producer and the consumer, it's not really accurate to describe the Surface as "a buffer". It's more like a communication endpoint that sends graphics data to the consumer.

Changing the EGL context associated with the consumer side will have no effect on the producer side. The attach / detach calls do not disconnect the producer. They only affect what the SurfaceTexture does with the buffers of data it receives.

It's fairly unusual to need to use these calls though, and there may be some overhead associated with manipulating EGL contexts, so make sure it's what you need.



来源:https://stackoverflow.com/questions/32161526/surfacetexture-attachtoglcontext-and-surface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!