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 ...@@ -1270,7 +1270,7 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E
return NoError(); 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)) 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 ...@@ -1326,32 +1326,26 @@ Error ValidateMakeCurrent(Display *display, EGLSurface draw, EGLSurface read, gl
return EglContextLost(); return EglContextLost();
} }
Surface *drawSurface = static_cast<Surface *>(draw);
if (draw != EGL_NO_SURFACE) 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) if (read != EGL_NO_SURFACE)
{ {
ANGLE_TRY(ValidateSurface(display, readSurface)); ANGLE_TRY(ValidateSurface(display, read));
} ANGLE_TRY(ValidateCompatibleConfigs(display, read->getConfig(), read, context->getConfig(),
read->getType()));
if (readSurface)
{
ANGLE_TRY(ValidateCompatibleConfigs(display, readSurface->getConfig(), readSurface,
context->getConfig(), readSurface->getType()));
} }
if (draw != read) if (draw != read)
{ {
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
if (drawSurface) if (draw)
{ {
ANGLE_TRY(ValidateCompatibleConfigs(display, drawSurface->getConfig(), drawSurface, ANGLE_TRY(ValidateCompatibleConfigs(display, draw->getConfig(), draw,
context->getConfig(), drawSurface->getType())); context->getConfig(), draw->getType()));
} }
} }
return NoError(); return NoError();
......
...@@ -49,7 +49,7 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri ...@@ -49,7 +49,7 @@ Error ValidateCreatePbufferSurface(Display *display, Config *config, const Attri
Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, EGLClientBuffer buffer, Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, EGLClientBuffer buffer,
Config *config, const AttributeMap& attributes); 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, Error ValidateCreateImageKHR(const Display *display,
gl::Context *context, gl::Context *context,
......
...@@ -490,36 +490,30 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r ...@@ -490,36 +490,30 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r
Thread *thread = GetCurrentThread(); Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy); 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); gl::Context *context = static_cast<gl::Context *>(ctx);
Error error = ValidateMakeCurrent(display, draw, read, context); ANGLE_EGL_TRY_RETURN(thread, ValidateMakeCurrent(display, drawSurface, readSurface, context),
if (error.isError()) EGL_FALSE);
{
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;
}
Surface *previousDraw = thread->getCurrentDrawSurface();
Surface *previousRead = thread->getCurrentReadSurface();
gl::Context *previousContext = thread->getContext(); gl::Context *previousContext = thread->getContext();
thread->setCurrent(context);
// Release the surface from the previously-current context, to allow // Only call makeCurrent if the context or surfaces have changed.
// destroyed surfaces to delete themselves. if (previousDraw != drawSurface || previousRead != readSurface || previousContext != context)
if (previousContext != nullptr && context != previousContext)
{ {
auto err = previousContext->releaseSurface(display); ANGLE_EGL_TRY_RETURN(thread, display->makeCurrent(drawSurface, readSurface, context),
if (err.isError()) 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); ANGLE_EGL_TRY_RETURN(thread, previousContext->releaseSurface(display), EGL_FALSE);
return 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