From 656ccb4dee9d8236c4e91c1e2fc13b22f8793722 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 16 May 2023 18:53:56 -0300 Subject: [PATCH 1/2] cogl/framebuffer: Remove scissor clip It's unused. Spotted while discussing snapshot APIs. Part-of: --- cogl/cogl/cogl-framebuffer.c | 21 --------------------- cogl/cogl/cogl-framebuffer.h | 28 ++-------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index c01ef8d8e11..ecc62400002 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -2009,27 +2009,6 @@ cogl_framebuffer_set_projection_matrix (CoglFramebuffer *framebuffer, } } -void -cogl_framebuffer_push_scissor_clip (CoglFramebuffer *framebuffer, - int x, - int y, - int width, - int height) -{ - CoglFramebufferPrivate *priv = - cogl_framebuffer_get_instance_private (framebuffer); - - priv->clip_stack = - _cogl_clip_stack_push_window_rectangle (priv->clip_stack, - x, y, width, height); - - if (priv->context->current_draw_buffer == framebuffer) - { - priv->context->current_draw_buffer_changes |= - COGL_FRAMEBUFFER_STATE_CLIP; - } -} - void cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer, float x_1, diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index e89b8f3a7f4..3c7f472df63 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -470,30 +470,6 @@ COGL_EXPORT void cogl_framebuffer_set_projection_matrix (CoglFramebuffer *framebuffer, const graphene_matrix_t *matrix); -/** - * cogl_framebuffer_push_scissor_clip: - * @framebuffer: A #CoglFramebuffer pointer - * @x: left edge of the clip rectangle in window coordinates - * @y: top edge of the clip rectangle in window coordinates - * @width: width of the clip rectangle - * @height: height of the clip rectangle - * - * Specifies a rectangular clipping area for all subsequent drawing - * operations. Any drawing commands that extend outside the rectangle - * will be clipped so that only the portion inside the rectangle will - * be displayed. The rectangle dimensions are not transformed by the - * current model-view matrix. - * - * The rectangle is intersected with the current clip region. To undo - * the effect of this function, call cogl_framebuffer_pop_clip(). - */ -COGL_EXPORT void -cogl_framebuffer_push_scissor_clip (CoglFramebuffer *framebuffer, - int x, - int y, - int width, - int height); - /** * cogl_framebuffer_push_rectangle_clip: * @framebuffer: A #CoglFramebuffer pointer @@ -561,8 +537,8 @@ cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer, * @framebuffer: A #CoglFramebuffer pointer * * Reverts the clipping region to the state before the last call to - * cogl_framebuffer_push_scissor_clip(), cogl_framebuffer_push_rectangle_clip() - * cogl_framebuffer_push_path_clip(), or cogl_framebuffer_push_primitive_clip(). + * cogl_framebuffer_push_rectangle_clip(), or + * cogl_framebuffer_push_primitive_clip(). */ COGL_EXPORT void cogl_framebuffer_pop_clip (CoglFramebuffer *framebuffer); -- GitLab From 3b7ca42c6f5d06874a31d5435cfd58ea68032d24 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 16 May 2023 18:57:42 -0300 Subject: [PATCH 2/2] cogl/clip-stack: Removing window rect The only consumer of this type of rect was the scissor clipping, which was removed by the previous commit. Remove window rects from CoglClipStack, and all dependent code. Part-of: --- cogl/cogl/cogl-clip-stack.c | 24 ------------------------ cogl/cogl/cogl-clip-stack.h | 16 ---------------- cogl/cogl/cogl-journal.c | 14 +------------- cogl/cogl/driver/gl/cogl-clip-stack-gl.c | 5 ----- 4 files changed, 1 insertion(+), 58 deletions(-) diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c index 4212810aef7..74f031beaa3 100644 --- a/cogl/cogl/cogl-clip-stack.c +++ b/cogl/cogl/cogl-clip-stack.c @@ -127,27 +127,6 @@ _cogl_clip_stack_entry_set_bounds (CoglClipStack *entry, entry->bounds_y1 = ceilf (max_y); } -CoglClipStack * -_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack, - int x_offset, - int y_offset, - int width, - int height) -{ - CoglClipStack *entry; - - entry = _cogl_clip_stack_push_entry (stack, - sizeof (CoglClipStackWindowRect), - COGL_CLIP_STACK_WINDOW_RECT); - - entry->bounds_x0 = x_offset; - entry->bounds_x1 = x_offset + width; - entry->bounds_y0 = y_offset; - entry->bounds_y1 = y_offset + height; - - return entry; -} - CoglClipStack * _cogl_clip_stack_push_rectangle (CoglClipStack *stack, float x_1, @@ -344,9 +323,6 @@ _cogl_clip_stack_unref (CoglClipStack *entry) g_free (entry); break; } - case COGL_CLIP_STACK_WINDOW_RECT: - g_free (entry); - break; case COGL_CLIP_STACK_PRIMITIVE: { CoglClipStackPrimitive *primitive_entry = diff --git a/cogl/cogl/cogl-clip-stack.h b/cogl/cogl/cogl-clip-stack.h index 2efaa277745..3df72b36edd 100644 --- a/cogl/cogl/cogl-clip-stack.h +++ b/cogl/cogl/cogl-clip-stack.h @@ -52,7 +52,6 @@ typedef struct _CoglClipStackRegion CoglClipStackRegion; typedef enum { COGL_CLIP_STACK_RECT, - COGL_CLIP_STACK_WINDOW_RECT, COGL_CLIP_STACK_PRIMITIVE, COGL_CLIP_STACK_REGION, } CoglClipStackType; @@ -140,14 +139,6 @@ struct _CoglClipStackRect gboolean can_be_scissor; }; -struct _CoglClipStackWindowRect -{ - CoglClipStack _parent_data; - - /* The window rect clip doesn't need any specific data because it - just adds to the scissor clip */ -}; - struct _CoglClipStackPrimitive { CoglClipStack _parent_data; @@ -170,13 +161,6 @@ struct _CoglClipStackRegion cairo_region_t *region; }; -CoglClipStack * -_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack, - int x_offset, - int y_offset, - int width, - int height); - COGL_EXPORT CoglClipStack * _cogl_clip_stack_push_rectangle (CoglClipStack *stack, float x_1, diff --git a/cogl/cogl/cogl-journal.c b/cogl/cogl/cogl-journal.c index 4ed508a7f64..becdc0f7fdb 100644 --- a/cogl/cogl/cogl-journal.c +++ b/cogl/cogl/cogl-journal.c @@ -1733,7 +1733,6 @@ try_checking_point_hits_entry_after_clipping (CoglFramebuffer *framebuffer, float y, gboolean *hit) { - gboolean can_software_clip = TRUE; gboolean needs_software_clip = FALSE; CoglClipStack *clip_entry; @@ -1754,15 +1753,7 @@ try_checking_point_hits_entry_after_clipping (CoglFramebuffer *framebuffer, return TRUE; } - if (clip_entry->type == COGL_CLIP_STACK_WINDOW_RECT) - { - /* XXX: technically we could still run the software clip in - * this case because for our purposes we know this clip - * can be ignored now, but [can_]sofware_clip_entry() doesn't - * know this and will bail out. */ - can_software_clip = FALSE; - } - else if (clip_entry->type == COGL_CLIP_STACK_RECT) + if (clip_entry->type == COGL_CLIP_STACK_RECT) { CoglClipStackRect *rect_entry = (CoglClipStackRect *)entry; @@ -1781,9 +1772,6 @@ try_checking_point_hits_entry_after_clipping (CoglFramebuffer *framebuffer, ClipBounds clip_bounds; float poly[16]; - if (!can_software_clip) - return FALSE; - if (!can_software_clip_entry (entry, NULL, entry->clip_stack, &clip_bounds)) return FALSE; diff --git a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c index a693903b3ce..366cab3a18e 100644 --- a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c +++ b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c @@ -536,11 +536,6 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack, } break; } - case COGL_CLIP_STACK_WINDOW_RECT: - break; - /* We don't need to do anything for window space rectangles because - * their functionality is entirely implemented by the entry bounding - * box */ } } } -- GitLab