forked from AuroraMiddleware/gtk
Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are not used.
This commit is contained in:
parent
2f453cc57e
commit
65ad2541d7
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user