From 5f1ffb5304d373404baf1aaaf90580ebdcf020f3 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 25 Jul 2024 19:21:10 +0200 Subject: [PATCH 01/27] cogl: Remove unused Primitive APIs This also removes a clutter interactive test, but as those tests don't serve that much any more for being no longer executed.. Part-of: --- clutter/clutter/clutter-deform-effect.c | 36 +- cogl/cogl/cogl-primitive.c | 187 +-------- cogl/cogl/cogl-primitive.h | 310 +------------- src/tests/clutter/interactive/meson.build | 1 - .../interactive/test-cogl-tex-polygon.c | 396 ------------------ .../cogl/conform/test-primitive-and-journal.c | 5 +- src/tests/cogl/conform/test-primitive.c | 160 ------- 7 files changed, 40 insertions(+), 1055 deletions(-) delete mode 100644 src/tests/clutter/interactive/test-cogl-tex-polygon.c diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 5326ec2428d..e3edf576553 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -61,6 +61,24 @@ #define DEFAULT_N_TILES 32 +/** + * ClutterVertexP3T2C4: + * @x: The x component of a position attribute + * @y: The y component of a position attribute + * @z: The z component of a position attribute + * @s: The s component of a texture coordinate attribute + * @t: The t component of a texture coordinate attribute + * @r: The red component of a color attribute + * @b: The green component of a color attribute + * @g: The blue component of a color attribute + * @a: The alpha component of a color attribute + */ +typedef struct { + float x, y, z; + float s, t; + uint8_t r, g, b, a; +} ClutterVertexP3T2C4; + typedef struct _ClutterDeformEffectPrivate { CoglPipeline *back_pipeline; @@ -179,7 +197,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect, if (priv->is_dirty) { gboolean mapped_buffer; - CoglVertexP3T2C4 *verts; + ClutterVertexP3T2C4 *verts; ClutterActor *actor; gfloat width, height; guint opacity; @@ -217,7 +235,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect, { for (j = 0; j < priv->x_tiles + 1; j++) { - CoglVertexP3T2C4 *vertex_out; + ClutterVertexP3T2C4 *vertex_out; ClutterTextureVertex vertex; /* CoglTextureVertex isn't an ideal structure to use for @@ -431,7 +449,7 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self) priv->buffer = cogl_attribute_buffer_new (ctx, - sizeof (CoglVertexP3T2C4) * + sizeof (ClutterVertexP3T2C4) * priv->n_vertices, NULL); @@ -442,20 +460,20 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self) attributes[0] = cogl_attribute_new (priv->buffer, "cogl_position_in", - sizeof (CoglVertexP3T2C4), - G_STRUCT_OFFSET (CoglVertexP3T2C4, x), + sizeof (ClutterVertexP3T2C4), + G_STRUCT_OFFSET (ClutterVertexP3T2C4, x), 3, /* n_components */ COGL_ATTRIBUTE_TYPE_FLOAT); attributes[1] = cogl_attribute_new (priv->buffer, "cogl_tex_coord0_in", - sizeof (CoglVertexP3T2C4), - G_STRUCT_OFFSET (CoglVertexP3T2C4, s), + sizeof (ClutterVertexP3T2C4), + G_STRUCT_OFFSET (ClutterVertexP3T2C4, s), 2, /* n_components */ COGL_ATTRIBUTE_TYPE_FLOAT); attributes[2] = cogl_attribute_new (priv->buffer, "cogl_color_in", - sizeof (CoglVertexP3T2C4), - G_STRUCT_OFFSET (CoglVertexP3T2C4, r), + sizeof (ClutterVertexP3T2C4), + G_STRUCT_OFFSET (ClutterVertexP3T2C4, r), 4, /* n_components */ COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); diff --git a/cogl/cogl/cogl-primitive.c b/cogl/cogl/cogl-primitive.c index 0a354873400..edc26635544 100644 --- a/cogl/cogl/cogl-primitive.c +++ b/cogl/cogl/cogl-primitive.c @@ -229,36 +229,6 @@ cogl_primitive_new_p2c4 (CoglContext *ctx, 2); } -CoglPrimitive * -cogl_primitive_new_p3c4 (CoglContext *ctx, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP3C4 *data) -{ - CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP3C4), data); - CoglAttribute *attributes[2]; - - attributes[0] = cogl_attribute_new (attribute_buffer, - "cogl_position_in", - sizeof (CoglVertexP3C4), - offsetof (CoglVertexP3C4, x), - 3, - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = cogl_attribute_new (attribute_buffer, - "cogl_color_in", - sizeof (CoglVertexP3C4), - offsetof (CoglVertexP3C4, r), - 4, - COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); - - g_object_unref (attribute_buffer); - - return _cogl_primitive_new_with_attributes_unref (mode, n_vertices, - attributes, - 2); -} - CoglPrimitive * cogl_primitive_new_p2t2 (CoglContext *ctx, CoglVerticesMode mode, @@ -319,88 +289,6 @@ cogl_primitive_new_p3t2 (CoglContext *ctx, 2); } -CoglPrimitive * -cogl_primitive_new_p2t2c4 (CoglContext *ctx, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP2T2C4 *data) -{ - CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (ctx, - n_vertices * sizeof (CoglVertexP2T2C4), data); - CoglAttribute *attributes[3]; - - attributes[0] = cogl_attribute_new (attribute_buffer, - "cogl_position_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, x), - 2, - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = cogl_attribute_new (attribute_buffer, - "cogl_tex_coord0_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, s), - 2, - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[2] = cogl_attribute_new (attribute_buffer, - "cogl_color_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, r), - 4, - COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); - - g_object_unref (attribute_buffer); - - return _cogl_primitive_new_with_attributes_unref (mode, n_vertices, - attributes, - 3); -} - -CoglPrimitive * -cogl_primitive_new_p3t2c4 (CoglContext *ctx, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP3T2C4 *data) -{ - CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (ctx, - n_vertices * sizeof (CoglVertexP3T2C4), data); - CoglAttribute *attributes[3]; - - attributes[0] = cogl_attribute_new (attribute_buffer, - "cogl_position_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, x), - 3, - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = cogl_attribute_new (attribute_buffer, - "cogl_tex_coord0_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, s), - 2, - COGL_ATTRIBUTE_TYPE_FLOAT); - attributes[2] = cogl_attribute_new (attribute_buffer, - "cogl_color_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, r), - 4, - COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); - - g_object_unref (attribute_buffer); - - return _cogl_primitive_new_with_attributes_unref (mode, n_vertices, - attributes, - 3); -} - -int -cogl_primitive_get_first_vertex (CoglPrimitive *primitive) -{ - g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); - - return primitive->first_vertex; -} - void cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int first_vertex) @@ -410,14 +298,6 @@ cogl_primitive_set_first_vertex (CoglPrimitive *primitive, primitive->first_vertex = first_vertex; } -int -cogl_primitive_get_n_vertices (CoglPrimitive *primitive) -{ - g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); - - return primitive->n_vertices; -} - void cogl_primitive_set_n_vertices (CoglPrimitive *primitive, int n_vertices) @@ -427,23 +307,6 @@ cogl_primitive_set_n_vertices (CoglPrimitive *primitive, primitive->n_vertices = n_vertices; } -CoglVerticesMode -cogl_primitive_get_mode (CoglPrimitive *primitive) -{ - g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), 0); - - return primitive->mode; -} - -void -cogl_primitive_set_mode (CoglPrimitive *primitive, - CoglVerticesMode mode) -{ - g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); - - primitive->mode = mode; -} - void cogl_primitive_set_indices (CoglPrimitive *primitive, CoglIndices *indices, @@ -459,44 +322,10 @@ cogl_primitive_set_indices (CoglPrimitive *primitive, primitive->n_vertices = n_indices; } -CoglIndices * -cogl_primitive_get_indices (CoglPrimitive *primitive) -{ - return primitive->indices; -} - -CoglPrimitive * -cogl_primitive_copy (CoglPrimitive *primitive) -{ - CoglPrimitive *copy; - - copy = cogl_primitive_new_with_attributes (primitive->mode, - primitive->n_vertices, - (CoglAttribute **)primitive->attributes->pdata, - primitive->n_attributes); - - cogl_primitive_set_indices (copy, primitive->indices, primitive->n_vertices); - cogl_primitive_set_first_vertex (copy, primitive->first_vertex); - - return copy; -} - -void -cogl_primitive_foreach_attribute (CoglPrimitive *primitive, - CoglPrimitiveAttributeCallback callback, - void *user_data) -{ - int i; - for (i = 0; i < primitive->n_attributes; i++) - if (!callback (primitive, primitive->attributes->pdata[i], user_data)) - break; -} - void -_cogl_primitive_draw (CoglPrimitive *primitive, +cogl_primitive_draw (CoglPrimitive *primitive, CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - CoglDrawFlags flags) + CoglPipeline *pipeline) { if (primitive->indices) _cogl_framebuffer_draw_indexed_attributes (framebuffer, @@ -507,7 +336,7 @@ _cogl_primitive_draw (CoglPrimitive *primitive, primitive->indices, (CoglAttribute **) primitive->attributes->pdata, primitive->n_attributes, - flags); + 0); else _cogl_framebuffer_draw_attributes (framebuffer, pipeline, @@ -516,13 +345,5 @@ _cogl_primitive_draw (CoglPrimitive *primitive, primitive->n_vertices, (CoglAttribute **) primitive->attributes->pdata, primitive->n_attributes, - flags); -} - -void -cogl_primitive_draw (CoglPrimitive *primitive, - CoglFramebuffer *framebuffer, - CoglPipeline *pipeline) -{ - _cogl_primitive_draw (primitive, framebuffer, pipeline, 0 /* flags */); + 0); } diff --git a/cogl/cogl/cogl-primitive.h b/cogl/cogl/cogl-primitive.h index 0de14b28988..7d278d85322 100644 --- a/cogl/cogl/cogl-primitive.h +++ b/cogl/cogl/cogl-primitive.h @@ -106,24 +106,6 @@ typedef struct { uint8_t r, g, b, a; } CoglVertexP2C4; -/** - * CoglVertexP3C4: - * @x: The x component of a position attribute - * @y: The y component of a position attribute - * @z: The z component of a position attribute - * @r: The red component of a color attribute - * @b: The green component of a color attribute - * @g: The blue component of a color attribute - * @a: The alpha component of a color attribute - * - * A convenience vertex definition that can be used with - * cogl_primitive_new_p3c4(). - */ -typedef struct { - float x, y, z; - uint8_t r, g, b, a; -} CoglVertexP3C4; - /** * CoglVertexP2T2: * @x: The x component of a position attribute @@ -155,48 +137,6 @@ typedef struct { float s, t; } CoglVertexP3T2; - -/** - * CoglVertexP2T2C4: - * @x: The x component of a position attribute - * @y: The y component of a position attribute - * @s: The s component of a texture coordinate attribute - * @t: The t component of a texture coordinate attribute - * @r: The red component of a color attribute - * @b: The green component of a color attribute - * @g: The blue component of a color attribute - * @a: The alpha component of a color attribute - * - * A convenience vertex definition that can be used with - * cogl_primitive_new_p3t2c4(). - */ -typedef struct { - float x, y; - float s, t; - uint8_t r, g, b, a; -} CoglVertexP2T2C4; - -/** - * CoglVertexP3T2C4: - * @x: The x component of a position attribute - * @y: The y component of a position attribute - * @z: The z component of a position attribute - * @s: The s component of a texture coordinate attribute - * @t: The t component of a texture coordinate attribute - * @r: The red component of a color attribute - * @b: The green component of a color attribute - * @g: The blue component of a color attribute - * @a: The alpha component of a color attribute - * - * A convenience vertex definition that can be used with - * cogl_primitive_new_p3t2c4(). - */ -typedef struct { - float x, y, z; - float s, t; - uint8_t r, g, b, a; -} CoglVertexP3T2C4; - /** * cogl_primitive_new: * @mode: A #CoglVerticesMode defining how to draw the vertices @@ -282,7 +222,7 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, * hardware doesn't support non-power of two textures (For example you * are using GLES 1.1) then you will need to make sure your assets are * resized to a power-of-two size (though they don't have to be square) - * + * * * Return value: (transfer full): A newly allocated #CoglPrimitive * with a reference of 1. This can be freed using g_object_unref(). @@ -332,7 +272,7 @@ cogl_primitive_new_p2 (CoglContext *context, * hardware doesn't support non-power of two textures (For example you * are using GLES 1.1) then you will need to make sure your assets are * resized to a power-of-two size (though they don't have to be square) - * + * * * Return value: (transfer full): A newly allocated #CoglPrimitive * with a reference of 1. This can be freed using g_object_unref(). @@ -384,7 +324,7 @@ cogl_primitive_new_p3 (CoglContext *context, * hardware doesn't support non-power of two textures (For example you * are using GLES 1.1) then you will need to make sure your assets are * resized to a power-of-two size (though they don't have to be square) - * + * * * Return value: (transfer full): A newly allocated #CoglPrimitive * with a reference of 1. This can be freed using g_object_unref(). @@ -395,58 +335,6 @@ cogl_primitive_new_p2c4 (CoglContext *context, int n_vertices, const CoglVertexP2C4 *data); -/** - * cogl_primitive_new_p3c4: - * @context: A #CoglContext - * @mode: A #CoglVerticesMode defining how to draw the vertices - * @n_vertices: The number of vertices to read from @data and also - * the number of vertices to read when later drawing. - * @data: (array length=n_vertices) (element-type Cogl.VertexP3C4): An array - * of #CoglVertexP3C4 vertices - * - * Provides a convenient way to describe a primitive, such as a single - * triangle strip or a triangle fan, that will internally allocate the - * necessary #CoglAttributeBuffer storage, describe the position - * and color attributes with `CoglAttribute`s and upload - * your data. - * - * For example to draw a convex polygon with a linear gradient you - * can do: - * ```c - * CoglVertexP3C4 triangle[] = - * { - * { 0, 300, 0, 0xff, 0x00, 0x00, 0xff }, - * { 150, 0, 0, 0x00, 0xff, 0x00, 0xff }, - * { 300, 300, 0, 0xff, 0x00, 0x00, 0xff } - * }; - * prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, - * 3, triangle); - * cogl_primitive_draw (prim); - * ``` - * - * The value passed as @n_vertices is initially used to determine how - * much can be read from @data but it will also be used to update the - * #CoglPrimitive `n_vertices` property as if - * cogl_primitive_set_n_vertices() were called. This property defines - * the number of vertices to read when drawing. - - * The primitive API doesn't support drawing with sliced - * textures (since switching between slices implies changing state and - * so that implies multiple primitives need to be submitted). If your - * hardware doesn't support non-power of two textures (For example you - * are using GLES 1.1) then you will need to make sure your assets are - * resized to a power-of-two size (though they don't have to be square) - * - * - * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using g_object_unref(). - */ -COGL_EXPORT CoglPrimitive * -cogl_primitive_new_p3c4 (CoglContext *context, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP3C4 *data); - /** * cogl_primitive_new_p2t2: * @context: A #CoglContext @@ -488,7 +376,7 @@ cogl_primitive_new_p3c4 (CoglContext *context, * hardware doesn't support non-power of two textures (For example you * are using GLES 1.1) then you will need to make sure your assets are * resized to a power-of-two size (though they don't have to be square) - * + * * * Return value: (transfer full): A newly allocated #CoglPrimitive * with a reference of 1. This can be freed using g_object_unref(). @@ -540,7 +428,7 @@ cogl_primitive_new_p2t2 (CoglContext *context, * hardware doesn't support non-power of two textures (For example you * are using GLES 1.1) then you will need to make sure your assets are * resized to a power-of-two size (though they don't have to be square) - * + * * * Return value: (transfer full): A newly allocated #CoglPrimitive * with a reference of 1. This can be freed using g_object_unref(). @@ -551,138 +439,10 @@ cogl_primitive_new_p3t2 (CoglContext *context, int n_vertices, const CoglVertexP3T2 *data); -/** - * cogl_primitive_new_p2t2c4: - * @context: A #CoglContext - * @mode: A #CoglVerticesMode defining how to draw the vertices - * @n_vertices: The number of vertices to read from @data and also - * the number of vertices to read when later drawing. - * @data: (array length=n_vertices) (element-type Cogl.VertexP2T2C4): An - * array of #CoglVertexP2T2C4 vertices - * - * Provides a convenient way to describe a primitive, such as a single - * triangle strip or a triangle fan, that will internally allocate the - * necessary #CoglAttributeBuffer storage, describe the position, texture - * coordinate and color attributes with `CoglAttribute`s and - * upload your data. - * - * For example to draw a convex polygon with texture mapping and a - * linear gradient you can do: - * ```c - * CoglVertexP2T2C4 triangle[] = - * { - * { 0, 300, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff}, - * { 150, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff}, - * { 300, 300, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff} - * }; - * prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, - * 3, triangle); - * cogl_primitive_draw (prim); - * ``` - * - * The value passed as @n_vertices is initially used to determine how - * much can be read from @data but it will also be used to update the - * #CoglPrimitive `n_vertices` property as if - * cogl_primitive_set_n_vertices() were called. This property defines - * the number of vertices to read when drawing. - - * The primitive API doesn't support drawing with sliced - * textures (since switching between slices implies changing state and - * so that implies multiple primitives need to be submitted). If your - * hardware doesn't support non-power of two textures (For example you - * are using GLES 1.1) then you will need to make sure your assets are - * resized to a power-of-two size (though they don't have to be square) - * - * - * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using g_object_unref(). - */ -COGL_EXPORT CoglPrimitive * -cogl_primitive_new_p2t2c4 (CoglContext *context, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP2T2C4 *data); - -/** - * cogl_primitive_new_p3t2c4: - * @context: A #CoglContext - * @mode: A #CoglVerticesMode defining how to draw the vertices - * @n_vertices: The number of vertices to read from @data and also - * the number of vertices to read when later drawing. - * @data: (array length=n_vertices) (element-type Cogl.VertexP3T2C4): An - * array of #CoglVertexP3T2C4 vertices - * - * Provides a convenient way to describe a primitive, such as a single - * triangle strip or a triangle fan, that will internally allocate the - * necessary #CoglAttributeBuffer storage, describe the position, texture - * coordinate and color attributes with `CoglAttribute`s and - * upload your data. - * - * For example to draw a convex polygon with texture mapping and a - * linear gradient you can do: - * ```c - * CoglVertexP3T2C4 triangle[] = - * { - * { 0, 300, 0, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff}, - * { 150, 0, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff}, - * { 300, 300, 0, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff} - * }; - * prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, - * 3, triangle); - * cogl_primitive_draw (prim); - * ``` - * - * The value passed as @n_vertices is initially used to determine how - * much can be read from @data but it will also be used to update the - * #CoglPrimitive `n_vertices` property as if - * cogl_primitive_set_n_vertices() were called. This property defines - * the number of vertices to read when drawing. - - * The primitive API doesn't support drawing with sliced - * textures (since switching between slices implies changing state and - * so that implies multiple primitives need to be submitted). If your - * hardware doesn't support non-power of two textures (For example you - * are using GLES 1.1) then you will need to make sure your assets are - * resized to a power-of-two size (though they don't have to be square) - * - * - * Return value: (transfer full): A newly allocated #CoglPrimitive - * with a reference of 1. This can be freed using g_object_unref(). - */ -COGL_EXPORT CoglPrimitive * -cogl_primitive_new_p3t2c4 (CoglContext *context, - CoglVerticesMode mode, - int n_vertices, - const CoglVertexP3T2C4 *data); -COGL_EXPORT int -cogl_primitive_get_first_vertex (CoglPrimitive *primitive); - COGL_EXPORT void cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int first_vertex); -/** - * cogl_primitive_get_n_vertices: - * @primitive: A #CoglPrimitive object - * - * Queries the number of vertices to read when drawing the given - * @primitive. Usually this value is implicitly set when associating - * vertex data or indices with a #CoglPrimitive. - * - * If cogl_primitive_set_indices() has been used to associate a - * sequence of #CoglIndices with the given @primitive then the - * number of vertices to read can also be phrased as the number - * of indices to read. - * - * To be clear; it doesn't refer to the number of vertices - in - * terms of data - associated with the primitive it's just the number - * of vertices to read and draw. - * - * Returns: The number of vertices to read when drawing. - */ -COGL_EXPORT int -cogl_primitive_get_n_vertices (CoglPrimitive *primitive); - /** * cogl_primitive_set_n_vertices: * @primitive: A #CoglPrimitive object @@ -702,12 +462,6 @@ COGL_EXPORT void cogl_primitive_set_n_vertices (CoglPrimitive *primitive, int n_vertices); -COGL_EXPORT CoglVerticesMode -cogl_primitive_get_mode (CoglPrimitive *primitive); - -COGL_EXPORT void -cogl_primitive_set_mode (CoglPrimitive *primitive, - CoglVerticesMode mode); /** * cogl_primitive_set_indices: @@ -739,60 +493,6 @@ cogl_primitive_set_indices (CoglPrimitive *primitive, CoglIndices *indices, int n_indices); -/** - * cogl_primitive_get_indices: - * @primitive: A #CoglPrimitive - * - * Return value: (transfer none) (nullable) (array): the indices that were set - * with cogl_primitive_set_indices() or %NULL if no indices were set. - */ -COGL_EXPORT CoglIndices * -cogl_primitive_get_indices (CoglPrimitive *primitive); - -/** - * cogl_primitive_copy: - * @primitive: A primitive copy - * - * Makes a copy of an existing #CoglPrimitive. Note that the primitive - * is a shallow copy which means it will use the same attributes and - * attribute buffers as the original primitive. - * - * Return value: (transfer full): the new primitive - */ -COGL_EXPORT CoglPrimitive * -cogl_primitive_copy (CoglPrimitive *primitive); - -/** - * CoglPrimitiveAttributeCallback: - * @primitive: The #CoglPrimitive whose attributes are being iterated - * @attribute: The #CoglAttribute - * @user_data: The private data passed to cogl_primitive_foreach_attribute() - * - * The callback prototype used with cogl_primitive_foreach_attribute() - * for iterating all the attributes of a #CoglPrimitive. - * - * The function should return TRUE to continue iteration or FALSE to - * stop. - */ -typedef gboolean (* CoglPrimitiveAttributeCallback) (CoglPrimitive *primitive, - CoglAttribute *attribute, - void *user_data); - -/** - * cogl_primitive_foreach_attribute: - * @primitive: A #CoglPrimitive object - * @callback: (scope call): A #CoglPrimitiveAttributeCallback to be - * called for each attribute - * @user_data: (closure): Private data that will be passed to the - * callback - * - * Iterates all the attributes of the given #CoglPrimitive. - */ -COGL_EXPORT void -cogl_primitive_foreach_attribute (CoglPrimitive *primitive, - CoglPrimitiveAttributeCallback callback, - void *user_data); - /** * cogl_primitive_draw: * @primitive: A #CoglPrimitive geometry object diff --git a/src/tests/clutter/interactive/meson.build b/src/tests/clutter/interactive/meson.build index b6138f711c5..6ceb474af96 100644 --- a/src/tests/clutter/interactive/meson.build +++ b/src/tests/clutter/interactive/meson.build @@ -19,7 +19,6 @@ clutter_tests_interactive_test_sources = [ 'test-cogl-shader-glsl.c', 'test-cogl-tex-tile.c', 'test-cogl-offscreen.c', - 'test-cogl-tex-polygon.c', 'test-animation.c', 'test-binding-pool.c', 'test-text.c', diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c deleted file mode 100644 index 5249b6d4b0b..00000000000 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ /dev/null @@ -1,396 +0,0 @@ -#include -#include -#include -#include -#include - -#include "clutter/test-utils.h" -#include "tests/clutter-test-utils.h" - -/* Coglbox declaration - *--------------------------------------------------*/ - -G_BEGIN_DECLS - -#define TEST_TYPE_COGLBOX test_coglbox_get_type() - -static -G_DECLARE_FINAL_TYPE (TestCoglbox, test_coglbox, TEST, COGLBOX, ClutterActor) - -struct _TestCoglbox -{ - ClutterActor parent; - - CoglTexture *sliced_tex; - CoglTexture *not_sliced_tex; - gint frame; - gboolean use_sliced; - gboolean use_linear_filtering; -}; - -G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - - -int -test_cogl_tex_polygon_main (int argc, char *argv[]); - -const char * -test_cogl_tex_polygon_describe (void); - -G_END_DECLS - -/* Coglbox implementation - *--------------------------------------------------*/ - -static void -test_coglbox_fade_texture (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - float x1, - float y1, - float x2, - float y2, - float tx1, - float ty1, - float tx2, - float ty2) -{ - CoglVertexP3T2C4 vertices[4]; - CoglPrimitive *primitive; - int i; - - vertices[0].x = x1; - vertices[0].y = y1; - vertices[0].z = 0; - vertices[0].s = tx1; - vertices[0].t = ty1; - vertices[1].x = x1; - vertices[1].y = y2; - vertices[1].z = 0; - vertices[1].s = tx1; - vertices[1].t = ty2; - vertices[2].x = x2; - vertices[2].y = y2; - vertices[2].z = 0; - vertices[2].s = tx2; - vertices[2].t = ty2; - vertices[3].x = x2; - vertices[3].y = y1; - vertices[3].z = 0; - vertices[3].s = tx2; - vertices[3].t = ty1; - - for (i = 0; i < 4; i++) - { - CoglColor cogl_color; - - cogl_color_init_from_4f (&cogl_color, - 1.0f, - 1.0f, - 1.0f, - ((i ^ (i >> 1)) & 1) ? 0.0 : 128.0f / 255.0f); - cogl_color_premultiply (&cogl_color); - vertices[i].r = (uint8_t) (cogl_color_get_red (&cogl_color) * 255.0); - vertices[i].g = (uint8_t) (cogl_color_get_green (&cogl_color) * 255.0); - vertices[i].b = (uint8_t) (cogl_color_get_blue (&cogl_color) * 255.0); - vertices[i].a = (uint8_t) (cogl_color_get_alpha (&cogl_color) * 255.0); - } - - primitive = - cogl_primitive_new_p3t2c4 (cogl_framebuffer_get_context (framebuffer), - COGL_VERTICES_MODE_TRIANGLE_FAN, - 4, - vertices); - cogl_primitive_draw (primitive, framebuffer, pipeline); - g_object_unref (primitive); -} - -static void -test_coglbox_triangle_texture (CoglFramebuffer *framebuffer, - CoglPipeline *pipeline, - int tex_width, - int tex_height, - float x, - float y, - float tx1, - float ty1, - float tx2, - float ty2, - float tx3, - float ty3) -{ - CoglVertexP3T2 vertices[3]; - CoglPrimitive *primitive; - - vertices[0].x = x + tx1 * tex_width; - vertices[0].y = y + ty1 * tex_height; - vertices[0].z = 0; - vertices[0].s = tx1; - vertices[0].t = ty1; - - vertices[1].x = x + tx2 * tex_width; - vertices[1].y = y + ty2 * tex_height; - vertices[1].z = 0; - vertices[1].s = tx2; - vertices[1].t = ty2; - - vertices[2].x = x + tx3 * tex_width; - vertices[2].y = y + ty3 * tex_height; - vertices[2].z = 0; - vertices[2].s = tx3; - vertices[2].t = ty3; - - primitive = cogl_primitive_new_p3t2 (cogl_framebuffer_get_context (framebuffer), - COGL_VERTICES_MODE_TRIANGLE_FAN, - 3, - vertices); - cogl_primitive_draw (primitive, framebuffer, pipeline); - g_object_unref (primitive); -} - -static void -test_coglbox_paint (ClutterActor *self, - ClutterPaintContext *paint_context) -{ - TestCoglbox *coglbox = TEST_COGLBOX (self); - CoglTexture *tex_handle = coglbox->use_sliced ? coglbox->sliced_tex - : coglbox->not_sliced_tex; - int tex_width = cogl_texture_get_width (tex_handle); - int tex_height = cogl_texture_get_height (tex_handle); - CoglPipeline *pipeline; - CoglFramebuffer *framebuffer = - clutter_paint_context_get_framebuffer (paint_context); - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); - - pipeline = cogl_pipeline_new (ctx); - cogl_pipeline_set_layer_texture (pipeline, 0, tex_handle); - - cogl_pipeline_set_layer_filters (pipeline, 0, - coglbox->use_linear_filtering - ? COGL_PIPELINE_FILTER_LINEAR : - COGL_PIPELINE_FILTER_NEAREST, - coglbox->use_linear_filtering - ? COGL_PIPELINE_FILTER_LINEAR : - COGL_PIPELINE_FILTER_NEAREST); - - cogl_framebuffer_push_matrix (framebuffer); - cogl_framebuffer_translate (framebuffer, tex_width / 2, 0, 0); - cogl_framebuffer_rotate (framebuffer, coglbox->frame, 0, 1, 0); - cogl_framebuffer_translate (framebuffer, -tex_width / 2, 0, 0); - - /* Draw a hand and reflect it */ - cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, - 0, 0, tex_width, tex_height, - 0, 0, 1, 1); - test_coglbox_fade_texture (framebuffer, pipeline, - 0, tex_height, - tex_width, (tex_height * 3 / 2), - 0.0, 1.0, - 1.0, 0.5); - - cogl_framebuffer_pop_matrix (framebuffer); - - cogl_framebuffer_push_matrix (framebuffer); - cogl_framebuffer_translate (framebuffer, tex_width * 3 / 2 + 60, 0, 0); - cogl_framebuffer_rotate (framebuffer, coglbox->frame, 0, 1, 0); - cogl_framebuffer_translate (framebuffer, -tex_width / 2 - 10, 0, 0); - - /* Draw the texture split into two triangles */ - test_coglbox_triangle_texture (framebuffer, pipeline, - tex_width, tex_height, - 0, 0, - 0, 0, - 0, 1, - 1, 1); - test_coglbox_triangle_texture (framebuffer, pipeline, - tex_width, tex_height, - 20, 0, - 0, 0, - 1, 0, - 1, 1); - - cogl_framebuffer_pop_matrix (framebuffer); - - g_object_unref (pipeline); -} - -static void -test_coglbox_dispose (GObject *object) -{ - TestCoglbox *coglbox = TEST_COGLBOX (object); - - g_object_unref (coglbox->not_sliced_tex); - g_object_unref (coglbox->sliced_tex); - - G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); -} - -static void -test_coglbox_init (TestCoglbox *self) -{ - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); - GError *error = NULL; - gchar *file; - - self->use_linear_filtering = FALSE; - self->use_sliced = FALSE; - - file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - self->sliced_tex = - clutter_test_texture_2d_sliced_new_from_file (ctx, file, - &error); - if (self->sliced_tex == NULL) - { - if (error) - { - g_warning ("Texture loading failed: %s", error->message); - g_error_free (error); - error = NULL; - } - else - g_warning ("Texture loading failed: "); - } - - self->not_sliced_tex = clutter_test_texture_2d_new_from_file (ctx, file, &error); - if (self->not_sliced_tex == NULL) - { - if (error) - { - g_warning ("Texture loading failed: %s", error->message); - g_error_free (error); - } - else - g_warning ("Texture loading failed: "); - } - - g_free (file); -} - -static void -test_coglbox_class_init (TestCoglboxClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - - gobject_class->dispose = test_coglbox_dispose; - actor_class->paint = test_coglbox_paint; -} - -static ClutterActor* -test_coglbox_new (void) -{ - return g_object_new (TEST_TYPE_COGLBOX, NULL); -} - -static void -frame_cb (ClutterTimeline *timeline, - int elapsed_msecs, - gpointer data) -{ - TestCoglbox *coglbox = TEST_COGLBOX (data); - gdouble progress = clutter_timeline_get_progress (timeline); - - coglbox->frame = (int) (360.0 * progress); - clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); -} - -static void -update_toggle_text (ClutterText *button, gboolean val) -{ - clutter_text_set_text (button, val ? "Enabled" : "Disabled"); -} - -static gboolean -on_toggle_click (ClutterActor *button, ClutterEvent *event, - gboolean *toggle_val) -{ - update_toggle_text (CLUTTER_TEXT (button), *toggle_val = !*toggle_val); - - return TRUE; -} - -static ClutterActor * -make_toggle (const char *label_text, gboolean *toggle_val) -{ - ClutterActor *group = clutter_actor_new (); - ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text); - ClutterActor *button = clutter_text_new_with_text ("Sans 14", ""); - - clutter_actor_set_reactive (button, TRUE); - - update_toggle_text (CLUTTER_TEXT (button), *toggle_val); - - clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0); - clutter_actor_add_child (group, label); - clutter_actor_add_child (group, button); - - g_signal_connect (button, "button-press-event", G_CALLBACK (on_toggle_click), - toggle_val); - - return group; -} - -G_MODULE_EXPORT int -test_cogl_tex_polygon_main (int argc, char *argv[]) -{ - ClutterActor *stage; - TestCoglbox *coglbox; - ClutterActor *filtering_toggle; - ClutterActor *slicing_toggle; - ClutterActor *note; - ClutterTimeline *timeline; - CoglColor blue = { 0x30, 0x30, 0xff, 0xff }; - - clutter_test_init (&argc, &argv); - - /* Stage */ - stage = clutter_test_get_stage (); - clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &blue); - clutter_actor_set_size (stage, 640, 480); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Polygon"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); - - /* Cogl Box */ - coglbox = TEST_COGLBOX (test_coglbox_new ()); - clutter_actor_add_child (stage, CLUTTER_ACTOR (coglbox)); - - /* Timeline for animation */ - timeline = clutter_timeline_new_for_actor (stage, 6000); - clutter_timeline_set_repeat_count (timeline, -1); - g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); - clutter_timeline_start (timeline); - - /* Labels for toggling settings */ - slicing_toggle = make_toggle ("Texture slicing: ", &coglbox->use_sliced); - clutter_actor_set_position (slicing_toggle, 0, - clutter_actor_get_height (stage) - - clutter_actor_get_height (slicing_toggle)); - filtering_toggle = make_toggle ("Linear filtering: ", - &coglbox->use_linear_filtering); - clutter_actor_set_position (filtering_toggle, 0, - clutter_actor_get_y (slicing_toggle) - - clutter_actor_get_height (filtering_toggle)); - note = clutter_text_new_with_text ("Sans 10", "<- Click to change"); - clutter_actor_set_position (note, - clutter_actor_get_width (filtering_toggle) + 10, - (clutter_actor_get_height (stage) - + clutter_actor_get_y (filtering_toggle)) / 2 - - clutter_actor_get_height (note) / 2); - - clutter_actor_add_child (stage, slicing_toggle); - clutter_actor_add_child (stage, filtering_toggle); - clutter_actor_add_child (stage, note); - - clutter_actor_show (stage); - - clutter_test_main (); - - return 0; -} - -G_MODULE_EXPORT const char * -test_cogl_tex_polygon_describe (void) -{ - return "Texture polygon primitive."; -} diff --git a/src/tests/cogl/conform/test-primitive-and-journal.c b/src/tests/cogl/conform/test-primitive-and-journal.c index 767a8313e9a..dc563a45ee7 100644 --- a/src/tests/cogl/conform/test-primitive-and-journal.c +++ b/src/tests/cogl/conform/test-primitive-and-journal.c @@ -47,7 +47,10 @@ create_primitives (CoglPrimitive *primitives[2]) vertex_data); cogl_primitive_set_n_vertices (primitives[0], 4); - primitives[1] = cogl_primitive_copy (primitives[0]); + primitives[1] = cogl_primitive_new_p2c4 (test_ctx, + COGL_VERTICES_MODE_TRIANGLE_STRIP, + G_N_ELEMENTS (vertex_data), + vertex_data); cogl_primitive_set_first_vertex (primitives[1], 4); cogl_primitive_set_n_vertices (primitives[1], 4); } diff --git a/src/tests/cogl/conform/test-primitive.c b/src/tests/cogl/conform/test-primitive.c index 0a0c1beb5cb..a034c82fff8 100644 --- a/src/tests/cogl/conform/test-primitive.c +++ b/src/tests/cogl/conform/test-primitive.c @@ -57,22 +57,6 @@ test_prim_p2c4 (CoglContext *ctx, uint32_t *expected_color) verts); } -static CoglPrimitive * -test_prim_p3c4 (CoglContext *ctx, uint32_t *expected_color) -{ - static const CoglVertexP3C4 verts[] = - { { 0, 0, 0, 255, 255, 0, 255 }, - { 0, 10, 0, 255, 255, 0, 255 }, - { 10, 0, 0, 255, 255, 0, 255 } }; - - *expected_color = 0xffff00ff; - - return cogl_primitive_new_p3c4 (test_ctx, - COGL_VERTICES_MODE_TRIANGLES, - 3, /* n_vertices */ - verts); -} - static CoglPrimitive * test_prim_p2t2 (CoglContext *ctx, uint32_t *expected_color) { @@ -105,51 +89,14 @@ test_prim_p3t2 (CoglContext *ctx, uint32_t *expected_color) verts); } -static CoglPrimitive * -test_prim_p2t2c4 (CoglContext *ctx, uint32_t *expected_color) -{ - static const CoglVertexP2T2C4 verts[] = - { { 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff }, - { 0, 10, 1, 0, 0xff, 0xff, 0xf0, 0xff }, - { 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } }; - - /* The blue component of the texture color should be replaced with 0xf0 */ - *expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000; - - return cogl_primitive_new_p2t2c4 (test_ctx, - COGL_VERTICES_MODE_TRIANGLES, - 3, /* n_vertices */ - verts); -} - -static CoglPrimitive * -test_prim_p3t2c4 (CoglContext *ctx, uint32_t *expected_color) -{ - static const CoglVertexP3T2C4 verts[] = - { { 0, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff }, - { 0, 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff }, - { 10, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } }; - - /* The blue component of the texture color should be replaced with 0xf0 */ - *expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000; - - return cogl_primitive_new_p3t2c4 (test_ctx, - COGL_VERTICES_MODE_TRIANGLES, - 3, /* n_vertices */ - verts); -} - static const TestPrimFunc test_prim_funcs[] = { test_prim_p2, test_prim_p3, test_prim_p2c4, - test_prim_p3c4, test_prim_p2t2, test_prim_p3t2, - test_prim_p2t2c4, - test_prim_p3t2c4 }; static void @@ -207,112 +154,6 @@ test_paint (TestState *state) g_object_unref (pipeline); } -static gboolean -get_attributes_cb (CoglPrimitive *prim, - CoglAttribute *attrib, - void *user_data) -{ - CoglAttribute ***p = user_data; - *((* p)++) = attrib; - return TRUE; -} - -static int -compare_pointers (const void *a, const void *b) -{ - CoglAttribute *pa = *(CoglAttribute **) a; - CoglAttribute *pb = *(CoglAttribute **) b; - - if (pa < pb) - return -1; - else if (pa > pb) - return 1; - else - return 0; -} - -static void -test_copy (TestState *state) -{ - static const uint16_t indices_data[2] = { 1, 2 }; - CoglAttributeBuffer *buffer = - cogl_attribute_buffer_new (test_ctx, 100, NULL); - CoglAttribute *attributes[N_ATTRIBS]; - CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS]; - CoglAttribute **p; - CoglPrimitive *prim_a, *prim_b; - CoglIndices *indices; - int i; - - for (i = 0; i < N_ATTRIBS; i++) - { - char *name = g_strdup_printf ("foo_%i", i); - attributes[i] = cogl_attribute_new (buffer, - name, - 16, /* stride */ - 16, /* offset */ - 2, /* components */ - COGL_ATTRIBUTE_TYPE_FLOAT); - g_free (name); - } - - prim_a = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES, - 8, /* n_vertices */ - attributes, - N_ATTRIBS); - - indices = cogl_indices_new (test_ctx, - COGL_INDICES_TYPE_UNSIGNED_SHORT, - indices_data, - 2 /* n_indices */); - - cogl_primitive_set_first_vertex (prim_a, 12); - cogl_primitive_set_indices (prim_a, indices, 2); - - prim_b = cogl_primitive_copy (prim_a); - - p = attributes_a; - cogl_primitive_foreach_attribute (prim_a, - get_attributes_cb, - &p); - g_assert_cmpint (p - attributes_a, ==, N_ATTRIBS); - - p = attributes_b; - cogl_primitive_foreach_attribute (prim_b, - get_attributes_cb, - &p); - g_assert_cmpint (p - attributes_b, ==, N_ATTRIBS); - - qsort (attributes_a, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers); - qsort (attributes_b, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers); - - g_assert (memcmp (attributes_a, attributes_b, sizeof (attributes_a)) == 0); - - g_assert_cmpint (cogl_primitive_get_first_vertex (prim_a), - ==, - cogl_primitive_get_first_vertex (prim_b)); - - g_assert_cmpint (cogl_primitive_get_n_vertices (prim_a), - ==, - cogl_primitive_get_n_vertices (prim_b)); - - g_assert_cmpint (cogl_primitive_get_mode (prim_a), - ==, - cogl_primitive_get_mode (prim_b)); - - g_assert (cogl_primitive_get_indices (prim_a) == - cogl_primitive_get_indices (prim_b)); - - g_object_unref (prim_a); - g_object_unref (prim_b); - g_object_unref (indices); - - for (i = 0; i < N_ATTRIBS; i++) - g_object_unref (attributes[i]); - - g_object_unref (buffer); -} - static void test_primitive (void) { @@ -329,7 +170,6 @@ test_primitive (void) 100); test_paint (&state); - test_copy (&state); if (cogl_test_verbose ()) g_print ("OK\n"); -- GitLab From 7eadc948aef835baf3100b5a7d48fe14f9977168 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 26 Jul 2024 22:35:39 +0200 Subject: [PATCH 02/27] cogl: Inline various utilities Part-of: --- cogl/cogl/cogl-clip-stack.c | 53 ++++++- cogl/cogl/cogl-texture.c | 6 + cogl/cogl/cogl-util.c | 167 --------------------- cogl/cogl/cogl-util.h | 46 +----- cogl/cogl/cogl.c | 41 ----- cogl/cogl/meson.build | 1 - cogl/cogl/winsys/cogl-texture-pixmap-x11.c | 129 ++++++++++++++++ 7 files changed, 188 insertions(+), 255 deletions(-) delete mode 100644 cogl/cogl/cogl-util.c diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c index 96f7514de97..7be177ee9c2 100644 --- a/cogl/cogl/cogl-clip-stack.c +++ b/cogl/cogl/cogl-clip-stack.c @@ -38,6 +38,7 @@ #include "cogl/cogl-clip-stack.h" #include "cogl/cogl-context-private.h" #include "cogl/cogl-framebuffer-private.h" +#include "cogl/cogl-graphene.h" #include "cogl/cogl-journal-private.h" #include "cogl/cogl-util.h" #include "cogl/cogl-primitives-private.h" @@ -97,6 +98,46 @@ _cogl_clip_stack_entry_set_bounds (CoglClipStack *entry, entry->bounds_y1 = (int) ceilf (max_y); } +/* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) + * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with + * (0,0) being top left. */ +#define VIEWPORT_TRANSFORM_X(x, vp_origin_x, vp_width) \ + ( ( ((x) + 1.0f) * ((vp_width) / 2.0f) ) + (vp_origin_x) ) +/* Note: for Y we first flip all coordinates around the X axis while in + * normalized device coordinates */ +#define VIEWPORT_TRANSFORM_Y(y, vp_origin_y, vp_height) \ + ( ( ((-(y)) + 1.0f) * ((vp_height) / 2.0f) ) + (vp_origin_y) ) + +/* Transform a homogeneous vertex position from model space to Cogl + * window coordinates (with 0,0 being top left) */ +void +_cogl_transform_point (const graphene_matrix_t *matrix_mv, + const graphene_matrix_t *matrix_p, + const float *viewport, + float *x, + float *y) +{ + float z = 0; + float w = 1; + + /* Apply the modelview matrix transform */ + cogl_graphene_matrix_project_point (matrix_mv, x, y, &z, &w); + + /* Apply the projection matrix transform */ + cogl_graphene_matrix_project_point (matrix_p, x, y, &z, &w); + + /* Perform perspective division */ + *x /= w; + *y /= w; + + /* Apply viewport transform */ + *x = VIEWPORT_TRANSFORM_X (*x, viewport[0], viewport[2]); + *y = VIEWPORT_TRANSFORM_Y (*y, viewport[1], viewport[3]); +} + +#undef VIEWPORT_TRANSFORM_X +#undef VIEWPORT_TRANSFORM_Y + CoglClipStack * _cogl_clip_stack_push_rectangle (CoglClipStack *stack, float x_1, @@ -304,14 +345,10 @@ _cogl_clip_stack_get_bounds (CoglClipStack *stack, { /* Get the intersection of the current scissor and the bounding box of this clip */ - _cogl_util_scissor_intersect (entry->bounds_x0, - entry->bounds_y0, - entry->bounds_x1, - entry->bounds_y1, - scissor_x0, - scissor_y0, - scissor_x1, - scissor_y1); + *scissor_x0 = MAX (*scissor_x0, entry->bounds_x0); + *scissor_y0 = MAX (*scissor_y0, entry->bounds_y0); + *scissor_x1 = MIN (*scissor_x1, entry->bounds_x1); + *scissor_y1 = MIN (*scissor_y1, entry->bounds_y1); } } diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index b03f90cd66b..773789dd0f1 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -264,6 +264,12 @@ cogl_texture_get_format (CoglTexture *texture) return COGL_TEXTURE_GET_CLASS (texture)->get_format (texture); } +static inline unsigned int +_cogl_util_fls (unsigned int n) +{ + return n == 0 ? 0 : sizeof (unsigned int) * 8 - __builtin_clz (n); +} + int _cogl_texture_get_n_levels (CoglTexture *texture) { diff --git a/cogl/cogl/cogl-util.c b/cogl/cogl/cogl-util.c deleted file mode 100644 index 4dffa822d95..00000000000 --- a/cogl/cogl/cogl-util.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2007,2008,2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - */ - -#include "config.h" - -#include - -#include "cogl/cogl-util.h" -#include "cogl/cogl-private.h" - -unsigned int -_cogl_util_one_at_a_time_mix (unsigned int hash) -{ - hash += ( hash << 3 ); - hash ^= ( hash >> 11 ); - hash += ( hash << 15 ); - - return hash; -} - -/* Given a set of red, green and blue component masks, a depth and - * bits per pixel this function tries to determine a corresponding - * CoglPixelFormat. - * - * The depth is measured in bits not including padding for un-used - * alpha. The bits per pixel (bpp) does include padding for un-used - * alpha. - * - * This function firstly aims to match formats with RGB ordered - * components and only considers alpha coming first, in the most - * significant bits. If the function fails to match then it recurses - * by either switching the r and b masks around to check for BGR - * ordered formats or it recurses with the masks shifted to check for - * formats where the alpha component is the least significant bits. - */ -static CoglPixelFormat -_cogl_util_pixel_format_from_masks_real (unsigned long r_mask, - unsigned long g_mask, - unsigned long b_mask, - int depth, int bpp, - gboolean check_bgr, - gboolean check_afirst, - int recursion_depth) -{ - CoglPixelFormat image_format; - - if (depth == 24 && bpp == 24 && - r_mask == 0xff0000 && g_mask == 0xff00 && b_mask == 0xff) - { - return COGL_PIXEL_FORMAT_RGB_888; - } - else if ((depth == 24 || depth == 32) && bpp == 32 && - r_mask == 0xff0000 && g_mask == 0xff00 && b_mask == 0xff) - { - return COGL_PIXEL_FORMAT_ARGB_8888_PRE; - } - else if ((depth == 30 || depth == 32) && - r_mask == 0x3ff00000 && g_mask == 0xffc00 && b_mask == 0x3ff) - { - return COGL_PIXEL_FORMAT_ARGB_2101010_PRE; - } - else if (depth == 16 && bpp == 16 && - r_mask == 0xf800 && g_mask == 0x7e0 && b_mask == 0x1f) - { - return COGL_PIXEL_FORMAT_RGB_565; - } - - if (recursion_depth == 2) - return 0; - - /* Check for BGR ordering if we didn't find a match */ - if (check_bgr) - { - image_format = - _cogl_util_pixel_format_from_masks_real (b_mask, g_mask, r_mask, - depth, bpp, - FALSE, - TRUE, - recursion_depth + 1); - if (image_format) - return image_format ^ COGL_BGR_BIT; - } - - /* Check for alpha in the least significant bits if we still - * haven't found a match... */ - if (check_afirst && depth != bpp) - { - int shift = bpp - depth; - - image_format = - _cogl_util_pixel_format_from_masks_real (r_mask >> shift, - g_mask >> shift, - b_mask >> shift, - depth, bpp, - TRUE, - FALSE, - recursion_depth + 1); - if (image_format) - return image_format ^ COGL_AFIRST_BIT; - } - - return 0; -} - -CoglPixelFormat -_cogl_util_pixel_format_from_masks (unsigned long r_mask, - unsigned long g_mask, - unsigned long b_mask, - int depth, int bpp, - gboolean byte_order_is_lsb_first) -{ - CoglPixelFormat image_format = - _cogl_util_pixel_format_from_masks_real (r_mask, g_mask, b_mask, - depth, bpp, - TRUE, - TRUE, - 0); - - if (!image_format) - { - const char *byte_order[] = { "MSB first", "LSB first" }; - g_warning ("Could not find a matching pixel format for red mask=0x%lx," - "green mask=0x%lx, blue mask=0x%lx at depth=%d, bpp=%d " - "and byte order=%s\n", r_mask, g_mask, b_mask, depth, bpp, - byte_order[!!byte_order_is_lsb_first]); - return 0; - } - - /* If the image is in little-endian then the order in memory is - reversed */ - if (byte_order_is_lsb_first && - _cogl_pixel_format_is_endian_dependant (image_format)) - { - image_format ^= COGL_BGR_BIT; - if (image_format & COGL_A_BIT) - image_format ^= COGL_AFIRST_BIT; - } - - return image_format; -} diff --git a/cogl/cogl/cogl-util.h b/cogl/cogl/cogl-util.h index a32ce311a17..04cd23ae4ef 100644 --- a/cogl/cogl/cogl-util.h +++ b/cogl/cogl/cogl-util.h @@ -71,46 +71,16 @@ _cogl_util_one_at_a_time_hash (unsigned int hash, return hash; } -unsigned int -_cogl_util_one_at_a_time_mix (unsigned int hash); - - -#define _cogl_util_ffsl __builtin_ffsl - static inline unsigned int -_cogl_util_fls (unsigned int n) +_cogl_util_one_at_a_time_mix (unsigned int hash) { - return n == 0 ? 0 : sizeof (unsigned int) * 8 - __builtin_clz (n); -} + hash += ( hash << 3 ); + hash ^= ( hash >> 11 ); + hash += ( hash << 15 ); -#define _cogl_util_popcountl __builtin_popcountl + return hash; +} -/* Match a CoglPixelFormat according to channel masks, color depth, - * bits per pixel and byte order. These information are provided by - * the Visual and XImage structures. - * - * If no specific pixel format could be found, COGL_PIXEL_FORMAT_ANY - * is returned. - */ -CoglPixelFormat -_cogl_util_pixel_format_from_masks (unsigned long r_mask, - unsigned long g_mask, - unsigned long b_mask, - int depth, int bpp, - int byte_order); +#define _cogl_util_ffsl __builtin_ffsl -static inline void -_cogl_util_scissor_intersect (int rect_x0, - int rect_y0, - int rect_x1, - int rect_y1, - int *scissor_x0, - int *scissor_y0, - int *scissor_x1, - int *scissor_y1) -{ - *scissor_x0 = MAX (*scissor_x0, rect_x0); - *scissor_y0 = MAX (*scissor_y0, rect_y0); - *scissor_x1 = MIN (*scissor_x1, rect_x1); - *scissor_y1 = MIN (*scissor_y1, rect_y1); -} +#define _cogl_util_popcountl __builtin_popcountl diff --git a/cogl/cogl/cogl.c b/cogl/cogl/cogl.c index ffe0251a271..b6cfe0ec542 100644 --- a/cogl/cogl/cogl.c +++ b/cogl/cogl/cogl.c @@ -36,7 +36,6 @@ #include "cogl/cogl-cpu-caps.h" #include "cogl/cogl-debug.h" -#include "cogl/cogl-graphene.h" #include "cogl/cogl-util.h" #include "cogl/cogl-context-private.h" #include "cogl/cogl-pipeline-private.h" @@ -71,46 +70,6 @@ _cogl_driver_error_quark (void) return g_quark_from_static_string ("cogl-driver-error-quark"); } -/* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) - * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with - * (0,0) being top left. */ -#define VIEWPORT_TRANSFORM_X(x, vp_origin_x, vp_width) \ - ( ( ((x) + 1.0f) * ((vp_width) / 2.0f) ) + (vp_origin_x) ) -/* Note: for Y we first flip all coordinates around the X axis while in - * normalized device coordinates */ -#define VIEWPORT_TRANSFORM_Y(y, vp_origin_y, vp_height) \ - ( ( ((-(y)) + 1.0f) * ((vp_height) / 2.0f) ) + (vp_origin_y) ) - -/* Transform a homogeneous vertex position from model space to Cogl - * window coordinates (with 0,0 being top left) */ -void -_cogl_transform_point (const graphene_matrix_t *matrix_mv, - const graphene_matrix_t *matrix_p, - const float *viewport, - float *x, - float *y) -{ - float z = 0; - float w = 1; - - /* Apply the modelview matrix transform */ - cogl_graphene_matrix_project_point (matrix_mv, x, y, &z, &w); - - /* Apply the projection matrix transform */ - cogl_graphene_matrix_project_point (matrix_p, x, y, &z, &w); - - /* Perform perspective division */ - *x /= w; - *y /= w; - - /* Apply viewport transform */ - *x = VIEWPORT_TRANSFORM_X (*x, viewport[0], viewport[2]); - *y = VIEWPORT_TRANSFORM_Y (*y, viewport[1], viewport[3]); -} - -#undef VIEWPORT_TRANSFORM_X -#undef VIEWPORT_TRANSFORM_Y - uint32_t _cogl_system_error_quark (void) { diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 3d80d4f18ee..e52a7fb8b23 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -273,7 +273,6 @@ cogl_sources = [ 'cogl-texture-private.h', 'cogl-texture.c', 'cogl-trace.c', - 'cogl-util.c', 'cogl-util.h', 'cogl.c', 'deprecated/cogl-program-private.h', diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index 9be2778e4c0..75c809bf054 100644 --- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -413,6 +413,135 @@ try_alloc_shm (CoglTexturePixmapX11 *tex_pixmap) tex_pixmap->shm_info.shmid = -1; } +/* Given a set of red, green and blue component masks, a depth and + * bits per pixel this function tries to determine a corresponding + * CoglPixelFormat. + * + * The depth is measured in bits not including padding for un-used + * alpha. The bits per pixel (bpp) does include padding for un-used + * alpha. + * + * This function firstly aims to match formats with RGB ordered + * components and only considers alpha coming first, in the most + * significant bits. If the function fails to match then it recurses + * by either switching the r and b masks around to check for BGR + * ordered formats or it recurses with the masks shifted to check for + * formats where the alpha component is the least significant bits. + */ +static CoglPixelFormat +_cogl_util_pixel_format_from_masks_real (unsigned long r_mask, + unsigned long g_mask, + unsigned long b_mask, + int depth, int bpp, + gboolean check_bgr, + gboolean check_afirst, + int recursion_depth) +{ + CoglPixelFormat image_format; + + if (depth == 24 && bpp == 24 && + r_mask == 0xff0000 && g_mask == 0xff00 && b_mask == 0xff) + { + return COGL_PIXEL_FORMAT_RGB_888; + } + else if ((depth == 24 || depth == 32) && bpp == 32 && + r_mask == 0xff0000 && g_mask == 0xff00 && b_mask == 0xff) + { + return COGL_PIXEL_FORMAT_ARGB_8888_PRE; + } + else if ((depth == 30 || depth == 32) && + r_mask == 0x3ff00000 && g_mask == 0xffc00 && b_mask == 0x3ff) + { + return COGL_PIXEL_FORMAT_ARGB_2101010_PRE; + } + else if (depth == 16 && bpp == 16 && + r_mask == 0xf800 && g_mask == 0x7e0 && b_mask == 0x1f) + { + return COGL_PIXEL_FORMAT_RGB_565; + } + + if (recursion_depth == 2) + return 0; + + /* Check for BGR ordering if we didn't find a match */ + if (check_bgr) + { + image_format = + _cogl_util_pixel_format_from_masks_real (b_mask, g_mask, r_mask, + depth, bpp, + FALSE, + TRUE, + recursion_depth + 1); + if (image_format) + return image_format ^ COGL_BGR_BIT; + } + + /* Check for alpha in the least significant bits if we still + * haven't found a match... */ + if (check_afirst && depth != bpp) + { + int shift = bpp - depth; + + image_format = + _cogl_util_pixel_format_from_masks_real (r_mask >> shift, + g_mask >> shift, + b_mask >> shift, + depth, bpp, + TRUE, + FALSE, + recursion_depth + 1); + if (image_format) + return image_format ^ COGL_AFIRST_BIT; + } + + return 0; +} + + +/* Match a CoglPixelFormat according to channel masks, color depth, + * bits per pixel and byte order. These information are provided by + * the Visual and XImage structures. + * + * If no specific pixel format could be found, COGL_PIXEL_FORMAT_ANY + * is returned. + */ +static CoglPixelFormat +_cogl_util_pixel_format_from_masks (unsigned long r_mask, + unsigned long g_mask, + unsigned long b_mask, + int depth, int bpp, + gboolean byte_order_is_lsb_first) +{ + CoglPixelFormat image_format = + _cogl_util_pixel_format_from_masks_real (r_mask, g_mask, b_mask, + depth, bpp, + TRUE, + TRUE, + 0); + + if (!image_format) + { + const char *byte_order[] = { "MSB first", "LSB first" }; + g_warning ("Could not find a matching pixel format for red mask=0x%lx," + "green mask=0x%lx, blue mask=0x%lx at depth=%d, bpp=%d " + "and byte order=%s\n", r_mask, g_mask, b_mask, depth, bpp, + byte_order[!!byte_order_is_lsb_first]); + return 0; + } + + /* If the image is in little-endian then the order in memory is + reversed */ + if (byte_order_is_lsb_first && + _cogl_pixel_format_is_endian_dependant (image_format)) + { + image_format ^= COGL_BGR_BIT; + if (image_format & COGL_A_BIT) + image_format ^= COGL_AFIRST_BIT; + } + + return image_format; +} + static void _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap) { -- GitLab From 5fde5abd3e29368a072f5cab65a61e0bc2c00c49 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 26 Jul 2024 22:41:46 +0200 Subject: [PATCH 03/27] cogl: Remove unnecessary compiler functions defines Part-of: --- cogl/cogl/cogl-bitmask.c | 6 +++--- cogl/cogl/cogl-bitmask.h | 8 ++++---- cogl/cogl/cogl-flags.h | 2 +- cogl/cogl/cogl-util.h | 4 ---- cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c | 2 +- cogl/cogl/winsys/cogl-winsys-glx.c | 6 +++--- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cogl/cogl/cogl-bitmask.c b/cogl/cogl/cogl-bitmask.c index 0bb7d455570..e5cc0bfce3a 100644 --- a/cogl/cogl/cogl-bitmask.c +++ b/cogl/cogl/cogl-bitmask.c @@ -285,7 +285,7 @@ _cogl_bitmask_popcount_in_array (const CoglBitmask *bitmask) int i; for (i = 0; i < array->len; i++) - pop += _cogl_util_popcountl (g_array_index (array, unsigned long, i)); + pop += __builtin_popcountl (g_array_index (array, unsigned long, i)); return pop; } @@ -307,10 +307,10 @@ _cogl_bitmask_popcount_upto_in_array (const CoglBitmask *bitmask, int i; for (i = 0; i < array_index; i++) - pop += _cogl_util_popcountl (g_array_index (array, unsigned long, i)); + pop += __builtin_popcountl (g_array_index (array, unsigned long, i)); top_mask = g_array_index (array, unsigned long, array_index); - return pop + _cogl_util_popcountl (top_mask & ((1UL << bit_index) - 1)); + return pop + __builtin_popcountl (top_mask & ((1UL << bit_index) - 1)); } } diff --git a/cogl/cogl/cogl-bitmask.h b/cogl/cogl/cogl-bitmask.h index a73e68e4d05..1f18b8fbb24 100644 --- a/cogl/cogl/cogl-bitmask.h +++ b/cogl/cogl/cogl-bitmask.h @@ -281,7 +281,7 @@ _cogl_bitmask_popcount (const CoglBitmask *bitmask) { return (_cogl_bitmask_has_array (bitmask) ? _cogl_bitmask_popcount_in_array (bitmask) : - _cogl_util_popcountl (_cogl_bitmask_to_bits (bitmask))); + __builtin_popcountl (_cogl_bitmask_to_bits (bitmask))); } /* @@ -301,10 +301,10 @@ _cogl_bitmask_popcount_upto (const CoglBitmask *bitmask, if (_cogl_bitmask_has_array (bitmask)) return _cogl_bitmask_popcount_upto_in_array (bitmask, upto); else if (upto >= (int) COGL_BITMASK_MAX_DIRECT_BITS) - return _cogl_util_popcountl (_cogl_bitmask_to_bits (bitmask)); + return __builtin_popcountl (_cogl_bitmask_to_bits (bitmask)); else - return _cogl_util_popcountl (_cogl_bitmask_to_bits (bitmask) & - ((1UL << upto) - 1)); + return __builtin_popcountl (_cogl_bitmask_to_bits (bitmask) & + ((1UL << upto) - 1)); } G_END_DECLS diff --git a/cogl/cogl/cogl-flags.h b/cogl/cogl/cogl-flags.h index 6e91e4781dd..4020cb27a57 100644 --- a/cogl/cogl/cogl-flags.h +++ b/cogl/cogl/cogl-flags.h @@ -111,7 +111,7 @@ G_BEGIN_DECLS \ while (_mask) \ { \ - int _next_bit = _cogl_util_ffsl (_mask); \ + int _next_bit = __builtin_ffsl (_mask); \ (bit) += _next_bit; \ /* This odd two-part shift is to avoid */ \ /* shifting by sizeof (long)*8 which has */ \ diff --git a/cogl/cogl/cogl-util.h b/cogl/cogl/cogl-util.h index 04cd23ae4ef..040c78afa01 100644 --- a/cogl/cogl/cogl-util.h +++ b/cogl/cogl/cogl-util.h @@ -80,7 +80,3 @@ _cogl_util_one_at_a_time_mix (unsigned int hash) return hash; } - -#define _cogl_util_ffsl __builtin_ffsl - -#define _cogl_util_popcountl __builtin_popcountl diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index 9532b604ab3..93d7c308d32 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -621,7 +621,7 @@ _cogl_pipeline_progend_glsl_flush_uniforms (CoglPipeline *pipeline, for (i = 0; i < n_uniform_longs; i++) data.n_differences += - _cogl_util_popcountl (data.uniform_differences[i]); + __builtin_popcountl (data.uniform_differences[i]); } while (pipeline && data.n_differences > 0) diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 166a0380808..9a7da34e4f0 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -1067,9 +1067,9 @@ try_create_glx_pixmap (CoglContext *context, * number of 1-bits in color masks against the color depth requested * by the client. */ - if (_cogl_util_popcountl (visual->red_mask | - visual->green_mask | - visual->blue_mask) == depth) + if (__builtin_popcountl (visual->red_mask | + visual->green_mask | + visual->blue_mask) == depth) attribs[i++] = GLX_TEXTURE_FORMAT_RGB_EXT; else attribs[i++] = GLX_TEXTURE_FORMAT_RGBA_EXT; -- GitLab From a107cae9761825fbf8b31954a98aae14d4f41fce Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 26 Jul 2024 22:53:47 +0200 Subject: [PATCH 04/27] cogl/atlas: Remove unused private function Part-of: --- cogl/cogl/cogl-atlas-private.h | 7 ------- cogl/cogl/cogl-atlas.c | 26 -------------------------- 2 files changed, 33 deletions(-) diff --git a/cogl/cogl/cogl-atlas-private.h b/cogl/cogl/cogl-atlas-private.h index dc3c4f940af..2804126a2fe 100644 --- a/cogl/cogl/cogl-atlas-private.h +++ b/cogl/cogl/cogl-atlas-private.h @@ -59,10 +59,3 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas, int width, int height, CoglPixelFormat format); - - -void -_cogl_atlas_remove_reorganize_callback (CoglAtlas *atlas, - GHookFunc pre_callback, - GHookFunc post_callback, - void *user_data); diff --git a/cogl/cogl/cogl-atlas.c b/cogl/cogl/cogl-atlas.c index 8e5c8b13a35..1f0d4c44b3c 100644 --- a/cogl/cogl/cogl-atlas.c +++ b/cogl/cogl/cogl-atlas.c @@ -669,29 +669,3 @@ cogl_atlas_add_reorganize_callback (CoglAtlas *atlas, g_hook_prepend (&atlas->post_reorganize_callbacks, hook); } } - -void -_cogl_atlas_remove_reorganize_callback (CoglAtlas *atlas, - GHookFunc pre_callback, - GHookFunc post_callback, - void *user_data) -{ - if (pre_callback) - { - GHook *hook = g_hook_find_func_data (&atlas->pre_reorganize_callbacks, - FALSE, - pre_callback, - user_data); - if (hook) - g_hook_destroy_link (&atlas->pre_reorganize_callbacks, hook); - } - if (post_callback) - { - GHook *hook = g_hook_find_func_data (&atlas->post_reorganize_callbacks, - FALSE, - post_callback, - user_data); - if (hook) - g_hook_destroy_link (&atlas->post_reorganize_callbacks, hook); - } -} -- GitLab From 0f405e9270cb4a411335c04deb9868d3f740ae80 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 00:21:06 +0200 Subject: [PATCH 05/27] Rename remaining usages of material to pipeline material is almost no longer used in the code base and the few remaining references makes it confusing when looking at parts of the codebase. So rename the rest as well. Note that this renames a DeformEffect property and the only extension making use of it doesn't use the property so i think it is okay to do so without deprecating the old property for a few releases Part-of: --- clutter/clutter/clutter-deform-effect.c | 42 +++++++++---------- clutter/clutter/clutter-deform-effect.h | 6 +-- clutter/clutter/clutter-effect.c | 12 +++--- clutter/clutter/clutter-offscreen-effect.c | 6 +-- cogl/cogl-pango/cogl-pango-pipeline-cache.c | 2 +- cogl/cogl/cogl-attribute.c | 2 +- cogl/cogl/cogl-context.h | 2 +- cogl/cogl/cogl-framebuffer.h | 2 +- cogl/cogl/cogl-pipeline-private.h | 8 ++-- cogl/cogl/cogl-point-in-poly.c | 1 - cogl/cogl/cogl-primitives.c | 4 +- cogl/cogl/cogl-types.h | 4 +- cogl/cogl/deprecated/cogl-program.c | 4 +- cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 6 +-- .../interactive/test-cogl-multitexture.c | 4 +- 15 files changed, 51 insertions(+), 54 deletions(-) diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index e3edf576553..a88b27cf42f 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -106,7 +106,7 @@ enum PROP_X_TILES, PROP_Y_TILES, - PROP_BACK_MATERIAL, + PROP_BACK_PIPELINE, PROP_LAST }; @@ -298,7 +298,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect, cogl_depth_state_set_test_function (&depth_state, COGL_DEPTH_TEST_FUNCTION_LEQUAL); cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL); - /* enable backface culling if we have a back material */ + /* enable backface culling if we have a back pipeline */ if (priv->back_pipeline != NULL) cogl_pipeline_set_cull_face_mode (pipeline, COGL_PIPELINE_CULL_FACE_MODE_BACK); @@ -322,7 +322,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect, ClutterPaintNode *back_node; CoglPipeline *back_pipeline; - /* We probably shouldn't be modifying the user's material so + /* We probably shouldn't be modifying the user's pipeline so instead we make a temporary copy */ back_pipeline = cogl_pipeline_copy (priv->back_pipeline); cogl_pipeline_set_depth_state (back_pipeline, &depth_state, NULL); @@ -548,8 +548,8 @@ clutter_deform_effect_set_property (GObject *gobject, g_value_get_uint (value)); break; - case PROP_BACK_MATERIAL: - clutter_deform_effect_set_back_material (self, g_value_get_object (value)); + case PROP_BACK_PIPELINE: + clutter_deform_effect_set_back_pipeline (self, g_value_get_object (value)); break; default: @@ -578,7 +578,7 @@ clutter_deform_effect_get_property (GObject *gobject, g_value_set_uint (value, priv->y_tiles); break; - case PROP_BACK_MATERIAL: + case PROP_BACK_PIPELINE: g_value_set_object (value, priv->back_pipeline); break; @@ -624,15 +624,15 @@ clutter_deform_effect_class_init (ClutterDeformEffectClass *klass) G_PARAM_STATIC_STRINGS); /** - * ClutterDeformEffect:back-material: + * ClutterDeformEffect:back-pipeline: * - * A material to be used when painting the back of the actor + * A pipeline to be used when painting the back of the actor * to which this effect has been applied * - * By default, no material will be used + * By default, no pipeline will be used */ - obj_props[PROP_BACK_MATERIAL] = - g_param_spec_object ("back-material", NULL, NULL, + obj_props[PROP_BACK_PIPELINE] = + g_param_spec_object ("back-pipeline", NULL, NULL, COGL_TYPE_PIPELINE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); @@ -662,18 +662,18 @@ clutter_deform_effect_init (ClutterDeformEffect *self) } /** - * clutter_deform_effect_set_back_material: + * clutter_deform_effect_set_back_pipeline: * @effect: a #ClutterDeformEffect - * @material: (allow-none): a handle to a Cogl material + * @pipeline: (allow-none): A #CoglPipeline * - * Sets the material that should be used when drawing the back face + * Sets the pipeline that should be used when drawing the back face * of the actor during a deformation * - * The #ClutterDeformEffect will take a reference on the material's + * The #ClutterDeformEffect will take a reference on the pipeline's * handle */ void -clutter_deform_effect_set_back_material (ClutterDeformEffect *effect, +clutter_deform_effect_set_back_pipeline (ClutterDeformEffect *effect, CoglPipeline *pipeline) { ClutterDeformEffectPrivate *priv; @@ -693,17 +693,15 @@ clutter_deform_effect_set_back_material (ClutterDeformEffect *effect, } /** - * clutter_deform_effect_get_back_material: + * clutter_deform_effect_get_back_pipeline: * @effect: a #ClutterDeformEffect * - * Retrieves the handle to the back face material used by @effect + * Retrieves the back pipeline used by @effect * - * Return value: (transfer none): a handle for the material, or %NULL. - * The returned material is owned by the #ClutterDeformEffect and it - * should not be freed directly + * Return value: (transfer none) (nullable): A #CoglPipeline. */ CoglPipeline* -clutter_deform_effect_get_back_material (ClutterDeformEffect *effect) +clutter_deform_effect_get_back_pipeline (ClutterDeformEffect *effect) { ClutterDeformEffectPrivate *priv; diff --git a/clutter/clutter/clutter-deform-effect.h b/clutter/clutter/clutter-deform-effect.h index 0de08e73a23..2fc4c1e113e 100644 --- a/clutter/clutter/clutter-deform-effect.h +++ b/clutter/clutter/clutter-deform-effect.h @@ -88,10 +88,10 @@ struct _ClutterDeformEffectClass }; CLUTTER_EXPORT -void clutter_deform_effect_set_back_material (ClutterDeformEffect *effect, - CoglPipeline *material); +void clutter_deform_effect_set_back_pipeline (ClutterDeformEffect *effect, + CoglPipeline *pipeline); CLUTTER_EXPORT -CoglPipeline* clutter_deform_effect_get_back_material (ClutterDeformEffect *effect); +CoglPipeline* clutter_deform_effect_get_back_pipeline (ClutterDeformEffect *effect); CLUTTER_EXPORT void clutter_deform_effect_set_n_tiles (ClutterDeformEffect *effect, guint x_tiles, diff --git a/clutter/clutter/clutter-effect.c b/clutter/clutter/clutter-effect.c index 29c39a1dc65..e857b7bf8c6 100644 --- a/clutter/clutter/clutter-effect.c +++ b/clutter/clutter/clutter-effect.c @@ -24,7 +24,7 @@ /** * ClutterEffect: - * + * * Base class for actor effects * * The #ClutterEffect class provides a default type and API for creating @@ -75,10 +75,10 @@ * The example below creates two rectangles: one will be painted "behind" the actor, * while another will be painted "on top" of the actor. * - * The #ClutterActorMetaClass.set_actor() implementation will create the two materials + * The #ClutterActorMetaClass.set_actor() implementation will create the two pipelines * used for the two different rectangles; the #ClutterEffectClass.paint() implementation - * will paint the first material using cogl_rectangle(), before continuing and then it - * will paint paint the second material after. + * will paint the first pipeline using cogl_rectangle(), before continuing and then it + * will paint paint the second pipeline after. * * ```c * typedef struct { @@ -119,12 +119,12 @@ * if (self->actor == NULL) * return; * - * // Create a red material + * // Create a red pipeline * self->rect_1 = cogl_pipeline_new (); * cogl_color_init_from_4f (&color, 1.0, 1.0, 1.0, 1.0); * cogl_pipeline_set_color (self->rect_1, &color); * - * // Create a green material + * // Create a green pipeline * self->rect_2 = cogl_pipeline_new (); * cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0); * cogl_pipeline_set_color (self->rect_2, &color); diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c index e8396325105..b2f36297c83 100644 --- a/clutter/clutter/clutter-offscreen-effect.c +++ b/clutter/clutter/clutter-offscreen-effect.c @@ -52,7 +52,7 @@ * function, which encapsulates the effective painting of the texture that * contains the result of the offscreen redirection. * - * The size of the target material is defined to be as big as the + * The size of the target pipeline is defined to be as big as the * transformed size of the [class@Actor] using the offscreen effect. * Sub-classes of #ClutterOffscreenEffect can change the texture creation * code to provide bigger textures by overriding the @@ -486,7 +486,7 @@ clutter_offscreen_effect_paint_texture (ClutterOffscreenEffect *effect, node = transform_node; } - /* paint the target material; this is virtualized for + /* paint the target pipeline; this is virtualized for * sub-classes that require special hand-holding */ clutter_offscreen_effect_paint_target (effect, node, paint_context); @@ -640,7 +640,7 @@ clutter_offscreen_effect_init (ClutterOffscreenEffect *self) * implementation should update any references to the texture after * chaining-up to the parent's pre_paint implementation. This can be * used instead of [method@OffscreenEffect.get_texture] when the - * effect subclass wants to paint using its own material. + * effect subclass wants to paint using its own pipeline. * * Return value: (transfer none): a #CoglTexture or %NULL. The * returned texture is owned by Clutter and it should not be diff --git a/cogl/cogl-pango/cogl-pango-pipeline-cache.c b/cogl/cogl-pango/cogl-pango-pipeline-cache.c index 6d587b9d29c..3d66ee997d2 100644 --- a/cogl/cogl-pango/cogl-pango-pipeline-cache.c +++ b/cogl/cogl-pango/cogl-pango-pipeline-cache.c @@ -134,7 +134,7 @@ get_base_texture_alpha_pipeline (CoglPangoPipelineCache *cache) cogl_pipeline_set_static_name (pipeline, "CoglPango (texture alpha)"); cache->base_texture_alpha_pipeline = pipeline; - /* The default combine mode of materials is to modulate (A x B) + /* The default combine mode of pipelines is to modulate (A x B) * the texture RGBA channels with the RGBA channels of the * previous layer (which in our case is just the font color) * diff --git a/cogl/cogl/cogl-attribute.c b/cogl/cogl/cogl-attribute.c index a6207035049..d886af578f3 100644 --- a/cogl/cogl/cogl-attribute.c +++ b/cogl/cogl/cogl-attribute.c @@ -301,7 +301,7 @@ validate_layer_cb (CoglPipeline *pipeline, if (!_cogl_texture_can_hardware_repeat (texture)) { - g_warning ("Disabling layer %d of the current source material, " + g_warning ("Disabling layer %d of the current source pipeline, " "because texturing with the vertex buffer API is not " "currently supported using sliced textures, or textures " "with waste\n", layer_index); diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index 3ad937df4be..b1099a240c4 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -365,7 +365,7 @@ cogl_context_has_winsys_feature (CoglContext *context, * primitives you are 100% on your own since you stand a good chance of * conflicting with Cogl internals. For example clutter-gst which currently * uses direct GL calls to bind ARBfp programs will very likely break when Cogl - * starts to use ARBfb programs itself for the material API. + * starts to use ARBfb programs itself for the pipeline API. */ COGL_EXPORT void cogl_context_flush (CoglContext *context); diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index 64bf8f4dc03..c2a1e52569a 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -794,7 +794,7 @@ cogl_framebuffer_draw_textured_rectangle (CoglFramebuffer *framebuffer, * * The first pair of coordinates are for the first layer (with the * smallest layer index) and if you supply less texture coordinates - * than there are layers in the current source material then default + * than there are layers in the current source pipeline then default * texture coordinates (0.0, 0.0, 1.0, 1.0) are generated. */ COGL_EXPORT void diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 75428b8f410..4b5e94e9113 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -618,7 +618,7 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func); * * typedef struct { * CoglPipeline *validated_source; - * } MyValidatedMaterialCache; + * } MyValidatedPipelineCache; * * static void * destroy_cache_cb (CoglObject *object, void *user_data) @@ -629,7 +629,7 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func); * static void * invalidate_cache_cb (CoglPipeline *destroyed, void *user_data) * { - * MyValidatedMaterialCache *cache = user_data; + * MyValidatedPipelineCache *cache = user_data; * g_object_unref (cache->validated_source); * cache->validated_source = NULL; * } @@ -638,12 +638,12 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func); * get_validated_pipeline (CoglPipeline *source) * { * _cogl_my_cache_key = g_quark_from_static_string ("my-cache-key"); - * MyValidatedMaterialCache *cache = + * MyValidatedPipelineCache *cache = * g_object_get_qdata (G_OBJECT (source), * _cogl_my_cache_key); * if (G_UNLIKELY (cache == NULL)) * { - * cache = g_new0 (MyValidatedMaterialCache, 1); + * cache = g_new0 (MyValidatedPipelineCache, 1); * * g_object_set_qdata_full (G_OBJECT (source), * _cogl_my_cache_key, diff --git a/cogl/cogl/cogl-point-in-poly.c b/cogl/cogl/cogl-point-in-poly.c index 25ffc2e4291..7ab8f4dc4bd 100644 --- a/cogl/cogl/cogl-point-in-poly.c +++ b/cogl/cogl/cogl-point-in-poly.c @@ -96,4 +96,3 @@ _cogl_util_point_in_screen_poly (float point_x, return c; } - diff --git a/cogl/cogl/cogl-primitives.c b/cogl/cogl/cogl-primitives.c index 214d03416bb..b72159bf760 100644 --- a/cogl/cogl/cogl-primitives.c +++ b/cogl/cogl/cogl-primitives.c @@ -344,7 +344,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline, { static gboolean warning_seen = FALSE; if (!warning_seen) - g_warning ("Skipping layers 1..n of your material since " + g_warning ("Skipping layers 1..n of your pipeline since " "the first layer doesn't support hardware " "repeat (e.g. because of waste or use of " "GL_TEXTURE_RECTANGLE_ARB) and you supplied " @@ -363,7 +363,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline, { static gboolean warning_seen = FALSE; if (!warning_seen) - g_warning ("Skipping layer %d of your material " + g_warning ("Skipping layer %d of your pipeline " "since you have supplied texture coords " "outside the range [0,1] but the texture " "doesn't support hardware repeat (e.g. " diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index 9f090fe272d..a7c295a0acc 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -198,9 +198,9 @@ typedef enum /* NB: The above definitions are taken from gl.h equivalents */ -/* XXX: should this be CoglMaterialDepthTestFunction? +/* XXX: should this be CoglPipelineDepthTestFunction? * It makes it very verbose but would be consistent with - * CoglMaterialWrapMode */ + * CoglPipelineWrapMode */ /** * CoglDepthTestFunction: diff --git a/cogl/cogl/deprecated/cogl-program.c b/cogl/cogl/deprecated/cogl-program.c index de824bb6d08..5d72a8bf7e2 100644 --- a/cogl/cogl/deprecated/cogl-program.c +++ b/cogl/cogl/deprecated/cogl-program.c @@ -81,8 +81,8 @@ cogl_program_class_init (CoglProgramClass *class) /* A CoglProgram is effectively just a list of shaders that will be used together and a set of values for the custom uniforms. No actual GL program is created - instead this is the responsibility - of the GLSL material backend. The uniform values are collected in - an array and then flushed whenever the material backend requests + of the GLSL pipeline backend. The uniform values are collected in + an array and then flushed whenever the pipeline backend requests it. */ CoglProgram* diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 13180ca5cc1..6e78a9a5de8 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -896,8 +896,8 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, COGL_STATIC_TIMER (pipeline_flush_timer, "Mainloop", /* parent */ - "Material Flush", - "The time spent flushing material state", + "Pipeline Flush", + "The time spent flushing pipeline state", 0 /* no application private data */); COGL_TIMER_START (_cogl_uprof_context, pipeline_flush_timer); @@ -1123,7 +1123,7 @@ done: } /* Give the progend a chance to update any uniforms that might not - * depend on the material state. This is used on GLES2 to update the + * depend on the pipeline state. This is used on GLES2 to update the * matrices */ if (progend->pre_paint) progend->pre_paint (pipeline, framebuffer); diff --git a/src/tests/clutter/interactive/test-cogl-multitexture.c b/src/tests/clutter/interactive/test-cogl-multitexture.c index d326e8957c0..8d03f021021 100644 --- a/src/tests/clutter/interactive/test-cogl-multitexture.c +++ b/src/tests/clutter/interactive/test-cogl-multitexture.c @@ -58,7 +58,7 @@ frame_cb (ClutterTimeline *timeline, } static void -material_rectangle_paint (ClutterActor *actor, +pipeline_rectangle_paint (ClutterActor *actor, ClutterPaintContext *paint_context, gpointer data) { @@ -144,7 +144,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) state->group = clutter_actor_new (); clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2); g_signal_connect (state->group, "paint", - G_CALLBACK (material_rectangle_paint), state); + G_CALLBACK (pipeline_rectangle_paint), state); files = g_new (gchar*, 4); files[0] = g_build_filename (TESTS_DATADIR, "redhand_alpha.png", NULL); -- GitLab From e57d3615bc5a402cd4d0917f2704143878a3d7ca Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 09:54:50 +0200 Subject: [PATCH 06/27] cogl/xlib-renderer: Remove [add|remove]_filter They end up calling the Renderer APIs & they are not used outside of Cogl Part-of: --- cogl/cogl/cogl-xlib-renderer.c | 24 ++----------- cogl/cogl/cogl-xlib-renderer.h | 42 ---------------------- cogl/cogl/winsys/cogl-texture-pixmap-x11.c | 12 +++---- cogl/cogl/winsys/cogl-winsys-egl-x11.c | 12 +++---- cogl/cogl/winsys/cogl-winsys-glx.c | 12 +++---- 5 files changed, 21 insertions(+), 81 deletions(-) diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index d84f09ea49d..3e757ebf93f 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -430,9 +430,9 @@ _cogl_xlib_renderer_connect (CoglRenderer *renderer, GError **error) register_xlib_renderer (renderer); - cogl_xlib_renderer_add_filter (renderer, - randr_filter, - renderer); + _cogl_renderer_add_native_filter (renderer, + (CoglNativeFilterFunc)randr_filter, + renderer); return TRUE; } @@ -473,24 +473,6 @@ cogl_xlib_renderer_handle_event (CoglRenderer *renderer, return _cogl_renderer_handle_native_event (renderer, event); } -void -cogl_xlib_renderer_add_filter (CoglRenderer *renderer, - CoglXlibFilterFunc func, - void *data) -{ - _cogl_renderer_add_native_filter (renderer, - (CoglNativeFilterFunc)func, data); -} - -void -cogl_xlib_renderer_remove_filter (CoglRenderer *renderer, - CoglXlibFilterFunc func, - void *data) -{ - _cogl_renderer_remove_native_filter (renderer, - (CoglNativeFilterFunc)func, data); -} - float _cogl_xlib_renderer_refresh_rate_for_rectangle (CoglRenderer *renderer, int x, diff --git a/cogl/cogl/cogl-xlib-renderer.h b/cogl/cogl/cogl-xlib-renderer.h index 5cbc0b36b85..12d18648cef 100644 --- a/cogl/cogl/cogl-xlib-renderer.h +++ b/cogl/cogl/cogl-xlib-renderer.h @@ -54,48 +54,6 @@ COGL_EXPORT CoglFilterReturn cogl_xlib_renderer_handle_event (CoglRenderer *renderer, XEvent *event); -/* - * CoglXlibFilterFunc: - * @event: pointer to an XEvent structure - * @data: the data that was given when the filter was added - * - * A callback function that can be registered with - * cogl_xlib_renderer_add_filter(). The function should return - * %COGL_FILTER_REMOVE if it wants to prevent further processing or - * %COGL_FILTER_CONTINUE otherwise. - */ -typedef CoglFilterReturn (* CoglXlibFilterFunc) (XEvent *event, - void *data); - -/** - * cogl_xlib_renderer_add_filter: (skip) - * @renderer: a #CoglRenderer - * @func: the callback function - * @data: user data passed to @func when called - * - * Adds a callback function that will receive all native events. The - * function can stop further processing of the event by return - * %COGL_FILTER_REMOVE. - */ -COGL_EXPORT void -cogl_xlib_renderer_add_filter (CoglRenderer *renderer, - CoglXlibFilterFunc func, - void *data); - -/** - * cogl_xlib_renderer_remove_filter: (skip) - * @renderer: a #CoglRenderer - * @func: the callback function - * @data: user data given when the callback was installed - * - * Removes a callback that was previously added with - * cogl_xlib_renderer_add_filter(). - */ -COGL_EXPORT void -cogl_xlib_renderer_remove_filter (CoglRenderer *renderer, - CoglXlibFilterFunc func, - void *data); - /** * cogl_xlib_renderer_set_foreign_display: (skip) * @renderer: a #CoglRenderer diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index 75c809bf054..e2234f75770 100644 --- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -223,9 +223,9 @@ set_damage_object_internal (CoglContext *ctx, if (tex_pixmap->damage) { - cogl_xlib_renderer_remove_filter (ctx->display->renderer, - _cogl_texture_pixmap_x11_filter, - tex_pixmap); + _cogl_renderer_remove_native_filter (ctx->display->renderer, + (CoglNativeFilterFunc)_cogl_texture_pixmap_x11_filter, + tex_pixmap); if (tex_pixmap->damage_owned) { @@ -238,9 +238,9 @@ set_damage_object_internal (CoglContext *ctx, tex_pixmap->damage_report_level = report_level; if (damage) - cogl_xlib_renderer_add_filter (ctx->display->renderer, - _cogl_texture_pixmap_x11_filter, - tex_pixmap); + _cogl_renderer_add_native_filter (ctx->display->renderer, + (CoglNativeFilterFunc)_cogl_texture_pixmap_x11_filter, + tex_pixmap); } static void diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c index aa44576ea40..66c4b899df2 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c @@ -323,9 +323,9 @@ static gboolean _cogl_winsys_egl_context_init (CoglContext *context, GError **error) { - cogl_xlib_renderer_add_filter (context->display->renderer, - event_filter_cb, - context); + _cogl_renderer_add_native_filter (context->display->renderer, + (CoglNativeFilterFunc)event_filter_cb, + context); /* We'll manually handle queueing dirty events in response to * Expose events from X */ @@ -339,9 +339,9 @@ _cogl_winsys_egl_context_init (CoglContext *context, static void _cogl_winsys_egl_context_deinit (CoglContext *context) { - cogl_xlib_renderer_remove_filter (context->display->renderer, - event_filter_cb, - context); + _cogl_renderer_remove_native_filter (context->display->renderer, + (CoglNativeFilterFunc)event_filter_cb, + context); } static gboolean diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 9a7da34e4f0..c86c2aaa69b 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -853,18 +853,18 @@ _cogl_winsys_context_init (CoglContext *context, GError **error) { context->winsys = g_new0 (CoglContextGLX, 1); - cogl_xlib_renderer_add_filter (context->display->renderer, - glx_event_filter_cb, - context); + _cogl_renderer_add_native_filter (context->display->renderer, + (CoglNativeFilterFunc)glx_event_filter_cb, + context); return update_winsys_features (context, error); } static void _cogl_winsys_context_deinit (CoglContext *context) { - cogl_xlib_renderer_remove_filter (context->display->renderer, - glx_event_filter_cb, - context); + _cogl_renderer_remove_native_filter (context->display->renderer, + (CoglNativeFilterFunc)glx_event_filter_cb, + context); g_free (context->winsys); } -- GitLab From 47695daed1ef192815477cd3bbf163f771509e71 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 09:56:43 +0200 Subject: [PATCH 07/27] cogl/xlib-renderer: Move struct where it is used The extra header is too much for one struct Part-of: --- cogl/cogl/cogl-x11-renderer-private.h | 37 ---------------------- cogl/cogl/cogl-xlib-renderer-private.h | 7 +++- cogl/cogl/cogl-xlib-renderer.c | 1 - cogl/cogl/meson.build | 1 - cogl/cogl/winsys/cogl-texture-pixmap-x11.c | 1 - 5 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 cogl/cogl/cogl-x11-renderer-private.h diff --git a/cogl/cogl/cogl-x11-renderer-private.h b/cogl/cogl/cogl-x11-renderer-private.h deleted file mode 100644 index 5a0559580af..00000000000 --- a/cogl/cogl/cogl-x11-renderer-private.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2011 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - */ - -#pragma once - -typedef struct _CoglX11Renderer -{ - int damage_base; - int randr_base; -} CoglX11Renderer; diff --git a/cogl/cogl/cogl-xlib-renderer-private.h b/cogl/cogl/cogl-xlib-renderer-private.h index b6c5a531573..bc79b558ed0 100644 --- a/cogl/cogl/cogl-xlib-renderer-private.h +++ b/cogl/cogl/cogl-xlib-renderer-private.h @@ -33,7 +33,6 @@ #include #include -#include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-context.h" typedef struct _CoglXlibOutput @@ -49,6 +48,12 @@ typedef struct _CoglXlibOutput SubpixelOrder subpixel_order; } CoglXlibOutput; +typedef struct _CoglX11Renderer +{ + int damage_base; + int randr_base; +} CoglX11Renderer; + typedef struct _CoglXlibRenderer { CoglX11Renderer _parent; diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index 3e757ebf93f..d3517805567 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -36,7 +36,6 @@ #include "cogl/cogl-renderer-private.h" #include "cogl/cogl-xlib-renderer-private.h" -#include "cogl/cogl-x11-renderer-private.h" #include "cogl/winsys/cogl-winsys-private.h" #include "mtk/mtk-x11.h" diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index e52a7fb8b23..9957d361a72 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -292,7 +292,6 @@ if have_x11 cogl_sources += [ 'cogl-x11-onscreen.c', 'cogl-x11-onscreen.h', - 'cogl-x11-renderer-private.h', 'cogl-xlib-renderer-private.h', 'cogl-xlib-renderer.c', 'winsys/cogl-texture-pixmap-x11-private.h', diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index e2234f75770..edb355462be 100644 --- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -49,7 +49,6 @@ #include "cogl/cogl-renderer-private.h" #include "cogl/cogl-xlib-renderer.h" #include "cogl/cogl-xlib-renderer-private.h" -#include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-private.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" #include "cogl/winsys/cogl-winsys-private.h" -- GitLab From 5a6d2266e4031d386e3e6ab3ad1aac2bef4a08e4 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 10:00:58 +0200 Subject: [PATCH 08/27] cogl/magazine: Remove unused free functions The only magazine instance created is a static so nothing to be freed Part-of: --- cogl/cogl/cogl-magazine-private.h | 3 --- cogl/cogl/cogl-magazine.c | 7 ------- cogl/cogl/cogl-memory-stack-private.h | 3 --- cogl/cogl/cogl-memory-stack.c | 22 ---------------------- 4 files changed, 35 deletions(-) diff --git a/cogl/cogl/cogl-magazine-private.h b/cogl/cogl/cogl-magazine-private.h index b5cc95c1094..507f751d9e2 100644 --- a/cogl/cogl/cogl-magazine-private.h +++ b/cogl/cogl/cogl-magazine-private.h @@ -73,6 +73,3 @@ _cogl_magazine_chunk_free (CoglMagazine *magazine, void *data) chunk->next = magazine->head; magazine->head = chunk; } - -void -_cogl_magazine_free (CoglMagazine *magazine); diff --git a/cogl/cogl/cogl-magazine.c b/cogl/cogl/cogl-magazine.c index c15583384aa..2e444598f1b 100644 --- a/cogl/cogl/cogl-magazine.c +++ b/cogl/cogl/cogl-magazine.c @@ -73,10 +73,3 @@ _cogl_magazine_new (size_t chunk_size, int initial_chunk_count) return magazine; } - -void -_cogl_magazine_free (CoglMagazine *magazine) -{ - _cogl_memory_stack_free (magazine->stack); - g_free (magazine); -} diff --git a/cogl/cogl/cogl-memory-stack-private.h b/cogl/cogl/cogl-memory-stack-private.h index fd6375b38d9..9f20ead96d1 100644 --- a/cogl/cogl/cogl-memory-stack-private.h +++ b/cogl/cogl/cogl-memory-stack-private.h @@ -39,6 +39,3 @@ _cogl_memory_stack_new (size_t initial_size_bytes); void * _cogl_memory_stack_alloc (CoglMemoryStack *stack, size_t bytes); - -void -_cogl_memory_stack_free (CoglMemoryStack *stack); diff --git a/cogl/cogl/cogl-memory-stack.c b/cogl/cogl/cogl-memory-stack.c index a7e29710b5c..042e2d51946 100644 --- a/cogl/cogl/cogl-memory-stack.c +++ b/cogl/cogl/cogl-memory-stack.c @@ -161,25 +161,3 @@ _cogl_memory_stack_alloc (CoglMemoryStack *stack, size_t bytes) return sub_stack->data; } - -static void -_cogl_memory_sub_stack_free (CoglMemorySubStack *sub_stack) -{ - g_free (sub_stack->data); - g_free (sub_stack); -} - -void -_cogl_memory_stack_free (CoglMemoryStack *stack) -{ - - while (!_cogl_list_empty (&stack->sub_stacks)) - { - CoglMemorySubStack *sub_stack = - _cogl_container_of (stack->sub_stacks.next, CoglMemorySubStack, link); - _cogl_list_remove (&sub_stack->link); - _cogl_memory_sub_stack_free (sub_stack); - } - - g_free (stack); -} -- GitLab From e90d2e845e72bb2bacb3da900b7e3cfa2d448fdf Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 10:10:40 +0200 Subject: [PATCH 09/27] cogl/glib-source: Remove no longer useful API It was only useful when Cogl was a separate library Part-of: --- clutter/clutter/clutter-backend.c | 2 +- cogl/cogl/cogl-glib-source.c | 12 ++---------- cogl/cogl/cogl-glib-source.h | 30 +++--------------------------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c index d97d9275dc7..c38cffc096c 100644 --- a/clutter/clutter/clutter-backend.c +++ b/clutter/clutter/clutter-backend.c @@ -255,7 +255,7 @@ clutter_backend_real_create_context (ClutterBackend *backend, return FALSE; } - backend->cogl_source = cogl_glib_source_new (backend->cogl_context, G_PRIORITY_DEFAULT); + backend->cogl_source = cogl_glib_source_new (backend->cogl_renderer, G_PRIORITY_DEFAULT); g_source_attach (backend->cogl_source, NULL); return TRUE; diff --git a/cogl/cogl/cogl-glib-source.c b/cogl/cogl/cogl-glib-source.c index f526cc663f0..90bf6afb6c3 100644 --- a/cogl/cogl/cogl-glib-source.c +++ b/cogl/cogl/cogl-glib-source.c @@ -96,8 +96,8 @@ cogl_glib_source_funcs = }; GSource * -cogl_glib_renderer_source_new (CoglRenderer *renderer, - int priority) +cogl_glib_source_new (CoglRenderer *renderer, + int priority) { GSource *source; CoglGLibSource *cogl_source; @@ -114,11 +114,3 @@ cogl_glib_renderer_source_new (CoglRenderer *renderer, return source; } - -GSource * -cogl_glib_source_new (CoglContext *context, - int priority) -{ - return cogl_glib_renderer_source_new (cogl_context_get_renderer (context), - priority); -} diff --git a/cogl/cogl/cogl-glib-source.h b/cogl/cogl/cogl-glib-source.h index 27b301f5382..ad3bb670411 100644 --- a/cogl/cogl/cogl-glib-source.h +++ b/cogl/cogl/cogl-glib-source.h @@ -42,40 +42,16 @@ G_BEGIN_DECLS /** * cogl_glib_source_new: - * @context: A #CoglContext - * @priority: The priority of the #GSource - * - * Creates a #GSource which handles Cogl's internal system event - * processing. - * - * Applications that manually connect to a #CoglRenderer before they - * create a #CoglContext should instead use - * cogl_glib_renderer_source_new() so that events may be dispatched - * before a context has been created. In that case you don't need to - * use this api in addition later, it is simply enough to use - * cogl_glib_renderer_source_new() instead. - * - * This api is actually just a thin convenience wrapper around - * cogl_glib_renderer_source_new() - * - * Return value: a new #GSource - */ -COGL_EXPORT GSource * -cogl_glib_source_new (CoglContext *context, - int priority); - -/** - * cogl_glib_renderer_source_new: * @renderer: A #CoglRenderer * @priority: The priority of the #GSource * * Creates a #GSource which handles Cogl's internal system event - * processing + * processing. * * Return value: a new #GSource */ COGL_EXPORT GSource * -cogl_glib_renderer_source_new (CoglRenderer *renderer, - int priority); +cogl_glib_source_new (CoglRenderer *renderer, + int priority); G_END_DECLS -- GitLab From 97c43f9eec82c2420ab34d033634f89ff45da578 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 12:02:52 +0200 Subject: [PATCH 10/27] cogl/egl: Move get_egl_display to Context Allows us to get rid of the extra header Part-of: --- cogl/cogl/cogl-context.h | 25 +++++++ cogl/cogl/cogl-egl.h | 72 -------------------- cogl/cogl/cogl-texture-2d.h | 14 ++-- cogl/cogl/cogl-texture-private.h | 3 - cogl/cogl/meson.build | 4 -- cogl/cogl/winsys/cogl-onscreen-egl.h | 2 + cogl/cogl/winsys/cogl-winsys-egl-private.h | 2 + cogl/cogl/winsys/cogl-winsys-egl.c | 4 +- src/backends/meta-screen-cast.c | 4 +- src/wayland/meta-wayland-buffer.c | 5 +- src/wayland/meta-wayland-dma-buf.c | 7 +- src/wayland/meta-wayland-egl-stream.c | 13 ++-- src/wayland/meta-wayland-linux-drm-syncobj.c | 2 +- src/wayland/meta-wayland.c | 3 +- 14 files changed, 51 insertions(+), 109 deletions(-) delete mode 100644 cogl/cogl/cogl-egl.h diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index b1099a240c4..a2fbee4b987 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -46,6 +46,12 @@ typedef struct _CoglTimestampQuery CoglTimestampQuery; #include "cogl/cogl-pipeline.h" #include "cogl/cogl-primitive.h" +#ifdef HAVE_EGL +#include +#include +#include +#endif + #include G_BEGIN_DECLS @@ -370,4 +376,23 @@ cogl_context_has_winsys_feature (CoglContext *context, COGL_EXPORT void cogl_context_flush (CoglContext *context); +#ifdef HAVE_EGL +/** + * cogl_context_get_egl_display: + * @context: A #CoglContext pointer + * + * If you have done a runtime check to determine that Cogl is using + * EGL internally then this API can be used to retrieve the EGLDisplay + * handle that was setup internally. The result is undefined if Cogl + * is not using EGL. + * + * Note: The current window system backend can be checked using + * cogl_renderer_get_winsys_id(). + * + * Return value: The internally setup EGLDisplay handle. + */ +COGL_EXPORT EGLDisplay +cogl_context_get_egl_display (CoglContext *context); +#endif /* HAVE_EGL */ + G_END_DECLS diff --git a/cogl/cogl/cogl-egl.h b/cogl/cogl/cogl-egl.h deleted file mode 100644 index deef1de2b47..00000000000 --- a/cogl/cogl/cogl-egl.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2007,2008,2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - */ - -#pragma once - -#include -#include -#include - -#include "cogl/cogl-types.h" - -G_BEGIN_DECLS - -/** - * cogl_egl_context_get_egl_display: - * @context: A #CoglContext pointer - * - * If you have done a runtime check to determine that Cogl is using - * EGL internally then this API can be used to retrieve the EGLDisplay - * handle that was setup internally. The result is undefined if Cogl - * is not using EGL. - * - * Note: The current window system backend can be checked using - * cogl_renderer_get_winsys_id(). - * - * Return value: The internally setup EGLDisplay handle. - */ -COGL_EXPORT EGLDisplay -cogl_egl_context_get_egl_display (CoglContext *context); - -G_END_DECLS - -/* The gobject introspection scanner seems to parse public headers in - * isolation which means we need to be extra careful about how we - * define and undefine __COGL_H_INSIDE__ used to detect when internal - * headers are incorrectly included by developers. In the gobject - * introspection case we have to manually define __COGL_H_INSIDE__ as - * a commandline argument for the scanner which means we must be - * careful not to undefine it in a header... - */ -#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE_COGL_EGL__ -#undef __COGL_H_INSIDE__ -#undef __COGL_EGL_H_INSIDE__ -#undef __COGL_MUST_UNDEF_COGL_H_INSIDE_COGL_EGL__ -#endif diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h index 552df0982c5..388c18aff83 100644 --- a/cogl/cogl/cogl-texture-2d.h +++ b/cogl/cogl/cogl-texture-2d.h @@ -39,10 +39,6 @@ #include "cogl/cogl-context.h" #include "cogl/cogl-bitmap.h" -#ifdef HAVE_EGL -#include "cogl/cogl-egl.h" -#endif - G_BEGIN_DECLS /** @@ -200,6 +196,12 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, COGL_EXPORT CoglTexture * cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap); +#ifdef HAVE_EGL +typedef gboolean (*CoglTexture2DEGLImageExternalAlloc) (CoglTexture2D *tex_2d, + gpointer user_data, + GError **error); +#endif + /** * cogl_egl_texture_2d_new_from_image: (skip) */ @@ -216,10 +218,6 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx, CoglEglImageFlags flags, GError **error); -typedef gboolean (*CoglTexture2DEGLImageExternalAlloc) (CoglTexture2D *tex_2d, - gpointer user_data, - GError **error); - /** * cogl_texture_2d_new_from_egl_image_external: (skip) */ diff --git a/cogl/cogl/cogl-texture-private.h b/cogl/cogl/cogl-texture-private.h index 432021c98c3..410f692db60 100644 --- a/cogl/cogl/cogl-texture-private.h +++ b/cogl/cogl/cogl-texture-private.h @@ -37,9 +37,6 @@ #include "cogl/cogl-framebuffer.h" #include "cogl/cogl-texture-2d.h" -#ifdef HAVE_EGL -#include "cogl/cogl-egl.h" -#endif /* Encodes three possibiloities result of transforming a quad */ typedef enum diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 9957d361a72..7b51bbed41e 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -315,9 +315,6 @@ if have_glx endif if have_egl - cogl_nonintrospected_headers += [ - 'cogl-egl.h', - ] cogl_sources += [ 'winsys/cogl-onscreen-egl.c', 'winsys/cogl-onscreen-egl.h', @@ -397,7 +394,6 @@ if have_introspection extra_args: introspection_args + [ '-UCOGL_COMPILATION', '-D__COGL_H_INSIDE__', - '-D__COGL_EGL_H_INSIDE__', '-DCOGL_GIR_SCANNING', ], header: 'cogl/cogl.h', diff --git a/cogl/cogl/winsys/cogl-onscreen-egl.h b/cogl/cogl/winsys/cogl-onscreen-egl.h index d4dda66361f..d521bd0479a 100644 --- a/cogl/cogl/winsys/cogl-onscreen-egl.h +++ b/cogl/cogl/winsys/cogl-onscreen-egl.h @@ -25,6 +25,8 @@ #pragma once +#include + #include "cogl/cogl-onscreen.h" #include "cogl/winsys/cogl-winsys-egl-private.h" diff --git a/cogl/cogl/winsys/cogl-winsys-egl-private.h b/cogl/cogl/winsys/cogl-winsys-egl-private.h index 6a31d1ab2d0..8a5cf01a52e 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-private.h +++ b/cogl/cogl/winsys/cogl-winsys-egl-private.h @@ -30,6 +30,8 @@ #pragma once +#include + #include "cogl/cogl-context.h" #include "cogl/cogl-context-private.h" #include "cogl/cogl-framebuffer-private.h" diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c index 046220da183..3da668adf62 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/cogl/winsys/cogl-winsys-egl.c @@ -34,12 +34,12 @@ #include "cogl/cogl-util.h" #include "cogl/cogl-feature-private.h" +#include "cogl/cogl-context.h" #include "cogl/cogl-context-private.h" #include "cogl/cogl-framebuffer.h" #include "cogl/cogl-onscreen-private.h" #include "cogl/cogl-renderer-private.h" #include "cogl/cogl-onscreen-template-private.h" -#include "cogl/cogl-egl.h" #include "cogl/cogl-private.h" #include "cogl/cogl-trace.h" #include "cogl/winsys/cogl-winsys-egl-private.h" @@ -678,7 +678,7 @@ _cogl_egl_query_wayland_buffer (CoglContext *ctx, #endif EGLDisplay -cogl_egl_context_get_egl_display (CoglContext *context) +cogl_context_get_egl_display (CoglContext *context) { CoglRendererEGL *egl_renderer = context->display->renderer->winsys; diff --git a/src/backends/meta-screen-cast.c b/src/backends/meta-screen-cast.c index 0089bc2d9fb..b9c52e9c18c 100644 --- a/src/backends/meta-screen-cast.c +++ b/src/backends/meta-screen-cast.c @@ -33,8 +33,6 @@ #include "backends/native/meta-render-device.h" #include "backends/native/meta-renderer-native-private.h" -#include "cogl/cogl-egl.h" - #include "common/meta-cogl-drm-formats.h" #endif @@ -189,7 +187,7 @@ meta_screen_cast_query_modifiers (MetaScreenCast *screen_cast, CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context); EGLDisplay egl_display = - cogl_egl_context_get_egl_display (cogl_context); + cogl_context_get_egl_display (cogl_context); MetaEgl *egl = meta_backend_get_egl (backend); EGLint num_modifiers; diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c index ee9d51feb6c..ad01a1d852a 100644 --- a/src/wayland/meta-wayland-buffer.c +++ b/src/wayland/meta-wayland-buffer.c @@ -53,7 +53,6 @@ #include "backends/meta-backend-private.h" #include "clutter/clutter.h" -#include "cogl/cogl-egl.h" #include "meta/util.h" #include "wayland/meta-wayland-dma-buf.h" #include "wayland/meta-wayland-private.h" @@ -184,7 +183,7 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer) meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); if (meta_egl_query_wayland_buffer (egl, egl_display, buffer->resource, EGL_TEXTURE_FORMAT, &format, @@ -481,7 +480,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); int format, width, height, y_inverted; CoglPixelFormat cogl_format; EGLImageKHR egl_image; diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index 499e0866285..1f8f0fac155 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -48,7 +48,6 @@ #include "backends/meta-backend-private.h" #include "backends/meta-egl-ext.h" #include "backends/meta-egl.h" -#include "cogl/cogl-egl.h" #include "cogl/cogl.h" #include "common/meta-cogl-drm-formats.h" #include "common/meta-drm-format-helpers.h" @@ -174,7 +173,7 @@ should_send_modifiers (MetaBackend *backend) ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); #ifdef HAVE_NATIVE_BACKEND if (META_IS_BACKEND_NATIVE (backend)) @@ -366,7 +365,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); MetaWaylandDmaBufBuffer *dma_buf = buffer->dma_buf.dma_buf; MetaMultiTextureFormat multi_format; CoglPixelFormat cogl_format; @@ -1820,7 +1819,7 @@ meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); dev_t device_id = 0; int protocol_version; EGLDeviceEXT egl_device; diff --git a/src/wayland/meta-wayland-egl-stream.c b/src/wayland/meta-wayland-egl-stream.c index 1a0fe62000a..fff6df7845b 100644 --- a/src/wayland/meta-wayland-egl-stream.c +++ b/src/wayland/meta-wayland-egl-stream.c @@ -29,7 +29,6 @@ #include "backends/meta-backend-private.h" #include "backends/meta-egl-ext.h" #include "backends/meta-egl.h" -#include "cogl/cogl-egl.h" #include "meta/meta-backend.h" #include "wayland/meta-wayland-buffer.h" #include "wayland/meta-wayland-private.h" @@ -153,7 +152,7 @@ meta_wayland_egl_stream_new (MetaWaylandBuffer *buffer, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); EGLAttrib stream_attribs[] = { EGL_WAYLAND_EGLSTREAM_WL, (EGLAttrib) buffer->resource, EGL_NONE @@ -200,7 +199,7 @@ alloc_egl_stream_texture (CoglTexture2D *texture, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); return meta_egl_stream_consumer_gl_texture_external (egl, egl_display, stream->egl_stream, @@ -217,7 +216,7 @@ meta_wayland_egl_stream_create_texture (MetaWaylandEglStream *stream, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); CoglTexture *texture; int width, height; int y_inverted; @@ -275,7 +274,7 @@ meta_wayland_egl_stream_attach (MetaWaylandEglStream *stream, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); EGLint stream_state; if (!meta_egl_query_stream (egl, egl_display, stream->egl_stream, @@ -328,7 +327,7 @@ meta_wayland_is_egl_stream_buffer (MetaWaylandBuffer *buffer) MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); int stream_fd; if (!meta_egl_has_extensions (egl, egl_display, NULL, @@ -355,7 +354,7 @@ meta_wayland_egl_stream_finalize (GObject *object) MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); g_assert (!stream->texture); diff --git a/src/wayland/meta-wayland-linux-drm-syncobj.c b/src/wayland/meta-wayland-linux-drm-syncobj.c index 710a019c304..3f2fed6bfa8 100644 --- a/src/wayland/meta-wayland-linux-drm-syncobj.c +++ b/src/wayland/meta-wayland-linux-drm-syncobj.c @@ -455,7 +455,7 @@ meta_wayland_drm_syncobj_manager_new (MetaWaylandCompositor *compositor, MetaEgl *egl = meta_backend_get_egl (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); MetaWaylandDrmSyncobjManager *drm_syncobj_manager; EGLDeviceEXT egl_device; g_autofd int drm_fd = -1; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index fd58e33f141..d42cbd16cb7 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -34,7 +34,6 @@ #endif #include "clutter/clutter.h" -#include "cogl/cogl-egl.h" #include "compositor/meta-surface-actor-wayland.h" #include "core/events.h" #include "core/meta-context-private.h" @@ -759,7 +758,7 @@ meta_wayland_init_egl (MetaWaylandCompositor *compositor) ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + EGLDisplay egl_display = cogl_context_get_egl_display (cogl_context); g_autoptr (GError) error = NULL; if (!meta_egl_has_extensions (egl, egl_display, NULL, -- GitLab From 6c1739ea1cec53fbda9bd34293762a8f5e61983f Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 14:27:55 +0200 Subject: [PATCH 11/27] cogl: Move get_graphics_status to Context That is where it belongs & avoids a global function in the docs when it shouldn't be one Part-of: --- cogl/cogl/cogl-context.c | 2 +- cogl/cogl/cogl-context.h | 6 +++--- src/compositor/compositor.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index 4f5f34a9177..eb74b6d3263 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -443,7 +443,7 @@ cogl_context_get_latest_sync_fd (CoglContext *context) } CoglGraphicsResetStatus -cogl_get_graphics_reset_status (CoglContext *context) +cogl_context_get_graphics_reset_status (CoglContext *context) { return context->driver_vtable->get_graphics_reset_status (context); } diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index a2fbee4b987..21e913632bd 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -235,7 +235,7 @@ cogl_context_has_feature (CoglContext *context, * @COGL_GRAPHICS_RESET_STATUS_PURGED_CONTEXT_RESET: * * All the error values that might be returned by - * cogl_get_graphics_reset_status(). Each value's meaning corresponds + * cogl_context_get_graphics_reset_status(). Each value's meaning corresponds * to the similarly named value defined in the ARB_robustness and * NV_robustness_video_memory_purge extensions. */ @@ -249,7 +249,7 @@ typedef enum _CoglGraphicsResetStatus } CoglGraphicsResetStatus; /** - * cogl_get_graphics_reset_status: + * cogl_context_get_graphics_reset_status: * @context: a #CoglContext pointer * * Returns the graphics reset status as reported by @@ -262,7 +262,7 @@ typedef enum _CoglGraphicsResetStatus * Return value: a #CoglGraphicsResetStatus */ COGL_EXPORT CoglGraphicsResetStatus -cogl_get_graphics_reset_status (CoglContext *context); +cogl_context_get_graphics_reset_status (CoglContext *context); /** * cogl_context_is_hardware_accelerated: diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index c72276823e4..a9ef7369116 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -1000,7 +1000,7 @@ meta_compositor_real_after_paint (MetaCompositor *compositor, ClutterStageView *stage_view; GList *l; - status = cogl_get_graphics_reset_status (priv->context); + status = cogl_context_get_graphics_reset_status (priv->context); switch (status) { case COGL_GRAPHICS_RESET_STATUS_NO_ERROR: -- GitLab From b3404816fb261c3b3cb6deb49e181ab134d45d01 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 15:21:15 +0200 Subject: [PATCH 12/27] cogl: Switch remaining headers to pragma once Part-of: --- cogl/cogl/cogl-cpu-caps.h | 5 +---- cogl/cogl/cogl-half-float.h | 5 +---- cogl/cogl/cogl-soft-float.h | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cogl/cogl/cogl-cpu-caps.h b/cogl/cogl/cogl-cpu-caps.h index 162e5b889df..50de9cfaf90 100644 --- a/cogl/cogl/cogl-cpu-caps.h +++ b/cogl/cogl/cogl-cpu-caps.h @@ -28,8 +28,7 @@ * */ -#ifndef COGL_CPU_CAPS_H -#define COGL_CPU_CAPS_H +#pragma once #include "cogl/cogl-types.h" @@ -50,5 +49,3 @@ cogl_cpu_has_cap (CoglCpuCaps cap) { return !!(cogl_cpu_caps & cap); } - -#endif /* COGL_CPU_CAPS_H */ diff --git a/cogl/cogl/cogl-half-float.h b/cogl/cogl/cogl-half-float.h index cee43749789..da420c6ef0b 100644 --- a/cogl/cogl/cogl-half-float.h +++ b/cogl/cogl/cogl-half-float.h @@ -23,8 +23,7 @@ /* This source file is originally from Mesa (src/util/half_float.h). */ -#ifndef COGL_HALF_FLOAT_H -#define COGL_HALF_FLOAT_H +#pragma once #include "cogl/cogl-types.h" @@ -117,5 +116,3 @@ cogl_half_is_negative (uint16_t h) { return !!(h & 0x8000); } - -#endif /* COGL_HALF_FLOAT_H */ diff --git a/cogl/cogl/cogl-soft-float.h b/cogl/cogl/cogl-soft-float.h index a222e09773e..761d5fb207b 100644 --- a/cogl/cogl/cogl-soft-float.h +++ b/cogl/cogl/cogl-soft-float.h @@ -40,8 +40,7 @@ * from the Berkeley SoftFloat 3e Library. */ -#ifndef COGL_SOFT_FLOAT_H -#define COGL_SOFT_FLOAT_H + #pragma once #include #include @@ -67,5 +66,3 @@ float cogl_double_to_f32 (double x, gboolean rtz); uint16_t cogl_float_to_half_rtz_slow (float x); - -#endif /* COGL_SOFT_FLOAT_H */ -- GitLab From 6b0a289d771b36abe325d757727ebd4873a48cc7 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 20:43:13 +0200 Subject: [PATCH 13/27] cogl: Make FramebufferDriverConfig private There is 0 reason to expose that, it is a private API Part-of: --- cogl/cogl/cogl-framebuffer-private.h | 4 ++-- cogl/cogl/cogl-framebuffer.h | 2 -- cogl/cogl/driver/gl/cogl-gl-framebuffer-back.h | 1 + cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.h | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h index 32fff4b6a4f..9acc4b59f7f 100644 --- a/cogl/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl/cogl-framebuffer-private.h @@ -44,12 +44,12 @@ typedef enum COGL_FRAMEBUFFER_DRIVER_TYPE_BACK, } CoglFramebufferDriverType; -struct _CoglFramebufferDriverConfig +typedef struct _CoglFramebufferDriverConfig { CoglFramebufferDriverType type; gboolean disable_depth_and_stencil; -}; +} CoglFramebufferDriverConfig; typedef struct { diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index c2a1e52569a..cb4fb17935d 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -85,8 +85,6 @@ G_BEGIN_DECLS * configuration. */ -typedef struct _CoglFramebufferDriverConfig CoglFramebufferDriverConfig; - #define COGL_TYPE_FRAMEBUFFER (cogl_framebuffer_get_type ()) COGL_EXPORT G_DECLARE_DERIVABLE_TYPE (CoglFramebuffer, cogl_framebuffer, diff --git a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.h b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.h index 293d3398a1f..871cba81cfb 100644 --- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.h +++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-back.h @@ -26,6 +26,7 @@ #pragma once #include "cogl/driver/gl/cogl-framebuffer-gl-private.h" +#include "cogl/cogl-framebuffer-private.h" #define COGL_TYPE_GL_FRAMEBUFFER_BACK (cogl_gl_framebuffer_back_get_type ()) G_DECLARE_FINAL_TYPE (CoglGlFramebufferBack, cogl_gl_framebuffer_back, diff --git a/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.h b/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.h index cc159899834..9f5ab3c777d 100644 --- a/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.h +++ b/cogl/cogl/driver/gl/cogl-gl-framebuffer-fbo.h @@ -26,6 +26,7 @@ #pragma once #include "cogl/driver/gl/cogl-framebuffer-gl-private.h" +#include "cogl/cogl-framebuffer-private.h" #define COGL_TYPE_GL_FRAMEBUFFER_FBO (cogl_gl_framebuffer_fbo_get_type ()) G_DECLARE_FINAL_TYPE (CoglGlFramebufferFbo, cogl_gl_framebuffer_fbo, -- GitLab From 50fc438599685509dacefdf24ca1c83390e235a2 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 27 Jul 2024 21:50:40 +0200 Subject: [PATCH 14/27] cogl: Replace OnscreenDirtyInfo with MtkRectangle It is a rectangle after all and is only used internally, so instead of making it private just replace it Part-of: --- cogl/cogl/cogl-onscreen-private.h | 7 ++++--- cogl/cogl/cogl-onscreen.c | 6 +++--- cogl/cogl/cogl-onscreen.h | 19 ------------------- cogl/cogl/winsys/cogl-winsys-egl-x11.c | 2 +- cogl/cogl/winsys/cogl-winsys-glx.c | 2 +- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/cogl/cogl/cogl-onscreen-private.h b/cogl/cogl/cogl-onscreen-private.h index 959a60533b3..e732d3fd0b3 100644 --- a/cogl/cogl/cogl-onscreen-private.h +++ b/cogl/cogl/cogl-onscreen-private.h @@ -34,6 +34,7 @@ #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-closure-list-private.h" #include "cogl/cogl-list.h" +#include "mtk/mtk-rectangle.h" #include @@ -51,7 +52,7 @@ typedef struct _CoglOnscreenQueuedDirty CoglList link; CoglOnscreen *onscreen; - CoglOnscreenDirtyInfo info; + MtkRectangle info; } CoglOnscreenQueuedDirty; void @@ -65,8 +66,8 @@ COGL_EXPORT void _cogl_onscreen_notify_complete (CoglOnscreen *onscreen, CoglFrameInfo *info); void -_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen, - const CoglOnscreenDirtyInfo *info); +_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen, + const MtkRectangle *info); void cogl_onscreen_bind (CoglOnscreen *onscreen); diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c index 13bc54493b1..8786247117a 100644 --- a/cogl/cogl/cogl-onscreen.c +++ b/cogl/cogl/cogl-onscreen.c @@ -231,8 +231,8 @@ _cogl_onscreen_queue_dispatch_idle (CoglOnscreen *onscreen) } void -_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen, - const CoglOnscreenDirtyInfo *info) +_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen, + const MtkRectangle *info) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); @@ -249,7 +249,7 @@ void _cogl_onscreen_queue_full_dirty (CoglOnscreen *onscreen) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); - CoglOnscreenDirtyInfo info; + MtkRectangle info; info.x = 0; info.y = 0; diff --git a/cogl/cogl/cogl-onscreen.h b/cogl/cogl/cogl-onscreen.h index 5dd131d868f..e7b71f19020 100644 --- a/cogl/cogl/cogl-onscreen.h +++ b/cogl/cogl/cogl-onscreen.h @@ -403,25 +403,6 @@ COGL_EXPORT void cogl_onscreen_remove_frame_callback (CoglOnscreen *onscreen, CoglFrameClosure *closure); -/** - * CoglOnscreenDirtyInfo: - * @x: Left edge of the dirty rectangle - * @y: Top edge of the dirty rectangle, measured from the top of the window - * @width: Width of the dirty rectangle - * @height: Height of the dirty rectangle - * - * A structure passed to callbacks registered using - * cogl_onscreen_add_dirty_callback(). The members describe a - * rectangle within the onscreen buffer that should be redrawn. - */ -typedef struct _CoglOnscreenDirtyInfo CoglOnscreenDirtyInfo; - -struct _CoglOnscreenDirtyInfo -{ - int x, y; - int width, height; -}; - /** * cogl_onscreen_get_frame_counter: * diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c index 66c4b899df2..7de343d6a2f 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c @@ -121,7 +121,7 @@ event_filter_cb (XEvent *xevent, void *data) if (onscreen) { - CoglOnscreenDirtyInfo info; + MtkRectangle info; info.x = xevent->xexpose.x; info.y = xevent->xexpose.y; diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index c86c2aaa69b..76a13f1c2fa 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -226,7 +226,7 @@ glx_event_filter_cb (XEvent *xevent, void *data) if (onscreen) { - CoglOnscreenDirtyInfo info; + MtkRectangle info; info.x = xevent->xexpose.x; info.y = xevent->xexpose.y; -- GitLab From 4bd974222ec1ba424622be5925d8aff2b08573cb Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 09:59:55 +0200 Subject: [PATCH 15/27] cogl: Make RendererConstraint private It is only used internally Part-of: --- cogl/cogl/cogl-renderer.h | 26 -------------------------- cogl/cogl/winsys/cogl-winsys-private.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cogl/cogl/cogl-renderer.h b/cogl/cogl/cogl-renderer.h index 657b73ec00a..e09b55582ba 100644 --- a/cogl/cogl/cogl-renderer.h +++ b/cogl/cogl/cogl-renderer.h @@ -191,32 +191,6 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer, COGL_EXPORT gboolean cogl_renderer_connect (CoglRenderer *renderer, GError **error); -/** - * CoglRendererConstraint: - * @COGL_RENDERER_CONSTRAINT_USES_X11: Require the renderer to be X11 based - * @COGL_RENDERER_CONSTRAINT_USES_XLIB: Require the renderer to be X11 - * based and use Xlib - * @COGL_RENDERER_CONSTRAINT_USES_EGL: Require the renderer to be EGL based - * - * These constraint flags are hard-coded features of the different renderer - * backends. Sometimes a platform may support multiple rendering options which - * Cogl will usually choose from automatically. Some of these features are - * important to higher level applications and frameworks though, such as - * whether a renderer is X11 based because an application might only support - * X11 based input handling. An application might also need to ensure EGL is - * used internally too if they depend on access to an EGLDisplay for some - * purpose. - * - * Applications should ideally minimize how many of these constraints - * they depend on to ensure maximum portability. - */ -typedef enum -{ - COGL_RENDERER_CONSTRAINT_USES_X11 = (1 << 0), - COGL_RENDERER_CONSTRAINT_USES_XLIB = (1 << 1), - COGL_RENDERER_CONSTRAINT_USES_EGL = (1 << 2), -} CoglRendererConstraint; - /** * CoglDriver: * @COGL_DRIVER_ANY: Implies no preference for which driver is used diff --git a/cogl/cogl/winsys/cogl-winsys-private.h b/cogl/cogl/winsys/cogl-winsys-private.h index 00644e3f277..0606243a777 100644 --- a/cogl/cogl/winsys/cogl-winsys-private.h +++ b/cogl/cogl/winsys/cogl-winsys-private.h @@ -51,6 +51,32 @@ typedef enum /*< prefix=COGL_WINSYS_ERROR >*/ COGL_WINSYS_ERROR_MAKE_CURRENT, } CoglWinsysError; +/** + * CoglRendererConstraint: + * @COGL_RENDERER_CONSTRAINT_USES_X11: Require the renderer to be X11 based + * @COGL_RENDERER_CONSTRAINT_USES_XLIB: Require the renderer to be X11 + * based and use Xlib + * @COGL_RENDERER_CONSTRAINT_USES_EGL: Require the renderer to be EGL based + * + * These constraint flags are hard-coded features of the different renderer + * backends. Sometimes a platform may support multiple rendering options which + * Cogl will usually choose from automatically. Some of these features are + * important to higher level applications and frameworks though, such as + * whether a renderer is X11 based because an application might only support + * X11 based input handling. An application might also need to ensure EGL is + * used internally too if they depend on access to an EGLDisplay for some + * purpose. + * + * Applications should ideally minimize how many of these constraints + * they depend on to ensure maximum portability. + */ +typedef enum +{ + COGL_RENDERER_CONSTRAINT_USES_X11 = (1 << 0), + COGL_RENDERER_CONSTRAINT_USES_XLIB = (1 << 1), + COGL_RENDERER_CONSTRAINT_USES_EGL = (1 << 2), +} CoglRendererConstraint; + typedef struct _CoglWinsysVtable { CoglWinsysID id; -- GitLab From 5d7c4bccd8ca41cf0e7b988ecbc36d47d2b8b8ca Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 10:13:09 +0200 Subject: [PATCH 16/27] cogl: Make BlendStringError private It is a private API Part-of: --- cogl/cogl/cogl-blend-string.h | 27 +++++++++++++++++++++++++++ cogl/cogl/cogl-types.h | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/cogl/cogl/cogl-blend-string.h b/cogl/cogl/cogl-blend-string.h index 08f6ab2b53d..e38b06b6a6a 100644 --- a/cogl/cogl/cogl-blend-string.h +++ b/cogl/cogl/cogl-blend-string.h @@ -127,6 +127,33 @@ typedef struct _CoglBlendStringStatement CoglBlendStringArgument args[3]; } CoglBlendStringStatement; +/** + * COGL_BLEND_STRING_ERROR: + * + * #GError domain for blend string parser errors + */ +#define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_quark ()) + +/** + * CoglBlendStringError: + * @COGL_BLEND_STRING_ERROR_PARSE_ERROR: Generic parse error + * @COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR: Argument parse error + * @COGL_BLEND_STRING_ERROR_INVALID_ERROR: Internal parser error + * @COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR: Blend string not + * supported by the GPU + * + * Error enumeration for the blend strings parser + */ +typedef enum /*< prefix=COGL_BLEND_STRING_ERROR >*/ +{ + COGL_BLEND_STRING_ERROR_PARSE_ERROR, + COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR, + COGL_BLEND_STRING_ERROR_INVALID_ERROR, + COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR +} CoglBlendStringError; + +uint32_t +cogl_blend_string_error_quark (void); gboolean _cogl_blend_string_compile (const char *string, diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index a7c295a0acc..7933862c512 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -67,34 +67,6 @@ typedef struct _CoglFramebuffer CoglFramebuffer; */ typedef struct _CoglDmaBufHandle CoglDmaBufHandle; -/** - * COGL_BLEND_STRING_ERROR: - * - * #GError domain for blend string parser errors - */ -#define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_quark ()) - -/** - * CoglBlendStringError: - * @COGL_BLEND_STRING_ERROR_PARSE_ERROR: Generic parse error - * @COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR: Argument parse error - * @COGL_BLEND_STRING_ERROR_INVALID_ERROR: Internal parser error - * @COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR: Blend string not - * supported by the GPU - * - * Error enumeration for the blend strings parser - */ -typedef enum /*< prefix=COGL_BLEND_STRING_ERROR >*/ -{ - COGL_BLEND_STRING_ERROR_PARSE_ERROR, - COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR, - COGL_BLEND_STRING_ERROR_INVALID_ERROR, - COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR -} CoglBlendStringError; - -COGL_EXPORT uint32_t -cogl_blend_string_error_quark (void); - #define COGL_SYSTEM_ERROR (_cogl_system_error_quark ()) /** -- GitLab From 162b8e1a1587a15c6e73a27e45759aa105ace079 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 10:31:16 +0200 Subject: [PATCH 17/27] cogl: Remove no longer useful UNAVAILABLE macro It is no longer a separate library Part-of: --- cogl/cogl/cogl-macros.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/cogl/cogl/cogl-macros.h b/cogl/cogl/cogl-macros.h index 895a597c056..7ce526fb23a 100644 --- a/cogl/cogl/cogl-macros.h +++ b/cogl/cogl/cogl-macros.h @@ -42,7 +42,6 @@ #define COGL_DEPRECATED #define COGL_DEPRECATED_FOR(f) -#define COGL_UNAVAILABLE(maj,min) #else /* COGL_DISABLE_DEPRECATION_WARNINGS */ @@ -62,14 +61,6 @@ #define COGL_DEPRECATED_FOR(f) G_DEPRECATED #endif -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -#define COGL_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) -#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) -#define COGL_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) -#else -#define COGL_UNAVAILABLE(maj,min) -#endif - #endif /* COGL_DISABLE_DEPRECATION_WARNINGS */ #define COGL_EXPORT __attribute__((visibility("default"))) extern -- GitLab From 716f23c7c1c90e65101aa0cbad71df79fe77b9d2 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 13:02:22 +0200 Subject: [PATCH 18/27] cogl/pixel-format: Make CAN_HAVE_PREMULT an inlined function To avoid exposing the function macro in the gir file & so the docs Part-of: --- cogl/cogl/cogl-bitmap.c | 4 ++-- cogl/cogl/cogl-pixel-format.h | 11 +++++++---- cogl/cogl/cogl-texture.c | 4 ++-- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cogl/cogl/cogl-bitmap.c b/cogl/cogl/cogl-bitmap.c index 7c8d2746865..4cec61f7c28 100644 --- a/cogl/cogl/cogl-bitmap.c +++ b/cogl/cogl/cogl-bitmap.c @@ -82,12 +82,12 @@ _cogl_bitmap_convert_premult_status (CoglBitmap *bmp, /* Do we need to unpremultiply? */ if ((bmp->format & COGL_PREMULT_BIT) > 0 && (dst_format & COGL_PREMULT_BIT) == 0 && - COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (dst_format)) + _cogl_pixel_format_can_have_premult (dst_format)) return _cogl_bitmap_unpremult (bmp, error); /* Do we need to premultiply? */ if ((bmp->format & COGL_PREMULT_BIT) == 0 && - COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (bmp->format) && + _cogl_pixel_format_can_have_premult (bmp->format) && (dst_format & COGL_PREMULT_BIT) > 0) /* Try premultiplying using imaging library */ return _cogl_bitmap_premult (bmp, error); diff --git a/cogl/cogl/cogl-pixel-format.h b/cogl/cogl/cogl-pixel-format.h index 0f00d66c508..d9fe538738e 100644 --- a/cogl/cogl/cogl-pixel-format.h +++ b/cogl/cogl/cogl-pixel-format.h @@ -265,7 +265,7 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/ /** * COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT: - * + * * Architecture dependant format, similar to CAIRO_ARGB32. */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN @@ -324,7 +324,7 @@ gboolean _cogl_pixel_format_is_endian_dependant (CoglPixelFormat format); /* - * COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format): + * _cogl_pixel_format_can_have_premult: * @format: a #CoglPixelFormat * * Returns TRUE if the pixel format can take a premult bit. This is @@ -332,8 +332,11 @@ _cogl_pixel_format_is_endian_dependant (CoglPixelFormat format); * COGL_PIXEL_FORMAT_A_8 (because that doesn't have any other * components to multiply by the alpha). */ -#define COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format) \ - (((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8) +static inline gboolean +_cogl_pixel_format_can_have_premult (CoglPixelFormat format) +{ + return (((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8); +} /** * cogl_pixel_format_get_n_planes: diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 773789dd0f1..2bc7746560c 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -808,7 +808,7 @@ cogl_texture_get_data (CoglTexture *texture, /* We can assume that whatever data GL gives us will have the premult status of the original texture */ - if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (closest_format)) + if (_cogl_pixel_format_can_have_premult (closest_format)) closest_format = ((closest_format & ~COGL_PREMULT_BIT) | (texture_format & COGL_PREMULT_BIT)); @@ -1202,7 +1202,7 @@ _cogl_texture_determine_internal_format (CoglTexture *texture, if (cogl_texture_get_premultiplied (texture)) { - if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format)) + if (_cogl_pixel_format_can_have_premult (format)) return format |= COGL_PREMULT_BIT; else return COGL_PIXEL_FORMAT_RGBA_8888_PRE; diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index 7197e7c5abd..36edc4cdbb4 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -472,7 +472,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, uint8_t *tmp_data; gboolean succeeded; - if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (read_format)) + if (_cogl_pixel_format_can_have_premult (read_format)) { read_format = ((read_format & ~COGL_PREMULT_BIT) | (internal_format & COGL_PREMULT_BIT)); @@ -536,7 +536,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver, /* We match the premultiplied state of the target buffer to the * premultiplied state of the framebuffer so that it will get * converted to the right format below */ - if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format)) + if (_cogl_pixel_format_can_have_premult (format)) bmp_format = ((format & ~COGL_PREMULT_BIT) | (internal_format & COGL_PREMULT_BIT)); else -- GitLab From b07c772fc86fd2d45d8edfa2c4e9dc3decc8e277 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 14:49:13 +0200 Subject: [PATCH 19/27] cogl: Rename Shader/Program constructors Otherwise they end up as global functions instead of constructors of their corresponding types. Helps with better docs Part-of: --- clutter/clutter/clutter-shader-effect.c | 12 ++++++------ cogl/cogl/cogl-pipeline-state.h | 8 ++++---- cogl/cogl/deprecated/cogl-program.c | 2 +- cogl/cogl/deprecated/cogl-shader.c | 4 ++-- cogl/cogl/deprecated/cogl-shader.h | 10 +++++----- .../clutter/interactive/test-cogl-shader-glsl.c | 5 ++--- src/tests/cogl/conform/test-just-vertex-shader.c | 4 ++-- src/tests/cogl/conform/test-pipeline-uniforms.c | 4 ++-- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/clutter/clutter/clutter-shader-effect.c b/clutter/clutter/clutter-shader-effect.c index 415ca7edac1..8125af8cc88 100644 --- a/clutter/clutter/clutter-shader-effect.c +++ b/clutter/clutter/clutter-shader-effect.c @@ -24,9 +24,9 @@ /** * ClutterShaderEffect: - * + * * Base class for shader effects - * + * * #ClutterShaderEffect is a class that implements all the plumbing for * creating [class@Effect]s using GLSL shaders. * @@ -305,11 +305,11 @@ clutter_shader_effect_create_shader (ClutterShaderEffect *self) switch (priv->shader_type) { case CLUTTER_FRAGMENT_SHADER: - return cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + return cogl_shader_new (COGL_SHADER_TYPE_FRAGMENT); break; case CLUTTER_VERTEX_SHADER: - return cogl_create_shader (COGL_SHADER_TYPE_VERTEX); + return cogl_shader_new (COGL_SHADER_TYPE_VERTEX); break; default: @@ -349,7 +349,7 @@ clutter_shader_effect_try_static_source (ClutterShaderEffect *self) CLUTTER_NOTE (SHADER, "Compiling shader effect"); - class_priv->program = cogl_create_program (); + class_priv->program = cogl_program_new (); cogl_program_attach_shader (class_priv->program, class_priv->shader); @@ -873,7 +873,7 @@ clutter_shader_effect_set_shader_source (ClutterShaderEffect *effect, CLUTTER_NOTE (SHADER, "Compiling shader effect"); - priv->program = cogl_create_program (); + priv->program = cogl_program_new (); cogl_program_attach_shader (priv->program, priv->shader); diff --git a/cogl/cogl/cogl-pipeline-state.h b/cogl/cogl/cogl-pipeline-state.h index 0650687f826..c6cbb5eba6f 100644 --- a/cogl/cogl/cogl-pipeline-state.h +++ b/cogl/cogl/cogl-pipeline-state.h @@ -166,13 +166,13 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline); * ``` * * This is the list of source-names usable as blend factors: - * + * * - `SRC_COLOR`: The color of the incoming fragment * - `DST_COLOR`: The color of the framebuffer * - `CONSTANT`: The constant set via cogl_pipeline_set_blend_constant() * * These can also be used as factors: - * + * * - `0`: (0, 0, 0, 0) * - `1`: (1, 1, 1, 1) * - `SRC_ALPHA_SATURATE_FACTOR`: (f,f,f,1) where `f = MIN(SRC_COLOR[A],1-DST_COLOR[A])` @@ -319,13 +319,13 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline); * CoglProgram *program; * CoglPipeline *pipeline; * - * shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + * shader = cogl_shader_new (COGL_SHADER_TYPE_FRAGMENT); * cogl_shader_source (shader, * "!!ARBfp1.0\n" * "MOV result.color,fragment.color;\n" * "END\n"); * - * program = cogl_create_program (); + * program = cogl_program_new (); * cogl_program_attach_shader (program, shader); * cogl_program_link (program); * diff --git a/cogl/cogl/deprecated/cogl-program.c b/cogl/cogl/deprecated/cogl-program.c index 5d72a8bf7e2..93721abf5f6 100644 --- a/cogl/cogl/deprecated/cogl-program.c +++ b/cogl/cogl/deprecated/cogl-program.c @@ -86,7 +86,7 @@ cogl_program_class_init (CoglProgramClass *class) it. */ CoglProgram* -cogl_create_program (void) +cogl_program_new (void) { CoglProgram *program; diff --git a/cogl/cogl/deprecated/cogl-shader.c b/cogl/cogl/deprecated/cogl-shader.c index 0cc43c623ea..4ea2220b509 100644 --- a/cogl/cogl/deprecated/cogl-shader.c +++ b/cogl/cogl/deprecated/cogl-shader.c @@ -70,7 +70,7 @@ cogl_shader_class_init (CoglShaderClass *class) } CoglShader* -cogl_create_shader (CoglShaderType type) +cogl_shader_new (CoglShaderType type) { CoglShader *shader; @@ -81,7 +81,7 @@ cogl_create_shader (CoglShaderType type) break; default: g_warning ("Unexpected shader type (0x%08lX) given to " - "cogl_create_shader", (unsigned long) type); + "cogl_shader_new", (unsigned long) type); return NULL; } diff --git a/cogl/cogl/deprecated/cogl-shader.h b/cogl/cogl/deprecated/cogl-shader.h index 48754035200..118b1cc5d49 100644 --- a/cogl/cogl/deprecated/cogl-shader.h +++ b/cogl/cogl/deprecated/cogl-shader.h @@ -145,7 +145,7 @@ typedef enum } CoglShaderType; /** - * cogl_create_shader: + * cogl_shader_new: * @shader_type: COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT. * * Create a new shader handle, use cogl_shader_source() to set the @@ -156,7 +156,7 @@ typedef enum */ COGL_DEPRECATED_FOR (cogl_snippet_) COGL_EXPORT CoglShader* -cogl_create_shader (CoglShaderType shader_type); +cogl_shader_new (CoglShaderType shader_type); /** * cogl_shader_source: @@ -165,7 +165,7 @@ cogl_create_shader (CoglShaderType shader_type); * * Replaces the current source associated with a shader with a new * one. - * + * * Deprecated: 1.16: Use #CoglSnippet api */ COGL_DEPRECATED_FOR (cogl_snippet_) @@ -188,7 +188,7 @@ COGL_EXPORT CoglShaderType cogl_shader_get_shader_type (CoglShader *self); /** - * cogl_create_program: + * cogl_program_new: * * Create a new cogl program object that can be used to replace parts of the GL * rendering pipeline with custom code. @@ -198,7 +198,7 @@ cogl_shader_get_shader_type (CoglShader *self); */ COGL_DEPRECATED_FOR (cogl_snippet_) COGL_EXPORT CoglProgram* -cogl_create_program (void); +cogl_program_new (void); /** * cogl_program_attach_shader: diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c b/src/tests/clutter/interactive/test-cogl-shader-glsl.c index eb95bbae6d5..28d68c7e5fb 100644 --- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c +++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c @@ -204,10 +204,10 @@ set_shader_num (int new_no) shader_pipeline = cogl_pipeline_new (ctx); - shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + shader = cogl_shader_new (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, shaders[new_no].source); - program = cogl_create_program (); + program = cogl_program_new (); cogl_program_attach_shader (program, shader); g_object_unref (shader); cogl_program_link (program); @@ -358,4 +358,3 @@ test_cogl_shader_glsl_main (int argc, char *argv[]) return EXIT_SUCCESS; } - diff --git a/src/tests/cogl/conform/test-just-vertex-shader.c b/src/tests/cogl/conform/test-just-vertex-shader.c index f149b025b36..cc5f5efbb8f 100644 --- a/src/tests/cogl/conform/test-just-vertex-shader.c +++ b/src/tests/cogl/conform/test-just-vertex-shader.c @@ -58,7 +58,7 @@ paint (TestState *state) /* Set up a dummy vertex shader that does nothing but the usual fixed function transform */ - shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); + shader = cogl_shader_new (COGL_SHADER_TYPE_VERTEX); cogl_shader_source (shader, "void\n" "main ()\n" @@ -70,7 +70,7 @@ paint (TestState *state) " cogl_tex_coord_out[0] = cogl_tex_coord_in;\n" "}\n"); - program = cogl_create_program (); + program = cogl_program_new (); cogl_program_attach_shader (program, shader); cogl_program_link (program); diff --git a/src/tests/cogl/conform/test-pipeline-uniforms.c b/src/tests/cogl/conform/test-pipeline-uniforms.c index 75caf3585b1..566d101d2d1 100644 --- a/src/tests/cogl/conform/test-pipeline-uniforms.c +++ b/src/tests/cogl/conform/test-pipeline-uniforms.c @@ -94,10 +94,10 @@ create_pipeline_for_shader (TestState *state, const char *shader_source) pipeline = cogl_pipeline_new (test_ctx); - shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + shader = cogl_shader_new (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, shader_source); - program = cogl_create_program (); + program = cogl_program_new (); cogl_program_attach_shader (program, shader); cogl_pipeline_set_user_program (pipeline, program); -- GitLab From a9ec604eba6edbfc530e5f74ca0b3a6c375e5fb0 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 14:58:33 +0200 Subject: [PATCH 20/27] cogl/renderer: Expose handle_event As it was originally the function to be used before making it private and providing safer wrappers around it for x11/win32. Nowadays, it is only used in x11 and only internally in mutter, exposing a 'safer' variant costs us exposing more of x11 renderer APIs without much benefits. With this change, the only internal xlib renderer we need from meta is set_foreign_display which can't be easily worked around Part-of: --- cogl/cogl/cogl-renderer-private.h | 4 ---- cogl/cogl/cogl-renderer.c | 4 ++-- cogl/cogl/cogl-renderer.h | 17 +++++++++++++++++ cogl/cogl/cogl-xlib-renderer.c | 7 ------- cogl/cogl/cogl-xlib-renderer.h | 21 +-------------------- src/backends/x11/meta-event-x11.c | 4 ++-- 6 files changed, 22 insertions(+), 35 deletions(-) diff --git a/cogl/cogl/cogl-renderer-private.h b/cogl/cogl/cogl-renderer-private.h index e64931f5419..8f8aa8ec14e 100644 --- a/cogl/cogl/cogl-renderer-private.h +++ b/cogl/cogl/cogl-renderer-private.h @@ -73,10 +73,6 @@ struct _CoglRenderer typedef CoglFilterReturn (* CoglNativeFilterFunc) (void *native_event, void *data); -CoglFilterReturn -_cogl_renderer_handle_native_event (CoglRenderer *renderer, - void *event); - void _cogl_renderer_add_native_filter (CoglRenderer *renderer, CoglNativeFilterFunc func, diff --git a/cogl/cogl/cogl-renderer.c b/cogl/cogl/cogl-renderer.c index af0f71223f2..7feab4b2052 100644 --- a/cogl/cogl/cogl-renderer.c +++ b/cogl/cogl/cogl-renderer.c @@ -521,8 +521,8 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error) } CoglFilterReturn -_cogl_renderer_handle_native_event (CoglRenderer *renderer, - void *event) +cogl_renderer_handle_event (CoglRenderer *renderer, + void *event) { GSList *l, *next; diff --git a/cogl/cogl/cogl-renderer.h b/cogl/cogl/cogl-renderer.h index e09b55582ba..369011abc59 100644 --- a/cogl/cogl/cogl-renderer.h +++ b/cogl/cogl/cogl-renderer.h @@ -305,4 +305,21 @@ COGL_EXPORT void * cogl_renderer_get_proc_address (CoglRenderer *renderer, const char *name); +/** + * cogl_renderer_handle_event: (skip) + * @renderer: a #CoglRenderer + * @event: pointer to an event structure + * + * Processes a single event. + * + * Return value: #CoglFilterReturn. %COGL_FILTER_REMOVE indicates that + * Cogl has internally handled the event and the caller should do no + * further processing. %COGL_FILTER_CONTINUE indicates that Cogl is + * either not interested in the event, or has used the event to update + * internal state without taking any exclusive action. + */ +COGL_EXPORT CoglFilterReturn +cogl_renderer_handle_event (CoglRenderer *renderer, + void *event); + G_END_DECLS diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index d3517805567..ba76a79c4c5 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -465,13 +465,6 @@ cogl_xlib_renderer_get_display (CoglRenderer *renderer) return xlib_renderer->xdpy; } -CoglFilterReturn -cogl_xlib_renderer_handle_event (CoglRenderer *renderer, - XEvent *event) -{ - return _cogl_renderer_handle_native_event (renderer, event); -} - float _cogl_xlib_renderer_refresh_rate_for_rectangle (CoglRenderer *renderer, int x, diff --git a/cogl/cogl/cogl-xlib-renderer.h b/cogl/cogl/cogl-xlib-renderer.h index 12d18648cef..7c5944c5d21 100644 --- a/cogl/cogl/cogl-xlib-renderer.h +++ b/cogl/cogl/cogl-xlib-renderer.h @@ -35,25 +35,6 @@ G_BEGIN_DECLS -/** - * cogl_xlib_renderer_handle_event: (skip) - * @renderer: a #CoglRenderer - * @event: pointer to an XEvent structure - * - * This function processes a single event; it can be used to hook into - * external event retrieval (for example that done by Clutter or - * GDK). - * - * Return value: #CoglFilterReturn. %COGL_FILTER_REMOVE indicates that - * Cogl has internally handled the event and the caller should do no - * further processing. %COGL_FILTER_CONTINUE indicates that Cogl is - * either not interested in the event, or has used the event to update - * internal state without taking any exclusive action. - */ -COGL_EXPORT CoglFilterReturn -cogl_xlib_renderer_handle_event (CoglRenderer *renderer, - XEvent *event); - /** * cogl_xlib_renderer_set_foreign_display: (skip) * @renderer: a #CoglRenderer @@ -63,7 +44,7 @@ cogl_xlib_renderer_handle_event (CoglRenderer *renderer, * * Note that calling this function will automatically disable Cogl's * event retrieval. Cogl still needs to see all of the X events so the - * application should also use cogl_xlib_renderer_handle_event() if it + * application should also use cogl_renderer_handle_event() if it * uses this function. */ COGL_EXPORT void diff --git a/src/backends/x11/meta-event-x11.c b/src/backends/x11/meta-event-x11.c index 2231851874d..743bf6f2c36 100644 --- a/src/backends/x11/meta-event-x11.c +++ b/src/backends/x11/meta-event-x11.c @@ -59,8 +59,8 @@ meta_backend_x11_handle_event (MetaBackend *backend, allocated_event = XGetEventData (xdisplay, &xevent->xcookie); - if (cogl_xlib_renderer_handle_event (clutter_backend->cogl_renderer, - xevent) == COGL_FILTER_REMOVE) + if (cogl_renderer_handle_event (clutter_backend->cogl_renderer, + xevent) == COGL_FILTER_REMOVE) goto out; stage_x11 = -- GitLab From a05caa63388a7616a01aa3c1fa518a45f6f58d4d Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 15:22:07 +0200 Subject: [PATCH 21/27] cogl/texture2d: Rename from_egl_image constructor Similar to the from_egl_image_external one, to give it the correct namespace Part-of: --- cogl/cogl/cogl-texture-2d.c | 2 +- cogl/cogl/cogl-texture-2d.h | 8 ++++---- cogl/cogl/winsys/cogl-winsys-egl-x11.c | 2 +- src/backends/native/meta-drm-buffer-gbm.c | 2 +- src/backends/native/meta-renderer-native.c | 2 +- src/wayland/meta-wayland-buffer.c | 2 +- src/wayland/meta-wayland-dma-buf.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index b58e9da39b7..d08e53a2dc2 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -455,7 +455,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, * even though they may seem redundant is because GLES 1/2 don't * provide a way to query these properties. */ CoglTexture * -cogl_egl_texture_2d_new_from_image (CoglContext *ctx, +cogl_texture_2d_new_from_egl_image (CoglContext *ctx, int width, int height, CoglPixelFormat format, diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h index 388c18aff83..a88b621007a 100644 --- a/cogl/cogl/cogl-texture-2d.h +++ b/cogl/cogl/cogl-texture-2d.h @@ -202,15 +202,15 @@ typedef gboolean (*CoglTexture2DEGLImageExternalAlloc) (CoglTexture2D *tex_2d, GError **error); #endif -/** - * cogl_egl_texture_2d_new_from_image: (skip) - */ #if defined (HAVE_EGL) && defined (EGL_KHR_image_base) /* NB: The reason we require the width, height and format to be passed * even though they may seem redundant is because GLES 1/2 don't * provide a way to query these properties. */ +/** + * cogl_texture_2d_new_from_egl_image: (skip) + */ COGL_EXPORT CoglTexture * -cogl_egl_texture_2d_new_from_image (CoglContext *ctx, +cogl_texture_2d_new_from_egl_image (CoglContext *ctx, int width, int height, CoglPixelFormat format, diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c index 7de343d6a2f..588d77b2b2b 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c @@ -490,7 +490,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap) COGL_PIXEL_FORMAT_RGB_888); egl_tex_pixmap->texture = - cogl_egl_texture_2d_new_from_image (ctx, + cogl_texture_2d_new_from_egl_image (ctx, cogl_texture_get_width (tex), cogl_texture_get_height (tex), texture_format, diff --git a/src/backends/native/meta-drm-buffer-gbm.c b/src/backends/native/meta-drm-buffer-gbm.c index 4ca8fb0f462..01963cd7546 100644 --- a/src/backends/native/meta-drm-buffer-gbm.c +++ b/src/backends/native/meta-drm-buffer-gbm.c @@ -318,7 +318,7 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout, } flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA; - cogl_tex = cogl_egl_texture_2d_new_from_image (cogl_context, + cogl_tex = cogl_texture_2d_new_from_egl_image (cogl_context, width, height, cogl_format, diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 8b23e4cc332..786f57a935b 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -680,7 +680,7 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n return NULL; flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA; - cogl_tex = cogl_egl_texture_2d_new_from_image (cogl_context, + cogl_tex = cogl_texture_2d_new_from_egl_image (cogl_context, width, height, cogl_format, diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c index ad01a1d852a..d21d4bef2f0 100644 --- a/src/wayland/meta-wayland-buffer.c +++ b/src/wayland/meta-wayland-buffer.c @@ -539,7 +539,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer, return FALSE; flags = COGL_EGL_IMAGE_FLAG_NONE; - texture_2d = cogl_egl_texture_2d_new_from_image (cogl_context, + texture_2d = cogl_texture_2d_new_from_egl_image (cogl_context, width, height, cogl_format, egl_image, diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index 1f8f0fac155..8a2b0ec6601 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -426,7 +426,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, return FALSE; flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA; - cogl_texture = cogl_egl_texture_2d_new_from_image (cogl_context, + cogl_texture = cogl_texture_2d_new_from_egl_image (cogl_context, dma_buf->width, dma_buf->height, cogl_format, @@ -488,7 +488,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, return FALSE; flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA; - cogl_texture = cogl_egl_texture_2d_new_from_image (cogl_context, + cogl_texture = cogl_texture_2d_new_from_egl_image (cogl_context, dma_buf->width, dma_buf->height, subformat, -- GitLab From beb9ecdbc430802152afd27d68ca03afb8dc44f3 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 15:22:43 +0200 Subject: [PATCH 22/27] cogl: Remove no longer useful Since annotation Spotted in previous commit Part-of: --- cogl/cogl/cogl-texture-2d.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h index a88b621007a..a276037cb3d 100644 --- a/cogl/cogl/cogl-texture-2d.h +++ b/cogl/cogl/cogl-texture-2d.h @@ -97,8 +97,6 @@ typedef enum _CoglEglImageFlags * cogl_texture_set_premultiplied(). * * Returns: (transfer full): A new #CoglTexture2D object with no storage yet allocated. - * - * Since: 2.0 */ COGL_EXPORT CoglTexture * cogl_texture_2d_new_with_format (CoglContext *ctx, -- GitLab From 2d25b114e612410190adb1c32617209ded45fe28 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 28 Jul 2024 17:06:43 +0200 Subject: [PATCH 23/27] cogl/buffer: Use set_data helper That ignores the error param, which is the behaviour we always had. Changing that to propagate the error would make the API ugly, so it is fine to remove? Part-of: --- cogl/cogl/cogl-attribute-buffer.c | 9 ++++----- cogl/cogl/cogl-buffer-private.h | 7 ------- cogl/cogl/cogl-buffer.c | 33 +++++++++++-------------------- cogl/cogl/cogl-indices.c | 15 +++++--------- cogl/cogl/cogl-pixel-buffer.c | 31 ++++++++--------------------- 5 files changed, 29 insertions(+), 66 deletions(-) diff --git a/cogl/cogl/cogl-attribute-buffer.c b/cogl/cogl/cogl-attribute-buffer.c index ee89e500ab3..9b33a2a059b 100644 --- a/cogl/cogl/cogl-attribute-buffer.c +++ b/cogl/cogl/cogl-attribute-buffer.c @@ -86,11 +86,10 @@ cogl_attribute_buffer_new (CoglContext *context, /* XXX: NB: for Cogl 2.0 we don't allow NULL data here but we can't * break the api for 1.x and so we keep the check for now. */ if (data) - _cogl_buffer_set_data (COGL_BUFFER (buffer), - 0, - data, - bytes, - NULL); + cogl_buffer_set_data (COGL_BUFFER (buffer), + 0, + data, + bytes); return buffer; } diff --git a/cogl/cogl/cogl-buffer-private.h b/cogl/cogl/cogl-buffer-private.h index a08d62592b7..bebc18f4159 100644 --- a/cogl/cogl/cogl-buffer-private.h +++ b/cogl/cogl/cogl-buffer-private.h @@ -90,13 +90,6 @@ struct _CoglBufferClass GObjectClass parent_class; }; -gboolean -_cogl_buffer_set_data (CoglBuffer *buffer, - size_t offset, - const void *data, - size_t size, - GError **error); - void * _cogl_buffer_map (CoglBuffer *buffer, CoglBufferAccess access, diff --git a/cogl/cogl/cogl-buffer.c b/cogl/cogl/cogl-buffer.c index 166e51afb3d..8c258e024a4 100644 --- a/cogl/cogl/cogl-buffer.c +++ b/cogl/cogl/cogl-buffer.c @@ -365,11 +365,10 @@ _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer) * smaller buffers, though that would probably not help for * deferred renderers. */ - _cogl_buffer_set_data (buffer, - ctx->buffer_map_fallback_offset, - ctx->buffer_map_fallback_array->data, - ctx->buffer_map_fallback_array->len, - NULL); + cogl_buffer_set_data (buffer, + ctx->buffer_map_fallback_offset, + ctx->buffer_map_fallback_array->data, + ctx->buffer_map_fallback_array->len); buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED_FALLBACK; } else @@ -377,27 +376,19 @@ _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer) } gboolean -_cogl_buffer_set_data (CoglBuffer *buffer, - size_t offset, - const void *data, - size_t size, - GError **error) +cogl_buffer_set_data (CoglBuffer *buffer, + size_t offset, + const void *data, + size_t size) { + GError *ignore_error = NULL; + gboolean status; + g_return_val_if_fail (COGL_IS_BUFFER (buffer), FALSE); g_return_val_if_fail ((offset + size) <= buffer->size, FALSE); - return buffer->set_data (buffer, offset, data, size, error); -} + status = buffer->set_data (buffer, offset, data, size, &ignore_error); -gboolean -cogl_buffer_set_data (CoglBuffer *buffer, - size_t offset, - const void *data, - size_t size) -{ - GError *ignore_error = NULL; - gboolean status = - _cogl_buffer_set_data (buffer, offset, data, size, &ignore_error); g_clear_error (&ignore_error); return status; } diff --git a/cogl/cogl/cogl-indices.c b/cogl/cogl/cogl-indices.c index 3697a075fc2..1989d8af66b 100644 --- a/cogl/cogl/cogl-indices.c +++ b/cogl/cogl/cogl-indices.c @@ -107,16 +107,12 @@ cogl_indices_new (CoglContext *context, CoglIndexBuffer *index_buffer = cogl_index_buffer_new (context, buffer_bytes); CoglBuffer *buffer = COGL_BUFFER (index_buffer); CoglIndices *indices; - GError *ignore_error = NULL; - - _cogl_buffer_set_data (buffer, - 0, - indices_data, - buffer_bytes, - &ignore_error); - if (ignore_error) + + if (!cogl_buffer_set_data (buffer, + 0, + indices_data, + buffer_bytes)) { - g_error_free (ignore_error); g_object_unref (index_buffer); return NULL; } @@ -240,4 +236,3 @@ cogl_get_rectangle_indices (CoglContext *ctx, int n_rectangles) return ctx->rectangle_short_indices; } } - diff --git a/cogl/cogl/cogl-pixel-buffer.c b/cogl/cogl/cogl-pixel-buffer.c index 39246093340..660841919d8 100644 --- a/cogl/cogl/cogl-pixel-buffer.c +++ b/cogl/cogl/cogl-pixel-buffer.c @@ -61,11 +61,10 @@ cogl_pixel_buffer_init (CoglPixelBuffer *buffer) { } -static CoglPixelBuffer * -_cogl_pixel_buffer_new (CoglContext *context, - size_t size, - const void *data, - GError **error) +CoglPixelBuffer * +cogl_pixel_buffer_new (CoglContext *context, + size_t size, + const void *data) { CoglPixelBuffer *pixel_buffer; @@ -78,11 +77,10 @@ _cogl_pixel_buffer_new (CoglContext *context, if (data) { - if (!_cogl_buffer_set_data (COGL_BUFFER (pixel_buffer), - 0, - data, - size, - error)) + if (!cogl_buffer_set_data (COGL_BUFFER (pixel_buffer), + 0, + data, + size)) { g_object_unref (pixel_buffer); return NULL; @@ -91,16 +89,3 @@ _cogl_pixel_buffer_new (CoglContext *context, return pixel_buffer; } - -CoglPixelBuffer * -cogl_pixel_buffer_new (CoglContext *context, - size_t size, - const void *data) -{ - GError *ignore_error = NULL; - CoglPixelBuffer *buffer = - _cogl_pixel_buffer_new (context, size, data, &ignore_error); - - g_clear_error (&ignore_error); - return buffer; -} -- GitLab From a71ad8e861d3eeecbd51b1c917fe9ce59576cc20 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 31 Jul 2024 13:27:29 +0200 Subject: [PATCH 24/27] cogl/list: Remove unused API Ideally, I think we might have to replace CoglList usage as the over-complicated macros makes it hard to parse But that is a task for another day Part-of: --- cogl/cogl/cogl-list.c | 17 ----------------- cogl/cogl/cogl-list.h | 3 --- 2 files changed, 20 deletions(-) diff --git a/cogl/cogl/cogl-list.c b/cogl/cogl/cogl-list.c index 91f86b5cf13..adb1d40b3c9 100644 --- a/cogl/cogl/cogl-list.c +++ b/cogl/cogl/cogl-list.c @@ -55,23 +55,6 @@ _cogl_list_remove (CoglList *elm) elm->prev = NULL; } -int -_cogl_list_length (CoglList *list) -{ - CoglList *e; - int count; - - count = 0; - e = list->next; - while (e != list) - { - e = e->next; - count++; - } - - return count; -} - int _cogl_list_empty (CoglList *list) { diff --git a/cogl/cogl/cogl-list.h b/cogl/cogl/cogl-list.h index dff9f3946e2..ffa221892bc 100644 --- a/cogl/cogl/cogl-list.h +++ b/cogl/cogl/cogl-list.h @@ -75,9 +75,6 @@ _cogl_list_insert (CoglList *list, void _cogl_list_remove (CoglList *elm); -int -_cogl_list_length (CoglList *list); - int _cogl_list_empty (CoglList *list); -- GitLab From 609f7e3fe1187ab32fac8c8a7a6e049fa06a5fd4 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 31 Jul 2024 13:30:07 +0200 Subject: [PATCH 25/27] cogl: Remove unused OnScreenTemplate.set_samples_per_pixel Not sure if we want to keep that env variable around Part-of: --- cogl/cogl/cogl-onscreen-template.c | 8 -------- cogl/cogl/cogl-onscreen-template.h | 19 ------------------- 2 files changed, 27 deletions(-) diff --git a/cogl/cogl/cogl-onscreen-template.c b/cogl/cogl/cogl-onscreen-template.c index 0f25355273f..adb146421c8 100644 --- a/cogl/cogl/cogl-onscreen-template.c +++ b/cogl/cogl/cogl-onscreen-template.c @@ -69,14 +69,6 @@ cogl_onscreen_template_new (void) return onscreen_template; } -void -cogl_onscreen_template_set_samples_per_pixel ( - CoglOnscreenTemplate *onscreen_template, - int samples_per_pixel) -{ - onscreen_template->config.samples_per_pixel = samples_per_pixel; -} - void cogl_onscreen_template_set_stereo_enabled ( CoglOnscreenTemplate *onscreen_template, diff --git a/cogl/cogl/cogl-onscreen-template.h b/cogl/cogl/cogl-onscreen-template.h index baf110ab983..4edfcb426c6 100644 --- a/cogl/cogl/cogl-onscreen-template.h +++ b/cogl/cogl/cogl-onscreen-template.h @@ -51,25 +51,6 @@ G_DECLARE_FINAL_TYPE (CoglOnscreenTemplate, cogl_onscreen_template, COGL_EXPORT CoglOnscreenTemplate * cogl_onscreen_template_new (void); -/** - * cogl_onscreen_template_set_samples_per_pixel: - * @onscreen_template: A #CoglOnscreenTemplate template framebuffer - * @n: The minimum number of samples per pixel - * - * Requires that any future CoglOnscreen framebuffers derived from - * this template must support making at least @n samples per pixel - * which will all contribute to the final resolved color for that - * pixel. - * - * By default this value is usually set to 0 and that is referred to - * as "single-sample" rendering. A value of 1 or greater is referred - * to as "multisample" rendering. - */ -COGL_EXPORT void -cogl_onscreen_template_set_samples_per_pixel ( - CoglOnscreenTemplate *onscreen_template, - int n); - /** * cogl_onscreen_template_set_stereo_enabled: * @onscreen_template: A #CoglOnscreenTemplate template framebuffer -- GitLab From e43d9d7e756c59095363263afc6f251f2df87304 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 31 Jul 2024 17:06:55 +0200 Subject: [PATCH 26/27] cogl/indices: Add a IndicesType.get_size To de-duplicate that code Part-of: --- cogl/cogl/cogl-indices-private.h | 3 +++ cogl/cogl/cogl-indices.c | 6 +++--- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 18 ++---------------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/cogl/cogl/cogl-indices-private.h b/cogl/cogl/cogl-indices-private.h index b3d9239192f..b9760d58a34 100644 --- a/cogl/cogl/cogl-indices-private.h +++ b/cogl/cogl/cogl-indices-private.h @@ -46,3 +46,6 @@ struct _CoglIndices CoglIndicesType type; }; + +size_t +cogl_indices_type_get_size (CoglIndicesType type); diff --git a/cogl/cogl/cogl-indices.c b/cogl/cogl/cogl-indices.c index 1989d8af66b..0bfd3a3b9a7 100644 --- a/cogl/cogl/cogl-indices.c +++ b/cogl/cogl/cogl-indices.c @@ -67,8 +67,8 @@ cogl_indices_class_init (CoglIndicesClass *class) object_class->dispose = cogl_indices_dispose; } -static size_t -sizeof_indices_type (CoglIndicesType type) +size_t +cogl_indices_type_get_size (CoglIndicesType type) { switch (type) { @@ -103,7 +103,7 @@ cogl_indices_new (CoglContext *context, const void *indices_data, int n_indices) { - size_t buffer_bytes = sizeof_indices_type (type) * n_indices; + size_t buffer_bytes = cogl_indices_type_get_size (type) * n_indices; CoglIndexBuffer *index_buffer = cogl_index_buffer_new (context, buffer_bytes); CoglBuffer *buffer = COGL_BUFFER (index_buffer); CoglIndices *indices; diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index 36edc4cdbb4..8c80d9a25e3 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -34,6 +34,7 @@ #include "cogl/cogl-context-private.h" #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-framebuffer.h" +#include "cogl/cogl-indices-private.h" #include "cogl/cogl-offscreen-private.h" #include "cogl/cogl-texture-private.h" #include "cogl/driver/gl/cogl-util-gl-private.h" @@ -324,21 +325,6 @@ cogl_gl_framebuffer_draw_attributes (CoglFramebufferDriver *driver, glDrawArrays ((GLenum)mode, first_vertex, n_vertices)); } -static size_t -sizeof_index_type (CoglIndicesType type) -{ - switch (type) - { - case COGL_INDICES_TYPE_UNSIGNED_BYTE: - return 1; - case COGL_INDICES_TYPE_UNSIGNED_SHORT: - return 2; - case COGL_INDICES_TYPE_UNSIGNED_INT: - return 4; - } - g_return_val_if_reached (0); -} - static void cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver, CoglPipeline *pipeline, @@ -371,7 +357,7 @@ cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver, base = _cogl_buffer_gl_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER, NULL); buffer_offset = cogl_indices_get_offset (indices); - index_size = sizeof_index_type (cogl_indices_get_indices_type (indices)); + index_size = cogl_indices_type_get_size (cogl_indices_get_indices_type (indices)); switch (cogl_indices_get_indices_type (indices)) { -- GitLab From b9269abaf5ff2dd8a66477c8f70a2f106921976e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 1 Aug 2024 10:59:03 +0200 Subject: [PATCH 27/27] cogl: Remove unused Error types Part-of: --- cogl/cogl/cogl-bitmap.c | 6 ------ cogl/cogl/cogl-bitmap.h | 27 --------------------------- cogl/cogl/cogl-buffer.h | 18 ------------------ 3 files changed, 51 deletions(-) diff --git a/cogl/cogl/cogl-bitmap.c b/cogl/cogl/cogl-bitmap.c index 4cec61f7c28..3025c416df9 100644 --- a/cogl/cogl/cogl-bitmap.c +++ b/cogl/cogl/cogl-bitmap.c @@ -372,12 +372,6 @@ cogl_bitmap_get_buffer (CoglBitmap *bitmap) return COGL_PIXEL_BUFFER (bitmap->buffer); } -uint32_t -cogl_bitmap_error_quark (void) -{ - return g_quark_from_static_string ("cogl-bitmap-error-quark"); -} - uint8_t * _cogl_bitmap_map (CoglBitmap *bitmap, CoglBufferAccess access, diff --git a/cogl/cogl/cogl-bitmap.h b/cogl/cogl/cogl-bitmap.h index c9a35f69f13..bca72f7fada 100644 --- a/cogl/cogl/cogl-bitmap.h +++ b/cogl/cogl/cogl-bitmap.h @@ -197,31 +197,4 @@ cogl_bitmap_get_rowstride (CoglBitmap *bitmap); COGL_EXPORT CoglPixelBuffer * cogl_bitmap_get_buffer (CoglBitmap *bitmap); -/** - * COGL_BITMAP_ERROR: - * - * #GError domain for bitmap errors. - */ -#define COGL_BITMAP_ERROR (cogl_bitmap_error_quark ()) - -/** - * CoglBitmapError: - * @COGL_BITMAP_ERROR_FAILED: Generic failure code, something went - * wrong. - * @COGL_BITMAP_ERROR_UNKNOWN_TYPE: Unknown image type. - * @COGL_BITMAP_ERROR_CORRUPT_IMAGE: An image file was broken somehow. - * - * Error codes that can be thrown when performing bitmap - * operations. - */ -typedef enum -{ - COGL_BITMAP_ERROR_FAILED, - COGL_BITMAP_ERROR_UNKNOWN_TYPE, - COGL_BITMAP_ERROR_CORRUPT_IMAGE -} CoglBitmapError; - -COGL_EXPORT -uint32_t cogl_bitmap_error_quark (void); - G_END_DECLS diff --git a/cogl/cogl/cogl-buffer.h b/cogl/cogl/cogl-buffer.h index c73cfad064d..a0b37455de0 100644 --- a/cogl/cogl/cogl-buffer.h +++ b/cogl/cogl/cogl-buffer.h @@ -79,24 +79,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglBuffer, g_object_unref) COGL_EXPORT GType cogl_buffer_get_type (void) G_GNUC_CONST; -#define COGL_BUFFER_ERROR (_cogl_buffer_error_domain ()) - -/** - * CoglBufferError: - * @COGL_BUFFER_ERROR_MAP: A buffer could not be mapped either - * because the feature isn't supported or because a system - * limitation was hit. - * - * Error enumeration for #CoglBuffer - */ -typedef enum /*< prefix=COGL_BUFFER_ERROR >*/ -{ - COGL_BUFFER_ERROR_MAP -} CoglBufferError; - -uint32_t -_cogl_buffer_error_domain (void); - /** * cogl_buffer_get_size: * @buffer: a buffer object -- GitLab