Exemple #1
0
static void
yield_and_finish (VALUE self)
{
  cairo_device_t *device;

  rb_yield (self);

  device = _SELF;
  if (!cairo_device_get_user_data (device, &cr_finished_key))
    cr_device_finish (self);
}
static cairo_surface_t *
_cairo_boilerplate_xcb_create_similar (cairo_surface_t *other,
				       cairo_content_t content,
				       int width, int height)
{
    cairo_device_t *device = cairo_surface_get_device (other);
    struct xcb_info *info = cairo_device_get_user_data (device, &key);
    xcb_screen_t *root;
    cairo_surface_t *surface;
    struct similar *similar;
    xcb_render_pictforminfo_t *render_format;
    int depth;

    similar = malloc (sizeof (*similar));

    switch (content) {
    default:
    case CAIRO_CONTENT_COLOR_ALPHA:
	    depth = 32;
	    render_format = info->render_format[0];
	    break;
    case CAIRO_CONTENT_COLOR:
	    depth = 24;
	    render_format = info->render_format[1];
	    break;
    case CAIRO_CONTENT_ALPHA:
	    depth = 8;
	    render_format = info->render_format[2];
	    break;
    }

    similar->connection =
	cairo_xcb_device_get_connection (cairo_surface_get_device(other));
    similar->pixmap = xcb_generate_id (similar->connection);

    root = xcb_setup_roots_iterator(xcb_get_setup(similar->connection)).data;
    xcb_create_pixmap (similar->connection, depth,
		       similar->pixmap, root->root,
		       width, height);

    surface = cairo_xcb_surface_create_with_xrender_format (similar->connection,
							    root,
							    similar->pixmap,
							    render_format,
							    width, height);
    cairo_surface_set_user_data (surface, &key, similar, _destroy_similar);

    return surface;
}
Exemple #3
0
static VALUE
cr_device_finish (VALUE self)
{
  cairo_device_t *device;
  rb_cairo__io_callback_closure_t *closure;

  device = _SELF;
  closure = cairo_device_get_user_data (device, &cr_closure_key);

  cairo_device_finish (device);
  cairo_device_set_user_data (device, &cr_finished_key, (void *)CR_TRUE, NULL);
  cairo_device_set_user_data (device, &cr_object_holder_key, NULL, NULL);

  if (closure && !NIL_P (closure->error))
    rb_exc_raise (closure->error);
  cr_device_check_status (device);

  return self;
}