mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
add some comments to Canvas::Image and ensure that the canvas redraws after a put_image() call is handled in the GUI thread
This commit is contained in:
parent
37dd7e952b
commit
be23e48e7f
2 changed files with 30 additions and 0 deletions
|
|
@ -48,7 +48,28 @@ public:
|
||||||
Cairo::Format format;
|
Cairo::Format format;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a shared_ptr to a Data object that can be used to
|
||||||
|
* write image data to. The Data object will contain a pointer
|
||||||
|
* to the buffer, along with image properties that may be
|
||||||
|
* useful during the data writing.
|
||||||
|
*
|
||||||
|
* Can be called from any thread BUT ..
|
||||||
|
*
|
||||||
|
* ... to avoid collisions with Image deletion, some synchronization method
|
||||||
|
* may be required or the use of shared_ptr<Image> or similar.
|
||||||
|
*/
|
||||||
boost::shared_ptr<Data> get_image ();
|
boost::shared_ptr<Data> get_image ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queues a Data object to be used to redraw this Image item
|
||||||
|
* at the earliest possible opportunity.
|
||||||
|
*
|
||||||
|
* May be called from any thread BUT ...
|
||||||
|
*
|
||||||
|
* ... to avoid collisions with Image deletion, some synchronization method
|
||||||
|
* may be required or the use of shared_ptr<Image> or similar.
|
||||||
|
*/
|
||||||
void put_image (boost::shared_ptr<Data>);
|
void put_image (boost::shared_ptr<Data>);
|
||||||
|
|
||||||
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ Image::compute_bounding_box () const
|
||||||
boost::shared_ptr<Image::Data>
|
boost::shared_ptr<Image::Data>
|
||||||
Image::get_image ()
|
Image::get_image ()
|
||||||
{
|
{
|
||||||
|
/* can be called by any thread */
|
||||||
|
|
||||||
int stride = Cairo::ImageSurface::format_stride_for_width (_format, _width);
|
int stride = Cairo::ImageSurface::format_stride_for_width (_format, _width);
|
||||||
boost::shared_ptr<Data> d (new Data (boost::shared_array<uint8_t> (new uint8_t[stride*_height]), _width, _height, stride, _format));
|
boost::shared_ptr<Data> d (new Data (boost::shared_array<uint8_t> (new uint8_t[stride*_height]), _width, _height, stride, _format));
|
||||||
|
|
||||||
|
|
@ -69,6 +71,8 @@ Image::get_image ()
|
||||||
void
|
void
|
||||||
Image::put_image (boost::shared_ptr<Data> d)
|
Image::put_image (boost::shared_ptr<Data> d)
|
||||||
{
|
{
|
||||||
|
/* can be called by any thread */
|
||||||
|
|
||||||
_pending = d;
|
_pending = d;
|
||||||
DataReady (); /* EMIT SIGNAL */
|
DataReady (); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
@ -77,8 +81,13 @@ void
|
||||||
Image::accept_data ()
|
Image::accept_data ()
|
||||||
{
|
{
|
||||||
/* must be executed in gui thread */
|
/* must be executed in gui thread */
|
||||||
|
|
||||||
|
begin_change ();
|
||||||
|
|
||||||
_current = _pending;
|
_current = _pending;
|
||||||
_pending.reset ();
|
_pending.reset ();
|
||||||
_need_render = true;
|
_need_render = true;
|
||||||
|
|
||||||
|
end_change (); // notify canvas that we need redrawing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue