diff options
author | Owen W. Taylor <[email protected]> | 2014-02-27 19:20:17 -0500 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-03-26 13:49:10 +0200 |
commit | 2cae078d88eb5e7d2e5891cb03cdb90b7852cc03 (patch) | |
tree | f84769194aa271da86cedc7a686adc931df91414 /libview/ev-view.c | |
parent | 7cb00e9dea3de02f61bda3c05133a04f4605e0ac (diff) | |
download | atril-2cae078d88eb5e7d2e5891cb03cdb90b7852cc03.tar.bz2 atril-2cae078d88eb5e7d2e5891cb03cdb90b7852cc03.tar.xz |
EvView: render correctly on hi-dpi displays
Make EvPixbufCache generate surfaces with extra resolution based on
gtk_widget_get_scale_factor(). Handle cairo surfaces with a device
scale in ev_view_draw(). Trigger an update of the pixbuf cache when
the scale factor changes.
https://bugzilla.gnome.org/show_bug.cgi?id=723431
origin commit:
https://git.gnome.org/browse/evince/commit/?id=a612f8
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r-- | libview/ev-view.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index b513fcbe..31aa613f 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -5690,10 +5690,14 @@ draw_surface (cairo_t *cr, gint target_width, gint target_height) { - gint width, height; + gdouble width, height; + gdouble device_scale_x = 1, device_scale_y = 1; - width = cairo_image_surface_get_width (surface); - height = cairo_image_surface_get_height (surface); +#ifdef HAVE_HIDPI_SUPPORT + cairo_surface_get_device_scale (surface, &device_scale_x, &device_scale_y); +#endif + width = cairo_image_surface_get_width (surface) / device_scale_x; + height = cairo_image_surface_get_height (surface) / device_scale_y; cairo_save (cr); cairo_translate (cr, x, y); @@ -5712,8 +5716,8 @@ draw_surface (cairo_t *cr, } cairo_surface_set_device_offset (surface, - offset_x, - offset_y); + offset_x * device_scale_x, + offset_y * device_scale_y); cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); cairo_restore (cr); @@ -5848,9 +5852,18 @@ draw_one_page (EvView *view, if (region) { double scale_x, scale_y; GdkRGBA color; + double device_scale_x = 1, device_scale_y = 1; scale_x = (gdouble)width / cairo_image_surface_get_width (page_surface); scale_y = (gdouble)height / cairo_image_surface_get_height (page_surface); + +#ifdef HAVE_HIDPI_SUPPORT + cairo_surface_get_device_scale (page_surface, &device_scale_x, &device_scale_y); +#endif + + scale_x *= device_scale_x; + scale_y *= device_scale_y; + _ev_view_get_selection_colors (view, &color, NULL); draw_selection_region (cr, region, &color, real_page_area.x, real_page_area.y, scale_x, scale_y); |