diff options
author | Chia-I Wu <[email protected]> | 2009-08-11 17:09:39 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-18 08:44:34 -0600 |
commit | 2f2cf461c57974abd89e4917945cc8ae6a67a72e (patch) | |
tree | 0548e5d4fc90f8603bfe019783cd041f5f8adb94 /src/gallium/state_trackers/egl | |
parent | 521dea21d46b4012653a4998d92ac0f6c0d1a8d4 (diff) |
egl: Overhaul driver API.
The motivation is so that drivers do not need to look up and check for
bad display, context, and etc. It also becomes unnecessary for drivers
to call the link functions.
This commit makes eglapi.[ch] do the lookup and check. As a result, the
driver API is overhauled, and almost all sources and drivers need
update. The updates are mainly find and replace with human brains.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/egl')
-rw-r--r-- | src/gallium/state_trackers/egl/egl_context.c | 24 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_surface.c | 49 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_tracker.c | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_tracker.h | 33 |
4 files changed, 43 insertions, 70 deletions
diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index 2c8f51cf388..52b6453d291 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -83,23 +83,16 @@ const struct dri_extension card_extensions[] = { {NULL, NULL} }; -EGLContext -drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) +_EGLContext * +drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) { struct drm_device *dev = (struct drm_device *)drv; struct drm_context *ctx; struct drm_context *share = NULL; struct st_context *st_share = NULL; - _EGLConfig *conf; int i; __GLcontextModes *visual; - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { /* no attribs defined for now */ @@ -129,25 +122,20 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext if (!ctx->st) goto err_gl; - /* link to display */ - _eglLinkContext(&ctx->base, _eglLookupDisplay(dpy)); - assert(_eglGetContextHandle(&ctx->base)); - - return _eglGetContextHandle(&ctx->base); + return &ctx->base; err_gl: ctx->pipe->destroy(ctx->pipe); err_pipe: free(ctx); err_c: - return EGL_NO_CONTEXT; + return NULL; } EGLBoolean -drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) +drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context) { struct drm_context *c = lookup_drm_context(context); - _eglUnlinkContext(&c->base); if (!_eglIsContextBound(&c->base)) { st_destroy_context(c->st); c->pipe->destroy(c->pipe); @@ -157,7 +145,7 @@ drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) } EGLBoolean -drm_make_current(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context) +drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context) { struct drm_surface *readSurf = lookup_drm_surface(read); struct drm_surface *drawSurf = lookup_drm_surface(draw); diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index d4cd2d3c743..c66c48f848b 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -178,22 +178,22 @@ drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen) screen->shown = 0; } -EGLSurface -drm_create_window_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) +_EGLSurface * +drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list) { - return EGL_NO_SURFACE; + return NULL; } -EGLSurface -drm_create_pixmap_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) +_EGLSurface * +drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list) { - return EGL_NO_SURFACE; + return NULL; } -EGLSurface -drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, +_EGLSurface * +drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list) { int i; @@ -201,13 +201,6 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, int height = -1; struct drm_surface *surf = NULL; __GLcontextModes *visual; - _EGLConfig *conf; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreatePbufferSurface"); - return EGL_NO_CONTEXT; - } for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { @@ -225,7 +218,7 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, if (width < 1 || height < 1) { _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePbufferSurface"); - return EGL_NO_SURFACE; + return NULL; } surf = (struct drm_surface *) calloc(1, sizeof(struct drm_surface)); @@ -245,17 +238,16 @@ drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, (void*)surf); drm_visual_modes_destroy(visual); - _eglLinkSurface(&surf->base, _eglLookupDisplay(dpy)); - return surf->base.Handle; + return &surf->base; err_surf: free(surf); err: - return EGL_NO_SURFACE; + return NULL; } -EGLSurface -drm_create_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, +_EGLSurface * +drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *cfg, const EGLint *attrib_list) { EGLSurface surf = drm_create_pbuffer_surface(drv, dpy, cfg, attrib_list); @@ -264,14 +256,13 @@ drm_create_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, } EGLBoolean -drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, - EGLScreenMESA screen, - EGLSurface surface, EGLModeMESA m) +drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLScreen *screen, + _EGLSurface *surface, _EGLMode *mode) { struct drm_device *dev = (struct drm_device *)drv; struct drm_surface *surf = lookup_drm_surface(surface); - struct drm_screen *scrn = lookup_drm_screen(dpy, screen); - _EGLMode *mode = _eglLookupMode(dpy, m); + struct drm_screen *scrn = lookup_drm_screen(screen); int ret; unsigned int i, k; @@ -361,11 +352,9 @@ err_bo: } EGLBoolean -drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) +drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) { struct drm_surface *surf = lookup_drm_surface(surface); - _eglUnlinkSurface(&surf->base); - if (!_eglIsSurfaceBound(&surf->base)) { if (surf->screen) drm_takedown_shown_screen(drv, surf->screen); @@ -376,7 +365,7 @@ drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) } EGLBoolean -drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) +drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) { struct drm_surface *surf = lookup_drm_surface(draw); struct pipe_surface *back_surf; diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index 521c91d8958..107f45cbcb1 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -129,9 +129,8 @@ drm_find_dpms(struct drm_device *dev, struct drm_screen *screen) } EGLBoolean -drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) +drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) { - _EGLDisplay *disp = _eglLookupDisplay(dpy); struct drm_device *dev = (struct drm_device *)drv; struct drm_screen *screen = NULL; drmModeConnectorPtr connector = NULL; @@ -214,7 +213,7 @@ err_fd: } EGLBoolean -drm_terminate(_EGLDriver *drv, EGLDisplay dpy) +drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy) { struct drm_device *dev = (struct drm_device *)drv; struct drm_screen *screen; @@ -240,7 +239,7 @@ drm_terminate(_EGLDriver *drv, EGLDisplay dpy) drmClose(dev->drmFD); - _eglCleanupDisplay(_eglLookupDisplay(dpy)); + _eglCleanupDisplay(dpy); free(dev); return EGL_TRUE; diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h index 3b8836720d6..25f70d885e0 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ b/src/gallium/state_trackers/egl/egl_tracker.h @@ -137,24 +137,21 @@ struct drm_screen static INLINE struct drm_context * -lookup_drm_context(EGLContext context) +lookup_drm_context(_EGLContext *c) { - _EGLContext *c = _eglLookupContext(context); return (struct drm_context *) c; } static INLINE struct drm_surface * -lookup_drm_surface(EGLSurface surface) +lookup_drm_surface(_EGLSurface *s) { - _EGLSurface *s = _eglLookupSurface(surface); return (struct drm_surface *) s; } static INLINE struct drm_screen * -lookup_drm_screen(EGLDisplay dpy, EGLScreenMESA screen) +lookup_drm_screen(_EGLScreen *s) { - _EGLScreen *s = _eglLookupScreen(dpy, screen); return (struct drm_screen *) s; } @@ -178,18 +175,18 @@ void drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen); * All function exported to the egl side. */ /*@{*/ -EGLBoolean drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLBoolean drm_terminate(_EGLDriver *drv, EGLDisplay dpy); -EGLContext drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list); -EGLBoolean drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context); -EGLSurface drm_create_window_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list); -EGLSurface drm_create_pixmap_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list); -EGLSurface drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); -EGLSurface drm_create_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, const EGLint *attrib_list); -EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA m); -EGLBoolean drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface); -EGLBoolean drm_make_current(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context); -EGLBoolean drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw); +EGLBoolean drm_initialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *major, EGLint *minor); +EGLBoolean drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy); +_EGLContext *drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list); +EGLBoolean drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context); +_EGLSurface *drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list); +_EGLSurface *drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list); +_EGLSurface *drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); +_EGLSurface *drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); +EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode); +EGLBoolean drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); +EGLBoolean drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context); +EGLBoolean drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); /*@}*/ #endif |