diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-01-24 20:17:34 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-01-24 20:17:34 -0500 |
commit | b518f7b307a8e421ef38c6f661147b64ee438771 (patch) | |
tree | 7554fdea80233e2b39ed80d166aef06eea6d729d | |
parent | e51d3882d6bd34e898a87ececc42b9aa555f09e9 (diff) |
Move copyBuffer functionality to eagle.c
-rw-r--r-- | eagle-internal.h | 2 | ||||
-rw-r--r-- | eagle.c | 38 | ||||
-rw-r--r-- | intel.c | 98 | ||||
-rw-r--r-- | radeon.c | 33 |
4 files changed, 54 insertions, 117 deletions
diff --git a/eagle-internal.h b/eagle-internal.h index c86efe5..30d7642 100644 --- a/eagle-internal.h +++ b/eagle-internal.h @@ -50,6 +50,8 @@ struct EGLDisplay { int width, height; + __DRIcopyBufferExtension *copyBuffer; + const struct EagleBackend *backend; void *backendPrivate; }; @@ -203,6 +203,12 @@ eglInitDisplay(EGLDisplay display, display->texBuffer = (__DRItexBufferExtension *) extensions[i]; } + + if (strcmp(extensions[i]->name, __DRI_COPY_BUFFER) == 0 && + extensions[i]->version >= __DRI_COPY_BUFFER_VERSION) { + display->copyBuffer = + (__DRIcopyBufferExtension *) extensions[i]; + } } for (i = 0; configs[i]; i++) @@ -742,3 +748,35 @@ void (*eglGetProcAddress(const char *procname))(void) { return NULL; } + +EGLBoolean +eglCopyNativeBuffers(EGLDisplay display, + EGLSurface dst, GLenum dstBuffer, int32_t dst_x, int32_t dst_y, + EGLSurface src, GLenum srcBuffer, int32_t x, int32_t y, int32_t width, int32_t height) +{ + EGLContext context; + __DRIbuffer *srcDRIBuffer, *dstDRIBuffer; + unsigned int attachments[1]; + + context = eglGetCurrentContext(); + + /* FIXME: glCopyPixels should work, but then we'll have to + * call eglMakeCurrent to set up the src and dest surfaces + * first. This seems cheaper, but maybe there's a better way + * to accomplish this. */ + + attachments[0] = __DRI_BUFFER_FRONT_LEFT; + display->backend->getBuffers(src, attachments, 1); + + /* FIXME: Actually use dstBuffer and srcBuffer (eg + * GL_FRONT_LEFT) to look up the buffers to use. */ + + dstDRIBuffer = &dst->buffers[0]; + srcDRIBuffer = &src->buffers[0]; + + return display->copyBuffer->copyBuffer(context->driContext, + dstDRIBuffer, + dst_x, dst_y, + srcDRIBuffer, + x, y, width, height); +} @@ -34,13 +34,6 @@ #define INTEL_STRIDE_ALIGNMENT 64 -typedef struct EGLDisplayNative *EGLDisplayNative; -struct EGLDisplayNative { - struct EGLDisplay base; - - __DRIcopyBufferExtension *copyBuffer; -}; - typedef struct EGLSurfaceNative *EGLSurfaceNative; struct EGLSurfaceNative { struct EGLSurface base; @@ -131,7 +124,6 @@ nativeDestroySurface(EGLDisplay display, EGLSurface surface) static EGLBoolean nativeDRISwapBuffers(EGLDisplay display, EGLSurface surface) { - EGLDisplayNative nativeDisplay = (EGLDisplayNative) display; EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface; EGLContext context; __DRIbuffer *back; @@ -143,13 +135,13 @@ nativeDRISwapBuffers(EGLDisplay display, EGLSurface surface) back = &surface->buffers[0]; - nativeDisplay->copyBuffer->copyBuffer(context->driContext, - &nativeSurface->front, - 0, 0, - back, - 0, 0, - surface->width, - surface->height); + display->copyBuffer->copyBuffer(context->driContext, + &nativeSurface->front, + 0, 0, + back, + 0, 0, + surface->width, + surface->height); glFlush(); @@ -162,52 +154,23 @@ static const struct EagleBackend nativeDRIBackend = { nativeDestroySurface, }; -static void -nativeInitDRICopyBuffer(EGLDisplay display) -{ - EGLDisplayNative nativeDisplay = (EGLDisplayNative) display; - const __DRIextension **extensions; - int i; - - extensions = display->core->getExtensions(display->driScreen); - if (extensions == NULL) - return; - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_COPY_BUFFER) == 0 && - extensions[i]->version >= __DRI_COPY_BUFFER_VERSION) { - nativeDisplay->copyBuffer = - (__DRIcopyBufferExtension *) extensions[i]; - } - } - - if (nativeDisplay->copyBuffer == NULL) - return; - - display->backend = &nativeDRIBackend; - - printf("Using DRI CopyBuffer swapbuffer\n"); -} - static EGLDisplay intelCreateDisplay(struct udev_device *device, const char *driver) { - EGLDisplayNative nativeDisplay; + EGLDisplay display; - nativeDisplay = malloc(sizeof *nativeDisplay); - if (nativeDisplay == NULL) + display = malloc(sizeof *display); + if (display == NULL) return NULL; - if (eglInitDisplay(&nativeDisplay->base, device, driver) < 0) { - free(nativeDisplay); + if (eglInitDisplay(display, device, driver) < 0) { + free(display); return NULL; } - nativeInitDRICopyBuffer(&nativeDisplay->base); - if (nativeDisplay->base.backend == NULL) - return NULL; + display->backend = &nativeDRIBackend; - return &nativeDisplay->base; + return display; } EGLDisplay @@ -253,36 +216,3 @@ eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, return &nativeSurface->base; } - -EGLBoolean -eglCopyNativeBuffers(EGLDisplay display, - EGLSurface dst, GLenum dstBuffer, int32_t dst_x, int32_t dst_y, - EGLSurface src, GLenum srcBuffer, int32_t x, int32_t y, int32_t width, int32_t height) -{ - EGLDisplayNative nativeDisplay = (EGLDisplayNative) display; - EGLContext context; - __DRIbuffer *srcDRIBuffer, *dstDRIBuffer; - unsigned int attachments[1]; - - context = eglGetCurrentContext(); - - /* FIXME: glCopyPixels should work, but then we'll have to - * call eglMakeCurrent to set up the src and dest surfaces - * first. This seems cheaper, but maybe there's a better way - * to accomplish this. */ - - attachments[0] = __DRI_BUFFER_FRONT_LEFT; - nativeGetBuffers(src, attachments, 1); - - /* FIXME: Actually use dstBuffer and srcBuffer (eg - * GL_FRONT_LEFT) to look up the buffers to use. */ - - dstDRIBuffer = &dst->buffers[0]; - srcDRIBuffer = &src->buffers[0]; - - return nativeDisplay->copyBuffer->copyBuffer(context->driContext, - dstDRIBuffer, - dst_x, dst_y, - srcDRIBuffer, - x, y, width, height); -} @@ -185,36 +185,3 @@ eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, return &nativeSurface->base; } - -EGLBoolean -eglCopyNativeBuffers(EGLDisplay display, - EGLSurface dst, GLenum dstBuffer, int32_t dst_x, int32_t dst_y, - EGLSurface src, GLenum srcBuffer, int32_t x, int32_t y, int32_t width, int32_t height) -{ - EGLDisplayNative nativeDisplay = (EGLDisplayNative) display; - EGLContext context; - __DRIbuffer *srcDRIBuffer, *dstDRIBuffer; - unsigned int attachments[1]; - - context = eglGetCurrentContext(); - - /* FIXME: glCopyPixels should work, but then we'll have to - * call eglMakeCurrent to set up the src and dest surfaces - * first. This seems cheaper, but maybe there's a better way - * to accomplish this. */ - - attachments[0] = __DRI_BUFFER_FRONT_LEFT; - nativeGetBuffers(src, attachments, 1); - - /* FIXME: Actually use dstBuffer and srcBuffer (eg - * GL_FRONT_LEFT) to look up the buffers to use. */ - - dstDRIBuffer = &dst->buffers[0]; - srcDRIBuffer = &src->buffers[0]; - - return nativeDisplay->copyBuffer->copyBuffer(context->driContext, - dstDRIBuffer, - dst_x, dst_y, - srcDRIBuffer, - x, y, width, height); -} |