Commit ad68c7cc by tofunmi Committed by microkatz

Remove glUtil.clearOutputFrame from GLObjectsProvider.

https://github.com/google/ExoPlayer/commit/ddbad570311fec7df635b0b6da9083be82291b50 added clearing depth buffers to GLUtil, so there is no need to have allow apps to have a custom clearOutputFrame.
Also removes default implementations in GLObjectsProvider know that these methods have been implemented.

PiperOrigin-RevId: 517156304
parent 927105ed
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import android.opengl.EGL14;
import android.opengl.EGLContext; import android.opengl.EGLContext;
import android.opengl.EGLDisplay; import android.opengl.EGLDisplay;
import android.opengl.EGLSurface; import android.opengl.EGLSurface;
...@@ -66,11 +67,6 @@ public interface GlObjectsProvider { ...@@ -66,11 +67,6 @@ public interface GlObjectsProvider {
int fboId = GlUtil.createFboForTexture(texId); int fboId = GlUtil.createFboForTexture(texId);
return new GlTextureInfo(texId, fboId, /* rboId= */ C.INDEX_UNSET, width, height); return new GlTextureInfo(texId, fboId, /* rboId= */ C.INDEX_UNSET, width, height);
} }
@Override
public void clearOutputFrame() throws GlException {
GlUtil.clearOutputFrame();
}
}; };
/** /**
...@@ -87,22 +83,38 @@ public interface GlObjectsProvider { ...@@ -87,22 +83,38 @@ public interface GlObjectsProvider {
EGLDisplay eglDisplay, @IntRange(from = 2, to = 3) int openGlVersion, int[] configAttributes) EGLDisplay eglDisplay, @IntRange(from = 2, to = 3) int openGlVersion, int[] configAttributes)
throws GlException; throws GlException;
// TODO(b/271433904): Remove default implementations once photos have implemented these methods. /**
* Creates a new {@link EGLSurface} wrapping the specified {@code surface}.
*
* @param eglDisplay The {@link EGLDisplay} to attach the surface to.
* @param surface The surface to wrap; must be a surface, surface texture or surface holder.
* @param colorTransfer The {@linkplain C.ColorTransfer color transfer characteristics} to which
* the {@code surface} is configured.
* @param isEncoderInputSurface Whether the {@code surface} is the input surface of an encoder.
* @throws GlException If an error occurs during creation.
*/
@RequiresApi(17) @RequiresApi(17)
default EGLSurface createEglSurface( EGLSurface createEglSurface(
EGLDisplay eglDisplay, EGLDisplay eglDisplay,
Object surface, Object surface,
@C.ColorTransfer int colorTransfer, @C.ColorTransfer int colorTransfer,
boolean isEncoderInputSurface) boolean isEncoderInputSurface)
throws GlException { throws GlException;
return GlUtil.createEglSurface(eglDisplay, surface, colorTransfer, isEncoderInputSurface);
}
/**
* Creates and focuses a placeholder {@link EGLSurface}.
*
* @param eglContext The {@link EGLContext} to make current.
* @param eglDisplay The {@link EGLDisplay} to attach the surface to.
* @param configAttributes The attributes to configure EGL with.
* @return A placeholder {@link EGLSurface} that has been focused to allow rendering to take
* place, or {@link EGL14#EGL_NO_SURFACE} if the current context supports rendering without a
* surface.
* @throws GlException If an error occurs during creation.
*/
@RequiresApi(17) @RequiresApi(17)
default EGLSurface createFocusedPlaceholderEglSurface( EGLSurface createFocusedPlaceholderEglSurface(
EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes) throws GlException { EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes) throws GlException;
return GlUtil.createFocusedPlaceholderEglSurface(eglContext, eglDisplay, configAttributes);
}
/** /**
* Returns a {@link GlTextureInfo} containing the identifiers of the newly created buffers. * Returns a {@link GlTextureInfo} containing the identifiers of the newly created buffers.
...@@ -113,11 +125,4 @@ public interface GlObjectsProvider { ...@@ -113,11 +125,4 @@ public interface GlObjectsProvider {
* @throws GlException If an error occurs during creation. * @throws GlException If an error occurs during creation.
*/ */
GlTextureInfo createBuffersForTexture(int texId, int width, int height) throws GlException; GlTextureInfo createBuffersForTexture(int texId, int width, int height) throws GlException;
/**
* Clears the current render target.
*
* @throws GlException If an error occurs during clearing.
*/
void clearOutputFrame() throws GlException;
} }
...@@ -324,7 +324,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -324,7 +324,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
outputEglSurface, outputEglSurface,
outputSurfaceInfo.width, outputSurfaceInfo.width,
outputSurfaceInfo.height); outputSurfaceInfo.height);
glObjectsProvider.clearOutputFrame(); GlUtil.clearOutputFrame();
defaultShaderProgram.drawFrame(inputTexture.texId, presentationTimeUs); defaultShaderProgram.drawFrame(inputTexture.texId, presentationTimeUs);
EGLExt.eglPresentationTimeANDROID( EGLExt.eglPresentationTimeANDROID(
...@@ -466,7 +466,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -466,7 +466,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
try { try {
debugSurfaceViewWrapper.maybeRenderToSurfaceView( debugSurfaceViewWrapper.maybeRenderToSurfaceView(
() -> { () -> {
glObjectsProvider.clearOutputFrame(); GlUtil.clearOutputFrame();
@C.ColorTransfer @C.ColorTransfer
int configuredColorTransfer = defaultShaderProgram.getOutputColorTransfer(); int configuredColorTransfer = defaultShaderProgram.getOutputColorTransfer();
defaultShaderProgram.setOutputColorTransfer( defaultShaderProgram.setOutputColorTransfer(
......
...@@ -137,7 +137,7 @@ import java.util.concurrent.Executor; ...@@ -137,7 +137,7 @@ import java.util.concurrent.Executor;
// Copy frame to fbo. // Copy frame to fbo.
GlUtil.focusFramebufferUsingCurrentContext( GlUtil.focusFramebufferUsingCurrentContext(
outputTexture.fboId, outputTexture.width, outputTexture.height); outputTexture.fboId, outputTexture.width, outputTexture.height);
glObjectsProvider.clearOutputFrame(); GlUtil.clearOutputFrame();
drawFrame(inputTexture.texId); drawFrame(inputTexture.texId);
inputListener.onInputFrameProcessed(inputTexture); inputListener.onInputFrameProcessed(inputTexture);
outputListener.onOutputFrameAvailable(outputTexture, presentationTimeUs); outputListener.onOutputFrameAvailable(outputTexture, presentationTimeUs);
......
...@@ -142,7 +142,7 @@ public abstract class SingleFrameGlShaderProgram implements GlShaderProgram { ...@@ -142,7 +142,7 @@ public abstract class SingleFrameGlShaderProgram implements GlShaderProgram {
outputTextureInUse = true; outputTextureInUse = true;
GlUtil.focusFramebufferUsingCurrentContext( GlUtil.focusFramebufferUsingCurrentContext(
outputTexture.fboId, outputTexture.width, outputTexture.height); outputTexture.fboId, outputTexture.width, outputTexture.height);
glObjectsProvider.clearOutputFrame(); GlUtil.clearOutputFrame();
drawFrame(inputTexture.texId, presentationTimeUs); drawFrame(inputTexture.texId, presentationTimeUs);
inputListener.onInputFrameProcessed(inputTexture); inputListener.onInputFrameProcessed(inputTexture);
outputListener.onOutputFrameAvailable(outputTexture, presentationTimeUs); outputListener.onOutputFrameAvailable(outputTexture, presentationTimeUs);
......
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