diff --git a/sdk/android/api/org/webrtc/RendererCommon.java b/sdk/android/api/org/webrtc/RendererCommon.java index ee73430373..d6472393f7 100644 --- a/sdk/android/api/org/webrtc/RendererCommon.java +++ b/sdk/android/api/org/webrtc/RendererCommon.java @@ -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); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java index 424971c464..f99b3b02ac 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java @@ -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(); } diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java index 34d795b9b8..d29fc0b030 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java @@ -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 - } }