bool NativeEngine::HandleEglError(EGLint error) { switch (error) { case EGL_SUCCESS: // nothing to do return true; case EGL_CONTEXT_LOST: LOGW("NativeEngine: egl error: EGL_CONTEXT_LOST. Recreating context."); KillContext(); return true; case EGL_BAD_CONTEXT: LOGW("NativeEngine: egl error: EGL_BAD_CONTEXT. Recreating context."); KillContext(); return true; case EGL_BAD_DISPLAY: LOGW("NativeEngine: egl error: EGL_BAD_DISPLAY. Recreating display."); KillDisplay(); return true; case EGL_BAD_SURFACE: LOGW("NativeEngine: egl error: EGL_BAD_SURFACE. Recreating display."); KillSurface(); return true; default: LOGW("NativeEngine: unknown egl error: %d", error); return false; } }
NativeEngine::~NativeEngine() { VLOGD("NativeEngine: destructor running"); KillContext(); if (mJniEnv) { LOGD("Detaching current thread from JNI."); mApp->activity->vm->DetachCurrentThread(); LOGD("Current thread detached from JNI."); mJniEnv = NULL; } _singleton = NULL; }
void NativeEngine::KillDisplay() { // causes context and surface to go away too, if they are there LOGD("NativeEngine: killing display."); KillContext(); KillSurface(); if (mEglDisplay != EGL_NO_DISPLAY) { LOGD("NativeEngine: terminating display now."); eglTerminate(mEglDisplay); mEglDisplay = EGL_NO_DISPLAY; } LOGD("NativeEngine: display killed successfully."); }
NativeEngine::~NativeEngine() { OLog("NativeEngine: destructor running"); KillContext(); _singleton = NULL; }