summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2013-12-02 18:43:45 +0000
committerNeil Roberts <neil@linux.intel.com>2013-12-17 14:24:20 +0000
commitcc70dbd4267a2b7251e0b3939f6a90fcbde744fb (patch)
treee4e8cb467b195da6e32d739c6933d18a4e910532
parent17caccee4bcbae68a7f8b20742be54c9ac89cf75 (diff)
downloadcogl-cc70dbd4267a2b7251e0b3939f6a90fcbde744fb.tar.gz
Add a test for cogl_framebuffer_push_path_clip
The test makes an L-shaped path that fills the whole framebuffer except for the top right quadrant. It then clips to that and tries to fill the framebuffer with a rectangle. Then it verifies that all of the quadrants have the expected colour. This is currently failing due to a bug in the primitive clipping. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 5404033220099b4a3c6cf32a0d269c4e98489fee)
-rw-r--r--tests/conform/Makefile.am4
-rw-r--r--tests/conform/test-conform-main.c1
-rw-r--r--tests/conform/test-path-clip.c68
3 files changed, 72 insertions, 1 deletions
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index 633507ab..32282123 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -76,7 +76,9 @@ test_sources += test-fence.c
endif
if BUILD_COGL_PATH
-test_sources += test-path.c
+test_sources += \
+ test-path.c \
+ test-path-clip.c
endif
test_conformance_SOURCES = $(common_sources) $(test_sources)
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 047537b4..e7842c11 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -59,6 +59,7 @@ main (int argc, char **argv)
UNPORTED_TEST (test_readpixels);
#ifdef COGL_HAS_COGL_PATH_SUPPORT
ADD_TEST (test_path, 0, 0);
+ ADD_TEST (test_path_clip, 0, TEST_KNOWN_FAILURE);
#endif
ADD_TEST (test_depth_test, 0, 0);
ADD_TEST (test_color_mask, 0, 0);
diff --git a/tests/conform/test-path-clip.c b/tests/conform/test-path-clip.c
new file mode 100644
index 00000000..95ad00b9
--- /dev/null
+++ b/tests/conform/test-path-clip.c
@@ -0,0 +1,68 @@
+#define COGL_ENABLE_EXPERIMENTAL_2_0_API
+#include <cogl/cogl.h>
+#include <cogl-path/cogl-path.h>
+
+#include <string.h>
+
+#include "test-utils.h"
+
+void
+test_path_clip (void)
+{
+ CoglPath *path;
+ CoglPipeline *pipeline;
+ int fb_width, fb_height;
+
+ fb_width = cogl_framebuffer_get_width (test_fb);
+ fb_height = cogl_framebuffer_get_height (test_fb);
+
+ cogl_framebuffer_orthographic (test_fb,
+ 0, 0, fb_width, fb_height, -1, 100);
+
+ path = cogl_path_new ();
+
+ cogl_framebuffer_clear4f (test_fb,
+ COGL_BUFFER_BIT_COLOR,
+ 1.0f, 0.0f, 0.0f, 1.0f);
+
+ /* Make an L-shape with the top right corner left untouched */
+ cogl_path_move_to (path, 0, fb_height);
+ cogl_path_line_to (path, fb_width, fb_height);
+ cogl_path_line_to (path, fb_width, fb_height / 2);
+ cogl_path_line_to (path, fb_width / 2, fb_height / 2);
+ cogl_path_line_to (path, fb_width / 2, 0);
+ cogl_path_line_to (path, 0, 0);
+ cogl_path_close (path);
+
+ cogl_framebuffer_push_path_clip (test_fb, path);
+
+ /* Try to fill the framebuffer with a blue rectangle. This should be
+ * clipped to leave the top right quadrant as is */
+ pipeline = cogl_pipeline_new (test_ctx);
+ cogl_pipeline_set_color4ub (pipeline, 0, 0, 255, 255);
+ cogl_framebuffer_draw_rectangle (test_fb,
+ pipeline,
+ 0, 0, fb_width, fb_height);
+
+ cogl_framebuffer_pop_clip (test_fb);
+
+ cogl_object_unref (pipeline);
+ cogl_object_unref (path);
+
+ /* Check each of the four quadrants */
+ test_utils_check_pixel (test_fb,
+ fb_width / 4, fb_height / 4,
+ 0x0000ffff);
+ test_utils_check_pixel (test_fb,
+ fb_width * 3 / 4, fb_height / 4,
+ 0xff0000ff);
+ test_utils_check_pixel (test_fb,
+ fb_width / 4, fb_height * 3 / 4,
+ 0x0000ffff);
+ test_utils_check_pixel (test_fb,
+ fb_width * 3 / 4, fb_height * 3 / 4,
+ 0x0000ffff);
+
+ if (cogl_test_verbose ())
+ g_print ("OK\n");
+}