cogl: Remove COGL_INVALID_HANDLE

Just use `NULL`, which is the normal C convention

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
This commit is contained in:
Niels De Graef 2019-02-20 14:53:01 +01:00 committed by Jonas Ådahl
parent 23f77a1b63
commit 0d0286d59e
17 changed files with 51 additions and 60 deletions

View File

@ -627,7 +627,7 @@ clutter_backend_init (ClutterBackend *self)
self->units_per_em = -1.0;
self->units_serial = 1;
self->dummy_onscreen = COGL_INVALID_HANDLE;
self->dummy_onscreen = NULL;
}
void
@ -1012,7 +1012,7 @@ _clutter_backend_get_keymap_direction (ClutterBackend *backend)
void
_clutter_backend_reset_cogl_framebuffer (ClutterBackend *backend)
{
if (backend->dummy_onscreen == COGL_INVALID_HANDLE)
if (backend->dummy_onscreen == NULL)
{
GError *internal_error = NULL;

View File

@ -537,7 +537,7 @@ clutter_offscreen_effect_init (ClutterOffscreenEffect *self)
* used instead of clutter_offscreen_effect_get_target() when the
* effect subclass wants to paint using its own material.
*
* Return value: (transfer none): a #CoglHandle or %COGL_INVALID_HANDLE. The
* Return value: (transfer none): a #CoglHandle or %NULL. The
* returned texture is owned by Clutter and it should not be
* modified or freed
*
@ -602,7 +602,7 @@ clutter_offscreen_effect_paint_target (ClutterOffscreenEffect *effect)
* Calls the create_texture() virtual function of the @effect
*
* Return value: (transfer full): a handle to a Cogl texture, or
* %COGL_INVALID_HANDLE. The returned handle has its reference
* %NULL. The returned handle has its reference
* count increased.
*
* Since: 1.4

View File

@ -177,18 +177,18 @@ clutter_shader_effect_clear (ClutterShaderEffect *self,
{
ClutterShaderEffectPrivate *priv = self->priv;
if (priv->shader != COGL_INVALID_HANDLE)
if (priv->shader != NULL)
{
cogl_object_unref (priv->shader);
priv->shader = COGL_INVALID_HANDLE;
priv->shader = NULL;
}
if (priv->program != COGL_INVALID_HANDLE)
if (priv->program != NULL)
{
cogl_object_unref (priv->program);
priv->program = COGL_INVALID_HANDLE;
priv->program = NULL;
}
if (reset_uniforms && priv->uniforms != NULL)
@ -208,7 +208,7 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
gpointer key, value;
gsize size;
if (priv->program == COGL_INVALID_HANDLE)
if (priv->program == NULL)
return;
if (priv->uniforms == NULL)
@ -333,7 +333,7 @@ clutter_shader_effect_create_shader (ClutterShaderEffect *self)
default:
g_assert_not_reached ();
return COGL_INVALID_HANDLE;
return NULL;
}
}
@ -353,7 +353,7 @@ clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
CLUTTER_TYPE_SHADER_EFFECT,
ClutterShaderEffectClassPrivate);
if (class_priv->shader == COGL_INVALID_HANDLE)
if (class_priv->shader == NULL)
{
gchar *source;
@ -389,7 +389,7 @@ clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
priv->shader = cogl_object_ref (class_priv->shader);
if (class_priv->program != COGL_INVALID_HANDLE)
if (class_priv->program != NULL)
priv->program = cogl_object_ref (class_priv->program);
}
}
@ -404,13 +404,13 @@ clutter_shader_effect_paint_target (ClutterOffscreenEffect *effect)
/* If the source hasn't been set then we'll try to get it from the
static source instead */
if (priv->shader == COGL_INVALID_HANDLE)
if (priv->shader == NULL)
clutter_shader_effect_try_static_source (self);
/* we haven't been prepared or we don't have support for
* GLSL shaders in Clutter
*/
if (priv->program == COGL_INVALID_HANDLE)
if (priv->program == NULL)
goto out;
CLUTTER_NOTE (SHADER, "Applying the shader effect of type '%s'",
@ -534,7 +534,7 @@ clutter_shader_effect_new (ClutterShaderType shader_type)
* Retrieves a pointer to the shader's handle
*
* Return value: (transfer none): a pointer to the shader's handle,
* or %COGL_INVALID_HANDLE
* or %NULL
*
* Since: 1.4
*/
@ -542,7 +542,7 @@ CoglHandle
clutter_shader_effect_get_shader (ClutterShaderEffect *effect)
{
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
COGL_INVALID_HANDLE);
NULL);
return effect->priv->shader;
}
@ -554,7 +554,7 @@ clutter_shader_effect_get_shader (ClutterShaderEffect *effect)
* Retrieves a pointer to the program's handle
*
* Return value: (transfer none): a pointer to the program's handle,
* or %COGL_INVALID_HANDLE
* or %NULL
*
* Since: 1.4
*/
@ -562,7 +562,7 @@ CoglHandle
clutter_shader_effect_get_program (ClutterShaderEffect *effect)
{
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
COGL_INVALID_HANDLE);
NULL);
return effect->priv->program;
}
@ -892,7 +892,7 @@ clutter_shader_effect_set_shader_source (ClutterShaderEffect *effect,
priv = effect->priv;
if (priv->shader != COGL_INVALID_HANDLE)
if (priv->shader != NULL)
return TRUE;
priv->shader = clutter_shader_effect_create_shader (effect);

View File

@ -294,7 +294,7 @@ clutter_cairo_texture_context_destroy (void *data)
cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (cairo));
if (cairo_width == 0 ||
cairo_height == 0 ||
cogl_texture == COGL_INVALID_HANDLE)
cogl_texture == NULL)
{
draw_context_destroy (ctxt);
return;

View File

@ -1070,7 +1070,7 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline)
{
CoglPipeline *authority;
g_return_val_if_fail (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE);
g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
@ -1105,7 +1105,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
*/
_cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
if (program != COGL_INVALID_HANDLE)
if (program != NULL)
_cogl_pipeline_set_progend (pipeline, COGL_PIPELINE_PROGEND_UNDEFINED);
/* If we are the current authority see if we can revert to one of our
@ -1130,10 +1130,10 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline,
_cogl_pipeline_prune_redundant_ancestry (pipeline);
}
if (program != COGL_INVALID_HANDLE)
if (program != NULL)
cogl_object_ref (program);
if (authority == pipeline &&
pipeline->big_state->user_program != COGL_INVALID_HANDLE)
pipeline->big_state->user_program != NULL)
cogl_object_unref (pipeline->big_state->user_program);
pipeline->big_state->user_program = program;

View File

@ -578,7 +578,7 @@ cogl_pipeline_get_per_vertex_point_size (CoglPipeline *pipeline);
* Queries what user program has been associated with the given
* @pipeline using cogl_pipeline_set_user_program().
*
* Return value: (transfer none): The current user program or %COGL_INVALID_HANDLE.
* Return value: (transfer none): The current user program or %NULL.
*
* Since: 2.0
* Stability: Unstable

View File

@ -182,7 +182,7 @@ _cogl_pipeline_init_default_pipeline (void)
blend_state->blend_src_factor_rgb = GL_ONE;
blend_state->blend_dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA;
big_state->user_program = COGL_INVALID_HANDLE;
big_state->user_program = NULL;
cogl_depth_state_init (&big_state->depth_state);
@ -749,7 +749,7 @@ _cogl_pipeline_change_implies_transparency (CoglPipeline *pipeline,
*
* TODO: check that it isn't just a vertex shader!
*/
if (_cogl_pipeline_get_user_program (pipeline) != COGL_INVALID_HANDLE)
if (_cogl_pipeline_get_user_program (pipeline) != NULL)
return TRUE;
}
@ -992,7 +992,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
big_state->user_program =
cogl_object_ref (src->big_state->user_program);
else
big_state->user_program = COGL_INVALID_HANDLE;
big_state->user_program = NULL;
}
if (differences & COGL_PIPELINE_STATE_DEPTH)
@ -2558,7 +2558,7 @@ _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline)
/* A program explicitly set on the pipeline has higher precedence than
* one associated with the context using cogl_program_use() */
if (ctx->current_program &&
cogl_pipeline_get_user_program (pipeline) == COGL_INVALID_HANDLE)
cogl_pipeline_get_user_program (pipeline) == NULL)
cogl_pipeline_set_user_program (pipeline, ctx->current_program);
if (ctx->legacy_depth_test_enabled)

View File

@ -80,14 +80,6 @@ typedef struct { \
*/
typedef void * CoglHandle;
/**
* COGL_INVALID_HANDLE:
*
* A COGL handle that is not valid, used for unitialized handles as well as
* error conditions.
*/
#define COGL_INVALID_HANDLE NULL
#define COGL_TYPE_HANDLE (cogl_handle_get_type ())
GType
cogl_handle_get_type (void) G_GNUC_CONST;

View File

@ -706,7 +706,7 @@ cogl_material_get_point_size (CoglMaterial *material);
* @material using cogl_material_set_user_program().
*
* Return value: (transfer none): The current user program
* or %COGL_INVALID_HANDLE.
* or %NULL.
*
* Since: 1.4
* Deprecated: 1.16: Use #CoglSnippet api instead instead
@ -1021,7 +1021,7 @@ cogl_material_layer_get_type (CoglMaterialLayer *layer);
* Extracts a texture handle for a specific layer.
*
* <note>In the future Cogl may support purely GLSL based layers; for those
* layers this function which will likely return %COGL_INVALID_HANDLE if you
* layers this function which will likely return %NULL if you
* try to get the texture handle from them. Considering this scenario, you
* should call cogl_material_layer_get_type() first in order check it is of
* type %COGL_MATERIAL_LAYER_TYPE_TEXTURE before calling this function.</note>

View File

@ -131,17 +131,16 @@ cogl_program_use (CoglHandle handle)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (handle == COGL_INVALID_HANDLE ||
cogl_is_program (handle));
g_return_if_fail (handle == NULL || cogl_is_program (handle));
if (ctx->current_program == 0 && handle != 0)
ctx->legacy_state_set++;
else if (handle == 0 && ctx->current_program != 0)
ctx->legacy_state_set--;
if (handle != COGL_INVALID_HANDLE)
if (handle != NULL)
cogl_object_ref (handle);
if (ctx->current_program != COGL_INVALID_HANDLE)
if (ctx->current_program != NULL)
cogl_object_unref (ctx->current_program);
ctx->current_program = handle;
}

View File

@ -71,7 +71,7 @@ cogl_create_shader (CoglShaderType type)
{
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
_COGL_GET_CONTEXT (ctx, NULL);
switch (type)
{
@ -81,7 +81,7 @@ cogl_create_shader (CoglShaderType type)
default:
g_warning ("Unexpected shader type (0x%08lX) given to "
"cogl_create_shader", (unsigned long) type);
return COGL_INVALID_HANDLE;
return NULL;
}
shader = g_slice_new (CoglShader);

View File

@ -453,10 +453,10 @@ cogl_program_link (CoglHandle handle);
/**
* cogl_program_use:
* @handle: a #CoglHandle for a shader program or %COGL_INVALID_HANDLE.
* @handle: a #CoglHandle for a shader program or %NULL.
*
* Activate a specific shader program replacing that part of the GL
* rendering pipeline, if passed in %COGL_INVALID_HANDLE the default
* rendering pipeline, if passed in %NULL the default
* behavior of GL is reinstated.
*
* This function affects the global state of the current Cogl

View File

@ -138,7 +138,7 @@ cogl_vertex_buffer_new (unsigned int n_vertices)
buffer->primitive = cogl_primitive_new (COGL_VERTICES_MODE_TRIANGLES,
n_vertices, NULL);
/* return COGL_INVALID_HANDLE; */
/* return NULL; */
return _cogl_vertex_buffer_handle_new (buffer);
}
@ -1675,7 +1675,7 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type,
{
CoglIndices *indices;
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
_COGL_GET_CONTEXT (ctx, NULL);
indices = cogl_indices_new (ctx, indices_type, indices_array, indices_len);
return _cogl_vertex_buffer_indices_new_real (indices);
@ -1749,11 +1749,11 @@ _cogl_vertex_buffer_free (CoglVertexBuffer *buffer)
CoglHandle
cogl_vertex_buffer_indices_get_for_quads (unsigned int n_indices)
{
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
_COGL_GET_CONTEXT (ctx, NULL);
if (n_indices <= 256 / 4 * 6)
{
if (ctx->quad_buffer_indices_byte == COGL_INVALID_HANDLE)
if (ctx->quad_buffer_indices_byte == NULL)
{
/* NB: cogl_get_quad_indices takes n_quads not n_indices... */
CoglIndices *indices = cogl_get_rectangle_indices (ctx, 256 / 4);
@ -1770,10 +1770,10 @@ cogl_vertex_buffer_indices_get_for_quads (unsigned int n_indices)
ctx->quad_buffer_indices_len < n_indices)
{
cogl_object_unref (ctx->quad_buffer_indices);
ctx->quad_buffer_indices = COGL_INVALID_HANDLE;
ctx->quad_buffer_indices = NULL;
}
if (ctx->quad_buffer_indices == COGL_INVALID_HANDLE)
if (ctx->quad_buffer_indices == NULL)
{
/* NB: cogl_get_quad_indices takes n_quads not n_indices... */
CoglIndices *indices =

View File

@ -91,7 +91,7 @@ paint_legacy (TestState *state)
/* Draw it again using the program. It should look exactly the same */
cogl_program_use (program);
cogl_rectangle (50, 0, 100, 50);
cogl_program_use (COGL_INVALID_HANDLE);
cogl_program_use (NULL);
cogl_object_unref (material);
cogl_object_unref (program);
@ -163,7 +163,7 @@ paint (TestState *state)
cogl_object_unref (program);
cogl_rectangle (50, 0, 100, 50);
cogl_pipeline_set_user_program (pipeline, COGL_INVALID_HANDLE);
cogl_pipeline_set_user_program (pipeline, NULL);
cogl_object_unref (pipeline);
}

View File

@ -256,7 +256,7 @@ test_coglbox_map (ClutterActor *actor)
cogl_pop_framebuffer ();
if (priv->offscreen_id == COGL_INVALID_HANDLE)
if (priv->offscreen_id == NULL)
printf ("Failed creating offscreen to texture!\n");
}
@ -281,7 +281,7 @@ test_coglbox_init (TestCoglbox *self)
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_RGB_888);
if (priv->texture_id == COGL_INVALID_HANDLE)
if (priv->texture_id == NULL)
printf ("Failed creating texture with size!\n");
}

View File

@ -320,7 +320,7 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
COGL_TEXTURE_NO_ATLAS,
COGL_PIXEL_FORMAT_ANY,
&error);
if (redhand == COGL_INVALID_HANDLE)
if (redhand == NULL)
g_error ("image load failed: %s", error->message);
material = cogl_material_new ();

View File

@ -259,7 +259,7 @@ test_coglbox_init (TestCoglbox *self)
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
&error);
if (priv->sliced_tex == COGL_INVALID_HANDLE)
if (priv->sliced_tex == NULL)
{
if (error)
{
@ -276,7 +276,7 @@ test_coglbox_init (TestCoglbox *self)
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
if (priv->not_sliced_tex == COGL_INVALID_HANDLE)
if (priv->not_sliced_tex == NULL)
{
if (error)
{