diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-15 21:40:15 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-15 21:40:15 -0400 |
commit | fe344859073b00ff63b0fd0b68c26af6cd96aae3 (patch) | |
tree | 8f7c8d07bdeca9c28030a6c8177dbfdcbfb69a2b /libs/canvas/canvas/image.h | |
parent | 64c861a79136d0ff4011e98b847606e1015c1ac4 (diff) |
add new canvas Image item, with somewhat optimized API for asynchronous, threaded rendering directly into an image buffer suitable for use by cairo as a source surface (currently untested)
Diffstat (limited to 'libs/canvas/canvas/image.h')
-rw-r--r-- | libs/canvas/canvas/image.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libs/canvas/canvas/image.h b/libs/canvas/canvas/image.h new file mode 100644 index 0000000000..e23e9221a3 --- /dev/null +++ b/libs/canvas/canvas/image.h @@ -0,0 +1,57 @@ +#ifndef __CANVAS_IMAGE__ +#define __CANVAS_IMAGE__ + +#include <stdint.h> +#include <boost/shared_ptr.hpp> +#include <boost/shared_array.hpp> + +#include "canvas/item.h" + +namespace ArdourCanvas { + +class Image : public Item +{ +public: + Image (Group *, Cairo::Format, int width, int height); + + struct Data { + Data (boost::shared_array<uint8_t> d, int w, int h, int s, Cairo::Format fmt) + : data (d) + , width (w) + , height (h) + , stride (s) + , format (fmt) + {} + + boost::shared_array<uint8_t> data; + int width; + int height; + int stride; + Cairo::Format format; + }; + + boost::shared_ptr<Data> get_image (); + void put_image (boost::shared_ptr<Data>); + + void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; + void compute_bounding_box () const; + XMLNode* get_state () const; + void set_state (XMLNode const *); + +private: + Cairo::Format _format; + int _width; + int _height; + int _data; + mutable boost::shared_ptr<Data> _current; + boost::shared_ptr<Data> _pending; + mutable bool _need_render; + mutable Cairo::RefPtr<Cairo::Surface> _surface; + + void accept_data (); + PBD::Signal0<void> DataReady; + PBD::ScopedConnectionList data_connections; +}; + +} +#endif |