mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
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)
This commit is contained in:
parent
64c861a791
commit
fe34485907
3 changed files with 139 additions and 1 deletions
57
libs/canvas/canvas/image.h
Normal file
57
libs/canvas/canvas/image.h
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue