mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
rendernodepaintable: Provide accurate aspect ratio
Since we report width and height as integers, the default implementation of this introduces rounding errors. This shows up in the node-editor, as having uneven scale factors like sx=1.0 and sy=1.0035. Text nodes don't handle uneven scales like that well and overdraw.
This commit is contained in:
parent
8c34dd58c0
commit
52a8492887
@ -87,6 +87,17 @@ gtk_render_node_paintable_paintable_get_intrinsic_height (GdkPaintable *paintabl
|
|||||||
return ceilf (self->bounds.size.height);
|
return ceilf (self->bounds.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
gtk_render_node_paintable_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
|
||||||
|
{
|
||||||
|
GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
|
||||||
|
|
||||||
|
if (self->bounds.size.height != 0)
|
||||||
|
return self->bounds.size.width / self->bounds.size.height;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_render_node_paintable_paintable_init (GdkPaintableInterface *iface)
|
gtk_render_node_paintable_paintable_init (GdkPaintableInterface *iface)
|
||||||
{
|
{
|
||||||
@ -94,6 +105,7 @@ gtk_render_node_paintable_paintable_init (GdkPaintableInterface *iface)
|
|||||||
iface->get_flags = gtk_render_node_paintable_paintable_get_flags;
|
iface->get_flags = gtk_render_node_paintable_paintable_get_flags;
|
||||||
iface->get_intrinsic_width = gtk_render_node_paintable_paintable_get_intrinsic_width;
|
iface->get_intrinsic_width = gtk_render_node_paintable_paintable_get_intrinsic_width;
|
||||||
iface->get_intrinsic_height = gtk_render_node_paintable_paintable_get_intrinsic_height;
|
iface->get_intrinsic_height = gtk_render_node_paintable_paintable_get_intrinsic_height;
|
||||||
|
iface->get_intrinsic_aspect_ratio = gtk_render_node_paintable_paintable_get_intrinsic_aspect_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED (GtkRenderNodePaintable, gtk_render_node_paintable, G_TYPE_OBJECT, 0,
|
G_DEFINE_TYPE_EXTENDED (GtkRenderNodePaintable, gtk_render_node_paintable, G_TYPE_OBJECT, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user