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 <robert@linux.inte.com>

(cherry picked from commit bf0d187f1b5423b9ce1281aab1333fa2dfb9863f)
This commit is contained in:
Alban Browaeys 2012-08-31 09:17:55 +02:00 committed by Robert Bragg
parent 2bc5c494a6
commit 8d09b93572
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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;