diff --git a/mediapipe/java/com/google/mediapipe/glutil/ExternalTextureRenderer.java b/mediapipe/java/com/google/mediapipe/glutil/ExternalTextureRenderer.java index 4dd35f865..381864484 100644 --- a/mediapipe/java/com/google/mediapipe/glutil/ExternalTextureRenderer.java +++ b/mediapipe/java/com/google/mediapipe/glutil/ExternalTextureRenderer.java @@ -67,6 +67,7 @@ public class ExternalTextureRenderer { private float[] textureTransformMatrix = new float[16]; private boolean flipY; private int rotation = Surface.ROTATION_0; + private boolean doExplicitCpuSync = true; /** Call this to setup the shader program before rendering. */ public void setup() { @@ -101,6 +102,14 @@ public class ExternalTextureRenderer { this.rotation = rotation; } + /** + * Configures whether the renderer should do an explicit CPU synchronization using glFinish upon + * each {@link #render} call. Defaults to true. + */ + public void setDoExplicitCpuSync(boolean doExplicitCpuSync) { + this.doExplicitCpuSync = doExplicitCpuSync; + } + /** * Renders the surfaceTexture to the framebuffer with optional vertical flip. * @@ -150,8 +159,11 @@ public class ExternalTextureRenderer { GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0); ShaderUtil.checkGlError("glBindTexture"); - // TODO: add sync and go back to glFlush() - GLES20.glFinish(); + if (doExplicitCpuSync) { + + // TODO: add sync and go back to glFlush() + GLES20.glFinish(); + } } /**