From 66493421e65d8cbda3e17fdbe43824387e3d51a7 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 23 May 2018 13:04:19 +0100 Subject: Plotters: Change stroke width in the plot_style_t to fixed point. --- include/netsurf/plot_style.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include/netsurf') diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h index db5a5ee26..d7a027cee 100644 --- a/include/netsurf/plot_style.h +++ b/include/netsurf/plot_style.h @@ -24,6 +24,7 @@ #ifndef NETSURF_PLOT_STYLE_H #define NETSURF_PLOT_STYLE_H +#include #include #include "netsurf/types.h" @@ -45,6 +46,18 @@ /* type for fixed point numbers */ typedef int32_t plot_style_fixed; +/* Convert an int to fixed point */ +#define plot_style_int_to_fixed(v) ((v) << PLOT_STYLE_RADIX) + +/* Convert fixed point to int */ +#define plot_style_fixed_to_int(v) ((v) >> PLOT_STYLE_RADIX) + +/* Convert fixed point to float */ +#define plot_style_fixed_to_float(v) (((float)v) / PLOT_STYLE_SCALE) + +/* Convert fixed point to double */ +#define plot_style_fixed_to_double(v) (((double)v) / PLOT_STYLE_SCALE) + /** * Type of plot operation */ @@ -61,7 +74,7 @@ typedef enum { */ typedef struct plot_style_s { plot_operation_type_t stroke_type; /**< Stroke plot type */ - int stroke_width; /**< Width of stroke, in pixels */ + plot_style_fixed stroke_width; /**< Width of stroke, in pixels */ colour stroke_colour; /**< Colour of stroke */ plot_operation_type_t fill_type; /**< Fill plot type */ colour fill_colour; /**< Colour of fill */ -- cgit v1.2.3