OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 /** | 102 /** |
103 * Test normal use by receiving three uniform texture frames. Texture frames a
re returned as early | 103 * Test normal use by receiving three uniform texture frames. Texture frames a
re returned as early |
104 * as possible. The texture pixel values are inspected by drawing the texture
frame to a pixel | 104 * as possible. The texture pixel values are inspected by drawing the texture
frame to a pixel |
105 * buffer and reading it back with glReadPixels(). | 105 * buffer and reading it back with glReadPixels(). |
106 */ | 106 */ |
107 @MediumTest | 107 @MediumTest |
108 public static void testThreeConstantColorFrames() throws InterruptedException
{ | 108 public static void testThreeConstantColorFrames() throws InterruptedException
{ |
109 final int width = 16; | 109 final int width = 16; |
110 final int height = 16; | 110 final int height = 16; |
111 // Create EGL base with a pixel buffer as display output. | 111 // Create EGL base with a pixel buffer as display output. |
112 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigType
.PIXEL_BUFFER); | 112 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.CONFIG_PIX
EL_BUFFER); |
113 eglBase.createPbufferSurface(width, height); | 113 eglBase.createPbufferSurface(width, height); |
114 final GlRectDrawer drawer = new GlRectDrawer(); | 114 final GlRectDrawer drawer = new GlRectDrawer(); |
115 | 115 |
116 // Create SurfaceTextureHelper and listener. | 116 // Create SurfaceTextureHelper and listener. |
117 final SurfaceTextureHelper surfaceTextureHelper = | 117 final SurfaceTextureHelper surfaceTextureHelper = |
118 SurfaceTextureHelper.create(eglBase.getContext()); | 118 SurfaceTextureHelper.create(eglBase.getContext()); |
119 final MockTextureListener listener = new MockTextureListener(); | 119 final MockTextureListener listener = new MockTextureListener(); |
120 surfaceTextureHelper.setListener(listener); | 120 surfaceTextureHelper.setListener(listener); |
121 surfaceTextureHelper.getSurfaceTexture().setDefaultBufferSize(width, height)
; | 121 surfaceTextureHelper.getSurfaceTexture().setDefaultBufferSize(width, height)
; |
122 | 122 |
123 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he SurfaceTexture in | 123 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he SurfaceTexture in |
124 // |surfaceTextureHelper| as the target EGLSurface. | 124 // |surfaceTextureHelper| as the target EGLSurface. |
125 final EglBase eglOesBase = new EglBase(eglBase.getContext(), EglBase.ConfigT
ype.PLAIN); | 125 final EglBase eglOesBase = new EglBase(eglBase.getContext(), EglBase.CONFIG_
PLAIN); |
126 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); | 126 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); |
127 assertEquals(eglOesBase.surfaceWidth(), width); | 127 assertEquals(eglOesBase.surfaceWidth(), width); |
128 assertEquals(eglOesBase.surfaceHeight(), height); | 128 assertEquals(eglOesBase.surfaceHeight(), height); |
129 | 129 |
130 final int red[] = new int[] {79, 144, 185}; | 130 final int red[] = new int[] {79, 144, 185}; |
131 final int green[] = new int[] {66, 210, 162}; | 131 final int green[] = new int[] {66, 210, 162}; |
132 final int blue[] = new int[] {161, 117, 158}; | 132 final int blue[] = new int[] {161, 117, 158}; |
133 // Draw three frames. | 133 // Draw three frames. |
134 for (int i = 0; i < 3; ++i) { | 134 for (int i = 0; i < 3; ++i) { |
135 // Draw a constant color frame onto the SurfaceTexture. | 135 // Draw a constant color frame onto the SurfaceTexture. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 /** | 169 /** |
170 * Test disconnecting the SurfaceTextureHelper while holding a pending texture
frame. The pending | 170 * Test disconnecting the SurfaceTextureHelper while holding a pending texture
frame. The pending |
171 * texture frame should still be valid, and this is tested by drawing the text
ure frame to a pixel | 171 * texture frame should still be valid, and this is tested by drawing the text
ure frame to a pixel |
172 * buffer and reading it back with glReadPixels(). | 172 * buffer and reading it back with glReadPixels(). |
173 */ | 173 */ |
174 @MediumTest | 174 @MediumTest |
175 public static void testLateReturnFrame() throws InterruptedException { | 175 public static void testLateReturnFrame() throws InterruptedException { |
176 final int width = 16; | 176 final int width = 16; |
177 final int height = 16; | 177 final int height = 16; |
178 // Create EGL base with a pixel buffer as display output. | 178 // Create EGL base with a pixel buffer as display output. |
179 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigType
.PIXEL_BUFFER); | 179 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.CONFIG_PIX
EL_BUFFER); |
180 eglBase.createPbufferSurface(width, height); | 180 eglBase.createPbufferSurface(width, height); |
181 | 181 |
182 // Create SurfaceTextureHelper and listener. | 182 // Create SurfaceTextureHelper and listener. |
183 final SurfaceTextureHelper surfaceTextureHelper = | 183 final SurfaceTextureHelper surfaceTextureHelper = |
184 SurfaceTextureHelper.create(eglBase.getContext()); | 184 SurfaceTextureHelper.create(eglBase.getContext()); |
185 final MockTextureListener listener = new MockTextureListener(); | 185 final MockTextureListener listener = new MockTextureListener(); |
186 surfaceTextureHelper.setListener(listener); | 186 surfaceTextureHelper.setListener(listener); |
187 surfaceTextureHelper.getSurfaceTexture().setDefaultBufferSize(width, height)
; | 187 surfaceTextureHelper.getSurfaceTexture().setDefaultBufferSize(width, height)
; |
188 | 188 |
189 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he SurfaceTexture in | 189 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he SurfaceTexture in |
190 // |surfaceTextureHelper| as the target EGLSurface. | 190 // |surfaceTextureHelper| as the target EGLSurface. |
191 final EglBase eglOesBase = new EglBase(eglBase.getContext(), EglBase.ConfigT
ype.PLAIN); | 191 final EglBase eglOesBase = new EglBase(eglBase.getContext(), EglBase.CONFIG_
PLAIN); |
192 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); | 192 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); |
193 assertEquals(eglOesBase.surfaceWidth(), width); | 193 assertEquals(eglOesBase.surfaceWidth(), width); |
194 assertEquals(eglOesBase.surfaceHeight(), height); | 194 assertEquals(eglOesBase.surfaceHeight(), height); |
195 | 195 |
196 final int red = 79; | 196 final int red = 79; |
197 final int green = 66; | 197 final int green = 66; |
198 final int blue = 161; | 198 final int blue = 161; |
199 // Draw a constant color frame onto the SurfaceTexture. | 199 // Draw a constant color frame onto the SurfaceTexture. |
200 eglOesBase.makeCurrent(); | 200 eglOesBase.makeCurrent(); |
201 GLES20.glClearColor(red / 255.0f, green / 255.0f, blue / 255.0f, 1.0f); | 201 GLES20.glClearColor(red / 255.0f, green / 255.0f, blue / 255.0f, 1.0f); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 * frames should be delivered to the listener. | 237 * frames should be delivered to the listener. |
238 */ | 238 */ |
239 @MediumTest | 239 @MediumTest |
240 public static void testDisconnect() throws InterruptedException { | 240 public static void testDisconnect() throws InterruptedException { |
241 // Create SurfaceTextureHelper and listener. | 241 // Create SurfaceTextureHelper and listener. |
242 final SurfaceTextureHelper surfaceTextureHelper = | 242 final SurfaceTextureHelper surfaceTextureHelper = |
243 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT); | 243 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT); |
244 final MockTextureListener listener = new MockTextureListener(); | 244 final MockTextureListener listener = new MockTextureListener(); |
245 surfaceTextureHelper.setListener(listener); | 245 surfaceTextureHelper.setListener(listener); |
246 // Create EglBase with the SurfaceTexture as target EGLSurface. | 246 // Create EglBase with the SurfaceTexture as target EGLSurface. |
247 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigType
.PLAIN); | 247 final EglBase eglBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.CONFIG_PLA
IN); |
248 eglBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); | 248 eglBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); |
249 eglBase.makeCurrent(); | 249 eglBase.makeCurrent(); |
250 // Assert no frame has been received yet. | 250 // Assert no frame has been received yet. |
251 assertFalse(listener.waitForNewFrame(1)); | 251 assertFalse(listener.waitForNewFrame(1)); |
252 // Draw and wait for one frame. | 252 // Draw and wait for one frame. |
253 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 253 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
254 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). | 254 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). |
255 eglBase.swapBuffers(); | 255 eglBase.swapBuffers(); |
256 listener.waitForNewFrame(); | 256 listener.waitForNewFrame(); |
257 surfaceTextureHelper.returnTextureFrame(); | 257 surfaceTextureHelper.returnTextureFrame(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 // Create SurfaceTextureHelper and listener. | 293 // Create SurfaceTextureHelper and listener. |
294 final SurfaceTextureHelper surfaceTextureHelper = | 294 final SurfaceTextureHelper surfaceTextureHelper = |
295 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT, handler); | 295 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT, handler); |
296 // Create a mock listener and expect frames to be delivered on |thread|. | 296 // Create a mock listener and expect frames to be delivered on |thread|. |
297 final MockTextureListener listener = new MockTextureListener(thread); | 297 final MockTextureListener listener = new MockTextureListener(thread); |
298 surfaceTextureHelper.setListener(listener); | 298 surfaceTextureHelper.setListener(listener); |
299 | 299 |
300 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he | 300 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he |
301 // SurfaceTexture in |surfaceTextureHelper| as the target EGLSurface. | 301 // SurfaceTexture in |surfaceTextureHelper| as the target EGLSurface. |
302 final EglBase eglOesBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigT
ype.PLAIN); | 302 final EglBase eglOesBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.CONFIG_
PLAIN); |
303 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); | 303 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); |
304 eglOesBase.makeCurrent(); | 304 eglOesBase.makeCurrent(); |
305 // Draw a frame onto the SurfaceTexture. | 305 // Draw a frame onto the SurfaceTexture. |
306 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 306 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
307 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). | 307 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). |
308 eglOesBase.swapBuffers(); | 308 eglOesBase.swapBuffers(); |
309 eglOesBase.release(); | 309 eglOesBase.release(); |
310 | 310 |
311 // Wait for an OES texture to arrive. | 311 // Wait for an OES texture to arrive. |
312 listener.waitForNewFrame(); | 312 listener.waitForNewFrame(); |
(...skipping 15 matching lines...) Expand all Loading... |
328 | 328 |
329 // Create SurfaceTextureHelper and listener. | 329 // Create SurfaceTextureHelper and listener. |
330 final SurfaceTextureHelper surfaceTextureHelper = | 330 final SurfaceTextureHelper surfaceTextureHelper = |
331 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT, handler); | 331 SurfaceTextureHelper.create(EGL10.EGL_NO_CONTEXT, handler); |
332 // Create a mock listener and expect frames to be delivered on |thread|. | 332 // Create a mock listener and expect frames to be delivered on |thread|. |
333 final MockTextureListener listener = new MockTextureListener(thread); | 333 final MockTextureListener listener = new MockTextureListener(thread); |
334 surfaceTextureHelper.setListener(listener); | 334 surfaceTextureHelper.setListener(listener); |
335 | 335 |
336 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he | 336 // Create resources for stubbing an OES texture producer. |eglOesBase| has t
he |
337 // SurfaceTexture in |surfaceTextureHelper| as the target EGLSurface. | 337 // SurfaceTexture in |surfaceTextureHelper| as the target EGLSurface. |
338 final EglBase eglOesBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.ConfigT
ype.PLAIN); | 338 final EglBase eglOesBase = new EglBase(EGL10.EGL_NO_CONTEXT, EglBase.CONFIG_
PLAIN); |
339 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); | 339 eglOesBase.createSurface(surfaceTextureHelper.getSurfaceTexture()); |
340 eglOesBase.makeCurrent(); | 340 eglOesBase.makeCurrent(); |
341 // Draw a frame onto the SurfaceTexture. | 341 // Draw a frame onto the SurfaceTexture. |
342 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); | 342 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); |
343 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). | 343 // swapBuffers() will ultimately trigger onTextureFrameAvailable(). |
344 eglOesBase.swapBuffers(); | 344 eglOesBase.swapBuffers(); |
345 eglOesBase.release(); | 345 eglOesBase.release(); |
346 | 346 |
347 // Wait for an OES texture to arrive. | 347 // Wait for an OES texture to arrive. |
348 listener.waitForNewFrame(); | 348 listener.waitForNewFrame(); |
349 | 349 |
350 surfaceTextureHelper.disconnect(handler); | 350 surfaceTextureHelper.disconnect(handler); |
351 | 351 |
352 surfaceTextureHelper.returnTextureFrame(); | 352 surfaceTextureHelper.returnTextureFrame(); |
353 } | 353 } |
354 } | 354 } |
OLD | NEW |