diff options
author | Stefan Wildemann <gta04@metalstrolche.de> | 2019-07-20 17:03:26 +0200 |
---|---|---|
committer | Stefan Wildemann <gta04@metalstrolche.de> | 2019-07-20 17:03:26 +0200 |
commit | e9fd4b840a085d5b2a8d3951365b2c2db0cdce35 (patch) | |
tree | 40309cbbb44269f549d70717fcc17b064b83191d | |
parent | 1103dc4026677ab164c5ffc20bb4fc693c9bea76 (diff) | |
download | navit-e9fd4b840a085d5b2a8d3951365b2c2db0cdce35.tar.gz |
Prepare for hardware dpi handling.
-rw-r--r-- | navit/graphics.c | 20 | ||||
-rw-r--r-- | navit/graphics/qt5/graphics_qt5.cpp | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/navit/graphics.c b/navit/graphics.c index 96f4acb47..3c7de9c24 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -88,6 +88,9 @@ struct graphics { */ int current_z_order; GHashTable *image_cache_hash; + /* for dpi compensation */ + navit_float virtual_dpi; + navit_float real_dpi; }; struct display_context { @@ -143,10 +146,9 @@ static void graphics_gc_init(struct graphics *this_); static int graphics_dpi_scale(struct graphics * gra, int p) { navit_float result; - navit_float dpi = 400.0; /* hardware dpi */ - navit_float unit = 95.0; /* navit assumes 95 dpi, 1px == 1/95 in */ - result = (((navit_float)p) * dpi) / unit; - result = p * 2; + if(gra == NULL) + return p; + result = (((navit_float)p) * gra->real_dpi) / gra->virtual_dpi; return (int) result; } static struct point graphics_dpi_scale_point(struct graphics * gra, struct point *p) { @@ -159,10 +161,9 @@ static struct point graphics_dpi_scale_point(struct graphics * gra, struct point } static int graphics_dpi_unscale(struct graphics * gra, int p) { navit_float result; - navit_float dpi = 400.0; /* hardware dpi */ - navit_float unit = 95.0; /* navit assumes 95 dpi, 1px == 1/95 in */ - result = (((navit_float)p) / unit) * dpi; - result = p/2; + if(gra == NULL) + return p; + result = (((navit_float)p) / gra->virtual_dpi) * gra->real_dpi; return (int) result; } static struct point graphics_dpi_unscale_point(struct graphics * gra, struct point *p) { @@ -344,6 +345,9 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs) { } this_=g_new0(struct graphics, 1); this_->attrs=attr_list_dup(attrs); + /*TODO: add attrs for virtual and real dpi */ + this_->virtual_dpi = 95; + this_->real_dpi = this_->virtual_dpi; this_->cbl=callback_list_new(); cbl_attr.type=attr_callback_list; cbl_attr.u.callback_list=this_->cbl; diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp index f1f7e9d0e..480ae4a1f 100644 --- a/navit/graphics/qt5/graphics_qt5.cpp +++ b/navit/graphics/qt5/graphics_qt5.cpp @@ -209,7 +209,7 @@ static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct grap } /* Convert silly font size to pixels. by 64 is to convert fixpoint to int. */ - dbg(lvl_error, "(font %s, %d=%f, %d)", font, size,((float)size)/64.0, ((size * 300) / 72) / 64); + dbg(lvl_debug, "(font %s, %d=%f, %d)", font, size,((float)size)/64.0, ((size * 300) / 72) / 64); font_priv->font->setPixelSize(((size * 300) / 72) / 64); //font_priv->font->setStyleStrategy(QFont::NoSubpixelAntialias); /* Check for bold font */ |