diff --git a/tests/conform/test-cogl-path.c b/tests/conform/test-cogl-path.c index 3a8895780..87d108ddf 100644 --- a/tests/conform/test-cogl-path.c +++ b/tests/conform/test-cogl-path.c @@ -75,10 +75,13 @@ on_paint (ClutterActor *actor, TestState *state) cogl_set_source_color4ub (255, 255, 255, 255); - /* Create a path filling just a quarter of a block */ + /* Create a path filling just a quarter of a block. It will use two + rectangles so that we have a sub path in the path */ cogl_path_new (); - cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, + cogl_path_rectangle (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE); + cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, + BLOCK_SIZE * 3 / 4, BLOCK_SIZE); path_a = cogl_handle_ref (cogl_path_get ()); draw_path_at (0, 0); @@ -110,12 +113,15 @@ on_paint (ClutterActor *actor, TestState *state) cogl_path_set (path_c); draw_path_at (5, 0); - /* Add another rectangle to path c */ + /* Add another rectangle to path c. It will be added in two halves, + one as an extension of the previous path and the other as a new + sub path */ cogl_path_set (path_c); cogl_path_line_to (BLOCK_SIZE / 2, 0); - cogl_path_line_to (BLOCK_SIZE, 0); - cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE / 2); + cogl_path_line_to (BLOCK_SIZE * 3 / 4, 0); + cogl_path_line_to (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2); cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); + cogl_path_rectangle (BLOCK_SIZE * 3 / 4, 0, BLOCK_SIZE, BLOCK_SIZE / 2); draw_path_at (6, 0); /* Draw the original path again. It should not have changed */ @@ -126,6 +132,21 @@ on_paint (ClutterActor *actor, TestState *state) cogl_handle_unref (path_b); cogl_handle_unref (path_c); + /* Draw a self-intersecting path. The part that intersects should be + inverted */ + cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE); + cogl_path_line_to (0, BLOCK_SIZE / 2); + cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2); + cogl_path_line_to (BLOCK_SIZE / 2, 0); + cogl_path_close (); + draw_path_at (8, 0); + + /* Draw two sub paths. Where the paths intersect it should be + inverted */ + cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE); + cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE); + draw_path_at (9, 0); + verify_block (0, 0, 0x8 /* bottom right */); verify_block (1, 0, 0xf /* all of them */); verify_block (2, 0, 0x8 /* bottom right */); @@ -134,6 +155,8 @@ on_paint (ClutterActor *actor, TestState *state) verify_block (5, 0, 0x8 /* bottom right */); verify_block (6, 0, 0xa /* bottom right and top right */); 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 */); /* Comment this out if you want visual feedback of what this test * paints.