summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-06-13 21:46:56 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-06-13 21:46:56 +0800
commit49f88dbb46ea808bd2be03c1b97c1dec44d66cc6 (patch)
tree8836dfceb52ce43a88cc7788c34254da00f577e8
parent5d2383c2fa30c374ad28feda0100d058a510bdf8 (diff)
downloadcompositionkit-49f88dbb46ea808bd2be03c1b97c1dec44d66cc6.tar.gz
compositionkit-49f88dbb46ea808bd2be03c1b97c1dec44d66cc6.tar.bz2
Added GetShaderSource and SetShaderSource methods, to modify the shaders themselves
-rw-r--r--ckservice/ckservice-main.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/ckservice/ckservice-main.c b/ckservice/ckservice-main.c
index 6538909..698b530 100644
--- a/ckservice/ckservice-main.c
+++ b/ckservice/ckservice-main.c
@@ -465,6 +465,83 @@ handle_method_call (GDBusConnection *connection,
if (string)
g_free (string);
}
+ else if (g_strcmp0 (method_name, "SetShaderSource") == 0)
+ {
+ guint32 id;
+ gchar *shader_name;
+ gchar *shader_source;
+ GList *list;
+
+ g_variant_get (parameters, "(ssi)", &shader_source, &shader_name, &id, NULL);
+
+ list = g_list_find_custom (service->priv->surfaces, &id, find_surface_by_id);
+
+ if (list)
+ {
+ CompositionKitSurface *surface = (CompositionKitSurface *) list->data;
+ GList *siter;
+
+ siter = g_list_find_custom (surface->shaders, shader_name, find_shader_by_name);
+
+ if (siter)
+ {
+ CompositionKitShader *shader = (CompositionKitShader *) siter->data;
+ shader->source = g_strdup (shader_source);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ }
+ else
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No shader %s for id %i\n", shader_name, id);
+ }
+ }
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "ID %i not valid for shader %s\n", id, shader_name);
+ }
+
+ if (shader_name)
+ g_free (shader_name);
+
+ if (shader_source)
+ g_free (shader_source);
+ }
+ else if (g_strcmp0 (method_name, "GetShaderSource") == 0)
+ {
+ guint32 id;
+ gchar *shader_name;
+ GList *list;
+ GVariant *reply;
+
+ g_variant_get (parameters, "(si)", &shader_name, &id, NULL);
+
+ list = g_list_find_custom (service->priv->surfaces, &id, find_surface_by_id);
+
+ if (list)
+ {
+ CompositionKitSurface *surface = (CompositionKitSurface *) list->data;
+ GList *siter;
+
+ siter = g_list_find_custom (surface->shaders, shader_name, find_shader_by_name);
+
+ if (siter)
+ {
+ CompositionKitShader *shader = (CompositionKitShader *) siter->data;
+ reply = g_variant_new ("(s)", shader->source);
+ g_dbus_method_invocation_return_value (invocation, reply);
+ g_variant_unref (reply);
+ }
+ else
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No shader %s for id %i\n", shader_name, id);
+ }
+ }
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "ID %i not valid for shader %s\n", id, shader_name);
+ }
+
+ if (shader_name)
+ g_free (shader_name);
+
+ }
else if (g_strcmp0 (method_name, "AddUniform") == 0)
{
guint32 id;
@@ -758,6 +835,18 @@ static const gchar introspection_xml[] =
" <arg type='i' name='id' direction='in'/>"
" </method>"
""
+ " <method name='SetShaderSource'>"
+ " <arg type='s' name='shader_source' direction='in'/>"
+ " <arg type='s' name='shader_name' direction='in'/>"
+ " <arg type='i' name='id' direction='in'/>"
+ " </method>"
+ ""
+ " <method name='GetShaderSource'>"
+ " <arg type='s' name='shader_source' direction='out'/>"
+ " <arg type='s' name='shader_name' direction='in'/>"
+ " <arg type='i' name='id' direction='in'/>"
+ " </method>"
+ ""
" <method name='RemoveAttribute'>"
" <arg type='s' name='attribute_name' direction='in'/>"
" <arg type='s' name='attribute_name' direction='in'/> "