mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 13:28:03 +02:00
gl/msaa: Prevent stroke overlap
When stroking we do not send our polygon to the tessellator, so it may have overlapping stroke components. Use the stencil buffer to prevent stroke components from overlapping.
This commit is contained in:
parent
138e595c11
commit
a60bb83f28
1 changed files with 36 additions and 0 deletions
|
|
@ -297,6 +297,37 @@ _stroke_shaper_add_quad (void *closure,
|
|||
quad);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_prevent_overlapping_drawing (cairo_gl_context_t *ctx,
|
||||
cairo_gl_composite_t *setup,
|
||||
cairo_composite_rectangles_t *composite,
|
||||
cairo_bool_t used_stencil_buffer_for_clip)
|
||||
{
|
||||
if (! _cairo_gl_ensure_stencil (ctx, setup->dst))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
if (_cairo_pattern_is_opaque (&composite->source_pattern.base,
|
||||
&composite->source_sample_area))
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
if (used_stencil_buffer_for_clip == FALSE) {
|
||||
/* Enable the stencil buffer, even if we have no clip so that
|
||||
we can use it below to prevent overlapping shapes. We initialize
|
||||
it all to one here which represents infinite clip. */
|
||||
glDepthMask (GL_TRUE);
|
||||
glEnable (GL_STENCIL_TEST);
|
||||
glClearStencil (1);
|
||||
glClear (GL_STENCIL_BUFFER_BIT);
|
||||
glStencilFunc (GL_EQUAL, 1, 1);
|
||||
}
|
||||
|
||||
/* This means that once we draw to a particular pixel nothing else can
|
||||
be drawn there until the stencil buffer is reset or the stencil test
|
||||
is disabled. */
|
||||
glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO);
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
|
||||
cairo_composite_rectangles_t *composite,
|
||||
|
|
@ -340,6 +371,11 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
|
|||
if (unlikely (status))
|
||||
goto finish;
|
||||
|
||||
status = _prevent_overlapping_drawing (info.ctx, &info.setup, composite,
|
||||
used_stencil_buffer_for_clip);
|
||||
if (unlikely (status))
|
||||
goto finish;
|
||||
|
||||
status = _cairo_path_fixed_stroke_to_shaper ((cairo_path_fixed_t *) path,
|
||||
style,
|
||||
ctm,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue