summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2008-07-07 13:24:09 +0200
committerJakob Bornecrantz <[email protected]>2008-07-07 13:24:09 +0200
commit1315f720ba80596b866103a7e153bfc2f2bd267b (patch)
tree59ff08e84e1d611920c9920648d1b814359898bd /src
parentb30fb6d54019c84174379a773121438ba943557a (diff)
i915: Destruction of surface, context and device in EGL
Diffstat (limited to 'src')
-rw-r--r--src/gallium/winsys/egl_drm/intel/intel_context.c14
-rw-r--r--src/gallium/winsys/egl_drm/intel/intel_egl.c21
-rw-r--r--src/gallium/winsys/egl_drm/intel/intel_egl.h8
-rw-r--r--src/gallium/winsys/egl_drm/intel/intel_screen.c31
4 files changed, 65 insertions, 9 deletions
diff --git a/src/gallium/winsys/egl_drm/intel/intel_context.c b/src/gallium/winsys/egl_drm/intel/intel_context.c
index 7205fa4483a..7513f3feefe 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_context.c
+++ b/src/gallium/winsys/egl_drm/intel/intel_context.c
@@ -178,6 +178,20 @@ intel_create_context(struct egl_drm_context *egl_context, const __GLcontextModes
return TRUE;
}
+int
+intel_destroy_context(struct egl_drm_context *egl_context)
+{
+ struct intel_context *intel = egl_context->priv;
+
+ if (intel->intel_screen->dummy == intel)
+ intel->intel_screen->dummy = NULL;
+
+ st_destroy_context(intel->st);
+ intel_be_destroy_context(&intel->base);
+ free(intel);
+ return TRUE;
+}
+
void
intel_make_current(struct egl_drm_context *context, struct egl_drm_drawable *draw, struct egl_drm_drawable *read)
{
diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.c b/src/gallium/winsys/egl_drm/intel/intel_egl.c
index e078b9eda10..9e12a024eb0 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_egl.c
+++ b/src/gallium/winsys/egl_drm/intel/intel_egl.c
@@ -32,7 +32,7 @@ egl_drm_create_device(int drmFD)
memset(device, 0, sizeof(*device));
device->drmFD = drmFD;
- if (!intel_init_driver(device)) {
+ if (!intel_create_device(device)) {
free(device);
return NULL;
}
@@ -180,8 +180,15 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
static EGLBoolean
drm_terminate(_EGLDriver *drv, EGLDisplay dpy)
{
- /* TODO: clean up */
- free(drv);
+ struct drm_driver *drm_drv = (struct drm_driver *)drv;
+
+ intel_destroy_device(drm_drv->device);
+
+ drmClose(drm_drv->device->drmFD);
+
+ free(drm_drv->device);
+ free(drm_drv);
+
return EGL_TRUE;
}
@@ -303,6 +310,8 @@ drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
if (fc->base.IsBound) {
fc->base.DeletePending = EGL_TRUE;
} else {
+ intel_destroy_context(fc->context);
+ free(fc->context);
free(fc);
}
return EGL_TRUE;
@@ -322,6 +331,7 @@ drm_create_pixmap_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, Nat
return EGL_NO_SURFACE;
}
+
static EGLSurface
drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list)
@@ -534,14 +544,15 @@ drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
if (fs->base.IsBound) {
fs->base.DeletePending = EGL_TRUE;
} else {
+ intel_bind_frontbuffer(fs->drawable, NULL);
+ intel_destroy_drawable(fs->drawable);
+ free(fs->drawable);
free(fs);
}
return EGL_TRUE;
}
-
-
static EGLBoolean
drm_make_current(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context)
{
diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.h b/src/gallium/winsys/egl_drm/intel/intel_egl.h
index 18e84e8eeab..84b6c212bfd 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_egl.h
+++ b/src/gallium/winsys/egl_drm/intel/intel_egl.h
@@ -32,9 +32,15 @@ struct egl_drm_frontbuffer
#include "GL/internal/glcore.h"
-int intel_init_driver(struct egl_drm_device *device);
+int intel_create_device(struct egl_drm_device *device);
+int intel_destroy_device(struct egl_drm_device *device);
+
int intel_create_context(struct egl_drm_context *context, const __GLcontextModes *visual, void *sharedContextPrivate);
+int intel_destroy_context(struct egl_drm_context *context);
+
int intel_create_drawable(struct egl_drm_drawable *drawable, const __GLcontextModes * visual);
+int intel_destroy_drawable(struct egl_drm_drawable *drawable);
+
void intel_make_current(struct egl_drm_context *context, struct egl_drm_drawable *draw, struct egl_drm_drawable *read);
void intel_swap_buffers(struct egl_drm_drawable *draw);
void intel_bind_frontbuffer(struct egl_drm_drawable *draw, struct egl_drm_frontbuffer *front);
diff --git a/src/gallium/winsys/egl_drm/intel/intel_screen.c b/src/gallium/winsys/egl_drm/intel/intel_screen.c
index 2818b9676c5..12f605e0bea 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_screen.c
+++ b/src/gallium/winsys/egl_drm/intel/intel_screen.c
@@ -41,7 +41,7 @@ extern const struct dri_extension card_extensions[];
int
-intel_init_driver(struct egl_drm_device *device)
+intel_create_device(struct egl_drm_device *device)
{
struct intel_screen *intel_screen;
@@ -67,6 +67,19 @@ intel_init_driver(struct egl_drm_device *device)
}
int
+intel_destroy_device(struct egl_drm_device *device)
+{
+ struct intel_screen *intel_screen = (struct intel_screen *)device->priv;
+
+ intel_be_destroy_device(&intel_screen->base);
+
+ free(intel_screen);
+ device->priv = NULL;
+
+ return TRUE;
+}
+
+int
intel_create_drawable(struct egl_drm_drawable *drawable,
const __GLcontextModes * visual)
{
@@ -108,6 +121,18 @@ intel_create_drawable(struct egl_drm_drawable *drawable,
return GL_FALSE;
}
- drawable->priv = (void *) intelfb;
- return GL_TRUE;
+ drawable->priv = (void *) intelfb;
+ return GL_TRUE;
+}
+
+int
+intel_destroy_drawable(struct egl_drm_drawable *drawable)
+{
+ struct intel_framebuffer *intelfb = (struct intel_framebuffer *)drawable->priv;
+ drawable->priv = NULL;
+
+ assert(intelfb->stfb);
+ st_unreference_framebuffer(&intelfb->stfb);
+ free(intelfb);
+ return TRUE;
}