mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
cogl-buffer: Use void* instead of guint8* for map and set_data
Unless the CoglBuffer is being used for texture data then it's relatively unlikely that the data will contain an array of bytes. For example if it's used as a vertex array then it's more likely to be floats or some vertex struct. In that case it's much more convenient if set_data and map use void* pointers so that we can avoid a cast.
This commit is contained in:
parent
2155bd7546
commit
6027aa04a4
@ -42,15 +42,15 @@ typedef struct _CoglBufferVtable CoglBufferVtable;
|
|||||||
|
|
||||||
struct _CoglBufferVtable
|
struct _CoglBufferVtable
|
||||||
{
|
{
|
||||||
guint8 * (* map) (CoglBuffer *buffer,
|
void * (* map) (CoglBuffer *buffer,
|
||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints);
|
CoglBufferMapHint hints);
|
||||||
|
|
||||||
void (* unmap) (CoglBuffer *buffer);
|
void (* unmap) (CoglBuffer *buffer);
|
||||||
|
|
||||||
gboolean (* set_data) (CoglBuffer *buffer,
|
gboolean (* set_data) (CoglBuffer *buffer,
|
||||||
unsigned int offset,
|
unsigned int offset,
|
||||||
const guint8 *data,
|
const void *data,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ convert_bind_target_to_gl_target (CoglBufferBindTarget target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint8 *
|
static void *
|
||||||
bo_map (CoglBuffer *buffer,
|
bo_map (CoglBuffer *buffer,
|
||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints)
|
CoglBufferMapHint hints)
|
||||||
@ -196,7 +196,7 @@ bo_unmap (CoglBuffer *buffer)
|
|||||||
static gboolean
|
static gboolean
|
||||||
bo_set_data (CoglBuffer *buffer,
|
bo_set_data (CoglBuffer *buffer,
|
||||||
unsigned int offset,
|
unsigned int offset,
|
||||||
const guint8 *data,
|
const void *data,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
CoglBufferBindTarget target;
|
CoglBufferBindTarget target;
|
||||||
@ -233,7 +233,7 @@ bo_set_data (CoglBuffer *buffer,
|
|||||||
* Fallback path, buffer->data points to a malloc'ed buffer.
|
* Fallback path, buffer->data points to a malloc'ed buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static guint8 *
|
static void *
|
||||||
malloc_map (CoglBuffer *buffer,
|
malloc_map (CoglBuffer *buffer,
|
||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints)
|
CoglBufferMapHint hints)
|
||||||
@ -251,7 +251,7 @@ malloc_unmap (CoglBuffer *buffer)
|
|||||||
static gboolean
|
static gboolean
|
||||||
malloc_set_data (CoglBuffer *buffer,
|
malloc_set_data (CoglBuffer *buffer,
|
||||||
unsigned int offset,
|
unsigned int offset,
|
||||||
const guint8 *data,
|
const void *data,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
memcpy (buffer->data + offset, data, size);
|
memcpy (buffer->data + offset, data, size);
|
||||||
@ -442,7 +442,7 @@ warn_about_midscene_changes (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guint8 *
|
void *
|
||||||
cogl_buffer_map (CoglBuffer *buffer,
|
cogl_buffer_map (CoglBuffer *buffer,
|
||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints)
|
CoglBufferMapHint hints)
|
||||||
@ -474,7 +474,7 @@ cogl_buffer_unmap (CoglBuffer *buffer)
|
|||||||
gboolean
|
gboolean
|
||||||
cogl_buffer_set_data (CoglBuffer *buffer,
|
cogl_buffer_set_data (CoglBuffer *buffer,
|
||||||
gsize offset,
|
gsize offset,
|
||||||
const guint8 *data,
|
const void *data,
|
||||||
gsize size)
|
gsize size)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_buffer (buffer), FALSE);
|
g_return_val_if_fail (cogl_is_buffer (buffer), FALSE);
|
||||||
|
@ -198,7 +198,7 @@ typedef enum { /*< prefix=COGL_BUFFER_MAP_HINT >*/
|
|||||||
* Since: 1.2
|
* Since: 1.2
|
||||||
* Stability: Unstable
|
* Stability: Unstable
|
||||||
*/
|
*/
|
||||||
guint8 *
|
void *
|
||||||
cogl_buffer_map (CoglBuffer *buffer,
|
cogl_buffer_map (CoglBuffer *buffer,
|
||||||
CoglBufferAccess access,
|
CoglBufferAccess access,
|
||||||
CoglBufferMapHint hints);
|
CoglBufferMapHint hints);
|
||||||
@ -234,7 +234,7 @@ cogl_buffer_unmap (CoglBuffer *buffer);
|
|||||||
gboolean
|
gboolean
|
||||||
cogl_buffer_set_data (CoglBuffer *buffer,
|
cogl_buffer_set_data (CoglBuffer *buffer,
|
||||||
gsize offset,
|
gsize offset,
|
||||||
const guint8 *data,
|
const void *data,
|
||||||
gsize size);
|
gsize size);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -595,7 +595,7 @@ upload_vertices (GArray *vertices, CoglJournalFlushState *state)
|
|||||||
array = cogl_vertex_array_new (needed_vbo_len);
|
array = cogl_vertex_array_new (needed_vbo_len);
|
||||||
buffer = COGL_BUFFER (array);
|
buffer = COGL_BUFFER (array);
|
||||||
cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_STATIC);
|
cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_STATIC);
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)vertices->data, needed_vbo_len);
|
cogl_buffer_set_data (buffer, 0, vertices->data, needed_vbo_len);
|
||||||
|
|
||||||
/* As we flush the journal entries in batches we walk forward through the
|
/* As we flush the journal entries in batches we walk forward through the
|
||||||
* above VBO starting at offset 0... */
|
* above VBO starting at offset 0... */
|
||||||
|
@ -130,7 +130,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[2];
|
CoglVertexAttribute *attributes[2];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP2Vertex));
|
n_vertices * sizeof (CoglP2Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -157,7 +157,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[2];
|
CoglVertexAttribute *attributes[2];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP3Vertex));
|
n_vertices * sizeof (CoglP3Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -184,7 +184,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglVertexAttribute *attributes[3];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP2C4Vertex));
|
n_vertices * sizeof (CoglP2C4Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -218,7 +218,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglVertexAttribute *attributes[3];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP3C4Vertex));
|
n_vertices * sizeof (CoglP3C4Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -252,7 +252,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglVertexAttribute *attributes[3];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP2T2Vertex));
|
n_vertices * sizeof (CoglP2T2Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -286,7 +286,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglVertexAttribute *attributes[3];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP3T2Vertex));
|
n_vertices * sizeof (CoglP3T2Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -320,7 +320,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[4];
|
CoglVertexAttribute *attributes[4];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP2T2C4Vertex));
|
n_vertices * sizeof (CoglP2T2C4Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
@ -361,7 +361,7 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
|
|||||||
CoglBuffer *buffer = COGL_BUFFER (array);
|
CoglBuffer *buffer = COGL_BUFFER (array);
|
||||||
CoglVertexAttribute *attributes[4];
|
CoglVertexAttribute *attributes[4];
|
||||||
|
|
||||||
cogl_buffer_set_data (buffer, 0, (guint8 *)data,
|
cogl_buffer_set_data (buffer, 0, data,
|
||||||
n_vertices * sizeof (CoglP3T2C4Vertex));
|
n_vertices * sizeof (CoglP3T2C4Vertex));
|
||||||
attributes[0] =
|
attributes[0] =
|
||||||
cogl_vertex_attribute_new (array,
|
cogl_vertex_attribute_new (array,
|
||||||
|
@ -1024,7 +1024,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
v = (float *)ctx->polygon_vertices->data;
|
v = (float *)ctx->polygon_vertices->data;
|
||||||
cogl_buffer_set_data (COGL_BUFFER (vertex_array),
|
cogl_buffer_set_data (COGL_BUFFER (vertex_array),
|
||||||
0,
|
0,
|
||||||
(const guint8 *)v,
|
v,
|
||||||
ctx->polygon_vertices->len * sizeof (float));
|
ctx->polygon_vertices->len * sizeof (float));
|
||||||
|
|
||||||
cogl_push_source (pipeline);
|
cogl_push_source (pipeline);
|
||||||
|
Loading…
Reference in New Issue
Block a user