mutter/tests/conform/test-framebuffer-get-bits.c
Robert Bragg 1317a25a91 offscreen: rename _new_to_texture to _new_with_texture
This renames cogl_offscreen_new_to_texture to
cogl_offscreen_new_with_texture. The intention is to then cherry-pick
this back to the cogl-1.16 branch so we can maintain a parallel
cogl_offscreen_new_to_texture() function which keeps the synchronous
allocation semantics that some clutter applications are currently
relying on.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ecc6d2f64481626992b2fe6cdfa7b999270b28f5)

Note: Since we can't break the 1.x api on this branch this keeps a
thin shim around cogl_offscreen_new_with_texture to implement
cogl_offscreen_new_to_texture with its synchronous allocation
semantics.
2013-08-19 22:44:44 +01:00

41 lines
1.5 KiB
C

#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);
CoglOffscreen *offscreen_a =
cogl_offscreen_new_with_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);
CoglOffscreen *offscreen_rgba =
cogl_offscreen_new_with_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);
}