Android: Allow construction of GlTextureFrameBuffer from non-OpenGL thread
This CL makes it possible to create a GlTextureFrameBuffer from any
thread. The actual GL resources will be allocated the first time
setSize() is called. The purpose is to be able to use 'final' variables
more often for this class and avoid @Nullable annotations.
Bug: None
Change-Id: I350304bcd33fd674990254df37a615995972f322
Reviewed-on: https://webrtc-review.googlesource.com/69241
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22835}
diff --git a/sdk/android/api/org/webrtc/EglRenderer.java b/sdk/android/api/org/webrtc/EglRenderer.java
index c6e9812..dccd111 100644
--- a/sdk/android/api/org/webrtc/EglRenderer.java
+++ b/sdk/android/api/org/webrtc/EglRenderer.java
@@ -131,7 +131,8 @@
private long renderSwapBufferTimeNs;
// Used for bitmap capturing.
- @Nullable private GlTextureFrameBuffer bitmapTextureFramebuffer;
+ private final GlTextureFrameBuffer bitmapTextureFramebuffer =
+ new GlTextureFrameBuffer(GLES20.GL_RGBA);
private final Runnable logStatisticsRunnable = new Runnable() {
@Override
@@ -233,10 +234,7 @@
drawer = null;
}
frameDrawer.release();
- if (bitmapTextureFramebuffer != null) {
- bitmapTextureFramebuffer.release();
- bitmapTextureFramebuffer = null;
- }
+ bitmapTextureFramebuffer.release();
if (eglBase != null) {
logD("eglBase detach and release.");
eglBase.detachCurrent();
@@ -637,9 +635,6 @@
continue;
}
- if (bitmapTextureFramebuffer == null) {
- bitmapTextureFramebuffer = new GlTextureFrameBuffer(GLES20.GL_RGBA);
- }
bitmapTextureFramebuffer.setSize(scaledWidth, scaledHeight);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, bitmapTextureFramebuffer.getFrameBufferId());