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 --- gtk/plotters.c | 14 +++++++------- gtk/print.c | 12 ++++++------ gtk/scaffolding.c | 10 ++++++---- gtk/thumbnail.c | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'gtk') 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), -- cgit v1.2.3