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 <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2011-09-20 20:46:38 +01:00
parent d4459e2d42
commit f16d3756df

View File

@ -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);