diff options
author | Kristian Høgsberg <krh@sasori.boston.redhat.com> | 2009-01-15 11:37:43 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@sasori.boston.redhat.com> | 2009-01-16 07:49:07 -0500 |
commit | 0ac16f056dc32235a54d1376cf8018d080506813 (patch) | |
tree | 1069c79fc83ee08f551d7fb305666a9afab6e673 /cairo-util.c | |
parent | 32692d2f48693ed61957f3252307ca26cdf50a18 (diff) | |
download | wayland-0ac16f056dc32235a54d1376cf8018d080506813.tar.gz wayland-0ac16f056dc32235a54d1376cf8018d080506813.tar.xz wayland-0ac16f056dc32235a54d1376cf8018d080506813.zip |
Switch to cairo-drm, drop struct buffer hacks.
Diffstat (limited to 'cairo-util.c')
-rw-r--r-- | cairo-util.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/cairo-util.c b/cairo-util.c index 2d23b5e..0dfa3ad 100644 --- a/cairo-util.c +++ b/cairo-util.c @@ -24,104 +24,10 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <i915_drm.h> -#include <sys/ioctl.h> #include <math.h> #include <cairo.h> #include "cairo-util.h" -struct buffer * -buffer_create(int fd, int width, int height, int stride) -{ - struct buffer *buffer; - struct drm_i915_gem_create create; - struct drm_gem_flink flink; - - buffer = malloc(sizeof *buffer); - buffer->width = width; - buffer->height = height; - buffer->stride = stride; - - memset(&create, 0, sizeof(create)); - create.size = height * stride; - - if (ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) { - fprintf(stderr, "gem create failed: %m\n"); - free(buffer); - return NULL; - } - - flink.handle = create.handle; - if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) != 0) { - fprintf(stderr, "gem flink failed: %m\n"); - free(buffer); - return 0; - } - - buffer->handle = flink.handle; - buffer->name = flink.name; - - return buffer; -} - -int -buffer_destroy(struct buffer *buffer, int fd) -{ - struct drm_gem_close close; - - close.handle = buffer->handle; - if (ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close) < 0) { - fprintf(stderr, "gem close failed: %m\n"); - return -1; - } - - free(buffer); - - return 0; -} - -int -buffer_data(struct buffer *buffer, int fd, void *data) -{ - struct drm_i915_gem_pwrite pwrite; - - pwrite.handle = buffer->handle; - pwrite.offset = 0; - pwrite.size = buffer->height * buffer->stride; - pwrite.data_ptr = (uint64_t) (uintptr_t) data; - - if (ioctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite) < 0) { - fprintf(stderr, "gem pwrite failed: %m\n"); - return -1; - } - - return 0; -} - -struct buffer * -buffer_create_from_cairo_surface(int fd, cairo_surface_t *surface) -{ - struct buffer *buffer; - int32_t width, height, stride; - void *data; - - width = cairo_image_surface_get_width(surface); - height = cairo_image_surface_get_height(surface); - stride = cairo_image_surface_get_stride(surface); - data = cairo_image_surface_get_data(surface); - - buffer = buffer_create(fd, width, height, stride); - if (buffer == NULL) - return NULL; - - if (buffer_data(buffer, fd, data) < 0) { - buffer_destroy(buffer, fd); - return NULL; - } - - return buffer; -} - #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) void |