From 740bd12f2ddd432af03e3ceb133db0d8e53cf716 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 9 Feb 2012 20:38:03 +0000 Subject: [PATCH] Add a version of _cogl_pipeline_get_layer which does not create it This adds _cogl_pipeline_get_layer_with_flags which takes a set of flags to modify the behaviour. The only flag currently available is one to disable creating the layer if the layer index does not already exist. Reviewed-by: Robert Bragg --- cogl/cogl-pipeline-private.h | 13 +++++++++++-- cogl/cogl-pipeline.c | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h index 5e4f0ff4e..072ab7414 100644 --- a/cogl/cogl-pipeline-private.h +++ b/cogl/cogl-pipeline-private.h @@ -665,9 +665,18 @@ _cogl_pipeline_prune_redundant_ancestry (CoglPipeline *pipeline); void _cogl_pipeline_update_blend_enable (CoglPipeline *pipeline, CoglPipelineState changes); +typedef enum +{ + COGL_PIPELINE_GET_LAYER_NO_CREATE +} CoglPipelineGetLayerFlags; + CoglPipelineLayer * -_cogl_pipeline_get_layer (CoglPipeline *pipeline, - int layer_index); +_cogl_pipeline_get_layer_with_flags (CoglPipeline *pipeline, + int layer_index, + CoglPipelineGetLayerFlags flags); + +#define _cogl_pipeline_get_layer(p, l) \ + _cogl_pipeline_get_layer_with_flags (p, l, 0) gboolean _cogl_is_pipeline_layer (void *object); diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index fa3b1e237..b94b16e05 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -1707,8 +1707,9 @@ _cogl_pipeline_get_layer_info (CoglPipeline *pipeline, } CoglPipelineLayer * -_cogl_pipeline_get_layer (CoglPipeline *pipeline, - int layer_index) +_cogl_pipeline_get_layer_with_flags (CoglPipeline *pipeline, + int layer_index, + CoglPipelineGetLayerFlags flags) { CoglPipeline *authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); @@ -1742,7 +1743,7 @@ _cogl_pipeline_get_layer (CoglPipeline *pipeline, _cogl_pipeline_get_layer_info (authority, &layer_info); - if (layer_info.layer) + if (layer_info.layer || (flags & COGL_PIPELINE_GET_LAYER_NO_CREATE)) return layer_info.layer; ctx = _cogl_context_get_default ();