Effect: Remove unused arguments in DefaultShaderProgram factories.
Partially addresses the following TODO, by simplifying the DefaultShaderProgram API surface. ``` // TODO(b/274109008): Refactor DefaultShaderProgram to create a class just for sampling. ``` PiperOrigin-RevId: 597575575
This commit is contained in:
parent
b4dfbed73d
commit
c59711f592
@ -185,16 +185,11 @@ import java.util.List;
|
||||
* <p>Input will be sampled from an internal (i.e. regular) texture.
|
||||
*
|
||||
* <p>Applies the {@linkplain ColorInfo#colorTransfer inputColorInfo EOTF} to convert from
|
||||
* electrical color input, to intermediate optical {@link GlShaderProgram} color output, before
|
||||
* {@code matrixTransformations} and {@code rgbMatrices} are applied. Also applies the {@linkplain
|
||||
* ColorInfo#colorTransfer outputColorInfo OETF}, if needed, to convert back to an electrical
|
||||
* color output.
|
||||
* electrical color input, to intermediate optical {@link GlShaderProgram} color output. Also
|
||||
* applies the {@linkplain ColorInfo#colorTransfer outputColorInfo OETF}, if needed, to convert
|
||||
* back to an electrical color output.
|
||||
*
|
||||
* @param context The {@link Context}.
|
||||
* @param matrixTransformations The {@link GlMatrixTransformation GlMatrixTransformations} to
|
||||
* apply to each frame in order. Can be empty to apply no vertex transformations.
|
||||
* @param rgbMatrices The {@link RgbMatrix RgbMatrices} to apply to each frame in order. Can be
|
||||
* empty to apply no color transformations.
|
||||
* @param inputColorInfo The input electrical (nonlinear) {@link ColorInfo}.
|
||||
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
|
||||
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
|
||||
@ -206,8 +201,6 @@ import java.util.List;
|
||||
*/
|
||||
public static DefaultShaderProgram createWithInternalSampler(
|
||||
Context context,
|
||||
List<GlMatrixTransformation> matrixTransformations,
|
||||
List<RgbMatrix> rgbMatrices,
|
||||
ColorInfo inputColorInfo,
|
||||
ColorInfo outputColorInfo,
|
||||
boolean enableColorTransfers,
|
||||
@ -226,13 +219,7 @@ import java.util.List;
|
||||
: FRAGMENT_SHADER_TRANSFORMATION_SDR_INTERNAL_PATH;
|
||||
GlProgram glProgram = createGlProgram(context, vertexShaderFilePath, fragmentShaderFilePath);
|
||||
glProgram.setIntUniform("uInputColorTransfer", inputColorInfo.colorTransfer);
|
||||
return createWithSampler(
|
||||
glProgram,
|
||||
matrixTransformations,
|
||||
rgbMatrices,
|
||||
inputColorInfo,
|
||||
outputColorInfo,
|
||||
enableColorTransfers);
|
||||
return createWithSampler(glProgram, inputColorInfo, outputColorInfo, enableColorTransfers);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,16 +230,11 @@ import java.util.List;
|
||||
* external texture.
|
||||
*
|
||||
* <p>Applies the {@linkplain ColorInfo#colorTransfer inputColorInfo EOTF} to convert from
|
||||
* electrical color input, to intermediate optical {@link GlShaderProgram} color output, before
|
||||
* {@code matrixTransformations} and {@code rgbMatrices} are applied. Also applies the {@linkplain
|
||||
* ColorInfo#colorTransfer outputColorInfo OETF}, if needed, to convert back to an electrical
|
||||
* color output.
|
||||
* electrical color input, to intermediate optical {@link GlShaderProgram} color output. Also
|
||||
* applies the {@linkplain ColorInfo#colorTransfer outputColorInfo OETF}, if needed, to convert
|
||||
* back to an electrical color output.
|
||||
*
|
||||
* @param context The {@link Context}.
|
||||
* @param matrixTransformations The {@link GlMatrixTransformation GlMatrixTransformations} to
|
||||
* apply to each frame in order. Can be empty to apply no vertex transformations.
|
||||
* @param rgbMatrices The {@link RgbMatrix RgbMatrices} to apply to each frame in order. Can be
|
||||
* empty to apply no color transformations.
|
||||
* @param inputColorInfo The input electrical (nonlinear) {@link ColorInfo}.
|
||||
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
|
||||
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
|
||||
@ -264,8 +246,6 @@ import java.util.List;
|
||||
*/
|
||||
public static DefaultShaderProgram createWithExternalSampler(
|
||||
Context context,
|
||||
List<GlMatrixTransformation> matrixTransformations,
|
||||
List<RgbMatrix> rgbMatrices,
|
||||
ColorInfo inputColorInfo,
|
||||
ColorInfo outputColorInfo,
|
||||
boolean enableColorTransfers)
|
||||
@ -294,13 +274,7 @@ import java.util.List;
|
||||
glProgram.setIntUniform("uInputColorTransfer", inputColorInfo.colorTransfer);
|
||||
}
|
||||
|
||||
return createWithSampler(
|
||||
glProgram,
|
||||
matrixTransformations,
|
||||
rgbMatrices,
|
||||
inputColorInfo,
|
||||
outputColorInfo,
|
||||
enableColorTransfers);
|
||||
return createWithSampler(glProgram, inputColorInfo, outputColorInfo, enableColorTransfers);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,8 +339,6 @@ import java.util.List;
|
||||
|
||||
private static DefaultShaderProgram createWithSampler(
|
||||
GlProgram glProgram,
|
||||
List<GlMatrixTransformation> matrixTransformations,
|
||||
List<RgbMatrix> rgbMatrices,
|
||||
ColorInfo inputColorInfo,
|
||||
ColorInfo outputColorInfo,
|
||||
boolean enableColorTransfers) {
|
||||
@ -397,8 +369,8 @@ import java.util.List;
|
||||
|
||||
return new DefaultShaderProgram(
|
||||
glProgram,
|
||||
ImmutableList.copyOf(matrixTransformations),
|
||||
ImmutableList.copyOf(rgbMatrices),
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(),
|
||||
outputColorInfo.colorTransfer,
|
||||
isInputTransferHdr);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import androidx.media3.common.GlTextureInfo;
|
||||
import androidx.media3.common.OnInputFrameProcessedListener;
|
||||
import androidx.media3.common.VideoFrameProcessingException;
|
||||
import androidx.media3.common.VideoFrameProcessor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.concurrent.Executor;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -97,12 +96,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
case INPUT_TYPE_SURFACE:
|
||||
samplingShaderProgram =
|
||||
DefaultShaderProgram.createWithExternalSampler(
|
||||
context,
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(),
|
||||
inputColorInfo,
|
||||
outputColorInfo,
|
||||
enableColorTransfers);
|
||||
context, inputColorInfo, outputColorInfo, enableColorTransfers);
|
||||
break;
|
||||
case INPUT_TYPE_BITMAP:
|
||||
// HDR bitmap input is not supported. Bitmaps are always sRGB/Full range/BT.709.
|
||||
@ -110,26 +104,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
ColorInfo bitmapColorInfo = ColorInfo.SRGB_BT709_FULL;
|
||||
samplingShaderProgram =
|
||||
DefaultShaderProgram.createWithInternalSampler(
|
||||
context,
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(),
|
||||
bitmapColorInfo,
|
||||
outputColorInfo,
|
||||
enableColorTransfers,
|
||||
inputType);
|
||||
context, bitmapColorInfo, outputColorInfo, enableColorTransfers, inputType);
|
||||
break;
|
||||
case INPUT_TYPE_TEXTURE_ID:
|
||||
// Image and textureId concatenation not supported.
|
||||
checkState(inputColorInfo.colorTransfer != C.COLOR_TRANSFER_SRGB);
|
||||
samplingShaderProgram =
|
||||
DefaultShaderProgram.createWithInternalSampler(
|
||||
context,
|
||||
/* matrixTransformations= */ ImmutableList.of(),
|
||||
/* rgbMatrices= */ ImmutableList.of(),
|
||||
inputColorInfo,
|
||||
outputColorInfo,
|
||||
enableColorTransfers,
|
||||
inputType);
|
||||
context, inputColorInfo, outputColorInfo, enableColorTransfers, inputType);
|
||||
break;
|
||||
default:
|
||||
throw new VideoFrameProcessingException("Unsupported input type " + inputType);
|
||||
|
Loading…
x
Reference in New Issue
Block a user