Commit 6c061894 by hschlueter Committed by Ian Baker

Make GlProgram an outer class.

This change makes GlUtil.Program an outer class named GlProgram,
and also moves private static helpers as well as the inner classes
Attribute and Uniform which were only used by GlUtil.Program to
GlProgram. Other static utility methods remain in GlUtil.

No functional changes intended.

PiperOrigin-RevId: 426119299
parent 9927883b
......@@ -27,6 +27,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.GlProgram;
import com.google.android.exoplayer2.util.GlUtil;
import java.io.IOException;
import java.util.Locale;
......@@ -50,7 +51,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private final Bitmap logoBitmap;
private final Canvas overlayCanvas;
private GlUtil.@MonotonicNonNull Program program;
private @MonotonicNonNull GlProgram program;
private float bitmapScaleX;
private float bitmapScaleY;
......@@ -78,7 +79,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public void initialize() {
try {
program =
new GlUtil.Program(
new GlProgram(
context,
/* vertexShaderFilePath= */ "bitmap_overlay_video_processor_vertex.glsl",
/* fragmentShaderFilePath= */ "bitmap_overlay_video_processor_fragment.glsl");
......@@ -117,7 +118,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
GlUtil.checkGlError();
// Run the shader program.
GlUtil.Program program = checkNotNull(this.program);
GlProgram program = checkNotNull(this.program);
program.setSamplerTexIdUniform("uTexSampler0", frameTexture, /* unit= */ 0);
program.setSamplerTexIdUniform("uTexSampler1", textures[0], /* unit= */ 1);
program.setFloatUniform("uScaleX", bitmapScaleX);
......
......@@ -24,6 +24,7 @@ import android.util.AttributeSet;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.GlProgram;
import com.google.android.exoplayer2.util.GlUtil;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
......@@ -144,7 +145,7 @@ public final class VideoDecoderGLSurfaceView extends GLSurfaceView
// glDrawArrays uses it.
private final FloatBuffer[] textureCoords;
private GlUtil.@MonotonicNonNull Program program;
private @MonotonicNonNull GlProgram program;
private int colorMatrixLocation;
// Accessed only from the GL thread.
......@@ -165,7 +166,7 @@ public final class VideoDecoderGLSurfaceView extends GLSurfaceView
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
program = new GlUtil.Program(VERTEX_SHADER, FRAGMENT_SHADER);
program = new GlProgram(VERTEX_SHADER, FRAGMENT_SHADER);
int posLocation = program.getAttributeArrayLocationAndEnable("in_pos");
GLES20.glVertexAttribPointer(
posLocation,
......
......@@ -21,6 +21,7 @@ import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.GlProgram;
import com.google.android.exoplayer2.util.GlUtil;
import java.nio.FloatBuffer;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
......@@ -87,7 +88,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private int stereoMode;
@Nullable private MeshData leftMeshData;
@Nullable private MeshData rightMeshData;
private GlUtil.@MonotonicNonNull Program program;
private @MonotonicNonNull GlProgram program;
// Program related GL items. These are only valid if Program is valid.
private int mvpMatrixHandle;
......@@ -114,7 +115,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** Initializes of the GL components. */
public void init() {
program = new GlUtil.Program(VERTEX_SHADER, FRAGMENT_SHADER);
program = new GlProgram(VERTEX_SHADER, FRAGMENT_SHADER);
mvpMatrixHandle = program.getUniformLocation("uMvpMatrix");
uTexMatrixHandle = program.getUniformLocation("uTexMatrix");
positionHandle = program.getAttributeArrayLocationAndEnable("aPosition");
......@@ -148,7 +149,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
GLES20.glUniformMatrix3fv(uTexMatrixHandle, 1, false, texMatrix, 0);
// TODO(b/205002913): Update to use GlUtil.Uniform.bind().
// TODO(b/205002913): Update to use GlProgram.Uniform.bind().
GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false, mvpMatrix, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId);
......
......@@ -31,6 +31,7 @@ import android.view.Surface;
import android.view.SurfaceView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.GlProgram;
import com.google.android.exoplayer2.util.GlUtil;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -86,7 +87,7 @@ import java.util.concurrent.atomic.AtomicInteger;
EGLContext eglContext;
EGLSurface eglSurface;
int textureId;
GlUtil.Program glProgram;
GlProgram glProgram;
@Nullable EGLSurface debugPreviewEglSurface = null;
try {
eglDisplay = GlUtil.createEglDisplay();
......@@ -141,7 +142,7 @@ import java.util.concurrent.atomic.AtomicInteger;
debugPreviewHeight);
}
private static GlUtil.Program configureGlProgram(
private static GlProgram configureGlProgram(
Context context,
Matrix transformationMatrix,
int textureId,
......@@ -157,8 +158,7 @@ import java.util.concurrent.atomic.AtomicInteger;
enableExperimentalHdrEditing
? FRAGMENT_SHADER_COPY_EXTERNAL_YUV_ES3_PATH
: FRAGMENT_SHADER_COPY_EXTERNAL_PATH;
GlUtil.Program glProgram =
new GlUtil.Program(context, vertexShaderFilePath, fragmentShaderFilePath);
GlProgram glProgram = new GlProgram(context, vertexShaderFilePath, fragmentShaderFilePath);
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram.setBufferAttribute(
......@@ -242,7 +242,7 @@ import java.util.concurrent.atomic.AtomicInteger;
private final AtomicInteger availableInputFrameCount;
private final SurfaceTexture inputSurfaceTexture;
private final Surface inputSurface;
private final GlUtil.Program glProgram;
private final GlProgram glProgram;
private final int outputWidth;
private final int outputHeight;
@Nullable private final EGLSurface debugPreviewEglSurface;
......@@ -256,7 +256,7 @@ import java.util.concurrent.atomic.AtomicInteger;
EGLContext eglContext,
EGLSurface eglSurface,
int textureId,
GlUtil.Program glProgram,
GlProgram glProgram,
int outputWidth,
int outputHeight,
@Nullable EGLSurface debugPreviewEglSurface,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment