mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Effect: Early return and rename variable (+ nits).
Reduce nesting by using an early return. Also, rename `outputSizeOrRotationChanged` to `outputChanged`, because this also applies to when the output surface changes. Also, update local variable initialization, add some javadoc, and remove unneeded local variable PiperOrigin-RevId: 518241708
This commit is contained in:
parent
87cd90eb15
commit
cbaf0f8232
@ -93,7 +93,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
@Nullable private SurfaceView debugSurfaceView;
|
@Nullable private SurfaceView debugSurfaceView;
|
||||||
private boolean frameProcessingStarted;
|
private boolean frameProcessingStarted;
|
||||||
|
|
||||||
private volatile boolean outputSizeOrRotationChanged;
|
private volatile boolean outputChanged;
|
||||||
|
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -270,7 +270,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
* @see VideoFrameProcessor#setOutputSurfaceInfo(SurfaceInfo)
|
* @see VideoFrameProcessor#setOutputSurfaceInfo(SurfaceInfo)
|
||||||
*/
|
*/
|
||||||
public synchronized void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo) {
|
public synchronized void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo) {
|
||||||
if (!Util.areEqual(this.outputSurfaceInfo, outputSurfaceInfo)) {
|
if (Util.areEqual(this.outputSurfaceInfo, outputSurfaceInfo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (outputSurfaceInfo != null
|
if (outputSurfaceInfo != null
|
||||||
&& this.outputSurfaceInfo != null
|
&& this.outputSurfaceInfo != null
|
||||||
&& !this.outputSurfaceInfo.surface.equals(outputSurfaceInfo.surface)) {
|
&& !this.outputSurfaceInfo.surface.equals(outputSurfaceInfo.surface)) {
|
||||||
@ -282,7 +285,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
this.outputEglSurface = null;
|
this.outputEglSurface = null;
|
||||||
}
|
}
|
||||||
outputSizeOrRotationChanged =
|
outputChanged =
|
||||||
this.outputSurfaceInfo == null
|
this.outputSurfaceInfo == null
|
||||||
|| outputSurfaceInfo == null
|
|| outputSurfaceInfo == null
|
||||||
|| this.outputSurfaceInfo.width != outputSurfaceInfo.width
|
|| this.outputSurfaceInfo.width != outputSurfaceInfo.width
|
||||||
@ -290,7 +293,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|| this.outputSurfaceInfo.orientationDegrees != outputSurfaceInfo.orientationDegrees;
|
|| this.outputSurfaceInfo.orientationDegrees != outputSurfaceInfo.orientationDegrees;
|
||||||
this.outputSurfaceInfo = outputSurfaceInfo;
|
this.outputSurfaceInfo = outputSurfaceInfo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void renderFrameToSurfaces(
|
private void renderFrameToSurfaces(
|
||||||
GlTextureInfo inputTexture, long presentationTimeUs, long releaseTimeNs) {
|
GlTextureInfo inputTexture, long presentationTimeUs, long releaseTimeNs) {
|
||||||
@ -336,16 +338,22 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
EGL14.eglSwapBuffers(eglDisplay, outputEglSurface);
|
EGL14.eglSwapBuffers(eglDisplay, outputEglSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures the instance is configured.
|
||||||
|
*
|
||||||
|
* <p>Returns {@code false} if {@code outputSurfaceInfo} is unset.
|
||||||
|
*/
|
||||||
@EnsuresNonNullIf(
|
@EnsuresNonNullIf(
|
||||||
expression = {"outputSurfaceInfo", "outputEglSurface", "defaultShaderProgram"},
|
expression = {"outputSurfaceInfo", "outputEglSurface", "defaultShaderProgram"},
|
||||||
result = true)
|
result = true)
|
||||||
private synchronized boolean ensureConfigured(int inputWidth, int inputHeight)
|
private synchronized boolean ensureConfigured(int inputWidth, int inputHeight)
|
||||||
throws VideoFrameProcessingException, GlUtil.GlException {
|
throws VideoFrameProcessingException, GlUtil.GlException {
|
||||||
|
|
||||||
boolean inputSizeChanged = false;
|
boolean inputSizeChanged =
|
||||||
if (this.inputWidth != inputWidth
|
this.inputWidth != inputWidth
|
||||||
|| this.inputHeight != inputHeight
|
|| this.inputHeight != inputHeight
|
||||||
|| this.outputSizeBeforeSurfaceTransformation == null) {
|
|| this.outputSizeBeforeSurfaceTransformation == null;
|
||||||
|
if (inputSizeChanged) {
|
||||||
this.inputWidth = inputWidth;
|
this.inputWidth = inputWidth;
|
||||||
this.inputHeight = inputHeight;
|
this.inputHeight = inputHeight;
|
||||||
Size outputSizeBeforeSurfaceTransformation =
|
Size outputSizeBeforeSurfaceTransformation =
|
||||||
@ -359,7 +367,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
outputSizeBeforeSurfaceTransformation.getWidth(),
|
outputSizeBeforeSurfaceTransformation.getWidth(),
|
||||||
outputSizeBeforeSurfaceTransformation.getHeight()));
|
outputSizeBeforeSurfaceTransformation.getHeight()));
|
||||||
}
|
}
|
||||||
inputSizeChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputSurfaceInfo == null) {
|
if (outputSurfaceInfo == null) {
|
||||||
@ -395,10 +402,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
this.debugSurfaceView = debugSurfaceView;
|
this.debugSurfaceView = debugSurfaceView;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultShaderProgram != null && (outputSizeOrRotationChanged || inputSizeChanged)) {
|
if (defaultShaderProgram != null && (outputChanged || inputSizeChanged)) {
|
||||||
defaultShaderProgram.release();
|
defaultShaderProgram.release();
|
||||||
defaultShaderProgram = null;
|
defaultShaderProgram = null;
|
||||||
outputSizeOrRotationChanged = false;
|
outputChanged = false;
|
||||||
}
|
}
|
||||||
if (defaultShaderProgram == null) {
|
if (defaultShaderProgram == null) {
|
||||||
defaultShaderProgram = createDefaultShaderProgramForOutputSurface(outputSurfaceInfo);
|
defaultShaderProgram = createDefaultShaderProgramForOutputSurface(outputSurfaceInfo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user