Test: Update MatrixProcessorPixelTest to use input width and height.

Before, they used `width` and `height`, which was inconsistent with other pixel tests, and less descriptive.

Refactoring change only. No functional change intended.

PiperOrigin-RevId: 481970243
This commit is contained in:
huangdarwin 2022-10-18 18:12:06 +00:00 committed by Rohit Singh
parent f850206c51
commit cce79a7040

View File

@ -65,24 +65,24 @@ public final class MatrixTextureProcessorPixelTest {
private @MonotonicNonNull EGLContext eglContext; private @MonotonicNonNull EGLContext eglContext;
private @MonotonicNonNull SingleFrameGlTextureProcessor matrixTextureProcessor; private @MonotonicNonNull SingleFrameGlTextureProcessor matrixTextureProcessor;
private int inputTexId; private int inputTexId;
private int width; private int inputWidth;
private int height; private int inputHeight;
@Before @Before
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
width = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
height = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, width, height); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
int outputTexId = int outputTexId =
GlUtil.createTexture(width, height, /* useHighPrecisionColorComponents= */ false); GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
int frameBuffer = GlUtil.createFboForTexture(outputTexId); int frameBuffer = GlUtil.createFboForTexture(outputTexId);
GlUtil.focusFramebuffer( GlUtil.focusFramebuffer(
eglDisplay, eglContext, placeholderEglSurface, frameBuffer, width, height); eglDisplay, eglContext, placeholderEglSurface, frameBuffer, inputWidth, inputHeight);
} }
@After @After
@ -102,11 +102,11 @@ public final class MatrixTextureProcessorPixelTest {
MatrixTransformation noEditsTransformation = (long presentationTimeUs) -> identityMatrix; MatrixTransformation noEditsTransformation = (long presentationTimeUs) -> identityMatrix;
matrixTextureProcessor = matrixTextureProcessor =
noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false); noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
matrixTextureProcessor.configure(width, height); matrixTextureProcessor.configure(inputWidth, inputHeight);
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): switch to using proper tooling for testing against golden data.
@ -124,11 +124,11 @@ public final class MatrixTextureProcessorPixelTest {
(long presentationTimeUs) -> translateRightMatrix; (long presentationTimeUs) -> translateRightMatrix;
matrixTextureProcessor = matrixTextureProcessor =
translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false); translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
matrixTextureProcessor.configure(width, height); matrixTextureProcessor.configure(inputWidth, inputHeight);
Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): switch to using proper tooling for testing against golden data.
@ -145,11 +145,11 @@ public final class MatrixTextureProcessorPixelTest {
MatrixTransformation scaleNarrowTransformation = (long presentationTimeUs) -> scaleNarrowMatrix; MatrixTransformation scaleNarrowTransformation = (long presentationTimeUs) -> scaleNarrowMatrix;
matrixTextureProcessor = matrixTextureProcessor =
scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false); scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
matrixTextureProcessor.configure(width, height); matrixTextureProcessor.configure(inputWidth, inputHeight);
Bitmap expectedBitmap = readBitmap(SCALE_NARROW_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(SCALE_NARROW_PNG_ASSET_PATH);
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): switch to using proper tooling for testing against golden data.
@ -166,11 +166,11 @@ public final class MatrixTextureProcessorPixelTest {
MatrixTransformation rotate90Transformation = (long presentationTimeUs) -> rotate90Matrix; MatrixTransformation rotate90Transformation = (long presentationTimeUs) -> rotate90Matrix;
matrixTextureProcessor = matrixTextureProcessor =
rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false); rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false);
matrixTextureProcessor.configure(width, height); matrixTextureProcessor.configure(inputWidth, inputHeight);
Bitmap expectedBitmap = readBitmap(ROTATE_90_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(ROTATE_90_PNG_ASSET_PATH);
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): switch to using proper tooling for testing against golden data.