From 84c0c1ff3f9666adb632b8c87b4c2f7c54f5d823 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 22 Jul 2022 17:12:09 +0200 Subject: Fix EDID reading in libfonts_get_output_dpi and make it use the output transformation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 common.h (limited to 'common.h') diff --git a/common.h b/common.h new file mode 100644 index 0000000..f39090e --- /dev/null +++ b/common.h @@ -0,0 +1,31 @@ +/* See LICENSE file for copyright and license details. */ +#include "libfonts.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define DOUBLE_TOLERANCE 0.000001 + + +static inline void +transform(double *x_out, double *y_out, double x, double y, const struct libfonts_transformation *transformation) +{ + double a = transformation->m[0][0], b = transformation->m[0][1], c = transformation->m[0][2]; + double d = transformation->m[1][0], e = transformation->m[1][1], f = transformation->m[1][2]; + double g = transformation->m[2][0], h = transformation->m[2][1], i = transformation->m[2][2]; + double w = g*x + h*y + i; + *x_out = (a*x + b*y + c) / w; + *y_out = (d*x + e*y + f) / w; +} + + +static inline int +eq(double a, double b) +{ + return b - DOUBLE_TOLERANCE <= a && a <= b + DOUBLE_TOLERANCE; +} -- cgit v1.2.3-70-g09d2