1
0
Fork 0

Also flip the virtual coordinates when iterating spans

_cogl_texture_spans_foreach_in_region first swaps over the texture
coordinates if they are flipped so that it can always iterate in a
positive direction. It sets a flag so that it will remember that the
coordinates are flipped. Before invoking the callback it is meant to
reflip the coordinates so that the callee doesn't need to be aware of
the flipping. However it was only flipping the sub-texture coordinates
and not the virtual coordinates. This was causing sliced textures to
draw their slice rectangles with the wrong geometry.
test-backface-culling was failing because of this.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e7338a1e09cb22151374aefa6f0bb58485af9189)
This commit is contained in:
Neil Roberts 2012-12-10 16:41:54 +00:00 committed by Robert Bragg
parent a2aa04f219
commit 671275ba36
2 changed files with 10 additions and 7 deletions

View file

@ -1366,6 +1366,7 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
CoglSpanIter iter_x;
CoglSpanIter iter_y;
float slice_coords[4];
float span_virtual_coords[4];
/* Iterate the y axis of the virtual rectangle */
for (_cogl_span_iter_begin (&iter_y,
@ -1382,11 +1383,15 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
{
slice_coords[1] = iter_y.intersect_end;
slice_coords[3] = iter_y.intersect_start;
span_virtual_coords[1] = iter_y.intersect_end;
span_virtual_coords[3] = iter_y.intersect_start;
}
else
{
slice_coords[1] = iter_y.intersect_start;
slice_coords[3] = iter_y.intersect_end;
span_virtual_coords[1] = iter_y.intersect_start;
span_virtual_coords[3] = iter_y.intersect_end;
}
/* Map the current intersection to normalized slice coordinates */
@ -1405,17 +1410,20 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
_cogl_span_iter_next (&iter_x))
{
CoglTexture *span_tex;
float span_virtual_coords[4];
if (iter_x.flipped)
{
slice_coords[0] = iter_x.intersect_end;
slice_coords[2] = iter_x.intersect_start;
span_virtual_coords[0] = iter_x.intersect_end;
span_virtual_coords[2] = iter_x.intersect_start;
}
else
{
slice_coords[0] = iter_x.intersect_start;
slice_coords[2] = iter_x.intersect_end;
span_virtual_coords[0] = iter_x.intersect_start;
span_virtual_coords[2] = iter_x.intersect_end;
}
/* Map the current intersection to normalized slice coordinates */
@ -1425,11 +1433,6 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
/* Pluck out the cogl texture for this span */
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;
span_virtual_coords[2] = iter_x.intersect_end;
span_virtual_coords[3] = iter_y.intersect_end;
callback (COGL_TEXTURE (span_tex),
slice_coords,
span_virtual_coords,

View file

@ -59,7 +59,7 @@ main (int argc, char **argv)
ADD_TEST (test_path, 0, 0);
ADD_TEST (test_depth_test, 0, 0);
ADD_TEST (test_color_mask, 0, 0);
ADD_TEST (test_backface_culling, 0, TEST_REQUIREMENT_NPOT);
ADD_TEST (test_backface_culling, 0, 0);
ADD_TEST (test_layer_remove, 0, 0);
ADD_TEST (test_sparse_pipeline, 0, 0);