mesa: Branch 'master' - 2 commits

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 12 15:50:38 UTC 2007


 src/mesa/main/image.c |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

New commits:
diff-tree 17fb7821d7cdc0ed211eaef013ee7798619a61d3 (from c1a544733749cd388b9f51d087c695b2ce0ec729)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Mar 12 09:49:44 2007 -0600

    clean-up, simplify _mesa_image_row_stride()

diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 58dd771..7c0b63b 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -651,44 +651,34 @@ _mesa_image_address3d( const struct gl_p
 
 
 /**
- * Compute the stride between image rows.
+ * Compute the stride (in bytes) between image rows.
  *
  * \param packing the pixelstore attributes
  * \param width image width.
  * \param format pixel format.
  * \param type pixel data type.
  * 
- * \return the stride in bytes for the given parameters.
+ * \return the stride in bytes for the given parameters, or -1 if error
  */
 GLint
 _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
                         GLint width, GLenum format, GLenum type )
 {
+   GLint bytesPerRow, remainder;
+
    ASSERT(packing);
+
    if (type == GL_BITMAP) {
-      /* BITMAP data */
-      GLint bytes, remainder;
       if (packing->RowLength == 0) {
-         bytes = (width + 7) / 8;
+         bytesPerRow = (width + 7) / 8;
       }
       else {
-         bytes = (packing->RowLength + 7) / 8;
+         bytesPerRow = (packing->RowLength + 7) / 8;
       }
-      if (packing->Invert) {
-         /* negate the bytes per row (negative row stride) */
-         bytes = -bytes;
-      }
-
-      remainder = bytes % packing->Alignment;
-      if (remainder > 0)
-         bytes += (packing->Alignment - remainder);
-
-      return bytes;
    }
    else {
       /* Non-BITMAP data */
       const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
-      GLint bytesPerRow, remainder;
       if (bytesPerPixel <= 0)
          return -1;  /* error */
       if (packing->RowLength == 0) {
@@ -697,13 +687,19 @@ _mesa_image_row_stride( const struct gl_
       else {
          bytesPerRow = bytesPerPixel * packing->RowLength;
       }
-      remainder = bytesPerRow % packing->Alignment;
-      if (remainder > 0)
-         bytesPerRow += (packing->Alignment - remainder);
-      if (packing->Invert)
-         bytesPerRow = -bytesPerRow;
-      return bytesPerRow;
    }
+
+   remainder = bytesPerRow % packing->Alignment;
+   if (remainder > 0) {
+      bytesPerRow += (packing->Alignment - remainder);
+   }
+
+   if (packing->Invert) {
+      /* negate the bytes per row (negative row stride) */
+      bytesPerRow = -bytesPerRow;
+   }
+
+   return bytesPerRow;
 }
 
 
diff-tree c1a544733749cd388b9f51d087c695b2ce0ec729 (from d0a3400f66b8c4ace7ebef6d0a944376d5203756)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Mar 12 09:35:44 2007 -0600

    take GL_UNPACK_ALIGNMENT into account in _mesa_image_row_stride() for GL_BITMAP type (bug 10261)

diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index eb91ebb..58dd771 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -667,7 +667,7 @@ _mesa_image_row_stride( const struct gl_
    ASSERT(packing);
    if (type == GL_BITMAP) {
       /* BITMAP data */
-      GLint bytes;
+      GLint bytes, remainder;
       if (packing->RowLength == 0) {
          bytes = (width + 7) / 8;
       }
@@ -678,6 +678,11 @@ _mesa_image_row_stride( const struct gl_
          /* negate the bytes per row (negative row stride) */
          bytes = -bytes;
       }
+
+      remainder = bytes % packing->Alignment;
+      if (remainder > 0)
+         bytes += (packing->Alignment - remainder);
+
       return bytes;
    }
    else {



More information about the mesa-commit mailing list