Commit 9cc8c967 by Nicolas Capens

Refactor using concrete EGL object pointers.

Bug 20045861 Change-Id: I3dc737b5cc5759e487245030bfd8d871eacd8124 Reviewed-on: https://swiftshader-review.googlesource.com/2793Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 6ed0304a
......@@ -192,7 +192,7 @@ void Display::terminate()
if(this == getCurrentDisplay())
{
setCurrentDisplay(EGL_NO_DISPLAY);
setCurrentDisplay(nullptr);
}
}
......@@ -442,12 +442,12 @@ void Display::destroySurface(egl::Surface *surface)
if(surface == getCurrentDrawSurface())
{
setCurrentDrawSurface(EGL_NO_SURFACE);
setCurrentDrawSurface(nullptr);
}
if(surface == getCurrentReadSurface())
{
setCurrentReadSurface(EGL_NO_SURFACE);
setCurrentReadSurface(nullptr);
}
}
......@@ -458,9 +458,9 @@ void Display::destroyContext(egl::Context *context)
if(context == getCurrentContext())
{
setCurrentContext(EGL_NO_CONTEXT);
setCurrentDrawSurface(EGL_NO_SURFACE);
setCurrentReadSurface(EGL_NO_SURFACE);
setCurrentContext(nullptr);
setCurrentDrawSurface(nullptr);
setCurrentReadSurface(nullptr);
}
}
......
......@@ -668,6 +668,8 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
egl::Display *display = static_cast<egl::Display*>(dpy);
egl::Context *context = static_cast<egl::Context*>(ctx);
egl::Surface *drawSurface = static_cast<egl::Surface*>(draw);
egl::Surface *readSurface = static_cast<egl::Surface*>(read);
if(ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)
{
......@@ -687,8 +689,8 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
return EGL_FALSE;
}
if((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||
(read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read))))
if((draw != EGL_NO_SURFACE && !validateSurface(display, drawSurface)) ||
(read != EGL_NO_SURFACE && !validateSurface(display, readSurface)))
{
return EGL_FALSE;
}
......@@ -703,14 +705,14 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
UNIMPLEMENTED(); // FIXME
}
egl::setCurrentDisplay(dpy);
egl::setCurrentDrawSurface(draw);
egl::setCurrentReadSurface(read);
egl::setCurrentContext(ctx);
egl::setCurrentDisplay(display);
egl::setCurrentDrawSurface(drawSurface);
egl::setCurrentReadSurface(readSurface);
egl::setCurrentContext(context);
if(context)
{
context->makeCurrent(static_cast<egl::Surface*>(draw));
context->makeCurrent(drawSurface);
}
return success(EGL_TRUE);
......
......@@ -40,10 +40,10 @@ static void eglAttachThread()
current->error = EGL_SUCCESS;
current->API = EGL_OPENGL_ES_API;
current->display = EGL_NO_DISPLAY;
current->drawSurface = EGL_NO_SURFACE;
current->readSurface = EGL_NO_SURFACE;
current->context = EGL_NO_CONTEXT;
current->display = nullptr;
current->context = nullptr;
current->drawSurface = nullptr;
current->readSurface = nullptr;
}
}
......@@ -241,56 +241,56 @@ EGLenum getCurrentAPI()
return current->API;
}
void setCurrentDisplay(EGLDisplay dpy)
void setCurrentDisplay(egl::Display *dpy)
{
Current *current = eglGetCurrent();
current->display = dpy;
}
EGLDisplay getCurrentDisplay()
egl::Display *getCurrentDisplay()
{
Current *current = eglGetCurrent();
return current->display;
}
void setCurrentContext(EGLContext ctx)
void setCurrentContext(egl::Context *ctx)
{
Current *current = eglGetCurrent();
current->context = ctx;
}
EGLContext getCurrentContext()
egl::Context *getCurrentContext()
{
Current *current = eglGetCurrent();
return current->context;
}
void setCurrentDrawSurface(EGLSurface surface)
void setCurrentDrawSurface(egl::Surface *surface)
{
Current *current = eglGetCurrent();
current->drawSurface = surface;
}
EGLSurface getCurrentDrawSurface()
egl::Surface *getCurrentDrawSurface()
{
Current *current = eglGetCurrent();
return current->drawSurface;
}
void setCurrentReadSurface(EGLSurface surface)
void setCurrentReadSurface(egl::Surface *surface)
{
Current *current = eglGetCurrent();
current->readSurface = surface;
}
EGLSurface getCurrentReadSurface()
egl::Surface *getCurrentReadSurface()
{
Current *current = eglGetCurrent();
......
......@@ -20,14 +20,18 @@
namespace egl
{
class Display;
class Context;
class Surface;
struct Current
{
EGLint error;
EGLenum API;
EGLDisplay display;
EGLContext context;
EGLSurface drawSurface;
EGLSurface readSurface;
Display *display;
Context *context;
Surface *drawSurface;
Surface *readSurface;
};
void setCurrentError(EGLint error);
......@@ -36,17 +40,17 @@ namespace egl
void setCurrentAPI(EGLenum API);
EGLenum getCurrentAPI();
void setCurrentDisplay(EGLDisplay dpy);
EGLDisplay getCurrentDisplay();
void setCurrentDisplay(Display *dpy);
Display *getCurrentDisplay();
void setCurrentContext(EGLContext ctx);
EGLContext getCurrentContext();
void setCurrentContext(Context *ctx);
Context *getCurrentContext();
void setCurrentDrawSurface(EGLSurface surface);
EGLSurface getCurrentDrawSurface();
void setCurrentDrawSurface(Surface *surface);
Surface *getCurrentDrawSurface();
void setCurrentReadSurface(EGLSurface surface);
EGLSurface getCurrentReadSurface();
void setCurrentReadSurface(Surface *surface);
Surface *getCurrentReadSurface();
}
void error(EGLint errorCode);
......
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