aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-11 09:43:30 -0700
committerKeith Whitwell <[email protected]>2008-09-21 22:13:54 -0700
commit74c64fa748c833a9688d3a141a7807686701e24f (patch)
tree84098cbb1a002e1a2f228af3d3a6fb25745325c7 /src/mesa/main
parente93243f8b7d43695654a36334c8cc5cea140d23c (diff)
code refactoring, new next_mipmap_level_size() function
(cherry picked from commit c22d9152e33792ea58426c53bc9b96bf552b0b44)
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mipmap.c77
-rw-r--r--src/mesa/main/mipmap.h4
2 files changed, 54 insertions, 27 deletions
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 9d57f424fd4..ebc3c9ace40 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -900,13 +900,58 @@ _mesa_generate_mipmap_level(GLenum target,
/* no mipmaps, do nothing */
break;
default:
- _mesa_problem(ctx, "bad dimensions in _mesa_generate_mipmaps");
+ _mesa_problem(NULL, "bad dimensions in _mesa_generate_mipmaps");
return;
}
}
/**
+ * compute next (level+1) image size
+ * \return GL_FALSE if no smaller size can be generated (eg. src is 1x1x1 size)
+ */
+static GLboolean
+next_mipmap_level_size(GLenum target, GLint border,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLint *dstWidth, GLint *dstHeight, GLint *dstDepth)
+{
+ if (srcWidth - 2 * border > 1) {
+ *dstWidth = (srcWidth - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ *dstWidth = srcWidth; /* can't go smaller */
+ }
+
+ if ((srcHeight - 2 * border > 1) &&
+ (target != GL_TEXTURE_1D_ARRAY_EXT)) {
+ *dstHeight = (srcHeight - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ *dstHeight = srcHeight; /* can't go smaller */
+ }
+
+ if ((srcDepth - 2 * border > 1) &&
+ (target != GL_TEXTURE_2D_ARRAY_EXT)) {
+ *dstDepth = (srcDepth - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ *dstDepth = srcDepth; /* can't go smaller */
+ }
+
+ if (*dstWidth == srcWidth &&
+ *dstHeight == srcHeight &&
+ *dstDepth == srcDepth) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
+}
+
+
+
+
+/**
* For GL_SGIX_generate_mipmap:
* Generate a complete set of mipmaps from texObj's base-level image.
* Stop at texObj's MaxLevel or when we get to the 1x1 texture.
@@ -995,6 +1040,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
GLint srcWidth, srcHeight, srcDepth;
GLint dstWidth, dstHeight, dstDepth;
GLint border, bytesPerTexel;
+ GLboolean nextLevel;
/* get src image parameters */
srcImage = _mesa_select_tex_image(ctx, texObj, target, level);
@@ -1004,31 +1050,10 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
srcDepth = srcImage->Depth;
border = srcImage->Border;
- /* compute next (level+1) image size */
- if (srcWidth - 2 * border > 1) {
- dstWidth = (srcWidth - 2 * border) / 2 + 2 * border;
- }
- else {
- dstWidth = srcWidth; /* can't go smaller */
- }
- if ((srcHeight - 2 * border > 1) &&
- (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT)) {
- dstHeight = (srcHeight - 2 * border) / 2 + 2 * border;
- }
- else {
- dstHeight = srcHeight; /* can't go smaller */
- }
- if ((srcDepth - 2 * border > 1) &&
- (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT)) {
- dstDepth = (srcDepth - 2 * border) / 2 + 2 * border;
- }
- else {
- dstDepth = srcDepth; /* can't go smaller */
- }
-
- if (dstWidth == srcWidth &&
- dstHeight == srcHeight &&
- dstDepth == srcDepth) {
+ nextLevel = next_mipmap_level_size(target, border,
+ srcWidth, srcHeight, srcDepth,
+ &dstWidth, &dstHeight, &dstDepth);
+ if (!nextLevel) {
/* all done */
if (srcImage->IsCompressed) {
_mesa_free((void *) srcData);
diff --git a/src/mesa/main/mipmap.h b/src/mesa/main/mipmap.h
index b6491f55073..22094c34372 100644
--- a/src/mesa/main/mipmap.h
+++ b/src/mesa/main/mipmap.h
@@ -35,8 +35,10 @@ _mesa_generate_mipmap_level(GLenum target,
GLint border,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
const GLubyte *srcData,
+ GLint srcRowStride,
GLint dstWidth, GLint dstHeight, GLint dstDepth,
- GLubyte *dstData);
+ GLubyte *dstData,
+ GLint dstRowStride);
extern void