Commit 26d84357 by Austin Kinross Committed by Jamie Madill

Fix some EGL validation issues

BUG=angleproject:1207 Change-Id: I425397ca81dfd8be98ffdc5b874d978e7cf7758d Reviewed-on: https://chromium-review.googlesource.com/310194Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 84f505db
...@@ -49,14 +49,13 @@ EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor) ...@@ -49,14 +49,13 @@ EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)", EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)",
dpy, major, minor); dpy, major, minor);
if (dpy == EGL_NO_DISPLAY) Display *display = static_cast<Display *>(dpy);
if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display))
{ {
SetGlobalError(Error(EGL_BAD_DISPLAY)); SetGlobalError(Error(EGL_BAD_DISPLAY));
return EGL_FALSE; return EGL_FALSE;
} }
Display *display = static_cast<Display*>(dpy);
Error error = display->initialize(); Error error = display->initialize();
if (error.isError()) if (error.isError())
{ {
...@@ -75,13 +74,13 @@ EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy) ...@@ -75,13 +74,13 @@ EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy)
{ {
EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy); EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy);
if (dpy == EGL_NO_DISPLAY) Display *display = static_cast<Display *>(dpy);
if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display))
{ {
SetGlobalError(Error(EGL_BAD_DISPLAY)); SetGlobalError(Error(EGL_BAD_DISPLAY));
return EGL_FALSE; return EGL_FALSE;
} }
Display *display = static_cast<Display*>(dpy);
gl::Context *context = GetGlobalContext(); gl::Context *context = GetGlobalContext();
if (display->isValidContext(context)) if (display->isValidContext(context))
...@@ -505,15 +504,30 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r ...@@ -505,15 +504,30 @@ EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface r
Display *display = static_cast<Display*>(dpy); Display *display = static_cast<Display*>(dpy);
gl::Context *context = static_cast<gl::Context*>(ctx); gl::Context *context = static_cast<gl::Context*>(ctx);
bool noContext = (ctx == EGL_NO_CONTEXT); // If ctx is EGL_NO_CONTEXT and either draw or read are not EGL_NO_SURFACE, an EGL_BAD_MATCH
bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE); // error is generated.
if (noContext != noSurface) if (ctx == EGL_NO_CONTEXT && (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE))
{
SetGlobalError(Error(EGL_BAD_MATCH));
return EGL_FALSE;
}
if (ctx != EGL_NO_CONTEXT && draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE)
{ {
SetGlobalError(Error(EGL_BAD_MATCH)); SetGlobalError(Error(EGL_BAD_MATCH));
return EGL_FALSE; return EGL_FALSE;
} }
if (dpy == EGL_NO_DISPLAY) // If either of draw or read is a valid surface and the other is EGL_NO_SURFACE, an
// EGL_BAD_MATCH error is generated.
if ((read == EGL_NO_SURFACE) != (draw == EGL_NO_SURFACE))
{
SetGlobalError(Error(
EGL_BAD_MATCH, "read and draw must both be valid surfaces, or both be EGL_NO_SURFACE"));
return EGL_FALSE;
}
if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display))
{ {
SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle")); SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle"));
return 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