From 94e7b44ebc1710eed0f870428ddb5bfcd85858fa Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 14 Feb 2011 22:05:39 +0000 Subject: 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 --- amiga/plotters.c | 13 ++++--- amiga/plotters.h | 2 +- atari/browser.c | 20 ++++++---- atari/plot.c | 4 +- atari/plot.h | 4 +- beos/beos_plotters.cpp | 37 ++++++++++++------- cocoa/plotter.m | 6 +-- desktop/browser.c | 2 +- desktop/history_core.c | 7 +++- desktop/knockout.c | 77 +++++++++++++-------------------------- desktop/plotters.h | 3 +- desktop/save_pdf/pdf_plotters.c | 15 ++++---- desktop/textarea.c | 4 +- desktop/tree.c | 29 ++++++++------- framebuffer/framebuffer.c | 14 +++---- gtk/plotters.c | 14 +++---- gtk/print.c | 12 +++--- gtk/scaffolding.c | 10 +++-- gtk/thumbnail.c | 2 +- render/form.c | 30 ++++++++------- render/form.h | 5 +-- render/html_redraw.c | 43 ++++++++++++---------- riscos/debugwin.c | 81 ++++++++++++++++++----------------------- riscos/gui/progress_bar.c | 18 ++++----- riscos/plotters.c | 14 +++---- riscos/print.c | 6 +-- riscos/save_draw.c | 6 +-- riscos/treeview.c | 11 +++--- windows/plot.c | 13 +++---- 29 files changed, 246 insertions(+), 256 deletions(-) diff --git a/amiga/plotters.c b/amiga/plotters.c index f89b12c04..9c61ad259 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -400,7 +400,7 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style) } -bool ami_clip(int x0, int y0, int x1, int y1) +bool ami_clip(const struct rect *clip) { #ifdef AMI_PLOTTER_DEBUG LOG(("[ami_plotter] Entered ami_clip()")); @@ -412,10 +412,10 @@ bool ami_clip(int x0, int y0, int x1, int y1) { reg = NewRegion(); - glob->rect.MinX = x0; - glob->rect.MinY = y0; - glob->rect.MaxX = x1-1; - glob->rect.MaxY = y1-1; + glob->rect.MinX = clip->x0; + glob->rect.MinY = clip->y0; + glob->rect.MaxX = clip->x1-1; + glob->rect.MaxY = clip->y1-1; OrRectRegion(reg,&glob->rect); @@ -426,7 +426,8 @@ bool ami_clip(int x0, int y0, int x1, int y1) #ifdef NS_AMIGA_CAIRO_ALL cairo_reset_clip(glob->cr); - cairo_rectangle(glob->cr, x0, y0, x1 - x0, y1 - y0); + cairo_rectangle(glob->cr, clip->x0, clip->y0, + clip->x1 - clip->x0, clip->y1 - clip->y0); cairo_clip(glob->cr); #endif diff --git a/amiga/plotters.h b/amiga/plotters.h index c58acfb8e..7bd42af6f 100755 --- a/amiga/plotters.h +++ b/amiga/plotters.h @@ -46,7 +46,7 @@ bool ami_clg(colour c); bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style); bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style); -bool ami_clip(int x0, int y0, int x1, int y1); +bool ami_clip(const struct rect *clip); bool ami_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); bool ami_disc(int x, int y, int radius, const plot_style_t *style); diff --git a/atari/browser.c b/atari/browser.c index 2c667a5d7..8d2f79ca5 100755 --- a/atari/browser.c +++ b/atari/browser.c @@ -873,9 +873,7 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff ) clip.x1 = b->redraw.area.x1 + b->scroll.current.x; clip.y1 = b->redraw.area.y1 + b->scroll.current.y; /* must clear the surface: */ - plot.clip( b->redraw.area.x0, b->redraw.area.y0, - b->redraw.area.x1, b->redraw.area.y1 - ); + plot.clip(&clip); plot.rectangle( b->redraw.area.x0, b->redraw.area.y0, b->redraw.area.x1, @@ -911,16 +909,24 @@ void browser_redraw_caret( struct gui_window * gw, GRECT * area ) caret.g_x -= gw->browser->scroll.current.x; caret.g_y -= gw->browser->scroll.current.y; struct s_clipping oldclip; + struct rect old_clip; + struct rect clip; + clip.x0 = caret.g_x - 1; + clip.y0 = caret.g_y - 1; + clip.x1 = caret.g_x + caret.g_w + 1; + clip.y1 = caret.g_y + caret.g_h + 1; plot_get_clip( &oldclip ); /* clip to cursor: */ - plot_clip( caret.g_x-1, caret.g_y -1, - caret.g_x + caret.g_w + 1, caret.g_y + caret.g_h + 1 - ); + plot_clip( &clip ); plot_rectangle( caret.g_x, caret.g_y, caret.g_x+caret.g_w, caret.g_y+caret.g_h, plot_style_caret ); /* restore clip area: */ - plot_clip( oldclip.x0, oldclip.y0, oldclip.x1,oldclip.y1); + old_clip.x0 = old_clip.x0; + old_clip.y0 = old_clip.y0; + old_clip.x1 = old_clip.x1; + old_clip.y1 = old_clip.y1; + plot_clip( &old_clip ); b->caret.current.g_x = caret.g_x + gw->browser->scroll.current.x; b->caret.current.g_y = caret.g_y + gw->browser->scroll.current.y; b->caret.current.g_w = caret.g_w; diff --git a/atari/plot.c b/atari/plot.c index 2bfe37923..2d45f1f63 100755 --- a/atari/plot.c +++ b/atari/plot.c @@ -110,9 +110,9 @@ static bool plot_polygon(const int *p, unsigned int n, return ( true ); } -bool plot_clip(int x0, int y0, int x1, int y1) +bool plot_clip(const struct rect *clip) { - plotter->clip( plotter, x0, y0, x1, y1 ); + plotter->clip( plotter, clip->x0, clip->y0, clip->x1, clip->y1 ); return ( true ); } diff --git a/atari/plot.h b/atari/plot.h index ed86041e5..a11b6d576 100755 --- a/atari/plot.h +++ b/atari/plot.h @@ -22,11 +22,13 @@ #include "desktop/plotters.h" #include "atari/plot/plotter.h" +struct rect; + int atari_plotter_init( char*, char * ); int atari_plotter_finalise( void ); bool plot_get_clip(struct s_clipping * out); -bool plot_clip(int x0, int y0, int x1, int y1); +bool plot_clip(const struct rect *clip); bool plot_rectangle( int x0, int y0, int x1, int y1,const plot_style_t *style ); #endif diff --git a/beos/beos_plotters.cpp b/beos/beos_plotters.cpp index e3372963e..8c65d7ac3 100644 --- a/beos/beos_plotters.cpp +++ b/beos/beos_plotters.cpp @@ -66,8 +66,7 @@ static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t static bool nsbeos_plot_polygon(const int *p, unsigned int n, const plot_style_t *style); static bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width, colour c, const float transform[6]); -static bool nsbeos_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1); +static bool nsbeos_plot_clip(const struct clip *rect); static bool nsbeos_plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); static bool nsbeos_plot_disc(int x, int y, int radius, const plot_style_t *style); @@ -316,8 +315,7 @@ bool nsbeos_plot_polygon(const int *p, unsigned int n, const plot_style_t *style -bool nsbeos_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1) +bool nsbeos_plot_clip(const struct rect *ns_clip) { BView *view; //fprintf(stderr, "%s(%d, %d, %d, %d)\n", __FUNCTION__, clip_x0, clip_y0, clip_x1, clip_y1); @@ -328,7 +326,8 @@ bool nsbeos_plot_clip(int clip_x0, int clip_y0, return false; } - BRect rect(clip_x0, clip_y0, clip_x1 - 1, clip_y1 - 1); + BRect rect(ns_clip->x0, ns_clip->y0, ns_clip->x1 - 1, + ns_clip->y1 - 1); BRegion clip(rect); view->ConstrainClippingRegion(NULL); if (view->Bounds() != rect) @@ -341,15 +340,15 @@ bool nsbeos_plot_clip(int clip_x0, int clip_y0, #ifdef CAIRO_VERSION if (option_render_cairo) { cairo_reset_clip(current_cr); - cairo_rectangle(current_cr, clip_x0, clip_y0, - clip_x1 - clip_x0, clip_y1 - clip_y0); + cairo_rectangle(current_cr, clip->x0, clip->y0, + clip->x1 - clip->x0, clip->y1 - clip->y0); cairo_clip(current_cr); } #endif - cliprect.x = clip_x0; - cliprect.y = clip_y0; - cliprect.width = clip_x1 - clip_x0; - cliprect.height = clip_y1 - clip_y0; + cliprect.x = clip->x0; + cliprect.y = clip->y0; + cliprect.width = clip->x1 - clip->x0; + cliprect.height = clip->y1 - clip->y0; gdk_gc_set_clip_rectangle(current_gc, &cliprect); #endif return true; @@ -835,6 +834,7 @@ static void test_plotters(void) { int x0, y0; int x1, y1; + struct rect r; x0 = 5; y0 = 5; @@ -853,10 +853,21 @@ static void test_plotters(void) plot.fill(x0, y0, x1, y1, 0x00ff0000); plot.rectangle(x0+10, y0+10, x1-x0+1, y1-y0+1, 2, 0x00ffff00, true, false); y0+=30; y1+=30; - plot.clip(x0 + 2, y0 + 2, x1 - 2, y1 - 2); + + r.x0 = x0 + 2; + r.y0 = y0 + 2; + r.x1 = x1 - 2; + r.y1 = y1 - 2; + plot.clip(&r); + plot.fill(x0, y0, x1, y1, 0x00000000); plot.disc(x1, y1, 8, 0x000000ff, false); - plot.clip(0, 0, 300, 300); + + r.x0 = 0; + r.y0 = 0; + r.x1 = 300; + r.y1 = 300; + plot.clip(&r); y0+=30; y1+=30; diff --git a/cocoa/plotter.m b/cocoa/plotter.m index 63ec807a0..c51e82c91 100644 --- a/cocoa/plotter.m +++ b/cocoa/plotter.m @@ -124,9 +124,9 @@ void cocoa_set_clip( NSRect rect ) cocoa_plot_clip_rect = rect; } -static bool plot_clip(int x0, int y0, int x1, int y1) +static bool plot_clip(const struct rect *clip) { - cocoa_plot_clip_rect = cocoa_rect( x0, y0, x1, y1 ); + cocoa_plot_clip_rect = cocoa_rect( clip->x0, clip->y0, clip->x1, clip->y1 ); return true; } @@ -329,4 +329,4 @@ static inline void cocoa_center_pixel( bool x, bool y ) NSAffineTransform *transform = [NSAffineTransform transform]; [transform translateXBy: x ? cocoa_half_pixel : 0.0 yBy: y ? cocoa_half_pixel : 0.0]; [transform concat]; -} \ No newline at end of file +} diff --git a/desktop/browser.c b/desktop/browser.c index 36661f1de..351b327c6 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -100,7 +100,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y, return false; } - plot.clip(clip->x0, clip->y0, clip->x1, clip->y1); + plot.clip(clip); if (bw->current_content == NULL) { return plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1, diff --git a/desktop/history_core.c b/desktop/history_core.c index ee964ad6d..96a760a9d 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -628,7 +628,12 @@ bool history_redraw_entry(struct history *history, plot_font_style_t fstyle = *plot_style_font; if (clip) { - if(!plot.clip(x0 + xoffset, y0 + yoffset, x1 + xoffset, y1 + yoffset)) + struct rect rect; + rect.x0 = x0 + xoffset; + rect.y0 = y0 + yoffset; + rect.x1 = x1 + xoffset; + rect.y1 = y1 + yoffset; + if(!plot.clip(&rect)) return false; } diff --git a/desktop/knockout.c b/desktop/knockout.c index 680257b0f..3525df972 100644 --- a/desktop/knockout.c +++ b/desktop/knockout.c @@ -88,8 +88,7 @@ static bool knockout_plot_bitmap_recursive(struct knockout_box *box, static bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle); static bool knockout_plot_polygon(const int *p, unsigned int n, const plot_style_t *pstyle); static bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *plot_style); -static bool knockout_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1); +static bool knockout_plot_clip(const struct rect *clip); static bool knockout_plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); static bool knockout_plot_disc(int x, int y, int radius, const plot_style_t *pstyle); @@ -137,12 +136,7 @@ typedef enum { struct knockout_box { - struct { - int x0; - int y0; - int x1; - int y1; - } bbox; + struct rect bbox; bool deleted; /* box has been deleted, ignore */ struct knockout_box *child; struct knockout_box *next; @@ -179,12 +173,7 @@ struct knockout_entry { int y1; plot_style_t plot_style; } fill; - struct { - int x0; - int y0; - int x1; - int y1; - } clip; + struct rect clip; struct { int x; int y; @@ -232,10 +221,7 @@ static struct knockout_box *knockout_list = NULL; static struct plotter_table real_plot; -static int clip_x0_cur; -static int clip_y0_cur; -static int clip_x1_cur; -static int clip_y1_cur; +static struct rect clip_cur; static int nested_depth = 0; /** @@ -339,10 +325,7 @@ bool knockout_plot_flush(void) break; case KNOCKOUT_PLOT_CLIP: success &= plot.clip( - knockout_entries[i].data.clip.x0, - knockout_entries[i].data.clip.y0, - knockout_entries[i].data.clip.x1, - knockout_entries[i].data.clip.y1); + &knockout_entries[i].data.clip); break; case KNOCKOUT_PLOT_TEXT: success &= plot.text( @@ -584,10 +567,7 @@ bool knockout_plot_bitmap_recursive(struct knockout_box *box, if (parent->child) knockout_plot_bitmap_recursive(parent->child, entry); else { - success &= plot.clip(parent->bbox.x0, - parent->bbox.y0, - parent->bbox.x1, - parent->bbox.y1); + success &= plot.clip(&parent->bbox); success &= plot.bitmap(entry->data.bitmap.x, entry->data.bitmap.y, entry->data.bitmap.width, @@ -608,12 +588,12 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t /* filled draw */ /* get our bounds */ - kx0 = (x0 > clip_x0_cur) ? x0 : clip_x0_cur; - ky0 = (y0 > clip_y0_cur) ? y0 : clip_y0_cur; - kx1 = (x1 < clip_x1_cur) ? x1 : clip_x1_cur; - ky1 = (y1 < clip_y1_cur) ? y1 : clip_y1_cur; - if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur) || - (ky0 > clip_y1_cur) || (ky1 < clip_y0_cur)) + kx0 = (x0 > clip_cur.x0) ? x0 : clip_cur.x0; + ky0 = (y0 > clip_cur.y0) ? y0 : clip_cur.y0; + kx1 = (x1 < clip_cur.x1) ? x1 : clip_cur.x1; + ky1 = (y1 < clip_cur.y1) ? y1 : clip_cur.y1; + if ((kx0 > clip_cur.x1) || (kx1 < clip_cur.x0) || + (ky0 > clip_cur.y1) || (ky1 < clip_cur.y0)) return true; /* fills both knock out and get knocked out */ @@ -707,25 +687,18 @@ bool knockout_plot_path(const float *p, unsigned int n, colour fill, } -bool knockout_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1) +bool knockout_plot_clip(const struct rect *clip) { - if (clip_x1 < clip_x0 || clip_y0 > clip_y1) { + if (clip->x1 < clip->x0 || clip->y0 > clip->y1) { LOG(("bad clip rectangle %i %i %i %i", - clip_x0, clip_y0, clip_x1, clip_y1)); + clip->x0, clip->y0, clip->x1, clip->y1)); return false; } /* memorise clip for bitmap tiling */ - clip_x0_cur = clip_x0; - clip_y0_cur = clip_y0; - clip_x1_cur = clip_x1; - clip_y1_cur = clip_y1; - - knockout_entries[knockout_entry_cur].data.clip.x0 = clip_x0; - knockout_entries[knockout_entry_cur].data.clip.y0 = clip_y0; - knockout_entries[knockout_entry_cur].data.clip.x1 = clip_x1; - knockout_entries[knockout_entry_cur].data.clip.y1 = clip_y1; + clip_cur = *clip; + + knockout_entries[knockout_entry_cur].data.clip = *clip; knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_CLIP; if (++knockout_entry_cur >= KNOCKOUT_ENTRIES) knockout_plot_flush(); @@ -783,16 +756,16 @@ bool knockout_plot_bitmap(int x, int y, int width, int height, int kx0, ky0, kx1, ky1; /* get our bounds */ - kx0 = clip_x0_cur; - ky0 = clip_y0_cur; - kx1 = clip_x1_cur; - ky1 = clip_y1_cur; + kx0 = clip_cur.x0; + ky0 = clip_cur.y0; + kx1 = clip_cur.x1; + ky1 = clip_cur.y1; if (!(flags & BITMAPF_REPEAT_X)) { if (x > kx0) kx0 = x; if (x + width < kx1) kx1 = x + width; - if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur)) + if ((kx0 > clip_cur.x1) || (kx1 < clip_cur.x0)) return true; } if (!(flags & BITMAPF_REPEAT_Y)) { @@ -800,7 +773,7 @@ bool knockout_plot_bitmap(int x, int y, int width, int height, ky0 = y; if (y + height < ky1) ky1 = y + height; - if ((ky0 > clip_y1_cur) || (ky1 < clip_y0_cur)) + if ((ky0 > clip_cur.y1) || (ky1 < clip_cur.y0)) return true; } @@ -827,7 +800,7 @@ bool knockout_plot_bitmap(int x, int y, int width, int height, if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) || (++knockout_box_cur >= KNOCKOUT_BOXES)) knockout_plot_flush(); - return knockout_plot_clip(clip_x0_cur, clip_y0_cur, clip_x1_cur, clip_y1_cur); + return knockout_plot_clip(&clip_cur); } bool knockout_plot_group_start(const char *name) diff --git a/desktop/plotters.h b/desktop/plotters.h index 076baf242..02735a15f 100644 --- a/desktop/plotters.h +++ b/desktop/plotters.h @@ -27,6 +27,7 @@ #include "css/css.h" #include "content/content.h" #include "desktop/plot_style.h" +#include "desktop/shape.h" struct bitmap; @@ -96,7 +97,7 @@ typedef unsigned long bitmap_flags_t; */ struct plotter_table { /* clipping operations */ - bool (*clip)(int x0, int y0, int x1, int y1); + bool (*clip)(const struct rect *clip); /* shape primatives */ bool (*arc)(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle); diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c index f33070edb..847d6dafc 100644 --- a/desktop/save_pdf/pdf_plotters.c +++ b/desktop/save_pdf/pdf_plotters.c @@ -49,8 +49,7 @@ static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style); static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle); static bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style); -static bool pdf_plot_clip(int clip_x0, int clip_y0, - int clip_x1, int clip_y1); +static bool pdf_plot_clip(const struct rect *clip); static bool pdf_plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style); @@ -267,19 +266,19 @@ bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) /**here the clip is only queried */ -bool pdf_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1) +bool pdf_plot_clip(const struct rect *clip) { #ifdef PDF_DEBUG - LOG(("%d %d %d %d", clip_x0, clip_y0, clip_x1, clip_y1)); + LOG(("%d %d %d %d", clip->x0, clip->y0, clip->x1, clip->y1)); #endif /*Normalize cllipping area - to prevent overflows. See comment in pdf_plot_fill. */ - last_clip_x0 = min(max(clip_x0, 0), page_width); - last_clip_y0 = min(max(clip_y0, 0), page_height); - last_clip_x1 = min(max(clip_x1, 0), page_width); - last_clip_y1 = min(max(clip_y1, 0), page_height); + last_clip_x0 = min(max(clip->x0, 0), page_width); + last_clip_y0 = min(max(clip->y0, 0), page_height); + last_clip_x1 = min(max(clip->x1, 0), page_width); + last_clip_y1 = min(max(clip->y1, 0), page_height); clip_update_needed = true; diff --git a/desktop/textarea.c b/desktop/textarea.c index a0dc860ba..5450dde64 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -777,7 +777,7 @@ void textarea_redraw(struct text_area *ta, int x, int y, if (r.y1 > y + ta->vis_height) r.y1 = y + ta->vis_height; - plot.clip(r.x0, r.y0, r.x1, r.y1); + plot.clip(&r); plot.rectangle(r.x0, r.y0, r.x1, r.y1, &plot_style_fill_bg); plot.rectangle(x, y, x + ta->vis_width - 1, y + ta->vis_height - 1, @@ -787,7 +787,7 @@ void textarea_redraw(struct text_area *ta, int x, int y, r.x0 = x + MARGIN_LEFT; if (r.x1 > x + ta->vis_width - MARGIN_RIGHT) r.x1 = x + ta->vis_width - MARGIN_RIGHT; - plot.clip(r.x0, r.y0, r.x1, r.y1); + plot.clip(&r); if (line0 > 0) c_pos = utf8_bounded_length(ta->text, diff --git a/desktop/tree.c b/desktop/tree.c index 7e303827d..9dc38c247 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -1577,7 +1577,7 @@ static void tree_draw_node_expansion_toggle(struct tree *tree, */ static void tree_draw_node_element(struct tree *tree, struct node_element *element, int tree_x, int tree_y, - struct rect clip) + const struct rect *clip) { struct bitmap *bitmap = NULL; @@ -1605,28 +1605,28 @@ static void tree_draw_node_element(struct tree *tree, CONTENT_STATUS_READY || content_get_status(icon) == CONTENT_STATUS_DONE) && - x + TREE_ICON_SIZE > clip.x0 && - x < clip.x1) { + x + TREE_ICON_SIZE > clip->x0 && + x < clip->x1) { struct rect c; /* Clip to image area */ c.x0 = x; c.y0 = y + icon_inset; c.x1 = x + TREE_ICON_SIZE; c.y1 = y + icon_inset + TREE_ICON_SIZE; - if (c.x0 < clip.x0) c.x0 = clip.x0; - if (c.y0 < clip.y0) c.y0 = clip.y0; - if (c.x1 > clip.x1) c.x1 = clip.x1; - if (c.y1 > clip.y1) c.y1 = clip.y1; + if (c.x0 < clip->x0) c.x0 = clip->x0; + if (c.y0 < clip->y0) c.y0 = clip->y0; + if (c.x1 > clip->x1) c.x1 = clip->x1; + if (c.y1 > clip->y1) c.y1 = clip->y1; if (c.x1 > c.x0 && c.y1 > c.y0) { /* Valid clip rectangles only */ - plot.clip(c.x0, c.y0, c.x1, c.y1); + plot.clip(&c); content_redraw(icon , x, y + icon_inset, TREE_ICON_SIZE, TREE_ICON_SIZE, &c, 1, 0); /* Restore previous clipping area */ - plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); + plot.clip(clip); } } @@ -1635,7 +1635,7 @@ static void tree_draw_node_element(struct tree *tree, /* fall through */ case NODE_ELEMENT_TEXT: - if (element->text == NULL || clip.x1 < x) + if (element->text == NULL || clip->x1 < x) break; if (element == tree->editing) @@ -1720,7 +1720,7 @@ static void tree_draw_node(struct tree *tree, struct node *node, } /* Set up the clipping area */ - plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); + plot.clip(&clip); /* Draw node's furniture */ if (!(tree->flags & TREE_NO_FURNITURE)) { @@ -1772,11 +1772,12 @@ static void tree_draw_node(struct tree *tree, struct node *node, element = element->next) { /* Draw each element of expanded node */ tree_draw_node_element(tree, element, tree_x, tree_y, - clip); + &clip); } } else { /* Draw main title element of node */ - tree_draw_node_element(tree, &node->data, tree_x, tree_y, clip); + tree_draw_node_element(tree, &node->data, tree_x, tree_y, + &clip); } } @@ -1849,7 +1850,7 @@ void tree_draw(struct tree *tree, int x, int y, clip.y0 = y + clip_y; clip.x1 = clip.x0 + clip_width; clip.y1 = clip.y0 + clip_height; - plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); + plot.clip(&clip); /* Flat fill extents of clipping area */ plot.rectangle(clip.x0, clip.y0, clip.x1, clip.y1, diff --git a/framebuffer/framebuffer.c b/framebuffer/framebuffer.c index bed356863..535f63c85 100644 --- a/framebuffer/framebuffer.c +++ b/framebuffer/framebuffer.c @@ -331,15 +331,15 @@ framebuffer_plot_path(const float *p, } static bool -framebuffer_plot_clip(int x0, int y0, int x1, int y1) +framebuffer_plot_clip(const struct rect *clip) { - nsfb_bbox_t clip; - clip.x0 = x0; - clip.y0 = y0; - clip.x1 = x1; - clip.y1 = y1; + nsfb_bbox_t nsfb_clip; + nsfb_clip.x0 = clip->x0; + nsfb_clip.y0 = clip->y0; + nsfb_clip.x1 = clip->x1; + nsfb_clip.y1 = clip->y1; - return nsfb_plot_set_clip(nsfb, &clip); + return nsfb_plot_set_clip(nsfb, &nsfb_clip); } struct plotter_table plot = { diff --git a/gtk/plotters.c b/gtk/plotters.c index 460a65a6f..76273bd0e 100644 --- a/gtk/plotters.c +++ b/gtk/plotters.c @@ -133,17 +133,17 @@ static inline void nsgtk_set_dashed(void) } /** Set clipping area for subsequent plot operations. */ -static bool nsgtk_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1) +static bool nsgtk_plot_clip(const struct rect *clip) { cairo_reset_clip(current_cr); - cairo_rectangle(current_cr, clip_x0, clip_y0, - clip_x1 - clip_x0, clip_y1 - clip_y0); + cairo_rectangle(current_cr, clip->x0, clip->y0, + clip->x1 - clip->x0, clip->y1 - clip->y0); cairo_clip(current_cr); - cliprect.x = clip_x0; - cliprect.y = clip_y0; - cliprect.width = clip_x1 - clip_x0; - cliprect.height = clip_y1 - clip_y0; + cliprect.x = clip->x0; + cliprect.y = clip->y0; + cliprect.width = clip->x1 - clip->x0; + cliprect.height = clip->y1 - clip->y0; gdk_gc_set_clip_rectangle(current_gc, &cliprect); return true; diff --git a/gtk/print.c b/gtk/print.c index 5f518e266..1da89551a 100644 --- a/gtk/print.c +++ b/gtk/print.c @@ -169,17 +169,17 @@ static inline void nsgtk_print_set_dashed(void) } /** Set clipping area for subsequent plot operations. */ -static bool nsgtk_print_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1) +static bool nsgtk_print_plot_clip(struct rect *clip) { LOG(("Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", - clip_x0,clip_y0,clip_x1,clip_y1)); + clip->x0, clip->y0, clip->x1, clip->y1)); /* Normalize cllipping area - to prevent overflows. * See comment in pdf_plot_fill. */ - clip_x0 = min(max(clip_x0, 0), settings->page_width); - clip_y0 = min(max(clip_y0, 0), settings->page_height); - clip_x1 = min(max(clip_x1, 0), settings->page_width); - clip_y1 = min(max(clip_y1, 0), settings->page_height); + int clip_x0 = min(max(clip->x0, 0), settings->page_width); + int clip_y0 = min(max(clip->y0, 0), settings->page_height); + int clip_x1 = min(max(clip->x1, 0), settings->page_width); + int clip_y1 = min(max(clip->y1, 0), settings->page_height); cairo_reset_clip(gtk_print_current_cr); cairo_rectangle(gtk_print_current_cr, clip_x0, clip_y0, diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 2fd865cb5..1a152ccd0 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -1486,6 +1486,7 @@ BUTTONHANDLER(history) static gboolean nsgtk_history_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer g) { + struct rect clip; struct gtk_history_window *hw = (struct gtk_history_window *)g; struct browser_window *bw = gui_window_get_browser_window(hw->g->top_level); @@ -1499,10 +1500,11 @@ static gboolean nsgtk_history_expose_event(GtkWidget *widget, plot = nsgtk_plotters; nsgtk_plot_set_scale(1.0); - plot.clip(event->area.x, - event->area.y, - event->area.x + event->area.width, - event->area.y + event->area.height); + clip.x0 = event->area.x; + clip.y0 = event->area.y; + clip.x1 = event->area.x + event->area.width; + clip.y1 = event->area.y + event->area.height; + plot.clip(&clip); history_redraw(bw->history); diff --git a/gtk/thumbnail.c b/gtk/thumbnail.c index f0a25ce30..de359535b 100644 --- a/gtk/thumbnail.c +++ b/gtk/thumbnail.c @@ -106,7 +106,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, #endif plot.rectangle(0, 0, cwidth, cwidth, plot_style_fill_white); - plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); + plot.clip(&clip); /* render the content */ content_redraw(content, 0, 0, content_get_width(content), diff --git a/render/form.c b/render/form.c index 8c54b23d5..6c703692a 100644 --- a/render/form.c +++ b/render/form.c @@ -975,7 +975,7 @@ void form_free_select_menu(struct form_control *control) * \return true on success, false otherwise */ bool form_redraw_select_menu(struct form_control *control, int x, int y, - float scale, int clip_x0, int clip_y0, int clip_x1, int clip_y1) + float scale, const struct rect *clip) { struct box *box; struct form_select_menu *menu = control->data.select.menu; @@ -989,11 +989,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y, int i; int scroll; int x_cp, y_cp; - struct rect clip; - clip.x0 = clip_x0; - clip.y0 = clip_y0; - clip.x1 = clip_x1; - clip.y1 = clip_y1; + struct rect r; box = control->box; @@ -1028,8 +1024,12 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y, x1 = x + width - 1; y1 = y + height - 1; scrollbar_x = x1 - scrollbar_width; - - if (!plot.clip(x0, y0, x1 + 1, y1 + 1)) + + r.x0 = x0; + r.y0 = y0; + r.x1 = x1 + 1; + r.y1 = y1 + 1; + if (!plot.clip(&r)) return false; if (!plot.rectangle(x0, y0, x1, y1 ,plot_style_stroke_darkwbasec)) return false; @@ -1041,7 +1041,11 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y, y1 = y1 - SELECT_BORDER_WIDTH; height = height - 2 * SELECT_BORDER_WIDTH; - if (!plot.clip(x0, y0, x1 + 1, y1 + 1)) + r.x0 = x0; + r.y0 = y0; + r.x1 = x1 + 1; + r.y1 = y1 + 1; + if (!plot.clip(&r)) return false; if (!plot.rectangle(x0, y0, x1 + 1, y1 + 1, plot_style_fill_lightwbasec)) @@ -1084,7 +1088,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y, if (!scroll_redraw(menu->scroll, x_cp + menu->width - SCROLLBAR_WIDTH, y_cp, - &clip, scale)) + clip, scale)) return false; return true; @@ -1103,7 +1107,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y, * \return true if inside false otherwise */ bool form_clip_inside_select_menu(struct form_control *control, float scale, - int clip_x0, int clip_y0, int clip_x1, int clip_y1) + const struct rect *clip) { struct form_select_menu *menu = control->data.select.menu; int width, height; @@ -1117,8 +1121,8 @@ bool form_clip_inside_select_menu(struct form_control *control, float scale, height *= scale; } - if (clip_x0 >= 0 && clip_x1 <= width && - clip_y0 >= 0 && clip_y1 <= height) + if (clip->x0 >= 0 && clip->x1 <= width && + clip->y0 >= 0 && clip->y1 <= height) return true; return false; diff --git a/render/form.h b/render/form.h index 9da24b8b9..a6cda0a99 100644 --- a/render/form.h +++ b/render/form.h @@ -161,10 +161,9 @@ void form_select_menu_callback(void *client_data, int x, int y, int width, int height); void form_free_select_menu(struct form_control *control); bool form_redraw_select_menu(struct form_control *control, int x, int y, - float scale, - int clip_x0, int clip_y0, int clip_x1, int clip_y1); + float scale, const struct rect *clip); bool form_clip_inside_select_menu(struct form_control *control, float scale, - int clip_x0, int clip_y0, int clip_x1, int clip_y1); + const struct rect *clip); const char *form_select_mouse_action(struct form_control *control, browser_mouse_state mouse, int x, int y); void form_select_mouse_drag_end(struct form_control *control, diff --git a/render/html_redraw.c b/render/html_redraw.c index 8468d3007..2c355c67c 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -141,12 +141,12 @@ bool html_redraw(struct content *c, int x, int y, /* check if the redraw rectangle is completely inside of the select menu */ select_only = form_clip_inside_select_menu(control, scale, - clip->x0, clip->y0, clip->x1, clip->y1); + clip); } if (!select_only) { /* clear to background colour */ - result = plot.clip(clip->x0, clip->y0, clip->x1, clip->y1); + result = plot.clip(clip); if (c->data.html.background_colour != NS_TRANSPARENT) pstyle_fill_bg.fill_colour = @@ -170,8 +170,7 @@ bool html_redraw(struct content *c, int x, int y, result &= form_redraw_select_menu( current_redraw_browser->visible_select_menu, x + menu_x, y + menu_y, - current_redraw_browser->scale, - clip->x0, clip->y0, clip->x1, clip->y1); + current_redraw_browser->scale, clip); } if (want_knockout) @@ -412,7 +411,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, /* not an error */ return ((!plot.group_end) || (plot.group_end())); /* clip to it */ - if (!plot.clip(r.x0, r.y0, r.x1, r.y1)) + if (!plot.clip(&r)) return false; } else { /* clip box unchanged */ @@ -470,7 +469,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, ¤t_background_color, bg_box)) return false; /* restore previous graphics window */ - if (!plot.clip(r.x0, r.y0, r.x1, r.y1)) + if (!plot.clip(&r)) return false; } } @@ -544,7 +543,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, ¤t_background_color)) return false; /* restore previous graphics window */ - if (!plot.clip(r.x0, r.y0, r.x1, r.y1)) + if (!plot.clip(&r)) return false; if (!html_redraw_inline_borders(box, b, r, scale, first, false)) @@ -576,7 +575,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, first, true, ¤t_background_color)) return false; /* restore previous graphics window */ - if (!plot.clip(r.x0, r.y0, r.x1, r.y1)) + if (!plot.clip(&r)) return false; if (!html_redraw_inline_borders(box, b, r, scale, first, true)) return false; @@ -639,7 +638,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, return ((!plot.group_end) || (plot.group_end())); if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK || box->type == BOX_TABLE_CELL || box->object) { - if (!plot.clip(r.x0, r.y0, r.x1, r.y1)) + if (!plot.clip(&r)) return false; } } @@ -734,7 +733,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK || box->type == BOX_TABLE_CELL || box->object) - if (!plot.clip(clip.x0, clip.y0, clip.x1, clip.y1)) + if (!plot.clip(&clip)) return false; return ((!plot.group_end) || (plot.group_end())); @@ -875,6 +874,7 @@ bool text_redraw(const char *utf8_text, size_t utf8_len, /* \todo make search terms visible within selected text */ if (highlighted) { + struct rect r; unsigned endtxt_idx = end_idx; bool clip_changed = false; bool text_visible = true; @@ -936,8 +936,11 @@ bool text_redraw(const char *utf8_text, size_t utf8_len, int px1 = min(x + endx, clip->x1); if (px0 < px1) { - if (!plot.clip(px0, clip->y0, px1, - clip->y1)) + r.x0 = px0; + r.y0 = clip->y0; + r.x1 = px1; + r.y1 = clip->y1; + if (!plot.clip(&r)) return false; clip_changed = true; } else { @@ -961,8 +964,11 @@ bool text_redraw(const char *utf8_text, size_t utf8_len, int px0 = max(x + endx, clip->x0); if (px0 < clip->x1) { - if (!plot.clip(px0, clip->y0, - clip->x1, clip->y1)) + r.x0 = px0; + r.y0 = clip->y0; + r.x1 = clip->x1; + r.y1 = clip->y1; + if (!plot.clip(&r)) return false; clip_changed = true; @@ -976,8 +982,7 @@ bool text_redraw(const char *utf8_text, size_t utf8_len, } if (clip_changed && - !plot.clip(clip->x0, clip->y0, - clip->x1, clip->y1)) + !plot.clip(clip)) return false; } } @@ -2172,8 +2177,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale, } /* valid clipping rectangles only */ if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) { - if (!plot.clip(clip.x0, clip.y0, - clip.x1, clip.y1)) + if (!plot.clip(&clip)) return false; if (!content_redraw_tiled( background->background, x, y, @@ -2314,8 +2318,7 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale, } /* valid clipping rectangles only */ if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) { - if (!plot.clip(clip.x0, clip.y0, - clip.x1, clip.y1)) + if (!plot.clip(&clip)) return false; if (!content_redraw_tiled(box->background, x, y, ceilf(width * scale), 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); diff --git a/windows/plot.c b/windows/plot.c index 050bf6136..2e21ae1fd 100644 --- a/windows/plot.c +++ b/windows/plot.c @@ -52,17 +52,16 @@ static float nsws_plot_scale = 1.0; static RECT plot_clip; /* currently set clipping rectangle */ -static bool clip(int x0, int y0, int x1, int y1) +static bool clip(const struct rect *clip) { - #if NSWS_PLOT_DEBUG - LOG(("clip %d,%d to %d,%d", x0, y0, x1, y1)); + LOG(("clip %d,%d to %d,%d", clip->x0, clip->y0, clip->x1, clip->y1)); #endif - plot_clip.left = x0; - plot_clip.top = y0; - plot_clip.right = x1 + 1; /* rectangle co-ordinates are exclusive */ - plot_clip.bottom = y1 + 1; /* rectangle co-ordinates are exclusive */ + plot_clip.left = clip->x0; + plot_clip.top = clip->y0; + plot_clip.right = clip->x1 + 1; /* co-ordinates are exclusive */ + plot_clip.bottom = clip->y1 + 1; /* co-ordinates are exclusive */ return true; } -- cgit v1.2.3