diff options
author | Timm Bäder <mail@baedert.org> | 2020-07-24 15:59:45 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-07-28 05:34:11 +0200 |
commit | 2fa9dddea6369a1a7dea0e4770be94c006c7d0ba (patch) | |
tree | 5d111271fe977a6eebccea6ee4ef710325784466 /gsk | |
parent | 72d4a83af81ec86581fb5b9cee863f37ab677063 (diff) | |
download | gtk+-2fa9dddea6369a1a7dea0e4770be94c006c7d0ba.tar.gz |
gsk: Remember border node uniformity
Lots of border nodes have all the same width and the same color.
Renderers might be able to simplifty that, so keep an extra bit per
border node.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gl/gskglrenderer.c | 7 | ||||
-rw-r--r-- | gsk/gskrendernodeimpl.c | 25 | ||||
-rw-r--r-- | gsk/gskrendernodeprivate.h | 2 |
3 files changed, 25 insertions, 9 deletions
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 81b9302f6d..1b188fddfe 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -735,12 +735,7 @@ render_border_node (GskGLRenderer *self, float h; } sizes[4]; - if (widths[0] == widths[1] && - widths[0] == widths[2] && - widths[0] == widths[3] && - gdk_rgba_equal (&colors[0], &colors[1]) && - gdk_rgba_equal (&colors[0], &colors[2]) && - gdk_rgba_equal (&colors[0], &colors[3])) + if (gsk_border_node_get_uniform (node)) { ops_set_program (builder, &self->programs->inset_shadow_program); ops_set_inset_shadow (builder, transform_rect (self, builder, rounded_outline), diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 05430bea8d..9879cdff12 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -392,6 +392,7 @@ struct _GskBorderNode { GskRenderNode render_node; + bool uniform: 1; GskRoundedRect outline; float border_width[4]; GdkRGBA border_color[4]; @@ -620,9 +621,9 @@ gsk_border_node_peek_colors (GskRenderNode *node) * Returns: (transfer full) (type GskBorderNode): A new #GskRenderNode */ GskRenderNode * -gsk_border_node_new (const GskRoundedRect *outline, - const float border_width[4], - const GdkRGBA border_color[4]) +gsk_border_node_new (const GskRoundedRect *outline, + const float border_width[4], + const GdkRGBA border_color[4]) { GskBorderNode *self; GskRenderNode *node; @@ -638,11 +639,29 @@ gsk_border_node_new (const GskRoundedRect *outline, memcpy (self->border_width, border_width, sizeof (self->border_width)); memcpy (self->border_color, border_color, sizeof (self->border_color)); + if (border_width[0] == border_width[1] && + border_width[0] == border_width[2] && + border_width[0] == border_width[3] && + gdk_rgba_equal (&border_color[0], &border_color[1]) && + gdk_rgba_equal (&border_color[0], &border_color[2]) && + gdk_rgba_equal (&border_color[0], &border_color[3])) + self->uniform = TRUE; + else + self->uniform = FALSE; + + graphene_rect_init_from_rect (&node->bounds, &self->outline.bounds); return node; } +/** Private */ +bool +gsk_border_node_get_uniform (GskRenderNode *self) +{ + return ((GskBorderNode *)self)->uniform; +} + /*** GSK_TEXTURE_NODE ***/ struct _GskTextureNode diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h index c1b5809b4e..d75a2c68b1 100644 --- a/gsk/gskrendernodeprivate.h +++ b/gsk/gskrendernodeprivate.h @@ -94,6 +94,8 @@ void gsk_render_node_diff_impossible (GskRenderNode GskRenderNode *node2, cairo_region_t *region); +bool gsk_border_node_get_uniform (GskRenderNode *self); + G_END_DECLS #endif /* __GSK_RENDER_NODE_PRIVATE_H__ */ |