/* Cairo::RasterSourcePattern */ static cairo_surface_t * cr_raster_source_acquire_callback (cairo_pattern_t *pattern, void *callback_data, cairo_surface_t *target, const cairo_rectangle_int_t *extents) { VALUE rb_pattern; VALUE rb_acquire; cairo_surface_t *acquired_surface = NULL; rb_pattern = POINTER2RVAL (callback_data); rb_acquire = rb_iv_get (rb_pattern, "@acquire"); if (!NIL_P (rb_acquire)) { VALUE rb_acquired_surface; VALUE rb_target; VALUE rb_extents; rb_target = CRSURFACE2RVAL (target); rb_extents = rb_funcall (rb_cCairo_Rectangle, id_new, 4, INT2NUM (extents->x), INT2NUM (extents->y), INT2NUM (extents->width), INT2NUM (extents->height)); rb_acquired_surface = rb_funcall (rb_acquire, id_call, 3, rb_pattern, rb_target, rb_extents); if (!NIL_P (rb_acquired_surface)) acquired_surface = RVAL2CRSURFACE (rb_acquired_surface); } return acquired_surface; }
static VALUE cr_mask_surface (VALUE self, VALUE surface, VALUE x, VALUE y) { cairo_mask_surface (_SELF, RVAL2CRSURFACE (surface), NUM2DBL (x), NUM2DBL (y)); cr_check_status (_SELF); return self; }
static VALUE cr_surface_pattern_initialize (VALUE self, VALUE surface) { cairo_pattern_t *pattern; pattern = cairo_pattern_create_for_surface (RVAL2CRSURFACE (surface)); cr_pattern_check_status (pattern); DATA_PTR (self) = pattern; return Qnil; }
static VALUE cr_xml_device_reply (VALUE self, VALUE recording_surface) { cairo_device_t *device; device = _SELF; cairo_xml_for_recording_surface (device, RVAL2CRSURFACE (recording_surface)); cr_device_check_status (device); return Qnil; }
static VALUE cr_set_source_surface (VALUE self, VALUE surface, VALUE width, VALUE height) { cairo_set_source_surface (_SELF, RVAL2CRSURFACE (surface), NUM2DBL (width), NUM2DBL (height)); cr_check_status (_SELF); rb_ivar_set (self, cr_id_source, Qnil); return self; }
static VALUE cr_surface_create_similar (VALUE self, VALUE content, VALUE width, VALUE height) { cairo_surface_t *surface; surface = cairo_surface_create_similar (RVAL2CRSURFACE (self), RVAL2CRCONTENT (content), NUM2INT (width), NUM2INT (height)); cr_surface_check_status (surface); return CRSURFACE2RVAL_WITH_DESTROY (surface); }
static VALUE cr_quartz_image_surface_initialize (VALUE self, VALUE image_surface) { cairo_surface_t *surface; surface = cairo_quartz_image_surface_create (RVAL2CRSURFACE (image_surface)); cr_surface_check_status (surface); DATA_PTR (self) = surface; if (rb_block_given_p ()) yield_and_finish (self); return Qnil; }
static VALUE cr_initialize (VALUE self, VALUE target) { cairo_t *cr; VALUE result = Qnil; cr = cairo_create (RVAL2CRSURFACE (target)); cr_check_status (cr); rb_ivar_set (self, cr_id_surface, target); cr_set_user_data (cr, &cr_object_holder_key, cr_object_holder_new(self), cr_object_holder_free); DATA_PTR (self) = cr; if (rb_block_given_p ()) result = rb_ensure (rb_yield, self, cr_destroy_with_destroy_check, self); return result; }
static VALUE cr_get_target (VALUE self) { cairo_surface_t *surface; VALUE rb_surface; surface = cairo_get_target (_SELF); rb_cairo_check_status (cairo_surface_status (surface)); rb_surface = rb_ivar_get (self, cr_id_surface); if (NIL_P (rb_surface) || RVAL2CRSURFACE (rb_surface) != surface) { rb_surface = CRSURFACE2RVAL (surface); rb_ivar_set (self, cr_id_surface, rb_surface); } return rb_surface; }