Rename CoglVertexArray to CoglAttributeBuffer

This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to have a strongly implied relationship
between CoglAttributes and CoglAttributeBuffers.
This commit is contained in:
Robert Bragg 2011-03-02 15:01:41 +00:00
parent 2da24ab863
commit ce7c06dc03
20 changed files with 235 additions and 229 deletions

View File

@ -77,7 +77,7 @@ cogl_public_h = \
$(srcdir)/cogl-types.h \
$(srcdir)/cogl-vertex-buffer.h \
$(srcdir)/cogl-index-array.h \
$(srcdir)/cogl-vertex-array.h \
$(srcdir)/cogl-attribute-buffer.h \
$(srcdir)/cogl-indices.h \
$(srcdir)/cogl-attribute.h \
$(srcdir)/cogl-primitive.h \
@ -222,8 +222,8 @@ cogl_sources_c = \
$(srcdir)/cogl-vertex-buffer.c \
$(srcdir)/cogl-index-array-private.h \
$(srcdir)/cogl-index-array.c \
$(srcdir)/cogl-vertex-array-private.h \
$(srcdir)/cogl-vertex-array.c \
$(srcdir)/cogl-attribute-buffer-private.h \
$(srcdir)/cogl-attribute-buffer.c \
$(srcdir)/cogl-indices-private.h \
$(srcdir)/cogl-indices.c \
$(srcdir)/cogl-attribute-private.h \

View File

@ -25,15 +25,14 @@
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef __COGL_VERTEX_ARRAY_PRIVATE_H
#define __COGL_VERTEX_ARRAY_PRIVATE_H
#ifndef __COGL_ATTRIBUTE_BUFFER_PRIVATE_H
#define __COGL_ATTRIBUTE_BUFFER_PRIVATE_H
#include "cogl-buffer-private.h"
struct _CoglVertexArray
struct _CoglAttributeBuffer
{
CoglBuffer _parent;
};
#endif /* __COGL_VERTEX_ARRAY_PRIVATE_H */
#endif /* __COGL_ATTRIBUTE_BUFFER_PRIVATE_H */

View File

@ -30,17 +30,17 @@
#endif
#include "cogl-object-private.h"
#include "cogl-vertex-array.h"
#include "cogl-vertex-array-private.h"
#include "cogl-attribute-buffer.h"
#include "cogl-attribute-buffer-private.h"
static void _cogl_vertex_array_free (CoglVertexArray *array);
static void _cogl_attribute_buffer_free (CoglAttributeBuffer *array);
COGL_BUFFER_DEFINE (VertexArray, vertex_array);
COGL_BUFFER_DEFINE (AttributeBuffer, attribute_buffer);
CoglVertexArray *
cogl_vertex_array_new (gsize bytes, const void *data)
CoglAttributeBuffer *
cogl_attribute_buffer_new (gsize bytes, const void *data)
{
CoglVertexArray *array = g_slice_new (CoglVertexArray);
CoglAttributeBuffer *array = g_slice_new (CoglAttributeBuffer);
gboolean use_malloc;
if (!cogl_features_available (COGL_FEATURE_VBOS))
@ -52,11 +52,11 @@ cogl_vertex_array_new (gsize bytes, const void *data)
_cogl_buffer_initialize (COGL_BUFFER (array),
bytes,
use_malloc,
COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY,
COGL_BUFFER_USAGE_HINT_VERTEX_ARRAY,
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
COGL_BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
COGL_BUFFER_UPDATE_HINT_STATIC);
_cogl_vertex_array_object_new (array);
_cogl_attribute_buffer_object_new (array);
if (data)
cogl_buffer_set_data (COGL_BUFFER (array),
@ -67,11 +67,11 @@ cogl_vertex_array_new (gsize bytes, const void *data)
}
static void
_cogl_vertex_array_free (CoglVertexArray *array)
_cogl_attribute_buffer_free (CoglAttributeBuffer *array)
{
/* parent's destructor */
_cogl_buffer_fini (COGL_BUFFER (array));
g_slice_free (CoglVertexArray, array);
g_slice_free (CoglAttributeBuffer, array);
}

View File

@ -28,26 +28,27 @@
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_VERTEX_ARRAY_H__
#define __COGL_VERTEX_ARRAY_H__
#ifndef __COGL_ATTRIBUTE_BUFFER_H__
#define __COGL_ATTRIBUTE_BUFFER_H__
G_BEGIN_DECLS
/**
* SECTION:cogl-vertex-array
* @short_description: Functions for creating and manipulating vertex arrays
* SECTION:cogl-attribute-buffer
* @short_description: Functions for creating and manipulating attribute
* buffers
*
* FIXME
*/
typedef struct _CoglVertexArray CoglVertexArray;
typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
/**
* cogl_vertex_array_new:
* cogl_attribute_buffer_new:
* @bytes: The number of bytes to allocate for vertex attribute data.
* @data: An optional pointer to vertex data to upload immediately.
*
* Declares a new #CoglVertexArray of @size bytes to contain arrays of vertex
* Declares a new #CoglAttributeBuffer of @size bytes to contain arrays of vertex
* attribute data. Once declared, data can be set using cogl_buffer_set_data()
* or by mapping it into the application's address space using cogl_buffer_map().
*
@ -57,26 +58,25 @@ typedef struct _CoglVertexArray CoglVertexArray;
* Since: 1.4
* Stability: Unstable
*/
CoglVertexArray *
cogl_vertex_array_new (gsize bytes,
const void *data);
CoglAttributeBuffer *
cogl_attribute_buffer_new (gsize bytes, const void *data);
/**
* cogl_is_vertex_array:
* cogl_is_attribute_buffer:
* @object: A #CoglObject
*
* Gets whether the given object references a #CoglVertexArray.
* Gets whether the given object references a #CoglAttributeBuffer.
*
* Returns: %TRUE if the handle references a #CoglVertexArray,
* Returns: %TRUE if the handle references a #CoglAttributeBuffer,
* %FALSE otherwise
*
* Since: 1.4
* Stability: Unstable
*/
gboolean
cogl_is_vertex_array (void *object);
cogl_is_attribute_buffer (void *object);
G_END_DECLS
#endif /* __COGL_VERTEX_ARRAY_H__ */
#endif /* __COGL_ATTRIBUTE_BUFFER_H__ */

View File

@ -44,7 +44,7 @@ struct _CoglAttribute
{
CoglObject _parent;
CoglVertexArray *array;
CoglAttributeBuffer *attribute_buffer;
char *name;
CoglAttributeNameID name_id;
gsize stride;

View File

@ -231,7 +231,7 @@ validate_cogl_attribute (const char *name,
}
CoglAttribute *
cogl_attribute_new (CoglVertexArray *array,
cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
const char *name,
gsize stride,
gsize offset,
@ -241,7 +241,7 @@ cogl_attribute_new (CoglVertexArray *array,
CoglAttribute *attribute = g_slice_new (CoglAttribute);
gboolean status;
attribute->array = cogl_object_ref (array);
attribute->attribute_buffer = cogl_object_ref (attribute_buffer);
attribute->name = g_strdup (name);
attribute->stride = stride;
attribute->offset = offset;
@ -312,27 +312,27 @@ cogl_attribute_set_normalized (CoglAttribute *attribute,
attribute->normalized = normalized;
}
CoglVertexArray *
cogl_attribute_get_array (CoglAttribute *attribute)
CoglAttributeBuffer *
cogl_attribute_get_buffer (CoglAttribute *attribute)
{
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
return attribute->array;
return attribute->attribute_buffer;
}
void
cogl_attribute_set_array (CoglAttribute *attribute,
CoglVertexArray *array)
CoglAttributeBuffer *attribute_buffer)
{
g_return_if_fail (cogl_is_attribute (attribute));
if (G_UNLIKELY (attribute->immutable_ref))
warn_about_midscene_changes ();
cogl_object_ref (array);
cogl_object_ref (attribute_buffer);
cogl_object_unref (attribute->array);
attribute->array = array;
cogl_object_unref (attribute->attribute_buffer);
attribute->attribute_buffer = attribute_buffer;
}
CoglAttribute *
@ -341,7 +341,7 @@ _cogl_attribute_immutable_ref (CoglAttribute *attribute)
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
attribute->immutable_ref++;
_cogl_buffer_immutable_ref (COGL_BUFFER (attribute->array));
_cogl_buffer_immutable_ref (COGL_BUFFER (attribute->attribute_buffer));
return attribute;
}
@ -352,14 +352,14 @@ _cogl_attribute_immutable_unref (CoglAttribute *attribute)
g_return_if_fail (attribute->immutable_ref > 0);
attribute->immutable_ref--;
_cogl_buffer_immutable_unref (COGL_BUFFER (attribute->array));
_cogl_buffer_immutable_unref (COGL_BUFFER (attribute->attribute_buffer));
}
static void
_cogl_attribute_free (CoglAttribute *attribute)
{
g_free (attribute->name);
cogl_object_unref (attribute->array);
cogl_object_unref (attribute->attribute_buffer);
g_slice_free (CoglAttribute, attribute);
}
@ -598,16 +598,16 @@ enable_gl_state (CoglDrawFlags flags,
for (i = 0; attributes[i]; i++)
{
CoglAttribute *attribute = attributes[i];
CoglVertexArray *vertex_array;
CoglAttributeBuffer *attribute_buffer;
CoglBuffer *buffer;
guint8 *base;
#ifdef HAVE_COGL_GLES2
int attrib_location;
#endif
vertex_array = cogl_attribute_get_array (attribute);
buffer = COGL_BUFFER (vertex_array);
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY);
attribute_buffer = cogl_attribute_get_buffer (attribute);
buffer = COGL_BUFFER (attribute_buffer);
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
switch (attribute->name_id)
{
@ -875,7 +875,7 @@ get_wire_lines (CoglAttribute *attribute,
int *n_vertices_out,
CoglIndices *_indices)
{
CoglVertexArray *vertex_array = cogl_attribute_get_array (attribute);
CoglAttributeBuffer *attribute_buffer = cogl_attribute_get_buffer (attribute);
void *vertices;
CoglIndexArray *index_array;
void *indices;
@ -884,7 +884,7 @@ get_wire_lines (CoglAttribute *attribute,
int n_lines;
CoglVertexP3 *out = NULL;
vertices = cogl_buffer_map (COGL_BUFFER (vertex_array),
vertices = cogl_buffer_map (COGL_BUFFER (attribute_buffer),
COGL_BUFFER_ACCESS_READ, 0);
if (_indices)
{
@ -982,7 +982,7 @@ get_wire_lines (CoglAttribute *attribute,
#endif
if (vertices != NULL)
cogl_buffer_unmap (COGL_BUFFER (vertex_array));
cogl_buffer_unmap (COGL_BUFFER (attribute_buffer));
if (indices != NULL)
cogl_buffer_unmap (COGL_BUFFER (index_array));
@ -1003,7 +1003,7 @@ draw_wireframe (CoglVerticesMode mode,
static CoglPipeline *wire_pipeline;
CoglAttribute *wire_attribute[2];
CoglVertexP3 *lines;
CoglVertexArray *array;
CoglAttributeBuffer *attribute_buffer;
for (i = 0; attributes[i]; i++)
{
@ -1021,16 +1021,17 @@ draw_wireframe (CoglVerticesMode mode,
n_vertices,
&n_line_vertices,
indices);
array = cogl_vertex_array_new (sizeof (CoglVertexP3) * n_line_vertices,
attribute_buffer =
cogl_attribute_buffer_new (sizeof (CoglVertexP3) * n_line_vertices,
lines);
wire_attribute[0] =
cogl_attribute_new (array, "cogl_position_in",
cogl_attribute_new (attribute_buffer, "cogl_position_in",
sizeof (CoglVertexP3),
0,
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
wire_attribute[1] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
if (!wire_pipeline)
{

View File

@ -31,7 +31,7 @@
#ifndef __COGL_ATTRIBUTE_H__
#define __COGL_ATTRIBUTE_H__
#include <cogl/cogl-vertex-array.h>
#include <cogl/cogl-attribute-buffer.h>
#include <cogl/cogl-indices.h>
G_BEGIN_DECLS
@ -48,13 +48,14 @@ typedef struct _CoglAttribute CoglAttribute;
/**
* cogl_attribute_new:
* @array: The #CoglVertexArray containing the actual attribute data
* @attribute_buffer: The #CoglAttributeBuffer containing the actual
* attribute data
* @name: The name of the attribute (used to reference it from GLSL)
* @stride: The number of bytes to jump to get to the next attribute
* value for the next vertex. (Usually
* <pre>sizeof (MyVertex)</pre>)
* @offset: The byte offset from the start of @array for the first
* attribute value. (Usually
* @offset: The byte offset from the start of @attribute_buffer for
* the first attribute value. (Usually
* <pre>offsetof (MyVertex, component0)</pre>
* @components: The number of components (e.g. 4 for an rgba color or
* 3 for and (x,y,z) position)
@ -131,7 +132,7 @@ typedef struct _CoglAttribute CoglAttribute;
/* XXX: look for a precedent to see if the stride/offset args should
* have a different order. */
CoglAttribute *
cogl_attribute_new (CoglVertexArray *array,
cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
const char *name,
gsize stride,
gsize offset,

View File

@ -64,14 +64,14 @@ typedef enum _CoglBufferFlags
typedef enum {
COGL_BUFFER_USAGE_HINT_TEXTURE,
COGL_BUFFER_USAGE_HINT_VERTEX_ARRAY,
COGL_BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
COGL_BUFFER_USAGE_HINT_INDEX_ARRAY
} CoglBufferUsageHint;
typedef enum {
COGL_BUFFER_BIND_TARGET_PIXEL_PACK,
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK,
COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY,
COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
COGL_BUFFER_BIND_TARGET_INDEX_ARRAY,
COGL_BUFFER_BIND_TARGET_COUNT

View File

@ -128,7 +128,7 @@ convert_bind_target_to_gl_target (CoglBufferBindTarget target)
return GL_PIXEL_PACK_BUFFER;
case COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK:
return GL_PIXEL_UNPACK_BUFFER;
case COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY:
case COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER:
return GL_ARRAY_BUFFER;
case COGL_BUFFER_BIND_TARGET_INDEX_ARRAY:
return GL_ELEMENT_ARRAY_BUFFER;

View File

@ -98,13 +98,14 @@ cogl_index_array_allocate (CoglIndexArray *indices,
*
* XXX: The double plurel form that "Indices" "Array" implies could be
* a bit confusing. Also to be a bit more consistent with
* CoglVertexArray vs CoglAttribute it might be best to rename so
* CoglAttributeBuffer vs CoglAttribute it might be best to rename so
* we have CoglIndexArray vs CoglIndices? maybe even
* CoglIndexRange :-/ ?
*
* CoglBuffer
* CoglVertexArray (buffer sub-class)
* CoglPrimitive (defines meta data for sub-region of array)
* CoglAttributeBuffer (buffer sub-class)
* CoglAttribute (defines meta data for sub-region of buffer)
* CoglPrimitive (object encapsulating a set of attributes)
* CoglPixelArray (buffer sub-class)
* CoglIndexArray (buffer sub-class)
* CoglIndices (defines meta data for sub-region of array)

View File

@ -95,7 +95,7 @@ typedef struct _CoglJournalFlushState
{
CoglJournal *journal;
CoglVertexArray *vertex_array;
CoglAttributeBuffer *attribute_buffer;
GArray *attributes;
int current_attribute;
@ -518,7 +518,7 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries (
/* XXX: it may be worth having some form of static initializer for
* attributes... */
*attribute_entry =
cogl_attribute_new (state->vertex_array,
cogl_attribute_new (state->attribute_buffer,
name,
state->stride,
state->array_offset +
@ -593,7 +593,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
g_array_set_size (state->attributes, 2);
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 0);
*attribute_entry = cogl_attribute_new (state->vertex_array,
*attribute_entry = cogl_attribute_new (state->attribute_buffer,
"cogl_position_in",
stride,
state->array_offset,
@ -602,7 +602,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 1);
*attribute_entry =
cogl_attribute_new (state->vertex_array,
cogl_attribute_new (state->attribute_buffer,
"cogl_color_in",
stride,
state->array_offset + (POS_STRIDE * 4),
@ -614,9 +614,9 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
#endif
/* We only create new Attributes when the stride within the
* VertexArray changes. (due to a change in the number of pipeline
* AttributeBuffer changes. (due to a change in the number of pipeline
* layers) While the stride remains constant we walk forward through
* the above VertexArray using a vertex offset passed to
* the above AttributeBuffer using a vertex offset passed to
* cogl_draw_attributes
*/
state->current_vertex = 0;
@ -628,7 +628,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
/* Mapping a buffer for read is probably a really bad thing to
do but this will only happen during debugging so it probably
doesn't matter */
verts = ((guint8 *) cogl_buffer_map (COGL_BUFFER (state->vertex_array),
verts = ((guint8 *)cogl_buffer_map (COGL_BUFFER (state->attribute_buffer),
COGL_BUFFER_ACCESS_READ, 0) +
state->array_offset);
@ -636,7 +636,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
batch_start->n_layers,
batch_len);
cogl_buffer_unmap (COGL_BUFFER (state->vertex_array));
cogl_buffer_unmap (COGL_BUFFER (state->attribute_buffer));
}
batch_and_call (batch_start,
@ -1092,13 +1092,13 @@ compare_entry_clip_stacks (CoglJournalEntry *entry0, CoglJournalEntry *entry1)
return entry0->clip_stack == entry1->clip_stack;
}
static CoglVertexArray *
static CoglAttributeBuffer *
upload_vertices (const CoglJournalEntry *entries,
int n_entries,
size_t needed_vbo_len,
GArray *vertices)
{
CoglVertexArray *array;
CoglAttributeBuffer *attribute_buffer;
CoglBuffer *buffer;
const float *vin;
float *vout;
@ -1107,8 +1107,8 @@ upload_vertices (const CoglJournalEntry *entries,
g_assert (needed_vbo_len);
array = cogl_vertex_array_new (needed_vbo_len * 4, NULL);
buffer = COGL_BUFFER (array);
attribute_buffer = cogl_attribute_buffer_new (needed_vbo_len * 4, NULL);
buffer = COGL_BUFFER (attribute_buffer);
cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_STATIC);
vout = _cogl_buffer_map_for_fill_or_fallback (buffer);
@ -1182,7 +1182,7 @@ upload_vertices (const CoglJournalEntry *entries,
_cogl_buffer_unmap_for_fill_or_fallback (buffer);
return array;
return attribute_buffer;
}
void
@ -1340,7 +1340,7 @@ _cogl_journal_flush (CoglJournal *journal,
/* We upload the vertices after the clip stack pass in case it
modifies the entries */
state.vertex_array = upload_vertices (&g_array_index (journal->entries,
state.attribute_buffer = upload_vertices (&g_array_index (journal->entries,
CoglJournalEntry, 0),
journal->entries->len,
journal->needed_vbo_len,
@ -1380,7 +1380,7 @@ _cogl_journal_flush (CoglJournal *journal,
cogl_object_unref (g_array_index (state.attributes, CoglAttribute *, i));
g_array_set_size (state.attributes, 0);
cogl_object_unref (state.vertex_array);
cogl_object_unref (state.attribute_buffer);
_cogl_journal_discard (journal);

View File

@ -79,14 +79,14 @@ struct _CoglPathData
floatVec2 path_nodes_min;
floatVec2 path_nodes_max;
CoglVertexArray *fill_vbo;
CoglAttributeBuffer *fill_attribute_buffer;
CoglIndices *fill_vbo_indices;
unsigned int fill_vbo_n_indices;
CoglAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1];
CoglAttribute *fill_attributes[COGL_PATH_N_ATTRIBUTES + 1];
CoglVertexArray *stroke_vbo;
CoglAttribute **stroke_vbo_attributes;
unsigned int stroke_vbo_n_attributes;
CoglAttributeBuffer *stroke_attribute_buffer;
CoglAttribute **stroke_attributes;
unsigned int stroke_n_attributes;
/* This is used as an optimisation for when the path contains a
single contour specified using cogl2_path_rectangle. Cogl is more

View File

@ -29,7 +29,7 @@
#define __COGL_PRIMITIVE_PRIVATE_H
#include "cogl-object-private.h"
#include "cogl-vertex-array-private.h"
#include "cogl-attribute-buffer-private.h"
struct _CoglPrimitive
{

View File

@ -124,11 +124,11 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP2 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2), data);
CoglAttribute *attributes[2];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP2),
offsetof (CoglVertexP2, x),
@ -136,7 +136,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -147,11 +147,11 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP3 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3), data);
CoglAttribute *attributes[2];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP3),
offsetof (CoglVertexP3, x),
@ -159,7 +159,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -170,17 +170,17 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP2C4 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2C4), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2C4), data);
CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP2C4),
offsetof (CoglVertexP2C4, x),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_color_in",
sizeof (CoglVertexP2C4),
offsetof (CoglVertexP2C4, r),
@ -188,7 +188,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[2] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -199,17 +199,17 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP3C4 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3C4), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3C4), data);
CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP3C4),
offsetof (CoglVertexP3C4, x),
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_color_in",
sizeof (CoglVertexP3C4),
offsetof (CoglVertexP3C4, r),
@ -217,7 +217,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[2] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -228,17 +228,17 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP2T2 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2), data);
CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP2T2),
offsetof (CoglVertexP2T2, x),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in",
sizeof (CoglVertexP2T2),
offsetof (CoglVertexP2T2, s),
@ -246,7 +246,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -257,17 +257,17 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP3T2 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2), data);
CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP3T2),
offsetof (CoglVertexP3T2, x),
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in",
sizeof (CoglVertexP3T2),
offsetof (CoglVertexP3T2, s),
@ -275,7 +275,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -286,23 +286,23 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP2T2C4 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
CoglAttribute *attributes[4];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, x),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in",
sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, s),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = cogl_attribute_new (array,
attributes[2] = cogl_attribute_new (attribute_buffer,
"cogl_color_in",
sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, r),
@ -310,7 +310,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[3] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);
@ -321,23 +321,23 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
int n_vertices,
const CoglVertexP3T2C4 *data)
{
CoglVertexArray *array =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
CoglAttribute *attributes[4];
attributes[0] = cogl_attribute_new (array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, x),
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array,
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in",
sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, s),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = cogl_attribute_new (array,
attributes[2] = cogl_attribute_new (attribute_buffer,
"cogl_color_in",
sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, r),
@ -345,7 +345,7 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[3] = NULL;
cogl_object_unref (array);
cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes);

View File

@ -245,7 +245,7 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position
* necessary #CoglAttributeBuffer storage, describe the position
* attribute with a #CoglAttribute and upload your data.
*
* For example to draw a convex polygon you can do:
@ -289,7 +289,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position
* necessary #CoglAttributeBuffer storage, describe the position
* attribute with a #CoglAttribute and upload your data.
*
* For example to draw a convex polygon you can do:
@ -333,7 +333,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position
* necessary #CoglAttributeBuffer storage, describe the position
* and color attributes with #CoglAttribute<!-- -->s and upload
* your data.
*
@ -379,7 +379,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position
* necessary #CoglAttributeBuffer storage, describe the position
* and color attributes with #CoglAttribute<!-- -->s and upload
* your data.
*
@ -425,7 +425,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position and
* necessary #CoglAttributeBuffer storage, describe the position and
* texture coordinate attributes with #CoglAttribute<!-- -->s and
* upload your data.
*
@ -471,7 +471,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position and
* necessary #CoglAttributeBuffer storage, describe the position and
* texture coordinate attributes with #CoglAttribute<!-- -->s and
* upload your data.
*
@ -517,7 +517,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position, texture
* necessary #CoglAttributeBuffer storage, describe the position, texture
* coordinate and color attributes with #CoglAttribute<!-- -->s and
* upload your data.
*
@ -563,7 +563,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
*
* Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position, texture
* necessary #CoglAttributeBuffer storage, describe the position, texture
* coordinate and color attributes with #CoglAttribute<!-- -->s and
* upload your data.
*

View File

@ -933,11 +933,11 @@ _cogl_rectangle_immediate (float x_1,
x_2, y_1,
x_2, y_2
};
CoglVertexArray *vertex_array;
CoglAttributeBuffer *attribute_buffer;
CoglAttribute *attributes[2];
vertex_array = cogl_vertex_array_new (sizeof (vertices), vertices);
attributes[0] = cogl_attribute_new (vertex_array,
attribute_buffer = cogl_attribute_buffer_new (sizeof (vertices), vertices);
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (float) * 2, /* stride */
0, /* offset */
@ -955,7 +955,7 @@ _cogl_rectangle_immediate (float x_1,
cogl_object_unref (attributes[0]);
cogl_object_unref (vertex_array);
cogl_object_unref (attribute_buffer);
}
typedef struct _AppendTexCoordsState
@ -1050,7 +1050,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
int i;
unsigned int stride;
gsize stride_bytes;
CoglVertexArray *vertex_array;
CoglAttributeBuffer *attribute_buffer;
float *v;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -1080,9 +1080,10 @@ cogl_polygon (const CoglTextureVertex *vertices,
* but still support any number of vertices */
g_array_set_size (ctx->polygon_vertices, n_vertices * stride);
vertex_array = cogl_vertex_array_new (n_vertices * stride_bytes, NULL);
attribute_buffer =
cogl_attribute_buffer_new (n_vertices * stride_bytes, NULL);
attributes[0] = cogl_attribute_new (vertex_array,
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
stride_bytes,
0,
@ -1104,7 +1105,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
char *name = i < 8 ? (char *)names[i] :
g_strdup_printf ("cogl_tex_coord%d_in", i);
attributes[i + 1] = cogl_attribute_new (vertex_array,
attributes[i + 1] = cogl_attribute_new (attribute_buffer,
name,
stride_bytes,
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
@ -1116,7 +1117,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
if (use_color)
{
attributes[n_attributes - 1] =
cogl_attribute_new (vertex_array,
cogl_attribute_new (attribute_buffer,
"cogl_color_in",
stride_bytes,
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
@ -1159,7 +1160,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
}
v = (float *)ctx->polygon_vertices->data;
cogl_buffer_set_data (COGL_BUFFER (vertex_array),
cogl_buffer_set_data (COGL_BUFFER (attribute_buffer),
0,
v,
ctx->polygon_vertices->len * sizeof (float));

View File

@ -124,8 +124,8 @@ typedef struct _CoglVertexBufferVBO
{
CoglVertexBufferVBOFlags flags;
CoglVertexArray *array;
size_t array_bytes;
CoglAttributeBuffer *attribute_buffer;
size_t buffer_bytes;
GList *attributes;
} CoglVertexBufferVBO;

View File

@ -833,8 +833,8 @@ filter_strided_attribute (CoglVertexBufferAttrib *attribute,
new_cogl_vbo->attributes =
g_list_prepend (new_cogl_vbo->attributes, attribute);
/* Any one of the interleved attributes will have the same span_bytes */
new_cogl_vbo->array = NULL;
new_cogl_vbo->array_bytes = attribute->span_bytes;
new_cogl_vbo->attribute_buffer = NULL;
new_cogl_vbo->buffer_bytes = attribute->span_bytes;
new_cogl_vbo->flags = COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED;
if (attribute->flags & COGL_VERTEX_BUFFER_ATTRIB_FLAG_INFREQUENT_RESUBMIT)
@ -942,7 +942,7 @@ cogl_vertex_buffer_vbo_free (CoglVertexBufferVBO *cogl_vbo)
g_list_free (cogl_vbo->attributes);
if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_SUBMITTED)
cogl_object_unref (cogl_vbo->array);
cogl_object_unref (cogl_vbo->attribute_buffer);
g_slice_free (CoglVertexBufferVBO, cogl_vbo);
}
@ -988,7 +988,7 @@ upload_multipack_vbo_via_map_buffer (CoglVertexBufferVBO *cogl_vbo)
_COGL_GET_CONTEXT (ctx, FALSE);
buf = cogl_buffer_map (COGL_BUFFER (cogl_vbo->array),
buf = cogl_buffer_map (COGL_BUFFER (cogl_vbo->attribute_buffer),
COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD);
if (!buf)
@ -1009,7 +1009,7 @@ upload_multipack_vbo_via_map_buffer (CoglVertexBufferVBO *cogl_vbo)
offset += attribute_size;
}
cogl_buffer_unmap (COGL_BUFFER (cogl_vbo->array));
cogl_buffer_unmap (COGL_BUFFER (cogl_vbo->attribute_buffer));
return TRUE;
}
@ -1028,7 +1028,7 @@ upload_multipack_vbo_via_buffer_sub_data (CoglVertexBufferVBO *cogl_vbo)
PAD_FOR_ALIGNMENT (offset, type_size);
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->array),
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->attribute_buffer),
offset,
attribute->u.pointer,
attribute_size);
@ -1050,15 +1050,15 @@ upload_attributes (CoglVertexBufferVBO *cogl_vbo)
usage = COGL_BUFFER_UPDATE_HINT_DYNAMIC;
else
usage = COGL_BUFFER_UPDATE_HINT_STATIC;
cogl_buffer_set_update_hint (COGL_BUFFER (cogl_vbo->array), usage);
cogl_buffer_set_update_hint (COGL_BUFFER (cogl_vbo->attribute_buffer), usage);
if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED)
{
const void *pointer = prep_strided_vbo_for_upload (cogl_vbo);
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->array),
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->attribute_buffer),
0, /* offset */
pointer,
cogl_vbo->array_bytes);
cogl_vbo->buffer_bytes);
}
else /* MULTIPACK */
{
@ -1107,10 +1107,11 @@ cogl_vertex_buffer_vbo_resolve (CoglVertexBuffer *buffer,
/* See if we can re-use this now empty VBO: */
if (!found_target_vbo
&& conflict_vbo->array_bytes == new_cogl_vbo->array_bytes)
&& conflict_vbo->buffer_bytes == new_cogl_vbo->buffer_bytes)
{
found_target_vbo = TRUE;
new_cogl_vbo->array = cogl_object_ref (conflict_vbo->array);
new_cogl_vbo->attribute_buffer =
cogl_object_ref (conflict_vbo->attribute_buffer);
cogl_vertex_buffer_vbo_free (conflict_vbo);
upload_attributes (new_cogl_vbo);
@ -1132,8 +1133,8 @@ cogl_vertex_buffer_vbo_resolve (CoglVertexBuffer *buffer,
if (!found_target_vbo)
{
new_cogl_vbo->array = cogl_vertex_array_new (new_cogl_vbo->array_bytes,
NULL);
new_cogl_vbo->attribute_buffer =
cogl_attribute_buffer_new (new_cogl_vbo->buffer_bytes, NULL);
upload_attributes (new_cogl_vbo);
*final_vbos = g_list_prepend (*final_vbos, new_cogl_vbo);
@ -1181,7 +1182,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
if (G_UNLIKELY (!attribute->attribute))
{
attribute->attribute =
cogl_attribute_new (cogl_vbo->array,
cogl_attribute_new (cogl_vbo->attribute_buffer,
attribute->name_without_detail,
attribute->stride,
attribute->u.vbo_offset,
@ -1346,8 +1347,8 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
*/
new_multipack_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO));
new_multipack_vbo->array = NULL;
new_multipack_vbo->array_bytes = 0;
new_multipack_vbo->attribute_buffer = NULL;
new_multipack_vbo->buffer_bytes = 0;
new_multipack_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK
| COGL_VERTEX_BUFFER_VBO_FLAG_INFREQUENT_RESUBMIT;
@ -1400,8 +1401,8 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
cogl_vbo->attributes = NULL;
cogl_vbo->attributes = g_list_prepend (cogl_vbo->attributes,
attribute);
cogl_vbo->array = NULL;
cogl_vbo->array_bytes = attribute->span_bytes;
cogl_vbo->attribute_buffer = NULL;
cogl_vbo->buffer_bytes = attribute->span_bytes;
new_vbos = g_list_prepend (new_vbos, cogl_vbo);
}
else
@ -1423,9 +1424,9 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
* is based on the adjacent attribute.
*/
PAD_FOR_ALIGNMENT (new_multipack_vbo->array_bytes, type_size);
PAD_FOR_ALIGNMENT (new_multipack_vbo->buffer_bytes, type_size);
new_multipack_vbo->array_bytes += attribute->span_bytes;
new_multipack_vbo->buffer_bytes += attribute->span_bytes;
}
}

View File

@ -81,7 +81,7 @@ typedef struct _CoglFramebuffer CoglFramebuffer;
#include <cogl/cogl-quaternion.h>
#include <cogl/cogl-texture-3d.h>
#include <cogl/cogl-index-array.h>
#include <cogl/cogl-vertex-array.h>
#include <cogl/cogl-attribute-buffer.h>
#include <cogl/cogl-indices.h>
#include <cogl/cogl-attribute.h>
#include <cogl/cogl-primitive.h>

View File

@ -52,8 +52,8 @@
static void _cogl_path_free (CoglPath *path);
static void _cogl_path_build_fill_vbo (CoglPath *path);
static void _cogl_path_build_stroke_vbo (CoglPath *path);
static void _cogl_path_build_fill_attribute_buffer (CoglPath *path);
static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path);
COGL_OBJECT_DEFINE (Path, path);
@ -62,27 +62,27 @@ _cogl_path_data_clear_vbos (CoglPathData *data)
{
int i;
if (data->fill_vbo)
if (data->fill_attribute_buffer)
{
cogl_object_unref (data->fill_vbo);
cogl_object_unref (data->fill_attribute_buffer);
cogl_object_unref (data->fill_vbo_indices);
for (i = 0; i < COGL_PATH_N_ATTRIBUTES; i++)
cogl_object_unref (data->fill_vbo_attributes[i]);
cogl_object_unref (data->fill_attributes[i]);
data->fill_vbo = NULL;
data->fill_attribute_buffer = NULL;
}
if (data->stroke_vbo)
if (data->stroke_attribute_buffer)
{
cogl_object_unref (data->stroke_vbo);
cogl_object_unref (data->stroke_attribute_buffer);
for (i = 0; i < data->stroke_vbo_n_attributes; i++)
cogl_object_unref (data->stroke_vbo_attributes[i]);
for (i = 0; i < data->stroke_n_attributes; i++)
cogl_object_unref (data->stroke_attributes[i]);
g_free (data->stroke_vbo_attributes);
g_free (data->stroke_attributes);
data->stroke_vbo = NULL;
data->stroke_attribute_buffer = NULL;
}
}
@ -118,13 +118,13 @@ _cogl_path_modify (CoglPath *path)
old_data->path_nodes->data,
old_data->path_nodes->len);
path->data->fill_vbo = COGL_INVALID_HANDLE;
path->data->fill_attribute_buffer = NULL;
path->data->ref_count = 1;
_cogl_path_data_unref (old_data);
}
/* The path is altered so the vbo will now be invalid */
else if (path->data->fill_vbo)
else if (path->data->fill_attribute_buffer)
_cogl_path_data_clear_vbos (path->data);
}
@ -228,7 +228,7 @@ _cogl_path_stroke_nodes (CoglPath *path)
source = copy;
}
_cogl_path_build_stroke_vbo (path);
_cogl_path_build_stroke_attribute_buffer (path);
cogl_push_source (source);
@ -240,7 +240,7 @@ _cogl_path_stroke_nodes (CoglPath *path)
cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP,
0, node->path_size,
data->stroke_vbo_attributes[path_num],
data->stroke_attributes[path_num],
NULL);
path_num++;
@ -341,14 +341,14 @@ _cogl_path_fill_nodes (CoglPath *path)
}
}
_cogl_path_build_fill_vbo (path);
_cogl_path_build_fill_attribute_buffer (path);
_cogl_draw_indexed_attributes_array
(COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
path->data->fill_vbo_n_indices,
path->data->fill_vbo_indices,
path->data->fill_vbo_attributes,
path->data->fill_attributes,
COGL_DRAW_SKIP_JOURNAL_FLUSH |
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
@ -1009,8 +1009,8 @@ cogl2_path_new (void)
data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD;
data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
data->last_path = 0;
data->fill_vbo = COGL_INVALID_HANDLE;
data->stroke_vbo = NULL;
data->fill_attribute_buffer = NULL;
data->stroke_attribute_buffer = NULL;
data->is_rectangle = FALSE;
return _cogl_path_object_new (path);
@ -1389,7 +1389,7 @@ _cogl_path_tesselator_combine (double coords[3],
}
static void
_cogl_path_build_fill_vbo (CoglPath *path)
_cogl_path_build_fill_attribute_buffer (CoglPath *path)
{
CoglPathTesselator tess;
unsigned int path_start = 0;
@ -1397,7 +1397,7 @@ _cogl_path_build_fill_vbo (CoglPath *path)
int i;
/* If we've already got a vbo then we don't need to do anything */
if (data->fill_vbo)
if (data->fill_attribute_buffer)
return;
tess.primitive_type = FALSE;
@ -1480,27 +1480,28 @@ _cogl_path_build_fill_vbo (CoglPath *path)
gluDeleteTess (tess.glu_tess);
data->fill_vbo = cogl_vertex_array_new (sizeof (CoglPathTesselatorVertex) *
data->fill_attribute_buffer =
cogl_attribute_buffer_new (sizeof (CoglPathTesselatorVertex) *
tess.vertices->len,
tess.vertices->data);
g_array_free (tess.vertices, TRUE);
data->fill_vbo_attributes[0] =
cogl_attribute_new (data->fill_vbo,
data->fill_attributes[0] =
cogl_attribute_new (data->fill_attribute_buffer,
"cogl_position_in",
sizeof (CoglPathTesselatorVertex),
G_STRUCT_OFFSET (CoglPathTesselatorVertex, x),
2, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT);
data->fill_vbo_attributes[1] =
cogl_attribute_new (data->fill_vbo,
data->fill_attributes[1] =
cogl_attribute_new (data->fill_attribute_buffer,
"cogl_tex_coord0_in",
sizeof (CoglPathTesselatorVertex),
G_STRUCT_OFFSET (CoglPathTesselatorVertex, s),
2, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT);
/* NULL terminator */
data->fill_vbo_attributes[2] = NULL;
data->fill_attributes[2] = NULL;
data->fill_vbo_indices = cogl_indices_new (tess.indices_type,
tess.indices->data,
@ -1510,25 +1511,26 @@ _cogl_path_build_fill_vbo (CoglPath *path)
}
static void
_cogl_path_build_stroke_vbo (CoglPath *path)
_cogl_path_build_stroke_attribute_buffer (CoglPath *path)
{
CoglPathData *data = path->data;
CoglBuffer *buffer;
unsigned int n_attributes = 0;
unsigned int path_start;
CoglPathNode *node;
floatVec2 *vbo_p;
floatVec2 *buffer_p;
unsigned int i;
/* If we've already got a cached vbo then we don't need to do anything */
if (data->stroke_vbo)
if (data->stroke_attribute_buffer)
return;
data->stroke_vbo = cogl_vertex_array_new (data->path_nodes->len *
sizeof (floatVec2),
data->stroke_attribute_buffer =
cogl_attribute_buffer_new (data->path_nodes->len * sizeof (floatVec2),
NULL);
vbo_p =
_cogl_buffer_map_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo));
buffer = COGL_BUFFER (data->stroke_attribute_buffer);
buffer_p = _cogl_buffer_map_for_fill_or_fallback (buffer);
/* Copy the vertices in and count the number of sub paths. Each sub
path will form a separate attribute so we can paint the disjoint
@ -1541,16 +1543,16 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
for (i = 0; i < node->path_size; i++)
{
vbo_p[path_start + i].x = node[i].x;
vbo_p[path_start + i].y = node[i].y;
buffer_p[path_start + i].x = node[i].x;
buffer_p[path_start + i].y = node[i].y;
}
n_attributes++;
}
_cogl_buffer_unmap_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo));
_cogl_buffer_unmap_for_fill_or_fallback (buffer);
data->stroke_vbo_attributes = g_new (CoglAttribute *, n_attributes);
data->stroke_attributes = g_new (CoglAttribute *, n_attributes);
/* Now we can loop the sub paths again to create the attributes */
for (i = 0, path_start = 0;
@ -1559,8 +1561,8 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
{
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
data->stroke_vbo_attributes[i] =
cogl_attribute_new (data->stroke_vbo,
data->stroke_attributes[i] =
cogl_attribute_new (data->stroke_attribute_buffer,
"cogl_position_in",
sizeof (floatVec2),
path_start * sizeof (floatVec2),
@ -1568,5 +1570,5 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
COGL_ATTRIBUTE_TYPE_FLOAT);
}
data->stroke_vbo_n_attributes = n_attributes;
data->stroke_n_attributes = n_attributes;
}