From 7df19876522dcbfc2c158ec6dacf0f7d98ca3365 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 28 Jan 2009 11:09:47 +0000 Subject: [PATCH] Fix _cogl_texture_unsliced_quad when no texture coordinates are given If no texture coordinates are given then texture_unsliced_quad tries to generate its own coordinates. However it also tries to read the texture coordinates to check if they are in [0.0,1.0] range so it will crash before it reaches that. --- clutter/cogl/gl/cogl-texture.c | 11 +++++++---- clutter/cogl/gles/cogl-texture.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 4aa2cb3..c324154 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -2441,6 +2441,7 @@ _cogl_multitexture_unsliced_quad (float x_1, */ if ((tex->gl_target == GL_TEXTURE_RECTANGLE_ARB || _cogl_texture_span_has_waste (tex, 0, 0)) + && i < user_tex_coords_len / 4 && (in_tex_coords[0] < 0 || in_tex_coords[0] > 1.0 || in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0 || in_tex_coords[2] < 0 || in_tex_coords[2] > 1.0 @@ -2497,6 +2498,8 @@ _cogl_multitexture_unsliced_quad (float x_1, else wrap_mode = GL_REPEAT; + memcpy (out_tex_coords, in_tex_coords, sizeof (GLfloat) * 4); + _cogl_texture_set_wrap_mode_parameter (tex, wrap_mode); } else @@ -2514,13 +2517,13 @@ _cogl_multitexture_unsliced_quad (float x_1, y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); out_tex_coords[0] = - in_tex_coords[0] * (x_span->size - x_span->waste) / x_span->size; + out_tex_coords[0] * (x_span->size - x_span->waste) / x_span->size; out_tex_coords[1] = - in_tex_coords[1] * (x_span->size - x_span->waste) / x_span->size; + out_tex_coords[1] * (x_span->size - x_span->waste) / x_span->size; out_tex_coords[2] = - in_tex_coords[2] * (y_span->size - y_span->waste) / y_span->size; + out_tex_coords[2] * (y_span->size - y_span->waste) / y_span->size; out_tex_coords[3] = - in_tex_coords[3] * (y_span->size - y_span->waste) / y_span->size; + out_tex_coords[3] * (y_span->size - y_span->waste) / y_span->size; /* Denormalize texture coordinates for rectangle textures */ if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB) diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index d5218cf..7f7242c 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -2556,6 +2556,7 @@ _cogl_multitexture_unsliced_quad (float x1, * case. */ if (_cogl_texture_span_has_waste (tex, 0, 0) + && i < user_tex_coords_len / 4 && (in_tex_coords[0] < 0 || in_tex_coords[0] > 1.0 || in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0 || in_tex_coords[2] < 0 || in_tex_coords[2] > 1.0 @@ -2612,6 +2613,8 @@ _cogl_multitexture_unsliced_quad (float x1, else wrap_mode = GL_REPEAT; + memcpy (out_tex_coords, in_tex_coords, sizeof (GLfloat) * 4); + _cogl_texture_set_wrap_mode_parameter (tex, wrap_mode); } else @@ -2629,13 +2632,13 @@ _cogl_multitexture_unsliced_quad (float x1, y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); out_tex_coords[0] = - in_tex_coords[0] * (x_span->size - x_span->waste) / x_span->size; + out_tex_coords[0] * (x_span->size - x_span->waste) / x_span->size; out_tex_coords[1] = - in_tex_coords[1] * (x_span->size - x_span->waste) / x_span->size; + out_tex_coords[1] * (x_span->size - x_span->waste) / x_span->size; out_tex_coords[2] = - in_tex_coords[2] * (y_span->size - y_span->waste) / y_span->size; + out_tex_coords[2] * (y_span->size - y_span->waste) / y_span->size; out_tex_coords[3] = - in_tex_coords[3] * (y_span->size - y_span->waste) / y_span->size; + out_tex_coords[3] * (y_span->size - y_span->waste) / y_span->size; } _cogl_journal_log_quad (x1, -- 2.7.4