diff options
author | Alexander Larsson <alexl@redhat.com> | 2017-01-11 10:08:58 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2017-01-11 10:22:40 +0100 |
commit | 65ad2541d736a699d01642096631984be7d64681 (patch) | |
tree | 492d999fd786accf1330ecb74adb37ae8bf3e1ab | |
parent | 2f453cc57e37638178f0cf2241609e829963af51 (diff) | |
download | gtk+-65ad2541d736a699d01642096631984be7d64681.tar.gz |
Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are
not used.
-rw-r--r-- | gtk/gtkcssimage.c | 2 | ||||
-rw-r--r-- | gtk/gtkcssimagecrossfade.c | 3 | ||||
-rw-r--r-- | gtk/gtkcssimagelinear.c | 9 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalue.c | 8 | ||||
-rw-r--r-- | gtk/gtkiconview.c | 2 | ||||
-rw-r--r-- | gtk/gtkrenderbackground.c | 3 | ||||
-rw-r--r-- | gtk/gtkrenderborder.c | 3 | ||||
-rw-r--r-- | gtk/gtksnapshot.c | 50 | ||||
-rw-r--r-- | gtk/gtksnapshotprivate.h | 5 | ||||
-rw-r--r-- | gtk/gtkstack.c | 10 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 2 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 3 | ||||
-rw-r--r-- | gtk/inspector/window.c | 16 | ||||
-rw-r--r-- | gtk/inspector/window.h | 1 |
14 files changed, 79 insertions, 38 deletions
diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c index d45a3f78d4..aa407f486c 100644 --- a/gtk/gtkcssimage.c +++ b/gtk/gtkcssimage.c @@ -107,7 +107,7 @@ gtk_css_image_real_draw (GtkCssImage *image, cairo_region_t *clip; clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height }); - gtk_snapshot_init (&snapshot, NULL, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image)); + gtk_snapshot_init (&snapshot, NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image)); gtk_css_image_snapshot (image, &snapshot, width, height); node = gtk_snapshot_finish (&snapshot); diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index 60e922480e..2b9aab1271 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -141,7 +141,8 @@ gtk_css_image_cross_fade_snapshot (GtkCssImage *image, { GskRenderNode *node = gsk_cross_fade_node_new (start_node, end_node, cross_fade->progress); - gsk_render_node_set_name (node, "CrossFade"); + if (snapshot->record_names) + gsk_render_node_set_name (node, "CrossFade"); gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 5841e1508f..592180a020 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -254,9 +254,12 @@ gtk_css_image_linear_snapshot (GtkCssImage *image, linear->stops->len); } - name = g_strdup_printf ("%sLinearGradient<%ustops>", linear->repeating ? "Repeating" : "", linear->stops->len); - gsk_render_node_set_name (node, name); - g_free (name); + if (snapshot->record_names) + { + name = g_strdup_printf ("%sLinearGradient<%ustops>", linear->repeating ? "Repeating" : "", linear->stops->len); + gsk_render_node_set_name (node, name); + g_free (name); + } gtk_snapshot_append_node (snapshot, node); diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 5bbb315e41..1be9708159 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -24,7 +24,7 @@ #include "gtkcsscolorvalueprivate.h" #include "gtkcssnumbervalueprivate.h" #include "gtkcssrgbavalueprivate.h" -#include "gtksnapshot.h" +#include "gtksnapshotprivate.h" #include "gtkstylecontextprivate.h" #include "gtkpango.h" @@ -1057,7 +1057,8 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *shadow, _gtk_css_number_value_get (shadow->voffset, 0), _gtk_css_number_value_get (shadow->spread, 0), _gtk_css_number_value_get (shadow->radius, 0)); - gsk_render_node_set_name (node, "Outset Shadow"); + if (snapshot->record_names) + gsk_render_node_set_name (node, "Outset Shadow"); gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); } @@ -1087,7 +1088,8 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *shadow, _gtk_css_number_value_get (shadow->voffset, 0), _gtk_css_number_value_get (shadow->spread, 0), _gtk_css_number_value_get (shadow->radius, 0)); - gsk_render_node_set_name (node, "Inset Shadow"); + if (snapshot->record_names) + gsk_render_node_set_name (node, "Inset Shadow"); gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); } diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index e3690ad9f4..6f092fb539 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -7013,7 +7013,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view, rect.width, rect.height); - gtk_snapshot_init (&snapshot, NULL, NULL, "IconView DragIcon"); + gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "IconView DragIcon"); gtk_icon_view_snapshot_item (icon_view, &snapshot, item, icon_view->priv->item_padding, icon_view->priv->item_padding, diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c index 67e8d4fc1b..e52d1de3b7 100644 --- a/gtk/gtkrenderbackground.c +++ b/gtk/gtkrenderbackground.c @@ -681,7 +681,8 @@ gtk_css_style_snapshot_background (GtkCssStyle *style, bottom = gsk_container_node_new (NULL, 0); blend = gsk_blend_node_new (bottom, top, blend_mode); - gsk_render_node_set_name (blend, "BackgroundBlend"); + if (snapshot->record_names) + gsk_render_node_set_name (blend, "BackgroundBlend"); gtk_snapshot_push (snapshot, TRUE, "BackgroundBlendGroup"); gtk_snapshot_append_node (snapshot, blend); diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c index d6223c441f..31f5725efb 100644 --- a/gtk/gtkrenderborder.c +++ b/gtk/gtkrenderborder.c @@ -438,7 +438,8 @@ snapshot_frame_fill (GtkSnapshot *snapshot, gsk_rounded_rect_offset (&offset_outline, off_x, off_y); node = gsk_border_node_new (&offset_outline, border_width, colors); - gsk_render_node_set_name (node, "Border"); + if (snapshot->record_names) + gsk_render_node_set_name (node, "Border"); gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); } diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 76adc59516..eb788090b6 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -67,7 +67,8 @@ gtk_snapshot_collect_default (GskRenderNode **nodes, else { node = gsk_container_node_new (nodes, n_nodes); - gsk_render_node_set_name (node, name); + if (name) + gsk_render_node_set_name (node, name); } return node; @@ -116,6 +117,7 @@ gtk_snapshot_state_free (GtkSnapshotState *state) void gtk_snapshot_init (GtkSnapshot *snapshot, GskRenderer *renderer, + gboolean record_names, const cairo_region_t *clip, const char *name, ...) @@ -123,9 +125,10 @@ gtk_snapshot_init (GtkSnapshot *snapshot, char *str; snapshot->state = NULL; + snapshot->record_names = record_names; snapshot->renderer = renderer; - if (name) + if (name && record_names) { va_list args; @@ -181,7 +184,7 @@ gtk_snapshot_push (GtkSnapshot *snapshot, { char *str; - if (name) + if (name && snapshot->record_names) { va_list args; @@ -226,7 +229,8 @@ gtk_snapshot_collect_transform (GskRenderNode **nodes, return NULL; transform_node = gsk_transform_node_new (node, transform); - gsk_render_node_set_name (transform_node, name); + if (name) + gsk_render_node_set_name (transform_node, name); gsk_render_node_unref (node); g_slice_free (graphene_matrix_t, transform); @@ -255,7 +259,7 @@ gtk_snapshot_push_transform (GtkSnapshot *snapshot, char *str; - if (name) + if (name && snapshot->record_names) { va_list args; @@ -287,7 +291,8 @@ gtk_snapshot_collect_opacity (GskRenderNode **nodes, return NULL; opacity_node = gsk_opacity_node_new (node, *(double *) opacity); - gsk_render_node_set_name (opacity_node, name); + if (name) + gsk_render_node_set_name (opacity_node, name); gsk_render_node_unref (node); g_free (opacity); @@ -310,7 +315,7 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot, double *real_opacity; char *str; - if (name) + if (name && snapshot->record_names) { va_list args; @@ -348,7 +353,8 @@ gtk_snapshot_collect_color_matrix (GskRenderNode **nodes, color_matrix_node = gsk_color_matrix_node_new (node, &color_matrix->matrix, &color_matrix->offset); - gsk_render_node_set_name (color_matrix_node, name); + if (name) + gsk_render_node_set_name (color_matrix_node, name); gsk_render_node_unref (node); g_free (color_matrix); @@ -366,7 +372,7 @@ gtk_snapshot_push_color_matrix (GtkSnapshot *snapshot, ColorMatrix *color_matrix_data; char *str; - if (name) + if (name && snapshot->record_names) { va_list args; @@ -416,7 +422,8 @@ gtk_snapshot_collect_repeat (GskRenderNode **nodes, repeat_node = gsk_repeat_node_new (&bounds[0], node, bounds[1].size.width > 0 ? &bounds[1] : NULL); - gsk_render_node_set_name (repeat_node, name); + if (name) + gsk_render_node_set_name (repeat_node, name); gsk_render_node_unref (node); g_free (data); @@ -435,7 +442,7 @@ gtk_snapshot_push_repeat (GtkSnapshot *snapshot, graphene_rect_t *data; char *str; - if (name) + if (name && snapshot->record_names) { va_list args; @@ -483,7 +490,8 @@ gtk_snapshot_collect_clip (GskRenderNode **nodes, return NULL; clip_node = gsk_clip_node_new (node, bounds); - gsk_render_node_set_name (clip_node, name); + if (name) + gsk_render_node_set_name (clip_node, name); gsk_render_node_unref (node); g_slice_free (graphene_rect_t, bounds); @@ -505,7 +513,7 @@ gtk_snapshot_push_clip (GtkSnapshot *snapshot, real_bounds = g_slice_new (graphene_rect_t); graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, real_bounds); - if (name) + if (name && snapshot->record_names) { va_list args; @@ -550,7 +558,8 @@ gtk_snapshot_collect_rounded_clip (GskRenderNode **nodes, return NULL; clip_node = gsk_rounded_clip_node_new (node, bounds); - gsk_render_node_set_name (clip_node, name); + if (name) + gsk_render_node_set_name (clip_node, name); gsk_render_node_unref (node); g_slice_free (GskRoundedRect, bounds); @@ -573,7 +582,7 @@ gtk_snapshot_push_rounded_clip (GtkSnapshot *snapshot, gsk_rounded_rect_init_copy (real_bounds, bounds); gsk_rounded_rect_offset (real_bounds, snapshot->state->translate_x, snapshot->state->translate_y); - if (name) + if (name && snapshot->record_names) { va_list args; @@ -624,7 +633,8 @@ gtk_snapshot_collect_shadow (GskRenderNode **nodes, return NULL; shadow_node = gsk_shadow_node_new (node, shadow->shadows, shadow->n_shadows); - gsk_render_node_set_name (shadow_node, name); + if (name) + gsk_render_node_set_name (shadow_node, name); gsk_render_node_unref (node); g_free (shadow); @@ -646,7 +656,7 @@ gtk_snapshot_push_shadow (GtkSnapshot *snapshot, real_shadow->n_shadows = n_shadows; memcpy (real_shadow->shadows, shadow, sizeof (GskShadow) * n_shadows); - if (name) + if (name && snapshot->record_names) { va_list args; @@ -849,7 +859,7 @@ gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot, graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &real_bounds); node = gsk_cairo_node_new (&real_bounds); - if (name) + if (name && snapshot->record_names) { va_list args; char *str; @@ -901,7 +911,7 @@ gtk_snapshot_append_texture_node (GtkSnapshot *snapshot, graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &real_bounds); node = gsk_texture_node_new (texture, &real_bounds); - if (name) + if (name && snapshot->record_names) { va_list args; char *str; @@ -949,7 +959,7 @@ gtk_snapshot_append_color_node (GtkSnapshot *snapshot, graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &real_bounds); node = gsk_color_node_new (color, &real_bounds); - if (name) + if (name && snapshot->record_names) { va_list args; char *str; diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 7eba0f48cc..a06383bb1c 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -45,15 +45,16 @@ struct _GtkSnapshotState { struct _GtkSnapshot { GtkSnapshotState *state; - + gboolean record_names; GskRenderer *renderer; }; void gtk_snapshot_init (GtkSnapshot *state, GskRenderer *renderer, + gboolean record_names, const cairo_region_t *clip, const char *name, - ...) G_GNUC_PRINTF (4, 5); + ...) G_GNUC_PRINTF (5, 6); GskRenderNode * gtk_snapshot_finish (GtkSnapshot *state); GskRenderer * gtk_snapshot_get_renderer (const GtkSnapshot *snapshot); diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index a4ecbb5291..1021e50525 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -29,6 +29,7 @@ #include "gtkcontainerprivate.h" #include "gtkprogresstrackerprivate.h" #include "gtksettingsprivate.h" +#include "gtksnapshotprivate.h" #include "gtkwidgetprivate.h" #include "a11y/gtkstackaccessible.h" #include "a11y/gtkstackaccessibleprivate.h" @@ -1940,9 +1941,12 @@ gtk_stack_snapshot_crossfade (GtkWidget *widget, node = gsk_opacity_node_new (end_node, 1.0 - progress); } - name = g_strdup_printf ("CrossFade<%g>", progress); - gsk_render_node_set_name (node, name); - g_free (name); + if (snapshot->record_names) + { + name = g_strdup_printf ("CrossFade<%g>", progress); + gsk_render_node_set_name (node, name); + g_free (name); + } gtk_snapshot_append_node (snapshot, node); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 206d3c048d..f1dc8a9002 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -14175,7 +14175,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view, bin_window_width + 2, background_area.height + 2); - gtk_snapshot_init (&snapshot, NULL, NULL, "TreeView DragIcon"); + gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "TreeView DragIcon"); gtk_snapshot_render_background (&snapshot, context, 0, 0, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8624647533..14b2d6d7e1 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6388,7 +6388,7 @@ gtk_widget_draw_internal (GtkWidget *widget, widget->priv->clip.y - widget->priv->allocation.y, widget->priv->clip.width, widget->priv->clip.height}); - gtk_snapshot_init (&snapshot, renderer, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget)); + gtk_snapshot_init (&snapshot, renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget)); gtk_widget_snapshot (widget, &snapshot); node = gtk_snapshot_finish (&snapshot); if (node != NULL) @@ -15686,6 +15686,7 @@ gtk_widget_render (GtkWidget *widget, gtk_snapshot_init (&snapshot, renderer, + gtk_inspector_is_recording (widget), clip, "Render<%s>", G_OBJECT_TYPE_NAME (widget)); cairo_region_destroy (clip); diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index fb3231ee5c..beb44f9025 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -368,4 +368,20 @@ gtk_inspector_record_render (GtkWidget *widget, node); } +gboolean +gtk_inspector_is_recording (GtkWidget *widget) +{ + GtkInspectorWindow *iw; + + iw = gtk_inspector_window_get_for_display (gtk_widget_get_display (widget)); + if (iw == NULL) + return FALSE; + + /* sanity check for single-display GDK backends */ + if (GTK_WIDGET (iw) == widget) + return FALSE; + + return gtk_inspector_recorder_is_recording (GTK_INSPECTOR_RECORDER (iw->widget_recorder)); +} + // vim: set et sw=2 ts=2: diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h index 3f330d7af5..e0504a784c 100644 --- a/gtk/inspector/window.h +++ b/gtk/inspector/window.h @@ -106,6 +106,7 @@ void gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow void gtk_inspector_window_rescan (GtkWidget *iw); +gboolean gtk_inspector_is_recording (GtkWidget *widget); void gtk_inspector_record_render (GtkWidget *widget, GskRenderer *renderer, GdkWindow *window, |