Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_pixels.c
index aaee401d7abc578f2c85092856353c759ebf8060..bbbd0d5740f26701e3ebc7e26813f601a6f83b2b 100644 (file)
@@ -23,7 +23,6 @@
  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */
 
 /*
  * Original rewrite:
 #include "tdfx_context.h"
 #include "tdfx_dd.h"
 #include "tdfx_lock.h"
-#include "tdfx_vb.h"
 #include "tdfx_pixels.h"
 #include "tdfx_render.h"
 
 #include "swrast/swrast.h"
 
-#include "image.h"
+#include "main/image.h"
 
 
 #define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)         \
@@ -155,7 +153,7 @@ inClipRects_Region(tdfxContextPtr fxMesa, int x, int y, int width, int height)
 
 #if 0
 GLboolean
-tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
+tdfx_bitmap_R5G6B5(struct gl_context * ctx, GLint px, GLint py,
                   GLsizei width, GLsizei height,
                   const struct gl_pixelstore_attrib *unpack,
                   const GLubyte * bitmap)
@@ -175,7 +173,7 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
                          SCISSOR_BIT |
                          STENCIL_BIT |
                          MASKING_BIT |
-                         ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+                         MULTI_DRAW_BIT)) return GL_FALSE;
 
    if (ctx->Scissor.Enabled) {
       /* This is a bit tricky, but by carefully adjusting the px, py,
@@ -264,10 +262,10 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
 
       for (row = 0; row < height; row++) {
         const GLubyte *src =
-           (const GLubyte *) _mesa_image_address(finalUnpack,
-                                                 bitmap, width, height,
-                                                 GL_COLOR_INDEX,
-                                                 GL_BITMAP, 0, row, 0);
+           (const GLubyte *) _mesa_image_address2d(finalUnpack,
+                                                    bitmap, width, height,
+                                                    GL_COLOR_INDEX,
+                                                    GL_BITMAP, row, 0);
         if (finalUnpack->LsbFirst) {
            /* least significan bit first */
            GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
@@ -319,7 +317,7 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
 
 #if 0
 GLboolean
-tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
+tdfx_bitmap_R8G8B8A8(struct gl_context * ctx, GLint px, GLint py,
                     GLsizei width, GLsizei height,
                     const struct gl_pixelstore_attrib *unpack,
                     const GLubyte * bitmap)
@@ -339,7 +337,7 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
                          SCISSOR_BIT |
                          STENCIL_BIT |
                          MASKING_BIT |
-                         ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+                         MULTI_DRAW_BIT)) return GL_FALSE;
 
    if (ctx->Scissor.Enabled) {
       /* This is a bit tricky, but by carefully adjusting the px, py,
@@ -423,10 +421,10 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
       /* compute dest address of bottom-left pixel in bitmap */
       for (row = 0; row < height; row++) {
         const GLubyte *src =
-           (const GLubyte *) _mesa_image_address(finalUnpack,
-                                                 bitmap, width, height,
-                                                 GL_COLOR_INDEX,
-                                                 GL_BITMAP, 0, row, 0);
+           (const GLubyte *) _mesa_image_address2d(finalUnpack,
+                                                    bitmap, width, height,
+                                                    GL_COLOR_INDEX,
+                                                    GL_BITMAP, row, 0);
         if (finalUnpack->LsbFirst) {
            /* least significan bit first */
            GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
@@ -477,7 +475,7 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
 #endif
 
 void
-tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
+tdfx_readpixels_R5G6B5(struct gl_context * ctx, GLint x, GLint y,
                       GLsizei width, GLsizei height,
                       GLenum format, GLenum type,
                       const struct gl_pixelstore_attrib *packing,
@@ -496,9 +494,9 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
    {
       tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
       GrLfbInfo_t info;
-
-      const GLint winX = fxMesa->x_offset;
-      const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+      __DRIdrawable *const readable = fxMesa->driReadable;
+      const GLint winX = readable->x;
+      const GLint winY = readable->y + readable->h - 1;
       const GLint scrX = winX + x;
       const GLint scrY = winY - y;
 
@@ -512,8 +510,8 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
             GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2);
         const GLushort *src = (const GLushort *) info.lfbPtr
            + scrY * srcStride + scrX;
-        GLubyte *dst = (GLubyte *) _mesa_image_address(packing,
-            dstImage, width, height, format, type, 0, 0, 0);
+        GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+            dstImage, width, height, format, type, 0, 0);
         const GLint dstStride = _mesa_image_row_stride(packing,
             width, format, type);
 
@@ -521,7 +519,7 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
         const GLint widthInBytes = width * 2;
         GLint row;
         for (row = 0; row < height; row++) {
-           MEMCPY(dst, src, widthInBytes);
+           memcpy(dst, src, widthInBytes);
            dst += dstStride;
            src -= srcStride;
         }
@@ -534,7 +532,7 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
 }
 
 void
-tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+tdfx_readpixels_R8G8B8A8(struct gl_context * ctx, GLint x, GLint y,
                          GLsizei width, GLsizei height,
                          GLenum format, GLenum type,
                          const struct gl_pixelstore_attrib *packing,
@@ -554,9 +552,9 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
    {
       tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
       GrLfbInfo_t info;
-
-      const GLint winX = fxMesa->x_offset;
-      const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+      __DRIdrawable *const readable = fxMesa->driReadable;
+      const GLint winX = readable->x;
+      const GLint winY = readable->y + readable->h - 1;
       const GLint scrX = winX + x;
       const GLint scrY = winY - y;
 
@@ -573,14 +571,14 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
             + scrY * srcStride + scrX;
          const GLint dstStride =
             _mesa_image_row_stride(packing, width, format, type);
-         GLubyte *dst = (GLubyte *) _mesa_image_address(packing,
-            dstImage, width, height, format, type, 0, 0, 0);
+         GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+            dstImage, width, height, format, type, 0, 0);
          const GLint widthInBytes = width * 4;
 
         {
             GLint row;
             for (row = 0; row < height; row++) {
-               MEMCPY(dst, src, widthInBytes);
+               memcpy(dst, src, widthInBytes);
                dst += dstStride;
                src -= srcStride;
             }
@@ -593,7 +591,7 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
 }
 
 void
-tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+tdfx_drawpixels_R8G8B8A8(struct gl_context * ctx, GLint x, GLint y,
                          GLsizei width, GLsizei height,
                          GLenum format, GLenum type,
                          const struct gl_pixelstore_attrib *unpack,
@@ -611,14 +609,13 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
        ctx->Depth.Test ||
        ctx->Fog.Enabled ||
        ctx->Scissor.Enabled ||
-       ctx->Stencil.Enabled ||
-       !ctx->Color.ColorMask[0] ||
-       !ctx->Color.ColorMask[1] ||
-       !ctx->Color.ColorMask[2] ||
-       !ctx->Color.ColorMask[3] ||
+       ctx->Stencil._Enabled ||
+       !ctx->Color.ColorMask[0][0] ||
+       !ctx->Color.ColorMask[0][1] ||
+       !ctx->Color.ColorMask[0][2] ||
+       !ctx->Color.ColorMask[0][3] ||
        ctx->Color.ColorLogicOpEnabled ||
        ctx->Texture._EnabledUnits ||
-       ctx->Depth.OcclusionTest ||
        fxMesa->Fallback)       
    {
       _swrast_DrawPixels( ctx, x, y, width, height, format, type, 
@@ -667,15 +664,15 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
             + scrY * dstStride + scrX * 4;
          const GLint srcStride =
             _mesa_image_row_stride(unpack, width, format, type);
-         const GLubyte *src = (GLubyte *) _mesa_image_address(unpack,
-            pixels, width, height, format, type, 0, 0, 0);
+         const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack,
+            pixels, width, height, format, type, 0, 0);
          const GLint widthInBytes = width * 4;
 
          if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) ||
              (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
             GLint row;
             for (row = 0; row < height; row++) {
-               MEMCPY(dst, src, widthInBytes);
+               memcpy(dst, src, widthInBytes);
                dst -= dstStride;
                src += srcStride;
             }