summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2019-05-06 21:22:55 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2019-05-06 21:22:55 +0100
commitffc199d778c7666edca028da965009574fdfd3df (patch)
tree75bb8585fc39a574aadc44535eed6d37aa9a5b38 /content/handlers
parent7567f6407512acb44199a11b6496a614ca659fe2 (diff)
downloadnetsurf-ffc199d778c7666edca028da965009574fdfd3df.tar.gz
netsurf-ffc199d778c7666edca028da965009574fdfd3df.tar.bz2
CSS: Add helpers to convert between css and physical pixels.
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/css/utils.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/content/handlers/css/utils.h b/content/handlers/css/utils.h
index 0e723f7f1..e35a6605b 100644
--- a/content/handlers/css/utils.h
+++ b/content/handlers/css/utils.h
@@ -79,6 +79,31 @@ css_fixed nscss_len2px(
css_unit unit,
const css_computed_style *style);
+/**
+ * Convert css pixels to physical pixels.
+ *
+ * \param[in] css_pixels Length in css pixels.
+ * \return length in physical pixels
+ */
+static inline css_fixed nscss_pixels_css_to_physical(
+ css_fixed css_pixels)
+{
+ return FDIV(FMUL(css_pixels, nscss_screen_dpi),
+ nscss_baseline_pixel_density);
+}
+
+/**
+ * Convert physical pixels to css pixels.
+ *
+ * \param[in] physical_pixels Length in physical pixels.
+ * \return length in css pixels
+ */
+static inline css_fixed nscss_pixels_physical_to_css(
+ css_fixed physical_pixels)
+{
+ return FDIV(FMUL(physical_pixels, nscss_baseline_pixel_density),
+ nscss_screen_dpi);
+}
/**
* Temporary helper wrappers for for libcss computed style getter, while