From 0fb51658fdba886fd5d9cb53cfca6df13aa1f7a0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 4 Jan 2010 11:43:00 +0000 Subject: [PATCH] cogl: Const-ify vertices in cogl_polygon() The CoglTextureVertex array passed to cogl_polygon() is a pure in-argument and should be const-ified. http://bugzilla.openedhand.com/show_bug.cgi?id=1917 --- clutter/cogl/cogl/cogl-primitives.c | 27 ++++++++++++++------------- clutter/cogl/cogl/cogl-texture.h | 6 +++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/clutter/cogl/cogl/cogl-primitives.c b/clutter/cogl/cogl/cogl-primitives.c index 63bd382..e4fdf6a 100644 --- a/clutter/cogl/cogl/cogl-primitives.c +++ b/clutter/cogl/cogl/cogl-primitives.c @@ -61,7 +61,7 @@ typedef struct _TextureSlicedQuadState typedef struct _TextureSlicedPolygonState { - CoglTextureVertex *vertices; + const CoglTextureVertex *vertices; int n_vertices; int stride; } TextureSlicedPolygonState; @@ -709,7 +709,7 @@ draw_polygon_sub_texture_cb (CoglHandle tex_handle, /* handles 2d-sliced textures with > 1 slice */ static void -_cogl_texture_polygon_multiple_primitives (CoglTextureVertex *vertices, +_cogl_texture_polygon_multiple_primitives (const CoglTextureVertex *vertices, unsigned int n_vertices, unsigned int stride, gboolean use_color) @@ -762,7 +762,7 @@ _cogl_texture_polygon_multiple_primitives (CoglTextureVertex *vertices, } static void -_cogl_multitexture_polygon_single_primitive (CoglTextureVertex *vertices, +_cogl_multitexture_polygon_single_primitive (const CoglTextureVertex *vertices, guint n_vertices, guint n_layers, guint stride, @@ -841,14 +841,13 @@ _cogl_multitexture_polygon_single_primitive (CoglTextureVertex *vertices, } void -cogl_polygon (CoglTextureVertex *vertices, - guint n_vertices, - gboolean use_color) +cogl_polygon (const CoglTextureVertex *vertices, + guint n_vertices, + gboolean use_color) { CoglHandle material; - const GList *layers; + const GList *layers, *tmp; int n_layers; - GList *tmp; gboolean use_sliced_polygon_fallback = FALSE; guint32 fallback_layers = 0; int i; @@ -871,10 +870,10 @@ cogl_polygon (CoglTextureVertex *vertices, layers = cogl_material_get_layers (ctx->source_material); n_layers = g_list_length ((GList *)layers); - for (tmp = (GList *)layers, i = 0; tmp != NULL; tmp = tmp->next, i++) + for (tmp = layers, i = 0; tmp != NULL; tmp = tmp->next, i++) { - CoglHandle layer = (CoglHandle)tmp->data; - CoglHandle tex_handle = cogl_material_layer_get_texture (layer); + CoglHandle layer = tmp->data; + CoglHandle tex_handle = cogl_material_layer_get_texture (layer); /* COGL_INVALID_HANDLE textures will be handled in * _cogl_material_flush_layers_gl_state */ @@ -904,6 +903,7 @@ cogl_polygon (CoglTextureVertex *vertices, warning_seen = TRUE; } } + use_sliced_polygon_fallback = TRUE; n_layers = 1; @@ -990,9 +990,10 @@ cogl_polygon (CoglTextureVertex *vertices, /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ v + 3 + 2 * i)); } - prev_n_texcoord_arrays_enabled = - ctx->n_texcoord_arrays_enabled; + + prev_n_texcoord_arrays_enabled = ctx->n_texcoord_arrays_enabled; ctx->n_texcoord_arrays_enabled = n_layers; + for (; i < prev_n_texcoord_arrays_enabled; i++) { GE (glClientActiveTexture (GL_TEXTURE0 + i)); diff --git a/clutter/cogl/cogl/cogl-texture.h b/clutter/cogl/cogl/cogl-texture.h index b831d1a..7859abd 100644 --- a/clutter/cogl/cogl/cogl-texture.h +++ b/clutter/cogl/cogl/cogl-texture.h @@ -466,9 +466,9 @@ void cogl_rectangles (const float *verts, * * Since: 1.0 */ -void cogl_polygon (CoglTextureVertex *vertices, - guint n_vertices, - gboolean use_color); +void cogl_polygon (const CoglTextureVertex *vertices, + guint n_vertices, + gboolean use_color); G_END_DECLS -- 2.7.4