From 6341ba98f966ab08827a92c19eefe733fd02933b Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 23 Jun 2010 17:17:40 +0100 Subject: [PATCH] test-cogl-path: Add tests for changing the fill rule This creates a path with an outer clockwise and two internal sub paths, one clockwise and one counter-clockwise. The path is then painted twice, once with each fill rule. --- tests/conform/test-cogl-path.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/conform/test-cogl-path.c b/tests/conform/test-cogl-path.c index 35ee8436d..1daa57f5b 100644 --- a/tests/conform/test-cogl-path.c +++ b/tests/conform/test-cogl-path.c @@ -147,6 +147,35 @@ on_paint (ClutterActor *actor, TestState *state) cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE); draw_path_at (9, 0); + /* Draw a clockwise outer path */ + cogl_path_move_to (0, 0); + cogl_path_line_to (BLOCK_SIZE, 0); + cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE); + cogl_path_line_to (0, BLOCK_SIZE); + cogl_path_close (); + /* Add a clockwise sub path in the upper left quadrant */ + cogl_path_move_to (0, 0); + cogl_path_line_to (BLOCK_SIZE / 2, 0); + cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); + cogl_path_line_to (0, BLOCK_SIZE / 2); + cogl_path_close (); + /* Add a counter-clockwise sub path in the upper right quadrant */ + cogl_path_move_to (BLOCK_SIZE / 2, 0); + cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); + cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE / 2); + cogl_path_line_to (BLOCK_SIZE, 0); + cogl_path_close (); + /* Retain the path for the next test */ + path_a = cogl_handle_ref (cogl_get_path ()); + draw_path_at (10, 0); + + /* Draw the same path again with the other fill rule */ + cogl_set_path (path_a); + cogl_path_set_fill_rule (COGL_PATH_FILL_RULE_NON_ZERO); + draw_path_at (11, 0); + + cogl_handle_unref (path_a); + verify_block (0, 0, 0x8 /* bottom right */); verify_block (1, 0, 0xf /* all of them */); verify_block (2, 0, 0x8 /* bottom right */); @@ -157,6 +186,8 @@ on_paint (ClutterActor *actor, TestState *state) verify_block (7, 0, 0x9 /* top_left and bottom right */); verify_block (8, 0, 0xe /* all but top left */); verify_block (9, 0, 0x7 /* all but bottom right */); + verify_block (10, 0, 0xc /* bottom two */); + verify_block (11, 0, 0xd /* all but top right */); /* Comment this out if you want visual feedback of what this test * paints.