Class: Cairo::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/cairo/device.rb,
ext/cairo/rb_cairo_device.c

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject



191
192
193
194
195
196
197
198
199
# File 'ext/cairo/rb_cairo_device.c', line 191

static VALUE
cr_device_initialize (int argc, VALUE *argv, VALUE self)
{
  rb_raise(rb_eNotImpError,
           "%s class creation isn't supported on this cairo installation",
           rb_obj_classname(self));

  return Qnil;
}

Class Method Details

.script_supported?Boolean

Returns:

  • (Boolean)


99
100
101
102
103
104
105
106
107
# File 'ext/cairo/rb_cairo_device.c', line 99

static VALUE
cr_device_script_supported_p (VALUE klass)
{
#ifdef CAIRO_HAS_SCRIPT_SURFACE
  return Qtrue;
#else
  return Qfalse;
#endif
}

.supported?(type) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'lib/cairo/device.rb', line 5

def supported?(type)
  supported_predicate = "#{type.to_s.downcase}_supported?"
  return false unless respond_to?(supported_predicate)
  send(supported_predicate)
end

.xml_supported?Boolean

Returns:

  • (Boolean)


109
110
111
112
113
114
115
116
117
# File 'ext/cairo/rb_cairo_device.c', line 109

static VALUE
cr_device_xml_supported_p (VALUE klass)
{
#ifdef CAIRO_HAS_XML_SURFACE
  return Qtrue;
#else
  return Qfalse;
#endif
}

Instance Method Details

#acquireObject



250
251
252
253
254
255
256
257
258
259
# File 'ext/cairo/rb_cairo_device.c', line 250

static VALUE
cr_device_acquire (VALUE self)
{
  cairo_device_acquire (_SELF);
  cr_device_check_status (_SELF);
  if (rb_block_given_p ())
    return rb_ensure (rb_yield, self, cr_device_release, self);
  else
    return self;
}

#destroyObject

Backend device manipulation



202
203
204
205
206
207
208
209
210
211
212
# File 'ext/cairo/rb_cairo_device.c', line 202

static VALUE
cr_device_destroy (VALUE self)
{
  cairo_device_t *device;

  device = _SELF;
  cairo_device_destroy (device);
  DATA_PTR (self) = NULL;

  return self;
}

#finishObject



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'ext/cairo/rb_cairo_device.c', line 214

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;
}

#flushObject



234
235
236
237
238
239
240
# File 'ext/cairo/rb_cairo_device.c', line 234

static VALUE
cr_device_flush (VALUE self)
{
  cairo_device_flush (_SELF);
  cr_device_check_status (_SELF);
  return self;
}

#releaseObject



242
243
244
245
246
247
248
# File 'ext/cairo/rb_cairo_device.c', line 242

static VALUE
cr_device_release (VALUE self)
{
  cairo_device_release (_SELF);
  cr_device_check_status (_SELF);
  return self;
}