Merge branch 'matthiasc/for-main' into 'main'

inspector: Show fine transform categories

See merge request GNOME/gtk!7591
This commit is contained in:
Matthias Clasen 2024-08-11 02:40:25 +00:00
commit 3014d36a61
3 changed files with 53 additions and 35 deletions

2
NEWS
View File

@ -6,7 +6,7 @@ Overview of Changes in 4.15.5, xx-xx-xxxx
* CSS: * CSS:
- Propagate color state information to GSK for many features: - Propagate color state information to GSK for many features:
colors, borders, shadows colors, borders, shadows, text
* Gdk: * Gdk:
- Fix an fd leak in the Vulkan code - Fix an fd leak in the Vulkan code

View File

@ -111,7 +111,7 @@ gdk_memory_sanitize (GBytes *bytes,
stride % align == 0) stride % align == 0)
{ {
*out_stride = stride; *out_stride = stride;
return g_bytes_ref (bytes); return bytes;
} }
bpp = gdk_memory_format_bytes_per_pixel (format); bpp = gdk_memory_format_bytes_per_pixel (format);
@ -122,6 +122,8 @@ gdk_memory_sanitize (GBytes *bytes,
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
memcpy (copy + y * copy_stride, data + y * stride, bpp * width); memcpy (copy + y * copy_stride, data + y * stride, bpp * width);
g_bytes_unref (bytes);
*out_stride = copy_stride; *out_stride = copy_stride;
return g_bytes_new_take (copy, copy_stride * height); return g_bytes_new_take (copy, copy_stride * height);
} }
@ -197,7 +199,7 @@ gdk_memory_texture_new (int width,
/* needs to be this complex to support subtexture of the bottom right part */ /* needs to be this complex to support subtexture of the bottom right part */
g_return_val_if_fail (g_bytes_get_size (bytes) >= gdk_memory_format_min_buffer_size (format, stride, width, height), NULL); g_return_val_if_fail (g_bytes_get_size (bytes) >= gdk_memory_format_min_buffer_size (format, stride, width, height), NULL);
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride); bytes = gdk_memory_sanitize (g_bytes_ref (bytes), width, height, format, stride, &stride);
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE, self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
"width", width, "width", width,

View File

@ -236,9 +236,15 @@ static GParamSpec *props[LAST_PROP] = { NULL, };
G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET) G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
typedef struct
{
GskRenderNode *node;
const char *role;
} RenderNode;
static GListModel * static GListModel *
create_render_node_list_model (GskRenderNode **nodes, create_render_node_list_model (RenderNode *nodes,
guint n_nodes) guint n_nodes)
{ {
GListStore *store; GListStore *store;
guint i; guint i;
@ -249,9 +255,11 @@ create_render_node_list_model (GskRenderNode **nodes,
for (i = 0; i < n_nodes; i++) for (i = 0; i < n_nodes; i++)
{ {
graphene_rect_t bounds; graphene_rect_t bounds;
GdkPaintable *paintable;
gsk_render_node_get_bounds (nodes[i], &bounds); gsk_render_node_get_bounds (nodes[i].node, &bounds);
GdkPaintable *paintable = gtk_render_node_paintable_new (nodes[i], &bounds); paintable = gtk_render_node_paintable_new (nodes[i].node, &bounds);
g_object_set_data (G_OBJECT (paintable), "role", (gpointer) nodes[i].role);
g_list_store_append (store, paintable); g_list_store_append (store, paintable);
g_object_unref (paintable); g_object_unref (paintable);
} }
@ -286,46 +294,46 @@ create_list_model_for_render_node (GskRenderNode *node)
return NULL; return NULL;
case GSK_TRANSFORM_NODE: case GSK_TRANSFORM_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_transform_node_get_child (node), NULL }, 1);
case GSK_OPACITY_NODE: case GSK_OPACITY_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_opacity_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_opacity_node_get_child (node), NULL }, 1);
case GSK_COLOR_MATRIX_NODE: case GSK_COLOR_MATRIX_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_color_matrix_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_color_matrix_node_get_child (node), NULL }, 1);
case GSK_BLUR_NODE: case GSK_BLUR_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_blur_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_blur_node_get_child (node), NULL }, 1);
case GSK_REPEAT_NODE: case GSK_REPEAT_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_repeat_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_repeat_node_get_child (node), NULL }, 1);
case GSK_CLIP_NODE: case GSK_CLIP_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_clip_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_clip_node_get_child (node), NULL }, 1);
case GSK_ROUNDED_CLIP_NODE: case GSK_ROUNDED_CLIP_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_rounded_clip_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_rounded_clip_node_get_child (node), NULL }, 1);
case GSK_FILL_NODE: case GSK_FILL_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_fill_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_fill_node_get_child (node), NULL }, 1);
case GSK_STROKE_NODE: case GSK_STROKE_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_stroke_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_stroke_node_get_child (node), NULL }, 1);
case GSK_SHADOW_NODE: case GSK_SHADOW_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_shadow_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_shadow_node_get_child (node), NULL }, 1);
case GSK_BLEND_NODE: case GSK_BLEND_NODE:
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_blend_node_get_bottom_child (node), return create_render_node_list_model ((RenderNode[2]) { { gsk_blend_node_get_bottom_child (node), "Bottom" },
gsk_blend_node_get_top_child (node) }, 2); { gsk_blend_node_get_top_child (node), "Top" } }, 2);
case GSK_MASK_NODE: case GSK_MASK_NODE:
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_mask_node_get_source (node), return create_render_node_list_model ((RenderNode[2]) { { gsk_mask_node_get_source (node), "Source" },
gsk_mask_node_get_mask (node) }, 2); { gsk_mask_node_get_mask (node), "Mask" } }, 2);
case GSK_CROSS_FADE_NODE: case GSK_CROSS_FADE_NODE:
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_cross_fade_node_get_start_child (node), return create_render_node_list_model ((RenderNode[2]) { { gsk_cross_fade_node_get_start_child (node), "Start" },
gsk_cross_fade_node_get_end_child (node) }, 2); { gsk_cross_fade_node_get_end_child (node), "End" } }, 2);
case GSK_GL_SHADER_NODE: case GSK_GL_SHADER_NODE:
{ {
@ -372,10 +380,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
} }
case GSK_DEBUG_NODE: case GSK_DEBUG_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_debug_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_debug_node_get_child (node), NULL }, 1);
case GSK_SUBSURFACE_NODE: case GSK_SUBSURFACE_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_subsurface_node_get_child (node) }, 1); return create_render_node_list_model (&(RenderNode) { gsk_subsurface_node_get_child (node), NULL }, 1);
} }
} }
@ -1003,7 +1011,8 @@ add_texture_rows (GListStore *store,
static void static void
populate_render_node_properties (GListStore *store, populate_render_node_properties (GListStore *store,
GskRenderNode *node) GskRenderNode *node,
const char *role)
{ {
graphene_rect_t bounds, opaque; graphene_rect_t bounds, opaque;
@ -1011,6 +1020,9 @@ populate_render_node_properties (GListStore *store,
gsk_render_node_get_bounds (node, &bounds); gsk_render_node_get_bounds (node, &bounds);
if (role)
add_text_row (store, "Role", "%s", role);
add_text_row (store, "Type", "%s", node_type_name (gsk_render_node_get_node_type (node))); add_text_row (store, "Type", "%s", node_type_name (gsk_render_node_get_node_type (node)));
add_text_row (store, "Bounds", add_text_row (store, "Bounds",
@ -1523,13 +1535,15 @@ G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_TRANSFORM_NODE: case GSK_TRANSFORM_NODE:
{ {
static const char * category_names[] = { static const char * category_names[] = {
[GSK_TRANSFORM_CATEGORY_UNKNOWN] = "unknown", [GSK_FINE_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
[GSK_TRANSFORM_CATEGORY_ANY] = "any", [GSK_FINE_TRANSFORM_CATEGORY_ANY] = "any",
[GSK_TRANSFORM_CATEGORY_3D] = "3D", [GSK_FINE_TRANSFORM_CATEGORY_3D] = "3D",
[GSK_TRANSFORM_CATEGORY_2D] = "2D", [GSK_FINE_TRANSFORM_CATEGORY_2D] = "2D",
[GSK_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine", [GSK_FINE_TRANSFORM_CATEGORY_2D_DIHEDRAL] = "2D dihedral",
[GSK_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate", [GSK_FINE_TRANSFORM_CATEGORY_2D_NEGATIVE_AFFINE] = "2D negative affine",
[GSK_TRANSFORM_CATEGORY_IDENTITY] = "identity" [GSK_FINE_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
[GSK_FINE_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
[GSK_FINE_TRANSFORM_CATEGORY_IDENTITY] = "identity"
}; };
GskTransform *transform; GskTransform *transform;
char *s; char *s;
@ -1538,7 +1552,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
s = gsk_transform_to_string (transform); s = gsk_transform_to_string (transform);
add_text_row (store, "Matrix", "%s", s); add_text_row (store, "Matrix", "%s", s);
g_free (s); g_free (s);
add_text_row (store, "Category", "%s", category_names[gsk_transform_get_category (transform)]); add_text_row (store, "Category", "%s", category_names[gsk_transform_get_fine_category (transform)]);
} }
break; break;
@ -1923,6 +1937,7 @@ render_node_list_selection_changed (GtkListBox *list,
GskRenderNode *node; GskRenderNode *node;
GdkPaintable *paintable; GdkPaintable *paintable;
GtkTreeListRow *row_item; GtkTreeListRow *row_item;
const char *role;
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection); row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
@ -1936,7 +1951,8 @@ render_node_list_selection_changed (GtkListBox *list,
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable); gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable)); node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
populate_render_node_properties (recorder->render_node_properties, node); role = g_object_get_data (G_OBJECT (paintable), "role");
populate_render_node_properties (recorder->render_node_properties, node, role);
g_object_unref (paintable); g_object_unref (paintable);
} }