1 // C function EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) 2 3 private static native EGLSurface _eglCreateWindowSurface( 4 EGLDisplay dpy, 5 EGLConfig config, 6 Object win, 7 int[] attrib_list, 8 int offset 9 ); 10 11 private static native EGLSurface _eglCreateWindowSurfaceTexture( 12 EGLDisplay dpy, 13 EGLConfig config, 14 Object win, 15 int[] attrib_list, 16 int offset 17 ); 18 19 public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, 20 EGLConfig config, 21 Object win, 22 int[] attrib_list, 23 int offset 24 ){ 25 Surface sur = null; 26 if (win instanceof SurfaceView) { 27 SurfaceView surfaceView = (SurfaceView)win; 28 sur = surfaceView.getHolder().getSurface(); 29 } else if (win instanceof SurfaceHolder) { 30 SurfaceHolder holder = (SurfaceHolder)win; 31 sur = holder.getSurface(); 32 } else if (win instanceof Surface) { 33 sur = (Surface) win; 34 } 35 36 EGLSurface surface; 37 if (sur != null) { 38 surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset); 39 } else if (win instanceof SurfaceTexture) { 40 surface = _eglCreateWindowSurfaceTexture(dpy, config, 41 win, attrib_list, offset); 42 } else { 43 throw new java.lang.UnsupportedOperationException( 44 "eglCreateWindowSurface() can only be called with an instance of " + 45 "Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " + 46 "this will be fixed later."); 47 } 48 49 return surface; 50 } 51