summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2020-09-25 16:46:39 +0200
committerAlexander Larsson <alexl@redhat.com>2020-09-25 16:46:39 +0200
commite4dfa5597a5451f89ce957c4744885935fceb525 (patch)
tree3114ca753ded5c264accb6553b5b5f513ef9f9a5
parent32aa470f68ca0ff29aa0b6775ed1f26baedd775c (diff)
downloadgtk+-e4dfa5597a5451f89ce957c4744885935fceb525.tar.gz
gtk_snapshot_push_gl_shader: Make @args transfer-full
This makes the common case of this just being created a lot easier.
-rw-r--r--gtk/gtksnapshot.c13
-rw-r--r--gtk/gtksnapshot.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 976c81ab35..3e4dd5bf38 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -867,13 +867,19 @@ gtk_snapshot_collect_gl_shader (GtkSnapshot *snapshot,
* @snapshot: a #GtkSnapshot
* @shader: The code to run
* @bounds: the rectangle to render into
- * @args: Data block with uniform data for the shader.
+ * @take_args: (transfer full): Data block with arguments for the shader.
* @n_children: The number of extra nodes given as argument to the shader as textures.
*
* Push a #GskGLShaderNode with a specific #GskGLShader and a set of uniform values
* to use while rendering. Additionally this takes a list of @n_children other nodes
* which will be passed to the #GskGLShaderNode.
*
+ * The @take_args argument is a block of data to use for uniform
+ * input, as per types and offsets defined by the @shader. Normally this is
+ * generated by gsk_gl_shader_format_args() or #GskGLShaderArgBuilder.
+ * The snapshotter takes ownership of @take_args, so the caller should not free it
+ * after this.
+ *
* If the renderer doesn't support GL shaders, or if there is any problem when
* compiling the shader, then the node will draw pink. You should use
* gsk_gl_shader_try_compile_for() to ensure the @shader will work for the renderer
@@ -890,7 +896,7 @@ void
gtk_snapshot_push_gl_shader (GtkSnapshot *snapshot,
GskGLShader *shader,
const graphene_rect_t *bounds,
- GBytes *args,
+ GBytes *take_args,
int n_children)
{
GtkSnapshotState *state;
@@ -907,7 +913,7 @@ gtk_snapshot_push_gl_shader (GtkSnapshot *snapshot,
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &transformed_bounds);
state->data.glshader.bounds = transformed_bounds;
state->data.glshader.shader = g_object_ref (shader);
- state->data.glshader.args = g_bytes_ref (args);
+ state->data.glshader.args = take_args; /* Takes ownership */
state->data.glshader.n_children = n_children;
nodes = g_new0 (GskRenderNode *, n_children);
node_idx = n_children-1; /* We pop in reverse order */
@@ -955,7 +961,6 @@ gtk_snapshot_push_gl_shader_va (GtkSnapshot *snapshot,
GBytes *args = gsk_gl_shader_format_args_va (shader, uniforms);
gtk_snapshot_push_gl_shader (snapshot, shader, bounds,
args, n_children);
- g_bytes_unref (args);
}
/**
diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h
index a87ee21c2b..6936eb3e67 100644
--- a/gtk/gtksnapshot.h
+++ b/gtk/gtksnapshot.h
@@ -102,7 +102,7 @@ GDK_AVAILABLE_IN_ALL
void gtk_snapshot_push_gl_shader (GtkSnapshot *snapshot,
GskGLShader *shader,
const graphene_rect_t *bounds,
- GBytes *args,
+ GBytes *take_args,
int n_children);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_push_gl_shader_v (GtkSnapshot *snapshot,