st/mesa: add missing case for PIPE_FORMAT_B8G8R8A8_UNORM
[mesa.git] / src / mesa / swrast / s_drawpix.c
index 4733d10bb5923899da7ddaf0165eb1bb8cb00f9b..6970b2e9cb522ae2f4c05fbba373a674a07dabf3 100644 (file)
  */
 
 
-#include "glheader.h"
-#include "bufferobj.h"
-#include "context.h"
-#include "convolve.h"
-#include "image.h"
-#include "macros.h"
-#include "imports.h"
-#include "pixel.h"
-#include "state.h"
+#include "main/glheader.h"
+#include "main/bufferobj.h"
+#include "main/context.h"
+#include "main/convolve.h"
+#include "main/image.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/pixel.h"
+#include "main/state.h"
 
 #include "s_context.h"
-#include "s_drawpix.h"
 #include "s_span.h"
 #include "s_stencil.h"
 #include "s_zoom.h"
@@ -817,7 +816,6 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
 }
 
 
-
 /**
  * Execute software-based glDrawPixels.
  * By time we get here, all error checking will have been done.
@@ -831,8 +829,19 @@ _swrast_DrawPixels( GLcontext *ctx,
                    const GLvoid *pixels )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   GLboolean save_vp_override = ctx->VertexProgram._Overriden;
+
+   /* We are creating fragments directly, without going through vertex
+    * programs.
+    *
+    * This override flag tells the fragment processing code that its input
+    * comes from a non-standard source, and it may therefore not rely on
+    * optimizations that assume e.g. constant color if there is no color
+    * vertex array.
+    */
+   _mesa_set_vp_override(ctx, GL_TRUE);
 
-   RENDER_START(swrast,ctx);
+   swrast_render_start(ctx);
 
    if (ctx->NewState)
       _mesa_update_state(ctx);
@@ -840,27 +849,12 @@ _swrast_DrawPixels( GLcontext *ctx,
    if (swrast->NewState)
       _swrast_validate_derived( ctx );
 
-   if (unpack->BufferObj->Name) {
-      /* unpack from PBO */
-      GLubyte *buf;
-      if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
-                                     format, type, pixels)) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glDrawPixels(invalid PBO access)");
-         RENDER_FINISH(swrast, ctx);
-        return;
-      }
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                                              GL_READ_ONLY_ARB,
-                                              unpack->BufferObj);
-      if (!buf) {
-         /* buffer is already mapped - that's an error */
-         _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)");
-         RENDER_FINISH(swrast, ctx);
-        return;
-      }
-      pixels = ADD_POINTERS(buf, pixels);
-   }
+    pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
+    if (!pixels) {
+       swrast_render_finish(ctx);
+       _mesa_set_vp_override(ctx, save_vp_override);
+       return;
+    }
 
    switch (format) {
    case GL_STENCIL_INDEX:
@@ -897,64 +891,8 @@ _swrast_DrawPixels( GLcontext *ctx,
       /* don't return yet, clean-up */
    }
 
-   RENDER_FINISH(swrast,ctx);
-
-   if (unpack->BufferObj->Name) {
-      /* done with PBO so unmap it now */
-      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                              unpack->BufferObj);
-   }
-}
-
-
-
-#if 0  /* experimental */
-/*
- * Execute glDrawDepthPixelsMESA().
- */
-void
-_swrast_DrawDepthPixelsMESA( GLcontext *ctx,
-                             GLint x, GLint y,
-                             GLsizei width, GLsizei height,
-                             GLenum colorFormat, GLenum colorType,
-                             const GLvoid *colors,
-                             GLenum depthType, const GLvoid *depths,
-                             const struct gl_pixelstore_attrib *unpack )
-{
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
-   if (swrast->NewState)
-      _swrast_validate_derived( ctx );
-
-   RENDER_START(swrast,ctx);
-
-   switch (colorFormat) {
-   case GL_COLOR_INDEX:
-      if (ctx->Visual.rgbMode)
-        draw_rgba_pixels(ctx, x,y, width, height, colorFormat, colorType,
-                          unpack, colors);
-      else
-        draw_index_pixels(ctx, x, y, width, height, colorType,
-                           unpack, colors);
-      break;
-   case GL_RED:
-   case GL_GREEN:
-   case GL_BLUE:
-   case GL_ALPHA:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE_ALPHA:
-   case GL_RGB:
-   case GL_BGR:
-   case GL_RGBA:
-   case GL_BGRA:
-   case GL_ABGR_EXT:
-      draw_rgba_pixels(ctx, x, y, width, height, colorFormat, colorType,
-                       unpack, colors);
-      break;
-   default:
-      _mesa_problem(ctx, "unexpected format in glDrawDepthPixelsMESA");
-   }
+   swrast_render_finish(ctx);
+   _mesa_set_vp_override(ctx, save_vp_override);
 
-   RENDER_FINISH(swrast,ctx);
+   _mesa_unmap_pbo_source(ctx, unpack);
 }
-#endif