[cogl/wip/pbo-read-pixels: 1/16] Add a conformance test for reading back an RGBA texture as alpha-only



commit fab4ec80009539f845f2e89002ba887878a22409
Author: Neil Roberts <neil linux intel com>
Date:   Wed Feb 29 11:19:56 2012 +0000

    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

 tests/conform/Makefile.am               |    1 +
 tests/conform/test-conform-main.c       |    3 ++
 tests/conform/test-read-alpha-texture.c |   42 +++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index a39070a..b0f2a88 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -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)
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index ae71c97..85eb489 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -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);
diff --git a/tests/conform/test-read-alpha-texture.c b/tests/conform/test-read-alpha-texture.c
new file mode 100644
index 0000000..6b9ca58
--- /dev/null
+++ b/tests/conform/test-read-alpha-texture.c
@@ -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");
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]