This looks good to land to me:<div><br></div><div>Reviewed-by: Robert Bragg <<a href="mailto:robert@linux.intel.com">robert@linux.intel.com</a>></div><div><br></div><div>thanks,</div><div>- Robert</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Nov 19, 2012 at 5:28 PM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This adds a conformance test with an alpha-component texture. The<br>
texture is rendered using a pipeline with the same layer combine mode<br>
as cogl-pango.<br>
---<br>
tests/conform/Makefile.am | 1 +<br>
tests/conform/test-alpha-textures.c | 124 ++++++++++++++++++++++++++++++++++++<br>
tests/conform/test-conform-main.c | 1 +<br>
3 files changed, 126 insertions(+)<br>
create mode 100644 tests/conform/test-alpha-textures.c<br>
<br>
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am<br>
index b6430e2..4f1905c 100644<br>
--- a/tests/conform/Makefile.am<br>
+++ b/tests/conform/Makefile.am<br>
@@ -59,6 +59,7 @@ test_sources = \<br>
test-alpha-test.c \<br>
test-map-buffer-range.c \<br>
test-npot-texture.c \<br>
+ test-alpha-textures.c \<br>
$(NULL)<br>
<br>
test_conformance_SOURCES = $(common_sources) $(test_sources)<br>
diff --git a/tests/conform/test-alpha-textures.c b/tests/conform/test-alpha-textures.c<br>
new file mode 100644<br>
index 0000000..9063b80<br>
--- /dev/null<br>
+++ b/tests/conform/test-alpha-textures.c<br>
@@ -0,0 +1,124 @@<br>
+#include <cogl/cogl.h><br>
+<br>
+#include <string.h><br>
+<br>
+#include "test-utils.h"<br>
+<br>
+static void<br>
+create_pipeline (CoglTexture **tex_out,<br>
+ CoglPipeline **pipeline_out)<br>
+{<br>
+ CoglTexture2D *tex;<br>
+ CoglPipeline *pipeline;<br>
+ static const uint8_t tex_data[] =<br>
+ { 0x00, 0x44, 0x88, 0xcc };<br>
+<br>
+ tex = cogl_texture_2d_new_from_data (test_ctx,<br>
+ 2, 2, /* width/height */<br>
+ COGL_PIXEL_FORMAT_A_8, /* format */<br>
+ COGL_PIXEL_FORMAT_ANY, /* int. format */<br>
+ 2, /* rowstride */<br>
+ tex_data,<br>
+ NULL);<br>
+<br>
+ pipeline = cogl_pipeline_new (test_ctx);<br>
+<br>
+ cogl_pipeline_set_layer_filters (pipeline,<br>
+ 0, /* layer */<br>
+ COGL_PIPELINE_FILTER_NEAREST,<br>
+ COGL_PIPELINE_FILTER_NEAREST);<br>
+ cogl_pipeline_set_layer_wrap_mode (pipeline,<br>
+ 0, /* layer */<br>
+ COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);<br>
+<br>
+ /* This is the layer combine used by cogl-pango */<br>
+ cogl_pipeline_set_layer_combine (pipeline,<br>
+ 0, /* layer */<br>
+ "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",<br>
+ NULL);<br>
+<br>
+ cogl_pipeline_set_layer_texture (pipeline,<br>
+ 0, /* layer */<br>
+ COGL_TEXTURE (tex));<br>
+<br>
+ *pipeline_out = pipeline;<br>
+ *tex_out = COGL_TEXTURE (tex);<br>
+}<br>
+<br>
+void<br>
+test_alpha_textures (void)<br>
+{<br>
+ CoglTexture *tex1, *tex2;<br>
+ CoglPipeline *pipeline1, *pipeline2;<br>
+ int fb_width = cogl_framebuffer_get_width (test_fb);<br>
+ int fb_height = cogl_framebuffer_get_height (test_fb);<br>
+ uint8_t replacement_data[1] = { 0xff };<br>
+<br>
+ create_pipeline (&tex1, &pipeline1);<br>
+<br>
+ cogl_framebuffer_draw_rectangle (test_fb,<br>
+ pipeline1,<br>
+ -1.0f, 1.0f, /* x1/y1 */<br>
+ 1.0f, 0.0f /* x2/y2 */);<br>
+<br>
+ create_pipeline (&tex2, &pipeline2);<br>
+<br>
+ cogl_texture_set_region (tex2,<br>
+ 0, 0, /* src_x/y */<br>
+ 1, 1, /* dst_x/y */<br>
+ 1, 1, /* dst_width / dst_height */<br>
+ 1, 1, /* width / height */<br>
+ COGL_PIXEL_FORMAT_A_8,<br>
+ 1, /* rowstride */<br>
+ replacement_data);<br>
+<br>
+ cogl_framebuffer_draw_rectangle (test_fb,<br>
+ pipeline2,<br>
+ -1.0f, 0.0f, /* x1/y1 */<br>
+ 1.0f, -1.0f /* x2/y2 */);<br>
+<br>
+ cogl_object_unref (tex1);<br>
+ cogl_object_unref (tex2);<br>
+ cogl_object_unref (pipeline1);<br>
+ cogl_object_unref (pipeline2);<br>
+<br>
+ /* Unmodified texture */<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width / 4,<br>
+ fb_height / 8,<br>
+ 0x000000ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width * 3 / 4,<br>
+ fb_height / 8,<br>
+ 0x444444ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width / 4,<br>
+ fb_height * 3 / 8,<br>
+ 0x888888ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width * 3 / 4,<br>
+ fb_height * 3 / 8,<br>
+ 0xccccccff);<br>
+<br>
+ /* Modified texture */<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width / 4,<br>
+ fb_height * 5 / 8,<br>
+ 0x000000ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width * 3 / 4,<br>
+ fb_height * 5 / 8,<br>
+ 0x444444ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width / 4,<br>
+ fb_height * 7 / 8,<br>
+ 0x888888ff);<br>
+ test_utils_check_pixel (test_fb,<br>
+ fb_width * 3 / 4,<br>
+ fb_height * 7 / 8,<br>
+ 0xffffffff);<br>
+<br>
+ if (cogl_test_verbose ())<br>
+ g_print ("OK\n");<br>
+}<br>
+<br>
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c<br>
index b510543..78f3b34 100644<br>
--- a/tests/conform/test-conform-main.c<br>
+++ b/tests/conform/test-conform-main.c<br>
@@ -77,6 +77,7 @@ main (int argc, char **argv)<br>
ADD_TEST (test_atlas_migration, 0, 0);<br>
ADD_TEST (test_read_texture_formats, 0, 0);<br>
ADD_TEST (test_write_texture_formats, 0, 0);<br>
+ ADD_TEST (test_alpha_textures, 0, 0);<br>
<br>
UNPORTED_TEST (test_vertex_buffer_contiguous);<br>
UNPORTED_TEST (test_vertex_buffer_interleved);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.3.g3c3efa5<br>
<br>
_______________________________________________<br>
Cogl mailing list<br>
<a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
</font></span></blockquote></div><br></div>