Create front buffer with eagle.
authorKristian Høgsberg <krh@redhat.com>
Wed, 11 Mar 2009 03:40:35 +0000 (23:40 -0400)
committerKristian Høgsberg <krh@redhat.com>
Wed, 11 Mar 2009 03:54:36 +0000 (23:54 -0400)
This removes the intel dependencies from the system compositor.

gears.c
wayland-system-compositor.c

diff --git a/gears.c b/gears.c
index b00961e..2b7b29e 100644 (file)
--- a/gears.c
+++ b/gears.c
@@ -315,9 +315,9 @@ handle_frame(void *data,
             uint32_t frame, uint32_t timestamp)
 {
        struct gears *gears = data;
-       uint32_t name, stride;
+       uint32_t name, handle, stride;
 
-       eglGetNativeBuffer(gears->surface, GL_FRONT_LEFT, &name, &stride);
+       eglGetNativeBuffer(gears->surface, GL_FRONT_LEFT, &name, &handle, &stride);
        
        window_copy(gears->window, &gears->rectangle, name, stride);
 
index 3b1c203..1358c58 100644 (file)
@@ -22,7 +22,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 #include <termios.h>
-#include <i915_drm.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -69,7 +68,7 @@ struct wlsc_output {
        struct wlsc_compositor *compositor;
        struct wlsc_surface *background;
        EGLSurface surface;
-       int32_t x, y, width, height, stride;
+       int32_t x, y, width, height;
 
        drmModeModeInfo *mode;
        uint32_t fb_id;
@@ -170,7 +169,6 @@ static const GOptionEntry option_entries[] = {
        { NULL }
 };
 
-
 struct screenshooter {
        struct wl_object base;
        struct wlsc_compositor *ec;
@@ -1231,9 +1229,8 @@ create_output(struct wlsc_compositor *ec, struct udev_device *device)
        drmModeRes *resources;
        drmModeEncoder *encoder;
        drmModeModeInfo *mode;
-       struct drm_i915_gem_create create;
-       struct drm_gem_flink flink;
        struct wlsc_output *output;
+       uint32_t name, handle, stride;
        int i, ret, fd;
 
        if (ec->display == NULL && init_egl(ec, device) < 0) {
@@ -1283,15 +1280,30 @@ create_output(struct wlsc_compositor *ec, struct udev_device *device)
                drmModeFreeEncoder(encoder);
        }
 
-       /* Mode size at 32 bpp */
-       create.size = mode->hdisplay * mode->vdisplay * 4;
-       if (ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) {
-               fprintf(stderr, "gem create failed: %m\n");
+       output->compositor = ec;
+       output->crtc_id = encoder->crtc_id;
+       output->connector_id = connector->connector_id;
+       output->mode = mode;
+       output->x = 0;
+       output->y = 0;
+       output->width = mode->hdisplay;
+       output->height = mode->vdisplay;
+
+       output->surface = eglCreateSurfaceForName(ec->display,
+                                                 ec->config,
+                                                 0,
+                                                 output->width,
+                                                 output->height,
+                                                 0, surface_attribs);
+       if (output->surface == NULL) {
+               fprintf(stderr, "failed to create surface\n");
                return -1;
        }
 
-       ret = drmModeAddFB(fd, mode->hdisplay, mode->vdisplay,
-                          32, 32, mode->hdisplay * 4, create.handle, &output->fb_id);
+       eglGetNativeBuffer(output->surface,
+                          GL_FRONT_LEFT, &name, &handle, &stride);
+       ret = drmModeAddFB(fd, output->width, output->height,
+                          32, 32, stride, handle, &output->fb_id);
        if (ret) {
                fprintf(stderr, "failed to add fb: %m\n");
                return -1;
@@ -1304,32 +1316,6 @@ create_output(struct wlsc_compositor *ec, struct udev_device *device)
                return -1;
        }
 
-       flink.handle = create.handle;
-       if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) != 0) {
-               fprintf(stderr, "gem flink failed: %m\n");
-               return -1;
-       }
-
-       output->compositor = ec;
-       output->crtc_id = encoder->crtc_id;
-       output->connector_id = connector->connector_id;
-       output->mode = mode;
-       output->x = 0;
-       output->y = 0;
-       output->width = mode->hdisplay;
-       output->height = mode->vdisplay;
-       output->stride = mode->hdisplay * 4;
-
-       output->surface = eglCreateSurfaceForName(ec->display, ec->config,
-                                                 flink.name,
-                                                 output->width, output->height,
-                                                 output->stride,
-                                                 surface_attribs);
-       if (output->surface == NULL) {
-               fprintf(stderr, "failed to create surface\n");
-               return -1;
-       }
-
        output->base.interface = &wl_output_interface;
        wl_display_add_object(ec->wl_display, &output->base);
        wl_display_add_global(ec->wl_display, &output->base, post_output_geometry);