diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c index 2ef05da29..921671217 100644 --- a/frontends/riscos/corewindow.c +++ b/frontends/riscos/corewindow.c @@ -120,10 +120,15 @@ static void ro_cw_redraw(wimp_draw *redraw) origin_x = redraw->box.x0 - redraw->xscroll; origin_y = redraw->box.y1 + ro_cw->origin_y - redraw->yscroll; - r.x0 = (redraw->clip.x0 - origin_x) / 2; - r.y0 = (origin_y - redraw->clip.y1) / 2; - r.x1 = r.x0 + ((redraw->clip.x1 - redraw->clip.x0) / 2); - r.y1 = r.y0 + ((redraw->clip.y1 - redraw->clip.y0) / 2); + ro_plot_clip_rect.x0 = redraw->clip.x0 - origin_x; + ro_plot_clip_rect.y0 = origin_y - redraw->clip.y0; + ro_plot_clip_rect.x1 = redraw->clip.x1 - origin_x; + ro_plot_clip_rect.y1 = origin_y - redraw->clip.y1; + + r.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */ + r.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */ + r.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */ + r.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */ /* call the draw callback */ ro_cw->draw(ro_cw, origin_x, origin_y, &r); diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h index 831c57dc7..5ff17e922 100644 --- a/frontends/riscos/gui.h +++ b/frontends/riscos/gui.h @@ -165,6 +165,7 @@ void ro_gui_print_prepare(struct gui_window *g); extern const struct plotter_table ro_plotters; extern int ro_plot_origin_x; extern int ro_plot_origin_y; +extern struct rect ro_plot_clip_rect; /* in theme_install.c */ bool ro_gui_theme_install_apply(wimp_w w); diff --git a/frontends/riscos/plotters.c b/frontends/riscos/plotters.c index 25c953f97..e38e746cd 100644 --- a/frontends/riscos/plotters.c +++ b/frontends/riscos/plotters.c @@ -39,6 +39,7 @@ int ro_plot_origin_x = 0; int ro_plot_origin_y = 0; +struct rect ro_plot_clip_rect; /** One version of the A9home OS is incapable of drawing patterned lines */ bool ro_plot_patterned_lines = true; @@ -115,6 +116,14 @@ ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip) int clip_x1 = clip->x1 * 2; int clip_y1 = clip->y0 * 2; + /* Avoid artefacts due to clip rectangle offsetting in EX0 EY0 modes. + * The area the WIMP asked us to draw might have dimensions that are + * not a multiple of 2. */ + if (clip_x0 < ro_plot_clip_rect.x0) clip_x0 = ro_plot_clip_rect.x0; + if (clip_x1 > ro_plot_clip_rect.x1) clip_x1 = ro_plot_clip_rect.x1; + if (clip_y0 > ro_plot_clip_rect.y0) clip_y0 = ro_plot_clip_rect.y0; + if (clip_y1 < ro_plot_clip_rect.y1) clip_y1 = ro_plot_clip_rect.y1; + clip_x0 = ro_plot_origin_x + clip_x0; clip_y0 = ro_plot_origin_y - clip_y0; clip_x1 = ro_plot_origin_x + clip_x1 - 1; diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c index f1728afce..24662365c 100644 --- a/frontends/riscos/window.c +++ b/frontends/riscos/window.c @@ -1685,13 +1685,19 @@ static void ro_gui_window_redraw(wimp_draw *redraw) ro_plot_origin_x = redraw->box.x0 - redraw->xscroll; ro_plot_origin_y = redraw->box.y1 - redraw->yscroll; + /* Adjust clip rect for origin. */ + ro_plot_clip_rect.x0 = redraw->clip.x0 - ro_plot_origin_x; + ro_plot_clip_rect.y0 = ro_plot_origin_y - redraw->clip.y0; + ro_plot_clip_rect.x1 = redraw->clip.x1 - ro_plot_origin_x; + ro_plot_clip_rect.y1 = ro_plot_origin_y - redraw->clip.y1; + /* Convert OS redraw rectangle request coordinates into NetSurf * coordinates. NetSurf coordinates have origin at top left of * document and units are in px. */ - clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2; /* left */ - clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2; /* top */ - clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2; /* right */ - clip.y1 = (ro_plot_origin_y - redraw->clip.y0) / 2; /* bottom */ + clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */ + clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */ + clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */ + clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */ if (ro_gui_current_redraw_gui->option.buffer_everything) ro_gui_buffer_open(redraw); @@ -4715,10 +4721,19 @@ void ro_gui_window_update_boxes(void) ro_plot_origin_y = update.box.y1 - update.yscroll; while (more) { - clip.x0 = (update.clip.x0 - ro_plot_origin_x) / 2; - clip.y0 = (ro_plot_origin_y - update.clip.y1) / 2; - clip.x1 = (update.clip.x1 - ro_plot_origin_x) / 2; - clip.y1 = (ro_plot_origin_y - update.clip.y0) / 2; + /* Adjust clip rect for origin. */ + ro_plot_clip_rect.x0 = update.clip.x0 - ro_plot_origin_x; + ro_plot_clip_rect.y0 = ro_plot_origin_y - update.clip.y0; + ro_plot_clip_rect.x1 = update.clip.x1 - ro_plot_origin_x; + ro_plot_clip_rect.y1 = ro_plot_origin_y - update.clip.y1; + + /* Convert OS redraw rectangle request coordinates into + * NetSurf coordinates. NetSurf coordinates have origin + * at top left of document and units are in px. */ + clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */ + clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */ + clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */ + clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */ if (use_buffer) ro_gui_buffer_open(&update);