Пример #1
0
    /**
     * Ensures the current EGL context is the one we expect.
     *
     * @return {@link #SURFACE_STATE_ERROR} if the correct EGL context cannot be made current,
     *     {@link #SURFACE_STATE_UPDATED} if the EGL context was changed or {@link
     *     #SURFACE_STATE_SUCCESS} if the EGL context was the correct one
     */
    int checkCurrent() {
      if (mEglThread != Thread.currentThread()) {
        throw new IllegalStateException(
            "Hardware acceleration can only be used with a "
                + "single UI thread.\nOriginal thread: "
                + mEglThread
                + "\n"
                + "Current thread: "
                + Thread.currentThread());
      }

      if (!mEglContext.equals(sEgl.eglGetCurrentContext())
          || !mEglSurface.equals(sEgl.eglGetCurrentSurface(EGL_DRAW))) {
        if (!sEgl.eglMakeCurrent(sEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
          Log.e(LOG_TAG, "eglMakeCurrent failed " + GLUtils.getEGLErrorString(sEgl.eglGetError()));
          fallback(true);
          return SURFACE_STATE_ERROR;
        } else {
          if (mUpdateDirtyRegions) {
            enableDirtyRegions();
            mUpdateDirtyRegions = false;
          }
          return SURFACE_STATE_UPDATED;
        }
      }
      return SURFACE_STATE_SUCCESS;
    }
  public EGLSurface eglGetCurrentSurface(int readdraw) {
    begin("eglGetCurrentSurface");
    arg("readdraw", readdraw);
    end();

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

    checkError();
    return result;
  }
Пример #3
0
 public void swapBuffers() {
   EGL10 egl = (EGL10) EGLContext.getEGL();
   EGLDisplay display = egl.eglGetCurrentDisplay();
   EGLSurface surface = egl.eglGetCurrentSurface(EGL10.EGL_READ);
   egl.eglSwapBuffers(display, surface);
 }