Commit 3394a73d by Tobin Ehlis Committed by Commit Bot

Refactor of EGL SwapBuffers validation

Move the Validation checks for SwapBuffers into new ValidateSwapBuffers function instead of in-line. This is a first commit for refactor of EGL validation. I'll continue the refactor in a similar fashion to this. Bug: angleproject:798 Change-Id: Icb308d66c93528c9e440ae68abe85e44f98ede82 Reviewed-on: https://chromium-review.googlesource.com/1151538 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6e5bf36f
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// validationEGL.cpp: Validation functions for generic EGL entry point parameters // validationEGL.cpp: Validation functions for generic EGL entry point parameters
#include "libANGLE/validationEGL.h" #include "libANGLE/validationEGL.h"
#include "libGLESv2/global_state.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
...@@ -2471,6 +2472,24 @@ Error ValidateGetSyncValuesCHROMIUM(const Display *display, ...@@ -2471,6 +2472,24 @@ Error ValidateGetSyncValuesCHROMIUM(const Display *display,
return NoError(); return NoError();
} }
Error ValidateSwapBuffers(Thread *thread, const Display *display, const Surface *eglSurface)
{
ANGLE_TRY(ValidateSurface(display, eglSurface));
if (display->isDeviceLost())
{
return EglContextLost();
}
if (eglSurface == EGL_NO_SURFACE || !thread->getContext() ||
thread->getCurrentDrawSurface() != eglSurface)
{
return EglBadSurface();
}
return NoError();
}
Error ValidateSwapBuffersWithDamageKHR(const Display *display, Error ValidateSwapBuffersWithDamageKHR(const Display *display,
const Surface *surface, const Surface *surface,
EGLint *rects, EGLint *rects,
......
...@@ -130,6 +130,8 @@ Error ValidateGetSyncValuesCHROMIUM(const Display *display, ...@@ -130,6 +130,8 @@ Error ValidateGetSyncValuesCHROMIUM(const Display *display,
const EGLuint64KHR *msc, const EGLuint64KHR *msc,
const EGLuint64KHR *sbc); const EGLuint64KHR *sbc);
Error ValidateSwapBuffers(Thread *thread, const Display *display, const Surface *surface);
Error ValidateSwapBuffersWithDamageKHR(const Display *display, Error ValidateSwapBuffersWithDamageKHR(const Display *display,
const Surface *surface, const Surface *surface,
EGLint *rects, EGLint *rects,
......
...@@ -657,42 +657,11 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) ...@@ -657,42 +657,11 @@ EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface)
Display *display = static_cast<Display *>(dpy); Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = (Surface *)surface; Surface *eglSurface = (Surface *)surface;
Error error = ValidateSurface(display, eglSurface); ANGLE_EGL_TRY_RETURN(thread, ValidateSwapBuffers(thread, display, eglSurface), "eglSwapBuffers",
if (error.isError()) GetSurfaceIfValid(display, eglSurface), EGL_FALSE);
{
thread->setError(error, GetDebug(), "eglSwapBuffers",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (display->isDeviceLost())
{
thread->setError(EglContextLost(), GetDebug(), "eglSwapBuffers",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE) ANGLE_EGL_TRY_RETURN(thread, eglSurface->swap(thread->getContext()), "eglSwapBuffers",
{ GetSurfaceIfValid(display, eglSurface), EGL_FALSE);
thread->setError(EglBadSurface(), GetDebug(), "eglSwapBuffers",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (!thread->getContext() || thread->getCurrentDrawSurface() != eglSurface)
{
thread->setError(EglBadSurface(), GetDebug(), "eglSwapBuffers",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
error = eglSurface->swap(thread->getContext());
if (error.isError())
{
thread->setError(error, GetDebug(), "eglSwapBuffers",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
thread->setSuccess(); thread->setSuccess();
return EGL_TRUE; return EGL_TRUE;
......
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