From 680298e61ce664e95b3f8143c0c0b814d5966f2a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 10 Jul 2009 18:36:49 +0000 Subject: plotters line refactor svn path=/trunk/netsurf/; revision=8446 --- riscos/plotters.c | 22 +++++++++++++++++----- riscos/print.c | 6 ++---- riscos/save_draw.c | 26 +++++++++++++++----------- 3 files changed, 34 insertions(+), 20 deletions(-) (limited to 'riscos') diff --git a/riscos/plotters.c b/riscos/plotters.c index 88a3179fd..ec55e81d6 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -35,8 +35,7 @@ static bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); -static bool ro_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed); +static bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style); static bool ro_plot_draw_path(const draw_path * const path, int width, colour c, bool dotted, bool dashed); static bool ro_plot_polygon(const int *p, unsigned int n, colour fill); @@ -147,8 +146,7 @@ bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style } -bool ro_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed) +bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) { const int path[] = { draw_MOVE_TO, (ro_plot_origin_x + x0 * 2) * 256, @@ -157,8 +155,22 @@ bool ro_plot_line(int x0, int y0, int x1, int y1, int width, (ro_plot_origin_x + x1 * 2) * 256, (ro_plot_origin_y - y1 * 2 - 1) * 256, draw_END_PATH }; + bool dotted = false; + bool dashed = false; + + if (style->stroke_type != PLOT_OP_TYPE_NONE) { + if (style->stroke_type == PLOT_OP_TYPE_DOT) + dotted = true; - return ro_plot_draw_path((const draw_path *) path, width, c, dotted, dashed); + if (style->stroke_type == PLOT_OP_TYPE_DASH) + dashed = true; + + return ro_plot_draw_path((const draw_path *)path, + style->stroke_width, + style->stroke_colour, + dotted, dashed); + } + return true; } diff --git a/riscos/print.c b/riscos/print.c index c06b235dd..4cbe97506 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -98,8 +98,7 @@ static bool print_send_printtypeknown(wimp_message *m); static bool print_document(struct gui_window *g, const char *filename); static const char *print_declare_fonts(struct content *content); static bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); -static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed); +static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style); static bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill); static bool print_fonts_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -810,8 +809,7 @@ bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style } -bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed) +bool print_fonts_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) { return true; } diff --git a/riscos/save_draw.c b/riscos/save_draw.c index 4a8f8d64d..da3e59799 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -38,8 +38,7 @@ #include "utils/utils.h" static bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); -static bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed); +static bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style); static bool ro_save_draw_polygon(const int *p, unsigned int n, colour fill); static bool ro_save_draw_path(const float *p, unsigned int n, colour fill, float width, colour c, const float transform[6]); @@ -192,19 +191,24 @@ bool ro_save_draw_rectangle(int x0, int y0, int x1, int y1, const plot_style_t * } -bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed) +bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t *style) { pencil_code code; const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1, - draw_LINE_TO, x1 * 2, -y1 * 2 - 1, - draw_END_PATH }; + draw_LINE_TO, x1 * 2, -y1 * 2 - 1, + draw_END_PATH }; - code = pencil_path(ro_save_draw_diagram, path, - sizeof path / sizeof path[0], - pencil_TRANSPARENT, c << 8, width, pencil_JOIN_MITRED, - pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false, - pencil_SOLID); + code = pencil_path(ro_save_draw_diagram, + path, + sizeof path / sizeof path[0], + pencil_TRANSPARENT, + style->stroke_colour << 8, + style->stroke_width, + pencil_JOIN_MITRED, + pencil_CAP_BUTT, + pencil_CAP_BUTT, + 0, 0, false, + pencil_SOLID); if (code != pencil_OK) return ro_save_draw_error(code); -- cgit v1.2.3