GUI update for non-cairo Plugin Inline Display
This commit is contained in:
parent
93bc9b9728
commit
594d0d8672
@ -1201,6 +1201,7 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
|
|||||||
|
|
||||||
ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
|
ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin> p, uint32_t max_height)
|
||||||
: _plug (p)
|
: _plug (p)
|
||||||
|
, _surf (0)
|
||||||
, _max_height (max_height)
|
, _max_height (max_height)
|
||||||
, _cur_height (1)
|
, _cur_height (1)
|
||||||
{
|
{
|
||||||
@ -1209,6 +1210,13 @@ ProcessorEntry::PluginDisplay::PluginDisplay (boost::shared_ptr<ARDOUR::Plugin>
|
|||||||
boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
|
boost::bind (&Gtk::Widget::queue_draw, this), gui_context ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProcessorEntry::PluginDisplay::~PluginDisplay ()
|
||||||
|
{
|
||||||
|
if (_surf) {
|
||||||
|
cairo_surface_destroy (_surf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
|
ProcessorEntry::PluginDisplay::on_size_request (Gtk::Requisition* req)
|
||||||
{
|
{
|
||||||
@ -1223,14 +1231,9 @@ ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
|
|||||||
double const width = a.get_width();
|
double const width = a.get_width();
|
||||||
double const height = a.get_height();
|
double const height = a.get_height();
|
||||||
|
|
||||||
void* csf = _plug->render_inline_display (width, _max_height);
|
Plugin::Display_Image_Surface* csf = _plug->render_inline_display (width, _max_height);
|
||||||
|
|
||||||
cairo_surface_t* surf = NULL;
|
if (!csf) {
|
||||||
if (csf) {
|
|
||||||
surf = (cairo_surface_t*) csf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!surf) {
|
|
||||||
hide ();
|
hide ();
|
||||||
if (_cur_height != 1) {
|
if (_cur_height != 1) {
|
||||||
_cur_height = 1;
|
_cur_height = 1;
|
||||||
@ -1239,6 +1242,26 @@ ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_surf
|
||||||
|
|| csf->width != cairo_image_surface_get_width (_surf)
|
||||||
|
|| csf->height != cairo_image_surface_get_height (_surf)
|
||||||
|
|| csf->stride != cairo_image_surface_get_stride (_surf)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (_surf) {
|
||||||
|
cairo_surface_destroy (_surf);
|
||||||
|
}
|
||||||
|
_surf = cairo_image_surface_create_for_data (
|
||||||
|
csf->data,
|
||||||
|
CAIRO_FORMAT_ARGB32,
|
||||||
|
csf->width,
|
||||||
|
csf->height,
|
||||||
|
csf->stride);
|
||||||
|
} else {
|
||||||
|
memcpy (cairo_image_surface_get_data (_surf), csf->data, csf->stride * csf->height);
|
||||||
|
cairo_surface_mark_dirty(_surf);
|
||||||
|
}
|
||||||
|
|
||||||
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
|
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
|
||||||
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
@ -1248,23 +1271,21 @@ ProcessorEntry::PluginDisplay::on_expose_event (GdkEventExpose* ev)
|
|||||||
cairo_rectangle (cr, 0, 0, width, height);
|
cairo_rectangle (cr, 0, 0, width, height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
if (surf) {
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
||||||
Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
|
Gtkmm2ext::rounded_rectangle (cr, .5, -1.5, width - 1, height + 1, 7);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
|
|
||||||
const double xc = floor ((width - cairo_image_surface_get_width (surf)) * .5);
|
const double xc = floor ((width - csf->width) * .5);
|
||||||
const double sh = cairo_image_surface_get_height (surf);
|
const double sh = csf->height;
|
||||||
uint32_t shm = std::min (_max_height, (uint32_t) ceil (sh));
|
uint32_t shm = std::min (_max_height, (uint32_t) ceil (sh));
|
||||||
if (shm != _cur_height) {
|
if (shm != _cur_height) {
|
||||||
_cur_height = shm;
|
_cur_height = shm;
|
||||||
queue_resize ();
|
queue_resize ();
|
||||||
}
|
}
|
||||||
cairo_set_source_surface(cr, surf, xc, 0);
|
cairo_set_source_surface(cr, _surf, xc, 0);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
std::string name = get_name();
|
std::string name = get_name();
|
||||||
|
@ -223,11 +223,13 @@ private:
|
|||||||
class PluginDisplay : public Gtk::DrawingArea {
|
class PluginDisplay : public Gtk::DrawingArea {
|
||||||
public:
|
public:
|
||||||
PluginDisplay(boost::shared_ptr<ARDOUR::Plugin>, uint32_t max_height = 80);
|
PluginDisplay(boost::shared_ptr<ARDOUR::Plugin>, uint32_t max_height = 80);
|
||||||
|
~PluginDisplay();
|
||||||
private:
|
private:
|
||||||
bool on_expose_event (GdkEventExpose *);
|
bool on_expose_event (GdkEventExpose *);
|
||||||
void on_size_request (Gtk::Requisition* req);
|
void on_size_request (Gtk::Requisition* req);
|
||||||
boost::shared_ptr<ARDOUR::Plugin> _plug;
|
boost::shared_ptr<ARDOUR::Plugin> _plug;
|
||||||
PBD::ScopedConnection _qdraw_connection;
|
PBD::ScopedConnection _qdraw_connection;
|
||||||
|
cairo_surface_t* _surf;
|
||||||
uint32_t _max_height;
|
uint32_t _max_height;
|
||||||
uint32_t _cur_height;
|
uint32_t _cur_height;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user