Java Code Examples for android.opengl.EGL14#EGL_NO_SURFACE

The following examples show how to use android.opengl.EGL14#EGL_NO_SURFACE . 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: EGLBase.java    From Tok-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * change context to draw this window surface
 */
private boolean makeCurrent(final EGLSurface surface) {
    //		if (DEBUG) Log.v(TAG, "makeCurrent:");
    if (mEglDisplay == null) {
        LogUtil.i(TAG, "makeCurrent:eglDisplay not initialized");
    }
    if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
        final int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }
    // attach EGL renderring context to specific EGL window surface
    if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
        return false;
    }
    return true;
}
 
Example 2
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 3
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private 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 == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 4
Source File: EGLBase.java    From TimeLapseRecordingSample with Apache License 2.0 5 votes vote down vote up
private void destroyWindowSurface(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "destroySurface:");

       if (surface != EGL14.EGL_NO_SURFACE) {
       	EGL14.eglMakeCurrent(mEglDisplay,
       		EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
       	EGL14.eglDestroySurface(mEglDisplay, surface);
       }
       surface = EGL14.EGL_NO_SURFACE;
       if (DEBUG) Log.v(TAG, "destroySurface:finished");
}
 
Example 5
Source File: EglSurfaceBase.java    From RtmpPublisher with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an off-screen surface.
 */
public void createOffscreenSurface(int width, int height) {
    if (mEGLSurface != EGL14.EGL_NO_SURFACE) {
        throw new IllegalStateException("surface already created");
    }
    mEGLSurface = mEglCore.createOffscreenSurface(width, height);
    mWidth = width;
    mHeight = height;
}
 
Example 6
Source File: EglBase14Impl.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void swapBuffers() {
  checkIsNotReleased();
  if (eglSurface == EGL14.EGL_NO_SURFACE) {
    throw new RuntimeException("No EGLSurface - can't swap buffers");
  }
  synchronized (EglBase.lock) {
    EGL14.eglSwapBuffers(eglDisplay, eglSurface);
  }
}
 
Example 7
Source File: EglSurfaceBase.java    From grafika with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a window surface.
 * <p>
 * @param surface May be a Surface or SurfaceTexture.
 */
public void createWindowSurface(Object surface) {
    if (mEGLSurface != EGL14.EGL_NO_SURFACE) {
        throw new IllegalStateException("surface already created");
    }
    mEGLSurface = mEglCore.createWindowSurface(surface);

    // Don't cache width/height here, because the size of the underlying surface can change
    // out from under us (see e.g. HardwareScalerActivity).
    //mWidth = mEglCore.querySurface(mEGLSurface, EGL14.EGL_WIDTH);
    //mHeight = mEglCore.querySurface(mEGLSurface, EGL14.EGL_HEIGHT);
}
 
Example 8
Source File: EglBase14Impl.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void releaseSurface() {
  if (eglSurface != EGL14.EGL_NO_SURFACE) {
    EGL14.eglDestroySurface(eglDisplay, eglSurface);
    eglSurface = EGL14.EGL_NO_SURFACE;
  }
}
 
Example 9
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 10
Source File: EglSurfaceBase.java    From AndroidPlayground with MIT License 5 votes vote down vote up
/**
 * Creates an off-screen surface.
 */
public void createOffscreenSurface(int width, int height) {
    if (mEGLSurface != EGL14.EGL_NO_SURFACE) {
        throw new IllegalStateException("surface already created");
    }
    mEGLSurface = mEglCore.createOffscreenSurface(width, height);
    mWidth = width;
    mHeight = height;
}
 
Example 11
Source File: EglSurfaceBase.java    From VIA-AI with MIT License 5 votes vote down vote up
/**
 * Creates a window surface.
 * <p>
 * @param surface May be a Surface or SurfaceTexture.
 */
public void createWindowSurface(Object surface) {
    if (mEGLSurface != EGL14.EGL_NO_SURFACE) {
        throw new IllegalStateException("surface already created");
    }
    mEGLSurface = mEglCore.createWindowSurface(surface);

    // Don't cache width/height here, because the size of the underlying surface can change
    // out from under us (see e.g. HardwareScalerActivity).
    //mWidth = mEglCore.querySurface(mEGLSurface, EGL14.EGL_WIDTH);
    //mHeight = mEglCore.querySurface(mEGLSurface, EGL14.EGL_HEIGHT);
}
 
Example 12
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 13
Source File: EglHelperAPI17.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private void destroySurfaceImp() {
    if (mEglSurface != null && mEglSurface != EGL14.EGL_NO_SURFACE) {
        EGL14.eglMakeCurrent(mEglDisplay, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        eglWindowSurfaceFactory.destroySurface(mEglDisplay, mEglSurface);
        mEglSurface = null;
    }
}
 
Example 14
Source File: EglSurface.java    From GPUVideo-android with MIT License 4 votes vote down vote up
public void release() {
    if (DEBUG) Log.v(TAG, "EglSurface:release:");
    egl.makeDefault();
    egl.destroyWindowSurface(eglSurface);
    eglSurface = EGL14.EGL_NO_SURFACE;
}
 
Example 15
Source File: EglSurfaceBase.java    From Fatigue-Detection with MIT License 4 votes vote down vote up
/**
 * Release the EGL surface.
 */
public void releaseEglSurface() {
    mEglCore.releaseSurface(mEGLSurface);
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mWidth = mHeight = -1;
}
 
Example 16
Source File: EGLSurfaceTexture.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private static EGLSurface createEGLSurface(
    EGLDisplay display, EGLConfig config, EGLContext context, @SecureMode int secureMode) {
  EGLSurface surface;
  if (secureMode == SECURE_MODE_SURFACELESS_CONTEXT) {
    surface = EGL14.EGL_NO_SURFACE;
  } else {
    int[] pbufferAttributes;
    if (secureMode == SECURE_MODE_PROTECTED_PBUFFER) {
      pbufferAttributes =
          new int[] {
            EGL14.EGL_WIDTH,
            EGL_SURFACE_WIDTH,
            EGL14.EGL_HEIGHT,
            EGL_SURFACE_HEIGHT,
            EGL_PROTECTED_CONTENT_EXT,
            EGL14.EGL_TRUE,
            EGL14.EGL_NONE
          };
    } else {
      pbufferAttributes =
          new int[] {
            EGL14.EGL_WIDTH,
            EGL_SURFACE_WIDTH,
            EGL14.EGL_HEIGHT,
            EGL_SURFACE_HEIGHT,
            EGL14.EGL_NONE
          };
    }
    surface = EGL14.eglCreatePbufferSurface(display, config, pbufferAttributes, /* offset= */ 0);
    if (surface == null) {
      throw new GlException("eglCreatePbufferSurface failed");
    }
  }

  boolean eglMadeCurrent =
      EGL14.eglMakeCurrent(display, /* draw= */ surface, /* read= */ surface, context);
  if (!eglMadeCurrent) {
    throw new GlException("eglMakeCurrent failed");
  }
  return surface;
}
 
Example 17
Source File: EglBaseSurface.java    From Lassi-Android with MIT License 4 votes vote down vote up
/**
 * Release the EGL surface.
 */
public void releaseEglSurface() {
    mEglCore.releaseSurface(mEGLSurface);
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mWidth = mHeight = -1;
}
 
Example 18
Source File: EglSurfaceBase.java    From sealrtc-android with MIT License 4 votes vote down vote up
/** Release the EGL surface. */
public void releaseEglSurface() {
    mEglCore.releaseSurface(mEGLSurface);
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mWidth = mHeight = -1;
}
 
Example 19
Source File: EglSurfaceBase.java    From AndroidPlayground with MIT License 4 votes vote down vote up
/**
 * Release the EGL surface.
 */
public void releaseEglSurface() {
    mEglCore.releaseSurface(mEGLSurface);
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mWidth = mHeight = -1;
}
 
Example 20
Source File: EGLSurfaceTexture.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
private static EGLSurface createEGLSurface(
    EGLDisplay display, EGLConfig config, EGLContext context, @SecureMode int secureMode) {
  EGLSurface surface;
  if (secureMode == SECURE_MODE_SURFACELESS_CONTEXT) {
    surface = EGL14.EGL_NO_SURFACE;
  } else {
    int[] pbufferAttributes;
    if (secureMode == SECURE_MODE_PROTECTED_PBUFFER) {
      pbufferAttributes =
          new int[] {
            EGL14.EGL_WIDTH,
            EGL_SURFACE_WIDTH,
            EGL14.EGL_HEIGHT,
            EGL_SURFACE_HEIGHT,
            EGL_PROTECTED_CONTENT_EXT,
            EGL14.EGL_TRUE,
            EGL14.EGL_NONE
          };
    } else {
      pbufferAttributes =
          new int[] {
            EGL14.EGL_WIDTH,
            EGL_SURFACE_WIDTH,
            EGL14.EGL_HEIGHT,
            EGL_SURFACE_HEIGHT,
            EGL14.EGL_NONE
          };
    }
    surface = EGL14.eglCreatePbufferSurface(display, config, pbufferAttributes, /* offset= */ 0);
    if (surface == null) {
      throw new GlException("eglCreatePbufferSurface failed");
    }
  }

  boolean eglMadeCurrent =
      EGL14.eglMakeCurrent(display, /* draw= */ surface, /* read= */ surface, context);
  if (!eglMadeCurrent) {
    throw new GlException("eglMakeCurrent failed");
  }
  return surface;
}