diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2018-05-23 13:04:19 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2018-05-23 13:04:19 +0100 |
commit | 66493421e65d8cbda3e17fdbe43824387e3d51a7 (patch) | |
tree | d260fb3aa5a0af3de954516e8eaac0d3cb5113b4 /frontends/gtk | |
parent | a58d97a41a6192038573da6862571dc72a560458 (diff) | |
download | netsurf-66493421e65d8cbda3e17fdbe43824387e3d51a7.tar.gz netsurf-66493421e65d8cbda3e17fdbe43824387e3d51a7.tar.bz2 |
Plotters: Change stroke width in the plot_style_t to fixed point.
Diffstat (limited to 'frontends/gtk')
-rw-r--r-- | frontends/gtk/plotters.c | 29 | ||||
-rw-r--r-- | frontends/gtk/print.c | 30 |
2 files changed, 31 insertions, 28 deletions
diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c index 88e7760c6..6178104d5 100644 --- a/frontends/gtk/plotters.c +++ b/frontends/gtk/plotters.c @@ -89,6 +89,20 @@ static inline void nsgtk_set_dashed(void) /** + * Set cairo context line width. + */ +static inline void nsgtk_set_line_width(plot_style_fixed width) +{ + if (width == 0) { + cairo_set_line_width(current_cr, 1); + } else { + cairo_set_line_width(current_cr, + plot_style_fixed_to_double(width)); + } +} + + +/** * \brief Sets a clip rectangle for subsequent plot operations. * * \param ctx The current redraw context. @@ -191,10 +205,7 @@ nsgtk_plot_disc(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); @@ -242,10 +253,7 @@ nsgtk_plot_line(const struct redraw_context *ctx, nsgtk_set_colour(style->stroke_colour); } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); /* core expects horizontal and vertical lines to be on pixels, not * between pixels @@ -331,10 +339,7 @@ nsgtk_plot_rectangle(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_rectangle(current_cr, rect->x0 + 0.5, diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c index 8f71230a6..f447a463e 100644 --- a/frontends/gtk/print.c +++ b/frontends/gtk/print.c @@ -133,6 +133,17 @@ static inline void nsgtk_print_set_dashed(void) cairo_set_dash(gtk_print_current_cr, cdashes, 1, 0); } +/** Set cairo context line width. */ +static inline void nsgtk_set_line_width(plot_style_fixed width) +{ + if (width == 0) { + cairo_set_line_width(gtk_print_current_cr, 1); + } else { + cairo_set_line_width(gtk_print_current_cr, + plot_style_fixed_to_double(width)); + } +} + /** * \brief Sets a clip rectangle for subsequent plot operations. @@ -248,10 +259,7 @@ nsgtk_print_plot_disc(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(gtk_print_current_cr, 1); - else - cairo_set_line_width(gtk_print_current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_arc(gtk_print_current_cr, x, y, radius, 0, M_PI * 2); @@ -294,10 +302,7 @@ nsgtk_print_plot_line(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(gtk_print_current_cr, 1); - else - cairo_set_line_width(gtk_print_current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_move_to(gtk_print_current_cr, line->x0 + 0.5, line->y0 + 0.5); cairo_line_to(gtk_print_current_cr, line->x1 + 0.5, line->y1 + 0.5); @@ -350,13 +355,6 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx, } if (style->stroke_type != PLOT_OP_TYPE_NONE) { - int stroke_width; - - /* ensure minimum stroke width */ - stroke_width = style->stroke_width; - if (stroke_width == 0) { - stroke_width = 1; - } nsgtk_print_set_colour(style->stroke_colour); @@ -375,7 +373,7 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx, break; } - cairo_set_line_width(gtk_print_current_cr, stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_rectangle(gtk_print_current_cr, rect->x0, rect->y0, |