mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
line-visualizer-row: handle HiDPI properly
When we find ourselves on a HiDPI display, we need to make sure we setup the device scale factor properly and adjust our render checks for valid surface sizes.
This commit is contained in:
@ -91,6 +91,7 @@ typedef struct
|
|||||||
PointCache *cache;
|
PointCache *cache;
|
||||||
GArray *lines;
|
GArray *lines;
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
|
gint scale_factor;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
} RenderData;
|
} RenderData;
|
||||||
@ -267,11 +268,12 @@ sp_line_visualizer_row_draw (GtkWidget *widget,
|
|||||||
|
|
||||||
if (ret == GDK_EVENT_PROPAGATE && priv->surface != NULL)
|
if (ret == GDK_EVENT_PROPAGATE && priv->surface != NULL)
|
||||||
{
|
{
|
||||||
|
gint scale_factor = gtk_widget_get_scale_factor (widget);
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
width = cairo_image_surface_get_width (priv->surface);
|
width = cairo_image_surface_get_width (priv->surface) / scale_factor;
|
||||||
height = cairo_image_surface_get_height (priv->surface);
|
height = cairo_image_surface_get_height (priv->surface) / scale_factor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must have another threaded draw queued, so to give the impression
|
* We must have another threaded draw queued, so to give the impression
|
||||||
@ -861,8 +863,8 @@ sp_line_visualizer_row_render_worker (GTask *task,
|
|||||||
* and ignore having to deal with backgrounds and such.
|
* and ignore having to deal with backgrounds and such.
|
||||||
*/
|
*/
|
||||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
render->width,
|
render->width * render->scale_factor,
|
||||||
render->height);
|
render->height * render->scale_factor);
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
{
|
{
|
||||||
@ -874,6 +876,11 @@ sp_line_visualizer_row_render_worker (GTask *task,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (render->scale_factor != 1)
|
||||||
|
cairo_surface_set_device_scale (surface,
|
||||||
|
render->scale_factor,
|
||||||
|
render->scale_factor);
|
||||||
|
|
||||||
cr = cairo_create (surface);
|
cr = cairo_create (surface);
|
||||||
|
|
||||||
if (cr == NULL)
|
if (cr == NULL)
|
||||||
@ -990,6 +997,7 @@ sp_line_visualizer_row_render_async (SpLineVisualizerRow *self,
|
|||||||
render->lines = copy_array (priv->lines);
|
render->lines = copy_array (priv->lines);
|
||||||
render->width = alloc.width;
|
render->width = alloc.width;
|
||||||
render->height = alloc.height;
|
render->height = alloc.height;
|
||||||
|
render->scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||||
|
|
||||||
style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
|
style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
|
||||||
state = gtk_widget_get_state_flags (GTK_WIDGET (self));
|
state = gtk_widget_get_state_flags (GTK_WIDGET (self));
|
||||||
|
|||||||
Reference in New Issue
Block a user