Commit dcda0e50 by Geoff Lang Committed by Commit Bot

Don't make redundant calls to Display::makeCurrent.

Refactor ValidateMakeCurrent to pass egl object pointers instead of handles. BUG=angleproject:2464 Change-Id: I98859f56d238a38bd6755f00dce7344635690491 Reviewed-on: https://chromium-review.googlesource.com/1053877 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent cff54d6a
......@@ -1270,7 +1270,7 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E
return NoError();
}
Error ValidateMakeCurrent(Display *display, EGLSurface draw, EGLSurface read, gl::Context *context)
Error ValidateMakeCurrent(Display *display, Surface *draw, Surface *read, gl::Context *context)
{
if (context == EGL_NO_CONTEXT && (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE))
{
......@@ -1326,32 +1326,26 @@ Error ValidateMakeCurrent(Display *display, EGLSurface draw, EGLSurface read, gl
return EglContextLost();
}
Surface *drawSurface = static_cast<Surface *>(draw);
if (draw != EGL_NO_SURFACE)
{
ANGLE_TRY(ValidateSurface(display, drawSurface));
ANGLE_TRY(ValidateSurface(display, draw));
}
Surface *readSurface = static_cast<Surface *>(read);
if (read != EGL_NO_SURFACE)
{
ANGLE_TRY(ValidateSurface(display, readSurface));
}
if (readSurface)
{
ANGLE_TRY(ValidateCompatibleConfigs(display, readSurface->getConfig(), readSurface,
context->getConfig(), readSurface->getType()));
ANGLE_TRY(ValidateSurface(display, read));
ANGLE_TRY(ValidateCompatibleConfigs(display, read->getConfig(), read, context->getConfig(),
read->getType()));
}
if (draw != read)
{
UNIMPLEMENTED(); // FIXME
if (drawSurface)
if (draw)
{
ANGLE_TRY(ValidateCompatibleConfigs(display, drawSurface->getConfig(), drawSurface,
context->getConfig(), drawSurface->getType()));
ANGLE_TRY(ValidateCompatibleConfigs(display, draw->getConfig(), draw,
context->getConfig(), draw->getType()));
}
}
return NoError();
......
......@@ -49,7 +49,7 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri
Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, EGLClientBuffer buffer,
Config *config, const AttributeMap& attributes);
Error ValidateMakeCurrent(Display *display, EGLSurface draw, EGLSurface read, gl::Context *context);
Error ValidateMakeCurrent(Display *display, Surface *draw, Surface *read, gl::Context *context);
Error ValidateCreateImageKHR(const Display *display,
gl::Context *context,
......
......@@ -490,36 +490,30 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *drawSurface = static_cast<Surface *>(draw);
Surface *readSurface = static_cast<Surface *>(read);
gl::Context *context = static_cast<gl::Context *>(ctx);
Error error = ValidateMakeCurrent(display, draw, read, context);
if (error.isError())
{
thread->setError(error);
return EGL_FALSE;
}
Surface *readSurface = static_cast<Surface *>(read);
Surface *drawSurface = static_cast<Surface *>(draw);
Error makeCurrentError = display->makeCurrent(drawSurface, readSurface, context);
if (makeCurrentError.isError())
{
thread->setError(makeCurrentError);
return EGL_FALSE;
}
ANGLE_EGL_TRY_RETURN(thread, ValidateMakeCurrent(display, drawSurface, readSurface, context),
EGL_FALSE);
Surface *previousDraw = thread->getCurrentDrawSurface();
Surface *previousRead = thread->getCurrentReadSurface();
gl::Context *previousContext = thread->getContext();
thread->setCurrent(context);
// Release the surface from the previously-current context, to allow
// destroyed surfaces to delete themselves.
if (previousContext != nullptr && context != previousContext)
// Only call makeCurrent if the context or surfaces have changed.
if (previousDraw != drawSurface || previousRead != readSurface || previousContext != context)
{
auto err = previousContext->releaseSurface(display);
if (err.isError())
ANGLE_EGL_TRY_RETURN(thread, display->makeCurrent(drawSurface, readSurface, context),
EGL_FALSE);
thread->setCurrent(context);
// Release the surface from the previously-current context, to allow
// destroyed surfaces to delete themselves.
if (previousContext != nullptr && context != previousContext)
{
thread->setError(err);
return EGL_FALSE;
ANGLE_EGL_TRY_RETURN(thread, previousContext->releaseSurface(display), EGL_FALSE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment