[Cogl] [PATCH 2/3] Also flip the virtual coordinates when iterating spans
Robert Bragg
robert at sixbynine.org
Wed Jan 16 05:50:04 PST 2013
This looks good to land to me:
Reviewed-by: Robert Bragg <robert at linux.intel.com>
thanks,
- Robert
On Tue, Dec 11, 2012 at 2:56 PM, Neil Roberts <neil at linux.intel.com> wrote:
> _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.
> ---
> cogl/cogl-texture.c | 15 +++++++++------
> tests/conform/test-conform-main.c | 2 +-
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
> index 1c9da68..15d7bbd 100644
> --- a/cogl/cogl-texture.c
> +++ b/cogl/cogl-texture.c
> @@ -1180,6 +1180,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,
> @@ -1196,11 +1197,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 */
> @@ -1219,17 +1224,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 */
> @@ -1239,11 +1247,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,
> diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
> index 5acf2e5..8e30b84 100644
> --- a/tests/conform/test-conform-main.c
> +++ b/tests/conform/test-conform-main.c
> @@ -58,7 +58,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);
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
More information about the Cogl
mailing list