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}
This commit is contained in:
Magnus Jedvert
2018-04-16 13:31:28 +02:00
committed by Commit Bot
parent e31be15d47
commit 28111d7fa0
5 changed files with 26 additions and 35 deletions

View File

@ -18,8 +18,8 @@ import org.webrtc.VideoFrame.I420Buffer;
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 @@ public class YuvConverter {
// 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 @@ public class YuvConverter {
* 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. */