3535import static android .opengl .EGL14 .eglCreateContext ;
3636import static android .opengl .EGL14 .eglCreatePbufferSurface ;
3737import static android .opengl .EGL14 .eglDestroyContext ;
38+ import static android .opengl .EGL14 .eglDestroySurface ;
3839import static android .opengl .EGL14 .eglGetDisplay ;
3940import static android .opengl .EGL14 .eglInitialize ;
4041import static android .opengl .EGL14 .eglMakeCurrent ;
@@ -175,8 +176,9 @@ private static class DummySurfaceThread extends HandlerThread implements OnFrame
175176 private static final int MSG_RELEASE = 3 ;
176177
177178 private final int [] textureIdHolder ;
178- private EGLContext context ;
179179 private EGLDisplay display ;
180+ private EGLContext context ;
181+ private EGLSurface pbuffer ;
180182 private Handler handler ;
181183 private SurfaceTexture surfaceTexture ;
182184
@@ -315,7 +317,7 @@ private void initInternal(boolean secure) {
315317 EGL_HEIGHT , 1 ,
316318 EGL_NONE };
317319 }
318- EGLSurface pbuffer = eglCreatePbufferSurface (display , config , pbufferAttributes , 0 );
320+ pbuffer = eglCreatePbufferSurface (display , config , pbufferAttributes , 0 );
319321 Assertions .checkState (pbuffer != null , "eglCreatePbufferSurface failed" );
320322
321323 boolean eglMadeCurrent = eglMakeCurrent (display , pbuffer , pbuffer , context );
@@ -334,11 +336,15 @@ private void releaseInternal() {
334336 glDeleteTextures (1 , textureIdHolder , 0 );
335337 }
336338 } finally {
339+ if (pbuffer != null ) {
340+ eglDestroySurface (display , pbuffer );
341+ }
337342 if (context != null ) {
338343 eglDestroyContext (display , context );
339344 }
340- display = null ;
345+ pbuffer = null ;
341346 context = null ;
347+ display = null ;
342348 surface = null ;
343349 surfaceTexture = null ;
344350 }
0 commit comments