OSDN Git Service

mesa/main: Make FEATURE_colortable follow feature conventions.
authorChia-I Wu <olvaffe@gmail.com>
Mon, 7 Sep 2009 09:17:11 +0000 (17:17 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Sat, 12 Sep 2009 12:55:55 +0000 (20:55 +0800)
As shown in mfeatures.h, this allows users of colortab.h to work
without knowing if the feature is available.

src/mesa/main/api_exec.c
src/mesa/main/colortab.c
src/mesa/main/colortab.h
src/mesa/main/context.c
src/mesa/main/texobj.c
src/mesa/main/texstate.c

index 39941a1..30c142e 100644 (file)
@@ -54,9 +54,7 @@
 #endif
 #include "clear.h"
 #include "clip.h"
-#if FEATURE_colortable
 #include "colortab.h"
-#endif
 #include "context.h"
 #if FEATURE_convolve
 #include "convolve.h"
@@ -385,17 +383,7 @@ _mesa_init_exec_table(struct _glapi_table *exec)
    SET_BlendEquation(exec, _mesa_BlendEquation);
    SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT);
 
-#if FEATURE_colortable
-   SET_ColorSubTable(exec, _mesa_ColorSubTable);
-   SET_ColorTable(exec, _mesa_ColorTable);
-   SET_ColorTableParameterfv(exec, _mesa_ColorTableParameterfv);
-   SET_ColorTableParameteriv(exec, _mesa_ColorTableParameteriv);
-   SET_CopyColorSubTable(exec, _mesa_CopyColorSubTable);
-   SET_CopyColorTable(exec, _mesa_CopyColorTable);
-   SET_GetColorTable(exec, _mesa_GetColorTable);
-   SET_GetColorTableParameterfv(exec, _mesa_GetColorTableParameterfv);
-   SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv);
-#endif
+   _mesa_init_colortable_dispatch(exec);
 
 #if FEATURE_convolve
    SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D);
index 5a7de5f..d6f3121 100644 (file)
 #include "macros.h"
 #include "state.h"
 #include "teximage.h"
+#include "glapi/dispatch.h"
+
+
+#if FEATURE_colortable
 
 
 /**
@@ -1044,6 +1048,25 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
    }
 }
 
+
+void 
+_mesa_init_colortable_dispatch(struct _glapi_table *disp)
+{
+   SET_ColorSubTable(disp, _mesa_ColorSubTable);
+   SET_ColorTable(disp, _mesa_ColorTable);
+   SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv);
+   SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv);
+   SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable);
+   SET_CopyColorTable(disp, _mesa_CopyColorTable);
+   SET_GetColorTable(disp, _mesa_GetColorTable);
+   SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv);
+   SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv);
+}
+
+
+#endif /* FEATURE_colortable */
+
+
 /**********************************************************************/
 /*****                      Initialization                        *****/
 /**********************************************************************/
index b6ff737..ec28cec 100644 (file)
 #define COLORTAB_H
 
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 
-#if _HAVE_FULL_GL
+#if FEATURE_colortable
+
+#define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl)                \
+   do {                                                              \
+      (driver)->CopyColorTable       = impl ## CopyColorTable;       \
+      (driver)->CopyColorSubTable    = impl ## CopyColorSubTable;    \
+      (driver)->UpdateTexturePalette = impl ## UpdateTexturePalette; \
+   } while (0)
 
 extern void GLAPIENTRY
 _mesa_ColorTable( GLenum target, GLenum internalformat,
@@ -67,6 +74,19 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params );
 extern void GLAPIENTRY
 _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params );
 
+extern void 
+_mesa_init_colortable_dispatch(struct _glapi_table *disp);
+
+#else /* FEATURE_colortable */
+
+#define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl) do { } while (0)
+
+static INLINE void
+_mesa_init_colortable_dispatch(struct _glapi_table *disp)
+{
+}
+
+#endif /* FEATURE_colortable */
 
 
 extern void
@@ -81,20 +101,5 @@ _mesa_init_colortables( GLcontext *ctx );
 extern void 
 _mesa_free_colortables_data( GLcontext *ctx );
 
-#else
-
-/** No-op */
-#define _mesa_init_colortable( p ) ((void) 0)
-
-/** No-op */
-#define _mesa_free_colortable_data( p ) ((void) 0)
-
-/** No-op */
-#define _mesa_init_colortables( p ) ((void)0)
-
-/** No-op */
-#define _mesa_free_colortables_data( p ) ((void)0)
-
-#endif
 
-#endif
+#endif /* COLORTAB_H */
index f6d4ac4..1907c79 100644 (file)
@@ -90,9 +90,7 @@
 #include "blend.h"
 #include "buffers.h"
 #include "bufferobj.h"
-#if FEATURE_colortable
 #include "colortab.h"
-#endif
 #include "context.h"
 #include "cpuinfo.h"
 #include "debug.h"
@@ -686,9 +684,7 @@ init_attrib_groups(GLcontext *ctx)
 #endif
    _mesa_init_buffer_objects( ctx );
    _mesa_init_color( ctx );
-#if FEATURE_colortable
    _mesa_init_colortables( ctx );
-#endif
    _mesa_init_current( ctx );
    _mesa_init_depth( ctx );
    _mesa_init_debug( ctx );
@@ -1015,9 +1011,7 @@ _mesa_free_context_data( GLcontext *ctx )
    _mesa_free_texture_data( ctx );
    _mesa_free_matrix_data( ctx );
    _mesa_free_viewport_data( ctx );
-#if FEATURE_colortable
    _mesa_free_colortables_data( ctx );
-#endif
    _mesa_free_program_data(ctx);
    _mesa_free_shader_state(ctx);
 #if FEATURE_ARB_occlusion_query
index d09c439..678845e 100644 (file)
@@ -29,9 +29,7 @@
 
 
 #include "mfeatures.h"
-#if FEATURE_colortable
 #include "colortab.h"
-#endif
 #include "context.h"
 #include "enums.h"
 #include "fbobject.h"
@@ -194,9 +192,7 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
     */
    texObj->Target = 0x99;
 
-#if FEATURE_colortable
    _mesa_free_colortable_data(&texObj->Palette);
-#endif
 
    /* free the texture images */
    for (face = 0; face < 6; face++) {
index 861c5f3..b9311d0 100644 (file)
@@ -31,9 +31,7 @@
 #include "glheader.h"
 #include "mfeatures.h"
 #include "colormac.h"
-#if FEATURE_colortable
 #include "colortab.h"
-#endif
 #include "context.h"
 #include "enums.h"
 #include "macros.h"
@@ -753,9 +751,7 @@ _mesa_init_texture(GLcontext *ctx)
    ctx->Texture.CurrentUnit = 0;      /* multitexture */
    ctx->Texture._EnabledUnits = 0x0;
    ctx->Texture.SharedPalette = GL_FALSE;
-#if FEATURE_colortable
    _mesa_init_colortable(&ctx->Texture.Palette);
-#endif
 
    for (u = 0; u < MAX_TEXTURE_UNITS; u++)
       init_texture_unit(ctx, u);
@@ -796,10 +792,8 @@ _mesa_free_texture_data(GLcontext *ctx)
    for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++)
       ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]);
 
-#if FEATURE_colortable
    for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++)
       _mesa_free_colortable_data(&ctx->Texture.Unit[u].ColorTable);
-#endif
 }