cogl/clip-stack: Remove unused primitive type
Detected by going through code coverage Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3901>
This commit is contained in:
parent
c65bb3b9ce
commit
90e0acf11a
@ -67,36 +67,6 @@ _cogl_clip_stack_push_entry (CoglClipStack *clip_stack,
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
get_transformed_corners (float x_1,
|
|
||||||
float y_1,
|
|
||||||
float x_2,
|
|
||||||
float y_2,
|
|
||||||
graphene_matrix_t *modelview,
|
|
||||||
graphene_matrix_t *projection,
|
|
||||||
const float *viewport,
|
|
||||||
float *transformed_corners)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
transformed_corners[0] = x_1;
|
|
||||||
transformed_corners[1] = y_1;
|
|
||||||
transformed_corners[2] = x_2;
|
|
||||||
transformed_corners[3] = y_1;
|
|
||||||
transformed_corners[4] = x_2;
|
|
||||||
transformed_corners[5] = y_2;
|
|
||||||
transformed_corners[6] = x_1;
|
|
||||||
transformed_corners[7] = y_2;
|
|
||||||
|
|
||||||
|
|
||||||
/* Project the coordinates to window space coordinates */
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
float *v = transformed_corners + i * 2;
|
|
||||||
_cogl_transform_point (modelview, projection, viewport, v, v + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets the window-space bounds of the entry based on the projected
|
/* Sets the window-space bounds of the entry based on the projected
|
||||||
coordinates of the given rectangle */
|
coordinates of the given rectangle */
|
||||||
static void
|
static void
|
||||||
@ -224,52 +194,6 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
|||||||
return (CoglClipStack *) entry;
|
return (CoglClipStack *) entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglClipStack *
|
|
||||||
_cogl_clip_stack_push_primitive (CoglClipStack *stack,
|
|
||||||
CoglPrimitive *primitive,
|
|
||||||
float bounds_x1,
|
|
||||||
float bounds_y1,
|
|
||||||
float bounds_x2,
|
|
||||||
float bounds_y2,
|
|
||||||
CoglMatrixEntry *modelview_entry,
|
|
||||||
CoglMatrixEntry *projection_entry,
|
|
||||||
const float *viewport)
|
|
||||||
{
|
|
||||||
CoglClipStackPrimitive *entry;
|
|
||||||
graphene_matrix_t modelview;
|
|
||||||
graphene_matrix_t projection;
|
|
||||||
float transformed_corners[8];
|
|
||||||
|
|
||||||
entry = _cogl_clip_stack_push_entry (stack,
|
|
||||||
sizeof (CoglClipStackPrimitive),
|
|
||||||
COGL_CLIP_STACK_PRIMITIVE);
|
|
||||||
|
|
||||||
entry->primitive = g_object_ref (primitive);
|
|
||||||
|
|
||||||
entry->matrix_entry = cogl_matrix_entry_ref (modelview_entry);
|
|
||||||
|
|
||||||
entry->bounds_x1 = bounds_x1;
|
|
||||||
entry->bounds_y1 = bounds_y1;
|
|
||||||
entry->bounds_x2 = bounds_x2;
|
|
||||||
entry->bounds_y2 = bounds_y2;
|
|
||||||
|
|
||||||
cogl_matrix_entry_get (modelview_entry, &modelview);
|
|
||||||
cogl_matrix_entry_get (projection_entry, &projection);
|
|
||||||
|
|
||||||
get_transformed_corners (bounds_x1, bounds_y1, bounds_x2, bounds_y2,
|
|
||||||
&modelview,
|
|
||||||
&projection,
|
|
||||||
viewport,
|
|
||||||
transformed_corners);
|
|
||||||
|
|
||||||
/* NB: this is referring to the bounds in window coordinates as opposed
|
|
||||||
* to the bounds above in primitive local coordinates. */
|
|
||||||
_cogl_clip_stack_entry_set_bounds ((CoglClipStack *) entry,
|
|
||||||
transformed_corners);
|
|
||||||
|
|
||||||
return (CoglClipStack *) entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
CoglClipStack *
|
CoglClipStack *
|
||||||
cogl_clip_stack_push_region (CoglClipStack *stack,
|
cogl_clip_stack_push_region (CoglClipStack *stack,
|
||||||
MtkRegion *region)
|
MtkRegion *region)
|
||||||
@ -323,15 +247,6 @@ _cogl_clip_stack_unref (CoglClipStack *entry)
|
|||||||
g_free (entry);
|
g_free (entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COGL_CLIP_STACK_PRIMITIVE:
|
|
||||||
{
|
|
||||||
CoglClipStackPrimitive *primitive_entry =
|
|
||||||
(CoglClipStackPrimitive *) entry;
|
|
||||||
cogl_matrix_entry_unref (primitive_entry->matrix_entry);
|
|
||||||
g_object_unref (primitive_entry->primitive);
|
|
||||||
g_free (entry);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COGL_CLIP_STACK_REGION:
|
case COGL_CLIP_STACK_REGION:
|
||||||
{
|
{
|
||||||
CoglClipStackRegion *region = (CoglClipStackRegion *) entry;
|
CoglClipStackRegion *region = (CoglClipStackRegion *) entry;
|
||||||
|
@ -45,13 +45,11 @@
|
|||||||
typedef struct _CoglClipStack CoglClipStack;
|
typedef struct _CoglClipStack CoglClipStack;
|
||||||
typedef struct _CoglClipStackRect CoglClipStackRect;
|
typedef struct _CoglClipStackRect CoglClipStackRect;
|
||||||
typedef struct _CoglClipStackWindowRect CoglClipStackWindowRect;
|
typedef struct _CoglClipStackWindowRect CoglClipStackWindowRect;
|
||||||
typedef struct _CoglClipStackPrimitive CoglClipStackPrimitive;
|
|
||||||
typedef struct _CoglClipStackRegion CoglClipStackRegion;
|
typedef struct _CoglClipStackRegion CoglClipStackRegion;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
COGL_CLIP_STACK_RECT,
|
COGL_CLIP_STACK_RECT,
|
||||||
COGL_CLIP_STACK_PRIMITIVE,
|
|
||||||
COGL_CLIP_STACK_REGION,
|
COGL_CLIP_STACK_REGION,
|
||||||
} CoglClipStackType;
|
} CoglClipStackType;
|
||||||
|
|
||||||
@ -138,21 +136,6 @@ struct _CoglClipStackRect
|
|||||||
gboolean can_be_scissor;
|
gboolean can_be_scissor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CoglClipStackPrimitive
|
|
||||||
{
|
|
||||||
CoglClipStack _parent_data;
|
|
||||||
|
|
||||||
/* The matrix that was current when the clip was set */
|
|
||||||
CoglMatrixEntry *matrix_entry;
|
|
||||||
|
|
||||||
CoglPrimitive *primitive;
|
|
||||||
|
|
||||||
float bounds_x1;
|
|
||||||
float bounds_y1;
|
|
||||||
float bounds_x2;
|
|
||||||
float bounds_y2;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CoglClipStackRegion
|
struct _CoglClipStackRegion
|
||||||
{
|
{
|
||||||
CoglClipStack _parent_data;
|
CoglClipStack _parent_data;
|
||||||
|
@ -247,148 +247,6 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
|
|||||||
GE( ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*SilhouettePaintCallback) (CoglFramebuffer *framebuffer,
|
|
||||||
CoglPipeline *pipeline,
|
|
||||||
void *user_data);
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_stencil_clip_silhouette (CoglFramebuffer *framebuffer,
|
|
||||||
SilhouettePaintCallback silhouette_callback,
|
|
||||||
CoglMatrixEntry *modelview_entry,
|
|
||||||
float bounds_x1,
|
|
||||||
float bounds_y1,
|
|
||||||
float bounds_x2,
|
|
||||||
float bounds_y2,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean need_clear,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
CoglMatrixStack *projection_stack =
|
|
||||||
_cogl_framebuffer_get_projection_stack (framebuffer);
|
|
||||||
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
|
||||||
CoglMatrixEntry *old_projection_entry, *old_modelview_entry;
|
|
||||||
|
|
||||||
/* NB: This can be called while flushing the journal so we need
|
|
||||||
* to be very conservative with what state we change.
|
|
||||||
*/
|
|
||||||
old_projection_entry = g_steal_pointer (&ctx->current_projection_entry);
|
|
||||||
old_modelview_entry = g_steal_pointer (&ctx->current_modelview_entry);
|
|
||||||
|
|
||||||
ctx->current_projection_entry = projection_stack->last_entry;
|
|
||||||
ctx->current_modelview_entry = modelview_entry;
|
|
||||||
|
|
||||||
_cogl_pipeline_flush_gl_state (ctx, ctx->stencil_pipeline,
|
|
||||||
framebuffer, FALSE, FALSE);
|
|
||||||
|
|
||||||
GE( ctx, glEnable (GL_STENCIL_TEST) );
|
|
||||||
|
|
||||||
GE( ctx, glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
|
||||||
GE( ctx, glDepthMask (FALSE) );
|
|
||||||
|
|
||||||
if (merge)
|
|
||||||
{
|
|
||||||
GE (ctx, glStencilMask (2));
|
|
||||||
GE (ctx, glStencilFunc (GL_LEQUAL, 0x2, 0x6));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* If we're not using the stencil buffer for clipping then we
|
|
||||||
don't need to clear the whole stencil buffer, just the area
|
|
||||||
that will be drawn */
|
|
||||||
if (need_clear)
|
|
||||||
/* If this is being called from the clip stack code then it
|
|
||||||
will have set up a scissor for the minimum bounding box of
|
|
||||||
all of the clips. That box will likely mean that this
|
|
||||||
_cogl_clear won't need to clear the entire
|
|
||||||
buffer. _cogl_framebuffer_clear_without_flush4f is used instead
|
|
||||||
of cogl_clear because it won't try to flush the journal */
|
|
||||||
_cogl_framebuffer_clear_without_flush4f (framebuffer,
|
|
||||||
COGL_BUFFER_BIT_STENCIL,
|
|
||||||
0, 0, 0, 0);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Just clear the bounding box */
|
|
||||||
GE( ctx, glStencilMask (~(GLuint) 0) );
|
|
||||||
GE( ctx, glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO) );
|
|
||||||
_cogl_rectangle_immediate (framebuffer,
|
|
||||||
ctx->stencil_pipeline,
|
|
||||||
bounds_x1, bounds_y1,
|
|
||||||
bounds_x2, bounds_y2);
|
|
||||||
}
|
|
||||||
GE (ctx, glStencilMask (1));
|
|
||||||
GE (ctx, glStencilFunc (GL_LEQUAL, 0x1, 0x3));
|
|
||||||
}
|
|
||||||
|
|
||||||
GE (ctx, glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT));
|
|
||||||
|
|
||||||
silhouette_callback (framebuffer, ctx->stencil_pipeline, user_data);
|
|
||||||
|
|
||||||
if (merge)
|
|
||||||
{
|
|
||||||
/* Now we have the new stencil buffer in bit 1 and the old
|
|
||||||
stencil buffer in bit 0 so we need to intersect them */
|
|
||||||
GE (ctx, glStencilMask (3));
|
|
||||||
GE (ctx, glStencilFunc (GL_NEVER, 0x2, 0x3));
|
|
||||||
GE (ctx, glStencilOp (GL_DECR, GL_DECR, GL_DECR));
|
|
||||||
/* Decrement all of the bits twice so that only pixels where the
|
|
||||||
value is 3 will remain */
|
|
||||||
|
|
||||||
ctx->current_projection_entry = &ctx->identity_entry;
|
|
||||||
ctx->current_modelview_entry = &ctx->identity_entry;
|
|
||||||
|
|
||||||
_cogl_rectangle_immediate (framebuffer, ctx->stencil_pipeline,
|
|
||||||
-1.0, -1.0, 1.0, 1.0);
|
|
||||||
_cogl_rectangle_immediate (framebuffer, ctx->stencil_pipeline,
|
|
||||||
-1.0, -1.0, 1.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->current_projection_entry = old_projection_entry;
|
|
||||||
ctx->current_modelview_entry = old_modelview_entry;
|
|
||||||
|
|
||||||
GE (ctx, glStencilMask (~(GLuint) 0));
|
|
||||||
GE (ctx, glDepthMask (TRUE));
|
|
||||||
GE (ctx, glColorMask (TRUE, TRUE, TRUE, TRUE));
|
|
||||||
|
|
||||||
GE (ctx, glStencilFunc (GL_EQUAL, 0x1, 0x1));
|
|
||||||
GE (ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
paint_primitive_silhouette (CoglFramebuffer *framebuffer,
|
|
||||||
CoglPipeline *pipeline,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
_cogl_primitive_draw (user_data,
|
|
||||||
framebuffer,
|
|
||||||
pipeline,
|
|
||||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
|
||||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
|
||||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_stencil_clip_primitive (CoglFramebuffer *framebuffer,
|
|
||||||
CoglMatrixEntry *modelview_entry,
|
|
||||||
CoglPrimitive *primitive,
|
|
||||||
float bounds_x1,
|
|
||||||
float bounds_y1,
|
|
||||||
float bounds_x2,
|
|
||||||
float bounds_y2,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean need_clear)
|
|
||||||
{
|
|
||||||
add_stencil_clip_silhouette (framebuffer,
|
|
||||||
paint_primitive_silhouette,
|
|
||||||
modelview_entry,
|
|
||||||
bounds_x1,
|
|
||||||
bounds_y1,
|
|
||||||
bounds_x2,
|
|
||||||
bounds_y2,
|
|
||||||
merge,
|
|
||||||
need_clear,
|
|
||||||
primitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_gl_flush (CoglClipStack *stack,
|
_cogl_clip_stack_gl_flush (CoglClipStack *stack,
|
||||||
CoglFramebuffer *framebuffer)
|
CoglFramebuffer *framebuffer)
|
||||||
@ -478,26 +336,6 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack,
|
|||||||
{
|
{
|
||||||
switch (entry->type)
|
switch (entry->type)
|
||||||
{
|
{
|
||||||
case COGL_CLIP_STACK_PRIMITIVE:
|
|
||||||
{
|
|
||||||
CoglClipStackPrimitive *primitive_entry =
|
|
||||||
(CoglClipStackPrimitive *) entry;
|
|
||||||
|
|
||||||
COGL_NOTE (CLIPPING, "Adding stencil clip for primitive");
|
|
||||||
|
|
||||||
add_stencil_clip_primitive (framebuffer,
|
|
||||||
primitive_entry->matrix_entry,
|
|
||||||
primitive_entry->primitive,
|
|
||||||
primitive_entry->bounds_x1,
|
|
||||||
primitive_entry->bounds_y1,
|
|
||||||
primitive_entry->bounds_x2,
|
|
||||||
primitive_entry->bounds_y2,
|
|
||||||
using_stencil_buffer,
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
using_stencil_buffer = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COGL_CLIP_STACK_RECT:
|
case COGL_CLIP_STACK_RECT:
|
||||||
{
|
{
|
||||||
CoglClipStackRect *rect = (CoglClipStackRect *) entry;
|
CoglClipStackRect *rect = (CoglClipStackRect *) entry;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user