Java Code Examples for android.opengl.EGL14#EGL_NO_CONTEXT

The following examples show how to use android.opengl.EGL14#EGL_NO_CONTEXT . 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: InstantCameraView.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void finalize() throws Throwable {
    try {
        if (eglDisplay != EGL14.EGL_NO_DISPLAY) {
            EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
            EGL14.eglDestroyContext(eglDisplay, eglContext);
            EGL14.eglReleaseThread();
            EGL14.eglTerminate(eglDisplay);
            eglDisplay = EGL14.EGL_NO_DISPLAY;
            eglContext = EGL14.EGL_NO_CONTEXT;
            eglConfig = null;
        }
    } finally {
        super.finalize();
    }
}
 
Example 2
Source File: EglCore.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  This must be
 * called from the thread where the context was created.
 * <p>
 * On completion, no context will be current.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
        // every eglInitialize() we need an eglTerminate().
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLConfig = null;
}
 
Example 3
Source File: InputSurface.java    From SimpleVideoEdit with Apache License 2.0 6 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mSurface.release();

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;

    mSurface = null;
}
 
Example 4
Source File: EglBase14.java    From UltraGpuImage with MIT License 6 votes vote down vote up
private static EGLContext createEglContext(
    @Nullable EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
  EGLContext rootContext =
      sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
  }
  if (eglContext == EGL14.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
  return eglContext;
}
 
Example 5
Source File: EncodeAndMuxTest.java    From Android-MediaCodec-Examples with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mSurface.release();

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;

    mSurface = null;
}
 
Example 6
Source File: OutputSurface.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }
    mSurface.release();
    // this causes a bunch of warnings that appear harmless but might confuse someone:
    //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
    //mSurfaceTexture.release();
    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mTextureRender = null;
    mSurface = null;
    mSurfaceTexture = null;
}
 
Example 7
Source File: EglCore.java    From AndroidPlayground with MIT License 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  This must be
 * called from the thread where the context was created.
 * <p>
 * On completion, no context will be current.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
        // every eglInitialize() we need an eglTerminate().
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLConfig = null;
}
 
Example 8
Source File: EGLEnvironment.java    From EZFilter with MIT License 5 votes vote down vote up
public void release() {
    if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
        destroyContext();
        EGL14.eglTerminate(mEglDisplay);
        EGL14.eglReleaseThread();
    }
    mEglDisplay = EGL14.EGL_NO_DISPLAY;
    mEglContext = EGL14.EGL_NO_CONTEXT;
}
 
Example 9
Source File: EGLBase.java    From UVCCameraZxing with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 10
Source File: EGLBase.java    From AudioVideoPlayerSample with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 11
Source File: SurfaceManager.java    From spydroid-ipcamera with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
	if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
		EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
				EGL14.EGL_NO_CONTEXT);
		EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
		EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
		EGL14.eglReleaseThread();
		EGL14.eglTerminate(mEGLDisplay);
	}
	mEGLDisplay = EGL14.EGL_NO_DISPLAY;
	mEGLContext = EGL14.EGL_NO_CONTEXT;
	mEGLSurface = EGL14.EGL_NO_SURFACE;
	mSurface.release();
}
 
Example 12
Source File: InputSurface.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }
    mSurface.release();
    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mSurface = null;
}
 
Example 13
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 14
Source File: InputSurface.java    From android-transcoder with Apache License 2.0 5 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }
    mSurface.release();
    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mSurface = null;
}
 
Example 15
Source File: SurfaceManager.java    From libstreaming with Apache License 2.0 5 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
	if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
		EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
				EGL14.EGL_NO_CONTEXT);
		EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
		EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
		EGL14.eglReleaseThread();
		EGL14.eglTerminate(mEGLDisplay);
	}
	mEGLDisplay = EGL14.EGL_NO_DISPLAY;
	mEGLContext = EGL14.EGL_NO_CONTEXT;
	mEGLSurface = EGL14.EGL_NO_SURFACE;
	mSurface.release();
}
 
Example 16
Source File: EGLBase.java    From AudioVideoPlayerSample with Apache License 2.0 5 votes vote down vote up
private void destroyContext() {
if (DEBUG) Log.v(TAG, "destroyContext:");

      if (!EGL14.eglDestroyContext(mEglDisplay, mEglContext)) {
          Log.e("DefaultContextFactory", "display:" + mEglDisplay + " context: " + mEglContext);
          Log.e(TAG, "eglDestroyContex:" + EGL14.eglGetError());
      }
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 17
Source File: BaseSurface.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
}
 
Example 18
Source File: EglContextWrapper.java    From android-openGL-canvas with Apache License 2.0 4 votes vote down vote up
public EGLNoContextWrapper() {
    eglContextOld = EGL10.EGL_NO_CONTEXT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        eglContext = EGL14.EGL_NO_CONTEXT;
    }
}
 
Example 19
Source File: EglContextWrapper.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public EGLNoContextWrapper() {
    eglContextOld = EGL10.EGL_NO_CONTEXT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        eglContext = EGL14.EGL_NO_CONTEXT;
    }
}
 
Example 20
Source File: EglBase14Impl.java    From webrtc_android with MIT License 4 votes vote down vote up
private void checkIsNotReleased() {
  if (eglDisplay == EGL14.EGL_NO_DISPLAY || eglContext == EGL14.EGL_NO_CONTEXT
      || eglConfig == null) {
    throw new RuntimeException("This object has been released");
  }
}