diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-17 10:53:17 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-17 10:53:17 -0400 |
commit | d1a05240efc9816b4358cdeab458a54048abf9be (patch) | |
tree | fa45892d3971951ec5a51d6a0526271940cb6de3 /libs/canvas/rectangle.cc | |
parent | 96eee9e7a162e3e26dd9c1ea4d8fc1ad02a3dda9 (diff) |
fix clamping of line and rect coordinates to avoid issues with cairo when drawing way outside a surface's dimensions; move various coordinate methods down to Canvas, because they don't require GTK information; make visible_area() a Canvas virtual method so that we don't have to cast to call it
Diffstat (limited to 'libs/canvas/rectangle.cc')
-rw-r--r-- | libs/canvas/rectangle.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index 8aa8b6161c..38106a6550 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -21,6 +21,8 @@ #include <cairomm/context.h> #include "pbd/stacktrace.h" #include "pbd/compose.h" + +#include "canvas/canvas.h" #include "canvas/rectangle.h" #include "canvas/debug.h" #include "canvas/utils.h" @@ -50,10 +52,18 @@ Rectangle::Rectangle (Group* parent, Rect const & rect) void Rectangle::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const { + /* Cairo goes a little (!) wrong when asked to fill/stroke rectangles that + * extend way beyond the surface boundaries. To avoid this issue, + * clamp what we are drawing using the absolute end of the visible + * canvas, converting to item-space coordinates, of course. + */ + Rect plot = _rect; + Rect visible = _canvas->visible_area(); + Duple visible_end = canvas_to_item (Duple (visible.x1, visible.y1)); - plot.x1 = min (plot.x1, CAIRO_MAX); - plot.y1 = min (plot.y1, CAIRO_MAX); + plot.x1 = min (plot.x1, visible_end.x); + plot.y1 = min (plot.y1, visible_end.y); if (_fill) { setup_fill_context (context); |