[goffice] Fix rendering on high resolution monitors when scale is not 1. [#578]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fix rendering on high resolution monitors when scale is not 1. [#578]
- Date: Thu, 27 May 2021 07:39:07 +0000 (UTC)
commit db5cbab8f4b50208d413a34a013a3c32620f78e1
Author: Jean Brefort <jean brefort normalesup org>
Date: Thu May 27 09:38:53 2021 +0200
Fix rendering on high resolution monitors when scale is not 1. [#578]
ChangeLog | 5 +++++
NEWS | 1 +
goffice/canvas/goc-graph.c | 31 ++++++++++++++++++++++---------
3 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index abf12aac4..cb6b96f1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-27 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/canvas/goc-graph.c (goc_graph_draw): fix rendering on high
+ resolution monitors when scale is not 1. #578.
+
2021-05-12 Jean Brefort <jean brefort normalesup org>
* plugins/plot_surface/gog-matrix.c (gog_matrix_view_render): call the
diff --git a/NEWS b/NEWS
index 017c81d9c..127c1571b 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ goffice 0.10.50:
Jean:
* Fix data update in matrix plots, see Debian #988397.
+ * Fix rendering on high resolution monitors when scale is not 1. [#578]
Morten:
* Simplify regression equation code.
diff --git a/goffice/canvas/goc-graph.c b/goffice/canvas/goc-graph.c
index ccc906417..5e6f4ce6f 100644
--- a/goffice/canvas/goc-graph.c
+++ b/goffice/canvas/goc-graph.c
@@ -186,25 +186,38 @@ goc_graph_draw (GocItem const *item, cairo_t *cr)
GocGraph *graph = GOC_GRAPH (item);
GocCanvas *canvas = item->canvas;
cairo_surface_t *surf;
- double x0, y0 = item->y0;
+ double x0, y0 = item->y0, scale = 1.;
if (graph->renderer == NULL)
return;
- if (item->canvas && goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL) {
+ // Note that we can't have RTL when the scene has no widget, may be we can
+ // add a direction mamber to the group (in its private member) if needed
+ if (canvas && goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL) {
x0 = item->x1;
goc_group_adjust_coords (item->parent, &x0, &y0);
x0 = canvas->width - (int) (x0 - canvas->scroll_x1) * canvas->pixels_per_unit;
} else {
x0 = item->x0;
goc_group_adjust_coords (item->parent, &x0, &y0);
- x0 = go_fake_round ((x0 - canvas->scroll_x1) * canvas->pixels_per_unit);
+ if (canvas)
+ x0 = go_fake_round ((x0 - canvas->scroll_x1) * canvas->pixels_per_unit);
}
cairo_save (cr);
- cairo_translate (cr, x0,
- (int) (y0 - canvas->scroll_y1) * canvas->pixels_per_unit);
- /* scaling only there gives a better rendering, and allows for caching */
- gog_renderer_update (graph->renderer,
- go_fake_round (graph->w * canvas->pixels_per_unit),
- go_fake_round (graph->h * canvas->pixels_per_unit));
+ if (canvas) {
+ cairo_translate (cr, x0,
+ (int) (y0 - canvas->scroll_y1) * canvas->pixels_per_unit);
+#if GTK_CHECK_VERSION(3,10,0)
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (canvas));
+ cairo_scale (cr, 1. / scale, 1. / scale);
+ /* scaling only there gives a better rendering, and allows for caching */
+ gog_renderer_update (graph->renderer,
+ go_fake_round (graph->w * canvas->pixels_per_unit * scale),
+ go_fake_round (graph->h * canvas->pixels_per_unit * scale));
+#endif
+ } else {
+ cairo_translate (cr, x0, y0);
+ /* scaling only there gives a better rendering, and allows for caching */
+ gog_renderer_update (graph->renderer, graph->w, graph->h);
+ }
surf = gog_renderer_get_cairo_surface (graph->renderer);
cairo_set_source_surface (cr, surf, 0., 0.);
cairo_paint (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]