mesa: Split out part of glGetTexLevelParameter into a helper function.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 11 Jun 2012 08:27:38 +0000 (01:27 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 17 Aug 2012 16:14:36 +0000 (09:14 -0700)
Move the _mesa_GetTexLevelParameter[iv] functions below the helper
function so the prototype is available.

This will be useful in the next commit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/texparam.c

index fe4115c4e3b428b647c0603524793a0df461109d..7285c47d1731240e5dc3799979e9a32533283207 100644 (file)
@@ -905,51 +905,14 @@ legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target)
 }
 
 
-void GLAPIENTRY
-_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
-                              GLenum pname, GLfloat *params )
-{
-   GLint iparam;
-   _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
-   *params = (GLfloat) iparam;
-}
-
-
-void GLAPIENTRY
-_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
-                              GLenum pname, GLint *params )
+static void
+get_tex_level_parameter_image(struct gl_context *ctx,
+                              struct gl_texture_object *texObj,
+                              GLenum target, GLint level,
+                              GLenum pname, GLint *params)
 {
-   const struct gl_texture_unit *texUnit;
-   struct gl_texture_object *texObj;
    const struct gl_texture_image *img = NULL;
-   GLint maxLevels;
    gl_format texFormat;
-   GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
-
-   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTexLevelParameteriv(current unit)");
-      return;
-   }
-
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
-   if (!legal_get_tex_level_parameter_target(ctx, target)) {
-      _mesa_error(ctx, GL_INVALID_ENUM,
-                  "glGetTexLevelParameter[if]v(target=0x%x)", target);
-      return;
-   }
-
-   maxLevels = _mesa_max_texture_levels(ctx, target);
-   assert(maxLevels != 0);
-
-   if (level < 0 || level >= maxLevels) {
-      _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
-      return;
-   }
-
-   texObj = _mesa_select_tex_object(ctx, texUnit, target);
 
    img = _mesa_select_tex_image(ctx, texObj, target, level);
    if (!img || img->TexFormat == MESA_FORMAT_NONE) {
@@ -1089,6 +1052,53 @@ invalid_pname:
 }
 
 
+void GLAPIENTRY
+_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
+                              GLenum pname, GLfloat *params )
+{
+   GLint iparam;
+   _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
+   *params = (GLfloat) iparam;
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
+                              GLenum pname, GLint *params )
+{
+   const struct gl_texture_unit *texUnit;
+   struct gl_texture_object *texObj;
+   GLint maxLevels;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetTexLevelParameteriv(current unit)");
+      return;
+   }
+
+   texUnit = _mesa_get_current_tex_unit(ctx);
+
+   if (!legal_get_tex_level_parameter_target(ctx, target)) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glGetTexLevelParameter[if]v(target=0x%x)", target);
+      return;
+   }
+
+   maxLevels = _mesa_max_texture_levels(ctx, target);
+   assert(maxLevels != 0);
+
+   if (level < 0 || level >= maxLevels) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
+      return;
+   }
+
+   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+   get_tex_level_parameter_image(ctx, texObj, target, level, pname, params);
+}
+
 
 void GLAPIENTRY
 _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )