diff options
author | Kristian Høgsberg <krh@redhat.com> | 2008-11-08 15:06:48 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-11-08 15:06:48 -0500 |
commit | 8b8fd730e454d4339e0a22ff15409238a9c64677 (patch) | |
tree | db8a5a70daccc80e233bbda3b4383db5c5334f97 | |
parent | 64107309e212a0ead3da229d749f26301cab0113 (diff) |
Export the copy buffer extension as a way to copy between surfaces.
-rw-r--r-- | eagle.h | 20 | ||||
-rw-r--r-- | intel.c | 54 |
2 files changed, 60 insertions, 14 deletions
@@ -221,13 +221,19 @@ extern EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLNativePixmapType pixmap, const EGLint *attribList); -extern EGLSurface eglCreatePixmapForName(EGLDisplay dpy, - EGLConfig config, - uint32_t name, - uint32_t width, - uint32_t height, - uint32_t stride, - const EGLint *attribList); +extern EGLSurface eglCreateSurfaceForName(EGLDisplay dpy, + EGLConfig config, + uint32_t name, + uint32_t width, + uint32_t height, + uint32_t stride, + const EGLint *attribList); + +extern 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); extern EGLBoolean eglDestroySurface(EGLDisplay display, EGLSurface surface); @@ -55,7 +55,8 @@ nativeGetBuffers(EGLSurface surface, unsigned int *attachments, int count) int fd, i, ret; if (nativeSurface->width == surface->width && - nativeSurface->height == surface->height) + nativeSurface->height == surface->height && + count == surface->count) return; for (i = 0; i < count; i++) { @@ -124,13 +125,19 @@ nativeDRISwapBuffers(EGLDisplay display, EGLSurface surface) { EGLDisplayNative nativeDisplay = (EGLDisplayNative) display; EGLContext context; + __DRIbuffer *buffer; context = eglGetCurrentContext(); + buffer = &surface->buffers[0]; + return nativeDisplay->copyBuffer->copyBuffer(context->driContext, - surface->driDrawable, - __DRI_BUFFER_FRONT_LEFT, - &nativeDisplay->front); + &nativeDisplay->front, + 0, 0, + buffer, + 0, 0, + surface->width, + surface->height); } static const struct EagleBackend nativeDRIBackend = { @@ -344,9 +351,9 @@ eglCreateSurfaceNative(EGLDisplay display, EGLConfig config, } EGLSurface -eglCreatePixmapForName(EGLDisplay display, EGLConfig config, - uint32_t name, uint32_t width, - uint32_t height, uint32_t stride, const EGLint *attribList) +eglCreateSurfaceForName(EGLDisplay display, EGLConfig config, + uint32_t name, uint32_t width, + uint32_t height, uint32_t stride, const EGLint *attribList) { EGLSurfaceNative nativeSurface; @@ -365,3 +372,36 @@ eglCreatePixmapForName(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); +} |