[SCM] calf/master: + DSSI: marshal cairo_iface as well
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:00 UTC 2013
The following commit has been merged in the master branch:
commit 8e0c4466bb9369cff1799c836b962962bf08e520
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Thu Jan 22 21:58:39 2009 +0000
+ DSSI: marshal cairo_iface as well
diff --git a/src/calf/giface.h b/src/calf/giface.h
index b983ecc..c1bafc8 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -367,6 +367,8 @@ enum line_graph_item
LGI_LEGEND,
LGI_DOT,
LGI_END_ITEM,
+ LGI_SET_RGBA,
+ LGI_SET_WIDTH,
};
/// A class to send status updates via OSC
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index 902c0f3..5106721 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -69,18 +69,36 @@ void osctl_test()
}
#endif
-struct graph_item
+struct cairo_params
+{
+ enum { HAS_COLOR = 1, HAS_WIDTH = 2 };
+ uint32_t flags;
+ float r, g, b, a;
+ float line_width;
+
+ cairo_params()
+ : flags(0)
+ , r(0.f)
+ , g(0.f)
+ , b(0.f)
+ , a(1.f)
+ , line_width(1)
+ {
+ }
+};
+
+struct graph_item: public cairo_params
{
float data[128];
};
-struct dot_item
+struct dot_item: public cairo_params
{
float x, y;
int32_t size;
};
-struct gridline_item
+struct gridline_item: public cairo_params
{
float pos;
int32_t vertical;
@@ -92,8 +110,26 @@ struct param_line_graphs
vector<graph_item *> graphs;
vector<dot_item *> dots;
vector<gridline_item *> gridlines;
+
+ void clear();
};
+void param_line_graphs::clear()
+{
+ for (size_t i = 0; i < graphs.size(); i++)
+ delete graphs[i];
+ graphs.clear();
+
+ for (size_t i = 0; i < dots.size(); i++)
+ delete dots[i];
+ dots.clear();
+
+ for (size_t i = 0; i < gridlines.size(); i++)
+ delete gridlines[i];
+ gridlines.clear();
+
+}
+
struct plugin_proxy: public plugin_ctl_iface, public plugin_metadata_proxy, public line_graph_iface
{
osc_client *client;
@@ -170,6 +206,7 @@ struct plugin_proxy: public plugin_ctl_iface, public plugin_metadata_proxy, publ
virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context);
virtual bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
+ void update_cairo_context(cairo_iface *context, cairo_params &item);
};
bool plugin_proxy::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
@@ -185,6 +222,7 @@ bool plugin_proxy::get_graph(int index, int subindex, float *data, int points, c
int ipos = i * 127 / points;
data[i] = sdata[ipos] + (sdata[ipos + 1] - sdata[ipos]) * (pos-ipos);
}
+ update_cairo_context(context, *g.graphs[subindex]);
return true;
}
return false;
@@ -197,9 +235,11 @@ bool plugin_proxy::get_dot(int index, int subindex, float &x, float &y, int &siz
param_line_graphs &g = graphs[index];
if (subindex < (int)g.dots.size())
{
- x = g.dots[subindex]->x;
- y = g.dots[subindex]->y;
- size = g.dots[subindex]->size;
+ dot_item &item = *g.dots[subindex];
+ x = item.x;
+ y = item.y;
+ size = item.size;
+ update_cairo_context(context, item);
return true;
}
return false;
@@ -212,14 +252,24 @@ bool plugin_proxy::get_gridline(int index, int subindex, float &pos, bool &verti
param_line_graphs &g = graphs[index];
if (subindex < (int)g.gridlines.size())
{
- pos = g.gridlines[subindex]->pos;
- vertical = g.gridlines[subindex]->vertical != 0;
- legend = g.gridlines[subindex]->text;
+ gridline_item &item = *g.gridlines[subindex];
+ pos = item.pos;
+ vertical = item.vertical != 0;
+ legend = item.text;
+ update_cairo_context(context, item);
return true;
}
return false;
}
+void plugin_proxy::update_cairo_context(cairo_iface *context, cairo_params &item)
+{
+ if (item.flags & cairo_params::HAS_COLOR)
+ context->set_source_rgba(item.r, item.g, item.b, item.a);
+ if (item.flags & cairo_params::HAS_WIDTH)
+ context->set_line_width(item.line_width);
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
GMainLoop *mainloop;
@@ -326,42 +376,51 @@ void dssi_osc_server::unmarshal_line_graph(osc_strstream &buffer)
uint32_t param;
buffer >> param;
param_line_graphs &graphs = plugin->graphs[param];
-
- for (size_t i = 0; i < graphs.graphs.size(); i++)
- delete graphs.graphs[i];
- graphs.graphs.clear();
-
- for (size_t i = 0; i < graphs.dots.size(); i++)
- delete graphs.dots[i];
- graphs.dots.clear();
-
- for (size_t i = 0; i < graphs.gridlines.size(); i++)
- delete graphs.gridlines[i];
- graphs.gridlines.clear();
+
+ graphs.clear();
+ cairo_params params;
do {
buffer >> cmd;
+ if (cmd == LGI_SET_RGBA)
+ {
+ params.flags |= cairo_params::HAS_COLOR;
+ buffer >> params.r >> params.g >> params.b >> params.a;
+ }
+ else
+ if (cmd == LGI_SET_WIDTH)
+ {
+ params.flags |= cairo_params::HAS_WIDTH;
+ buffer >> params.line_width;
+ }
+ else
if (cmd == LGI_SUBGRAPH)
{
buffer >> param; // ignore number of points
graph_item *gi = new graph_item;
+ (cairo_params &)*gi = params;
for (int i = 0; i < 128; i++)
buffer >> gi->data[i];
graphs.graphs.push_back(gi);
+ params.flags = 0;
}
else
if (cmd == LGI_DOT)
{
dot_item *di = new dot_item;
+ (cairo_params &)*di = params;
buffer >> di->x >> di->y >> di->size;
graphs.dots.push_back(di);
+ params.flags = 0;
}
else
if (cmd == LGI_LEGEND)
{
gridline_item *li = new gridline_item;
+ (cairo_params &)*li = params;
buffer >> li->pos >> li->vertical >> li->text;
graphs.gridlines.push_back(li);
+ params.flags = 0;
}
else
break;
diff --git a/src/giface.cpp b/src/giface.cpp
index c496ec1..2a4c430 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -242,11 +242,11 @@ struct osc_cairo_control: public cairo_iface
osc_cairo_control(osctl::osc_inline_typed_strstream &_os) : os(_os) {}
virtual void set_source_rgba(float r, float g, float b, float a = 1.f)
{
- // os << some control stuff
+ os << (uint32_t)LGI_SET_RGBA << r << g << b << a;
}
virtual void set_line_width(float width)
{
- // os << some control stuff
+ os << (uint32_t)LGI_SET_WIDTH << width;
}
};
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list