Esempio n. 1
0
void
rig_pb_stream_set_tcp_transport(rig_pb_stream_t *stream,
                                const char *hostname,
                                const char *port)
{
    uv_loop_t *loop = rut_uv_shell_get_loop(stream->shell);
    struct addrinfo hints;

    c_return_if_fail(stream->type == STREAM_TYPE_DISCONNECTED);
    c_return_if_fail(stream->hostname == NULL);
    c_return_if_fail(stream->port == NULL);
    c_return_if_fail(stream->resolving == false);

    hints.ai_family = PF_INET;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;
    hints.ai_flags = 0;

    stream->hostname = c_strdup(hostname);
    stream->port = c_strdup(port);

    rut_object_ref(stream); /* keep alive during resolve request */
    stream->resolving = true;
    uv_getaddrinfo(loop, &stream->resolver, on_address_resolved,
                   hostname, port, &hints);
}
Esempio n. 2
0
void
rut_mesh_set_indices(rut_mesh_t *mesh,
                     cg_indices_type_t type,
                     rut_buffer_t *buffer,
                     int n_indices)
{
    mesh->indices_buffer = rut_object_ref(buffer);
    mesh->indices_type = type;
    mesh->n_indices = n_indices;
}
Esempio n. 3
0
static void
objects_selection_event_cb(rig_objects_selection_t *selection,
                           rig_objects_selection_event_t event,
                           rut_object_t *object,
                           void *user_data)
{
    rig_selection_tool_t *tool = user_data;
    entity_state_t *entity_state;
    c_llist_t *l;

    if (!tool->active && event == RIG_OBJECTS_SELECTION_ADD_EVENT)
        return;

    if (rut_object_get_type(object) != &rig_entity_type)
        return;

    for (l = tool->selected_entities; l; l = l->next) {
        entity_state = l->data;
        if (entity_state->entity == object)
            break;
    }
    if (l == NULL)
        entity_state = NULL;

    switch (event) {
    case RIG_OBJECTS_SELECTION_ADD_EVENT: {
        c_return_if_fail(entity_state == NULL);

        entity_state = c_slice_new0(entity_state_t);
        entity_state->tool = tool;
        entity_state->entity = rut_object_ref(object);
        entity_state->control_points = NULL;

        tool->selected_entities =
            c_llist_prepend(tool->selected_entities, entity_state);

        entity_state->sizeable = find_sizeable_component(entity_state->entity);
        if (entity_state->sizeable)
            create_sizeable_control_points(entity_state);
        else
            create_dummy_control_points(entity_state);

        break;
    }

    case RIG_OBJECTS_SELECTION_REMOVE_EVENT:
        c_return_if_fail(entity_state != NULL);

        tool->selected_entities =
            c_llist_remove(tool->selected_entities, entity_state);
        entity_state_destroy(entity_state);
        break;
    }
}
Esempio n. 4
0
void
rut_mesh_set_attributes(rut_mesh_t *mesh,
                        rut_attribute_t **attributes,
                        int n_attributes)
{
    rut_attribute_t **attributes_real = attributes ?
        c_slice_copy(sizeof(void *) * n_attributes, attributes) : NULL;
    int i;

    /* NB: some of the given attributes may be the same as
     * some of the current attributes so we ref before
     * unrefing to avoid destroying any of them. */
    for (i = 0; i < n_attributes; i++)
        rut_object_ref(attributes[i]);

    for (i = 0; i < mesh->n_attributes; i++)
        rut_object_unref(mesh->attributes[i]);

    mesh->attributes = attributes_real;
    mesh->n_attributes = n_attributes;
}
Esempio n. 5
0
rut_attribute_t *
rut_attribute_new(rut_buffer_t *buffer,
                  const char *name,
                  size_t stride,
                  size_t offset,
                  int n_components,
                  rut_attribute_type_t type)
{
    rut_attribute_t *attribute = rut_object_alloc0(
        rut_attribute_t, &rut_attribute_type, _rut_attribute_init_type);

    attribute->name = c_strdup(name);
    attribute->is_buffered = true;
    attribute->buffered.buffer = rut_object_ref(buffer);
    attribute->buffered.stride = stride;
    attribute->buffered.offset = offset;
    attribute->buffered.n_components = n_components;
    attribute->buffered.type = type;

    return attribute;
}