void ANGLETest::TearDown() { checkD3D11SDKLayersMessages(); const auto &info = testing::UnitTest::GetInstance()->current_test_info(); angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name()); swapBuffers(); mOSWindow->messageLoop(); if (!destroyEGLContext()) { FAIL() << "egl context destruction failed."; } // Check for quit message Event myEvent; while (mOSWindow->popEvent(&myEvent)) { if (myEvent.Type == Event::EVENT_CLOSED) { exit(0); } } }
void ANGLETest::TearDown() { swapBuffers(); if (!destroyEGLContext()) { FAIL() << "egl context destruction failed."; } }
bool ANGLETest::createEGLContext() { PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")); if (!eglGetPlatformDisplayEXT) { return false; } const EGLint displayAttributes[] = { EGL_PLATFORM_ANGLE_TYPE_ANGLE, mTestPlatform, EGL_NONE, }; mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, mNativeDisplay, displayAttributes); if (mDisplay == EGL_NO_DISPLAY) { destroyEGLContext(); return false; } EGLint majorVersion, minorVersion; if (!eglInitialize(mDisplay, &majorVersion, &minorVersion)) { destroyEGLContext(); return false; } eglBindAPI(EGL_OPENGL_ES_API); if (eglGetError() != EGL_SUCCESS) { destroyEGLContext(); return false; } const EGLint configAttributes[] = { EGL_RED_SIZE, (mRedBits >= 0) ? mRedBits : EGL_DONT_CARE, EGL_GREEN_SIZE, (mGreenBits >= 0) ? mGreenBits : EGL_DONT_CARE, EGL_BLUE_SIZE, (mBlueBits >= 0) ? mBlueBits : EGL_DONT_CARE, EGL_ALPHA_SIZE, (mAlphaBits >= 0) ? mAlphaBits : EGL_DONT_CARE, EGL_DEPTH_SIZE, (mDepthBits >= 0) ? mDepthBits : EGL_DONT_CARE, EGL_STENCIL_SIZE, (mStencilBits >= 0) ? mStencilBits : EGL_DONT_CARE, EGL_SAMPLE_BUFFERS, mMultisample ? 1 : 0, EGL_NONE }; EGLint configCount; if (!eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount) || (configCount != 1)) { destroyEGLContext(); return false; } eglGetConfigAttrib(mDisplay, mConfig, EGL_RED_SIZE, &mRedBits); eglGetConfigAttrib(mDisplay, mConfig, EGL_GREEN_SIZE, &mGreenBits); eglGetConfigAttrib(mDisplay, mConfig, EGL_BLUE_SIZE, &mBlueBits); eglGetConfigAttrib(mDisplay, mConfig, EGL_ALPHA_SIZE, &mBlueBits); eglGetConfigAttrib(mDisplay, mConfig, EGL_DEPTH_SIZE, &mDepthBits); eglGetConfigAttrib(mDisplay, mConfig, EGL_STENCIL_SIZE, &mStencilBits); EGLint samples; eglGetConfigAttrib(mDisplay, mConfig, EGL_SAMPLE_BUFFERS, &samples); mMultisample = (samples != 0); mSurface = eglCreateWindowSurface(mDisplay, mConfig, mNativeWindow, NULL); if(mSurface == EGL_NO_SURFACE) { eglGetError(); // Clear error mSurface = eglCreateWindowSurface(mDisplay, mConfig, NULL, NULL); } if (eglGetError() != EGL_SUCCESS) { destroyEGLContext(); return false; } EGLint contextAttibutes[] = { EGL_CONTEXT_CLIENT_VERSION, mClientVersion, EGL_NONE }; mContext = eglCreateContext(mDisplay, mConfig, NULL, contextAttibutes); if (eglGetError() != EGL_SUCCESS) { destroyEGLContext(); return false; } eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); if (eglGetError() != EGL_SUCCESS) { destroyEGLContext(); return false; } return true; }