| Index: talk/app/webrtc/androidtests/src/org/webrtc/RendererCommonTest.java
|
| diff --git a/talk/app/webrtc/androidtests/src/org/webrtc/RendererCommonTest.java b/talk/app/webrtc/androidtests/src/org/webrtc/RendererCommonTest.java
|
| index 28c0f283c3909af15d9af73324ee4807c4c97b1d..cd8bfcb48c7b4ae623e94a24ecafe38bf096bbb7 100644
|
| --- a/talk/app/webrtc/androidtests/src/org/webrtc/RendererCommonTest.java
|
| +++ b/talk/app/webrtc/androidtests/src/org/webrtc/RendererCommonTest.java
|
| @@ -35,7 +35,8 @@ import android.graphics.Point;
|
|
|
| import static org.webrtc.RendererCommon.ScalingType.*;
|
| import static org.webrtc.RendererCommon.getDisplaySize;
|
| -import static org.webrtc.RendererCommon.getTextureMatrix;
|
| +import static org.webrtc.RendererCommon.getLayoutMatrix;
|
| +import static org.webrtc.RendererCommon.getSamplingMatrix;
|
|
|
| public class RendererCommonTest extends ActivityTestCase {
|
| @SmallTest
|
| @@ -100,64 +101,76 @@ public class RendererCommonTest extends ActivityTestCase {
|
| return doubleArray;
|
| }
|
|
|
| + // Brief summary about matrix transformations:
|
| + // A coordinate p = [u, v, 0, 1] is transformed by matrix m like this p' = [u', v', 0, 1] = m * p.
|
| + // OpenGL uses column-major order, so:
|
| + // u' = u * m[0] + v * m[4] + m[12].
|
| + // v' = u * m[1] + v * m[5] + m[13].
|
| +
|
| @SmallTest
|
| - static public void testTexMatrixDefault() {
|
| - final float texMatrix[] = new float[16];
|
| - getTextureMatrix(texMatrix, 0, false, 1.0f, 1.0f);
|
| - // TODO(magjed): Every tex matrix contains a vertical flip, because we ignore the texture
|
| - // transform matrix from the SurfaceTexture (which contains a vertical flip). Update tests when
|
| - // this is fixed.
|
| + static public void testLayoutMatrixDefault() {
|
| + final float layoutMatrix[] = getLayoutMatrix(false, 1.0f, 1.0f);
|
| // Assert:
|
| // u' = u.
|
| - // v' = 1 - v.
|
| - MoreAsserts.assertEquals(round(texMatrix), new double[]
|
| + // v' = v.
|
| + MoreAsserts.assertEquals(round(layoutMatrix), new double[]
|
| {1, 0, 0, 0,
|
| - 0, -1, 0, 0,
|
| + 0, 1, 0, 0,
|
| 0, 0, 1, 0,
|
| - 0, 1, 0, 1});
|
| + 0, 0, 0, 1});
|
| }
|
|
|
| @SmallTest
|
| - static public void testTexMatrixMirror() {
|
| - final float texMatrix[] = new float[16];
|
| - getTextureMatrix(texMatrix, 0, true, 1.0f, 1.0f);
|
| + static public void testLayoutMatrixMirror() {
|
| + final float layoutMatrix[] = getLayoutMatrix(true, 1.0f, 1.0f);
|
| // Assert:
|
| // u' = 1 - u.
|
| - // v' = 1 - v.
|
| - MoreAsserts.assertEquals(round(texMatrix), new double[]
|
| + // v' = v.
|
| + MoreAsserts.assertEquals(round(layoutMatrix), new double[]
|
| {-1, 0, 0, 0,
|
| - 0, -1, 0, 0,
|
| - 0, 0, 1, 0,
|
| - 1, 1, 0, 1});
|
| + 0, 1, 0, 0,
|
| + 0, 0, 1, 0,
|
| + 1, 0, 0, 1});
|
| }
|
|
|
| @SmallTest
|
| - static public void testTexMatrixRotation90Deg() {
|
| - final float texMatrix[] = new float[16];
|
| - getTextureMatrix(texMatrix, 90, false, 1.0f, 1.0f);
|
| + static public void testLayoutMatrixScale() {
|
| + // Video has aspect ratio 2, but layout is square. This will cause only the center part of the
|
| + // video to be visible, i.e. the u coordinate will go from 0.25 to 0.75 instead of from 0 to 1.
|
| + final float layoutMatrix[] = getLayoutMatrix(false, 2.0f, 1.0f);
|
| // Assert:
|
| - // u' = 1 - v.
|
| - // v' = 1 - u.
|
| - MoreAsserts.assertEquals(round(texMatrix), new double[]
|
| - {0, -1, 0, 0,
|
| - -1, 0, 0, 0,
|
| - 0, 0, 1, 0,
|
| - 1, 1, 0, 1});
|
| + // u' = 0.25 + 0.5 u.
|
| + // v' = v.
|
| + MoreAsserts.assertEquals(round(layoutMatrix), new double[]
|
| + { 0.5, 0, 0, 0,
|
| + 0, 1, 0, 0,
|
| + 0, 0, 1, 0,
|
| + 0.25, 0, 0, 1});
|
| }
|
|
|
| @SmallTest
|
| - static public void testTexMatrixScale() {
|
| - final float texMatrix[] = new float[16];
|
| - // Video has aspect ratio 2, but layout is square. This will cause only the center part of the
|
| - // video to be visible, i.e. the u coordinate will go from 0.25 to 0.75 instead of from 0 to 1.
|
| - getTextureMatrix(texMatrix, 0, false, 2.0f, 1.0f);
|
| + static public void testSamplingMatrixDefault() {
|
| + final float samplingMatrix[] = getSamplingMatrix(null, 0);
|
| // Assert:
|
| - // u' = 0.25 + 0.5 u.
|
| + // u' = u.
|
| // v' = 1 - v.
|
| - MoreAsserts.assertEquals(round(texMatrix), new double[]
|
| - {0.5, 0, 0, 0,
|
| + MoreAsserts.assertEquals(round(samplingMatrix), new double[]
|
| + {1, 0, 0, 0,
|
| 0, -1, 0, 0,
|
| - 0, 0, 1, 0,
|
| - 0.25, 1, 0, 1});
|
| + 0, 0, 1, 0,
|
| + 0, 1, 0, 1});
|
| + }
|
| +
|
| + @SmallTest
|
| + static public void testSamplingMatrixRotation90Deg() {
|
| + final float samplingMatrix[] = getSamplingMatrix(null, 90);
|
| + // Assert:
|
| + // u' = 1 - u.
|
| + // v' = 1 - v.
|
| + MoreAsserts.assertEquals(round(samplingMatrix), new double[]
|
| + { 0, -1, 0, 0,
|
| + -1, 0, 0, 0,
|
| + 0, 0, 1, 0,
|
| + 1, 1, 0, 1});
|
| }
|
| }
|
|
|