[gtk/63-regression-3-22-26-3-22-27-hidpi-checkboxes-and-radiobuttons-pixmaps-are-not-scaled] GtkCssImageSurface: set device scale for cache surface
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/63-regression-3-22-26-3-22-27-hidpi-checkboxes-and-radiobuttons-pixmaps-are-not-scaled] GtkCssImageSurface: set device scale for cache surface
- Date: Mon, 5 Mar 2018 17:59:20 +0000 (UTC)
commit e36b629c367fa11e6e544ff8b8203bcf29ec73ee
Author: Juan Pablo Ugarte <ugarte endlessm com>
Date: Mon Mar 5 14:47:00 2018 -0300
GtkCssImageSurface: set device scale for cache surface
Closes #63
gtk/gtkcssimagesurface.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssimagesurface.c b/gtk/gtkcssimagesurface.c
index 8c439c9a52..f6f694aff7 100644
--- a/gtk/gtkcssimagesurface.c
+++ b/gtk/gtkcssimagesurface.c
@@ -60,8 +60,14 @@ gtk_css_image_surface_draw (GtkCssImage *image,
ABS (width - surface->width) > 0.001 ||
ABS (height - surface->height) > 0.001)
{
+ double xscale, yscale;
cairo_t *cache;
+ /* We need the device scale (HiDPI mode) to calculate the proper size in
+ * pixels for the image surface and set the cache device scale
+ */
+ cairo_surface_get_device_scale (cairo_get_target (cr), &xscale, &yscale);
+
/* Save original size to preserve precision */
surface->width = width;
surface->height = height;
@@ -72,8 +78,9 @@ gtk_css_image_surface_draw (GtkCssImage *image,
/* Image big enough to contain scaled image with subpixel precision */
surface->cache = cairo_surface_create_similar_image (surface->surface,
CAIRO_FORMAT_ARGB32,
- ceil (width),
- ceil (height));
+ ceil (width*xscale),
+ ceil (height*yscale));
+ cairo_surface_set_device_scale (surface->cache, xscale, yscale);
cache = cairo_create (surface->cache);
cairo_rectangle (cache, 0, 0, width, height);
cairo_scale (cache, width / image_width, height / image_height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]