Esempio n. 1
0
 void destroySurface() {
   if (mEglSurface != null && mEglSurface != EGL_NO_SURFACE) {
     sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
     sEgl.eglDestroySurface(sEglDisplay, mEglSurface);
     mEglSurface = null;
   }
 }
 @Override
 public void destroySurface(
     final EGL10 egl, final EGLDisplay display, final EGLSurface surface) {
   Log.v(
       TAG,
       "EGLWindowSurfaceFactory.destroySurface " + Integer.toHexString(surface.hashCode()));
   egl.eglDestroySurface(display, surface);
 }
Esempio n. 3
0
 private void cleanupgl() {
   // Unbind and destroy the old EGL surface, if there is one.
   if (surface != null) {
     egl.eglMakeCurrent(
         display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
     egl.eglDestroySurface(display, surface);
     surface = null;
   }
 }
 private void destroySurfaceForTimeWarp() {
   if (null != mMainSurface) {
     Log.v(TAG, "destroying mMainSurface: 0x%x", mMainSurface.hashCode());
     final EGL10 egl = (EGL10) EGLContext.getEGL();
     final EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
     egl.eglDestroySurface(display, mMainSurface);
     mMainSurface = null;
   }
 }
  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;
  }
Esempio n. 6
0
  private void createSurface() {
    hasSurface = false;

    if (surface != null) {
      egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
      egl.eglDestroySurface(display, surface);
    }

    surface = egl.eglCreateWindowSurface(display, config, surfaceHolder, null);
    egl.eglMakeCurrent(display, surface, surface, eglContext);

    gl = eglContext.getGL();

    hasSurface = true;
  }
Esempio n. 7
0
  public void surfaceDestroyed(SurfaceHolder arg0) {
    if (running) {
      running = false;
      this.newFrameLock.setValue(true);
      try {
        mainLoop.join();
      } catch (Exception ex) {
      }
      mainLoop = null;

      egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
      egl.eglDestroySurface(dpy, surface);
      egl.eglDestroyContext(dpy, eglContext);
      egl.eglTerminate(dpy);
    }
  }
Esempio n. 8
0
  public static void deleteGLContext() {
    if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext != EGL10.EGL_NO_CONTEXT) {
      EGL10 egl = (EGL10) EGLContext.getEGL();
      egl.eglMakeCurrent(
          SDLActivity.mEGLDisplay,
          EGL10.EGL_NO_SURFACE,
          EGL10.EGL_NO_SURFACE,
          EGL10.EGL_NO_CONTEXT);
      egl.eglDestroyContext(SDLActivity.mEGLDisplay, SDLActivity.mEGLContext);
      SDLActivity.mEGLContext = EGL10.EGL_NO_CONTEXT;

      if (SDLActivity.mEGLSurface != EGL10.EGL_NO_SURFACE) {
        egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface);
        SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE;
      }
    }
  }
Esempio n. 9
0
  // Called when we lose the surface
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
    Log.v("SDL", "surfaceDestroyed()");
    // Call this *before* setting mIsSurfaceReady to 'false'
    SDLActivity.handlePause();
    SDLActivity.mIsSurfaceReady = false;

    /* We have to clear the current context and destroy the egl surface here
     * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume
     * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d
     */

    EGL10 egl = (EGL10) EGLContext.getEGL();
    egl.eglMakeCurrent(
        SDLActivity.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    egl.eglDestroySurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface);
    SDLActivity.mEGLSurface = EGL10.EGL_NO_SURFACE;
  }
Esempio n. 10
0
  private void endGLES() {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    if (mEglSurface != null) {
      // レンダリングコンテキストとの結びつけは解除
      egl.eglMakeCurrent(
          mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);

      egl.eglDestroySurface(mEglDisplay, mEglSurface);
      mEglSurface = null;
    }

    if (mEglContext != null) {
      egl.eglDestroyContext(mEglDisplay, mEglContext);
      mEglContext = null;
    }

    if (mEglDisplay != null) {
      egl.eglTerminate(mEglDisplay);
      mEglDisplay = null;
    }
  }
Esempio n. 11
0
  synchronized void serverSurfaceDestroyed() {
    ThreadUtils.assertOnUiThread();

    mServerSurfaceValid = false;

    if (mEGLSurfaceForCompositor != null) {
      sEGL.eglDestroySurface(sEGLDisplay, mEGLSurfaceForCompositor);
      mEGLSurfaceForCompositor = null;
    }

    // We need to coordinate with Gecko when pausing composition, to ensure
    // that Gecko never executes a draw event while the compositor is paused.
    // This is sent synchronously to make sure that we don't attempt to use
    // any outstanding Surfaces after we call this (such as from a
    // serverSurfaceDestroyed notification), and to make sure that any in-flight
    // Gecko draw events have been processed.  When this returns, composition is
    // definitely paused -- it'll synchronize with the Gecko event loop, which
    // in turn will synchronize with the compositor thread.
    if (mCompositorCreated) {
      pauseCompositor();
    }
  }
Esempio n. 12
0
    @Override
    void invalidate(Surface surface) {
      // Cancels any existing buffer to ensure we'll get a buffer
      // of the right size before we call eglSwapBuffers
      sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

      if (mEglSurface != null && mEglSurface != EGL_NO_SURFACE) {
        sEgl.eglDestroySurface(sEglDisplay, mEglSurface);
        mEglSurface = null;
        setEnabled(false);
      }

      if (surface.isValid()) {
        if (!createSurface(surface)) {
          return;
        }

        mUpdateDirtyRegions = true;

        if (mCanvas != null) {
          setEnabled(true);
        }
      }
    }
 @Override
 public void destroySurface(final EGL10 egl, final EGLDisplay display, final EGLSurface surface) {
   egl.eglDestroySurface(display, surface);
 }
 public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) {
   egl.eglDestroySurface(display, surface);
 }
Esempio n. 15
0
  public void run() {
    // Much of this code is from GLSurfaceView in the Google API Demos.
    // I encourage those interested to look there for documentation.
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    int[] version = new int[2];
    egl.eglInitialize(dpy, version);

    int[] configSpec = {
      EGL10.EGL_RED_SIZE, 5,
      EGL10.EGL_GREEN_SIZE, 6,
      EGL10.EGL_BLUE_SIZE, 5,
      EGL10.EGL_DEPTH_SIZE, 16,
      EGL10.EGL_NONE
    };

    EGLConfig[] configs = new EGLConfig[1];
    int[] num_config = new int[1];
    egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config);
    EGLConfig config = configs[0];

    EGLContext context = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, null);

    EGLSurface surface = egl.eglCreateWindowSurface(dpy, config, sHolder, null);
    egl.eglMakeCurrent(dpy, surface, surface, context);

    GL10 gl = (GL10) context.getGL();

    init(gl);

    int delta = -1;
    if (fps > 0) {
      delta = 1000 / fps;
    }
    long time = System.currentTimeMillis();

    running = true;
    while (running) {
      int w, h;
      synchronized (this) {
        w = width;
        h = height;
      }
      if (System.currentTimeMillis() - time < delta) {
        try {
          Thread.sleep(System.currentTimeMillis() - time);
        } catch (InterruptedException ex) {
        }
      }
      drawFrame(gl, w, h);
      egl.eglSwapBuffers(dpy, surface);

      if (egl.eglGetError() == EGL11.EGL_CONTEXT_LOST) {
        Context c = getContext();
        if (c instanceof Activity) {
          ((Activity) c).finish();
        }
      }
      time = System.currentTimeMillis();
    }
    egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    egl.eglDestroySurface(dpy, surface);
    egl.eglDestroyContext(dpy, context);
    egl.eglTerminate(dpy);
  }