javax.microedition.khronos.egl.EGLSurface Java Examples

The following examples show how to use javax.microedition.khronos.egl.EGLSurface. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {

    int[] surfaceAttribs = {
            EGL10.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #2
Source File: GLTextureView.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #3
Source File: GLTextureView.java    From VideoRecorder with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
        EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #4
Source File: GLTextureView.java    From alpha-movie with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #5
Source File: EGLBase10.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private final boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
/*		if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        } */
        if (surface == null || surface == EGL10.EGL_NO_SURFACE) {
            final int error = mEgl.eglGetError();
            if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:EGL_BAD_NATIVE_WINDOW");
            }
            return false;
        }
        // attach EGL rendering context to specific EGL window surface
        if (!mEgl.eglMakeCurrent(mEglDisplay, surface, surface, mContext.eglContext)) {
			Log.w("TAG", "eglMakeCurrent" + mEgl.eglGetError());
			return false;
        }
        return true;
	}
 
Example #6
Source File: GLSurfaceView.java    From EZFilter with MIT License 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #7
Source File: GLTextureView.java    From EZFilter with MIT License 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #8
Source File: GLSurfaceView.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
									  EGLConfig config, Object nativeWindow) {
	EGLSurface result = null;
	try {
		result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
	} catch (IllegalArgumentException e) {
		// This exception indicates that the surface flinger surface
		// is not valid. This can happen if the surface flinger surface has
		// been torn down, but the application has not yet been
		// notified via SurfaceHolder.Callback.surfaceDestroyed.
		// In theory the application should be notified first,
		// but in practice sometimes it is not. See b/4588890
		Log.e(TAG, "eglCreateWindowSurface", e);
	}
	return result;
}
 
Example #9
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public android.opengl.EGLSurface createWindowSurface(android.opengl.EGLDisplay display, android.opengl.EGLConfig config, Object nativeWindow) {
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    android.opengl.EGLSurface result = null;
    try {
        result = EGL14.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs, 0);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #10
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #11
Source File: GLTextureView.java    From ZGDanmaku with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #12
Source File: GLTextureView.java    From android-RoundedTextureView with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config,
    Object nativeWindow) {
  EGLSurface result = null;
  try {
    result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
  } catch (IllegalArgumentException e) {
    // This exception indicates that the surface flinger surface
    // is not valid. This can happen if the surface flinger surface has
    // been torn down, but the application has not yet been
    // notified via SurfaceHolder.Callback.surfaceDestroyed.
    // In theory the application should be notified first,
    // but in practice sometimes it is not. See b/4588890
    Log.e(TAG, "eglCreateWindowSurface", e);
  }
  return result;
}
 
Example #13
Source File: GLThread.java    From android-openGL-canvas with Apache License 2.0 6 votes vote down vote up
@Override
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {

    int[] surfaceAttribs = {
            EGL10.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #14
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private void arg(String name, EGLSurface object) {
    if (object == EGL10.EGL_NO_SURFACE) {
        arg(name, "EGL10.EGL_NO_SURFACE");
    } else {
        arg(name, toString(object));
    }
}
 
Example #15
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface,
                              Object native_pixmap) {
    begin("eglCopyBuffers");
    arg("display", display);
    arg("surface", surface);
    arg("native_pixmap", native_pixmap);
    end();

    boolean result = mEgl10.eglCopyBuffers(display, surface, native_pixmap);
    returns(result);
    checkError();
    return result;
}
 
Example #16
Source File: EGLBase10.java    From libcommon with Apache License 2.0 5 votes vote down vote up
private final int swap(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "swap:");
        if (!mEgl.eglSwapBuffers(mEglDisplay, surface)) {
        	final int err = mEgl.eglGetError();
//        	if (DEBUG) Log.w(TAG, "swap:err=" + err);
            return err;
        }
        return EGL10.EGL_SUCCESS;
    }
 
Example #17
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public boolean eglSwapBuffers(EGLDisplay display, EGLSurface surface) {
    begin("eglSwapBuffers");
    arg("display", display);
    arg("surface", surface);
    end();
    boolean result = mEgl10.eglSwapBuffers(display, surface);
    returns(result);
    checkError();
    return result;
}
 
Example #18
Source File: EglBuffer.java    From HokoBlur with Apache License 2.0 5 votes vote down vote up
private EGLSurface createSurface(int width, int height) {
    int[] surfaceAttrs = {
            EGL10.EGL_WIDTH, width,
            EGL10.EGL_HEIGHT, height,
            EGL10.EGL_NONE
    };

    EGLSurface eglSurface = mEgl.eglCreatePbufferSurface(mEGLDisplay, mEglConfigs[0], surfaceAttrs);

    mEgl.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, getEGLContext());

    return eglSurface;

}
 
Example #19
Source File: EglBuffer.java    From HokoBlur with Apache License 2.0 5 votes vote down vote up
public Bitmap getBlurBitmap(Bitmap bitmap) {
    final int w = bitmap.getWidth();
    final int h = bitmap.getHeight();

    try {
        EGLSurface eglSurface = createSurface(w, h);
        if (eglSurface == null) {
            Log.e(TAG, "Create surface error");
            return bitmap;
        }

        OffScreenBlurRenderer renderer = getRenderer();
        if (renderer != null) {
            renderer.onDrawFrame(bitmap);
            mEgl.eglSwapBuffers(mEGLDisplay, eglSurface);
        } else {
            Log.e(TAG, "Renderer is unavailable");
            return bitmap;
        }
        convertToBitmap(bitmap);
    } catch (Throwable t) {
        Log.e(TAG, "Blur the bitmap error", t);
    } finally {
        unbindEglCurrent();
    }

    return bitmap;

}
 
Example #20
Source File: WindowSurfaceFactory.java    From VIA-AI with MIT License 5 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    d = display;
    c = config;
    try {
        mEGLPreviewSurface = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "eglCreateWindowSurface (native)", e);
    }
    // this return will trigger Renderer
    result = mEGLPreviewSurface;
    return result;
}
 
Example #21
Source File: EGLBase10.java    From libcommon with Apache License 2.0 5 votes vote down vote up
private final int getSurfaceHeight(final EGLSurface surface) {
	final int[] value = new int[1];
	final boolean ret = mEgl.eglQuerySurface(mEglDisplay,
		surface, EGL10.EGL_HEIGHT, value);
	if (!ret) value[0] = 0;
	return value[0];
}
 
Example #22
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public EGLSurface eglCreatePbufferSurface(EGLDisplay display,
                                          EGLConfig config, int[] attrib_list) {
    begin("eglCreatePbufferSurface");
    arg("display", display);
    arg("config", config);
    arg("attrib_list", attrib_list);
    end();

    EGLSurface result = mEgl10.eglCreatePbufferSurface(display, config,
            attrib_list);
    returns(result);
    checkError();
    return result;
}
 
Example #23
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public EGLSurface eglCreatePixmapSurface(EGLDisplay display,
                                         EGLConfig config, Object native_pixmap, int[] attrib_list) {
    begin("eglCreatePixmapSurface");
    arg("display", display);
    arg("config", config);
    arg("native_pixmap", native_pixmap);
    arg("attrib_list", attrib_list);
    end();

    EGLSurface result = mEgl10.eglCreatePixmapSurface(display, config,
            native_pixmap, attrib_list);
    returns(result);
    checkError();
    return result;
}
 
Example #24
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public EGLSurface eglCreateWindowSurface(EGLDisplay display,
                                         EGLConfig config, Object native_window, int[] attrib_list) {
    begin("eglCreateWindowSurface");
    arg("display", display);
    arg("config", config);
    arg("native_window", native_window);
    arg("attrib_list", attrib_list);
    end();

    EGLSurface result = mEgl10.eglCreateWindowSurface(display, config,
            native_window, attrib_list);
    returns(result);
    checkError();
    return result;
}
 
Example #25
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public boolean eglDestroySurface(EGLDisplay display, EGLSurface surface) {
    begin("eglDestroySurface");
    arg("display", display);
    arg("surface", surface);
    end();

    boolean result = mEgl10.eglDestroySurface(display, surface);
    returns(result);
    checkError();
    return result;
}
 
Example #26
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public EGLSurface eglGetCurrentSurface(int readdraw) {
    begin("eglGetCurrentSurface");
    arg("readdraw", readdraw);
    end();

    EGLSurface result = mEgl10.eglGetCurrentSurface(readdraw);
    returns(result);

    checkError();
    return result;
}
 
Example #27
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public boolean eglMakeCurrent(EGLDisplay display, EGLSurface draw,
                              EGLSurface read, EGLContext context) {
    begin("eglMakeCurrent");
    arg("display", display);
    arg("draw", draw);
    arg("read", read);
    arg("context", context);
    end();
    boolean result = mEgl10.eglMakeCurrent(display, draw, read, context);
    returns(result);
    checkError();
    return result;
}
 
Example #28
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public boolean eglQuerySurface(EGLDisplay display, EGLSurface surface,
                               int attribute, int[] value) {
    begin("eglQuerySurface");
    arg("display", display);
    arg("surface", surface);
    arg("attribute", attribute);
    end();
    boolean result = mEgl10.eglQuerySurface(display, surface, attribute,
            value);
    returns(value[0]);
    returns(result);
    checkError();
    return result;
}
 
Example #29
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
private void arg(String name, EGLSurface object) {
    if (object == EGL10.EGL_NO_SURFACE) {
        arg(name, "EGL10.EGL_NO_SURFACE");
    } else {
        arg(name, toString(object));
    }
}
 
Example #30
Source File: EGLBase10.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 現在のスレッドの既存のレンダリングコンテキストがあればそれを共有して
 * 新しいレンダリングコンテキストを生成する
 * 既存のレンダリングコンテキストが存在していなければ独立したレンダリングコンテキストを
 * 生成する
 * @param maxClientVersion
 * @param withDepthBuffer
 * @param stencilBits
 * @param isRecordable
 * @return
 */
/*package*/ static EGLBase createFromCurrentImpl(final int maxClientVersion,
	final boolean withDepthBuffer, final int stencilBits, final boolean isRecordable) {

	Context context = null;
	final EGL10 egl10 = (EGL10)EGLContext.getEGL();
	final EGLContext currentContext = egl10.eglGetCurrentContext();
	final EGLSurface currentSurface = egl10.eglGetCurrentSurface(EGL10.EGL_DRAW);
	if ((currentContext != null) && (currentSurface != null)) {
		context = wrap(currentContext);
	}
	return new EGLBase10(maxClientVersion, context, withDepthBuffer, stencilBits, isRecordable);
}