[gtk/glshader-paintable: 3/8] Rename uniform_data to shader args, or just args
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/glshader-paintable: 3/8] Rename uniform_data to shader args, or just args
- Date: Fri, 25 Sep 2020 21:22:39 +0000 (UTC)
commit 32aa470f68ca0ff29aa0b6775ed1f26baedd775c
Author: Alexander Larsson <alexl redhat com>
Date: Fri Sep 25 16:38:10 2020 +0200
Rename uniform_data to shader args, or just args
This makes a lot of types and function names shorter.
Also, we add a "..." version of gsk_gl_shader_format_args_va().
docs/reference/gsk/gsk4-sections.txt | 45 +++----
gsk/gl/gskglrenderer.c | 6 +-
gsk/gskglshader.c | 248 +++++++++++++++++++----------------
gsk/gskglshader.h | 123 ++++++++---------
gsk/gskrendernode.h | 5 +-
gsk/gskrendernodeimpl.c | 28 ++--
gsk/gskrendernodeparser.c | 54 ++++----
gtk/gtksnapshot.c | 18 +--
gtk/gtksnapshot.h | 2 +-
gtk/inspector/recorder.c | 16 +--
testsuite/gsk/shader.c | 44 +++----
11 files changed, 308 insertions(+), 281 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index def2c85750..c36920dd43 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -287,31 +287,32 @@ gsk_gl_shader_get_uniform_name
gsk_gl_shader_find_uniform_by_name
gsk_gl_shader_get_uniform_type
gsk_gl_shader_get_uniform_offset
-gsk_gl_shader_get_uniforms_size
+gsk_gl_shader_get_args_size
<SUBSECTION Uniform Data>
-gsk_gl_shader_get_uniform_data_float
-gsk_gl_shader_get_uniform_data_int
-gsk_gl_shader_get_uniform_data_uint
-gsk_gl_shader_get_uniform_data_bool
-gsk_gl_shader_get_uniform_data_vec2
-gsk_gl_shader_get_uniform_data_vec3
-gsk_gl_shader_get_uniform_data_vec4
-gsk_gl_shader_format_uniform_data_va
+gsk_gl_shader_get_arg_float
+gsk_gl_shader_get_arg_int
+gsk_gl_shader_get_arg_uint
+gsk_gl_shader_get_arg_bool
+gsk_gl_shader_get_arg_vec2
+gsk_gl_shader_get_arg_vec3
+gsk_gl_shader_get_arg_vec4
+gsk_gl_shader_format_args_va
+gsk_gl_shader_format_args
-<SUBSECTION Uniform Data Builder>
-GskUniformDataBuilder
+<SUBSECTION Shader Args Builder>
+GskShaderArgsBuilder
-gsk_gl_shader_build_uniform_data
-gsk_uniform_data_builder_finish
-gsk_uniform_data_builder_free
-gsk_uniform_data_builder_copy
+gsk_gl_shader_build_args
+gsk_shader_args_builder_finish
+gsk_shader_args_builder_free
+gsk_shader_args_builder_copy
-gsk_uniform_data_builder_set_float
-gsk_uniform_data_builder_set_int
-gsk_uniform_data_builder_set_uint
-gsk_uniform_data_builder_set_bool
-gsk_uniform_data_builder_set_vec2
-gsk_uniform_data_builder_set_vec3
-gsk_uniform_data_builder_set_vec4
+gsk_shader_args_builder_set_float
+gsk_shader_args_builder_set_int
+gsk_shader_args_builder_set_uint
+gsk_shader_args_builder_set_bool
+gsk_shader_args_builder_set_vec2
+gsk_shader_args_builder_set_vec3
+gsk_shader_args_builder_set_vec4
</SECTION>
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 78c653ef3c..2c8916ac68 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1187,7 +1187,7 @@ render_gl_shader_node (GskGLRenderer *self,
if (program->id >= 0 && n_children <= G_N_ELEMENTS (program->glshader.texture_locations))
{
- GBytes *uniform_data;
+ GBytes *args;
TextureRegion regions[4];
gboolean is_offscreen[4];
for (guint i = 0; i < n_children; i++)
@@ -1201,10 +1201,10 @@ render_gl_shader_node (GskGLRenderer *self,
return;
}
- uniform_data = gsk_gl_shader_node_get_uniform_data (node);
+ args = gsk_gl_shader_node_get_args (node);
ops_set_program (builder, program);
- ops_set_gl_shader_args (builder, shader, node->bounds.size.width, node->bounds.size.height,
g_bytes_get_data (uniform_data, NULL));
+ ops_set_gl_shader_args (builder, shader, node->bounds.size.width, node->bounds.size.height,
g_bytes_get_data (args, NULL));
for (guint i = 0; i < n_children; i++)
{
if (i == 0)
diff --git a/gsk/gskglshader.c b/gsk/gskglshader.c
index e58ec4dcba..13802f6067 100644
--- a/gsk/gskglshader.c
+++ b/gsk/gskglshader.c
@@ -644,15 +644,15 @@ gsk_gl_shader_get_uniforms (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniforms_size:
+ * gsk_gl_shader_get_args_size:
* @shader: A #GskGLShader
*
- * Get the size of the data block used to specify uniform data for this shader.
+ * Get the size of the data block used to specify arguments for this shader.
*
* Returns: The size of the data block
*/
int
-gsk_gl_shader_get_uniforms_size (GskGLShader *shader)
+gsk_gl_shader_get_args_size (GskGLShader *shader)
{
return shader->uniforms_size;
}
@@ -672,25 +672,25 @@ gsk_gl_shader_find_uniform (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_float:
+ * gsk_gl_shader_get_arg_float:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of float type.
*
* Returns: The value
*/
float
-gsk_gl_shader_get_uniform_data_float (GskGLShader *shader,
- GBytes *uniform_data,
- int idx)
+gsk_gl_shader_get_arg_float (GskGLShader *shader,
+ GBytes *args,
+ int idx)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -702,25 +702,25 @@ gsk_gl_shader_get_uniform_data_float (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_int:
+ * gsk_gl_shader_get_arg_int:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of int type.
*
* Returns: The value
*/
gint32
-gsk_gl_shader_get_uniform_data_int (GskGLShader *shader,
- GBytes *uniform_data,
- int idx)
+gsk_gl_shader_get_arg_int (GskGLShader *shader,
+ GBytes *args,
+ int idx)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -732,25 +732,25 @@ gsk_gl_shader_get_uniform_data_int (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_uint:
+ * gsk_gl_shader_get_arg_uint:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of uint type.
*
* Returns: The value
*/
guint32
-gsk_gl_shader_get_uniform_data_uint (GskGLShader *shader,
- GBytes *uniform_data,
- int idx)
+gsk_gl_shader_get_arg_uint (GskGLShader *shader,
+ GBytes *args,
+ int idx)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -762,25 +762,25 @@ gsk_gl_shader_get_uniform_data_uint (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_bool:
+ * gsk_gl_shader_get_arg_bool:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of bool type.
*
* Returns: The value
*/
gboolean
-gsk_gl_shader_get_uniform_data_bool (GskGLShader *shader,
- GBytes *uniform_data,
- int idx)
+gsk_gl_shader_get_arg_bool (GskGLShader *shader,
+ GBytes *args,
+ int idx)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -792,25 +792,25 @@ gsk_gl_shader_get_uniform_data_bool (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_vec2:
+ * gsk_gl_shader_get_arg_vec2:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
* @out_value: Location to store set the uniform value too
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of vec2 type.
*/
void
-gsk_gl_shader_get_uniform_data_vec2 (GskGLShader *shader,
- GBytes *uniform_data,
- int idx,
- graphene_vec2_t *out_value)
+gsk_gl_shader_get_arg_vec2 (GskGLShader *shader,
+ GBytes *args,
+ int idx,
+ graphene_vec2_t *out_value)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -822,25 +822,25 @@ gsk_gl_shader_get_uniform_data_vec2 (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_vec3:
+ * gsk_gl_shader_get_arg_vec3:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
* @out_value: Location to store set the uniform value too
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of vec3 type.
*/
void
-gsk_gl_shader_get_uniform_data_vec3 (GskGLShader *shader,
- GBytes *uniform_data,
+gsk_gl_shader_get_arg_vec3 (GskGLShader *shader,
+ GBytes *args,
int idx,
graphene_vec3_t *out_value)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -852,25 +852,25 @@ gsk_gl_shader_get_uniform_data_vec3 (GskGLShader *shader,
}
/**
- * gsk_gl_shader_get_uniform_data_vec4:
+ * gsk_gl_shader_get_arg_vec4:
* @shader: A #GskGLShader
- * @uniform_data: The uniform data block
+ * @args: The uniform arguments
* @idx: The index of the uniform
* @out_value: Location to store set the uniform value too
*
- * Gets the value of the uniform @idx in the @uniform_data block.
+ * Gets the value of the uniform @idx in the @args block.
* The uniform must be of vec4 type.
*/
void
-gsk_gl_shader_get_uniform_data_vec4 (GskGLShader *shader,
- GBytes *uniform_data,
- int idx,
- graphene_vec4_t *out_value)
+gsk_gl_shader_get_arg_vec4 (GskGLShader *shader,
+ GBytes *args,
+ int idx,
+ graphene_vec4_t *out_value)
{
const GskGLUniform *u;
const guchar *args_src;
gsize size;
- const guchar *data = g_bytes_get_data (uniform_data, &size);
+ const guchar *data = g_bytes_get_data (args, &size);
g_assert (size == shader->uniforms_size);
g_assert (idx < shader->uniforms->len);
@@ -882,7 +882,7 @@ gsk_gl_shader_get_uniform_data_vec4 (GskGLShader *shader,
}
/**
- * gsk_gl_shader_format_uniform_data_va:
+ * gsk_gl_shader_format_args_va:
* @shader: A #GskGLShader
* @uniforms: Name-Value pairs for the uniforms of @shader, ending with a %NULL name, all values are passed
by reference.
*
@@ -894,8 +894,8 @@ gsk_gl_shader_get_uniform_data_vec4 (GskGLShader *shader,
* Returns: (transfer full): A newly allocated block of data which can be passed to gsk_gl_shader_node_new().
*/
GBytes *
-gsk_gl_shader_format_uniform_data_va (GskGLShader *shader,
- va_list uniforms)
+gsk_gl_shader_format_args_va (GskGLShader *shader,
+ va_list uniforms)
{
guchar *args = g_malloc0 (shader->uniforms_size);
const char *name;
@@ -963,29 +963,55 @@ gsk_gl_shader_format_uniform_data_va (GskGLShader *shader,
return g_bytes_new_take (args, shader->uniforms_size);
}
-struct _GskUniformDataBuilder {
+/**
+ * gsk_gl_shader_format_args:
+ * @shader: A #GskGLShader
+ * @...: Name-Value pairs for the uniforms of @shader, ending with a %NULL name, all values are passed by
reference.
+ *
+ * Formats the uniform data as needed for feeding the named uniforms values into the shader.
+ * The argument list is a list of pairs of names, and pointers to data of the types
+ * that match the declared uniforms (i.e. `float *` for float uniforms and `graphene_vec4_t *` f
+ * or vec3 uniforms).
+ *
+ * Returns: (transfer full): A newly allocated block of data which can be passed to gsk_gl_shader_node_new().
+ */
+GBytes *
+gsk_gl_shader_format_args (GskGLShader *shader,
+ ...)
+{
+ GBytes *bytes;
+ va_list args;
+
+ va_start (args, shader);
+ bytes = gsk_gl_shader_format_args_va (shader, args);
+ va_end (args);
+
+ return bytes;
+}
+
+struct _GskShaderArgsBuilder {
GskGLShader *shader;
guchar *data;
};
-G_DEFINE_BOXED_TYPE (GskUniformDataBuilder, gsk_uniform_data_builder,
- gsk_uniform_data_builder_copy,
- gsk_uniform_data_builder_free);
+G_DEFINE_BOXED_TYPE (GskShaderArgsBuilder, gsk_shader_args_builder,
+ gsk_shader_args_builder_copy,
+ gsk_shader_args_builder_free);
/**
- * gsk_gl_shader_build_uniform_data:
+ * gsk_gl_shader_build_args:
* @shader: A #GskGLShader
*
* Allocates a builder that can be used to construct a new uniform data
* chunk.
*
- * Returns: (transfer full): The newly allocated builder, free with gsk_uniform_data_builder_free()
+ * Returns: (transfer full): The newly allocated builder, free with gsk_shader_args_builder_free()
*/
-GskUniformDataBuilder *
-gsk_gl_shader_build_uniform_data (GskGLShader *shader)
+GskShaderArgsBuilder *
+gsk_gl_shader_build_args (GskGLShader *shader)
{
- GskUniformDataBuilder *builder = g_new0 (GskUniformDataBuilder, 1);
+ GskShaderArgsBuilder *builder = g_new0 (GskShaderArgsBuilder, 1);
builder->shader = g_object_ref (shader);
builder->data = g_malloc0 (shader->uniforms_size);
@@ -993,29 +1019,29 @@ gsk_gl_shader_build_uniform_data (GskGLShader *shader)
}
/**
- * gsk_uniform_data_builder_finish:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_finish:
+ * @builder: A #GskShaderArgsBuilder
*
* Finishes building the uniform data and returns it as a GBytes. Once this
* is called the builder can not be used anymore.
*
- * Returns: (transfer full): The newly allocated builder, free with gsk_uniform_data_builder_free()
+ * Returns: (transfer full): The newly allocated builder, free with gsk_shader_args_builder_free()
*/
GBytes *
-gsk_uniform_data_builder_finish (GskUniformDataBuilder *builder)
+gsk_shader_args_builder_finish (GskShaderArgsBuilder *builder)
{
return g_bytes_new_take (g_steal_pointer (&builder->data),
builder->shader->uniforms_size);
}
/**
- * gsk_uniform_data_builder_free:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_free:
+ * @builder: A #GskShaderArgsBuilder
*
* Frees the builder.
*/
void
-gsk_uniform_data_builder_free (GskUniformDataBuilder *builder)
+gsk_shader_args_builder_free (GskShaderArgsBuilder *builder)
{
g_object_unref (builder->shader);
g_free (builder->data);
@@ -1023,25 +1049,25 @@ gsk_uniform_data_builder_free (GskUniformDataBuilder *builder)
}
/**
- * gsk_uniform_data_builder_copy:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_copy:
+ * @builder: A #GskShaderArgsBuilder
*
* Makes a copy of the builder.
*
- * Returns: (transfer full): A copy of the builder, free with gsk_uniform_data_builder_free().
+ * Returns: (transfer full): A copy of the builder, free with gsk_shader_args_builder_free().
*/
-GskUniformDataBuilder *
-gsk_uniform_data_builder_copy (GskUniformDataBuilder *builder)
+GskShaderArgsBuilder *
+gsk_shader_args_builder_copy (GskShaderArgsBuilder *builder)
{
- GskUniformDataBuilder *new = g_new0 (GskUniformDataBuilder, 1);
+ GskShaderArgsBuilder *new = g_new0 (GskShaderArgsBuilder, 1);
new->data = g_memdup (builder->data, builder->shader->uniforms_size);
new->shader = g_object_ref (builder->shader);
return new;
}
/**
- * gsk_uniform_data_builder_set_float:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_float:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1049,7 +1075,7 @@ gsk_uniform_data_builder_copy (GskUniformDataBuilder *builder)
* The uniform must be of float type.
*/
void
-gsk_uniform_data_builder_set_float (GskUniformDataBuilder *builder,
+gsk_shader_args_builder_set_float (GskShaderArgsBuilder *builder,
int idx,
float value)
{
@@ -1066,8 +1092,8 @@ gsk_uniform_data_builder_set_float (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_int:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_int:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1075,9 +1101,9 @@ gsk_uniform_data_builder_set_float (GskUniformDataBuilder *builder,
* The uniform must be of int type.
*/
void
-gsk_uniform_data_builder_set_int (GskUniformDataBuilder *builder,
- int idx,
- gint32 value)
+gsk_shader_args_builder_set_int (GskShaderArgsBuilder *builder,
+ int idx,
+ gint32 value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
@@ -1092,8 +1118,8 @@ gsk_uniform_data_builder_set_int (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_uint:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_uint:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1101,9 +1127,9 @@ gsk_uniform_data_builder_set_int (GskUniformDataBuilder *builder,
* The uniform must be of uint type.
*/
void
-gsk_uniform_data_builder_set_uint (GskUniformDataBuilder *builder,
- int idx,
- guint32 value)
+gsk_shader_args_builder_set_uint (GskShaderArgsBuilder *builder,
+ int idx,
+ guint32 value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
@@ -1118,8 +1144,8 @@ gsk_uniform_data_builder_set_uint (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_bool:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_bool:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1127,9 +1153,9 @@ gsk_uniform_data_builder_set_uint (GskUniformDataBuilder *builder,
* The uniform must be of bool type.
*/
void
-gsk_uniform_data_builder_set_bool (GskUniformDataBuilder *builder,
- int idx,
- gboolean value)
+gsk_shader_args_builder_set_bool (GskShaderArgsBuilder *builder,
+ int idx,
+ gboolean value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
@@ -1144,8 +1170,8 @@ gsk_uniform_data_builder_set_bool (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_vec2:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_vec2:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1153,9 +1179,9 @@ gsk_uniform_data_builder_set_bool (GskUniformDataBuilder *builder,
* The uniform must be of vec2 type.
*/
void
-gsk_uniform_data_builder_set_vec2 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec2_t *value)
+gsk_shader_args_builder_set_vec2 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec2_t *value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
@@ -1170,8 +1196,8 @@ gsk_uniform_data_builder_set_vec2 (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_vec3:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_vec3:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1179,9 +1205,9 @@ gsk_uniform_data_builder_set_vec2 (GskUniformDataBuilder *builder,
* The uniform must be of vec3 type.
*/
void
-gsk_uniform_data_builder_set_vec3 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec3_t *value)
+gsk_shader_args_builder_set_vec3 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec3_t *value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
@@ -1196,8 +1222,8 @@ gsk_uniform_data_builder_set_vec3 (GskUniformDataBuilder *builder,
}
/**
- * gsk_uniform_data_builder_set_vec4:
- * @builder: A #GskUniformDataBuilder
+ * gsk_shader_args_builder_set_vec4:
+ * @builder: A #GskShaderArgsBuilder
* @idx: The index of the uniform
* @value: The value to set the uniform too
*
@@ -1205,9 +1231,9 @@ gsk_uniform_data_builder_set_vec3 (GskUniformDataBuilder *builder,
* The uniform must be of vec4 type.
*/
void
-gsk_uniform_data_builder_set_vec4 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec4_t *value)
+gsk_shader_args_builder_set_vec4 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec4_t *value)
{
GskGLShader *shader = builder->shader;
const GskGLUniform *u;
diff --git a/gsk/gskglshader.h b/gsk/gskglshader.h
index bf99b28acb..6401c3b535 100644
--- a/gsk/gskglshader.h
+++ b/gsk/gskglshader.h
@@ -30,6 +30,10 @@
G_BEGIN_DECLS
+#define GSK_TYPE_SHADER_ARGS_BUILDER (gsk_shader_args_builder_get_type ())
+
+typedef struct _GskShaderArgsBuilder GskShaderArgsBuilder;
+
#define GSK_TYPE_GL_SHADER (gsk_gl_shader_get_type ())
GDK_AVAILABLE_IN_ALL
@@ -62,94 +66,91 @@ GDK_AVAILABLE_IN_ALL
int gsk_gl_shader_get_uniform_offset (GskGLShader *shader,
int idx);
GDK_AVAILABLE_IN_ALL
-int gsk_gl_shader_get_uniforms_size (GskGLShader *shader);
+int gsk_gl_shader_get_args_size (GskGLShader *shader);
-/* Helpers for managing uniform data */
+/* Helpers for managing shader args */
GDK_AVAILABLE_IN_ALL
-float gsk_gl_shader_get_uniform_data_float (GskGLShader *shader,
- GBytes *uniform_data,
- int idx);
+GBytes * gsk_gl_shader_format_args_va (GskGLShader *shader,
+ va_list uniforms);
GDK_AVAILABLE_IN_ALL
-gint32 gsk_gl_shader_get_uniform_data_int (GskGLShader *shader,
- GBytes *uniform_data,
- int idx);
+GBytes * gsk_gl_shader_format_args (GskGLShader *shader,
+ ...) G_GNUC_NULL_TERMINATED;
+
GDK_AVAILABLE_IN_ALL
-guint32 gsk_gl_shader_get_uniform_data_uint (GskGLShader *shader,
- GBytes *uniform_data,
- int idx);
+float gsk_gl_shader_get_arg_float (GskGLShader *shader,
+ GBytes *args,
+ int idx);
GDK_AVAILABLE_IN_ALL
-gboolean gsk_gl_shader_get_uniform_data_bool (GskGLShader *shader,
- GBytes *uniform_data,
- int idx);
+gint32 gsk_gl_shader_get_arg_int (GskGLShader *shader,
+ GBytes *args,
+ int idx);
GDK_AVAILABLE_IN_ALL
-void gsk_gl_shader_get_uniform_data_vec2 (GskGLShader *shader,
- GBytes *uniform_data,
- int idx,
- graphene_vec2_t *out_value);
+guint32 gsk_gl_shader_get_arg_uint (GskGLShader *shader,
+ GBytes *args,
+ int idx);
GDK_AVAILABLE_IN_ALL
-void gsk_gl_shader_get_uniform_data_vec3 (GskGLShader *shader,
- GBytes *uniform_data,
- int idx,
- graphene_vec3_t *out_value);
+gboolean gsk_gl_shader_get_arg_bool (GskGLShader *shader,
+ GBytes *args,
+ int idx);
GDK_AVAILABLE_IN_ALL
-void gsk_gl_shader_get_uniform_data_vec4 (GskGLShader *shader,
- GBytes *uniform_data,
- int idx,
- graphene_vec4_t *out_value);
+void gsk_gl_shader_get_arg_vec2 (GskGLShader *shader,
+ GBytes *args,
+ int idx,
+ graphene_vec2_t *out_value);
GDK_AVAILABLE_IN_ALL
-GBytes * gsk_gl_shader_format_uniform_data_va (GskGLShader *shader,
- va_list uniforms);
-
-typedef struct _GskUniformDataBuilder GskUniformDataBuilder;
-
+void gsk_gl_shader_get_arg_vec3 (GskGLShader *shader,
+ GBytes *args,
+ int idx,
+ graphene_vec3_t *out_value);
GDK_AVAILABLE_IN_ALL
-GskUniformDataBuilder *gsk_gl_shader_build_uniform_data (GskGLShader *shader);
+void gsk_gl_shader_get_arg_vec4 (GskGLShader *shader,
+ GBytes *args,
+ int idx,
+ graphene_vec4_t *out_value);
-
-#define GSK_TYPE_UNIFORM_DATA_BUILDER (gsk_uniform_data_builder_get_type ())
+GDK_AVAILABLE_IN_ALL
+GskShaderArgsBuilder *gsk_gl_shader_build_args (GskGLShader *shader);
GDK_AVAILABLE_IN_ALL
-GType gsk_uniform_data_builder_get_type (void) G_GNUC_CONST;
+GType gsk_shader_args_builder_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GBytes * gsk_uniform_data_builder_finish (GskUniformDataBuilder *builder);
+GBytes * gsk_shader_args_builder_finish (GskShaderArgsBuilder *builder);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_free (GskUniformDataBuilder *builder);
+void gsk_shader_args_builder_free (GskShaderArgsBuilder *builder);
GDK_AVAILABLE_IN_ALL
-GskUniformDataBuilder *gsk_uniform_data_builder_copy (GskUniformDataBuilder *builder);
+GskShaderArgsBuilder *gsk_shader_args_builder_copy (GskShaderArgsBuilder *builder);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_float (GskUniformDataBuilder *builder,
- int idx,
- float value);
+void gsk_shader_args_builder_set_float (GskShaderArgsBuilder *builder,
+ int idx,
+ float value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_int (GskUniformDataBuilder *builder,
- int idx,
- gint32 value);
+void gsk_shader_args_builder_set_int (GskShaderArgsBuilder *builder,
+ int idx,
+ gint32 value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_uint (GskUniformDataBuilder *builder,
- int idx,
- guint32 value);
+void gsk_shader_args_builder_set_uint (GskShaderArgsBuilder *builder,
+ int idx,
+ guint32 value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_bool (GskUniformDataBuilder *builder,
- int idx,
- gboolean value);
+void gsk_shader_args_builder_set_bool (GskShaderArgsBuilder *builder,
+ int idx,
+ gboolean value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_vec2 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec2_t *value);
+void gsk_shader_args_builder_set_vec2 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec2_t *value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_vec3 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec3_t *value);
+void gsk_shader_args_builder_set_vec3 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec3_t *value);
GDK_AVAILABLE_IN_ALL
-void gsk_uniform_data_builder_set_vec4 (GskUniformDataBuilder *builder,
- int idx,
- const graphene_vec4_t *value);
-
-
+void gsk_shader_args_builder_set_vec4 (GskShaderArgsBuilder *builder,
+ int idx,
+ const graphene_vec4_t *value);
G_END_DECLS
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 3c392cd980..a6583ba947 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -459,7 +459,7 @@ GType gsk_gl_shader_node_get_type (void) G_GNUC_C
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_gl_shader_node_new (GskGLShader *shader,
const graphene_rect_t *bounds,
- GBytes *uniform_data,
+ GBytes *args,
GskRenderNode **children,
int n_children);
GDK_AVAILABLE_IN_ALL
@@ -468,11 +468,10 @@ GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_gl_shader_node_get_child (GskRenderNode *node,
int idx);
GDK_AVAILABLE_IN_ALL
-GBytes * gsk_gl_shader_node_get_uniform_data (GskRenderNode *node);
+GBytes * gsk_gl_shader_node_get_args (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskGLShader * gsk_gl_shader_node_get_shader (GskRenderNode *node);
-
G_END_DECLS
#endif /* __GSK_RENDER_NODE_H__ */
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 566236d0f3..2a1c6d038a 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -4477,7 +4477,7 @@ struct _GskGLShaderNode
GskRenderNode render_node;
GskGLShader *shader;
- GBytes *uniform_data;
+ GBytes *args;
GskRenderNode **children;
guint n_children;
};
@@ -4492,7 +4492,7 @@ gsk_gl_shader_node_finalize (GskRenderNode *node)
gsk_render_node_unref (self->children[i]);
g_free (self->children);
- g_bytes_unref (self->uniform_data);
+ g_bytes_unref (self->args);
g_object_unref (self->shader);
@@ -4518,7 +4518,7 @@ gsk_gl_shader_node_diff (GskRenderNode *node1,
if (graphene_rect_equal (&node1->bounds, &node2->bounds) &&
self1->shader == self2->shader &&
- g_bytes_compare (self1->uniform_data, self2->uniform_data) == 0 &&
+ g_bytes_compare (self1->args, self2->args) == 0 &&
self1->n_children == self2->n_children)
{
for (guint i = 0; i < self1->n_children; i++)
@@ -4540,14 +4540,14 @@ gsk_gl_shader_node_diff (GskRenderNode *node1,
* gsk_gl_shader_node_new:
* @shader: the #GskGLShader
* @bounds: the rectangle to render the shader into
- * @uniform_data: Data for the uniforms
+ * @args: Arguments for the uniforms
* @children: List of child nodes, these will be rendered to textures and used as input.
* @n_children: Length of @children (currenly the GL backend only supports max 4 children)
*
* Creates a #GskRenderNode that will render the given @shader into the area
- * given by @bounds. The @uniform_data is a block of data to use for uniform
+ * given by @bounds. The @args is a block of data to use for uniform
* input, as per types and offsets defined by the @shader. Normally this is
- * generated by a #GskUniformDataBuilder.
+ * generated by gsk_gl_shader_format_args() or #GskGLShaderArgBuilder.
*
* See #GskGLShader for details about how the shader should be written.
*
@@ -4565,7 +4565,7 @@ gsk_gl_shader_node_diff (GskRenderNode *node1,
GskRenderNode *
gsk_gl_shader_node_new (GskGLShader *shader,
const graphene_rect_t *bounds,
- GBytes *uniform_data,
+ GBytes *args,
GskRenderNode **children,
int n_children)
{
@@ -4581,10 +4581,10 @@ gsk_gl_shader_node_new (GskGLShader *shader,
graphene_rect_init_from_rect (&node->bounds, bounds);
self->shader = g_object_ref (shader);
- uniforms_size = gsk_gl_shader_get_uniforms_size (shader);
- g_assert (g_bytes_get_size (uniform_data) == uniforms_size);
+ uniforms_size = gsk_gl_shader_get_args_size (shader);
+ g_assert (g_bytes_get_size (args) == uniforms_size);
- self->uniform_data = g_bytes_ref (uniform_data);
+ self->args = g_bytes_ref (args);
self->n_children = n_children;
if (n_children > 0)
@@ -4655,21 +4655,21 @@ gsk_gl_shader_node_get_shader (GskRenderNode *node)
}
/**
- * gsk_gl_shader_node_get_uniform_data:
+ * gsk_gl_shader_node_get_args:
* @node: (type GskGLShaderNode): a #GskRenderNode for a gl shader
*
* Gets args for the node.
*
- * Returns: (transfer none): A #GBytes with the uniform data
+ * Returns: (transfer none): A #GBytes with the uniform arguments
*/
GBytes *
-gsk_gl_shader_node_get_uniform_data (GskRenderNode *node)
+gsk_gl_shader_node_get_args (GskRenderNode *node)
{
GskGLShaderNode *self = (GskGLShaderNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_GL_SHADER_NODE), NULL);
- return self->uniform_data;
+ return self->args;
}
GType gsk_render_node_types[GSK_RENDER_NODE_TYPE_N_TYPES];
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c
index 1e46c4135f..ecf0675c26 100644
--- a/gsk/gskrendernodeparser.c
+++ b/gsk/gskrendernodeparser.c
@@ -1189,7 +1189,7 @@ parse_uniform_value (GtkCssParser *parser,
}
static gboolean
-parse_uniform_data (GtkCssParser *parser, gpointer data)
+parse_shader_args (GtkCssParser *parser, gpointer data)
{
ShaderInfo *shader_info = data;
int n_uniforms = gsk_gl_shader_get_n_uniforms (shader_info->shader);
@@ -1221,7 +1221,7 @@ parse_glshader_node (GtkCssParser *parser)
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
{ "sourcecode", parse_shader, NULL, &shader_info },
- { "uniform-data", parse_uniform_data, clear_shader_info, &shader_info },
+ { "uniform-data", parse_shader_args, clear_shader_info, &shader_info },
{ "child1", parse_node, clear_node, &child[0] },
{ "child2", parse_node, clear_node, &child[1] },
{ "child3", parse_node, clear_node, &child[2] },
@@ -1229,8 +1229,8 @@ parse_glshader_node (GtkCssParser *parser)
};
GskGLShader *shader;
GskRenderNode *node;
- GskUniformDataBuilder *builder;
- GBytes *uniform_data = NULL;
+ GskShaderArgsBuilder *builder;
+ GBytes *args = NULL;
int len, i;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
@@ -1243,7 +1243,7 @@ parse_glshader_node (GtkCssParser *parser)
shader = shader_info.shader;
- builder = gsk_gl_shader_build_uniform_data (shader);
+ builder = gsk_gl_shader_build_args (shader);
for (i = 0; i < shader_info.uniform_values->len; i++)
{
GskGLUniformType uniform_type = gsk_gl_shader_get_uniform_type (shader, i);
@@ -1252,26 +1252,26 @@ parse_glshader_node (GtkCssParser *parser)
switch (uniform_type)
{
case GSK_GL_UNIFORM_TYPE_FLOAT:
- gsk_uniform_data_builder_set_float (builder, i, value->v[0]);
+ gsk_shader_args_builder_set_float (builder, i, value->v[0]);
break;
case GSK_GL_UNIFORM_TYPE_INT:
- gsk_uniform_data_builder_set_int (builder, i, value->i);
+ gsk_shader_args_builder_set_int (builder, i, value->i);
break;
case GSK_GL_UNIFORM_TYPE_UINT:
- gsk_uniform_data_builder_set_uint (builder, i, value->i);
+ gsk_shader_args_builder_set_uint (builder, i, value->i);
break;
case GSK_GL_UNIFORM_TYPE_BOOL:
- gsk_uniform_data_builder_set_bool (builder, i, value->i);
+ gsk_shader_args_builder_set_bool (builder, i, value->i);
break;
case GSK_GL_UNIFORM_TYPE_VEC2:
{
graphene_vec2_t v;
graphene_vec2_init (&v, value->v[0], value->v[1]);
- gsk_uniform_data_builder_set_vec2 (builder, i, &v);
+ gsk_shader_args_builder_set_vec2 (builder, i, &v);
}
break;
@@ -1279,7 +1279,7 @@ parse_glshader_node (GtkCssParser *parser)
{
graphene_vec3_t v;
graphene_vec3_init (&v, value->v[0], value->v[1], value->v[2]);
- gsk_uniform_data_builder_set_vec3 (builder, i, &v);
+ gsk_shader_args_builder_set_vec3 (builder, i, &v);
}
break;
@@ -1287,7 +1287,7 @@ parse_glshader_node (GtkCssParser *parser)
{
graphene_vec4_t v;
graphene_vec4_init (&v, value->v[0], value->v[1], value->v[2], value->v[3]);
- gsk_uniform_data_builder_set_vec4 (builder, i, &v);
+ gsk_shader_args_builder_set_vec4 (builder, i, &v);
}
break;
@@ -1297,14 +1297,14 @@ parse_glshader_node (GtkCssParser *parser)
}
}
- uniform_data = gsk_uniform_data_builder_finish (builder);
- gsk_uniform_data_builder_free (builder);
+ args = gsk_shader_args_builder_finish (builder);
+ gsk_shader_args_builder_free (builder);
- node = gsk_gl_shader_node_new (shader, &bounds, uniform_data,
+ node = gsk_gl_shader_node_new (shader, &bounds, args,
child, len);
g_array_unref (shader_info.uniform_values);
- g_bytes_unref (uniform_data);
+ g_bytes_unref (args);
g_object_unref (shader);
for (i = 0; i < 4; i++)
@@ -2729,7 +2729,7 @@ render_node_print (Printer *p,
case GSK_GL_SHADER_NODE:
{
GskGLShader *shader = gsk_gl_shader_node_get_shader (node);
- GBytes *uniform_data = gsk_gl_shader_node_get_uniform_data (node);
+ GBytes *args = gsk_gl_shader_node_get_args (node);
start_node (p, "glshader");
@@ -2759,28 +2759,28 @@ render_node_print (Printer *p,
case GSK_GL_UNIFORM_TYPE_FLOAT:
{
- float value = gsk_gl_shader_get_uniform_data_float (shader, uniform_data, i);
+ float value = gsk_gl_shader_get_arg_float (shader, args, i);
string_append_double (data, value);
}
break;
case GSK_GL_UNIFORM_TYPE_INT:
{
- gint32 value = gsk_gl_shader_get_uniform_data_int (shader, uniform_data, i);
+ gint32 value = gsk_gl_shader_get_arg_int (shader, args, i);
g_string_append_printf (data, "%d", value);
}
break;
case GSK_GL_UNIFORM_TYPE_UINT:
{
- guint32 value = gsk_gl_shader_get_uniform_data_uint (shader, uniform_data, i);
+ guint32 value = gsk_gl_shader_get_arg_uint (shader, args, i);
g_string_append_printf (data, "%u", value);
}
break;
case GSK_GL_UNIFORM_TYPE_BOOL:
{
- gboolean value = gsk_gl_shader_get_uniform_data_bool (shader, uniform_data, i);
+ gboolean value = gsk_gl_shader_get_arg_bool (shader, args, i);
g_string_append_printf (data, "%d", value);
}
break;
@@ -2788,8 +2788,8 @@ render_node_print (Printer *p,
case GSK_GL_UNIFORM_TYPE_VEC2:
{
graphene_vec2_t value;
- gsk_gl_shader_get_uniform_data_vec2 (shader, uniform_data, i,
- &value);
+ gsk_gl_shader_get_arg_vec2 (shader, args, i,
+ &value);
string_append_double (data, graphene_vec2_get_x (&value));
g_string_append (data, " ");
string_append_double (data, graphene_vec2_get_y (&value));
@@ -2799,8 +2799,8 @@ render_node_print (Printer *p,
case GSK_GL_UNIFORM_TYPE_VEC3:
{
graphene_vec3_t value;
- gsk_gl_shader_get_uniform_data_vec3 (shader, uniform_data, i,
- &value);
+ gsk_gl_shader_get_arg_vec3 (shader, args, i,
+ &value);
string_append_double (data, graphene_vec3_get_x (&value));
g_string_append (data, " ");
string_append_double (data, graphene_vec3_get_y (&value));
@@ -2812,8 +2812,8 @@ render_node_print (Printer *p,
case GSK_GL_UNIFORM_TYPE_VEC4:
{
graphene_vec4_t value;
- gsk_gl_shader_get_uniform_data_vec4 (shader, uniform_data, i,
- &value);
+ gsk_gl_shader_get_arg_vec4 (shader, args, i,
+ &value);
string_append_double (data, graphene_vec4_get_x (&value));
g_string_append (data, " ");
string_append_double (data, graphene_vec4_get_y (&value));
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 74cf37d960..976c81ab35 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -93,7 +93,7 @@ struct _GtkSnapshotState {
} clip;
struct {
GskGLShader *shader;
- GBytes *uniform_data;
+ GBytes *args;
graphene_rect_t bounds;
int n_children;
int node_idx;
@@ -848,13 +848,13 @@ gtk_snapshot_collect_gl_shader (GtkSnapshot *snapshot,
{
shader_node = gsk_gl_shader_node_new (state->data.glshader.shader,
&state->data.glshader.bounds,
- state->data.glshader.uniform_data,
+ state->data.glshader.args,
&state->data.glshader.nodes[0],
state->data.glshader.n_children);
}
g_object_unref (state->data.glshader.shader);
- g_bytes_unref (state->data.glshader.uniform_data);
+ g_bytes_unref (state->data.glshader.args);
for (guint i = 0; i < state->data.glshader.n_children; i++)
gsk_render_node_unref (state->data.glshader.nodes[i]);
g_free (state->data.glshader.nodes);
@@ -867,7 +867,7 @@ gtk_snapshot_collect_gl_shader (GtkSnapshot *snapshot,
* @snapshot: a #GtkSnapshot
* @shader: The code to run
* @bounds: the rectangle to render into
- * @uniform_data: Data block with uniform data for the shader.
+ * @args: Data block with uniform data 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
@@ -890,7 +890,7 @@ void
gtk_snapshot_push_gl_shader (GtkSnapshot *snapshot,
GskGLShader *shader,
const graphene_rect_t *bounds,
- GBytes *uniform_data,
+ GBytes *args,
int n_children)
{
GtkSnapshotState *state;
@@ -907,7 +907,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.uniform_data = g_bytes_ref (uniform_data);
+ state->data.glshader.args = g_bytes_ref (args);
state->data.glshader.n_children = n_children;
nodes = g_new0 (GskRenderNode *, n_children);
node_idx = n_children-1; /* We pop in reverse order */
@@ -952,10 +952,10 @@ gtk_snapshot_push_gl_shader_va (GtkSnapshot *snapshot,
int n_children,
va_list uniforms)
{
- GBytes *uniform_data = gsk_gl_shader_format_uniform_data_va (shader, uniforms);
+ GBytes *args = gsk_gl_shader_format_args_va (shader, uniforms);
gtk_snapshot_push_gl_shader (snapshot, shader, bounds,
- uniform_data, n_children);
- g_bytes_unref (uniform_data);
+ args, n_children);
+ g_bytes_unref (args);
}
/**
diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h
index 6adacc28cc..a87ee21c2b 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 *uniform_data,
+ GBytes *args,
int n_children);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_push_gl_shader_v (GtkSnapshot *snapshot,
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index aae4df77ca..42b24e3640 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -812,7 +812,7 @@ populate_render_node_properties (GtkListStore *store,
case GSK_GL_SHADER_NODE:
{
GskGLShader *shader = gsk_gl_shader_node_get_shader (node);
- GBytes *uniform_data = gsk_gl_shader_node_get_uniform_data (node);
+ GBytes *args = gsk_gl_shader_node_get_args (node);
int i;
add_int_row (store, "Required textures", gsk_gl_shader_get_n_required_textures (shader));
@@ -833,28 +833,28 @@ populate_render_node_properties (GtkListStore *store,
case GSK_GL_UNIFORM_TYPE_FLOAT:
add_float_row (store, title,
- gsk_gl_shader_get_uniform_data_float (shader, uniform_data, i));
+ gsk_gl_shader_get_arg_float (shader, args, i));
break;
case GSK_GL_UNIFORM_TYPE_INT:
add_int_row (store, title,
- gsk_gl_shader_get_uniform_data_int (shader, uniform_data, i));
+ gsk_gl_shader_get_arg_int (shader, args, i));
break;
case GSK_GL_UNIFORM_TYPE_UINT:
add_uint_row (store, title,
- gsk_gl_shader_get_uniform_data_uint (shader, uniform_data, i));
+ gsk_gl_shader_get_arg_uint (shader, args, i));
break;
case GSK_GL_UNIFORM_TYPE_BOOL:
add_boolean_row (store, title,
- gsk_gl_shader_get_uniform_data_bool (shader, uniform_data, i));
+ gsk_gl_shader_get_arg_bool (shader, args, i));
break;
case GSK_GL_UNIFORM_TYPE_VEC2:
{
graphene_vec2_t v;
- gsk_gl_shader_get_uniform_data_vec2 (shader, uniform_data, i, &v);
+ gsk_gl_shader_get_arg_vec2 (shader, args, i, &v);
float x = graphene_vec2_get_x (&v);
float y = graphene_vec2_get_x (&v);
char *s = g_strdup_printf ("%.2f %.2f", x, y);
@@ -866,7 +866,7 @@ populate_render_node_properties (GtkListStore *store,
case GSK_GL_UNIFORM_TYPE_VEC3:
{
graphene_vec3_t v;
- gsk_gl_shader_get_uniform_data_vec3 (shader, uniform_data, i, &v);
+ gsk_gl_shader_get_arg_vec3 (shader, args, i, &v);
float x = graphene_vec3_get_x (&v);
float y = graphene_vec3_get_y (&v);
float z = graphene_vec3_get_z (&v);
@@ -879,7 +879,7 @@ populate_render_node_properties (GtkListStore *store,
case GSK_GL_UNIFORM_TYPE_VEC4:
{
graphene_vec4_t v;
- gsk_gl_shader_get_uniform_data_vec4 (shader, uniform_data, i, &v);
+ gsk_gl_shader_get_arg_vec4 (shader, args, i, &v);
float x = graphene_vec4_get_x (&v);
float y = graphene_vec4_get_y (&v);
float z = graphene_vec4_get_z (&v);
diff --git a/testsuite/gsk/shader.c b/testsuite/gsk/shader.c
index f0e919c331..8b3872072c 100644
--- a/testsuite/gsk/shader.c
+++ b/testsuite/gsk/shader.c
@@ -109,7 +109,7 @@ test_create_data (void)
{
GBytes *bytes;
GskGLShader *shader;
- GskUniformDataBuilder *builder;
+ GskShaderArgsBuilder *builder;
graphene_vec2_t v2, vv2;
graphene_vec3_t v3, vv3;
graphene_vec4_t v4, vv4;
@@ -119,40 +119,40 @@ test_create_data (void)
g_assert_nonnull (shader);
g_clear_pointer (&bytes, g_bytes_unref);
- builder = gsk_gl_shader_build_uniform_data (shader);
+ builder = gsk_gl_shader_build_args (shader);
g_assert_nonnull (builder);
graphene_vec2_init (&v2, 20, 30);
graphene_vec3_init (&v3, -1, -2, -3);
graphene_vec4_init (&v4, 100, 0, -100, 10);
- gsk_uniform_data_builder_set_float (builder, 0, 0.5);
- gsk_uniform_data_builder_set_float (builder, 1, 20.0);
- gsk_uniform_data_builder_set_vec2 (builder, 2, &v2);
- gsk_uniform_data_builder_set_int (builder, 3, -99);
- gsk_uniform_data_builder_set_uint (builder, 4, 99);
- gsk_uniform_data_builder_set_bool (builder, 5, 1);
- gsk_uniform_data_builder_set_vec3 (builder, 6, &v3);
- gsk_uniform_data_builder_set_vec4 (builder, 7, &v4);
-
- bytes = gsk_uniform_data_builder_finish (builder);
-
- g_assert_cmpfloat (gsk_gl_shader_get_uniform_data_float (shader, bytes, 0), ==, 0.5);
- g_assert_cmpfloat (gsk_gl_shader_get_uniform_data_float (shader, bytes, 1), ==, 20.0);
- gsk_gl_shader_get_uniform_data_vec2 (shader, bytes, 2, &vv2);
+ gsk_shader_args_builder_set_float (builder, 0, 0.5);
+ gsk_shader_args_builder_set_float (builder, 1, 20.0);
+ gsk_shader_args_builder_set_vec2 (builder, 2, &v2);
+ gsk_shader_args_builder_set_int (builder, 3, -99);
+ gsk_shader_args_builder_set_uint (builder, 4, 99);
+ gsk_shader_args_builder_set_bool (builder, 5, 1);
+ gsk_shader_args_builder_set_vec3 (builder, 6, &v3);
+ gsk_shader_args_builder_set_vec4 (builder, 7, &v4);
+
+ bytes = gsk_shader_args_builder_finish (builder);
+
+ g_assert_cmpfloat (gsk_gl_shader_get_arg_float (shader, bytes, 0), ==, 0.5);
+ g_assert_cmpfloat (gsk_gl_shader_get_arg_float (shader, bytes, 1), ==, 20.0);
+ gsk_gl_shader_get_arg_vec2 (shader, bytes, 2, &vv2);
g_assert_true (graphene_vec2_equal (&v2, &vv2));
- g_assert_cmpint (gsk_gl_shader_get_uniform_data_int (shader, bytes, 3), ==, -99);
- g_assert_cmpuint (gsk_gl_shader_get_uniform_data_uint (shader, bytes, 4), ==, 99);
- g_assert_cmpint (gsk_gl_shader_get_uniform_data_bool (shader, bytes, 5), ==, 1);
+ g_assert_cmpint (gsk_gl_shader_get_arg_int (shader, bytes, 3), ==, -99);
+ g_assert_cmpuint (gsk_gl_shader_get_arg_uint (shader, bytes, 4), ==, 99);
+ g_assert_cmpint (gsk_gl_shader_get_arg_bool (shader, bytes, 5), ==, 1);
- gsk_gl_shader_get_uniform_data_vec3 (shader, bytes, 6, &vv3);
+ gsk_gl_shader_get_arg_vec3 (shader, bytes, 6, &vv3);
g_assert_true (graphene_vec3_equal (&v3, &vv3));
- gsk_gl_shader_get_uniform_data_vec4 (shader, bytes, 7, &vv4);
+ gsk_gl_shader_get_arg_vec4 (shader, bytes, 7, &vv4);
g_assert_true (graphene_vec4_equal (&v4, &vv4));
g_bytes_unref (bytes);
- gsk_uniform_data_builder_free (builder);
+ gsk_shader_args_builder_free (builder);
g_object_unref (shader);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]