From e7338a1e09cb22151374aefa6f0bb58485af9189 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 10 Dec 2012 16:41:54 +0000 Subject: 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 --- cogl/cogl-texture.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cogl/cogl-texture.c') diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 274e831a..e1a305ba 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -1218,6 +1218,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, @@ -1234,11 +1235,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 */ @@ -1257,17 +1262,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 */ @@ -1277,11 +1285,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, -- cgit v1.2.1