1
0
Fork 0

cogl: Remove cogl_handle_ref/unref

This is for all intents and purposes the same as
`cogl_object_ref/unref`, but still refers to handles rather than
objects (while we're trying to get rid of the former) so it's a bit of
unnecessary redundant API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
This commit is contained in:
Niels De Graef 2019-02-20 14:51:12 +01:00 committed by Jonas Ådahl
parent 317ce05a27
commit 23f77a1b63
35 changed files with 81 additions and 116 deletions

View file

@ -100,13 +100,13 @@
* // Clear the previous state //
* if (self->rect_1)
* {
* cogl_handle_unref (self->rect_1);
* cogl_object_unref (self->rect_1);
* self->rect_1 = NULL;
* }
*
* if (self->rect_2)
* {
* cogl_handle_unref (self->rect_2);
* cogl_object_unref (self->rect_2);
* self->rect_2 = NULL;
* }
*

View file

@ -119,7 +119,7 @@ clutter_offscreen_effect_set_actor (ClutterActorMeta *meta,
/* clear out the previous state */
if (priv->offscreen != NULL)
{
cogl_handle_unref (priv->offscreen);
cogl_object_unref (priv->offscreen);
priv->offscreen = NULL;
}
@ -199,13 +199,13 @@ update_fbo (ClutterEffect *effect,
if (priv->texture != NULL)
{
cogl_handle_unref (priv->texture);
cogl_object_unref (priv->texture);
priv->texture = NULL;
}
if (priv->offscreen != NULL)
{
cogl_handle_unref (priv->offscreen);
cogl_object_unref (priv->offscreen);
priv->offscreen = NULL;
}
@ -224,7 +224,7 @@ update_fbo (ClutterEffect *effect,
{
g_warning ("%s: Unable to create an Offscreen buffer", G_STRLOC);
cogl_handle_unref (priv->target);
cogl_object_unref (priv->target);
priv->target = NULL;
priv->target_width = 0;
@ -487,13 +487,13 @@ clutter_offscreen_effect_finalize (GObject *gobject)
ClutterOffscreenEffectPrivate *priv = self->priv;
if (priv->offscreen)
cogl_handle_unref (priv->offscreen);
cogl_object_unref (priv->offscreen);
if (priv->target)
cogl_handle_unref (priv->target);
cogl_object_unref (priv->target);
if (priv->texture)
cogl_handle_unref (priv->texture);
cogl_object_unref (priv->texture);
G_OBJECT_CLASS (clutter_offscreen_effect_parent_class)->finalize (gobject);
}

View file

@ -179,14 +179,14 @@ clutter_shader_effect_clear (ClutterShaderEffect *self,
if (priv->shader != COGL_INVALID_HANDLE)
{
cogl_handle_unref (priv->shader);
cogl_object_unref (priv->shader);
priv->shader = COGL_INVALID_HANDLE;
}
if (priv->program != COGL_INVALID_HANDLE)
{
cogl_handle_unref (priv->program);
cogl_object_unref (priv->program);
priv->program = COGL_INVALID_HANDLE;
}
@ -387,10 +387,10 @@ clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
}
}
priv->shader = cogl_handle_ref (class_priv->shader);
priv->shader = cogl_object_ref (class_priv->shader);
if (class_priv->program != COGL_INVALID_HANDLE)
priv->program = cogl_handle_ref (class_priv->program);
priv->program = cogl_object_ref (class_priv->program);
}
}

View file

@ -507,7 +507,7 @@ clutter_cairo_texture_create_surface (ClutterCairoTexture *self,
cairo_stride,
cairo_data);
clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (self), cogl_texture);
cogl_handle_unref (cogl_texture);
cogl_object_unref (cogl_texture);
return surface;
}

View file

@ -1229,7 +1229,7 @@ clutter_texture_get_cogl_material (ClutterTexture *texture)
* Replaces the underlying Cogl material drawn by this actor with
* @cogl_material. A reference to the material is taken so if the
* handle is no longer needed it should be deref'd with
* cogl_handle_unref. Texture data is attached to the material so
* cogl_object_unref. Texture data is attached to the material so
* calling this function also replaces the Cogl
* texture. #ClutterTexture requires that the material have a texture
* layer so you should set one on the material before calling this
@ -1302,7 +1302,7 @@ get_first_layer_index (CoglPipeline *pipeline, int *layer_index)
*
* Retrieves the handle to the underlying COGL texture used for drawing
* the actor. No extra reference is taken so if you need to keep the
* handle then you should call cogl_handle_ref() on it.
* handle then you should call cogl_object_ref() on it.
*
* The texture handle returned is the first layer of the material
* handle used by the #ClutterTexture. If you need to access the other
@ -1342,7 +1342,7 @@ clutter_texture_get_cogl_texture (ClutterTexture *texture)
*
* Replaces the underlying COGL texture drawn by this actor with
* @cogl_tex. A reference to the texture is taken so if the handle is
* no longer needed it should be deref'd with cogl_handle_unref.
* no longer needed it should be deref'd with cogl_object_unref.
*
* Since: 0.8
*

View file

@ -432,7 +432,7 @@ _cogl_context_free (CoglContext *context)
_cogl_free_framebuffer_stack (context->framebuffer_stack);
if (context->current_path)
cogl_handle_unref (context->current_path);
cogl_object_unref (context->current_path);
if (context->default_gl_texture_2d_tex)
cogl_object_unref (context->default_gl_texture_2d_tex);

View file

@ -253,7 +253,7 @@ cogl_##type_name##_ref (void *object) \
\
_COGL_OBJECT_DEBUG_REF (TypeName, object); \
\
cogl_handle_ref (object); \
cogl_object_ref (object); \
\
return object; \
} \
@ -271,7 +271,7 @@ cogl_##type_name##_unref (void *object) \
\
_COGL_OBJECT_DEBUG_UNREF (TypeName, object); \
\
cogl_handle_unref (object); \
cogl_object_unref (object); \
}
#define COGL_OBJECT_DEFINE(TypeName, type_name) \

View file

@ -52,12 +52,6 @@ cogl_object_ref (void *object)
return object;
}
CoglHandle
cogl_handle_ref (CoglHandle handle)
{
return cogl_object_ref (handle);
}
void
_cogl_object_default_unref (void *object)
{
@ -115,12 +109,6 @@ cogl_object_unref (void *obj)
unref_func (obj);
}
void
cogl_handle_unref (CoglHandle handle)
{
cogl_object_unref (handle);
}
GType
cogl_handle_get_type (void)
{

View file

@ -1131,10 +1131,10 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
}
if (program != COGL_INVALID_HANDLE)
cogl_handle_ref (program);
cogl_object_ref (program);
if (authority == pipeline &&
pipeline->big_state->user_program != COGL_INVALID_HANDLE)
cogl_handle_unref (pipeline->big_state->user_program);
cogl_object_unref (pipeline->big_state->user_program);
pipeline->big_state->user_program = program;
pipeline->dirty_real_blend_enable = TRUE;

View file

@ -435,7 +435,7 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER &&
pipeline->big_state->user_program)
cogl_handle_unref (pipeline->big_state->user_program);
cogl_object_unref (pipeline->big_state->user_program);
if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS)
{
@ -990,7 +990,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
{
if (src->big_state->user_program)
big_state->user_program =
cogl_handle_ref (src->big_state->user_program);
cogl_object_ref (src->big_state->user_program);
else
big_state->user_program = COGL_INVALID_HANDLE;
}

View file

@ -92,27 +92,6 @@ typedef void * CoglHandle;
GType
cogl_handle_get_type (void) G_GNUC_CONST;
/**
* cogl_handle_ref:
* @handle: a #CoglHandle
*
* Increases the reference count of @handle by 1
*
* Return value: (transfer none): the handle, with its reference count increased
*/
CoglHandle
cogl_handle_ref (CoglHandle handle);
/**
* cogl_handle_unref:
* @handle: a #CoglHandle
*
* Drecreases the reference count of @handle by 1; if the reference
* count reaches 0, the resources allocated by @handle will be freed
*/
void
cogl_handle_unref (CoglHandle handle);
/* We forward declare this in cogl-types to avoid circular dependencies
* between cogl-matrix.h, cogl-euler.h and cogl-quaterion.h */
typedef struct _CoglMatrix CoglMatrix;

View file

@ -340,8 +340,6 @@ cogl_gtype_matrix_get_type
#endif
cogl_handle_get_type
cogl_handle_ref
cogl_handle_unref
cogl_has_feature
cogl_has_features

View file

@ -60,7 +60,7 @@ _cogl_program_free (CoglProgram *program)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Unref all of the attached shaders and destroy the list */
g_slist_free_full (program->attached_shaders, cogl_handle_unref);
g_slist_free_full (program->attached_shaders, cogl_object_unref);
for (i = 0; i < program->custom_uniforms->len; i++)
{
@ -113,7 +113,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
program->attached_shaders
= g_slist_prepend (program->attached_shaders,
cogl_handle_ref (shader_handle));
cogl_object_ref (shader_handle));
program->age++;
}
@ -140,9 +140,9 @@ cogl_program_use (CoglHandle handle)
ctx->legacy_state_set--;
if (handle != COGL_INVALID_HANDLE)
cogl_handle_ref (handle);
cogl_object_ref (handle);
if (ctx->current_program != COGL_INVALID_HANDLE)
cogl_handle_unref (ctx->current_program);
cogl_object_unref (ctx->current_program);
ctx->current_program = handle;
}

View file

@ -1769,7 +1769,7 @@ cogl_vertex_buffer_indices_get_for_quads (unsigned int n_indices)
if (ctx->quad_buffer_indices &&
ctx->quad_buffer_indices_len < n_indices)
{
cogl_handle_unref (ctx->quad_buffer_indices);
cogl_object_unref (ctx->quad_buffer_indices);
ctx->quad_buffer_indices = COGL_INVALID_HANDLE;
}

View file

@ -142,7 +142,7 @@ test_blend_paint (TestState *state,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_handle_unref (material);
cogl_object_unref (material);
/*
* Now blend a rectangle over our well defined destination:
@ -168,7 +168,7 @@ test_blend_paint (TestState *state,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_handle_unref (material);
cogl_object_unref (material);
/* See what we got... */
@ -268,7 +268,7 @@ test_tex_combine (TestState *state,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_handle_unref (material);
cogl_object_unref (material);
cogl_object_unref (tex0);
cogl_object_unref (tex1);

View file

@ -82,7 +82,7 @@ paint_legacy (TestState *state)
cogl_program_attach_shader (program, shader);
cogl_program_link (program);
cogl_handle_unref (shader);
cogl_object_unref (shader);
/* Draw something using the material */
cogl_set_source (material);
@ -93,8 +93,8 @@ paint_legacy (TestState *state)
cogl_rectangle (50, 0, 100, 50);
cogl_program_use (COGL_INVALID_HANDLE);
cogl_handle_unref (material);
cogl_handle_unref (program);
cogl_object_unref (material);
cogl_object_unref (program);
}
static void
@ -152,7 +152,7 @@ paint (TestState *state)
cogl_program_attach_shader (program, shader);
cogl_program_link (program);
cogl_handle_unref (shader);
cogl_object_unref (shader);
/* Draw something without the program */
cogl_set_source (pipeline);
@ -160,7 +160,7 @@ paint (TestState *state)
/* Draw it again using the program. It should look exactly the same */
cogl_pipeline_set_user_program (pipeline, program);
cogl_handle_unref (program);
cogl_object_unref (program);
cogl_rectangle (50, 0, 100, 50);
cogl_pipeline_set_user_program (pipeline, COGL_INVALID_HANDLE);

View file

@ -68,7 +68,7 @@ test_material_with_primitives (TestState *state,
COGL_VERTICES_MODE_TRIANGLE_FAN,
0, /* first */
4); /* count */
cogl_handle_unref (vbo);
cogl_object_unref (vbo);
cogl_pop_matrix ();
@ -89,7 +89,7 @@ test_invalid_texture_layers (TestState *state, int x, int y)
cogl_set_source (material);
cogl_handle_unref (material);
cogl_object_unref (material);
/* We expect a white fallback material to be used */
test_material_with_primitives (state, x, y, 0xffffffff);
@ -156,9 +156,9 @@ test_using_all_layers (TestState *state, int x, int y)
cogl_set_source (material);
cogl_handle_unref (material);
cogl_handle_unref (white_texture);
cogl_handle_unref (red_texture);
cogl_object_unref (material);
cogl_object_unref (white_texture);
cogl_object_unref (red_texture);
/* We expect the final fragment to be red */
test_material_with_primitives (state, x, y, 0xff0000ff);
@ -184,7 +184,7 @@ test_invalid_texture_layers_with_constant_colors (TestState *state,
cogl_set_source (material);
cogl_handle_unref (material);
cogl_object_unref (material);
/* We expect the final fragments to be green */
test_material_with_primitives (state, x, y, 0x0000ffff);

View file

@ -149,9 +149,9 @@ on_paint (ClutterActor *actor, TestState *state)
cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH,
tex_coords, 8);
cogl_handle_unref (material);
cogl_handle_unref (tex0);
cogl_handle_unref (tex1);
cogl_object_unref (material);
cogl_object_unref (tex0);
cogl_object_unref (tex1);
/* See what we got... */

View file

@ -101,8 +101,8 @@ create_pipeline_for_shader (TestState *state, const char *shader_source)
cogl_pipeline_set_user_program (pipeline, program);
cogl_handle_unref (shader);
cogl_handle_unref (program);
cogl_object_unref (shader);
cogl_object_unref (program);
return pipeline;
}

View file

@ -81,7 +81,7 @@ on_paint (ClutterActor *actor, void *state)
g_free (pixels);
cogl_pop_framebuffer ();
cogl_handle_unref (offscreen);
cogl_object_unref (offscreen);
/* Now verify reading back from an onscreen framebuffer...
*/
@ -122,7 +122,7 @@ on_paint (ClutterActor *actor, void *state)
g_free (pixelsc);
cogl_handle_unref (tex);
cogl_object_unref (tex);
/* Restore the viewport and matrices state */
cogl_set_viewport (saved_viewport[0],

View file

@ -54,7 +54,7 @@ on_paint (ClutterActor *actor, TestState *state)
tex = make_texture ();
material = cogl_material_new ();
cogl_material_set_layer (material, 0, tex);
cogl_handle_unref (tex);
cogl_object_unref (tex);
/* Render a 1x1 pixel quad without mipmaps */
cogl_set_source (material);
@ -68,7 +68,7 @@ on_paint (ClutterActor *actor, TestState *state)
COGL_MATERIAL_FILTER_NEAREST);
cogl_rectangle (1, 0, 2, 1);
cogl_handle_unref (material);
cogl_object_unref (material);
/* Read back the two pixels we rendered */
cogl_read_pixels (0, 0, 2, 1,

View file

@ -149,12 +149,12 @@ draw_frame (TestState *state)
/* Flush the rendering now so we can safely delete the texture */
cogl_flush ();
cogl_handle_unref (material_rect);
cogl_object_unref (material_rect);
/* Cogl doesn't destroy foreign textures so we have to do it manually */
cogl_texture_get_gl_texture (tex_rect, &gl_tex, NULL);
glDeleteTextures (1, &gl_tex);
cogl_handle_unref (tex_rect);
cogl_object_unref (tex_rect);
}
static void

View file

@ -245,9 +245,9 @@ test_vertex_buffer_contiguous (TestUtilsGTestFixture *fixture,
clutter_main ();
cogl_handle_unref (state.buffer);
cogl_handle_unref (state.material);
cogl_handle_unref (state.texture);
cogl_object_unref (state.buffer);
cogl_object_unref (state.material);
cogl_object_unref (state.texture);
g_source_remove (idle_source);

View file

@ -152,7 +152,7 @@ test_vertex_buffer_interleved (TestUtilsGTestFixture *fixture,
clutter_main ();
cogl_handle_unref (state.buffer);
cogl_object_unref (state.buffer);
g_source_remove (idle_source);

View file

@ -188,7 +188,7 @@ test_vertex_buffer_mutability (TestUtilsGTestFixture *fixture,
clutter_main ();
cogl_handle_unref (state.buffer);
cogl_object_unref (state.buffer);
g_source_remove (idle_source);

View file

@ -335,7 +335,7 @@ on_paint (ClutterActor *actor, void *state)
cogl_set_viewport (0, 0, 10, 10);
cogl_pop_framebuffer ();
cogl_handle_unref (offscreen);
cogl_object_unref (offscreen);
/*
* Verify that the previous onscreen framebuffer's viewport was restored
@ -361,7 +361,7 @@ on_paint (ClutterActor *actor, void *state)
cogl_rectangle (-1, 1, 1, -1);
#endif
cogl_handle_unref (tex);
cogl_object_unref (tex);
/* Finally restore the stage's original state... */
cogl_pop_matrix ();

View file

@ -173,7 +173,7 @@ draw_tests_vbo (TestState *state)
cogl_pop_matrix ();
}
cogl_handle_unref (vbo);
cogl_object_unref (vbo);
}
static void

View file

@ -225,12 +225,12 @@ test_cogl_multitexture_main (int argc, char *argv[])
clutter_main();
cogl_handle_unref (state->material1);
cogl_handle_unref (state->material0);
cogl_handle_unref (state->alpha_tex);
cogl_handle_unref (state->redhand_tex);
cogl_handle_unref (state->light_tex0);
cogl_handle_unref (state->light_tex1);
cogl_object_unref (state->material1);
cogl_object_unref (state->material0);
cogl_object_unref (state->alpha_tex);
cogl_object_unref (state->redhand_tex);
cogl_object_unref (state->light_tex0);
cogl_object_unref (state->light_tex1);
g_free (state);
return 0;

View file

@ -133,8 +133,8 @@ test_coglbox_dispose (GObject *object)
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->texture_id);
cogl_handle_unref (priv->offscreen_id);
cogl_object_unref (priv->texture_id);
cogl_object_unref (priv->offscreen_id);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}

View file

@ -209,7 +209,7 @@ paint_cb (ClutterActor *stage, Data *data)
cogl_set_source (data->material);
cogl_vertex_buffer_draw (vbo, COGL_VERTICES_MODE_POINTS, 0, N_SPARKS);
cogl_handle_unref (vbo);
cogl_object_unref (vbo);
cogl_set_projection_matrix (&old_matrix);
cogl_pop_matrix ();
@ -242,7 +242,7 @@ test_cogl_point_sprites_main (int argc, char *argv[])
tex = generate_round_texture ();
cogl_material_set_layer (data.material, 0, tex);
cogl_handle_unref (tex);
cogl_object_unref (tex);
if (!cogl_material_set_layer_point_sprite_coords_enabled (data.material,
0, TRUE,

View file

@ -197,7 +197,7 @@ set_shader_num (int new_no)
program = cogl_create_program ();
cogl_program_attach_shader (program, shader);
cogl_handle_unref (shader);
cogl_object_unref (shader);
cogl_program_link (program);
uniform_no = cogl_program_get_uniform_location (program, "tex");
@ -215,7 +215,7 @@ set_shader_num (int new_no)
cogl_program_set_uniform_1f (program, uniform_no, 1.0f / image_height);
cogl_material_set_user_program (material, program);
cogl_handle_unref (program);
cogl_object_unref (program);
shader_no = new_no;
}

View file

@ -137,7 +137,7 @@ test_coglbox_dispose (GObject *object)
TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->cogl_tex_id);
cogl_object_unref (priv->cogl_tex_id);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}

View file

@ -220,7 +220,7 @@ test_coglbox_paint (ClutterActor *self)
cogl_pop_matrix ();
cogl_handle_unref (material);
cogl_object_unref (material);
}
static void
@ -235,8 +235,8 @@ test_coglbox_dispose (GObject *object)
TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->not_sliced_tex);
cogl_handle_unref (priv->sliced_tex);
cogl_object_unref (priv->not_sliced_tex);
cogl_object_unref (priv->sliced_tex);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}

View file

@ -134,7 +134,7 @@ test_coglbox_dispose (GObject *object)
TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->cogl_tex_id);
cogl_object_unref (priv->cogl_tex_id);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}

View file

@ -383,8 +383,8 @@ test_cogl_vertex_buffer_main (int argc, char *argv[])
clutter_main ();
cogl_handle_unref (state.buffer);
cogl_handle_unref (state.indices);
cogl_object_unref (state.buffer);
cogl_object_unref (state.indices);
return 0;
}