[Cogl] [PATCH 2/2] Split test-point-sprite into two, one without checking orientation

Robert Bragg robert at sixbynine.org
Mon Jul 2 14:22:47 PDT 2012


Both of these point sprite patches look good to land to me.

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

kind regards,
- Robert

On Mon, Jul 2, 2012 at 2:52 PM, Neil Roberts <neil at linux.intel.com> wrote:
> There is currently a known bug where when rendering offscreen point
> sprites will be rendered upside-down. For that reason
> test-point-sprite is marked as a known failure because it checks the
> orientation of the point sprites and the conformance test suite is
> rendered to offscreen buffers by default. However this doesn't help to
> catch more general failures that stop the point sprites being rendered
> at all. To fix this the test-point-sprite test has been split into two
> tests, one which verifies the orientation and one which does not. The
> two tests are in the same source file and internally share the same
> static function but pass a flag to specify whether to check the
> orientation. If the orientation should be ignored then it will create
> a 2x1 texture instead of a 2x2 texture so that it will appear the same
> regardless of whether it is upside-down. The checks for the colors
> have been altered accordingly.
> ---
>  tests/conform/test-conform-main.c |  2 ++
>  tests/conform/test-point-sprite.c | 35 ++++++++++++++++++++++++++++++-----
>  2 files changed, 32 insertions(+), 5 deletions(-)
>
> diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
> index aa2f746..fc49635 100644
> --- a/tests/conform/test-conform-main.c
> +++ b/tests/conform/test-conform-main.c
> @@ -94,6 +94,8 @@ main (int argc, char **argv)
>
>    ADD_TEST (test_point_size, 0);
>    ADD_TEST (test_point_sprite,
> +            TEST_REQUIREMENT_POINT_SPRITE);
> +  ADD_TEST (test_point_sprite_orientation,
>              TEST_KNOWN_FAILURE | TEST_REQUIREMENT_POINT_SPRITE);
>
>    ADD_TEST (test_version, 0);
> diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
> index c5effcd..0cdfdbd 100644
> --- a/tests/conform/test-point-sprite.c
> +++ b/tests/conform/test-point-sprite.c
> @@ -18,8 +18,8 @@ tex_data[3 * 2 * 2] =
>      0x00, 0xff, 0xff, 0xff, 0x00, 0x00
>    };
>
> -void
> -test_point_sprite (void)
> +static void
> +do_test (CoglBool check_orientation)
>  {
>    int fb_width = cogl_framebuffer_get_width (test_fb);
>    int fb_height = cogl_framebuffer_get_height (test_fb);
> @@ -28,6 +28,7 @@ test_point_sprite (void)
>    CoglTexture2D *tex_2d;
>    CoglPipeline *pipeline, *solid_pipeline;
>    CoglBool res;
> +  int tex_height;
>
>    cogl_framebuffer_orthographic (test_fb,
>                                   0, 0, /* x_1, y_1 */
> @@ -39,8 +40,16 @@ test_point_sprite (void)
>                              COGL_BUFFER_BIT_COLOR,
>                              1.0f, 1.0f, 1.0f, 1.0f);
>
> +  /* If we're not checking the orientation of the point sprite then
> +   * we'll set the height of the texture to 1 so that the vertical
> +   * orientation does not matter */
> +  if (check_orientation)
> +    tex_height = 2;
> +  else
> +    tex_height = 1;
> +
>    tex_2d = cogl_texture_2d_new_from_data (test_ctx,
> -                                          2, 2, /* width/height */
> +                                          2, tex_height, /* width/height */
>                                            COGL_PIXEL_FORMAT_RGB_888,
>                                            COGL_PIXEL_FORMAT_ANY,
>                                            6, /* row stride */
> @@ -111,11 +120,15 @@ test_point_sprite (void)
>    test_utils_check_pixel (test_fb,
>                            POINT_SIZE - POINT_SIZE / 4,
>                            POINT_SIZE + POINT_SIZE / 4,
> -                          0x00ffffff);
> +                          check_orientation ?
> +                          0x00ffffff :
> +                          0x0000ffff);
>    test_utils_check_pixel (test_fb,
>                            POINT_SIZE + POINT_SIZE / 4,
>                            POINT_SIZE + POINT_SIZE / 4,
> -                          0xff0000ff);
> +                          check_orientation ?
> +                          0xff0000ff :
> +                          0x00ff00ff);
>
>    /* When rendering without the point sprites all of the texture
>       coordinates should be 0,0 so it should get the top-left texel
> @@ -129,3 +142,15 @@ test_point_sprite (void)
>    if (cogl_test_verbose ())
>      g_print ("OK\n");
>  }
> +
> +void
> +test_point_sprite (void)
> +{
> +  do_test (FALSE /* don't check orientation */);
> +}
> +
> +void
> +test_point_sprite_orientation (void)
> +{
> +  do_test (TRUE /* check orientation */);
> +}
> --
> 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