# class Cairo::TeeSurface

tee surface

### Public Class Methods

new(p1) click to toggle source

tee surface functions

    static VALUE
    cr_tee_surface_initialize (VALUE self, VALUE master)
    {
      cairo_surface_t *surface = NULL;

      surface = cairo_tee_surface_create (RVAL2CRSURFACE (master));
      rb_cairo_surface_check_status (surface);
      DATA_PTR (self) = surface;
      rb_iv_set (self, "surfaces", rb_ary_new3 (1, master));
      if (rb_block_given_p ())
        rb_cairo__surface_yield_and_finish (self);
      return Qnil;
    }

### Public Instance Methods

<<(p1) click to toggle source

    static VALUE
    cr_tee_surface_shift_operator (VALUE self, VALUE target)
    {
      cr_tee_surface_add (self, target);
      return self;
    }

[](p1) click to toggle source

    static VALUE
    cr_tee_surface_array_reference (VALUE self, VALUE index)
    {
      cairo_surface_t *surface = NULL, *target;

      surface = _SELF;
      index = rb_Integer (index);
      target = cairo_tee_surface_index (surface, NUM2UINT (index));
      rb_cairo_surface_check_status (surface);
      rb_cairo_surface_check_status (target);
      return CRSURFACE2RVAL (target);
    }

add(p1) click to toggle source

    static VALUE
    cr_tee_surface_add (VALUE self, VALUE target)
    {
      cairo_surface_t *surface = NULL;

      surface = _SELF;
      cairo_tee_surface_add (surface, RVAL2CRSURFACE (target));
      rb_cairo_surface_check_status (surface);
      rb_ary_push (rb_iv_get (self, "surfaces"), target);
      return Qnil;
    }

remove(p1) click to toggle source

    static VALUE
    cr_tee_surface_remove (VALUE self, VALUE target_or_index)
    {
      cairo_surface_t *surface = NULL, *target;
      VALUE rb_surfaces;
      int i;

      surface = _SELF;
      if (rb_cairo__is_kind_of (target_or_index, rb_cCairo_Surface))
        {
          target = RVAL2CRSURFACE (target_or_index);
        }
      else
        {
          VALUE index;

          index = rb_check_to_integer (target_or_index, "to_int");
          if (NIL_P (index))
            rb_raise (rb_eArgError,
                      "invalid argument (expect (surface) or (index)): %s",
                      rb_cairo__inspect (target_or_index));
          target = cairo_tee_surface_index (surface, NUM2INT (index));
        }
      cairo_tee_surface_remove (surface, target);
      rb_cairo_surface_check_status (surface);

      rb_surfaces = rb_iv_get (self, "surfaces");
      for (i = 0; i < RARRAY_LEN (rb_surfaces); i++)
        {
          VALUE rb_marked_surface;
          cairo_surface_t *marked_surface;

          rb_marked_surface = RARRAY_PTR (rb_surfaces)[i];
          marked_surface = RVAL2CRSURFACE (rb_marked_surface);
          if (marked_surface == target)
            {
              rb_ary_delete (rb_surfaces, rb_marked_surface);
              break;
            }
        }

      return Qnil;
    }