Android: Generalize and make TextureBufferImpl public
This CL generalizes TextureBufferImpl so it's useful from other contexts than
from a SurfaceTextureHelper, and fixes a bug in cropAndScale(). It also exposes
the class in the api so that clients don't have to duplicate the logic.
Bug: None
Change-Id: Ib82aa8bee025ec14de74a7be9d91fd4e5298a248
Reviewed-on: https://webrtc-review.googlesource.com/69819
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22875}
diff --git a/sdk/android/api/org/webrtc/YuvConverter.java b/sdk/android/api/org/webrtc/YuvConverter.java
index 31db0dd..2d8e548 100644
--- a/sdk/android/api/org/webrtc/YuvConverter.java
+++ b/sdk/android/api/org/webrtc/YuvConverter.java
@@ -18,8 +18,8 @@
import org.webrtc.VideoFrame.TextureBuffer;
/**
- * Class for converting OES textures to a YUV ByteBuffer. It should be constructed on a thread with
- * an active EGL context, and only be used from that thread.
+ * Class for converting OES textures to a YUV ByteBuffer. It can be constructed on any thread, but
+ * should only be operated from a single thread with an active EGL context.
*/
public class YuvConverter {
// Vertex coordinates in Normalized Device Coordinates, i.e.
@@ -111,7 +111,7 @@
// clang-format on
private final ThreadUtils.ThreadChecker threadChecker = new ThreadUtils.ThreadChecker();
- private final GlTextureFrameBuffer textureFrameBuffer;
+ private final GlTextureFrameBuffer textureFrameBuffer = new GlTextureFrameBuffer(GLES20.GL_RGBA);
private TextureBuffer.Type shaderTextureType;
private GlShader shader;
private int texMatrixLoc;
@@ -123,8 +123,7 @@
* This class should be constructed on a thread that has an active EGL context.
*/
public YuvConverter() {
- threadChecker.checkIsOnValidThread();
- textureFrameBuffer = new GlTextureFrameBuffer(GLES20.GL_RGBA);
+ threadChecker.detachThread();
}
/** Converts the texture buffer to I420. */