summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <scampa.giovanni@gmail.com>2015-03-21 21:54:32 -0700
committerRay Strode <rstrode@redhat.com>2016-03-03 14:32:25 -0500
commit72ae2bd8892ebe7be84319fa28a93ba369d819b3 (patch)
tree97b762236ecb268eca375bc9f0ed4a4ef4722e66
parentdd005c3fd5515925a563006f74e53dc354eed84e (diff)
label: add support for HiDPI
Set the device scale on the cairo surface based on the pixel buffer device scale. cairo will do the rest of the magic for us. https://bugs.freedesktop.org/show_bug.cgi?id=84482
-rw-r--r--src/plugins/controls/label/plugin.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/controls/label/plugin.c b/src/plugins/controls/label/plugin.c
index 5edce3b..acba52b 100644
--- a/src/plugins/controls/label/plugin.c
+++ b/src/plugins/controls/label/plugin.c
@@ -113,15 +113,18 @@ get_cairo_context_for_pixel_buffer (ply_label_plugin_control_t *label,
cairo_t *cairo_context;
unsigned char *data;
ply_rectangle_t size;
+ uint32_t scale;
data = (unsigned char *) ply_pixel_buffer_get_argb32_data (pixel_buffer);
ply_pixel_buffer_get_size (pixel_buffer, &size);
+ scale = ply_pixel_buffer_get_device_scale (pixel_buffer);
cairo_surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
- size.width,
- size.height,
- size.width * 4);
+ size.width * scale,
+ size.height * scale,
+ size.width * scale * 4);
+ cairo_surface_set_device_scale (cairo_surface, scale, scale);
cairo_context = cairo_create (cairo_surface);
cairo_surface_destroy (cairo_surface);