[cogl/wip/rig: 27/34] blend-string: Avoid using _COGL_GET_CONTEXT



commit e7fad3813147e5c66fd35115b3590b134959f4de
Author: Robert Bragg <robert bragg intel com>
Date:   Mon Mar 17 14:07:48 2014 +0000

    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.

 cogl/cogl-blend-string.c         |   19 +++++++++++--------
 cogl/cogl-blend-string.h         |    3 ++-
 cogl/cogl-pipeline-layer-state.c |    5 ++++-
 cogl/cogl-pipeline-state.c       |   10 +++++-----
 4 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/cogl/cogl-blend-string.c b/cogl/cogl-blend-string.c
index 9fe3ed1..884ab77 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 32f1e64..8561c25 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 40f3a0f..d9cf082 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 15c09d1..c053844 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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]