summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebarshi Ray <debarshir@gnome.org>2016-12-15 13:46:59 +0100
committerDebarshi Ray <debarshir@gnome.org>2016-12-15 14:15:40 +0100
commit3ed74952612a5e6dbde3f5785b40141fae760c60 (patch)
tree6a3f616d798ccff4ea6faf018ceca88978db2499
parent755346e7e6c3ccc31417710a28c6fd62ab76d3da (diff)
downloadlibgd-3ed74952612a5e6dbde3f5785b40141fae760c60.tar.gz
main-view: Don't let the Cairo surface get bigger while copying
The cairo_surface_create_similar API expects the width and height to be in device-space units, not pixels. So either we need to scale down the outputs of cairo_image_surface_get_{width, height}, or we need to use cairo_surface_create_similar_image. I prefer the latter because we are already using other image surface API and pixel values. Note that unlike cairo_surface_create_similar, we need to manually set the device scale because cairo_surface_create_similar_image doesn't inherit it. https://bugzilla.gnome.org/show_bug.cgi?id=776133
-rw-r--r--libgd/gd-main-view.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libgd/gd-main-view.c b/libgd/gd-main-view.c
index 7aca51a..0e3688f 100644
--- a/libgd/gd-main-view.c
+++ b/libgd/gd-main-view.c
@@ -860,10 +860,15 @@ copy_surface (cairo_surface_t *surface)
{
cairo_surface_t *copy;
cairo_t *cr;
+ gdouble scale_x;
+ gdouble scale_y;
+
+ copy = cairo_surface_create_similar_image (surface, CAIRO_FORMAT_ARGB32,
+ cairo_image_surface_get_width (surface),
+ cairo_image_surface_get_height (surface));
+ cairo_surface_get_device_scale (surface, &scale_x, &scale_y);
+ cairo_surface_set_device_scale (copy, scale_x, scale_y);
- copy = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
- cairo_image_surface_get_width (surface),
- cairo_image_surface_get_height (surface));
cr = cairo_create (copy);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);