cogl/clip-stack: Use "merge" parameter for rectangle clips

Just like for the other sorts of clips, use a "merge" parameter instead
of a "first" parameter.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1096
This commit is contained in:
Jonas Dreßler 2020-02-26 16:28:04 +01:00 committed by Carlos Garnacho
parent 84275688f3
commit d30ef0dd3b

View File

@ -57,7 +57,7 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
float y_1, float y_1,
float x_2, float x_2,
float y_2, float y_2,
gboolean first) gboolean merge)
{ {
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_framebuffer_get_projection_stack (framebuffer); _cogl_framebuffer_get_projection_stack (framebuffer);
@ -71,23 +71,7 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
projection_stack->last_entry); projection_stack->last_entry);
_cogl_context_set_current_modelview_entry (ctx, modelview_entry); _cogl_context_set_current_modelview_entry (ctx, modelview_entry);
if (first) if (merge)
{
GE( ctx, glEnable (GL_STENCIL_TEST) );
/* Initially disallow everything */
GE( ctx, glClearStencil (0) );
GE( ctx, glClear (GL_STENCIL_BUFFER_BIT) );
/* Punch out a hole to allow the rectangle */
GE( ctx, glStencilFunc (GL_NEVER, 0x1, 0x1) );
GE( ctx, glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
_cogl_rectangle_immediate (framebuffer,
ctx->stencil_pipeline,
x_1, y_1, x_2, y_2);
}
else
{ {
/* Add one to every pixel of the stencil buffer in the /* Add one to every pixel of the stencil buffer in the
rectangle */ rectangle */
@ -109,6 +93,21 @@ add_stencil_clip_rectangle (CoglFramebuffer *framebuffer,
ctx->stencil_pipeline, ctx->stencil_pipeline,
-1.0, -1.0, 1.0, 1.0); -1.0, -1.0, 1.0, 1.0);
} }
else
{
GE( ctx, glEnable (GL_STENCIL_TEST) );
/* Initially disallow everything */
GE( ctx, glClearStencil (0) );
GE( ctx, glClear (GL_STENCIL_BUFFER_BIT) );
/* Punch out a hole to allow the rectangle */
GE( ctx, glStencilFunc (GL_ALWAYS, 0x1, 0x1) );
GE( ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE) );
_cogl_rectangle_immediate (framebuffer,
ctx->stencil_pipeline,
x_1, y_1, x_2, y_2);
}
/* Restore the stencil mode */ /* Restore the stencil mode */
GE( ctx, glStencilFunc (GL_EQUAL, 0x1, 0x1) ); GE( ctx, glStencilFunc (GL_EQUAL, 0x1, 0x1) );
@ -491,7 +490,7 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
rect->y0, rect->y0,
rect->x1, rect->x1,
rect->y1, rect->y1,
!using_stencil_buffer); using_stencil_buffer);
using_stencil_buffer = TRUE; using_stencil_buffer = TRUE;
} }
break; break;