diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-02-06 09:00:32 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-02-06 16:09:21 -0500 |
commit | 5b8896f1db5a4ffa57634b66ab2f916a981135a8 (patch) | |
tree | a84ab1e30ca9c3a4402a77feac1f0b3faa754ed2 | |
parent | 4e27de7df9b2925ca3d56fc01dc5360c95557ed0 (diff) | |
download | gtk+-5b8896f1db5a4ffa57634b66ab2f916a981135a8.tar.gz |
cssshadowvalue: Add gtk_css_shadow_value_pop_snapshot
This is the counterpart ot gtk_css_shadow_value_push_snapshot.
To make this easy, move the determination whether we need a
shadow out of the push function and save it.
-rw-r--r-- | gtk/gtkcssshadowvalue.c | 24 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalueprivate.h | 6 |
2 files changed, 27 insertions, 3 deletions
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index a691d157e2..f4d60c9bcd 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -308,6 +308,7 @@ gtk_css_shadow_value_new (ShadowValue *shadows, memcpy (retval->shadows, shadows, sizeof (ShadowValue) * n_shadows); retval->is_computed = TRUE; + for (i = 0; i < n_shadows; i++) { const ShadowValue *shadow = &retval->shadows[i]; @@ -706,7 +707,6 @@ gtk_css_shadow_value_push_snapshot (const GtkCssValue *value, gboolean need_shadow = FALSE; guint i; - /* TODO: We can save this as a flag once and then reuse it */ for (i = 0; i < value->n_shadows; i++) { const ShadowValue *shadow = &value->shadows[i]; @@ -737,3 +737,25 @@ gtk_css_shadow_value_push_snapshot (const GtkCssValue *value, return need_shadow; } + +void +gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value, + GtkSnapshot *snapshot) +{ + gboolean need_shadow = FALSE; + guint i; + + for (i = 0; i < value->n_shadows; i++) + { + const ShadowValue *shadow = &value->shadows[i]; + + if (!gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color))) + { + need_shadow = TRUE; + break; + } + } + + if (need_shadow) + gtk_snapshot_pop (snapshot); +} diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h index fa2050e080..21efac1908 100644 --- a/gtk/gtkcssshadowvalueprivate.h +++ b/gtk/gtkcssshadowvalueprivate.h @@ -34,12 +34,12 @@ G_BEGIN_DECLS -GtkCssValue * gtk_css_shadow_value_new_none (void); +GtkCssValue * gtk_css_shadow_value_new_none (void); GtkCssValue * gtk_css_shadow_value_new_filter (void); GtkCssValue * gtk_css_shadow_value_parse (GtkCssParser *parser, gboolean box_shadow_mode); -GtkCssValue * _gtk_css_shadow_value_parse_filter (GtkCssParser *parser); +GtkCssValue * gtk_css_shadow_value_parse_filter (GtkCssParser *parser); void gtk_css_shadow_value_get_extents (const GtkCssValue *shadow, GtkBorder *border); @@ -55,6 +55,8 @@ gboolean gtk_css_shadow_value_is_none (const GtkCssValue gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue *value, GtkSnapshot *snapshot); +void gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value, + GtkSnapshot *snapshot); G_END_DECLS |