[Mesa-dev] [PATCH 14/21] mesa: refactor _mesa_DebugMessageControl

Chia-I Wu olvaffe at gmail.com
Tue Apr 22 01:58:29 PDT 2014


Merge set_message_state, control_messages, and control_app_messages into the
function.

Signed-off-by: Chia-I Wu <olv at lunarg.com>
---
 src/mesa/main/errors.c | 83 +++++++++++---------------------------------------
 1 file changed, 17 insertions(+), 66 deletions(-)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 5136f75..a5a7425 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -639,20 +639,6 @@ should_log(struct gl_context *ctx,
 }
 
 
-static void
-set_message_state(struct gl_context *ctx,
-                  enum mesa_debug_source source,
-                  enum mesa_debug_type type,
-                  GLuint id, GLboolean enabled)
-{
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
-
-   if (debug)
-      debug_set_message_filter(debug, source, type, id, enabled);
-}
-
-
-
 /**
  * Log a client or driver debug message.
  */
@@ -761,54 +747,6 @@ error:
 }
 
 
-static void
-control_messages(struct gl_context *ctx,
-                 enum mesa_debug_source source,
-                 enum mesa_debug_type type,
-                 enum mesa_debug_severity severity,
-                 GLboolean enabled)
-{
-   struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
-
-   if (!debug)
-      return;
-
-   debug_set_default_filter(debug, source, type, severity, enabled);
-}
-
-
-/**
- * Debugging-message namespaces with the source APPLICATION or THIRD_PARTY
- * require special handling, since the IDs in them are controlled by clients,
- * not the OpenGL implementation.
- *
- * 'count' is the length of the array 'ids'. If 'count' is nonzero, all
- * the given IDs in the namespace defined by 'esource' and 'etype'
- * will be affected.
- *
- * If 'count' is zero, this sets the state of all IDs that match
- * the combination of 'esource', 'etype', and 'eseverity'.
- */
-static void
-control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype,
-                     GLenum eseverity, GLsizei count, const GLuint *ids,
-                     GLboolean enabled)
-{
-   GLsizei i;
-   enum mesa_debug_source source = gl_enum_to_debug_source(esource);
-   enum mesa_debug_type type = gl_enum_to_debug_type(etype);
-   enum mesa_debug_severity severity = gl_enum_to_debug_severity(eseverity);
-
-   for (i = 0; i < count; i++)
-      set_message_state(ctx, source, type, ids[i], enabled);
-
-   if (count)
-      return;
-
-   control_messages(ctx, source, type, severity, enabled);
-}
-
-
 /**
  * This is a generic message insert function.
  * Validation of source, type and severity parameters should be done
@@ -920,9 +858,12 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
                           GLenum gl_severity, GLsizei count,
                           const GLuint *ids, GLboolean enabled)
 {
-   const char *callerstr = "glDebugMessageControl";
-
    GET_CURRENT_CONTEXT(ctx);
+   enum mesa_debug_source source = gl_enum_to_debug_source(gl_source);
+   enum mesa_debug_type type = gl_enum_to_debug_type(gl_type);
+   enum mesa_debug_severity severity = gl_enum_to_debug_severity(gl_severity);
+   const char *callerstr = "glDebugMessageControl";
+   struct gl_debug_state *debug;
 
    if (count < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
@@ -944,8 +885,18 @@ _mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
       return;
    }
 
-   control_app_messages(ctx, gl_source, gl_type, gl_severity,
-                        count, ids, enabled);
+   debug = _mesa_get_debug_state(ctx);
+   if (!debug)
+      return;
+
+   if (count) {
+      GLsizei i;
+      for (i = 0; i < count; i++)
+         debug_set_message_filter(debug, source, type, ids[i], enabled);
+   }
+   else {
+      debug_set_default_filter(debug, source, type, severity, enabled);
+   }
 }
 
 
-- 
1.8.5.3



More information about the mesa-dev mailing list