From f16d3756dfafa63521954842c8365e8862bfd126 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Sep 2011 20:46:38 +0100 Subject: [PATCH] pipeline: lazily get ctx in _get_layer We only need a ctx pointer if we need to refer to the default_layer_x layers to copy as templates so only call _cogl_context_get_default() once we need to copy a template. _cogl_context_get_default() was starting to show up in profiles and this was the main cause. Reviewed-by: Neil Roberts --- cogl/cogl-pipeline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 0466740d3..140a488be 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -1615,8 +1615,7 @@ _cogl_pipeline_get_layer (CoglPipeline *pipeline, CoglPipelineLayer *layer; int unit_index; int i; - - _COGL_GET_CONTEXT (ctx, NULL); + CoglContext *ctx; /* The layer index of the layer we want info about */ layer_info.layer_index = layer_index; @@ -1645,6 +1644,8 @@ _cogl_pipeline_get_layer (CoglPipeline *pipeline, if (layer_info.layer) return layer_info.layer; + ctx = _cogl_context_get_default (); + unit_index = layer_info.insert_after + 1; if (unit_index == 0) layer = _cogl_pipeline_layer_copy (ctx->default_layer_0);