Java Code Examples for android.opengl.EGL14#eglSwapBuffers()

The following examples show how to use android.opengl.EGL14#eglSwapBuffers() . 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 AudioVideoRecordingSample with Apache License 2.0 5 votes vote down vote up
private int swap(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "swap:");
        if (!EGL14.eglSwapBuffers(mEglDisplay, surface)) {
        	final int err = EGL14.eglGetError();
        	if (DEBUG) Log.w(TAG, "swap:err=" + err);
            return err;
        }
        return EGL14.EGL_SUCCESS;
    }
 
Example 2
Source File: EGLBase.java    From CameraRecorder-android with MIT License 5 votes vote down vote up
int swap(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "swap:");
        if (!EGL14.eglSwapBuffers(eglDisplay, surface)) {
            final int err = EGL14.eglGetError();
            if (DEBUG) Log.w(TAG, "swap:err=" + err);
            return err;
        }
        return EGL14.EGL_SUCCESS;
    }
 
Example 3
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 4
Source File: EglBase14Impl.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void swapBuffers(long timeStampNs) {
  checkIsNotReleased();
  if (eglSurface == EGL14.EGL_NO_SURFACE) {
    throw new RuntimeException("No EGLSurface - can't swap buffers");
  }
  synchronized (EglBase.lock) {
    // See
    // https://android.googlesource.com/platform/frameworks/native/+/tools_r22.2/opengl/specs/EGL_ANDROID_presentation_time.txt
    EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs);
    EGL14.eglSwapBuffers(eglDisplay, eglSurface);
  }
}
 
Example 5
Source File: SurfaceTextureRenderer.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean swapBuffers(EGLSurface surface)
        throws LegacyExceptionUtils.BufferQueueAbandonedException {
    boolean result = EGL14.eglSwapBuffers(mEGLDisplay, surface);

    int error = EGL14.eglGetError();
    switch (error) {
        case EGL14.EGL_SUCCESS:
            return result;

        // Check for an abandoned buffer queue, or other error conditions out
        // of the user's control.
        //
        // From the EGL 1.4 spec (2013-12-04), Section 3.9.4 Posting Errors:
        //
        //   If eglSwapBuffers is called and the native window associated with
        //   surface is no longer valid, an EGL_BAD_NATIVE_WINDOW error is
        //   generated.
        //
        // We also interpret EGL_BAD_SURFACE as indicating an abandoned
        // surface, even though the EGL spec does not document it as such, for
        // backwards compatibility with older versions of this file.
        case EGL14.EGL_BAD_NATIVE_WINDOW:
        case EGL14.EGL_BAD_SURFACE:
            throw new LegacyExceptionUtils.BufferQueueAbandonedException();

        default:
            throw new IllegalStateException(
                    "swapBuffers: EGL error: 0x" + Integer.toHexString(error));
    }
}
 
Example 6
Source File: ColorFade.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Draws an animation frame showing the color fade activated at the
 * specified level.
 *
 * @param level The color fade level.
 * @return True if successful.
 */
public boolean draw(float level) {
    if (DEBUG) {
        Slog.d(TAG, "drawFrame: level=" + level);
    }

    if (!mPrepared) {
        return false;
    }

    if (mMode == MODE_FADE) {
        return showSurface(1.0f - level);
    }

    if (!attachEglContext()) {
        return false;
    }
    try {
        // Clear frame to solid black.
        GLES20.glClearColor(0f, 0f, 0f, 1f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

        // Draw the frame.
        double one_minus_level = 1 - level;
        double cos = Math.cos(Math.PI * one_minus_level);
        double sign = cos < 0 ? -1 : 1;
        float opacity = (float) -Math.pow(one_minus_level, 2) + 1;
        float gamma = (float) ((0.5d * sign * Math.pow(cos, 2) + 0.5d) * 0.9d + 0.1d);
        drawFaded(opacity, 1.f / gamma);
        if (checkGlErrors("drawFrame")) {
            return false;
        }

        EGL14.eglSwapBuffers(mEglDisplay, mEglSurface);
    } finally {
        detachEglContext();
    }
    return showSurface(1.0f);
}
 
Example 7
Source File: EglManager.java    From AudioVideoCodec with Apache License 2.0 4 votes vote down vote up
/**
 * 调用SwapBuffer进行双缓冲切换显示渲染画面
 */
public boolean swapBuffer() {
    return EGL14.eglSwapBuffers(eglDisplay, eglSurface);
}
 
Example 8
Source File: InputSurface.java    From VideoProcessor with Apache License 2.0 4 votes vote down vote up
public boolean swapBuffers() {
    return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
}
 
Example 9
Source File: InputSurface.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 */
public boolean swapBuffers() {
    return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
}
 
Example 10
Source File: InputSurface.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
public boolean swapBuffers() {
    return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
}
 
Example 11
Source File: InputSurface.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
public boolean swapBuffers() {
    return EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
}
 
Example 12
Source File: BaseSurface.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 */
public boolean swapBuffers() {
    boolean result = EGL14.eglSwapBuffers(mEGLDisplay, mEGLSurface);
    checkEglError("eglSwapBuffers");
    return result;
}
 
Example 13
Source File: EglCore.java    From Fatigue-Detection with MIT License 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 14
Source File: EglCore.java    From kickflip-android-sdk with Apache License 2.0 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 15
Source File: EglCore.java    From Lassi-Android with MIT License 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 16
Source File: EglCore.java    From LiveVideoBroadcaster with Apache License 2.0 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 17
Source File: EglCore.java    From sealrtc-android with MIT License 2 votes vote down vote up
/**
 * Calls eglSwapBuffers. Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 18
Source File: EglCore.java    From RtmpPublisher with Apache License 2.0 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 19
Source File: EglCore.java    From FuAgoraDemoDroid with MIT License 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(mEGLDisplay, eglSurface);
}
 
Example 20
Source File: EglCore.java    From MockCamera with Apache License 2.0 2 votes vote down vote up
/**
 * Calls eglSwapBuffers.  Use this to "publish" the current frame.
 *
 * @return false on failure
 */
public boolean swapBuffers(EGLSurface eglSurface) {
    return EGL14.eglSwapBuffers(eGLDisplay, eglSurface);
}