--- src/mesa/main/image.c | 67 ++++++++++++++++++++++++++++++++++++------------ src/mesa/main/image.h | 7 +++++ 2 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 3e0ca05..ba66c8a 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1088,13 +1088,12 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) /** - * Return the address of a specific pixel in an image (1D, 2D or 3D). + * Return the byte offset of a specific pixel in an image (1D, 2D or 3D). * * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image * \param packing the pixelstore attributes - * \param image starting address of image data * \param width the image width * \param height the image height * \param format the pixel format (must be validated beforehand) @@ -1102,18 +1101,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image - * - * \return address of pixel. + * + * \return offset of pixel. * * \sa gl_pixelstore_attrib. */ -GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) +GLintptr +_mesa_image_offset( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) { GLint alignment; /* 1, 2 or 4 */ GLint pixels_per_row; @@ -1121,7 +1119,7 @@ _mesa_image_address( GLuint dimensions, GLint skiprows; GLint skippixels; GLint skipimages; /* for 3-D volume images */ - GLubyte *pixel_addr; + GLintptr offset; ASSERT(dimensions >= 1 && dimensions <= 3); @@ -1162,8 +1160,7 @@ _mesa_image_address( GLuint dimensions, bytes_per_image = bytes_per_row * rows_per_image; - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + (skiprows + row) * bytes_per_row + (skippixels + column) / 8; } @@ -1196,14 +1193,50 @@ _mesa_image_address( GLuint dimensions, } /* compute final pixel address */ - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + topOfImage + (skiprows + row) * bytes_per_row + (skippixels + column) * bytes_per_pixel; } - return (GLvoid *) pixel_addr; + return offset; +} + + +/** + * Return the address of a specific pixel in an image (1D, 2D or 3D). + * + * Pixel unpacking/packing parameters are observed according to \p packing. + * + * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes + * \param image starting address of image data + * \param width the image width + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) + * \param img which image in the volume (0 for 1D or 2D images) + * \param row row of pixel in the image (0 for 1D images) + * \param column column of pixel in the image + * + * \return address of pixel. + * + * \sa gl_pixelstore_attrib. + */ +GLvoid * +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + const GLubyte *addr = (const GLubyte *) image; + + addr += _mesa_image_offset(dimensions, packing, width, height, + format, type, img, row, column); + + return (GLvoid *) addr; } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 46adaec..f0ce029 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -84,6 +84,13 @@ _mesa_is_integer_format(GLenum format); extern GLboolean _mesa_is_compressed_format(struct gl_context *ctx, GLenum format); +extern GLintptr +_mesa_image_offset( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ); + extern GLvoid * _mesa_image_address( GLuint dimensions, const struct gl_pixelstore_attrib *packing, -- 1.7.6.msysgit.0
From bc1cc2c4c0e03f764d2812ebd5b0c7c3e00bb3cc Mon Sep 17 00:00:00 2001 From: nobled <nob...@dreamwidth.org> Date: Tue, 18 Oct 2011 20:50:16 +0000 Subject: [PATCH 8/9] mesa: add _mesa_image_offset() --- src/mesa/main/image.c | 67 ++++++++++++++++++++++++++++++++++++------------ src/mesa/main/image.h | 7 +++++ 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 3e0ca05..ba66c8a 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1088,13 +1088,12 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) /** - * Return the address of a specific pixel in an image (1D, 2D or 3D). + * Return the byte offset of a specific pixel in an image (1D, 2D or 3D). * * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image * \param packing the pixelstore attributes - * \param image starting address of image data * \param width the image width * \param height the image height * \param format the pixel format (must be validated beforehand) @@ -1102,18 +1101,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image - * - * \return address of pixel. + * + * \return offset of pixel. * * \sa gl_pixelstore_attrib. */ -GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) +GLintptr +_mesa_image_offset( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) { GLint alignment; /* 1, 2 or 4 */ GLint pixels_per_row; @@ -1121,7 +1119,7 @@ _mesa_image_address( GLuint dimensions, GLint skiprows; GLint skippixels; GLint skipimages; /* for 3-D volume images */ - GLubyte *pixel_addr; + GLintptr offset; ASSERT(dimensions >= 1 && dimensions <= 3); @@ -1162,8 +1160,7 @@ _mesa_image_address( GLuint dimensions, bytes_per_image = bytes_per_row * rows_per_image; - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + (skiprows + row) * bytes_per_row + (skippixels + column) / 8; } @@ -1196,14 +1193,50 @@ _mesa_image_address( GLuint dimensions, } /* compute final pixel address */ - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + topOfImage + (skiprows + row) * bytes_per_row + (skippixels + column) * bytes_per_pixel; } - return (GLvoid *) pixel_addr; + return offset; +} + + +/** + * Return the address of a specific pixel in an image (1D, 2D or 3D). + * + * Pixel unpacking/packing parameters are observed according to \p packing. + * + * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes + * \param image starting address of image data + * \param width the image width + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) + * \param img which image in the volume (0 for 1D or 2D images) + * \param row row of pixel in the image (0 for 1D images) + * \param column column of pixel in the image + * + * \return address of pixel. + * + * \sa gl_pixelstore_attrib. + */ +GLvoid * +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + const GLubyte *addr = (const GLubyte *) image; + + addr += _mesa_image_offset(dimensions, packing, width, height, + format, type, img, row, column); + + return (GLvoid *) addr; } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 46adaec..f0ce029 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -84,6 +84,13 @@ _mesa_is_integer_format(GLenum format); extern GLboolean _mesa_is_compressed_format(struct gl_context *ctx, GLenum format); +extern GLintptr +_mesa_image_offset( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ); + extern GLvoid * _mesa_image_address( GLuint dimensions, const struct gl_pixelstore_attrib *packing, -- 1.7.6.msysgit.0
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev