virtual Fill:: and Outline:: methods so that Canvas::Items that cache image renderings of themselves can invalidate those caches when colors etc. change; add Item::{begin,end}_visual_change() so that we can notify the canvas more efficiently when *only* visual properties have changed and not the bounding box (probably needs to be used more widely)

This commit is contained in:
Paul Davis 2013-04-16 20:38:10 -04:00
parent 81eed21dde
commit c1df3295c1
8 changed files with 54 additions and 11 deletions

View File

@ -30,14 +30,16 @@ class Fill : virtual public Item
public:
Fill (Group *);
virtual void set_fill_color (Color);
virtual void set_fill (bool);
Color fill_color () const {
return _fill_color;
}
void set_fill_color (Color);
bool fill () const {
return _fill;
}
void set_fill (bool);
protected:
void setup_fill_context (Cairo::RefPtr<Cairo::Context>) const;

View File

@ -168,8 +168,22 @@ public:
protected:
/** To be called at the beginning of any property change that
* may alter the bounding box of this item
*/
void begin_change ();
/** To be called at the endof any property change that
* may alter the bounding box of this item
*/
void end_change ();
/** To be called at the beginning of any property change that
* does NOT alter the bounding box of this item
*/
void begin_visual_change ();
/** To be called at the endof any property change that
* does NOT alter the bounding box of this item
*/
void end_visual_change ();
Canvas* _canvas;
/** parent group; may be 0 if we are the root group or if we have been unparent()ed */

View File

@ -48,7 +48,7 @@ public:
return _outline;
}
void set_outline (bool);
virtual void set_outline (bool);
#ifdef CANVAS_COMPATIBILITY
int& property_first_arrowhead () {

View File

@ -60,6 +60,9 @@ public:
void set_height (Distance);
void set_channel (int);
void set_region_start (ARDOUR::frameoffset_t);
void set_fill_color (Color);
void set_outline_color (Color);
void region_resized ();

View File

@ -39,21 +39,21 @@ Fill::Fill (Group* parent)
void
Fill::set_fill_color (Color color)
{
begin_change ();
begin_visual_change ();
_fill_color = color;
end_change ();
end_visual_change ();
}
void
Fill::set_fill (bool fill)
{
begin_change ();
begin_visual_change ();
_fill = fill;
end_change ();
end_visual_change ();
}
void

View File

@ -295,7 +295,6 @@ Item::width () const
return 0;
}
/* XXX may be called even if bbox is not changing ... bit grotty */
void
Item::begin_change ()
{
@ -312,6 +311,17 @@ Item::end_change ()
}
}
void
Item::begin_visual_change ()
{
}
void
Item::end_visual_change ()
{
_canvas->item_visual_property_changed (this);
}
void
Item::move (Duple movement)
{

View File

@ -41,11 +41,11 @@ Outline::Outline (Group* parent)
void
Outline::set_outline_color (Color color)
{
begin_change ();
begin_visual_change ();
_outline_color = color;
end_change ();
end_visual_change ();
}
void

View File

@ -88,6 +88,20 @@ WaveView::handle_visual_property_change ()
}
}
void
WaveView::set_fill_color (Color c)
{
invalidate_image_cache ();
Fill::set_fill_color (c);
}
void
WaveView::set_outline_color (Color c)
{
invalidate_image_cache ();
Outline::set_outline_color (c);
}
void
WaveView::set_samples_per_pixel (double samples_per_pixel)
{
@ -475,7 +489,7 @@ WaveView::CacheEntry::image ()
double stops[3];
double r, g, b, a;
if (_wave_view->_shape == Rectified) {
stops[0] = 0.1;
stops[0] = 0.3;