Ejemplo n.º 1
0
int
cogl_primitive_get_n_vertices (CoglPrimitive *primitive)
{
  _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);

  return primitive->n_vertices;
}
Ejemplo n.º 2
0
CoglVerticesMode
cogl_primitive_get_mode (CoglPrimitive *primitive)
{
  _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);

  return primitive->mode;
}
Ejemplo n.º 3
0
int
cogl_primitive_get_first_vertex (CoglPrimitive *primitive)
{
  _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0);

  return primitive->first_vertex;
}
Ejemplo n.º 4
0
void
cogl_primitive_set_n_vertices (CoglPrimitive *primitive,
                               int n_vertices)
{
  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));

  primitive->n_vertices = n_vertices;
}
Ejemplo n.º 5
0
void
cogl_primitive_set_attributes (CoglPrimitive *primitive,
                               CoglAttribute **attributes,
                               int n_attributes)
{
  int i;

  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));

  if (G_UNLIKELY (primitive->immutable_ref))
    {
      warn_about_midscene_changes ();
      return;
    }

  /* NB: we don't unref the previous attributes before refing the new
   * in case we would end up releasing the last reference for an
   * attribute thats actually in the new list too. */
  for (i = 0; i < n_attributes; i++)
    {
      _COGL_RETURN_IF_FAIL (cogl_is_attribute (attributes[i]));
      cogl_object_ref (attributes[i]);
    }

  for (i = 0; i < primitive->n_attributes; i++)
    cogl_object_unref (primitive->attributes[i]);

  /* First try to use the embedded storage assocated with the
   * primitive, else fallback to slice allocating separate storage for
   * the attribute pointers... */

  if (n_attributes <= primitive->n_embedded_attributes)
    {
      if (primitive->attributes != &primitive->embedded_attribute)
        g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes,
                       primitive->attributes);
      primitive->attributes = &primitive->embedded_attribute;
    }
  else
    {
      if (primitive->attributes != &primitive->embedded_attribute)
        g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes,
                       primitive->attributes);
      primitive->attributes =
        g_slice_alloc (sizeof (CoglAttribute *) * n_attributes);
    }

  memcpy (primitive->attributes, attributes,
          sizeof (CoglAttribute *) * n_attributes);

  primitive->n_attributes = n_attributes;
}
Ejemplo n.º 6
0
void
_cogl_primitive_immutable_unref (CoglPrimitive *primitive)
{
  int i;

  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
  _COGL_RETURN_IF_FAIL (primitive->immutable_ref > 0);

  primitive->immutable_ref--;

  for (i = 0; i < primitive->n_attributes; i++)
    _cogl_attribute_immutable_unref (primitive->attributes[i]);
}
Ejemplo n.º 7
0
CoglPrimitive *
_cogl_primitive_immutable_ref (CoglPrimitive *primitive)
{
  int i;

  _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), NULL);

  primitive->immutable_ref++;

  for (i = 0; i < primitive->n_attributes; i++)
    _cogl_attribute_immutable_ref (primitive->attributes[i]);

  return primitive;
}
Ejemplo n.º 8
0
void
cogl_primitive_set_mode (CoglPrimitive *primitive,
                         CoglVerticesMode mode)
{
  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));

  if (G_UNLIKELY (primitive->immutable_ref))
    {
      warn_about_midscene_changes ();
      return;
    }

  primitive->mode = mode;
}
Ejemplo n.º 9
0
void
cogl_primitive_set_first_vertex (CoglPrimitive *primitive,
                                 int first_vertex)
{
  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));

  if (G_UNLIKELY (primitive->immutable_ref))
    {
      warn_about_midscene_changes ();
      return;
    }

  primitive->first_vertex = first_vertex;
}
Ejemplo n.º 10
0
/**
 * clutter_paint_node_add_primitive:
 * @node: a #ClutterPaintNode
 * @primitive: a Cogl primitive
 *
 * Adds a region described by a Cogl primitive to the @node.
 *
 * This function acquires a reference on @primitive, so it is safe
 * to call cogl_object_unref() when it returns.
 *
 *
 */
void
clutter_paint_node_add_primitive (ClutterPaintNode *node,
                                  CoglPrimitive    *primitive)
{
  ClutterPaintOperation operation = PAINT_OP_INIT;

  g_return_if_fail (CLUTTER_IS_PAINT_NODE (node));
  g_return_if_fail (cogl_is_primitive (primitive));

  clutter_paint_node_maybe_init_operations (node);

  clutter_paint_op_init_primitive (&operation, primitive);
  g_array_append_val (node->operations, operation);
}
Ejemplo n.º 11
0
void
cogl_primitive_set_indices (CoglPrimitive *primitive,
                            CoglIndices *indices,
                            int n_indices)
{
  _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));

  if (G_UNLIKELY (primitive->immutable_ref))
    {
      warn_about_midscene_changes ();
      return;
    }

  if (indices)
    cogl_object_ref (indices);
  if (primitive->indices)
    cogl_object_unref (primitive->indices);
  primitive->indices = indices;
  primitive->n_vertices = n_indices;
}