summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert.bragg@intel.com>2014-03-17 14:07:48 +0000
committerRobert Bragg <robert.bragg@intel.com>2014-03-24 19:37:22 +0000
commit6e69b69180addd60e963e684314f5dc122c442e3 (patch)
tree4a2cb7bead10c353ff14f1c7cd7caca154a4bf47
parent4c4d90fb09316201fb5c7af6c3416a51ae0c972b (diff)
downloadcogl-6e69b69180addd60e963e684314f5dc122c442e3.tar.gz
blend-string: Avoid using _COGL_GET_CONTEXT
Although this just moves the _GET_CONTEXT() into the cogl-pipeline code, it means we have one less component in cogl depending on a global context. CoglPipeline is one of the only remaining components that heavily depends on a global context and will probably be the last component we tackle.
-rw-r--r--cogl/cogl-blend-string.c19
-rw-r--r--cogl/cogl-blend-string.h3
-rw-r--r--cogl/cogl-pipeline-layer-state.c5
-rw-r--r--cogl/cogl-pipeline-state.c10
4 files changed, 22 insertions, 15 deletions
diff --git a/cogl/cogl-blend-string.c b/cogl/cogl-blend-string.c
index 9fe3ed17..884ab77d 100644
--- a/cogl/cogl-blend-string.c
+++ b/cogl/cogl-blend-string.c
@@ -212,7 +212,8 @@ error:
}
static CoglBool
-validate_blend_statements (CoglBlendStringStatement *statements,
+validate_blend_statements (CoglContext *ctx,
+ CoglBlendStringStatement *statements,
int n_statements,
CoglError **error)
{
@@ -220,8 +221,6 @@ validate_blend_statements (CoglBlendStringStatement *statements,
const char *error_string;
CoglBlendStringError detail = COGL_BLEND_STRING_ERROR_INVALID_ERROR;
- _COGL_GET_CONTEXT (ctx, 0);
-
if (n_statements == 2 &&
!ctx->glBlendEquationSeparate &&
statements[0].function->type != statements[1].function->type)
@@ -276,7 +275,8 @@ error:
}
static CoglBool
-validate_statements_for_context (CoglBlendStringStatement *statements,
+validate_statements_for_context (CoglContext *ctx,
+ CoglBlendStringStatement *statements,
int n_statements,
CoglBlendStringContext context,
CoglError **error)
@@ -300,7 +300,7 @@ validate_statements_for_context (CoglBlendStringStatement *statements,
}
if (context == COGL_BLEND_STRING_CONTEXT_BLENDING)
- return validate_blend_statements (statements, n_statements, error);
+ return validate_blend_statements (ctx, statements, n_statements, error);
else
return validate_tex_combine_statements (statements, n_statements, error);
@@ -753,7 +753,8 @@ error:
}
int
-_cogl_blend_string_compile (const char *string,
+_cogl_blend_string_compile (CoglContext *ctx,
+ const char *string,
CoglBlendStringContext context,
CoglBlendStringStatement *statements,
CoglError **error)
@@ -905,7 +906,8 @@ finished:
print_statement (1, &statements[1]);
}
- if (!validate_statements_for_context (statements,
+ if (!validate_statements_for_context (ctx,
+ statements,
current_statement,
context,
error))
@@ -1003,7 +1005,8 @@ UNIT_TEST (blend_string_parsing,
for (i = 0; tests[i].string; i++)
{
CoglBlendStringStatement statements[2];
- _cogl_blend_string_compile (tests[i].string,
+ _cogl_blend_string_compile (test_ctx,
+ tests[i].string,
tests[i].context,
statements,
&error);
diff --git a/cogl/cogl-blend-string.h b/cogl/cogl-blend-string.h
index 32f1e64b..8561c25f 100644
--- a/cogl/cogl-blend-string.h
+++ b/cogl/cogl-blend-string.h
@@ -130,7 +130,8 @@ typedef struct _CoglBlendStringStatement
CoglBool
-_cogl_blend_string_compile (const char *string,
+_cogl_blend_string_compile (CoglContext *ctx,
+ const char *string,
CoglBlendStringContext context,
CoglBlendStringStatement *statements,
CoglError **error);
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c
index 40f3a0f1..d9cf0827 100644
--- a/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl-pipeline-layer-state.c
@@ -1175,6 +1175,8 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
CoglBlendStringStatement *a;
int count;
+ _COGL_GET_CONTEXT (ctx, FALSE);
+
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
/* Note: this will ensure that the layer exists, creating one if it
@@ -1190,7 +1192,8 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
authority = _cogl_pipeline_layer_get_authority (layer, state);
count =
- _cogl_blend_string_compile (combine_description,
+ _cogl_blend_string_compile (ctx,
+ combine_description,
COGL_BLEND_STRING_CONTEXT_TEXTURE_COMBINE,
statements,
error);
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 15c09d18..c0538447 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -643,11 +643,11 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline,
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
- count =
- _cogl_blend_string_compile (blend_description,
- COGL_BLEND_STRING_CONTEXT_BLENDING,
- statements,
- error);
+ count = _cogl_blend_string_compile (ctx,
+ blend_description,
+ COGL_BLEND_STRING_CONTEXT_BLENDING,
+ statements,
+ error);
if (!count)
return FALSE;