From 44c86fceadf4e770fa93df1605cf93f16103b195 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 19 Apr 2010 18:54:40 +0100 Subject: [PATCH] cogl-path: Don't try to union sub paths When drawing a path with only a single sub path, Cogl uses the 'even-odd' fill rule which means that if a part of the path intersects with another part then the intersection would be inverted. However when combining sub paths it treats them as separate paths and then unions them together. This doesn't match the semantics of the even-odd rule in SVG and Cairo. This patch makes it so that a new sub path is just drawn as another triangle fan so that it will continue to invert the stencil buffer. This is also much simpler and more efficient as well as being more correct. http://bugzilla.openedhand.com/show_bug.cgi?id=2088 --- clutter/cogl/cogl/cogl-path.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/clutter/cogl/cogl/cogl-path.c b/clutter/cogl/cogl/cogl-path.c index 2e1481d..a405e70 100644 --- a/clutter/cogl/cogl/cogl-path.c +++ b/clutter/cogl/cogl/cogl-path.c @@ -189,7 +189,6 @@ _cogl_add_path_to_stencil_buffer (CoglHandle path_handle, gboolean need_clear) { unsigned int path_start = 0; - unsigned int sub_path_num = 0; float bounds_x; float bounds_y; float bounds_w; @@ -288,30 +287,7 @@ _cogl_add_path_to_stencil_buffer (CoglHandle path_handle, GE (glDrawArrays (GL_TRIANGLE_FAN, 0, MIN (node->path_size, path->path_size - path_start))); - if (sub_path_num > 0) - { - /* Union the two stencil buffers bits into the least - significant bit */ - GE (glStencilMask (merge ? 6 : 3)); - GE (glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE)); - cogl_rectangle (bounds_x, bounds_y, - bounds_x + bounds_w, bounds_y + bounds_h); - /* Make sure the rectangle hits the stencil buffer before - * directly changing other GL state. */ - _cogl_journal_flush (); - /* NB: The journal flushing may trash the modelview state and - * enable flags */ - _cogl_matrix_stack_flush_to_gl (modelview_stack, - COGL_MATRIX_MODELVIEW); - _cogl_enable (enable_flags); - - GE (glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT)); - } - - GE (glStencilMask (merge ? 4 : 2)); - path_start += node->path_size; - sub_path_num++; } if (merge) -- 2.7.4