我正在使用媒体编解码器对来自相机的帧进行编码,并使用 gl 表面视图对其进行渲染。
我的ondrawframe 看起来像这样
public void onDrawFrame(GL10 unused)
{
float[] mtx = new float[16];
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
surface.updateTexImage();
surface.getTransformMatrix(mtx);
mDirectVideo.draw(surface);
saveRenderState();
delegate.mInputSurface.makeCurrent();
mDirectVideo.draw(surface);
delegate.swapBuffers();
restoreRenderState();
}
所以这里我们做了两次 Draw(surface) 渲染到表面。这将在系统中产生开销。有什么地方我只能做一次 Ondraw 吗?两次使用着色器是昂贵的操作有什么方法可以在渲染器和编码器之间共享表面吗?