summaryrefslogtreecommitdiff
path: root/gtk/gtkcssshadowsvalue.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-10-28 16:10:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-10-28 16:10:46 -0400
commit598d22d194a51304277fb2eb174576aaa8185b7d (patch)
tree963f460d93d5c1c13ce4b6d1055ff93b000d0389 /gtk/gtkcssshadowsvalue.c
parent99d3d31314666b836be45d8adea1f17cee8d3cdd (diff)
downloadgtk+-598d22d194a51304277fb2eb174576aaa8185b7d.tar.gz
Avoid creating trivial shadow nodes
The Vulkan renderer creates a fallback surface for each shadow node, even if we end up not rendering anything to it. Avoiding this is a nice optimization.
Diffstat (limited to 'gtk/gtkcssshadowsvalue.c')
-rw-r--r--gtk/gtkcssshadowsvalue.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index bd687dc156..fcb6097cea 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -24,6 +24,7 @@
#include <math.h>
#include "gtkcssshadowvalueprivate.h"
+#include "gtksnapshot.h"
#include <string.h>
@@ -393,3 +394,29 @@ _gtk_css_shadows_value_get_extents (const GtkCssValue *shadows,
*border = b;
}
+
+gboolean
+gtk_css_shadows_value_push_snapshot (const GtkCssValue *value,
+ GtkSnapshot *snapshot)
+{
+ gboolean need_shadow = FALSE;
+ int i;
+
+ for (i = 0; i < value->len; i++)
+ {
+ if (!gtk_css_shadow_value_is_clear (value->values[i]))
+ {
+ need_shadow = TRUE;
+ break;
+ }
+ }
+
+ if (need_shadow)
+ {
+ GskShadow *shadows = g_newa (GskShadow, value->len);
+ gtk_css_shadows_value_get_shadows (value, shadows);
+ gtk_snapshot_push_shadow (snapshot, shadows, value->len, "Shadow<%u>", value->len);
+ }
+
+ return need_shadow;
+}