[gtk/wip/baedert/for-master: 18/23] layoutoverlay: Avoid adding 0 sized color nodes
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 18/23] layoutoverlay: Avoid adding 0 sized color nodes
- Date: Mon, 21 Dec 2020 09:26:12 +0000 (UTC)
commit 2feac2772fe79aadd9e0811b7ff8d44c19a276a6
Author: Timm Bäder <mail baedert org>
Date: Mon Dec 21 08:30:51 2020 +0100
layoutoverlay: Avoid adding 0 sized color nodes
This way, the output node file of the listbox demo in gtk4-demo with
enabled layout borders is only 3.8MB instead of 12MB.
gtk/inspector/layoutoverlay.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gtk/inspector/layoutoverlay.c b/gtk/inspector/layoutoverlay.c
index 74f4084084..3924f03bb8 100644
--- a/gtk/inspector/layoutoverlay.c
+++ b/gtk/inspector/layoutoverlay.c
@@ -65,9 +65,9 @@ static void
recurse_child_widgets (GtkWidget *widget,
GtkSnapshot *snapshot)
{
- gboolean needs_clip;
int width = gtk_widget_get_width (widget);
int height = gtk_widget_get_height (widget);
+ gboolean needs_clip;
GtkCssStyle *style;
GtkWidget *child;
GtkBorder boxes[4];
@@ -107,14 +107,18 @@ recurse_child_widgets (GtkWidget *widget,
const GdkRGBA *color = &colors[i];
const GtkBorder *box = &boxes[i];
- gtk_snapshot_append_color (snapshot, color,
- &GRAPHENE_RECT_INIT ( 0, - box->top, width, box->top));
- gtk_snapshot_append_color (snapshot, color,
- &GRAPHENE_RECT_INIT (width, 0, box->right, height));
- gtk_snapshot_append_color (snapshot, color,
- &GRAPHENE_RECT_INIT (0, height, width, box->bottom));
- gtk_snapshot_append_color (snapshot, color,
- &GRAPHENE_RECT_INIT (- box->left, 0, box->left, height));
+ if (box->top > 0)
+ gtk_snapshot_append_color (snapshot, color,
+ &GRAPHENE_RECT_INIT ( 0, - box->top, width, box->top));
+ if (box->right > 0)
+ gtk_snapshot_append_color (snapshot, color,
+ &GRAPHENE_RECT_INIT (width, 0, box->right, height));
+ if (box->bottom > 0)
+ gtk_snapshot_append_color (snapshot, color,
+ &GRAPHENE_RECT_INIT (0, height, width, box->bottom));
+ if (box->left > 0)
+ gtk_snapshot_append_color (snapshot, color,
+ &GRAPHENE_RECT_INIT (- box->left, 0, box->left, height));
/* Grow box + offset */
width += box->left + box->right;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]