summaryrefslogtreecommitdiff
path: root/eagle.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-10-12 23:01:21 -0400
committerKristian Høgsberg <krh@redhat.com>2008-10-13 10:13:48 -0400
commit2f15a22cc99d895b1c5f58bbd5618053f7c196c5 (patch)
tree19bcbad895a6d3e3375e21e4ff2e1bf4a4873439 /eagle.c
parent69584b77ca68b001b6b6ee24c112d9bae81aa9fe (diff)
Implement swapbuffers using a dri driver extension.
Diffstat (limited to 'eagle.c')
-rw-r--r--eagle.c71
1 files changed, 62 insertions, 9 deletions
diff --git a/eagle.c b/eagle.c
index 4ebd3df..2135e63 100644
--- a/eagle.c
+++ b/eagle.c
@@ -69,10 +69,15 @@ eglLoadDriver(EGLDisplay display, const char *driverName)
{
char filename[PATH_MAX];
const __DRIextension **extensions;
+ const char *path;
int i;
+ path = getenv("EAGLE_DRIVER_PATH");
+ if (path == NULL)
+ path = driDriverPath;
+
snprintf(filename, sizeof filename, "%s/%s_dri.so",
- driDriverPath, driverName);
+ path, driverName);
display->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
if (display->driver == NULL)
@@ -112,6 +117,7 @@ eglCreateDisplay(const char *device, const char *driver)
EGLDisplay display;
int i;
const __DRIconfig **configs;
+ const __DRIextension **extensions;
display = malloc(sizeof *display);
@@ -119,6 +125,9 @@ eglCreateDisplay(const char *device, const char *driver)
display->next_surface_id = 1;
display->fd = open(device, O_RDWR);
+ if (intelBackendInit(display) < 0)
+ goto fail;
+
if (eglLoadDriver(display, driver) < 0)
goto fail;
@@ -131,6 +140,25 @@ eglCreateDisplay(const char *device, const char *driver)
if (display->driScreen == NULL)
goto fail;
+
+ extensions = display->core->getExtensions(display->driScreen);
+ if (extensions == NULL)
+ goto fail;
+
+ for (i = 0; extensions[i]; i++) {
+#ifdef __DRI_COPY_BUFFER
+ if (strcmp(extensions[i]->name, __DRI_COPY_BUFFER) == 0 &&
+ extensions[i]->version >= __DRI_COPY_BUFFER_VERSION) {
+ display->copyBuffer = (__DRIcopyBufferExtension *) extensions[i];
+ }
+#endif
+ }
+
+#ifdef __DRI_COPY_BUFFER
+ if (display->copyBuffer == NULL)
+ goto fail;
+#endif
+
for (i = 0; configs[i]; i++)
;
display->numConfigs = i;
@@ -141,12 +169,10 @@ eglCreateDisplay(const char *device, const char *driver)
display->configs[i].id = i;
}
- intelBackendInit(display);
-
return display;
fail:
- drmClose(display->fd);
+ close(display->fd);
free(display);
return NULL;
@@ -341,6 +367,20 @@ eglCreateSurface(EGLDisplay display, EGLConfig fbconfig,
}
EGLSurface
+eglGetFullscreenSurface(EGLDisplay display, EGLConfig config,
+ int *width, int *height)
+{
+ EGLSurface surface;
+
+ surface = eglCreateSurface(display, config, 0, 0,
+ display->width, display->height);
+ *width = display->width;
+ *height = display->height;
+
+ return surface;
+}
+
+EGLSurface
eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win, const EGLint *attribList)
{
@@ -447,6 +487,9 @@ eglCreateContext(EGLDisplay display, EGLConfig config,
void
eglDestroyContext(EGLDisplay display, EGLContext context)
{
+ if (context == currentContext)
+ currentContext = EGL_NO_CONTEXT;
+
display->core->destroyContext(context->driContext);
free(context);
}
@@ -456,6 +499,7 @@ eglMakeCurrent(EGLDisplay display,
EGLSurface draw, EGLSurface read, EGLContext context)
{
__DRIdrawable *driDraw, *driRead;
+ EGLBoolean status;
context->drawSurface = draw;
context->readSurface = read;
@@ -465,8 +509,12 @@ eglMakeCurrent(EGLDisplay display,
if (read != NULL)
driRead = read->driDrawable;
- return display->core->bindContext(context->driContext,
- driDraw, driRead);
+ status = display->core->bindContext(context->driContext,
+ driDraw, driRead);
+ if (status)
+ currentContext = context;
+
+ return status;
}
EGLContext
@@ -552,14 +600,19 @@ eglWaitNative(EGLint engine)
return EGL_TRUE;
}
-
EGLBoolean
eglSwapBuffers(EGLDisplay display, EGLSurface surface)
{
- return display->backend->swapBuffers(display, surface);
+#ifdef __DRI_COPY_BUFFER
+ return display->copyBuffer->copyBuffer(currentContext->driContext,
+ surface->driDrawable,
+ __DRI_BUFFER_FRONT_LEFT,
+ &display->front);
+#else
+ return EGL_FALSE;
+#endif
}
-
EGLBoolean
eglCopyBuffers(EGLDisplay dpy,
EGLSurface surface, EGLNativePixmapType target)