Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/span.c

    r2938 r3598  
    1 /* $Id: span.c,v 1.1 2000-02-29 00:50:10 sandervl Exp $ */
     1/* $Id: span.c,v 1.2 2000-05-23 20:40:53 jeroen Exp $ */
    22
    33/*
    44 * Mesa 3-D graphics library
    5  * Version:  3.1
     5 * Version:  3.3
    66 *
    77 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
     
    2626
    2727
    28 
    29 
    30 
    3128/*
    3229 * pixel span rasterization:
    33  * These functions simulate the rasterization pipeline.
     30 * These functions implement the rasterization pipeline.
    3431 */
    3532
     
    3835#include "all.h"
    3936#else
    40 #ifndef XFree86Server
    41 #include <assert.h>
    42 #include <string.h>
    43 #else
    44 #include "GL/xf86glx.h"
    45 #endif
     37#include "glheader.h"
    4638#include "alpha.h"
    4739#include "alphabuf.h"
     
    5244#include "macros.h"
    5345#include "masking.h"
     46#include "mem.h"
    5447#include "scissor.h"
    5548#include "span.h"
     
    7568   for (i=0;i<n;i++) {
    7669      if ((m & stipple)==0) {
    77         mask[i] = 0;
     70        mask[i] = 0;
    7871      }
    7972      m = m >> 1;
    8073      if (m==0) {
    81         m = 0x80000000;
     74        m = 0x80000000;
    8275      }
    8376   }
     
    9790
    9891   /* Clip to top and bottom */
    99    if (y<0 || y>=ctx->Buffer->Height) {
     92   if (y < 0 || y >= ctx->DrawBuffer->Height) {
    10093      return 0;
    10194   }
    10295
    10396   /* Clip to left and right */
    104    if (x>=0 && x+n<=ctx->Buffer->Width) {
     97   if (x >= 0 && x + n <= ctx->DrawBuffer->Width) {
    10598      /* no clipping needed */
    10699      return 1;
    107100   }
    108    else if (x+n<=0) {
     101   else if (x + n <= 0) {
    109102      /* completely off left side */
    110103      return 0;
    111104   }
    112    else if (x>=ctx->Buffer->Width) {
     105   else if (x >= ctx->DrawBuffer->Width) {
    113106      /* completely off right side */
    114107      return 0;
     
    117110      /* clip-test each pixel, this could be done better */
    118111      for (i=0;i<n;i++) {
    119          if (x+i<0 || x+i>=ctx->Buffer->Width) {
     112         if (x + i < 0 || x + i >= ctx->DrawBuffer->Width) {
    120113            mask[i] = 0;
    121114         }
     
    146139
    147140         if (bufferBit == FRONT_LEFT_BIT)
    148             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_LEFT);
     141            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
    149142         else if (bufferBit == FRONT_RIGHT_BIT)
    150             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_RIGHT);
     143            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
    151144         else if (bufferBit == BACK_LEFT_BIT)
    152             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_LEFT);
     145            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
    153146         else
    154             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_RIGHT);
     147            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
    155148
    156149         /* make copy of incoming indexes */
     
    167160
    168161   /* restore default dest buffer */
    169    (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer);
     162   (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer);
    170163}
    171164
     
    183176void gl_write_index_span( GLcontext *ctx,
    184177                          GLuint n, GLint x, GLint y, const GLdepth z[],
    185                           GLuint indexIn[], GLenum primitive )
     178                          GLuint indexIn[], GLenum primitive )
    186179{
    187180   GLubyte mask[MAX_WIDTH];
     
    194187   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    195188      if (clip_span(ctx,n,x,y,mask)==0) {
    196         return;
     189        return;
    197190      }
    198191   }
     
    210203   /* Per-pixel fog */
    211204   if (ctx->Fog.Enabled && (primitive==GL_BITMAP || ctx->FogMode == FOG_FRAGMENT)) {
    212       gl_fog_ci_pixels( ctx, n, z, index );
     205      _mesa_fog_ci_pixels( ctx, n, z, index );
    213206   }
    214207
     
    216209   if (ctx->Scissor.Enabled) {
    217210      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    218         return;
     211        return;
    219212      }
    220213   }
     
    227220   if (ctx->Stencil.Enabled) {
    228221      /* first stencil test */
    229       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    230          return;
    231       }
    232       /* depth buffering w/ stencil */
    233       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     222      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     223         return;
     224      }
    234225   }
    235226   else if (ctx->Depth.Test) {
    236227      /* regular depth testing */
    237       if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0)  return;
    238    }
     228      if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0)  return;
     229   }
     230
     231   /* if we get here, something passed the depth test */
     232   ctx->OcclusionResult = GL_TRUE;
    239233
    240234   if (ctx->RasterMask & MULTI_DRAW_BIT) {
     
    261255void gl_write_monoindex_span( GLcontext *ctx,
    262256                              GLuint n, GLint x, GLint y, const GLdepth z[],
    263                               GLuint index, GLenum primitive )
     257                              GLuint index, GLenum primitive )
    264258{
    265259   GLubyte mask[MAX_WIDTH];
     
    271265   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    272266      if (clip_span( ctx, n, x, y, mask)==0) {
    273         return;
     267        return;
    274268      }
    275269   }
     
    278272   if (ctx->Scissor.Enabled) {
    279273      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    280         return;
     274        return;
    281275      }
    282276   }
     
    289283   if (ctx->Stencil.Enabled) {
    290284      /* first stencil test */
    291       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    292          return;
    293       }
    294       /* depth buffering w/ stencil */
    295       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     285      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     286         return;
     287      }
    296288   }
    297289   else if (ctx->Depth.Test) {
    298290      /* regular depth testing */
    299       if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0)  return;
    300    }
     291      if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0)  return;
     292   }
     293
     294   /* if we get here, something passed the depth test */
     295   ctx->OcclusionResult = GL_TRUE;
    301296
    302297   if (ctx->Color.DrawBuffer == GL_NONE) {
     
    310305      GLuint indexes[MAX_WIDTH];
    311306      for (i=0;i<n;i++) {
    312         indexes[i] = index;
     307        indexes[i] = index;
    313308      }
    314309
    315310      if (ctx->Fog.Enabled && (primitive==GL_BITMAP || ctx->FogMode==FOG_FRAGMENT)) {
    316          gl_fog_ci_pixels( ctx, n, z, indexes );
     311         _mesa_fog_ci_pixels( ctx, n, z, indexes );
    317312      }
    318313
    319314      if (ctx->Color.SWLogicOpEnabled) {
    320         gl_logicop_ci_span( ctx, n, x, y, indexes, mask );
     315        gl_logicop_ci_span( ctx, n, x, y, indexes, mask );
    321316      }
    322317
     
    379374
    380375         if (bufferBit == FRONT_LEFT_BIT) {
    381             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_LEFT);
    382             ctx->Buffer->Alpha = ctx->Buffer->FrontLeftAlpha;
     376            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
     377            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha;
    383378         }
    384379         else if (bufferBit == FRONT_RIGHT_BIT) {
    385             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_RIGHT);
    386             ctx->Buffer->Alpha = ctx->Buffer->FrontRightAlpha;
     380            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
     381            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha;
    387382         }
    388383         else if (bufferBit == BACK_LEFT_BIT) {
    389             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_LEFT);
    390             ctx->Buffer->Alpha = ctx->Buffer->BackLeftAlpha;
     384            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
     385            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha;
    391386         }
    392387         else {
    393             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_RIGHT);
    394             ctx->Buffer->Alpha = ctx->Buffer->BackRightAlpha;
     388            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
     389            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha;
    395390         }
    396391
     
    402397         }
    403398         else if (ctx->Color.BlendEnabled) {
    404             gl_blend_span( ctx, n, x, y, rgbaTmp, mask );
     399            _mesa_blend_span( ctx, n, x, y, rgbaTmp, mask );
    405400         }
    406401         if (ctx->Color.SWmasking) {
     
    409404
    410405         (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
    411                                        (const GLubyte (*)[4]) rgbaTmp, mask );
     406                                       (const GLubyte (*)[4]) rgbaTmp, mask );
    412407         if (ctx->RasterMask & ALPHABUF_BIT) {
    413408            gl_write_alpha_span( ctx, n, x, y,
    414                                 (const GLubyte (*)[4])rgbaTmp, mask );
     409                                (const GLubyte (*)[4])rgbaTmp, mask );
    415410         }
    416411      }
     
    418413
    419414   /* restore default dest buffer */
    420    (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer );
     415   (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
    421416}
    422417
     
    439434   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    440435      if (clip_span( ctx,n,x,y,mask)==0) {
    441         return;
     436        return;
    442437      }
    443438      write_all = GL_FALSE;
     
    456451   /* Per-pixel fog */
    457452   if (ctx->Fog.Enabled && (primitive==GL_BITMAP || ctx->FogMode==FOG_FRAGMENT)) {
    458       gl_fog_rgba_pixels( ctx, n, z, rgba );
     453      _mesa_fog_rgba_pixels( ctx, n, z, rgba );
    459454   }
    460455
     
    462457   if (ctx->Scissor.Enabled) {
    463458      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    464         return;
     459        return;
    465460      }
    466461      write_all = GL_FALSE;
     
    475470   /* Do the alpha test */
    476471   if (ctx->Color.AlphaEnabled) {
    477       if (gl_alpha_test( ctx, n, (const GLubyte (*)[4]) rgba, mask )==0) {
    478         return;
     472      if (_mesa_alpha_test( ctx, n, (const GLubyte (*)[4]) rgba, mask )==0) {
     473        return;
    479474      }
    480475      write_all = GL_FALSE;
     
    483478   if (ctx->Stencil.Enabled) {
    484479      /* first stencil test */
    485       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    486          return;
    487       }
    488       /* depth buffering w/ stencil */
    489       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     480      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     481         return;
     482      }
    490483      write_all = GL_FALSE;
    491484   }
    492485   else if (ctx->Depth.Test) {
    493486      /* regular depth testing */
    494       GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
     487      GLuint m = _mesa_depth_test_span( ctx, n, x, y, z, mask );
    495488      if (m==0) {
    496489         return;
     
    501494   }
    502495
     496   /* if we get here, something passed the depth test */
     497   ctx->OcclusionResult = GL_TRUE;
     498
    503499   if (ctx->RasterMask & MULTI_DRAW_BIT) {
    504500      multi_write_rgba_span( ctx, n, x, y,
    505                              (const GLubyte (*)[4]) rgba,
    506                              write_all ? Null : mask );
     501                             (const GLubyte (*)[4]) rgba,
     502                             write_all ? Null : mask );
    507503   }
    508504   else {
     
    513509      }
    514510      else if (ctx->Color.BlendEnabled) {
    515          gl_blend_span( ctx, n, x, y, rgba, mask );
     511         _mesa_blend_span( ctx, n, x, y, rgba, mask );
    516512      }
    517513
     
    523519      /* write pixels */
    524520      (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
    525                                     (const GLubyte (*)[4]) rgba,
    526                                     write_all ? Null : mask );
     521                                    (const GLubyte (*)[4]) rgba,
     522                                    write_all ? Null : mask );
    527523
    528524      if (ctx->RasterMask & ALPHABUF_BIT) {
    529525         gl_write_alpha_span( ctx, n, x, y,
    530                               (const GLubyte (*)[4]) rgba,
    531                               write_all ? Null : mask );
     526                              (const GLubyte (*)[4]) rgba,
     527                              write_all ? Null : mask );
    532528      }
    533529
     
    549545void gl_write_monocolor_span( GLcontext *ctx,
    550546                              GLuint n, GLint x, GLint y, const GLdepth z[],
    551                               const GLubyte color[4],
     547                              const GLubyte color[4],
    552548                              GLenum primitive )
    553549{
     
    563559   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    564560      if (clip_span( ctx,n,x,y,mask)==0) {
    565         return;
     561        return;
    566562      }
    567563      write_all = GL_FALSE;
     
    571567   if (ctx->Scissor.Enabled) {
    572568      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    573         return;
     569        return;
    574570      }
    575571      write_all = GL_FALSE;
     
    587583         rgba[i][ACOMP] = color[ACOMP];
    588584      }
    589       if (gl_alpha_test( ctx, n, (const GLubyte (*)[4])rgba, mask )==0) {
    590         return;
     585      if (_mesa_alpha_test( ctx, n, (const GLubyte (*)[4])rgba, mask )==0) {
     586        return;
    591587      }
    592588      write_all = GL_FALSE;
     
    595591   if (ctx->Stencil.Enabled) {
    596592      /* first stencil test */
    597       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    598          return;
    599       }
    600       /* depth buffering w/ stencil */
    601       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     593      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     594         return;
     595      }
    602596      write_all = GL_FALSE;
    603597   }
    604598   else if (ctx->Depth.Test) {
    605599      /* regular depth testing */
    606       GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
     600      GLuint m = _mesa_depth_test_span( ctx, n, x, y, z, mask );
    607601      if (m==0) {
    608602         return;
     
    612606      }
    613607   }
     608
     609   /* if we get here, something passed the depth test */
     610   ctx->OcclusionResult = GL_TRUE;
    614611
    615612   if (ctx->Color.DrawBuffer == GL_NONE) {
     
    622619      /* assign same color to each pixel */
    623620      for (i=0;i<n;i++) {
    624         if (mask[i]) {
     621        if (mask[i]) {
    625622            COPY_4UBV(rgba[i], color);
    626         }
     623        }
    627624      }
    628625
    629626      if (ctx->RasterMask & MULTI_DRAW_BIT) {
    630627         multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
    631                                 mask );
     628                                mask );
    632629      }
    633630      else {
     
    637634         }
    638635         else if (ctx->Color.BlendEnabled) {
    639             gl_blend_span( ctx, n, x, y, rgba, mask );
     636            _mesa_blend_span( ctx, n, x, y, rgba, mask );
    640637         }
    641638
     
    647644         /* write pixels */
    648645         (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
    649                                        (const GLubyte (*)[4]) rgba,
    650                                        write_all ? Null : mask );
     646                                       (const GLubyte (*)[4]) rgba,
     647                                       write_all ? Null : mask );
    651648         if (ctx->RasterMask & ALPHABUF_BIT) {
    652649            gl_write_alpha_span( ctx, n, x, y,
    653                                 (const GLubyte (*)[4]) rgba,
    654                                 write_all ? Null : mask );
     650                                (const GLubyte (*)[4]) rgba,
     651                                write_all ? Null : mask );
    655652         }
    656653      }
     
    669666         }
    670667         multi_write_rgba_span( ctx, n, x, y,
    671                                 (const GLubyte (*)[4]) rgba,
    672                                 mask );
     668                                (const GLubyte (*)[4]) rgba,
     669                                mask );
    673670      }
    674671      else {
     
    717714void gl_write_texture_span( GLcontext *ctx,
    718715                            GLuint n, GLint x, GLint y, const GLdepth z[],
    719                             const GLfloat s[], const GLfloat t[],
     716                            const GLfloat s[], const GLfloat t[],
    720717                            const GLfloat u[], GLfloat lambda[],
    721                             GLubyte rgbaIn[][4], CONST GLubyte spec[][4],
    722                             GLenum primitive )
     718                            GLubyte rgbaIn[][4], CONST GLubyte spec[][4],
     719                            GLenum primitive )
    723720{
    724721   GLubyte mask[MAX_WIDTH];
     
    733730   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    734731      if (clip_span(ctx, n, x, y, mask)==0) {
    735         return;
     732        return;
    736733      }
    737734      write_all = GL_FALSE;
     
    741738   if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) {
    742739      /* must make a copy of the colors since they may be modified */
    743       MEMCPY(rgbaBackup, rgbaIn, 4 * sizeof(GLubyte));
     740      MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte));
    744741      rgba = rgbaBackup;
    745742   }
     
    755752   if (spec && ctx->Light.Enabled
    756753       && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
    757       add_colors( n, rgba, spec );   /* rgba = rgba + spec */
     754      add_colors( n, rgba, spec );                    /* rgba = rgba + spec*/
    758755
    759756   /* Per-pixel fog */
    760757   if (ctx->Fog.Enabled && (primitive==GL_BITMAP || ctx->FogMode==FOG_FRAGMENT)) {
    761       gl_fog_rgba_pixels( ctx, n, z, rgba );
     758      _mesa_fog_rgba_pixels( ctx, n, z, rgba );
    762759   }
    763760
     
    765762   if (ctx->Scissor.Enabled) {
    766763      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    767         return;
     764        return;
    768765      }
    769766      write_all = GL_FALSE;
     
    778775   /* Do the alpha test */
    779776   if (ctx->Color.AlphaEnabled) {
    780       if (gl_alpha_test( ctx, n, (const GLubyte (*)[4]) rgba, mask )==0) {
    781         return;
     777      if (_mesa_alpha_test( ctx, n, (const GLubyte (*)[4]) rgba, mask )==0) {
     778        return;
    782779      }
    783780      write_all = GL_FALSE;
     
    786783   if (ctx->Stencil.Enabled) {
    787784      /* first stencil test */
    788       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    789          return;
    790       }
    791       /* depth buffering w/ stencil */
    792       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     785      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     786         return;
     787      }
    793788      write_all = GL_FALSE;
    794789   }
    795790   else if (ctx->Depth.Test) {
    796791      /* regular depth testing */
    797       GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
     792      GLuint m = _mesa_depth_test_span( ctx, n, x, y, z, mask );
    798793      if (m==0) {
    799794         return;
     
    804799   }
    805800
     801   /* if we get here, something passed the depth test */
     802   ctx->OcclusionResult = GL_TRUE;
     803
    806804   if (ctx->RasterMask & MULTI_DRAW_BIT) {
    807805      multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4])rgba,
    808                              write_all ? Null : mask );
     806                             write_all ? Null : mask );
    809807   }
    810808   else {
     
    814812      }
    815813      else  if (ctx->Color.BlendEnabled) {
    816          gl_blend_span( ctx, n, x, y, rgba, mask );
     814         _mesa_blend_span( ctx, n, x, y, rgba, mask );
    817815      }
    818816      if (ctx->Color.SWmasking) {
     
    821819
    822820      (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4])rgba,
    823                                     write_all ? Null : mask );
     821                                    write_all ? Null : mask );
    824822      if (ctx->RasterMask & ALPHABUF_BIT) {
    825823         gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
    826                               write_all ? Null : mask );
     824                              write_all ? Null : mask );
    827825      }
    828826   }
     
    835833 * Input:  texUnits - number of texture units to apply
    836834 */
    837 void gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
    838                                  GLuint n, GLint x, GLint y,
    839                                  const GLdepth z[],
    840                                  CONST GLfloat s[][MAX_WIDTH],
    841                                  CONST GLfloat t[][MAX_WIDTH],
    842                                  CONST GLfloat u[][MAX_WIDTH],
    843                                  GLfloat lambda[][MAX_WIDTH],
    844                                  GLubyte rgbaIn[][4], CONST GLubyte spec[][4],
    845                                  GLenum primitive )
     835void
     836gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
     837                            GLuint n, GLint x, GLint y,
     838                            const GLdepth z[],
     839                            CONST GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH],
     840                            CONST GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH],
     841                            CONST GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH],
     842                            GLfloat lambda[][MAX_WIDTH],
     843                            GLubyte rgbaIn[MAX_TEXTURE_UNITS][4],
     844                            CONST GLubyte spec[MAX_TEXTURE_UNITS][4],
     845                            GLenum primitive )
    846846{
    847847   GLubyte mask[MAX_WIDTH];
     
    857857   if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
    858858      if (clip_span(ctx, n, x, y, mask)==0) {
    859         return;
     859        return;
    860860      }
    861861      write_all = GL_FALSE;
     
    865865   if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) {
    866866      /* must make a copy of the colors since they may be modified */
    867       MEMCPY(rgbaBackup, rgbaIn, 4 * sizeof(GLubyte));
     867      MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte));
    868868      rgba = rgbaBackup;
    869869   }
     
    882882   if (spec && ctx->Light.Enabled
    883883       && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
    884       add_colors( n, rgba, spec );   /* rgba = rgba + spec */
     884      add_colors( n, rgba, spec );                    /* rgba = rgba + spec*/
    885885
    886886   /* Per-pixel fog */
    887887   if (ctx->Fog.Enabled && (primitive==GL_BITMAP || ctx->FogMode==FOG_FRAGMENT)) {
    888       gl_fog_rgba_pixels( ctx, n, z, rgba );
     888      _mesa_fog_rgba_pixels( ctx, n, z, rgba );
    889889   }
    890890
     
    892892   if (ctx->Scissor.Enabled) {
    893893      if (gl_scissor_span( ctx, n, x, y, mask )==0) {
    894         return;
     894        return;
    895895      }
    896896      write_all = GL_FALSE;
     
    905905   /* Do the alpha test */
    906906   if (ctx->Color.AlphaEnabled) {
    907       if (gl_alpha_test( ctx, n, (const GLubyte (*)[4])rgba, mask )==0) {
    908         return;
     907      if (_mesa_alpha_test( ctx, n, (const GLubyte (*)[4])rgba, mask )==0) {
     908        return;
    909909      }
    910910      write_all = GL_FALSE;
     
    913913   if (ctx->Stencil.Enabled) {
    914914      /* first stencil test */
    915       if (gl_stencil_span( ctx, n, x, y, mask )==0) {
    916          return;
    917       }
    918       /* depth buffering w/ stencil */
    919       gl_depth_stencil_span( ctx, n, x, y, z, mask );
     915      if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) {
     916         return;
     917      }
    920918      write_all = GL_FALSE;
    921919   }
    922920   else if (ctx->Depth.Test) {
    923921      /* regular depth testing */
    924       GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
     922      GLuint m = _mesa_depth_test_span( ctx, n, x, y, z, mask );
    925923      if (m==0) {
    926924         return;
     
    931929   }
    932930
     931   /* if we get here, something passed the depth test */
     932   ctx->OcclusionResult = GL_TRUE;
     933
    933934   if (ctx->RasterMask & MULTI_DRAW_BIT) {
    934       multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, write_all ? Null : mask );
     935      multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
     936                             write_all ? Null : mask );
    935937   }
    936938   else {
     
    941943      }
    942944      else  if (ctx->Color.BlendEnabled) {
    943          gl_blend_span( ctx, n, x, y, rgba, mask );
     945         _mesa_blend_span( ctx, n, x, y, rgba, mask );
    944946      }
    945947      if (ctx->Color.SWmasking) {
     
    950952      if (ctx->RasterMask & ALPHABUF_BIT) {
    951953         gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4])rgba,
    952                               write_all ? Null : mask );
     954                              write_all ? Null : mask );
    953955      }
    954956   }
     
    961963 * reading ouside the buffer's boundaries.
    962964 */
    963 void gl_read_rgba_span( GLcontext *ctx,
     965void gl_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
    964966                        GLuint n, GLint x, GLint y,
    965967                        GLubyte rgba[][4] )
    966968{
    967    if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) {
     969   if (y < 0 || y >= buffer->Height
     970       || x + (GLint) n < 0 || x >= buffer->Width) {
    968971      /* completely above, below, or right */
    969       MEMSET( rgba, 0, 4 * n * sizeof(GLubyte)); /*XXX maybe leave undefined?*/
     972      /* XXX maybe leave undefined? */
     973      MEMSET( rgba, 0, 4 * n * sizeof(GLubyte));
    970974   }
    971975   else {
     
    979983            return;
    980984         }
    981          if (length > ctx->Buffer->Width) {
    982             length = ctx->Buffer->Width;
    983          }
    984       }
    985       else if ((GLint) (x + n) > ctx->Buffer->Width) {
     985         if (length > buffer->Width) {
     986            length = buffer->Width;
     987         }
     988      }
     989      else if ((GLint) (x + n) > buffer->Width) {
    986990         /* right edge clipping */
    987991         skip = 0;
    988          length = ctx->Buffer->Width - x;
     992         length = buffer->Width - x;
    989993         if (length < 0) {
    990994            /* completely to right of window */
     
    10121016 * reading ouside the buffer's boundaries.
    10131017 */
    1014 void gl_read_index_span( GLcontext *ctx,
     1018void gl_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
    10151019                         GLuint n, GLint x, GLint y, GLuint indx[] )
    10161020{
    1017    register GLuint i;
    1018 
    1019    if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) {
     1021   if (y < 0 || y >= buffer->Height
     1022       || x + (GLint) n < 0 || x >= buffer->Width) {
    10201023      /* completely above, below, or right */
    1021       for (i=0;i<n;i++) {
    1022          indx[i] = 0;
    1023       }
     1024      MEMSET(indx, 0, n * sizeof(GLuint));
    10241025   }
    10251026   else {
     
    10331034            return;
    10341035         }
    1035          if (length > ctx->Buffer->Width) {
    1036             length = ctx->Buffer->Width;
    1037          }
    1038       }
    1039       else if ((GLint) (x + n) > ctx->Buffer->Width) {
     1036         if (length > buffer->Width) {
     1037            length = buffer->Width;
     1038         }
     1039      }
     1040      else if ((GLint) (x + n) > buffer->Width) {
    10401041         /* right edge clipping */
    10411042         skip = 0;
    1042          length = ctx->Buffer->Width - x;
     1043         length = buffer->Width - x;
    10431044         if (length < 0) {
    10441045            /* completely to right of window */
Note: See TracChangeset for help on using the changeset viewer.