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.
This commit is contained in:
Timm Bäder 2020-07-24 15:59:45 +02:00
parent 72d4a83af8
commit 2fa9dddea6
3 changed files with 25 additions and 9 deletions

View File

@ -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),

View File

@ -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

View File

@ -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__ */