From e79d130dc4d4b53a77474e9739919c7ce0bc074d Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Wed, 31 Jul 2019 11:58:26 +0200 Subject: [PATCH] use glBindTexture instead of workaround --- .../internal/Issue514Workaround.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/internal/Issue514Workaround.java b/cameraview/src/main/java/com/otaliastudios/cameraview/internal/Issue514Workaround.java index 5a050c0d..f59fc3b5 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/internal/Issue514Workaround.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/internal/Issue514Workaround.java @@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.internal; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.SurfaceTexture; +import android.opengl.GLES11Ext; import android.opengl.GLES20; import android.view.Surface; import com.otaliastudios.cameraview.preview.RendererThread; @@ -85,23 +86,21 @@ import com.otaliastudios.cameraview.preview.RendererThread; * - Calling a useless {@link SurfaceTexture#updateTexImage()} before locking the overlay canvas * - Releasing the useless {@link SurfaceTexture} * This must be done using the video frame textureId, not the overlayTextureId nor any other id. + * + * https://android.googlesource.com/platform/frameworks/native/+/5c1139f/libs/gui/SurfaceTexture.cpp */ public class Issue514Workaround { private SurfaceTexture surfaceTexture = null; + private final int cameraTextureId; private final boolean hasOverlay; public Issue514Workaround(int cameraTextureId, boolean hasOverlay) { + this.cameraTextureId = cameraTextureId; this.hasOverlay = hasOverlay; if (this.hasOverlay) { try { - surfaceTexture = new SurfaceTexture(cameraTextureId); - surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { - @Override - public void onFrameAvailable(SurfaceTexture surfaceTexture) { - // Never called! Correctly. - } - }); + // surfaceTexture = new SurfaceTexture(cameraTextureId); } catch (Exception ignore) { } } } @@ -109,7 +108,8 @@ public class Issue514Workaround { public void start() { if (hasOverlay) { try { - surfaceTexture.updateTexImage(); + GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTextureId); + // surfaceTexture.updateTexImage(); } catch (Exception ignore) {} } } @@ -117,7 +117,7 @@ public class Issue514Workaround { public void end() { if (hasOverlay) { try { - surfaceTexture.release(); + // surfaceTexture.release(); } catch (Exception ignore) {} } }