1
0
Fork 0

cogl/pipeline: Add API to name a pipeline

It uses static strings, and is meant to make it easier to match what
pipeline source code one might be looking at when running with
COGL_DEBUG=show-sources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
This commit is contained in:
Jonas Ådahl 2024-06-07 17:07:52 +02:00 committed by Sebastian Wick
parent 0c653b4cf2
commit 6cd28a84ac
3 changed files with 39 additions and 0 deletions

View file

@ -368,6 +368,9 @@ struct _CoglPipeline
* string with a pipeline which can be an aid when trying to trace
* where the pipeline originates from */
const char *static_breadcrumb;
/* Pointer to a static string with a descriptive name, or NULL. */
const char *name;
};
struct _CoglPipelineClass

View file

@ -335,6 +335,8 @@ _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
if (src->capabilities)
pipeline->capabilities = g_array_copy (src->capabilities);
pipeline->name = src->name;
/* XXX:
* consider generalizing the idea of "cached" properties. These
* would still have an authority like other sparse properties but
@ -2855,3 +2857,16 @@ cogl_pipeline_has_capability (CoglPipeline *pipeline,
return FALSE;
}
void
cogl_pipeline_set_static_name (CoglPipeline *pipeline,
const char *name)
{
pipeline->name = name;
}
const char *
cogl_pipeline_get_name (CoglPipeline *pipeline)
{
return pipeline->name;
}

View file

@ -160,4 +160,25 @@ cogl_pipeline_has_capability (CoglPipeline *pipeline,
GQuark domain,
unsigned int capability);
/**
* cogl_pipeline_set_static_name:
* @pipeline: A #CoglPipeline object
* @name: A descriptive name
*
* Set a pipeline name. It may be used for debugging or logging purposes. The
* string must be a static string, and string. It will not be copied.
*/
COGL_EXPORT void
cogl_pipeline_set_static_name (CoglPipeline *pipeline,
const char *name);
/**
* cogl_pipeline_get_name:
* @pipeline: A #CoglPipeline object
*
* Returns: (transfer none): The pipeline name, or %NULL
*/
COGL_EXPORT const char *
cogl_pipeline_get_name (CoglPipeline *pipeline);
G_END_DECLS