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.
This commit is contained in:
Neil Roberts 2009-01-28 11:09:47 +00:00
parent 8dca5c73bc
commit c18d945dc7
2 changed files with 14 additions and 8 deletions

View File

@ -2441,6 +2441,7 @@ _cogl_multitexture_unsliced_quad (float x_1,
*/ */
if ((tex->gl_target == GL_TEXTURE_RECTANGLE_ARB if ((tex->gl_target == GL_TEXTURE_RECTANGLE_ARB
|| _cogl_texture_span_has_waste (tex, 0, 0)) || _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[0] < 0 || in_tex_coords[0] > 1.0
|| in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0 || in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0
|| in_tex_coords[2] < 0 || in_tex_coords[2] > 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 else
wrap_mode = GL_REPEAT; wrap_mode = GL_REPEAT;
memcpy (out_tex_coords, in_tex_coords, sizeof (GLfloat) * 4);
_cogl_texture_set_wrap_mode_parameter (tex, wrap_mode); _cogl_texture_set_wrap_mode_parameter (tex, wrap_mode);
} }
else else
@ -2514,13 +2517,13 @@ _cogl_multitexture_unsliced_quad (float x_1,
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
out_tex_coords[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] = 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] = 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] = 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 */ /* Denormalize texture coordinates for rectangle textures */
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB) if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)

View File

@ -2556,6 +2556,7 @@ _cogl_multitexture_unsliced_quad (float x1,
* case. * case.
*/ */
if (_cogl_texture_span_has_waste (tex, 0, 0) 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[0] < 0 || in_tex_coords[0] > 1.0
|| in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0 || in_tex_coords[1] < 0 || in_tex_coords[1] > 1.0
|| in_tex_coords[2] < 0 || in_tex_coords[2] > 1.0 || in_tex_coords[2] < 0 || in_tex_coords[2] > 1.0
@ -2612,6 +2613,8 @@ _cogl_multitexture_unsliced_quad (float x1,
else else
wrap_mode = GL_REPEAT; wrap_mode = GL_REPEAT;
memcpy (out_tex_coords, in_tex_coords, sizeof (GLfloat) * 4);
_cogl_texture_set_wrap_mode_parameter (tex, wrap_mode); _cogl_texture_set_wrap_mode_parameter (tex, wrap_mode);
} }
else else
@ -2629,13 +2632,13 @@ _cogl_multitexture_unsliced_quad (float x1,
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
out_tex_coords[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] = 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] = 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] = 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, _cogl_journal_log_quad (x1,