Add an optional ArdourCanvas::Item::prepare_for_render interface

Called when an item has requested a redraw and intersects with visible
canvas area.

Also add Canvas::prepare_for_render that will call Item::prepare_for_render for
items visible on the canvas.
This commit is contained in:
Tim Mayberry 2017-04-01 23:02:49 +10:00
parent 265f52535a
commit c4e31fc322
6 changed files with 93 additions and 1 deletions

View file

@ -87,6 +87,8 @@ public:
void render (Rect const &, Cairo::RefPtr<Cairo::Context> const &) const;
void prepare_for_render (Rect const &) const;
/** @return root group */
Item* root () {
return &_root;
@ -214,6 +216,8 @@ public:
Canvas::render (rect, ctx);
}
void prepare_for_render () const;
uint32_t background_color() { return Canvas::background_color (); }
protected:

View file

@ -53,6 +53,12 @@ public:
* (just call Item::render_children()). It can be overridden as necessary.
*/
void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
/** The prepare_for_render() method is likely to be identical in all
* containers (just call Item::prepare_for_render_children()). It can be
* overridden as necessary.
*/
void prepare_for_render (Rect const & area) const;
};
}

View file

@ -75,6 +75,13 @@ public:
*/
virtual void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const = 0;
/** Item has changed will be rendered in next render pass so give item a
* chance to perhaps schedule work in another thread etc.
*
* @param area Area to draw, in **window** coordinates
*/
virtual void prepare_for_render (Rect const & area) const { }
/** Adds one or more items to the vector @param items based on their
* covering @param point which is in **window** coordinates
*
@ -309,6 +316,7 @@ protected:
void add_child_bounding_boxes (bool include_hidden = false) const;
void render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
void prepare_for_render_children (Rect const & area) const;
Duple scroll_offset() const;
Duple position_offset() const;