mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Add a conformance test for reading back an RGBA texture as alpha-only
This just creates a 1x1 RGBA texture and then reads it back in COGL_PIXEL_FORMAT_A_8 format. Gnome Shell is doing this to create a shadow and I accidentally broke it so this should hopefully stop that happening again. https://bugzilla.gnome.org/show_bug.cgi?id=671016 Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
59fd9b49d9
commit
b6dc23370d
@ -48,6 +48,7 @@ test_sources = \
|
||||
test-primitive.c \
|
||||
test-texture-3d.c \
|
||||
test-sparse-pipeline.c \
|
||||
test-read-alpha-texture.c \
|
||||
$(NULL)
|
||||
|
||||
test_conformance_SOURCES = $(common_sources) $(test_sources)
|
||||
|
@ -81,6 +81,9 @@ main (int argc, char **argv)
|
||||
UNPORTED_TEST (test_cogl_texture_pixmap_x11);
|
||||
UNPORTED_TEST (test_cogl_texture_get_set_data);
|
||||
UNPORTED_TEST (test_cogl_atlas_migration);
|
||||
/* This doesn't currently work on GLES because there is no fallback
|
||||
conversion to/from alpha-only */
|
||||
ADD_TEST (test_cogl_read_alpha_texture, TEST_REQUIREMENT_GL);
|
||||
|
||||
UNPORTED_TEST (test_cogl_vertex_buffer_contiguous);
|
||||
UNPORTED_TEST (test_cogl_vertex_buffer_interleved);
|
||||
|
42
tests/conform/test-read-alpha-texture.c
Normal file
42
tests/conform/test-read-alpha-texture.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
|
||||
#include "test-utils.h"
|
||||
|
||||
/*
|
||||
* This tests reading back an RGBA texture in alpha-only format.
|
||||
* This test just exists because I accidentally broke it and
|
||||
* gnome-shell is doing it.
|
||||
*
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=671016
|
||||
*/
|
||||
|
||||
static const guint8 tex_data[4] = { 0x12, 0x34, 0x56, 0x78 };
|
||||
|
||||
void
|
||||
test_cogl_read_alpha_texture (TestUtilsGTestFixture *fixture,
|
||||
void *data)
|
||||
{
|
||||
TestUtilsSharedState *shared_state = data;
|
||||
CoglTexture2D *tex_2d;
|
||||
guint8 alpha_value;
|
||||
|
||||
tex_2d = cogl_texture_2d_new_from_data (shared_state->ctx,
|
||||
1, 1, /* width / height */
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
4, /* rowstride */
|
||||
tex_data,
|
||||
NULL);
|
||||
|
||||
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
|
||||
COGL_PIXEL_FORMAT_A_8,
|
||||
1, /* rowstride */
|
||||
&alpha_value);
|
||||
|
||||
cogl_object_unref (tex_2d);
|
||||
|
||||
g_assert_cmpint (alpha_value, ==, 0x78);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("OK\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user