Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java

Issue 1367923002: Android GlRectDrawer: Add test for RGB rendering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java
diff --git a/talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java b/talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java
index 71bd5e3561da14888cfea5324d0171a282b7ebdb..8708ffd7f3ff9eb5a0da91be0a1acb224681be9d 100644
--- a/talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java
+++ b/talk/app/webrtc/androidtests/src/org/webrtc/GlRectDrawerTest.java
@@ -54,9 +54,53 @@ public class GlRectDrawerTest extends ActivityTestCase {
}
@SmallTest
+ public void testRgbRendering() throws Exception {
+ // Create EGL base with a pixel buffer as display output.
+ final EglBase eglBase = new EglBase(EGL14.EGL_NO_CONTEXT, EglBase.ConfigType.PIXEL_BUFFER);
+ eglBase.createPbufferSurface(WIDTH, HEIGHT);
+ eglBase.makeCurrent();
+
+ // Create RGB byte buffer plane with random content.
+ final ByteBuffer rgbaPlane = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3);
+ final Random random = new Random(SEED);
+ random.nextBytes(rgbaPlane.array());
+
+ // Upload the RGB byte buffer data as a texture.
+ final int rgbaTexture = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D);
+ GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, rgbaTexture);
+ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, WIDTH,
+ HEIGHT, 0, GLES20.GL_RGB, GLES20.GL_UNSIGNED_BYTE, rgbaPlane);
+
+ // Draw the RGB frame onto the pixel buffer.
+ final GlRectDrawer drawer = new GlRectDrawer();
+ final float[] identityMatrix = new float[16];
+ Matrix.setIdentityM(identityMatrix, 0);
+ drawer.drawRgb(rgbaTexture, identityMatrix);
+
+ // Download the pixels in the pixel buffer as RGBA.
+ final ByteBuffer data = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 4);
+ GLES20.glReadPixels(0, 0, WIDTH, HEIGHT, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
hbos 2015/09/24 11:37:38 Why read RGBA and not just RGB?
magjed_webrtc 2015/09/24 12:15:17 Done. I switched to RGB without alpha.
+
+ // Assert rendered image is pixel perfect to source RGB.
+ for (int y = 0; y < HEIGHT; ++y) {
+ for (int x = 0; x < WIDTH; ++x) {
+ assertEquals("Red", data.get() & 0xFF, rgbaPlane.get() & 0xFF);
+ assertEquals("Green", data.get() & 0xFF, rgbaPlane.get() & 0xFF);
+ assertEquals("Blue", data.get() & 0xFF, rgbaPlane.get() & 0xFF);
+ assertEquals("Alpha", data.get() & 0xFF, 255);
+ }
+ }
+
+ drawer.release();
+ GLES20.glDeleteTextures(1, new int[] {rgbaTexture}, 0);
+ eglBase.release();
+ }
+
+ @SmallTest
public void testYuvRendering() throws Exception {
// Create EGL base with a pixel buffer as display output.
- EglBase eglBase = eglBase = new EglBase(EGL14.EGL_NO_CONTEXT, EglBase.ConfigType.PIXEL_BUFFER);
+ EglBase eglBase = new EglBase(EGL14.EGL_NO_CONTEXT, EglBase.ConfigType.PIXEL_BUFFER);
eglBase.createPbufferSurface(WIDTH, HEIGHT);
eglBase.makeCurrent();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698