image_attribs[3] = rectangle->height;
data->image = eglCreateDRMImageMESA(dpy, image_attribs);
+ if (data->image == EGL_NO_IMAGE_KHR) {
+ free(data);
+ return NULL;
+ }
+
cairo_device_acquire(display->device);
glGenTextures(1, &data->texture);
glBindTexture(GL_TEXTURE_2D, data->texture);
}
surface = display_create_drm_surface(display, rect);
+ if (surface == NULL) {
+ g_object_unref(pixbuf);
+ return NULL;
+ }
+
data = cairo_surface_get_user_data(surface, &surface_data_key);
cairo_device_acquire(display->device);
pixels = gdk_pixbuf_get_pixels(pixbuf);
surface = display_create_shm_surface(display, rect);
+ if (surface == NULL) {
+ g_object_unref(pixbuf);
+ return NULL;
+ }
+
dest_data = cairo_image_surface_get_data (surface);
dest_stride = cairo_image_surface_get_stride (surface);
return surface;
}
+static int
+check_size(struct rectangle *rect)
+{
+ if (rect->width && rect->height)
+ return 0;
+
+ fprintf(stderr, "tried to create surface of "
+ "width: %d, height: %d\n", rect->width, rect->height);
+ return -1;
+}
+
cairo_surface_t *
display_create_surface(struct display *display,
struct rectangle *rectangle)
{
+ if (check_size(rectangle) < 0)
+ return NULL;
#ifdef HAVE_CAIRO_EGL
if (display->drm) {
return display_create_drm_surface(display, rectangle);
const char *filename,
struct rectangle *rectangle)
{
+ if (check_size(rectangle) < 0)
+ return NULL;
#ifdef HAVE_CAIRO_EGL
if (display->drm) {
return display_create_drm_surface_from_file(display, filename, rectangle);