From 0064bf240ec7867c91cb88e8e595deaa035c3da4 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 14 Jun 2024 21:16:05 +0200 Subject: [PATCH] cogl: Remove unused immutable_ref Part-of: --- cogl/cogl/cogl-attribute-private.h | 8 ---- cogl/cogl/cogl-attribute.c | 41 -------------------- cogl/cogl/cogl-buffer-private.h | 8 ---- cogl/cogl/cogl-buffer.c | 39 ------------------- cogl/cogl/cogl-indices-private.h | 7 ---- cogl/cogl/cogl-indices.c | 37 ------------------ cogl/cogl/cogl-primitive-private.h | 8 ---- cogl/cogl/cogl-primitive.c | 60 ------------------------------ 8 files changed, 208 deletions(-) diff --git a/cogl/cogl/cogl-attribute-private.h b/cogl/cogl/cogl-attribute-private.h index ffb0596a4..5712065c0 100644 --- a/cogl/cogl/cogl-attribute-private.h +++ b/cogl/cogl/cogl-attribute-private.h @@ -78,8 +78,6 @@ struct _CoglAttribute CoglBoxedValue boxed; } constant; } d; - - int immutable_ref; }; typedef enum @@ -109,12 +107,6 @@ CoglAttributeNameState * _cogl_attribute_register_attribute_name (CoglContext *context, const char *name); -CoglAttribute * -_cogl_attribute_immutable_ref (CoglAttribute *attribute); - -void -_cogl_attribute_immutable_unref (CoglAttribute *attribute); - typedef struct { int unit; diff --git a/cogl/cogl/cogl-attribute.c b/cogl/cogl/cogl-attribute.c index eb94ee4f6..eb594ad7d 100644 --- a/cogl/cogl/cogl-attribute.c +++ b/cogl/cogl/cogl-attribute.c @@ -235,8 +235,6 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer, attribute->d.buffered.n_components = n_components; attribute->d.buffered.type = type; - attribute->immutable_ref = 0; - if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY) { if (!validate_n_components (attribute->name_state, n_components)) @@ -254,27 +252,12 @@ error: return NULL; } -static void -warn_about_midscene_changes (void) -{ - static gboolean seen = FALSE; - if (!seen) - { - g_warning ("Mid-scene modification of attributes has " - "undefined results\n"); - seen = TRUE; - } -} - void cogl_attribute_set_normalized (CoglAttribute *attribute, gboolean normalized) { g_return_if_fail (COGL_IS_ATTRIBUTE (attribute)); - if (G_UNLIKELY (attribute->immutable_ref)) - warn_about_midscene_changes (); - attribute->normalized = normalized; } @@ -287,30 +270,6 @@ cogl_attribute_get_buffer (CoglAttribute *attribute) return attribute->d.buffered.attribute_buffer; } -CoglAttribute * -_cogl_attribute_immutable_ref (CoglAttribute *attribute) -{ - CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer); - - g_return_val_if_fail (COGL_IS_ATTRIBUTE (attribute), NULL); - - attribute->immutable_ref++; - _cogl_buffer_immutable_ref (buffer); - return attribute; -} - -void -_cogl_attribute_immutable_unref (CoglAttribute *attribute) -{ - CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer); - - g_return_if_fail (COGL_IS_ATTRIBUTE (attribute)); - g_return_if_fail (attribute->immutable_ref > 0); - - attribute->immutable_ref--; - _cogl_buffer_immutable_unref (buffer); -} - static gboolean validate_layer_cb (CoglPipeline *pipeline, int layer_index, diff --git a/cogl/cogl/cogl-buffer-private.h b/cogl/cogl/cogl-buffer-private.h index 6d37368cb..a08d62592 100644 --- a/cogl/cogl/cogl-buffer-private.h +++ b/cogl/cogl/cogl-buffer-private.h @@ -68,8 +68,6 @@ struct _CoglBuffer * ... or points to allocated memory in the fallback paths */ uint8_t *data; - int immutable_ref; - unsigned int store_created : 1; void * (* map_range) (CoglBuffer *buffer, @@ -92,12 +90,6 @@ struct _CoglBufferClass GObjectClass parent_class; }; -CoglBuffer * -_cogl_buffer_immutable_ref (CoglBuffer *buffer); - -void -_cogl_buffer_immutable_unref (CoglBuffer *buffer); - gboolean _cogl_buffer_set_data (CoglBuffer *buffer, size_t offset, diff --git a/cogl/cogl/cogl-buffer.c b/cogl/cogl/cogl-buffer.c index 807382c6e..166e51afb 100644 --- a/cogl/cogl/cogl-buffer.c +++ b/cogl/cogl/cogl-buffer.c @@ -104,7 +104,6 @@ cogl_buffer_dispose (GObject *object) CoglBuffer *buffer = COGL_BUFFER (object); g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); - g_return_if_fail (buffer->immutable_ref == 0); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) buffer->context->driver_vtable->buffer_destroy (buffer); @@ -217,7 +216,6 @@ cogl_buffer_init (CoglBuffer *buffer) buffer->flags = COGL_BUFFER_FLAG_NONE; buffer->store_created = FALSE; buffer->data = NULL; - buffer->immutable_ref = 0; } unsigned int @@ -249,18 +247,6 @@ cogl_buffer_get_update_hint (CoglBuffer *buffer) return buffer->update_hint; } -static void -warn_about_midscene_changes (void) -{ - static gboolean seen = FALSE; - if (!seen) - { - g_warning ("Mid-scene modification of buffers has " - "undefined results\n"); - seen = TRUE; - } -} - void * _cogl_buffer_map (CoglBuffer *buffer, CoglBufferAccess access, @@ -296,9 +282,6 @@ cogl_buffer_map_range (CoglBuffer *buffer, g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL); g_return_val_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED), NULL); - if (G_UNLIKELY (buffer->immutable_ref)) - warn_about_midscene_changes (); - buffer->data = buffer->map_range (buffer, offset, size, @@ -403,9 +386,6 @@ _cogl_buffer_set_data (CoglBuffer *buffer, g_return_val_if_fail (COGL_IS_BUFFER (buffer), FALSE); g_return_val_if_fail ((offset + size) <= buffer->size, FALSE); - if (G_UNLIKELY (buffer->immutable_ref)) - warn_about_midscene_changes (); - return buffer->set_data (buffer, offset, data, size, error); } @@ -421,22 +401,3 @@ cogl_buffer_set_data (CoglBuffer *buffer, g_clear_error (&ignore_error); return status; } - -CoglBuffer * -_cogl_buffer_immutable_ref (CoglBuffer *buffer) -{ - g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL); - - buffer->immutable_ref++; - return buffer; -} - -void -_cogl_buffer_immutable_unref (CoglBuffer *buffer) -{ - g_return_if_fail (COGL_IS_BUFFER (buffer)); - g_return_if_fail (buffer->immutable_ref > 0); - - buffer->immutable_ref--; -} - diff --git a/cogl/cogl/cogl-indices-private.h b/cogl/cogl/cogl-indices-private.h index d50c57cbc..b3d923919 100644 --- a/cogl/cogl/cogl-indices-private.h +++ b/cogl/cogl/cogl-indices-private.h @@ -45,11 +45,4 @@ struct _CoglIndices CoglIndicesType type; - int immutable_ref; }; - -CoglIndices * -_cogl_indices_immutable_ref (CoglIndices *indices); - -void -_cogl_indices_immutable_unref (CoglIndices *indices); diff --git a/cogl/cogl/cogl-indices.c b/cogl/cogl/cogl-indices.c index 55a27b481..3697a075f 100644 --- a/cogl/cogl/cogl-indices.c +++ b/cogl/cogl/cogl-indices.c @@ -94,8 +94,6 @@ cogl_indices_new_for_buffer (CoglIndicesType type, indices->type = type; - indices->immutable_ref = 0; - return indices; } @@ -151,50 +149,15 @@ cogl_indices_get_offset (CoglIndices *indices) return indices->offset; } -static void -warn_about_midscene_changes (void) -{ - static gboolean seen = FALSE; - if (!seen) - { - g_warning ("Mid-scene modification of indices has " - "undefined results\n"); - seen = TRUE; - } -} - void cogl_indices_set_offset (CoglIndices *indices, size_t offset) { g_return_if_fail (COGL_IS_INDICES (indices)); - if (G_UNLIKELY (indices->immutable_ref)) - warn_about_midscene_changes (); - indices->offset = offset; } -CoglIndices * -_cogl_indices_immutable_ref (CoglIndices *indices) -{ - g_return_val_if_fail (COGL_IS_INDICES (indices), NULL); - - indices->immutable_ref++; - _cogl_buffer_immutable_ref (COGL_BUFFER (indices->buffer)); - return indices; -} - -void -_cogl_indices_immutable_unref (CoglIndices *indices) -{ - g_return_if_fail (COGL_IS_INDICES (indices)); - g_return_if_fail (indices->immutable_ref > 0); - - indices->immutable_ref--; - _cogl_buffer_immutable_unref (COGL_BUFFER (indices->buffer)); -} - CoglIndices * cogl_get_rectangle_indices (CoglContext *ctx, int n_rectangles) { diff --git a/cogl/cogl/cogl-primitive-private.h b/cogl/cogl/cogl-primitive-private.h index 64ef89033..f2b99d5e5 100644 --- a/cogl/cogl/cogl-primitive-private.h +++ b/cogl/cogl/cogl-primitive-private.h @@ -46,18 +46,10 @@ struct _CoglPrimitive int first_vertex; int n_vertices; - int immutable_ref; - GPtrArray *attributes; int n_attributes; }; -CoglPrimitive * -_cogl_primitive_immutable_ref (CoglPrimitive *primitive); - -void -_cogl_primitive_immutable_unref (CoglPrimitive *primitive); - void _cogl_primitive_draw (CoglPrimitive *primitive, CoglFramebuffer *framebuffer, diff --git a/cogl/cogl/cogl-primitive.c b/cogl/cogl/cogl-primitive.c index d31eeebd8..0a3548734 100644 --- a/cogl/cogl/cogl-primitive.c +++ b/cogl/cogl/cogl-primitive.c @@ -69,7 +69,6 @@ static void cogl_primitive_init (CoglPrimitive *primitive) { primitive->first_vertex = 0; - primitive->immutable_ref = 0; primitive->indices = NULL; primitive->attributes = g_ptr_array_new_with_free_func (g_object_unref); } @@ -394,18 +393,6 @@ cogl_primitive_new_p3t2c4 (CoglContext *ctx, 3); } -static void -warn_about_midscene_changes (void) -{ - static gboolean seen = FALSE; - if (!seen) - { - g_warning ("Mid-scene modification of primitives has " - "undefined results\n"); - seen = TRUE; - } -} - int cogl_primitive_get_first_vertex (CoglPrimitive *primitive) { @@ -420,12 +407,6 @@ cogl_primitive_set_first_vertex (CoglPrimitive *primitive, { g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); - if (G_UNLIKELY (primitive->immutable_ref)) - { - warn_about_midscene_changes (); - return; - } - primitive->first_vertex = first_vertex; } @@ -460,12 +441,6 @@ cogl_primitive_set_mode (CoglPrimitive *primitive, { g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); - if (G_UNLIKELY (primitive->immutable_ref)) - { - warn_about_midscene_changes (); - return; - } - primitive->mode = mode; } @@ -476,12 +451,6 @@ cogl_primitive_set_indices (CoglPrimitive *primitive, { g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); - if (G_UNLIKELY (primitive->immutable_ref)) - { - warn_about_midscene_changes (); - return; - } - if (indices) g_object_ref (indices); if (primitive->indices) @@ -512,35 +481,6 @@ cogl_primitive_copy (CoglPrimitive *primitive) return copy; } -CoglPrimitive * -_cogl_primitive_immutable_ref (CoglPrimitive *primitive) -{ - int i; - - g_return_val_if_fail (COGL_IS_PRIMITIVE (primitive), NULL); - - primitive->immutable_ref++; - - for (i = 0; i < primitive->n_attributes; i++) - _cogl_attribute_immutable_ref (primitive->attributes->pdata[i]); - - return primitive; -} - -void -_cogl_primitive_immutable_unref (CoglPrimitive *primitive) -{ - int i; - - g_return_if_fail (COGL_IS_PRIMITIVE (primitive)); - g_return_if_fail (primitive->immutable_ref > 0); - - primitive->immutable_ref--; - - for (i = 0; i < primitive->n_attributes; i++) - _cogl_attribute_immutable_unref (primitive->attributes->pdata[i]); -} - void cogl_primitive_foreach_attribute (CoglPrimitive *primitive, CoglPrimitiveAttributeCallback callback,