Can a texture be updated in background thread but printed in foreground thread?

帅比萌擦擦* 提交于 2019-12-11 10:54:15

问题


In webRTC, in SurfaceTextureHelper the surfaceTexture (with handle the creation/update of the openGL texture) is created inside a background thread:

final HandlerThread thread = new HandlerThread(threadName);
thread.start();

an inside this newly created thread we do

oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
surfaceTexture = new SurfaceTexture(oesTextureId); 

The problem is that the OnFrameAvailableListener of the surfacetexture will be called in the thread where the surfacetexture was created (seam logical). My problem is that all the painting of my app are done in the main UI thread (and I can not change this), so here I end up by something where the texture will be updated in background thread (texture of GL_TEXTURE_EXTERNAL_OES) but will be print on the foreground thread.

Is it possible that it's will work ? textureID never change, just the content of the texture get updated in the bakcground thread

来源:https://stackoverflow.com/questions/53441496/can-a-texture-be-updated-in-background-thread-but-printed-in-foreground-thread

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