From 93bc93b6f614123536cd03f1b5c8bc0c64873034 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 17 Jun 2014 11:34:47 -0400 Subject: a set of 3 fixes that cure Canvas::Text leaving dirty pixels when being dragged. or might not - testing is non-deterministic, which is alarming --- libs/canvas/text.cc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'libs/canvas/text.cc') diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc index 12fe3eb6cb..4c2077a70b 100644 --- a/libs/canvas/text.cc +++ b/libs/canvas/text.cc @@ -106,15 +106,15 @@ Text::_redraw (Glib::RefPtr layout) const } layout->set_alignment (_alignment); - + int w; int h; - layout->get_size (w, h); - - _width = w / Pango::SCALE; - _height = h / Pango::SCALE; - + layout->get_pixel_size (w, h); + + _width = w; + _height = h; + _image = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, _width, _height); Cairo::RefPtr img_context = Cairo::Context::create (_image); @@ -133,19 +133,26 @@ Text::_redraw (Glib::RefPtr layout) const } void -Text::render (Rect const & /*area*/, Cairo::RefPtr context) const +Text::render (Rect const & area, Cairo::RefPtr context) const { if (_text.empty()) { return; } + Rect self = item_to_window (Rect (0, 0, min (_clamped_width, (double)_image->get_width ()), _image->get_height ())); + boost::optional i = self.intersection (area); + + if (!i) { + return; + } + if (_need_redraw) { redraw (context); } - Rect self = item_to_window (Rect (0, 0, min (_clamped_width, _width), _height)); - - context->rectangle (self.x0, self.y0, self.width(), self.height()); + Rect intersection (i.get()); + + context->rectangle (intersection.x0, intersection.y0, intersection.width(), intersection.height()); context->set_source (_image, self.x0, self.y0); context->fill (); } -- cgit v1.2.3