Android: Deprecated custom matrix helper functions in RendererCommon
All usage of these functions should be migrated to use android.opengl.Matrix instead. Bug: webrtc:9487 Change-Id: I023761b31cae7e7af9b537928b849657baa5bb8b Reviewed-on: https://webrtc-review.googlesource.com/87263 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23853}
This commit is contained in:

committed by
Commit Bot

parent
d97b862593
commit
b4918dad6a
@ -119,6 +119,7 @@ public class RendererCommon {
|
||||
// This limits excessive cropping when adjusting display size.
|
||||
private static float BALANCED_VISIBLE_FRACTION = 0.5625f;
|
||||
// clang-format off
|
||||
@Deprecated
|
||||
public static final float[] identityMatrix() {
|
||||
return new float[] {
|
||||
1, 0, 0, 0,
|
||||
@ -127,6 +128,7 @@ public class RendererCommon {
|
||||
0, 0, 0, 1};
|
||||
}
|
||||
// Matrix with transform y' = 1 - y.
|
||||
@Deprecated
|
||||
public static final float[] verticalFlipMatrix() {
|
||||
return new float[] {
|
||||
1, 0, 0, 0,
|
||||
@ -136,6 +138,7 @@ public class RendererCommon {
|
||||
}
|
||||
|
||||
// Matrix with transform x' = 1 - x.
|
||||
@Deprecated
|
||||
public static final float[] horizontalFlipMatrix() {
|
||||
return new float[] {
|
||||
-1, 0, 0, 0,
|
||||
@ -149,6 +152,7 @@ public class RendererCommon {
|
||||
* Returns texture matrix that will have the effect of rotating the frame |rotationDegree|
|
||||
* clockwise when rendered.
|
||||
*/
|
||||
@Deprecated
|
||||
public static float[] rotateTextureMatrix(float[] textureMatrix, float rotationDegree) {
|
||||
final float[] rotationMatrix = new float[16];
|
||||
Matrix.setRotateM(rotationMatrix, 0, rotationDegree, 0, 0, 1);
|
||||
@ -159,6 +163,7 @@ public class RendererCommon {
|
||||
/**
|
||||
* Returns new matrix with the result of a * b.
|
||||
*/
|
||||
@Deprecated
|
||||
public static float[] multiplyMatrices(float[] a, float[] b) {
|
||||
final float[] resultMatrix = new float[16];
|
||||
Matrix.multiplyMM(resultMatrix, 0, a, 0, b, 0);
|
||||
|
@ -34,6 +34,14 @@ public class GlRectDrawerTest {
|
||||
// When comparing pixels, allow some slack for float arithmetic and integer rounding.
|
||||
private static final float MAX_DIFF = 1.5f;
|
||||
|
||||
// clang-format off
|
||||
private static final float[] IDENTITY_MATRIX = {
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1};
|
||||
// clang-format on
|
||||
|
||||
private static float normalizedByte(byte b) {
|
||||
return (b & 0xFF) / 255.0f;
|
||||
}
|
||||
@ -110,8 +118,8 @@ public class GlRectDrawerTest {
|
||||
|
||||
// Draw the RGB frame onto the pixel buffer.
|
||||
final GlRectDrawer drawer = new GlRectDrawer();
|
||||
drawer.drawRgb(rgbTexture, RendererCommon.identityMatrix(), WIDTH, HEIGHT, 0 /* viewportX */,
|
||||
0 /* viewportY */, WIDTH, HEIGHT);
|
||||
drawer.drawRgb(rgbTexture, IDENTITY_MATRIX, WIDTH, HEIGHT, 0 /* viewportX */, 0 /* viewportY */,
|
||||
WIDTH, HEIGHT);
|
||||
|
||||
// Download the pixels in the pixel buffer as RGBA. Not all platforms support RGB, e.g. Nexus 9.
|
||||
final ByteBuffer rgbaData = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 4);
|
||||
@ -161,7 +169,7 @@ public class GlRectDrawerTest {
|
||||
|
||||
// Draw the YUV frame onto the pixel buffer.
|
||||
final GlRectDrawer drawer = new GlRectDrawer();
|
||||
drawer.drawYuv(yuvTextures, RendererCommon.identityMatrix(), WIDTH, HEIGHT, 0 /* viewportX */,
|
||||
drawer.drawYuv(yuvTextures, IDENTITY_MATRIX, WIDTH, HEIGHT, 0 /* viewportX */,
|
||||
0 /* viewportY */, WIDTH, HEIGHT);
|
||||
|
||||
// Download the pixels in the pixel buffer as RGBA. Not all platforms support RGB, e.g. Nexus 9.
|
||||
@ -252,8 +260,8 @@ public class GlRectDrawerTest {
|
||||
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, WIDTH, HEIGHT, 0, GLES20.GL_RGB,
|
||||
GLES20.GL_UNSIGNED_BYTE, rgbPlane);
|
||||
// Draw the RGB data onto the SurfaceTexture.
|
||||
drawer.drawRgb(rgbTexture, RendererCommon.identityMatrix(), WIDTH, HEIGHT,
|
||||
0 /* viewportX */, 0 /* viewportY */, WIDTH, HEIGHT);
|
||||
drawer.drawRgb(rgbTexture, IDENTITY_MATRIX, WIDTH, HEIGHT, 0 /* viewportX */,
|
||||
0 /* viewportY */, WIDTH, HEIGHT);
|
||||
eglBase.swapBuffers();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.webrtc.RendererCommon.ScalingType.*;
|
||||
import static org.webrtc.RendererCommon.getDisplaySize;
|
||||
import static org.webrtc.RendererCommon.getLayoutMatrix;
|
||||
import static org.webrtc.RendererCommon.rotateTextureMatrix;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.support.test.filters.SmallTest;
|
||||
@ -149,52 +148,4 @@ public class RendererCommonTest {
|
||||
0.25, 0, 0, 1}, round(layoutMatrix), 0.0);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRotateTextureMatrixDefault() {
|
||||
// Test that rotation with 0 degrees returns an identical matrix.
|
||||
// clang-format off
|
||||
final float[] matrix = new float[] {
|
||||
1, 2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
9, 0, 1, 2,
|
||||
3, 4, 5, 6
|
||||
};
|
||||
// clang-format on
|
||||
final float rotatedMatrix[] = rotateTextureMatrix(matrix, 0);
|
||||
assertArrayEquals(round(matrix), round(rotatedMatrix), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRotateTextureMatrix90Deg() {
|
||||
final float samplingMatrix[] = rotateTextureMatrix(RendererCommon.identityMatrix(), 90);
|
||||
// Assert:
|
||||
// u' = 1 - v.
|
||||
// v' = u.
|
||||
// clang-format off
|
||||
assertArrayEquals(new double[] {
|
||||
0, 1, 0, 0,
|
||||
-1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
1, 0, 0, 1}, round(samplingMatrix), 0.0);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRotateTextureMatrix180Deg() {
|
||||
final float samplingMatrix[] = rotateTextureMatrix(RendererCommon.identityMatrix(), 180);
|
||||
// Assert:
|
||||
// u' = 1 - u.
|
||||
// v' = 1 - v.
|
||||
// clang-format off
|
||||
assertArrayEquals(new double[] {
|
||||
-1, 0, 0, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
1, 1, 0, 1}, round(samplingMatrix), 0.0);
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user