From 8d09b93572a20c68fe03f773294e6a270b3aac6d Mon Sep 17 00:00:00 2001 From: Alban Browaeys Date: Fri, 31 Aug 2012 09:17:55 +0200 Subject: [PATCH] meta-texture: Fix textures[] index textures[iter_y.index * n_y_spans + iter_x.index] only works for vertical rectangles when n_x_spans > 0 (ie x != {0} ) is also wrong for horizontal rectangles ( x = {0, 1, 2, 3} , y = {0, 1} -> second line will start at 2 = iter_y.index * n_y_spans + iter_x.index -> iteration are 0, 1, 2, 3, \n 2, 3, 4, 5 instead of 0, 1, 2, 3 \n 4, 5, 6, 7 Reviewed-by: Robert Bragg (cherry picked from commit bf0d187f1b5423b9ce1281aab1333fa2dfb9863f) --- cogl/cogl-meta-texture.c | 4 ++-- cogl/cogl-texture.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cogl/cogl-meta-texture.c b/cogl/cogl-meta-texture.c index e192a0aaa..4f51f7ced 100644 --- a/cogl/cogl-meta-texture.c +++ b/cogl/cogl-meta-texture.c @@ -182,7 +182,7 @@ create_grid_and_repeat_cb (CoglTexture *slice_texture, data->height, &y_real_index); - data->padded_textures[n_y_spans * y_real_index + x_real_index] = + data->padded_textures[n_x_spans * y_real_index + x_real_index] = slice_texture; /* Our callback is going to be passed normalized slice texture @@ -214,7 +214,7 @@ create_grid_and_repeat_cb (CoglTexture *slice_texture, data); /* Clear the padded_textures ready for the next iteration */ - data->padded_textures[n_y_spans * y_real_index + x_real_index] = NULL; + data->padded_textures[n_x_spans * y_real_index + x_real_index] = NULL; } #define SWAP(A,B) do { float tmp = B; B = A; A = tmp; } while (0) diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index bd60f4666..c6a02adb1 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -1441,7 +1441,7 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans, slice_coords[2] = (slice_coords[2] - iter_x.pos) / iter_x.span->size; /* Pluck out the cogl texture for this span */ - span_tex = textures[iter_y.index * n_y_spans + iter_x.index]; + span_tex = textures[iter_y.index * n_x_spans + iter_x.index]; span_virtual_coords[0] = iter_x.intersect_start; span_virtual_coords[1] = iter_y.intersect_start;