[gtk/matthiasc/for-master: 1/7] cssshadowvalue: Add gtk_css_shadow_value_pop_snapshot
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 1/7] cssshadowvalue: Add gtk_css_shadow_value_pop_snapshot
- Date: Sat, 6 Feb 2021 14:58:15 +0000 (UTC)
commit 92ddc7ac211aafb38bdd7a7dba14fc53836b65ed
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 6 09:00:32 2021 -0500
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.
gtk/gtkcssshadowvalue.c | 26 ++++++++++++++++++++++++--
gtk/gtkcssshadowvalueprivate.h | 4 +++-
2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 126e9af8f2..ba170c7cc9 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];
@@ -672,10 +673,9 @@ gboolean
gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot)
{
- gboolean need_shadow = FALSE;
+ gboolean need_shadow;
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];
@@ -706,3 +706,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 5784dfa516..fd126bd6c9 100644
--- a/gtk/gtkcssshadowvalueprivate.h
+++ b/gtk/gtkcssshadowvalueprivate.h
@@ -34,7 +34,7 @@
G_BEGIN_DECLS
-GtkCssValue * gtk_css_shadow_value_new_none (void);
+GtkCssValue * gtk_css_shadow_value_new_none (void);
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode);
@@ -53,6 +53,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]