mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix resizing in debug preview
PiperOrigin-RevId: 732905018 (cherry picked from commit 1e4a10651a931ed9c95898bff1151d8f16a322af)
This commit is contained in:
parent
766dbd497e
commit
e1d328db11
@ -68,6 +68,8 @@ public final class DebugViewShaderProgram implements GlShaderProgram {
|
|||||||
private Executor errorListenerExecutor;
|
private Executor errorListenerExecutor;
|
||||||
|
|
||||||
private @MonotonicNonNull EGLDisplay eglDisplay;
|
private @MonotonicNonNull EGLDisplay eglDisplay;
|
||||||
|
private int outputWidth = C.LENGTH_UNSET;
|
||||||
|
private int outputHeight = C.LENGTH_UNSET;
|
||||||
|
|
||||||
public DebugViewShaderProgram(
|
public DebugViewShaderProgram(
|
||||||
Context context, DebugViewProvider debugViewProvider, ColorInfo outputColorInfo) {
|
Context context, DebugViewProvider debugViewProvider, ColorInfo outputColorInfo) {
|
||||||
@ -154,9 +156,13 @@ public final class DebugViewShaderProgram implements GlShaderProgram {
|
|||||||
eglDisplay = getDefaultEglDisplay();
|
eglDisplay = getDefaultEglDisplay();
|
||||||
}
|
}
|
||||||
EGLContext eglContext = GlUtil.getCurrentContext();
|
EGLContext eglContext = GlUtil.getCurrentContext();
|
||||||
|
if (outputWidth == C.LENGTH_UNSET || outputHeight == C.LENGTH_UNSET) {
|
||||||
|
outputWidth = inputWidth;
|
||||||
|
outputHeight = inputHeight;
|
||||||
|
}
|
||||||
@Nullable
|
@Nullable
|
||||||
SurfaceView debugSurfaceView =
|
SurfaceView debugSurfaceView =
|
||||||
debugViewProvider.getDebugPreviewSurfaceView(inputWidth, inputHeight);
|
debugViewProvider.getDebugPreviewSurfaceView(outputWidth, outputHeight);
|
||||||
if (debugSurfaceView != null && !Objects.equals(this.debugSurfaceView, debugSurfaceView)) {
|
if (debugSurfaceView != null && !Objects.equals(this.debugSurfaceView, debugSurfaceView)) {
|
||||||
debugSurfaceViewWrapper =
|
debugSurfaceViewWrapper =
|
||||||
new SurfaceViewWrapper(
|
new SurfaceViewWrapper(
|
||||||
@ -164,10 +170,16 @@ public final class DebugViewShaderProgram implements GlShaderProgram {
|
|||||||
}
|
}
|
||||||
this.debugSurfaceView = debugSurfaceView;
|
this.debugSurfaceView = debugSurfaceView;
|
||||||
if (defaultShaderProgram == null) {
|
if (defaultShaderProgram == null) {
|
||||||
|
ImmutableList.Builder<GlMatrixTransformation> matrixTransformationListBuilder =
|
||||||
|
new ImmutableList.Builder<>();
|
||||||
|
matrixTransformationListBuilder.add(
|
||||||
|
Presentation.createForWidthAndHeight(
|
||||||
|
outputWidth, outputHeight, Presentation.LAYOUT_SCALE_TO_FIT));
|
||||||
|
|
||||||
defaultShaderProgram =
|
defaultShaderProgram =
|
||||||
DefaultShaderProgram.createApplyingOetf(
|
DefaultShaderProgram.createApplyingOetf(
|
||||||
context,
|
context,
|
||||||
/* matrixTransformations= */ ImmutableList.of(),
|
/* matrixTransformations= */ matrixTransformationListBuilder.build(),
|
||||||
/* rgbMatrices= */ ImmutableList.of(),
|
/* rgbMatrices= */ ImmutableList.of(),
|
||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
outputColorInfo.colorTransfer == C.COLOR_TRANSFER_LINEAR
|
outputColorInfo.colorTransfer == C.COLOR_TRANSFER_LINEAR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user