summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-02-14 22:05:39 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-02-14 22:05:39 +0000
commit94e7b44ebc1710eed0f870428ddb5bfcd85858fa (patch)
tree2d75845c082051bac12cd41cf2d5139e019c16bf /riscos
parent3ce0613193ca945566ec9ea056d6a67eae7d199c (diff)
downloadnetsurf-94e7b44ebc1710eed0f870428ddb5bfcd85858fa.tar.gz
netsurf-94e7b44ebc1710eed0f870428ddb5bfcd85858fa.tar.bz2
Pass clip rect to clip plotters as struct. Simplify clip rect handling in debug window code. Pass clip rect to select menu as struct.
svn path=/trunk/netsurf/; revision=11683
Diffstat (limited to 'riscos')
-rw-r--r--riscos/debugwin.c81
-rw-r--r--riscos/gui/progress_bar.c18
-rw-r--r--riscos/plotters.c14
-rw-r--r--riscos/print.c6
-rw-r--r--riscos/save_draw.c6
-rw-r--r--riscos/treeview.c11
6 files changed, 60 insertions, 76 deletions
diff --git a/riscos/debugwin.c b/riscos/debugwin.c
index dd7a134b4..c32731a71 100644
--- a/riscos/debugwin.c
+++ b/riscos/debugwin.c
@@ -61,11 +61,10 @@ enum align {
static plot_font_style_t fstyle;
static plot_style_t style;
-static void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1);
+static void debugwin_redraw(const struct rect *clip);
static void debugwin_get_size(int *width, int *height);
static bool debugwin_render_cell(int x, int y, int width, int height,
- const char *text, enum align align, int clip_x0, int clip_y0,
- int clip_x1, int clip_y1);
+ const char *text, enum align align, const struct rect *clip);
#endif
@@ -152,21 +151,21 @@ void ro_gui_debugwin_redraw(wimp_draw *redraw)
return;
}
while (more) {
- int clip_x0, clip_y0, clip_x1, clip_y1;
+ struct rect clip;
/* Sep plot origin */
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
/* Set clip rectangle */
- 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 */
- plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
+ 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 */
+ plot.clip(&clip);
/* Render the content debug table */
- debugwin_redraw(clip_x0, clip_y0, clip_x1, clip_y1);
+ debugwin_redraw(&clip);
error = xwimp_get_rectangle(redraw, &more);
if (error) {
@@ -179,7 +178,7 @@ void ro_gui_debugwin_redraw(wimp_draw *redraw)
}
-void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
+void debugwin_redraw(const struct rect *clip)
{
char s[40];
int y, x, w;
@@ -225,38 +224,31 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
x = 0;
w = w_url;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "url", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "url", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_type;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "type", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "type", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_fresh;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "fresh", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "fresh", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_mime_type;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "mime-type", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "mime-type", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_users;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "users", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "users", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_status;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "status", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "status", DEBUGWIN_CENTRE, clip);
x += w + 1;
w = w_size;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- "size", DEBUGWIN_CENTRE, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ "size", DEBUGWIN_CENTRE, clip);
/* Move down to next row */
y += DEBUGWIN_TEXT_HEIGHT + 2 * DEBUGWIN_CELL_PADDING + 1;
@@ -273,20 +265,19 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
x = 0;
w = w_url;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- content->url, DEBUGWIN_RIGHT, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ content->url, DEBUGWIN_RIGHT, clip);
/* Create Type cell */
x += w + 1;
w = w_type;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
content_type_name[content->type], DEBUGWIN_LEFT,
- clip_x0, clip_y0, clip_x1, clip_y1);
+ clip);
/* Create cell for showing wheher content is fresh */
x += w + 1;
w = w_fresh;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
content->fresh ? "yes" : "no", DEBUGWIN_LEFT,
- clip_x0, clip_y0, clip_x1, clip_y1);
+ clip);
/* Create Mime-type cell */
x += w + 1;
w = w_mime_type;
@@ -302,15 +293,13 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
x += w + 1;
w = w_users;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- s, DEBUGWIN_RIGHT, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ s, DEBUGWIN_RIGHT, clip);
/* Create Status cell */
x += w + 1;
w = w_status;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
content_status_name[content->status],
- DEBUGWIN_LEFT, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ DEBUGWIN_LEFT, clip);
/* Create Size cell */
talloc_size = talloc_total_size(content);
snprintf(s, sizeof s, "%u+%u= %u", content->size, talloc_size,
@@ -318,8 +307,7 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
x += w + 1;
w = w_size;
debugwin_render_cell(x, y, w, DEBUGWIN_TEXT_HEIGHT,
- s, DEBUGWIN_RIGHT, clip_x0, clip_y0,
- clip_x1, clip_y1);
+ s, DEBUGWIN_RIGHT, clip);
/* Keep running total of size used */
size += content->size + talloc_size;
@@ -332,7 +320,7 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
/* Show total size */
debugwin_render_cell(DEBUGWIN_WINDOW_WIDTH - w_size, y,
w_size, DEBUGWIN_TEXT_HEIGHT, s, DEBUGWIN_RIGHT,
- clip_x0, clip_y0, clip_x1, clip_y1);
+ clip);
/* Heading cell for total size */
fstyle.weight = 900;
@@ -342,7 +330,7 @@ void debugwin_redraw(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
debugwin_render_cell(0, y,
DEBUGWIN_WINDOW_WIDTH - w_size - 1,
DEBUGWIN_TEXT_HEIGHT, "total size:", DEBUGWIN_RIGHT,
- clip_x0, clip_y0, clip_x1, clip_y1);
+ clip);
// if (want_knockout)
// knockout_plot_end();
@@ -369,24 +357,25 @@ void debugwin_get_size(int *width, int *height)
bool debugwin_render_cell(int x, int y, int width, int height,
- const char *text, enum align align, int clip_x0, int clip_y0,
- int clip_x1, int clip_y1)
+ const char *text, enum align align, const struct rect *clip)
{
int text_width;
size_t length;
+ struct rect r;
height += 2 * DEBUGWIN_CELL_PADDING;
/* Return if the rectangle is completely outside the clip rectangle */
- if (clip_y1 < y || y + height < clip_y0 ||
- clip_x1 < x || x + width < clip_x0)
+ if (clip->y1 < y || y + height < clip->y0 ||
+ clip->x1 < x || x + width < clip->x0)
return true;
/* Clip to intersection of clip rectangle and cell */
- if (!plot.clip( (x < clip_x0) ? clip_x0 : x,
- (y < clip_y0) ? clip_y0 : y,
- (clip_x1 < x + width) ? clip_x1 : x + width,
- (clip_y1 < y + height) ? clip_y1 : y + height))
+ r.x0 = (x < clip->x0) ? clip->x0 : x;
+ r.y0 = (y < clip->y0) ? clip->y0 : y;
+ r.x1 = (clip->x1 < x + width) ? clip->x1 : x + width;
+ r.y1 = (clip->y1 < y + height) ? clip->y1 : y + height);
+ if (!plot.clip(&r))
return false;
/* Plot cell background */
@@ -425,7 +414,7 @@ bool debugwin_render_cell(int x, int y, int width, int height,
return false;
/* Restore previous clip rectangle */
- if (!plot.clip(clip_x0, clip_y0, clip_x1, clip_y1))
+ if (!plot.clip(clip))
return false;
return true;
diff --git a/riscos/gui/progress_bar.c b/riscos/gui/progress_bar.c
index bee9581aa..5c90195ad 100644
--- a/riscos/gui/progress_bar.c
+++ b/riscos/gui/progress_bar.c
@@ -468,7 +468,7 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
{
os_error *error;
osbool more = true;
- int clip_x0 = 0, clip_y0 = 0, clip_x1 = 0, clip_y1 = 0;
+ struct rect clip;
int progress_ymid;
/* initialise the plotters */
@@ -492,25 +492,25 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
redraw->box.y0 + pb->icon_y0,
tinct_ERROR_DIFFUSE);
if (!pb->icon_obscured) {
- clip_x0 = max(redraw->clip.x0,
+ clip.x0 = max(redraw->clip.x0,
redraw->box.x0 + pb->visible.x0) >> 1;
- clip_y0 = -min(redraw->clip.y1,
+ clip.y0 = -min(redraw->clip.y1,
redraw->box.y0 + pb->visible.y1) >> 1;
- clip_x1 = min(redraw->clip.x1,
+ clip.x1 = min(redraw->clip.x1,
redraw->box.x0 + pb->visible.x1) >> 1;
- clip_y1 = -max(redraw->clip.y0,
+ clip.y1 = -max(redraw->clip.y0,
redraw->box.y0 + pb->visible.y0) >> 1;
- if ((clip_x0 < clip_x1) && (clip_y0 < clip_y1)) {
+ if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) {
if (progress_icon) {
- plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
+ plot.clip(&clip);
_swix(Tinct_Plot, _IN(2) | _IN(3) | _IN(4) | _IN(7),
progress_icon,
redraw->box.x0 - pb->offset,
progress_ymid - progress_height,
tinct_FILL_HORIZONTALLY);
} else {
- plot.rectangle(clip_x0, clip_y0,
- clip_x1, clip_y1,
+ plot.rectangle(clip.x0, clip.y0,
+ clip.x1, clip.y1,
plot_style_fill_red);
}
}
diff --git a/riscos/plotters.c b/riscos/plotters.c
index 1323835d0..8d489fc0f 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -41,8 +41,7 @@ static bool ro_plot_draw_path(const draw_path * const path, int width,
static bool ro_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
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_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1);
+static bool ro_plot_clip(const struct rect *clip);
static bool ro_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool ro_plot_disc(int x, int y, int radius, const plot_style_t *style);
@@ -356,16 +355,15 @@ error:
-bool ro_plot_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1)
+bool ro_plot_clip(const struct rect *clip)
{
os_error *error;
char buf[12];
- clip_x0 = ro_plot_origin_x + clip_x0 * 2;
- clip_y0 = ro_plot_origin_y - clip_y0 * 2 - 1;
- clip_x1 = ro_plot_origin_x + clip_x1 * 2 - 1;
- clip_y1 = ro_plot_origin_y - clip_y1 * 2;
+ int clip_x0 = ro_plot_origin_x + clip->x0 * 2;
+ int clip_y0 = ro_plot_origin_y - clip->y0 * 2 - 1;
+ int clip_x1 = ro_plot_origin_x + clip->x1 * 2 - 1;
+ int clip_y1 = ro_plot_origin_y - clip->y1 * 2;
if (clip_x1 < clip_x0 || clip_y0 < clip_y1) {
LOG(("bad clip rectangle %i %i %i %i",
diff --git a/riscos/print.c b/riscos/print.c
index 575990f27..1a66e7e12 100644
--- a/riscos/print.c
+++ b/riscos/print.c
@@ -103,8 +103,7 @@ static const char *print_declare_fonts(hlcache_handle *h);
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, const plot_style_t *style);
static bool print_fonts_plot_polygon(const int *p, unsigned int n, const 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_clip(const struct rect *clip);
static bool print_fonts_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool print_fonts_plot_disc(int x, int y, int radius, const plot_style_t *style);
@@ -872,8 +871,7 @@ bool print_fonts_plot_polygon(const int *p, unsigned int n, const plot_style_t *
}
-bool print_fonts_plot_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1)
+bool print_fonts_plot_clip(const struct rect *clip)
{
return true;
}
diff --git a/riscos/save_draw.c b/riscos/save_draw.c
index 5fa93e4f7..765fb5c3b 100644
--- a/riscos/save_draw.c
+++ b/riscos/save_draw.c
@@ -44,8 +44,7 @@ static bool ro_save_draw_line(int x0, int y0, int x1, int y1, const plot_style_t
static bool ro_save_draw_polygon(const int *p, unsigned int n, const plot_style_t *style);
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_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1);
+static bool ro_save_draw_clip(const struct rect *clip);
static bool ro_save_draw_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool ro_save_draw_disc(int x, int y, int radius, const plot_style_t *style);
@@ -347,8 +346,7 @@ bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
-bool ro_save_draw_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1)
+bool ro_save_draw_clip(const struct rect *clip)
{
return true;
}
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 7cf711677..afd636519 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -358,6 +358,7 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
if (tv != NULL && tv->tree != NULL) {
+ struct rect clip;
tree_draw(tv->tree, tv->origin.x/2, -(tv->origin.y/2),
(redraw->clip.x0
-(ro_plot_origin_x+tv->origin.x))/2,
@@ -367,11 +368,11 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
(redraw->clip.y1 - redraw->clip.y0)/2);
/* Put the graphcis window back how the Wimp set it. */
-
- plot.clip((redraw->clip.x0 - ro_plot_origin_x)/2,
- (ro_plot_origin_y - redraw->clip.y1)/2,
- (redraw->clip.x1 - ro_plot_origin_x)/2,
- (ro_plot_origin_y - redraw->clip.y0)/2);
+ clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
+ clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
+ clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2;
+ clip.y1 = (ro_plot_origin_y - redraw->clip.y0) / 2;
+ plot.clip(&clip);
}
error = xwimp_get_rectangle(redraw, &more);