Class: Cairo::GLSurface

Inherits:
Surface show all
Defined in:
ext/cairo/rb_cairo_surface.c

Direct Known Subclasses

GLTextureSurface

Instance Method Summary collapse

Methods inherited from Surface

#clone, #content, #copy_page, create, #create_similar, #create_similar_image, #destroy, #device, #device_offset, #device_scale, #dup, #fallback_resolution, #finish, #flush, #font_options, #get_mime_data, gl_supported?, gl_texture_supported?, image_supported?, #map_to_image, #mark_dirty, pdf_supported?, ps_supported?, quartz_image_supported?, quartz_supported?, recording_supported?, #reference_count, script_supported?, #set_device_offset, #set_device_scale, #set_fallback_resolution, #set_mime_data, #show_page, #sub_rectangle_surface, supported?, #supported_mime_type?, svg_supported?, tee_supported?, #unmap_image, win32_printing_supported?, win32_supported?, #write_to_png, xml_supported?

Constructor Details

#initializeObject

GL surface functions



1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
# File 'ext/cairo/rb_cairo_surface.c', line 1769

static VALUE
cr_gl_surface_initialize (int argc, VALUE *argv, VALUE self)
{
  cairo_surface_t *surface;
  cairo_device_t *device;
  int width, height;
  cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
  VALUE rb_device, rb_width, rb_height, rb_content;

  rb_scan_args (argc, argv, "31",
                &rb_device, &rb_width, &rb_height, &rb_content);

  device = RVAL2CRDEVICE (rb_device);
  width = NUM2INT (rb_width);
  height = NUM2INT (rb_height);
  switch (TYPE (rb_content))
    {
    case T_NIL:
      break;
    case T_STRING:
    case T_SYMBOL:
    case T_FIXNUM:
      content = RVAL2CRCONTENT (rb_content);
      break;
    default:
      rb_raise (rb_eArgError,
                "invalid argument (expect "
                "(device, width, height) or "
                "(device, width, height, content)): %s",
                rb_cairo__inspect (rb_ary_new4 (argc, argv)));
      break;
    }

  surface = cairo_gl_surface_create (device, content, width, height);

  rb_cairo_surface_check_status (surface);
  RTYPEDDATA_DATA (self) = surface;
  if (rb_block_given_p ())
    rb_cairo__surface_yield_and_finish (self);
  return Qnil;
}

Instance Method Details

#heightObject



1875
1876
1877
1878
1879
# File 'ext/cairo/rb_cairo_surface.c', line 1875

static VALUE
cr_gl_surface_get_height (VALUE self)
{
  return INT2NUM (cairo_gl_surface_get_height (_SELF));
}

#set_sizeObject



1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
# File 'ext/cairo/rb_cairo_surface.c', line 1858

static VALUE
cr_gl_surface_set_size (VALUE self, VALUE width, VALUE height)
{
  cairo_surface_t *surface = NULL;

  surface = _SELF;
  cairo_gl_surface_set_size (surface, NUM2INT (width), NUM2INT (height));
  rb_cairo_surface_check_status (surface);
  return Qnil;
}

#swap_buffersObject



1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
# File 'ext/cairo/rb_cairo_surface.c', line 1881

static VALUE
cr_gl_surface_swap_buffers (VALUE self)
{
  cairo_surface_t *surface = NULL;

  surface = _SELF;
  cairo_gl_surface_swapbuffers (surface);
  rb_cairo_surface_check_status (surface);
  return Qnil;
}

#widthObject



1869
1870
1871
1872
1873
# File 'ext/cairo/rb_cairo_surface.c', line 1869

static VALUE
cr_gl_surface_get_width (VALUE self)
{
  return INT2NUM (cairo_gl_surface_get_width (_SELF));
}