mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
inspector: Fix surface transform regression
Ever since we added surface-to-widget transforms, the autofading of the fps overlay did not work anymore, since it was given the transient transform node, most of the time. Fix this by passing both the root of the node tree and the node for the toplevel widget to prepare_render, and hande the widget node to the overlays. Update the affected overlays that need to have their positioning adjusted.
This commit is contained in:
parent
9d51821e84
commit
5556907194
@ -11462,6 +11462,7 @@ gtk_widget_render (GtkWidget *widget,
|
||||
GdkSurface *surface,
|
||||
const cairo_region_t *region)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkSnapshot *snapshot;
|
||||
GskRenderer *renderer;
|
||||
GskRenderNode *root;
|
||||
@ -11497,7 +11498,8 @@ gtk_widget_render (GtkWidget *widget,
|
||||
renderer,
|
||||
surface,
|
||||
region,
|
||||
root);
|
||||
root,
|
||||
priv->render_node);
|
||||
|
||||
gsk_renderer_render (renderer, root, region);
|
||||
|
||||
|
@ -172,15 +172,10 @@ gtk_updates_overlay_snapshot (GtkInspectorOverlay *overlay,
|
||||
GtkUpdate *draw;
|
||||
gint64 now;
|
||||
GList *l;
|
||||
double native_x, native_y;
|
||||
|
||||
if (!GTK_IS_NATIVE (widget))
|
||||
return;
|
||||
|
||||
/* The coordinates we're getting from GdkSurface API are in GdkSurface coordinate spaces,
|
||||
* but we're snapshotting in widget space, so we need to transform */
|
||||
gtk_native_get_surface_transform (GTK_NATIVE (widget), &native_x, &native_y);
|
||||
|
||||
updates = gtk_update_overlay_lookup_for_widget (self, widget, TRUE);
|
||||
now = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
|
||||
|
||||
@ -234,7 +229,7 @@ gtk_updates_overlay_snapshot (GtkInspectorOverlay *overlay,
|
||||
cairo_region_get_rectangle (draw->region, i, &rect);
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
&(GdkRGBA) { 1, 0, 0, 0.4 * (1 - progress) },
|
||||
&GRAPHENE_RECT_INIT(rect.x - native_x, rect.y - native_y,
|
||||
&GRAPHENE_RECT_INIT(rect.x, rect.y,
|
||||
rect.width, rect.height));
|
||||
}
|
||||
}
|
||||
|
@ -780,24 +780,25 @@ gtk_inspector_prepare_render (GtkWidget *widget,
|
||||
GskRenderer *renderer,
|
||||
GdkSurface *surface,
|
||||
const cairo_region_t *region,
|
||||
GskRenderNode *node)
|
||||
GskRenderNode *root,
|
||||
GskRenderNode *widget_node)
|
||||
{
|
||||
GtkInspectorWindow *iw;
|
||||
|
||||
iw = gtk_inspector_window_get_for_display (gtk_widget_get_display (widget));
|
||||
if (iw == NULL)
|
||||
return node;
|
||||
return root;
|
||||
|
||||
/* sanity check for single-display GDK backends */
|
||||
if (GTK_WIDGET (iw) == widget)
|
||||
return node;
|
||||
return root;
|
||||
|
||||
gtk_inspector_recorder_record_render (GTK_INSPECTOR_RECORDER (iw->widget_recorder),
|
||||
widget,
|
||||
renderer,
|
||||
surface,
|
||||
region,
|
||||
node);
|
||||
root);
|
||||
|
||||
if (iw->overlays)
|
||||
{
|
||||
@ -806,7 +807,7 @@ gtk_inspector_prepare_render (GtkWidget *widget,
|
||||
double native_x, native_y;
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_snapshot_append_node (snapshot, node);
|
||||
gtk_snapshot_append_node (snapshot, root);
|
||||
|
||||
gtk_native_get_surface_transform (GTK_NATIVE (widget), &native_x, &native_y);
|
||||
|
||||
@ -815,16 +816,16 @@ gtk_inspector_prepare_render (GtkWidget *widget,
|
||||
|
||||
for (l = iw->overlays; l; l = l->next)
|
||||
{
|
||||
gtk_inspector_overlay_snapshot (l->data, snapshot, node, widget);
|
||||
gtk_inspector_overlay_snapshot (l->data, snapshot, widget_node, widget);
|
||||
}
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
gsk_render_node_unref (root);
|
||||
root = gtk_snapshot_free_to_node (snapshot);
|
||||
}
|
||||
|
||||
return node;
|
||||
return root;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -154,7 +154,8 @@ GskRenderNode * gtk_inspector_prepare_render
|
||||
GskRenderer *renderer,
|
||||
GdkSurface *surface,
|
||||
const cairo_region_t *region,
|
||||
GskRenderNode *node);
|
||||
GskRenderNode *root,
|
||||
GskRenderNode *widget_node);
|
||||
gboolean gtk_inspector_handle_event (GdkEvent *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user