[Cogl] [PATCH 1/6] Add a test for getting the component sizes from different fbs

Robert Bragg robert at sixbynine.org
Wed Jan 16 06:00:11 PST 2013


This looks good to land to me:

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

thanks,
- Robert

On Fri, Dec 14, 2012 at 11:43 AM, Neil Roberts <neil at linux.intel.com> wrote:
> This adds a test which creates two offscreen framebuffers, one with
> just an alpha component texture and the other will a full RGBA
> texture. The bit sizes of both framebuffers are then checked to verify
> that they either have or haven't got bits for the RGB components.
>
> The test currently fails because the framebuffer functions don't bind
> the framebuffer before querying so they just query whichever
> framebuffer happened to be used last.
> ---
>  tests/conform/Makefile.am                 |  1 +
>  tests/conform/test-conform-main.c         |  3 +++
>  tests/conform/test-framebuffer-get-bits.c | 42 +++++++++++++++++++++++++++++++
>  tests/conform/test-utils.c                |  6 +++++
>  tests/conform/test-utils.h                |  3 ++-
>  5 files changed, 54 insertions(+), 1 deletion(-)
>  create mode 100644 tests/conform/test-framebuffer-get-bits.c
>
> diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
> index 013f29f..9d6e516 100644
> --- a/tests/conform/Makefile.am
> +++ b/tests/conform/Makefile.am
> @@ -61,6 +61,7 @@ test_sources = \
>         test-wrap-rectangle-textures.c \
>         test-texture-get-set-data.c \
>         test-texture-mipmap-get-set.c \
> +       test-framebuffer-get-bits.c \
>         $(NULL)
>
>  test_conformance_SOURCES = $(common_sources) $(test_sources)
> diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
> index 486479b..cbee5b2 100644
> --- a/tests/conform/test-conform-main.c
> +++ b/tests/conform/test-conform-main.c
> @@ -98,6 +98,9 @@ main (int argc, char **argv)
>    ADD_TEST (test_bitmask, 0, 0);
>
>    ADD_TEST (test_offscreen, 0, 0);
> +  ADD_TEST (test_framebuffer_get_bits,
> +            TEST_REQUIREMENT_OFFSCREEN,
> +            TEST_KNOWN_FAILURE);
>
>    ADD_TEST (test_point_size, 0, 0);
>    ADD_TEST (test_point_sprite,
> diff --git a/tests/conform/test-framebuffer-get-bits.c b/tests/conform/test-framebuffer-get-bits.c
> new file mode 100644
> index 0000000..21c00a4
> --- /dev/null
> +++ b/tests/conform/test-framebuffer-get-bits.c
> @@ -0,0 +1,42 @@
> +#include <cogl/cogl.h>
> +
> +#include "test-utils.h"
> +
> +void
> +test_framebuffer_get_bits (void)
> +{
> +  CoglTexture2D *tex_a =
> +    cogl_texture_2d_new_with_size (test_ctx,
> +                                   16, 16, /* width/height */
> +                                   COGL_PIXEL_FORMAT_A_8,
> +                                   NULL);
> +  CoglOffscreen *offscreen_a =
> +    cogl_offscreen_new_to_texture (COGL_TEXTURE (tex_a));
> +  CoglFramebuffer *fb_a = COGL_FRAMEBUFFER (offscreen_a);
> +  CoglTexture2D *tex_rgba =
> +    cogl_texture_2d_new_with_size (test_ctx,
> +                                   16, 16, /* width/height */
> +                                   COGL_PIXEL_FORMAT_RGBA_8888,
> +                                   NULL);
> +  CoglOffscreen *offscreen_rgba =
> +    cogl_offscreen_new_to_texture (COGL_TEXTURE (tex_rgba));
> +  CoglFramebuffer *fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
> +
> +  cogl_framebuffer_allocate (fb_a, NULL);
> +  cogl_framebuffer_allocate (fb_rgba, NULL);
> +
> +  g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_a), ==, 0);
> +  g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_a), ==, 0);
> +  g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_a), ==, 0);
> +  g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_a), >=, 1);
> +
> +  g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_rgba), >=, 1);
> +  g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_rgba), >=, 1);
> +  g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_rgba), >=, 1);
> +  g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_rgba), >=, 1);
> +
> +  cogl_object_unref (fb_rgba);
> +  cogl_object_unref (tex_rgba);
> +  cogl_object_unref (fb_a);
> +  cogl_object_unref (tex_a);
> +}
> diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
> index ba2ec47..e84ac68 100644
> --- a/tests/conform/test-utils.c
> +++ b/tests/conform/test-utils.c
> @@ -64,6 +64,12 @@ check_flags (TestFlags flags,
>        return FALSE;
>      }
>
> +  if (flags & TEST_REQUIREMENT_OFFSCREEN &&
> +      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_OFFSCREEN))
> +    {
> +      return FALSE;
> +    }
> +
>    if (flags & TEST_KNOWN_FAILURE)
>      {
>        return FALSE;
> diff --git a/tests/conform/test-utils.h b/tests/conform/test-utils.h
> index ec96913..e698f32 100644
> --- a/tests/conform/test-utils.h
> +++ b/tests/conform/test-utils.h
> @@ -19,7 +19,8 @@ typedef enum _TestFlags
>    TEST_REQUIREMENT_POINT_SPRITE = 1<<5,
>    TEST_REQUIREMENT_GLES2_CONTEXT = 1<<6,
>    TEST_REQUIREMENT_MAP_WRITE = 1<<7,
> -  TEST_REQUIREMENT_GLSL = 1<<8
> +  TEST_REQUIREMENT_GLSL = 1<<8,
> +  TEST_REQUIREMENT_OFFSCREEN = 1<<9
>  } TestFlags;
>
>  extern CoglContext *test_ctx;
> --
> 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