OSDN Git Service

Refactor using concrete EGL object pointers.
authorNicolas Capens <capn@google.com>
Thu, 2 Apr 2015 17:18:21 +0000 (13:18 -0400)
committerNicolas Capens <capn@google.com>
Fri, 10 Apr 2015 16:05:37 +0000 (16:05 +0000)
Bug 20045861

Change-Id: I3dc737b5cc5759e487245030bfd8d871eacd8124
Reviewed-on: https://swiftshader-review.googlesource.com/2793
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/libEGL/Display.cpp
src/OpenGL/libEGL/libEGL.cpp
src/OpenGL/libEGL/main.cpp
src/OpenGL/libEGL/main.h

index c3b1824..097d913 100644 (file)
@@ -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);
        }
 }
 
index b053c94..1e2a70c 100644 (file)
@@ -668,6 +668,8 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
 \r
        egl::Display *display = static_cast<egl::Display*>(dpy);\r
        egl::Context *context = static_cast<egl::Context*>(ctx);\r
+       egl::Surface *drawSurface = static_cast<egl::Surface*>(draw);\r
+       egl::Surface *readSurface = static_cast<egl::Surface*>(read);\r
 \r
        if(ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)\r
        {\r
@@ -687,8 +689,8 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
                return EGL_FALSE;\r
        }\r
 \r
-       if((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||\r
-               (read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read))))\r
+       if((draw != EGL_NO_SURFACE && !validateSurface(display, drawSurface)) ||\r
+          (read != EGL_NO_SURFACE && !validateSurface(display, readSurface)))\r
        {\r
                return EGL_FALSE;\r
        }\r
@@ -703,14 +705,14 @@ EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurfac
                UNIMPLEMENTED();   // FIXME\r
        }\r
 \r
-       egl::setCurrentDisplay(dpy);\r
-       egl::setCurrentDrawSurface(draw);\r
-       egl::setCurrentReadSurface(read);\r
-       egl::setCurrentContext(ctx);\r
+       egl::setCurrentDisplay(display);\r
+       egl::setCurrentDrawSurface(drawSurface);\r
+       egl::setCurrentReadSurface(readSurface);\r
+       egl::setCurrentContext(context);\r
 \r
        if(context)\r
        {\r
-               context->makeCurrent(static_cast<egl::Surface*>(draw));\r
+               context->makeCurrent(drawSurface);\r
        }\r
 \r
        return success(EGL_TRUE);\r
index 111d417..33facde 100644 (file)
@@ -40,10 +40,10 @@ static void eglAttachThread()
 \r
         current->error = EGL_SUCCESS;\r
         current->API = EGL_OPENGL_ES_API;\r
-        current->display = EGL_NO_DISPLAY;\r
-        current->drawSurface = EGL_NO_SURFACE;\r
-        current->readSurface = EGL_NO_SURFACE;\r
-               current->context = EGL_NO_CONTEXT;\r
+               current->display = nullptr;\r
+               current->context = nullptr;\r
+               current->drawSurface = nullptr;\r
+        current->readSurface = nullptr;\r
        }\r
 }\r
 \r
@@ -241,56 +241,56 @@ EGLenum getCurrentAPI()
     return current->API;\r
 }\r
 \r
-void setCurrentDisplay(EGLDisplay dpy)\r
+void setCurrentDisplay(egl::Display *dpy)\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     current->display = dpy;\r
 }\r
 \r
-EGLDisplay getCurrentDisplay()\r
+egl::Display *getCurrentDisplay()\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     return current->display;\r
 }\r
 \r
-void setCurrentContext(EGLContext ctx)\r
+void setCurrentContext(egl::Context *ctx)\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     current->context = ctx;\r
 }\r
 \r
-EGLContext getCurrentContext()\r
+egl::Context *getCurrentContext()\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     return current->context;\r
 }\r
 \r
-void setCurrentDrawSurface(EGLSurface surface)\r
+void setCurrentDrawSurface(egl::Surface *surface)\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     current->drawSurface = surface;\r
 }\r
 \r
-EGLSurface getCurrentDrawSurface()\r
+egl::Surface *getCurrentDrawSurface()\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     return current->drawSurface;\r
 }\r
 \r
-void setCurrentReadSurface(EGLSurface surface)\r
+void setCurrentReadSurface(egl::Surface *surface)\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
     current->readSurface = surface;\r
 }\r
 \r
-EGLSurface getCurrentReadSurface()\r
+egl::Surface *getCurrentReadSurface()\r
 {\r
     Current *current = eglGetCurrent();\r
 \r
index f6d74d5..9758237 100644 (file)
 
 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);