mesa: clean-up _mesa_lookup_prim_by_nr()

Remove the redundant public _mesa_prim_name[] array.
This commit is contained in:
Brian Paul 2011-01-20 09:38:49 -07:00
parent fe49dcb3b0
commit 887d2b647b
5 changed files with 55 additions and 57 deletions

View File

@ -46,6 +46,7 @@ class PrintGlEnums(gl_XML.gl_print_base):
print '#include "main/mfeatures.h"' print '#include "main/mfeatures.h"'
print '#include "main/enums.h"' print '#include "main/enums.h"'
print '#include "main/imports.h"' print '#include "main/imports.h"'
print '#include "main/mtypes.h"'
print '' print ''
print 'typedef struct {' print 'typedef struct {'
print ' size_t offset;' print ' size_t offset;'
@ -111,29 +112,39 @@ const char *_mesa_lookup_enum_by_nr( int nr )
} }
} }
/**
* Primitive names
*/
static const char *prim_names[PRIM_UNKNOWN + 1] = {
"GL_POINTS",
"GL_LINES",
"GL_LINE_LOOP",
"GL_LINE_STRIP",
"GL_TRIANGLES",
"GL_TRIANGLE_STRIP",
"GL_TRIANGLE_FAN",
"GL_QUADS",
"GL_QUAD_STRIP",
"GL_POLYGON",
"outside begin/end",
"inside unknown primitive",
"unknown state"
};
/* Get the name of an enum given that it is a primitive type. Avoids /* Get the name of an enum given that it is a primitive type. Avoids
* GL_FALSE/GL_POINTS ambiguity and others. * GL_FALSE/GL_POINTS ambiguity and others.
*/ */
const char *_mesa_lookup_prim_by_nr( int nr ) const char *
_mesa_lookup_prim_by_nr(GLuint nr)
{ {
switch (nr) { if (nr < Elements(prim_names))
case GL_POINTS: return "GL_POINTS"; return prim_names[nr];
case GL_LINES: return "GL_LINES"; else
case GL_LINE_STRIP: return "GL_LINE_STRIP"; return "invalid mode";
case GL_LINE_LOOP: return "GL_LINE_LOOP";
case GL_TRIANGLES: return "GL_TRIANGLES";
case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP";
case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN";
case GL_QUADS: return "GL_QUADS";
case GL_QUAD_STRIP: return "GL_QUAD_STRIP";
case GL_POLYGON: return "GL_POLYGON";
case GL_POLYGON+1: return "OUTSIDE_BEGIN_END";
default: return "<invalid>";
}
} }
int _mesa_lookup_enum_by_name( const char *symbol ) int _mesa_lookup_enum_by_name( const char *symbol )
{ {
enum_elt * f = NULL; enum_elt * f = NULL;

View File

@ -37,26 +37,6 @@
#include "texobj.h" #include "texobj.h"
/**
* Primitive names
*/
const char *_mesa_prim_name[GL_POLYGON+4] = {
"GL_POINTS",
"GL_LINES",
"GL_LINE_LOOP",
"GL_LINE_STRIP",
"GL_TRIANGLES",
"GL_TRIANGLE_STRIP",
"GL_TRIANGLE_FAN",
"GL_QUADS",
"GL_QUAD_STRIP",
"GL_POLYGON",
"outside begin/end",
"inside unknown primitive",
"unknown state"
};
static const char * static const char *
tex_target_name(GLenum tgt) tex_target_name(GLenum tgt)
{ {

View File

@ -29,6 +29,7 @@
#include "main/mfeatures.h" #include "main/mfeatures.h"
#include "main/enums.h" #include "main/enums.h"
#include "main/imports.h" #include "main/imports.h"
#include "main/mtypes.h"
typedef struct { typedef struct {
size_t offset; size_t offset;
@ -6243,29 +6244,39 @@ const char *_mesa_lookup_enum_by_nr( int nr )
} }
} }
/**
* Primitive names
*/
static const char *prim_names[PRIM_UNKNOWN + 1] = {
"GL_POINTS",
"GL_LINES",
"GL_LINE_LOOP",
"GL_LINE_STRIP",
"GL_TRIANGLES",
"GL_TRIANGLE_STRIP",
"GL_TRIANGLE_FAN",
"GL_QUADS",
"GL_QUAD_STRIP",
"GL_POLYGON",
"outside begin/end",
"inside unknown primitive",
"unknown state"
};
/* Get the name of an enum given that it is a primitive type. Avoids /* Get the name of an enum given that it is a primitive type. Avoids
* GL_FALSE/GL_POINTS ambiguity and others. * GL_FALSE/GL_POINTS ambiguity and others.
*/ */
const char *_mesa_lookup_prim_by_nr( int nr ) const char *
_mesa_lookup_prim_by_nr(GLuint nr)
{ {
switch (nr) { if (nr < Elements(prim_names))
case GL_POINTS: return "GL_POINTS"; return prim_names[nr];
case GL_LINES: return "GL_LINES"; else
case GL_LINE_STRIP: return "GL_LINE_STRIP"; return "invalid mode";
case GL_LINE_LOOP: return "GL_LINE_LOOP";
case GL_TRIANGLES: return "GL_TRIANGLES";
case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP";
case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN";
case GL_QUADS: return "GL_QUADS";
case GL_QUAD_STRIP: return "GL_QUAD_STRIP";
case GL_POLYGON: return "GL_POLYGON";
case GL_POLYGON+1: return "OUTSIDE_BEGIN_END";
default: return "<invalid>";
}
} }
int _mesa_lookup_enum_by_name( const char *symbol ) int _mesa_lookup_enum_by_name( const char *symbol )
{ {
enum_elt * f = NULL; enum_elt * f = NULL;

View File

@ -45,7 +45,7 @@ extern const char *_mesa_lookup_enum_by_nr( int nr );
/* Get the name of an enum given that it is a primitive type. Avoids /* Get the name of an enum given that it is a primitive type. Avoids
* GL_FALSE/GL_POINTS ambiguity and others. * GL_FALSE/GL_POINTS ambiguity and others.
*/ */
const char *_mesa_lookup_prim_by_nr( int nr ); const char *_mesa_lookup_prim_by_nr( GLuint nr );
extern int _mesa_lookup_enum_by_name( const char *symbol ); extern int _mesa_lookup_enum_by_name( const char *symbol );

View File

@ -3317,10 +3317,6 @@ struct gl_context
}; };
/** The string names for GL_POINT, GL_LINE_LOOP, etc */
extern const char *_mesa_prim_name[GL_POLYGON+4];
#ifdef DEBUG #ifdef DEBUG
extern int MESA_VERBOSE; extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS; extern int MESA_DEBUG_FLAGS;