mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 16:40:41 -05:00
Use a GArray for the texture vertices in cogl_texture_polygon
Previously it was a dynamic array that was manually reallocated.
This commit is contained in:
parent
dfa730909c
commit
93ea1681bb
@ -57,8 +57,8 @@ cogl_create_context ()
|
|||||||
_context->path_nodes_size = 0;
|
_context->path_nodes_size = 0;
|
||||||
|
|
||||||
_context->texture_handles = NULL;
|
_context->texture_handles = NULL;
|
||||||
_context->texture_vertices_size = 0;
|
_context->texture_vertices = g_array_new (FALSE, FALSE,
|
||||||
_context->texture_vertices = NULL;
|
sizeof (CoglTextureGLVertex));
|
||||||
|
|
||||||
_context->fbo_handles = NULL;
|
_context->fbo_handles = NULL;
|
||||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||||
@ -141,6 +141,9 @@ cogl_destroy_context ()
|
|||||||
if (_context->program_handles)
|
if (_context->program_handles)
|
||||||
g_array_free (_context->program_handles, TRUE);
|
g_array_free (_context->program_handles, TRUE);
|
||||||
|
|
||||||
|
if (_context->texture_vertices)
|
||||||
|
g_array_free (_context->texture_vertices, TRUE);
|
||||||
|
|
||||||
g_free (_context);
|
g_free (_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ typedef struct
|
|||||||
|
|
||||||
/* Textures */
|
/* Textures */
|
||||||
GArray *texture_handles;
|
GArray *texture_handles;
|
||||||
CoglTextureGLVertex *texture_vertices;
|
GArray *texture_vertices;
|
||||||
gulong texture_vertices_size;
|
|
||||||
|
|
||||||
/* Framebuffer objects */
|
/* Framebuffer objects */
|
||||||
GArray *fbo_handles;
|
GArray *fbo_handles;
|
||||||
|
@ -2252,22 +2252,8 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
/* Make sure there is enough space in the global texture vertex
|
/* Make sure there is enough space in the global texture vertex
|
||||||
array. This is used so we can render the polygon with a single
|
array. This is used so we can render the polygon with a single
|
||||||
call to OpenGL but still support any number of vertices */
|
call to OpenGL but still support any number of vertices */
|
||||||
if (ctx->texture_vertices_size < n_vertices)
|
g_array_set_size (ctx->texture_vertices, n_vertices);
|
||||||
{
|
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
guint nsize = ctx->texture_vertices_size;
|
|
||||||
|
|
||||||
if (nsize == 0)
|
|
||||||
nsize = 1;
|
|
||||||
do
|
|
||||||
nsize *= 2;
|
|
||||||
while (nsize < n_vertices);
|
|
||||||
|
|
||||||
ctx->texture_vertices_size = nsize;
|
|
||||||
|
|
||||||
ctx->texture_vertices = g_realloc (ctx->texture_vertices,
|
|
||||||
nsize
|
|
||||||
* sizeof (CoglTextureGLVertex));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
enable_flags = (COGL_ENABLE_TEXTURE_2D
|
enable_flags = (COGL_ENABLE_TEXTURE_2D
|
||||||
@ -2282,14 +2268,12 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
if (use_color)
|
if (use_color)
|
||||||
{
|
{
|
||||||
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
||||||
GE( glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (CoglTextureGLVertex),
|
GE( glColorPointer (4, GL_UNSIGNED_BYTE,
|
||||||
ctx->texture_vertices[0].c) );
|
sizeof (CoglTextureGLVertex), p->c) );
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex), p->v ) );
|
||||||
ctx->texture_vertices[0].v) );
|
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
|
||||||
ctx->texture_vertices[0].t) );
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
@ -2320,9 +2304,11 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
|
|
||||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
|
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
|
||||||
|
|
||||||
|
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
|
|
||||||
/* Convert the vertices into an array of GLfloats ready to pass to
|
/* Convert the vertices into an array of GLfloats ready to pass to
|
||||||
OpenGL */
|
OpenGL */
|
||||||
for (i = 0, p = ctx->texture_vertices; i < n_vertices; i++, p++)
|
for (i = 0; i < n_vertices; i++, p++)
|
||||||
{
|
{
|
||||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
#define CFX_F COGL_FIXED_TO_FLOAT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user