diff options
| author | Matthias Clasen <mclasen@redhat.com> | 2020-12-05 14:20:17 -0500 |
|---|---|---|
| committer | Matthias Clasen <mclasen@redhat.com> | 2022-04-08 16:44:29 -0400 |
| commit | 31fe02e44905dfb80d6f6107e1113c4aa2c0138e (patch) | |
| tree | d026d74d132a470625788d95fb8cb6b4261b8923 | |
| parent | 068838eac4620f39d86c790cfe390805ed261344 (diff) | |
| download | gtk+-31fe02e44905dfb80d6f6107e1113c4aa2c0138e.tar.gz | |
contour: Special-case rects for strokes
In many cases, the outline of a rectangle is just
two rectangles.
| -rw-r--r-- | gsk/gskcontour.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c index b37de599e5..d399a7a4cf 100644 --- a/gsk/gskcontour.c +++ b/gsk/gskcontour.c @@ -495,11 +495,43 @@ gsk_rect_contour_get_stroke_bounds (const GskContour *contour, return TRUE; } +static gboolean +stroke_is_simple (GskStroke *stroke) +{ + if (stroke->line_join != GSK_LINE_JOIN_MITER && + stroke->line_join != GSK_LINE_JOIN_MITER_CLIP) + return FALSE; + + if (stroke->miter_limit < 1.5) + return FALSE; + + if (stroke->dash_length != 0) + return FALSE; + + return TRUE; +} + static void gsk_rect_contour_add_stroke (const GskContour *contour, GskPathBuilder *builder, GskStroke *stroke) { + const GskRectContour *self = (const GskRectContour *) contour; + + if (stroke_is_simple (stroke)) + { + graphene_rect_t rect; + + graphene_rect_init (&rect, self->x, self->y, self->width, self->height); + + graphene_rect_inset (&rect, stroke->line_width / 2, stroke->line_width / 2); + gsk_path_builder_add_rect (builder, &rect); + + graphene_rect_inset (&rect, - stroke->line_width, - stroke->line_width); + rect.origin.x += rect.size.width; + rect.size.width = - rect.size.width; + gsk_path_builder_add_rect (builder, &rect); + } } static const GskContourClass GSK_RECT_CONTOUR_CLASS = |
