Mesa (mesa_7_4_branch): mesa: allow GL_BITMAP type in _mesa_image_image_stride()

Brian Paul brianp at kemper.freedesktop.org
Fri May 22 15:38:30 UTC 2009


Module: Mesa
Branch: mesa_7_4_branch
Commit: 9adca8814d4c342103d55c45cf191941cd355c98
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9adca8814d4c342103d55c45cf191941cd355c98

Author: Brian Paul <brianp at vmware.com>
Date:   Fri May 22 09:38:18 2009 -0600

mesa: allow GL_BITMAP type in _mesa_image_image_stride()

It's possible to hand a GL_COLOR_INDEX/GL_BITMAP image to glTexImage3D()
which gets converted to RGBA via the glPixelMap tables.

This fixes a failure with piglit/fdo10370 with Gallium.

(cherry picked from commit 995456f9305593005f8466520314ee087f3d422a)

---

 src/mesa/main/image.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 4d86c54..b41939c 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,8 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.5
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -738,12 +739,20 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
                           GLint width, GLint height,
                           GLenum format, GLenum type )
 {
+   GLint bytesPerRow, bytesPerImage, remainder;
+
    ASSERT(packing);
-   ASSERT(type != GL_BITMAP);
 
-   {
+   if (type == GL_BITMAP) {
+      if (packing->RowLength == 0) {
+         bytesPerRow = (width + 7) / 8;
+      }
+      else {
+         bytesPerRow = (packing->RowLength + 7) / 8;
+      }
+   }
+   else {
       const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
-      GLint bytesPerRow, bytesPerImage, remainder;
 
       if (bytesPerPixel <= 0)
          return -1;  /* error */
@@ -753,17 +762,18 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
       else {
          bytesPerRow = bytesPerPixel * packing->RowLength;
       }
-      remainder = bytesPerRow % packing->Alignment;
-      if (remainder > 0)
-         bytesPerRow += (packing->Alignment - remainder);
+   }
 
-      if (packing->ImageHeight == 0)
-         bytesPerImage = bytesPerRow * height;
-      else
-         bytesPerImage = bytesPerRow * packing->ImageHeight;
+   remainder = bytesPerRow % packing->Alignment;
+   if (remainder > 0)
+      bytesPerRow += (packing->Alignment - remainder);
 
-      return bytesPerImage;
-   }
+   if (packing->ImageHeight == 0)
+      bytesPerImage = bytesPerRow * height;
+   else
+      bytesPerImage = bytesPerRow * packing->ImageHeight;
+
+   return bytesPerImage;
 }
 
 




More information about the mesa-commit mailing list