summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2009-07-08 22:04:40 +0000
committerVincent Sanders <vince@netsurf-browser.org>2009-07-08 22:04:40 +0000
commitf9ecd56f62f833f21b3475f0d1b59bc8e053a03e (patch)
tree9874485045ec0fc52fccab99ad545bdefb672203 /riscos
parent651228e64d688e1a565ac88e60b736995ba84012 (diff)
downloadnetsurf-f9ecd56f62f833f21b3475f0d1b59bc8e053a03e.tar.gz
netsurf-f9ecd56f62f833f21b3475f0d1b59bc8e053a03e.tar.bz2
ploter refactor of rectangle handling
svn path=/trunk/netsurf/; revision=8399
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui/progress_bar.c6
-rw-r--r--riscos/gui/status_bar.c2
-rw-r--r--riscos/plotters.c121
-rw-r--r--riscos/print.c13
-rw-r--r--riscos/save_draw.c85
-rw-r--r--riscos/window.c2
6 files changed, 118 insertions, 111 deletions
diff --git a/riscos/gui/progress_bar.c b/riscos/gui/progress_bar.c
index f1f214b01..bee9581aa 100644
--- a/riscos/gui/progress_bar.c
+++ b/riscos/gui/progress_bar.c
@@ -509,9 +509,9 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
progress_ymid - progress_height,
tinct_FILL_HORIZONTALLY);
} else {
- plot.fill(clip_x0, clip_y0,
- clip_x1, clip_y1,
- plot_style_fill_red);
+ plot.rectangle(clip_x0, clip_y0,
+ clip_x1, clip_y1,
+ plot_style_fill_red);
}
}
}
diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c
index 37af0f75f..b56529f07 100644
--- a/riscos/gui/status_bar.c
+++ b/riscos/gui/status_bar.c
@@ -495,7 +495,7 @@ void ro_gui_status_bar_redraw(wimp_draw *redraw)
}
/* separate the widget from the text with a line */
- plot.fill((redraw->box.x0 + sb->width - WIDGET_WIDTH - 2) >> 1,
+ plot.rectangle((redraw->box.x0 + sb->width - WIDGET_WIDTH - 2) >> 1,
-redraw->box.y0 >> 1,
(redraw->box.x0 + sb->width - WIDGET_WIDTH) >> 1,
-redraw->box.y1 >> 1,
diff --git a/riscos/plotters.c b/riscos/plotters.c
index 5422d3211..88a3179fd 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -34,8 +34,7 @@
#include "utils/log.h"
-static bool ro_plot_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed);
+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_draw_path(const draw_path * const path, int width,
@@ -43,7 +42,6 @@ static bool ro_plot_draw_path(const draw_path * const path, int width,
static bool ro_plot_polygon(const int *p, unsigned int n, colour fill);
static bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
-static bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool ro_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool ro_plot_text(int x, int y, const struct css_style *style,
@@ -62,7 +60,6 @@ const struct plotter_table ro_plotters = {
.rectangle = ro_plot_rectangle,
.line = ro_plot_line,
.polygon = ro_plot_polygon,
- .fill = ro_plot_fill,
.clip = ro_plot_clip,
.text = ro_plot_text,
.disc = ro_plot_disc,
@@ -81,29 +78,72 @@ bool ro_plot_patterned_lines = true;
-
-bool ro_plot_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed)
+bool ro_plot_rectangle(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,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + (x0 + width) * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + (x0 + width) * 2) * 256,
- (ro_plot_origin_y - (y0 + height) * 2 - 1) * 256,
- draw_LINE_TO,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - (y0 + height) * 2 - 1) * 256,
- draw_CLOSE_LINE,
- (ro_plot_origin_x + x0 * 2) * 256,
- (ro_plot_origin_y - y0 * 2 - 1) * 256,
- draw_END_PATH };
+ os_error *error;
+
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+
+ error = xcolourtrans_set_gcol(style->fill_colour << 8,
+ colourtrans_USE_ECFS_GCOL,
+ os_ACTION_OVERWRITE, 0, 0);
+ if (error) {
+ LOG(("xcolourtrans_set_gcol: 0x%x: %s",
+ error->errnum, error->errmess));
+ return false;
+ }
+
+ error = xos_plot(os_MOVE_TO,
+ ro_plot_origin_x + x0 * 2,
+ ro_plot_origin_y - y0 * 2 - 1);
+ if (error) {
+ LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
+ return false;
+ }
+
+ error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
+ ro_plot_origin_x + x1 * 2 - 1,
+ ro_plot_origin_y - y1 * 2);
+ if (error) {
+ LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
+ return false;
+ }
+ }
- return ro_plot_draw_path((const draw_path *) path, line_width, c,
- dotted, dashed);
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ bool dotted = false;
+ bool dashed = false;
+
+ const int path[] = { draw_MOVE_TO,
+ (ro_plot_origin_x + x0 * 2) * 256,
+ (ro_plot_origin_y - y0 * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + (x1) * 2) * 256,
+ (ro_plot_origin_y - y0 * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + (x1) * 2) * 256,
+ (ro_plot_origin_y - (y1) * 2 - 1) * 256,
+ draw_LINE_TO,
+ (ro_plot_origin_x + x0 * 2) * 256,
+ (ro_plot_origin_y - (y1) * 2 - 1) * 256,
+ draw_CLOSE_LINE,
+ (ro_plot_origin_x + x0 * 2) * 256,
+ (ro_plot_origin_y - y0 * 2 - 1) * 256,
+ draw_END_PATH };
+
+ if (style->stroke_type == PLOT_OP_TYPE_DOT)
+ dotted = true;
+
+ if (style->stroke_type == PLOT_OP_TYPE_DASH)
+ dashed = true;
+
+ ro_plot_draw_path((const draw_path *)path,
+ style->stroke_width,
+ style->stroke_colour,
+ dotted, dashed);
+ }
+
+ return true;
}
@@ -303,37 +343,6 @@ error:
}
-bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
-{
- os_error *error;
-
- error = xcolourtrans_set_gcol(style->fill_colour << 8,
- colourtrans_USE_ECFS_GCOL,
- os_ACTION_OVERWRITE, 0, 0);
- if (error) {
- LOG(("xcolourtrans_set_gcol: 0x%x: %s",
- error->errnum, error->errmess));
- return false;
- }
-
- error = xos_plot(os_MOVE_TO,
- ro_plot_origin_x + x0 * 2,
- ro_plot_origin_y - y0 * 2 - 1);
- if (error) {
- LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
- return false;
- }
-
- error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- ro_plot_origin_x + x1 * 2 - 1,
- ro_plot_origin_y - y1 * 2);
- if (error) {
- LOG(("xos_plot: 0x%x: %s", error->errnum, error->errmess));
- return false;
- }
-
- return true;
-}
bool ro_plot_clip(int clip_x0, int clip_y0,
diff --git a/riscos/print.c b/riscos/print.c
index a216bbee4..c06b235dd 100644
--- a/riscos/print.c
+++ b/riscos/print.c
@@ -97,12 +97,10 @@ static void print_send_printsave(struct content *c);
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 width, int height,
- int line_width, colour c, bool dotted, bool dashed);
+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_polygon(const int *p, unsigned int n, colour fill);
-static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool print_fonts_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool print_fonts_plot_text(int x, int y, const struct css_style *style,
@@ -128,7 +126,6 @@ static const struct plotter_table print_fonts_plotters = {
.rectangle = print_fonts_plot_rectangle,
.line = print_fonts_plot_line,
.polygon = print_fonts_plot_polygon,
- .fill = print_fonts_plot_fill,
.clip = print_fonts_plot_clip,
.text = print_fonts_plot_text,
.disc = print_fonts_plot_disc,
@@ -807,12 +804,12 @@ end:
}
-bool print_fonts_plot_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed)
+bool print_fonts_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
return true;
}
+
bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
@@ -824,10 +821,6 @@ bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill)
return true;
}
-bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
-{
- return true;
-}
bool print_fonts_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1)
diff --git a/riscos/save_draw.c b/riscos/save_draw.c
index f74608cf3..4a8f8d64d 100644
--- a/riscos/save_draw.c
+++ b/riscos/save_draw.c
@@ -37,14 +37,12 @@
#include "utils/log.h"
#include "utils/utils.h"
-static bool ro_save_draw_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed);
+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_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]);
-static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool ro_save_draw_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool ro_save_draw_text(int x, int y, const struct css_style *style,
@@ -64,7 +62,6 @@ static const struct plotter_table ro_save_draw_plotters = {
.rectangle = ro_save_draw_rectangle,
.line = ro_save_draw_line,
.polygon = ro_save_draw_polygon,
- .fill = ro_save_draw_fill,
.clip = ro_save_draw_clip,
.text = ro_save_draw_text,
.disc = ro_save_draw_disc,
@@ -143,25 +140,54 @@ bool save_as_draw(struct content *c, const char *path)
return true;
}
-bool ro_save_draw_rectangle(int x0, int y0, int width, int height,
- int line_width, colour c, bool dotted, bool dashed)
+bool ro_save_draw_rectangle(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, (x0 + width) * 2, -y0 * 2 - 1,
- draw_LINE_TO, (x0 + width) * 2, -(y0 + height) * 2 - 1,
- draw_LINE_TO, x0 * 2, -(y0 + height) * 2 - 1,
- draw_CLOSE_LINE,
- 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);
- if (code != pencil_OK)
- return ro_save_draw_error(code);
+ draw_LINE_TO, x1 * 2, -y0 * 2 - 1,
+ draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
+ draw_LINE_TO, x0 * 2, -y1 * 2 - 1,
+ draw_CLOSE_LINE,
+ draw_END_PATH };
+
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+
+ code = pencil_path(ro_save_draw_diagram,
+ path,
+ sizeof path / sizeof path[0],
+ style->fill_colour << 8,
+ pencil_TRANSPARENT,
+ 0,
+ pencil_JOIN_MITRED,
+ pencil_CAP_BUTT,
+ pencil_CAP_BUTT,
+ 0,
+ 0,
+ false,
+ pencil_SOLID);
+ if (code != pencil_OK)
+ return ro_save_draw_error(code);
+ }
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+
+ 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);
+ }
return true;
}
@@ -302,27 +328,6 @@ bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
}
-bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
-{
- pencil_code code;
- const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y0 * 2 - 1,
- draw_LINE_TO, x1 * 2, -y1 * 2 - 1,
- draw_LINE_TO, x0 * 2, -y1 * 2 - 1,
- draw_CLOSE_LINE,
- draw_END_PATH };
-
- code = pencil_path(ro_save_draw_diagram, path,
- sizeof path / sizeof path[0],
- style->fill_colour << 8,
- pencil_TRANSPARENT, 0, pencil_JOIN_MITRED,
- pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
- pencil_SOLID);
- if (code != pencil_OK)
- return ro_save_draw_error(code);
-
- return true;
-}
bool ro_save_draw_clip(int clip_x0, int clip_y0,
diff --git a/riscos/window.c b/riscos/window.c
index 5b73d8783..d8637661b 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1483,7 +1483,7 @@ void ro_gui_window_redraw(wimp_draw *redraw)
plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
if (c->type != CONTENT_HTML)
- plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white);
+ plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white);
/* Redraw the clip rectangle area of the content */
content_redraw(c, 0, 0,