mesa: skip bitmap drawing code if width==0 or height==0
authorBrian Paul <brianp@vmware.com>
Tue, 1 Sep 2009 23:40:07 +0000 (17:40 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 1 Sep 2009 23:40:07 +0000 (17:40 -0600)
src/mesa/main/drawpix.c

index 67311f71a2671abda40bd67aea5021aaa4c21c91..aef6585641ed73478484ec60049c0fec89b3ce47 100644 (file)
@@ -264,27 +264,30 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
 
    if (ctx->RenderMode == GL_RENDER) {
       /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
-      const GLfloat epsilon = 0.0001F;
-      GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
-      GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
-
-      if (ctx->Unpack.BufferObj->Name) {
-         /* unpack from PBO */
-         if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
-                                        GL_COLOR_INDEX, GL_BITMAP,
-                                        (GLvoid *) bitmap)) {
-            _mesa_error(ctx, GL_INVALID_OPERATION,
-                        "glBitmap(invalid PBO access)");
-            return;
-         }
-         if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) {
-            /* buffer is mapped - that's an error */
-            _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
-            return;
+      if (width > 0 && height > 0) {
+         const GLfloat epsilon = 0.0001F;
+         GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
+         GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
+
+         if (ctx->Unpack.BufferObj->Name) {
+            /* unpack from PBO */
+            if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
+                                           GL_COLOR_INDEX, GL_BITMAP,
+                                           (GLvoid *) bitmap)) {
+               _mesa_error(ctx, GL_INVALID_OPERATION,
+                           "glBitmap(invalid PBO access)");
+               return;
+            }
+            if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) {
+               /* buffer is mapped - that's an error */
+               _mesa_error(ctx, GL_INVALID_OPERATION,
+                           "glBitmap(PBO is mapped)");
+               return;
+            }
          }
-      }
 
-      ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
+         ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
+      }
    }
 #if _HAVE_FULL_GL
    else if (ctx->RenderMode == GL_FEEDBACK) {