summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Bintz <me@johnbintz.com>2006-09-04 15:43:24 +0000
committerjohncoswell <johncoswell@users.sourceforge.net>2006-09-04 15:43:24 +0000
commitac7c2a5c9c1f183508fba21a5661a7375c29c841 (patch)
tree4862a84f0e378ad5932efdae58a8a4392d706764 /src
parentquick bug fix to whiteboard (diff)
downloadinkscape-ac7c2a5c9c1f183508fba21a5661a7375c29c841.tar.gz
inkscape-ac7c2a5c9c1f183508fba21a5661a7375c29c841.zip
Add ability to force canvas to perform a full, non-interruptible redraw
(bzr r1678)
Diffstat (limited to 'src')
-rw-r--r--src/display/sp-canvas.cpp35
-rw-r--r--src/display/sp-canvas.h4
2 files changed, 37 insertions, 2 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 91712e633..6cb3990dd 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -977,6 +977,8 @@ sp_canvas_init (SPCanvas *canvas)
canvas->redraw_aborted.y1 = -NR_HUGE_L;
canvas->redraw_count = 0;
+
+ canvas->forced_full_redraw_count = 0;
canvas->slowest_buffer = 0;
}
@@ -1690,8 +1692,9 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
// INTERRUPTIBLE DISPLAY:
// Process events that may have arrived while we were busy drawing;
- // only if we're drawing multiple buffers, and only if this one was not very fast
- if (multiple_buffers && this_buffer > 25000) {
+ // only if we're drawing multiple buffers, and only if this one was not very fast,
+ // and only if we're allowed to interrupt this redraw
+ if (multiple_buffers && this_buffer > 25000 && !canvas->forced_full_redraw_count) {
// Run at most max_iterations of the main loop; we cannot process ALL events
// here because some things (e.g. rubberband) flood with dirtying events but will
@@ -1718,11 +1721,39 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
}
}
+ // We've finished a redraw; decrement the full redraw counter
+ if (canvas->forced_full_redraw_count > 0) {
+ canvas->forced_full_redraw_count--;
+ }
+
// Remember the slowest buffer of this paint in canvas
canvas->slowest_buffer = slowest_buffer;
}
/**
+ * Force the next several screen redraws to not be interruptible.
+ * Used when having an accurate representation of the drawing canvas
+ * is more important than speed.
+ *
+ * In the future, this should be a toggle switch to be enabled/disabled
+ * when precise object drawing is necessary.
+ */
+void
+sp_canvas_force_full_redraws(SPCanvas *canvas, unsigned int count) {
+ canvas->forced_full_redraw_count += count;
+}
+
+/**
+ * Flush all forced full redraw requests.
+ * Used when accurate representation of the drawing canvas is no
+ * longer needed.
+ */
+void
+sp_canvas_clear_forced_full_redraws(SPCanvas *canvas) {
+ canvas->forced_full_redraw_count = 0;
+}
+
+/**
* The canvas widget's expose callback.
*/
static gint
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 1375cf272..f9f4330fc 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -161,6 +161,8 @@ struct SPCanvas {
long redraw_count;
glong slowest_buffer;
+ unsigned int forced_full_redraw_count;
+
/* For use by internal pick_current_item() function */
unsigned int left_grabbed_item : 1;
/* For use by internal pick_current_item() function */
@@ -187,6 +189,8 @@ void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int cl
void sp_canvas_update_now(SPCanvas *canvas);
void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
+void sp_canvas_force_full_redraws(SPCanvas *canvas, unsigned int count);
+void sp_canvas_clear_forced_full_redraws(SPCanvas *canvas);
void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy);