summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-03-06 21:11:45 -0500
committerKristian Høgsberg <krh@redhat.com>2009-03-06 21:13:01 -0500
commitc21f18146dad6962527cf2f0a45b1f824c0a1596 (patch)
treefe8931ef3e756687640d2b3af892383480791fa3
parent7a6cfb4704e98cfdbdcdffb387f26c9572781e0f (diff)
Create front buffer in eglCreateSurfaceForName if name is 0.
-rw-r--r--eagle.h13
-rw-r--r--intel.c76
2 files changed, 54 insertions, 35 deletions
diff --git a/eagle.h b/eagle.h
index cd8ecab..6c788c5 100644
--- a/eagle.h
+++ b/eagle.h
@@ -25,6 +25,7 @@
#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
#include <libudev.h>
+#include <GL/gl.h>
typedef int EGLBoolean;
typedef int EGLint;
@@ -249,17 +250,17 @@ extern EGLSurface eglCreatePixmapSurface(EGLDisplay dpy,
extern EGLSurface eglCreateSurfaceForName(EGLDisplay dpy,
EGLConfig config,
- uint32_t name,
- uint32_t width,
- uint32_t height,
- uint32_t stride,
+ GLuint name,
+ GLuint width,
+ GLuint height,
+ GLuint stride,
const EGLint *attribList);
extern EGLBoolean eglCopyNativeBuffers(EGLDisplay display,
EGLSurface dst, GLenum dstBuffer,
- int32_t dst_x, int32_t dst_y,
+ GLint dst_x, GLint dst_y,
EGLSurface src, GLenum srcBuffer,
- int32_t x, int32_t y, int32_t width, int32_t height);
+ GLint x, GLint y, GLint width, GLint height);
extern void *eglReadBuffer(EGLDisplay display,
EGLSurface surface, GLenum buffer, GLuint *stride);
diff --git a/intel.c b/intel.c
index bd28fe6..dae7a5a 100644
--- a/intel.c
+++ b/intel.c
@@ -49,16 +49,40 @@ align_to(uint32_t value, uint32_t align)
return (value + align - 1) & ~(align - 1);
}
+static int
+intelCreateBuffer(int fd, GLint width, GLint height, __DRIbuffer *buffer)
+{
+ struct drm_i915_gem_create create;
+ struct drm_gem_flink flink;
+ uint32_t size;
+
+ buffer->pitch = align_to(width * 4, INTEL_STRIDE_ALIGNMENT);
+ size = buffer->pitch * height;
+ create.size = size;
+ if (ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create)) {
+ fprintf(stderr, "failed to create buffer\n");
+ return -1;
+ }
+
+ flink.handle = create.handle;
+ if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
+ fprintf(stderr, "failed to create buffer\n");
+ return -1;
+ }
+
+ buffer->name = flink.name;
+ buffer->cpp = 4;
+
+ return create.handle;
+}
+
static void
intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count)
{
EGLSurfaceNative nativeSurface = (EGLSurfaceNative) surface;
- struct drm_i915_gem_create create;
- struct drm_gem_flink flink;
- struct drm_gem_open open_arg;
__DRIbuffer *buffer;
- uint32_t size;
- int fd, i, ret;
+ struct drm_gem_open open_arg;
+ int i, ret;
if (count == surface->count)
return;
@@ -69,15 +93,13 @@ intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count)
buffer = &surface->buffers[i];
buffer->attachment = attachments[i];
- buffer->pitch = align_to(surface->width * 4,
- INTEL_STRIDE_ALIGNMENT);
- buffer->cpp = 4;
if (buffer->attachment == __DRI_BUFFER_FRONT_LEFT &&
nativeSurface->front.name != ~0 &&
!nativeSurface->backBuffer) {
buffer->name = nativeSurface->front.name;
buffer->pitch = nativeSurface->front.pitch;
+ buffer->cpp = 4;
open_arg.name = buffer->name;
ret = ioctl(surface->display->fd,
DRM_IOCTL_GEM_OPEN, &open_arg);
@@ -92,22 +114,11 @@ intelGetBuffers(EGLSurface surface, unsigned int *attachments, int count)
continue;
}
- size = buffer->pitch * surface->height;
- fd = surface->display->fd;
- create.size = size;
- if (ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create)) {
- fprintf(stderr, "failed to create buffer\n");
- return;
- }
- nativeSurface->handles[i] = create.handle;
-
- flink.handle = create.handle;
- if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
- fprintf(stderr, "failed to create buffer\n");
- return;
- }
-
- buffer->name = flink.name;
+ nativeSurface->handles[i] =
+ intelCreateBuffer(surface->display->fd,
+ surface->width,
+ surface->height,
+ buffer);
}
surface->count = count;
@@ -170,11 +181,18 @@ intelCreateSurfaceForName(EGLDisplay display, EGLConfig config,
nativeSurface->backBuffer = EGL_FALSE;
nativeSurface->front.attachment = __DRI_BUFFER_FRONT_LEFT;
- nativeSurface->front.name = name;
- nativeSurface->front.pitch = stride;
- nativeSurface->front.cpp = 4;
- nativeSurface->front.flags = 0;
- nativeSurface->frontHandle = 0;
+ if (name == 0) {
+ nativeSurface->frontHandle =
+ intelCreateBuffer(display->fd,
+ width, height,
+ &nativeSurface->front);
+ } else {
+ nativeSurface->front.name = name;
+ nativeSurface->front.pitch = stride;
+ nativeSurface->front.cpp = 4;
+ nativeSurface->front.flags = 0;
+ nativeSurface->frontHandle = 0;
+ }
eglInitSurface(&nativeSurface->base, display, config, width, height);