diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-11 21:56:29 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-11 21:59:38 -0500 |
commit | a992a2e6e07c1eb9465b2437aebe7921058f428b (patch) | |
tree | 407ee32a07d829a0ed9c7723873d77ace73ace51 /libs/canvas/rectangle.cc | |
parent | 2a5921ecf159d49597264a9328dc899bba55e57e (diff) |
simplify Canvas::Rectangle rendering to avoid unnecessary nonsense, and remove TimeRectangle
Diffstat (limited to 'libs/canvas/rectangle.cc')
-rw-r--r-- | libs/canvas/rectangle.cc | 65 |
1 files changed, 19 insertions, 46 deletions
diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index 7a4129d30a..557e8763c7 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -99,36 +99,43 @@ Rectangle::render_self (Rect const & area, Cairo::RefPtr<Cairo::Context> context * coordinates of the rectangle. So if the rectangle * has a left edge at 0 and a right edge at 10, then * the left edge must span 0..1, the right edge - * must span 9..10 because the first and final pixels - * to be colored are actually "at" 0.5 and 9.5 (midway - * between the integer coordinates. + * must span 10..11 because the first and final pixels + * to be colored are actually "at" 0.5 and 10.5 (midway + * between the integer coordinates). + * + * See the Cairo FAQ on single pixel lines for more + * detail. */ + if (fmod (_outline_width, 2.0) != 0.0) { + const double shift = _outline_width * 0.5; + self = self.translate (Duple (shift, shift)); + } + if (_outline_what == What (LEFT|RIGHT|BOTTOM|TOP)) { - self = self.shrink (0.5); context->rectangle (self.x0, self.y0, self.width(), self.height()); } else { if (_outline_what & LEFT) { - context->move_to (self.x0+0.5, self.y0); - context->line_to (self.x0+0.5, self.y1); + context->move_to (self.x0, self.y0); + context->line_to (self.x0, self.y1); } if (_outline_what & TOP) { - context->move_to (self.x0, self.y0+0.5); - context->line_to (self.x1, self.y0+0.5); + context->move_to (self.x0, self.y0); + context->line_to (self.x1, self.y0); } if (_outline_what & BOTTOM) { - context->move_to (self.x0, self.y1-0.5); - context->line_to (self.x1, self.y1-0.5); + context->move_to (self.x0, self.y1); + context->line_to (self.x1, self.y1); } if (_outline_what & RIGHT) { - context->move_to (self.x1-0.5, self.y0); - context->line_to (self.x1-0.5, self.y1); + context->move_to (self.x1, self.y0); + context->line_to (self.x1, self.y1); } } @@ -259,37 +266,3 @@ Rectangle::set_outline_what (What what) end_visual_change (); } } - - -/*-------------------*/ - -void -TimeRectangle::compute_bounding_box () const -{ - Rectangle::compute_bounding_box (); - - if (_bounding_box) { - Rect r = _bounding_box.get (); - - /* This is a TimeRectangle, so its right edge is drawn 1 pixel beyond - * (larger x-axis coordinates) than a normal Rectangle. - */ - - r.x1 += 1.0; /* this should be using safe_add() */ - - _bounding_box = r; - } -} - -void -TimeRectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const -{ - Rect self = get_self_for_render (); - - /* This is a TimeRectangle, so its right edge is drawn 1 pixel beyond - * (larger x-axis coordinates) than a normal Rectangle. - */ - - self.x1 += 1.0; /* this should be using safe_add() */ - render_self (area, context, self); -} |