Set swap interval explicitly.

The swap interval can be changed independent of the Surface config.
Thus it makes more sense to set it explicitly in test setup. This
simplifies the test config.

Also updates some of the API for GLWindowBase. Return an explicit
error from makeCurrent.

Bug: angleproject:3393
Change-Id: Ic62b33018e872bc0e38f2848e2427ed898b60749
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1574672
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill
2019-04-30 16:14:43 -04:00
committed by Commit Bot
parent 8f39cd8378
commit 0659c99131
6 changed files with 71 additions and 53 deletions

View File

@@ -116,7 +116,10 @@ bool WGLWindow::initializeGL(OSWindow *osWindow,
return false;
}
makeCurrent();
if (!makeCurrent())
{
return false;
}
// Reload entry points to capture extensions.
angle::LoadWGL(GetProcAddressWithFallback);
@@ -164,21 +167,9 @@ bool WGLWindow::initializeGL(OSWindow *osWindow,
return false;
}
makeCurrent();
if (mConfigParams.swapInterval != -1)
if (!makeCurrent())
{
if (_wglSwapIntervalEXT)
{
if (_wglSwapIntervalEXT(mConfigParams.swapInterval) == FALSE)
{
std::cerr << "Error setting swap interval." << std::endl;
}
}
else
{
std::cerr << "Error setting swap interval." << std::endl;
}
return false;
}
angle::LoadGLES(GetProcAddressWithFallback);
@@ -205,19 +196,32 @@ bool WGLWindow::isGLInitialized() const
return mWGLContext != nullptr;
}
void WGLWindow::makeCurrent()
bool WGLWindow::makeCurrent()
{
if (_wglMakeCurrent(mDeviceContext, mWGLContext) == FALSE)
{
std::cerr << "Error during wglMakeCurrent." << std::endl;
std::cerr << "Error during wglMakeCurrent.\n";
return false;
}
return true;
}
bool WGLWindow::setSwapInterval(EGLint swapInterval)
{
if (!_wglSwapIntervalEXT || _wglSwapIntervalEXT(swapInterval) == FALSE)
{
std::cerr << "Error during wglSwapIntervalEXT.\n";
return false;
}
return true;
}
void WGLWindow::swap()
{
if (SwapBuffers(mDeviceContext) == FALSE)
{
std::cerr << "Error during SwapBuffers." << std::endl;
std::cerr << "Error during SwapBuffers.\n";
}
}