summaryrefslogtreecommitdiff
path: root/libs/canvas/canvas/image.h
blob: e23e9221a31ee16abcdefa21a10eeb0c01a655c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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