From 6cd28a84ace00d5d0202f70681be87ab88b529b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 7 Jun 2024 17:07:52 +0200 Subject: [PATCH] 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: --- cogl/cogl/cogl-pipeline-private.h | 3 +++ cogl/cogl/cogl-pipeline.c | 15 +++++++++++++++ cogl/cogl/cogl-pipeline.h | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 82c9c4bb6..75428b8f4 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -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 diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 43e665533..4f33c4055 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -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; +} diff --git a/cogl/cogl/cogl-pipeline.h b/cogl/cogl/cogl-pipeline.h index 15d9b34b2..35af46c4e 100644 --- a/cogl/cogl/cogl-pipeline.h +++ b/cogl/cogl/cogl-pipeline.h @@ -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