egl: drop unused _EGLDriver from Terminate()
[mesa.git] / src / egl / drivers / haiku / egl_haiku.cpp
index 517c264088a370acf179b09641cb5c46ece7397c..58872433ee6aa05be86cd1fa38912dcbac4ae87f 100644 (file)
@@ -73,10 +73,10 @@ struct haiku_egl_surface
 
 
 /**
- * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
+ * Called via eglCreateWindowSurface(), drv->CreateWindowSurface().
  */
 static _EGLSurface *
-haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
+haiku_create_window_surface(const _EGLDriver *drv, _EGLDisplay *disp,
        _EGLConfig *conf, void *native_window, const EGLint *attrib_list)
 {
        CALLED();
@@ -89,7 +89,7 @@ haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
        }
 
        if (!_eglInitSurface(&surface->surf, disp, EGL_WINDOW_BIT,
-               conf, attrib_list)) {
+               conf, attrib_list, native_window)) {
                free(surface);
                return NULL;
        }
@@ -113,7 +113,7 @@ haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
 
 
 static _EGLSurface *
-haiku_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
+haiku_create_pixmap_surface(const _EGLDriver *drv, _EGLDisplay *disp,
        _EGLConfig *conf, void *native_pixmap, const EGLint *attrib_list)
 {
        return NULL;
@@ -121,7 +121,7 @@ haiku_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
 
 
 static _EGLSurface *
-haiku_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
+haiku_create_pbuffer_surface(const _EGLDriver *drv, _EGLDisplay *disp,
        _EGLConfig *conf, const EGLint *attrib_list)
 {
        return NULL;
@@ -129,7 +129,7 @@ haiku_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
 
 
 static EGLBoolean
-haiku_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+haiku_destroy_surface(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 {
        if (_eglPutSurface(surf)) {
                // XXX: detach haiku_egl_surface::gl from the native window and destroy it
@@ -152,35 +152,34 @@ haiku_add_configs_for_visuals(_EGLDisplay *disp)
        _eglInitConfig(&conf->base, disp, 1);
        TRACE("Config inited\n");
 
-       _eglSetConfigKey(&conf->base, EGL_RED_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_BLUE_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_GREEN_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_LUMINANCE_SIZE, 0);
-       _eglSetConfigKey(&conf->base, EGL_ALPHA_SIZE, 8);
-       _eglSetConfigKey(&conf->base, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
-       EGLint r = (_eglGetConfigKey(&conf->base, EGL_RED_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_GREEN_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_BLUE_SIZE)
-               + _eglGetConfigKey(&conf->base, EGL_ALPHA_SIZE));
-       _eglSetConfigKey(&conf->base, EGL_BUFFER_SIZE, r);
-       _eglSetConfigKey(&conf->base, EGL_CONFIG_CAVEAT, EGL_NONE);
-       _eglSetConfigKey(&conf->base, EGL_CONFIG_ID, 1);
-       _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGB, EGL_FALSE);
-       _eglSetConfigKey(&conf->base, EGL_BIND_TO_TEXTURE_RGBA, EGL_FALSE);
-       _eglSetConfigKey(&conf->base, EGL_STENCIL_SIZE, 0);
-       _eglSetConfigKey(&conf->base, EGL_TRANSPARENT_TYPE, EGL_NONE);
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_RENDERABLE, EGL_TRUE); // Let's say yes
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_ID, 0); // No visual
-       _eglSetConfigKey(&conf->base, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); // No visual
-       _eglSetConfigKey(&conf->base, EGL_RENDERABLE_TYPE, 0x8);
-       _eglSetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_SAMPLES, _eglGetConfigKey(&conf->base, EGL_SAMPLE_BUFFERS) == 0 ? 0 : 0);
-       _eglSetConfigKey(&conf->base, EGL_DEPTH_SIZE, 24); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_LEVEL, 0);
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_WIDTH, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_HEIGHT, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_MAX_PBUFFER_PIXELS, 0); // TODO: How to get the right value ?
-       _eglSetConfigKey(&conf->base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/);
+       conf->base.RedSize = 8;
+       conf->base.BlueSize = 8;
+       conf->base.GreenSize = 8;
+       conf->base.LuminanceSize = 0;
+       conf->base.AlphaSize = 8;
+       conf->base.ColorBufferType = EGL_RGB_BUFFER;
+       conf->base.BufferSize = conf->base.RedSize
+                             + conf->base.GreenSize
+                             + conf->base.BlueSize
+                             + conf->base.AlphaSize;
+       conf->base.ConfigCaveat = EGL_NONE;
+       conf->base.ConfigId = 1;
+       conf->base.BindToTextureRGB = EGL_FALSE;
+       conf->base.BindToTextureRGBA = EGL_FALSE;
+       conf->base.StencilSize = 0;
+       conf->base.TransparentType = EGL_NONE;
+       conf->base.NativeRenderable = EGL_TRUE; // Let's say yes
+       conf->base.NativeVisualID = 0; // No visual
+       conf->base.NativeVisualType = EGL_NONE; // No visual
+       conf->base.RenderableType = 0x8;
+       conf->base.SampleBuffers = 0; // TODO: How to get the right value ?
+       conf->base.Samples = conf->base.SampleBuffers == 0 ? 0 : 0;
+       conf->base.DepthSize = 24; // TODO: How to get the right value ?
+       conf->base.Level = 0;
+       conf->base.MaxPbufferWidth = 0; // TODO: How to get the right value ?
+       conf->base.MaxPbufferHeight = 0; // TODO: How to get the right value ?
+       conf->base.MaxPbufferPixels = 0; // TODO: How to get the right value ?
+       conf->base.SurfaceType = EGL_WINDOW_BIT /*| EGL_PIXMAP_BIT | EGL_PBUFFER_BIT*/;
 
        TRACE("Config configuated\n");
        if (!_eglValidateConfig(&conf->base, EGL_FALSE)) {
@@ -206,7 +205,7 @@ cleanup:
 
 extern "C"
 EGLBoolean
-init_haiku(_EGLDriver *drv, _EGLDisplay *disp)
+init_haiku(_EGLDisplay *disp)
 {
        _EGLDevice *dev;
        CALLED();
@@ -222,8 +221,6 @@ init_haiku(_EGLDriver *drv, _EGLDisplay *disp)
        if (!haiku_add_configs_for_visuals(disp))
                return EGL_FALSE;
 
-       disp->Version = 14;
-
        TRACE("Initialization finished\n");
 
        return EGL_TRUE;
@@ -232,7 +229,7 @@ init_haiku(_EGLDriver *drv, _EGLDisplay *disp)
 
 extern "C"
 EGLBoolean
-haiku_terminate(_EGLDriver* drv,_EGLDisplay *disp)
+haiku_terminate(_EGLDisplay *disp)
 {
        return EGL_TRUE;
 }
@@ -240,7 +237,7 @@ haiku_terminate(_EGLDriver* drv,_EGLDisplay *disp)
 
 extern "C"
 _EGLContext*
-haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
+haiku_create_context(const _EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
        _EGLContext *share_list, const EGLint *attrib_list)
 {
        CALLED();
@@ -266,7 +263,7 @@ cleanup:
 
 extern "C"
 EGLBoolean
-haiku_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx)
+haiku_destroy_context(const _EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx)
 {
        struct haiku_egl_context* context = haiku_egl_context(ctx);
 
@@ -281,7 +278,7 @@ haiku_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx)
 
 extern "C"
 EGLBoolean
-haiku_make_current(_EGLDriver* drv, _EGLDisplay *disp, _EGLSurface *dsurf,
+haiku_make_current(const _EGLDriver* drv, _EGLDisplay *disp, _EGLSurface *dsurf,
        _EGLSurface *rsurf, _EGLContext *ctx)
 {
        CALLED();
@@ -302,7 +299,7 @@ haiku_make_current(_EGLDriver* drv, _EGLDisplay *disp, _EGLSurface *dsurf,
 
 extern "C"
 EGLBoolean
-haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+haiku_swap_buffers(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 {
        struct haiku_egl_surface* surface = haiku_egl_surface(surf);
 
@@ -312,27 +309,16 @@ haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
 }
 
 
-/**
- * This is the main entrypoint into the driver, called by libEGL.
- * Gets an _EGLDriver object and init its dispatch table.
- */
 extern "C"
-void
-_eglInitDriver(_EGLDriver *driver)
-{
-       CALLED();
-
-       driver->API.Initialize = init_haiku;
-       driver->API.Terminate = haiku_terminate;
-       driver->API.CreateContext = haiku_create_context;
-       driver->API.DestroyContext = haiku_destroy_context;
-       driver->API.MakeCurrent = haiku_make_current;
-       driver->API.CreateWindowSurface = haiku_create_window_surface;
-       driver->API.CreatePixmapSurface = haiku_create_pixmap_surface;
-       driver->API.CreatePbufferSurface = haiku_create_pbuffer_surface;
-       driver->API.DestroySurface = haiku_destroy_surface;
-
-       driver->API.SwapBuffers = haiku_swap_buffers;
-
-       TRACE("API Calls defined\n");
-}
+const _EGLDriver _eglDriver = {
+       .Initialize = init_haiku,
+       .Terminate = haiku_terminate,
+       .CreateContext = haiku_create_context,
+       .DestroyContext = haiku_destroy_context,
+       .MakeCurrent = haiku_make_current,
+       .CreateWindowSurface = haiku_create_window_surface,
+       .CreatePixmapSurface = haiku_create_pixmap_surface,
+       .CreatePbufferSurface = haiku_create_pbuffer_surface,
+       .DestroySurface = haiku_destroy_surface,
+       .SwapBuffers = haiku_swap_buffers,
+};