summaryrefslogtreecommitdiff
path: root/gtk/gtkcssimage.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-08-05 16:11:18 +0200
committerAlexander Larsson <alexl@redhat.com>2013-08-05 16:14:25 +0200
commit499cef1bb00b9e4d0b4cffed5ef3e6e951bc2e5e (patch)
tree161a4600f0d4d48b68c05ea316b0cb217dc28750 /gtk/gtkcssimage.c
parent8c7a8e9314f4cdef015611a9d9cad2fd21d4f2b4 (diff)
downloadgtk+-499cef1bb00b9e4d0b4cffed5ef3e6e951bc2e5e.tar.gz
css: Inherit device scale in _gtk_css_image_get_surface
To handle hidpi support we need to make sure we don't downscale scaled css images. Note: If cairo_surface_create_similar starts doing this by itself we need to back this out.
Diffstat (limited to 'gtk/gtkcssimage.c')
-rw-r--r--gtk/gtkcssimage.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c
index a79b3e1398..33c85f2abf 100644
--- a/gtk/gtkcssimage.c
+++ b/gtk/gtkcssimage.c
@@ -389,16 +389,30 @@ _gtk_css_image_get_surface (GtkCssImage *image,
{
cairo_surface_t *result;
cairo_t *cr;
+ double sx, sy;
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
g_return_val_if_fail (surface_width > 0, NULL);
g_return_val_if_fail (surface_height > 0, NULL);
+
if (target)
- result = cairo_surface_create_similar (target,
- CAIRO_CONTENT_COLOR_ALPHA,
- surface_width,
- surface_height);
+ {
+#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+ cairo_surface_get_device_scale (target, &sx, &sy);
+#else
+ sx = sy = 1;
+#endif
+
+ result = cairo_surface_create_similar (target,
+ CAIRO_CONTENT_COLOR_ALPHA,
+ surface_width*sx,
+ surface_height*sy);
+
+#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
+ cairo_surface_set_device_scale (result, sx, sy);
+#endif
+ }
else
result = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
surface_width,