Remove unused texunit parameter to ctx->Driver.GenerateMipmap()
[mesa.git] / src / mesa / main / drawpix.c
index d9b724bc06d5d6c8e4ae3ea3c67604c03e2174ab..fde933843095522911387a0804b379076b836cd7 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "glheader.h"
 #include "imports.h"
+#include "bufferobj.h"
 #include "context.h"
 #include "drawpix.h"
 #include "feedback.h"
@@ -182,6 +183,23 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
       /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
       GLint x = IROUND(ctx->Current.RasterPos[0]);
       GLint y = IROUND(ctx->Current.RasterPos[1]);
+
+      if (ctx->Unpack.BufferObj->Name) {
+         /* unpack from PBO */
+         if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
+                                        format, type, pixels)) {
+            _mesa_error(ctx, GL_INVALID_OPERATION,
+                        "glDrawPixels(invalid PBO access)");
+            return;
+         }
+         if (ctx->Unpack.BufferObj->Pointer) {
+            /* buffer is mapped - that's an error */
+            _mesa_error(ctx, GL_INVALID_OPERATION,
+                        "glDrawPixels(PBO is mapped)");
+            return;
+         }
+      }
+
       ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
                             &ctx->Unpack, pixels);
    }
@@ -300,6 +318,21 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
       return;
    }
 
+   if (ctx->Pack.BufferObj->Name) {
+      if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1,
+                                     format, type, pixels)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glReadPixels(invalid PBO access)");
+         return;
+      }
+
+      if (ctx->Pack.BufferObj->Pointer) {
+         /* buffer is mapped - that's an error */
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)");
+         return;
+      }
+   }
+
    ctx->Driver.ReadPixels(ctx, x, y, width, height,
                          format, type, &ctx->Pack, pixels);
 }
@@ -341,8 +374,26 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
 
    if (ctx->RenderMode == GL_RENDER) {
       /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
-      GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
-      GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig);
+      const GLfloat epsilon = 0.0001;
+      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 (ctx->Unpack.BufferObj->Pointer) {
+            /* 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 );
    }
 #if _HAVE_FULL_GL