diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java index e2696818aa..6f9676becb 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java @@ -42,7 +42,7 @@ import java.util.HashMap; import java.util.Map; import javax.microedition.khronos.egl.EGL10; -/** GL utilities. */ +/** OpenGL ES 2.0 utilities. */ public final class GlUtil { /** Thrown when an OpenGL error occurs and {@link #glAssertionsEnabled} is {@code true}. */ @@ -85,7 +85,10 @@ public final class GlUtil { } /** - * Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code. + * Creates a GL shader program from vertex and fragment shader GLSL GLES20 code. + * + *
This involves slow steps, like compiling, linking, and switching the GL program, so do not + * call this in fast rendering loops. * * @param vertexShaderGlsl The vertex shader program. * @param fragmentShaderGlsl The fragment shader program. @@ -128,8 +131,14 @@ public final class GlUtil { checkGlError(); } - /** Uses the program. */ + /** + * Uses the program. + * + *
Call this in the rendering loop to switch between different programs. + */ public void use() { + // TODO(http://b/205002913): When multiple GL programs are supported by Transformer, make sure + // to call use() to switch between programs. GLES20.glUseProgram(programId); checkGlError(); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java index 8f61630e19..524132f807 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java @@ -166,7 +166,6 @@ public final class VideoDecoderGLSurfaceView extends GLSurfaceView @Override public void onSurfaceCreated(GL10 unused, EGLConfig config) { program = new GlUtil.Program(VERTEX_SHADER, FRAGMENT_SHADER); - program.use(); int posLocation = program.getAttributeArrayLocationAndEnable("in_pos"); GLES20.glVertexAttribPointer( posLocation, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java index 3e9f577e20..f5f9966b4e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.video.spherical; -import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.GlUtil.checkGlError; import android.opengl.GLES11Ext; @@ -139,9 +138,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } // Configure shader. - checkNotNull(program).use(); - checkGlError(); - float[] texMatrix; if (stereoMode == C.STEREO_MODE_TOP_BOTTOM) { texMatrix = rightEye ? TEX_MATRIX_BOTTOM : TEX_MATRIX_TOP;