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

Side by Side Diff: webrtc/api/androidtests/src/org/webrtc/GlRectDrawerTest.java

Issue 1755573002: Android SurfaceTextureHelper: Add stopListening() function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change name from disconnect() to dispose() Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/api/androidtests/src/org/webrtc/SurfaceTextureHelperTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 package org.webrtc; 10 package org.webrtc;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 final EglBase eglBase = EglBase.create(null, EglBase.CONFIG_PIXEL_BUFFER); 249 final EglBase eglBase = EglBase.create(null, EglBase.CONFIG_PIXEL_BUFFER);
250 eglBase.createPbufferSurface(WIDTH, HEIGHT); 250 eglBase.createPbufferSurface(WIDTH, HEIGHT);
251 251
252 // Create resources for generating OES textures. 252 // Create resources for generating OES textures.
253 final SurfaceTextureHelper surfaceTextureHelper = 253 final SurfaceTextureHelper surfaceTextureHelper =
254 SurfaceTextureHelper.create(eglBase.getEglBaseContext()); 254 SurfaceTextureHelper.create(eglBase.getEglBaseContext());
255 final StubOesTextureProducer oesProducer = new StubOesTextureProducer( 255 final StubOesTextureProducer oesProducer = new StubOesTextureProducer(
256 eglBase.getEglBaseContext(), surfaceTextureHelper.getSurfaceTexture(), W IDTH, HEIGHT); 256 eglBase.getEglBaseContext(), surfaceTextureHelper.getSurfaceTexture(), W IDTH, HEIGHT);
257 final SurfaceTextureHelperTest.MockTextureListener listener = 257 final SurfaceTextureHelperTest.MockTextureListener listener =
258 new SurfaceTextureHelperTest.MockTextureListener(); 258 new SurfaceTextureHelperTest.MockTextureListener();
259 surfaceTextureHelper.setListener(listener); 259 surfaceTextureHelper.startListening(listener);
260 260
261 // Create RGB byte buffer plane with random content. 261 // Create RGB byte buffer plane with random content.
262 final ByteBuffer rgbPlane = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3); 262 final ByteBuffer rgbPlane = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3);
263 final Random random = new Random(SEED); 263 final Random random = new Random(SEED);
264 random.nextBytes(rgbPlane.array()); 264 random.nextBytes(rgbPlane.array());
265 265
266 // Draw the frame and block until an OES texture is delivered. 266 // Draw the frame and block until an OES texture is delivered.
267 oesProducer.draw(rgbPlane); 267 oesProducer.draw(rgbPlane);
268 listener.waitForNewFrame(); 268 listener.waitForNewFrame();
269 269
270 // Real test starts here. 270 // Real test starts here.
271 // Draw the OES texture on the pixel buffer. 271 // Draw the OES texture on the pixel buffer.
272 eglBase.makeCurrent(); 272 eglBase.makeCurrent();
273 final GlRectDrawer drawer = new GlRectDrawer(); 273 final GlRectDrawer drawer = new GlRectDrawer();
274 drawer.drawOes(listener.oesTextureId, listener.transformMatrix, 0, 0, WIDTH, HEIGHT); 274 drawer.drawOes(listener.oesTextureId, listener.transformMatrix, 0, 0, WIDTH, HEIGHT);
275 275
276 // Download the pixels in the pixel buffer as RGBA. Not all platforms suppor t RGB, e.g. Nexus 9. 276 // Download the pixels in the pixel buffer as RGBA. Not all platforms suppor t RGB, e.g. Nexus 9.
277 final ByteBuffer rgbaData = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 4); 277 final ByteBuffer rgbaData = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 4);
278 GLES20.glReadPixels(0, 0, WIDTH, HEIGHT, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_ BYTE, rgbaData); 278 GLES20.glReadPixels(0, 0, WIDTH, HEIGHT, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_ BYTE, rgbaData);
279 GlUtil.checkNoGLES2Error("glReadPixels"); 279 GlUtil.checkNoGLES2Error("glReadPixels");
280 280
281 // Assert rendered image is pixel perfect to source RGB. 281 // Assert rendered image is pixel perfect to source RGB.
282 assertEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane); 282 assertEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane);
283 283
284 drawer.release(); 284 drawer.release();
285 surfaceTextureHelper.returnTextureFrame(); 285 surfaceTextureHelper.returnTextureFrame();
286 oesProducer.release(); 286 oesProducer.release();
287 surfaceTextureHelper.disconnect(); 287 surfaceTextureHelper.dispose();
288 eglBase.release(); 288 eglBase.release();
289 } 289 }
290 } 290 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/androidtests/src/org/webrtc/SurfaceTextureHelperTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698