[gtk/ngl-rect-borders: 1/2] gsk: Add gsk_border_node_get_uniform_color
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ngl-rect-borders: 1/2] gsk: Add gsk_border_node_get_uniform_color
- Date: Tue, 9 Mar 2021 02:38:58 +0000 (UTC)
commit 1fdd216d7fec228a9844ad27b62b00b33dc1e4a3
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 8 21:36:41 2021 -0500
gsk: Add gsk_border_node_get_uniform_color
Maintain this bit of information separately,
it will be useful in the next commit.
gsk/gskrendernodeimpl.c | 34 ++++++++++++++++++++++++----------
gsk/gskrendernodeprivate.h | 1 +
2 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index bab387cc2c..24f5abf1a5 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -1137,7 +1137,8 @@ struct _GskBorderNode
{
GskRenderNode render_node;
- bool uniform: 1;
+ bool uniform_width: 1;
+ bool uniform_color: 1;
GskRoundedRect outline;
float border_width[4];
GdkRGBA border_color[4];
@@ -1286,16 +1287,18 @@ gsk_border_node_diff (GskRenderNode *node1,
{
GskBorderNode *self1 = (GskBorderNode *) node1;
GskBorderNode *self2 = (GskBorderNode *) node2;
+ gboolean uniform1 = self1->uniform_width && self1->uniform_color;
+ gboolean uniform2 = self2->uniform_width && self2->uniform_color;
- if (self1->uniform &&
- self2->uniform &&
+ if (uniform1 &&
+ uniform2 &&
self1->border_width[0] == self2->border_width[0] &&
gsk_rounded_rect_equal (&self1->outline, &self2->outline) &&
gdk_rgba_equal (&self1->border_color[0], &self2->border_color[0]))
return;
/* Different uniformity -> diff impossible */
- if (self1->uniform ^ self2->uniform)
+ if (uniform1 ^ uniform1)
{
gsk_render_node_diff_impossible (node1, node2, region);
return;
@@ -1401,14 +1404,17 @@ gsk_border_node_new (const GskRoundedRect *outline,
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]) &&
+ border_width[0] == border_width[3])
+ self->uniform_width = TRUE;
+ else
+ self->uniform_width = FALSE;
+
+ if (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;
+ self->uniform_color = TRUE;
else
- self->uniform = FALSE;
-
+ self->uniform_color = FALSE;
graphene_rect_init_from_rect (&node->bounds, &self->outline.bounds);
@@ -1419,7 +1425,15 @@ gsk_border_node_new (const GskRoundedRect *outline,
bool
gsk_border_node_get_uniform (const GskRenderNode *self)
{
- return ((const GskBorderNode *)self)->uniform;
+ const GskBorderNode *node = (const GskBorderNode *)self;
+ return node->uniform_width && node->uniform_color;
+}
+
+bool
+gsk_border_node_get_uniform_color (const GskRenderNode *self)
+{
+ const GskBorderNode *node = (const GskBorderNode *)self;
+ return node->uniform_color;
}
/*** GSK_TEXTURE_NODE ***/
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index dcc77037d7..07ec707c03 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -95,6 +95,7 @@ void gsk_render_node_diff_impossible (GskRenderNode
cairo_region_t *region);
bool gsk_border_node_get_uniform (const GskRenderNode *self);
+bool gsk_border_node_get_uniform_color (const GskRenderNode *self);
void gsk_text_node_serialize_glyphs (GskRenderNode *self,
GString *str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]