ReactOS 0.4.15-dev-8109-gd7be748
span.c File Reference
#include <string.h>
#include "alpha.h"
#include "alphabuf.h"
#include "blend.h"
#include "depth.h"
#include "fog.h"
#include "logic.h"
#include "macros.h"
#include "masking.h"
#include "scissor.h"
#include "span.h"
#include "stencil.h"
#include "texture.h"
#include "types.h"
Include dependency graph for span.c:

Go to the source code of this file.

Functions

static void stipple_polygon_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte mask[])
 
static GLuint clip_span (GLcontext *ctx, GLint n, GLint x, GLint y, GLubyte mask[])
 
void gl_write_index_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLuint index[], GLenum primitive)
 
void gl_write_monoindex_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLuint index, GLenum primitive)
 
void gl_write_color_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLubyte r[], GLubyte g[], GLubyte b[], GLubyte a[], GLenum primitive)
 
void gl_write_monocolor_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLint r, GLint g, GLint b, GLint a, GLenum primitive)
 
void gl_write_texture_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLfloat s[], GLfloat t[], GLfloat u[], GLfloat lambda[], GLubyte r[], GLubyte g[], GLubyte b[], GLubyte a[], GLenum primitive)
 
void gl_read_color_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
 
void gl_read_index_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint indx[])
 

Function Documentation

◆ clip_span()

static GLuint clip_span ( GLcontext ctx,
GLint  n,
GLint  x,
GLint  y,
GLubyte  mask[] 
)
static

Definition at line 122 of file span.c.

124{
125 GLint i;
126
127 /* Clip to top and bottom */
128 if (y<0 || y>=ctx->Buffer->Height) {
129 return 0;
130 }
131
132 /* Clip to left and right */
133 if (x>=0 && x+n<=ctx->Buffer->Width) {
134 /* no clipping needed */
135 return 1;
136 }
137 else if (x+n<=0) {
138 /* completely off left side */
139 return 0;
140 }
141 else if (x>=ctx->Buffer->Width) {
142 /* completely off right side */
143 return 0;
144 }
145 else {
146 /* clip-test each pixel, this could be done better */
147 for (i=0;i<n;i++) {
148 if (x+i<0 || x+i>=ctx->Buffer->Width) {
149 mask[i] = 0;
150 }
151 }
152 return 1;
153 }
154}
Definition: bufpool.h:45
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
int GLint
Definition: gl.h:156
GLdouble n
Definition: glext.h:7729
GLenum GLint GLuint mask
Definition: glext.h:6028
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by gl_write_color_span(), gl_write_index_span(), gl_write_monocolor_span(), gl_write_monoindex_span(), and gl_write_texture_span().

◆ gl_read_color_span()

void gl_read_color_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLubyte  red[],
GLubyte  green[],
GLubyte  blue[],
GLubyte  alpha[] 
)

Definition at line 850 of file span.c.

854{
855 register GLuint i;
856
857 if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) {
858 /* completely above, below, or right */
859 for (i=0;i<n;i++) {
860 red[i] = green[i] = blue[i] = alpha[i] = 0;
861 }
862 }
863 else {
864 if (x>=0 && x+n<=ctx->Buffer->Width) {
865 /* OK */
866 (*ctx->Driver.ReadColorSpan)( ctx, n, x, y, red, green, blue, alpha );
867 if (ctx->RasterMask & ALPHABUF_BIT) {
869 }
870 }
871 else {
872 i = 0;
873 if (x<0) {
874 while (x<0 && n>0) {
875 red[i] = green[i] = blue[i] = alpha[i] = 0;
876 x++;
877 n--;
878 i++;
879 }
880 }
881 n = MIN2( n, ctx->Buffer->Width - x );
882 (*ctx->Driver.ReadColorSpan)( ctx, n, x, y, red+i, green+i, blue+i, alpha+i);
883 if (ctx->RasterMask & ALPHABUF_BIT) {
885 }
886 }
887 }
888}
void gl_read_alpha_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte alpha[])
Definition: alphabuf.c:246
#define ALPHABUF_BIT
Definition: types.h:1223
GLclampf green
Definition: gl.h:1740
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
unsigned int GLuint
Definition: gl.h:159
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67
#define MIN2(A, B)
Definition: macros.h:159

Referenced by copy_rgb_pixels(), copy_tex_sub_image(), gl_blend_span(), gl_logicop_rgba_span(), gl_mask_color_span(), and read_color_image().

◆ gl_read_index_span()

void gl_read_index_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLuint  indx[] 
)

Definition at line 897 of file span.c.

899{
900 register GLuint i;
901
902 if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) {
903 /* completely above, below, or right */
904 for (i=0;i<n;i++) {
905 indx[i] = 0;
906 }
907 }
908 else {
909 if (x>=0 && x+n<=ctx->Buffer->Width) {
910 /* OK */
911 (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, indx );
912 }
913 else {
914 i = 0;
915 if (x<0) {
916 while (x<0 && n>0) {
917 indx[i] = 0;
918 x++;
919 n--;
920 i++;
921 }
922 }
923 n = MIN2( n, ctx->Buffer->Width - x );
924 (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, indx+i );
925 }
926 }
927}

Referenced by copy_ci_pixels(), and gl_mask_index_span().

◆ gl_write_color_span()

void gl_write_color_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLdepth  z[],
GLubyte  r[],
GLubyte  g[],
GLubyte  b[],
GLubyte  a[],
GLenum  primitive 
)

Definition at line 378 of file span.c.

383{
385 GLboolean write_all = GL_TRUE;
386 GLubyte rtmp[MAX_WIDTH], gtmp[MAX_WIDTH], btmp[MAX_WIDTH], atmp[MAX_WIDTH];
387 GLubyte *red, *green, *blue, *alpha;
388
389 /* init mask to 1's (all pixels are to be written) */
390 MEMSET(mask, 1, n);
391
392 if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
393 if (clip_span( ctx,n,x,y,mask)==0) {
394 return;
395 }
396 write_all = GL_FALSE;
397 }
398
399 if ((primitive==GL_BITMAP && ctx->MutablePixels)
400 || (ctx->RasterMask & FRONT_AND_BACK_BIT)) {
401 /* must make a copy of the colors since they may be modified */
402 MEMCPY( rtmp, r, n * sizeof(GLubyte) );
403 MEMCPY( gtmp, g, n * sizeof(GLubyte) );
404 MEMCPY( btmp, b, n * sizeof(GLubyte) );
405 MEMCPY( atmp, a, n * sizeof(GLubyte) );
406 red = rtmp;
407 green = gtmp;
408 blue = btmp;
409 alpha = atmp;
410 }
411 else {
412 red = r;
413 green = g;
414 blue = b;
415 alpha = a;
416 }
417
418 /* Per-pixel fog */
419 if (ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP
420 || ctx->Texture.Enabled)) {
422 }
423
424 /* Do the scissor test */
425 if (ctx->Scissor.Enabled) {
426 if (gl_scissor_span( ctx, n, x, y, mask )==0) {
427 return;
428 }
429 write_all = GL_FALSE;
430 }
431
432 /* Polygon Stippling */
433 if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
435 write_all = GL_FALSE;
436 }
437
438 /* Do the alpha test */
439 if (ctx->Color.AlphaEnabled) {
440 if (gl_alpha_test( ctx, n, alpha, mask )==0) {
441 return;
442 }
443 write_all = GL_FALSE;
444 }
445
446 if (ctx->Stencil.Enabled) {
447 /* first stencil test */
448 if (gl_stencil_span( ctx, n, x, y, mask )==0) {
449 return;
450 }
451 /* depth buffering w/ stencil */
453 write_all = GL_FALSE;
454 }
455 else if (ctx->Depth.Test) {
456 /* regular depth testing */
457 GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
458 if (m==0) {
459 return;
460 }
461 if (m<n) {
462 write_all = GL_FALSE;
463 }
464 }
465
466 if (ctx->RasterMask & NO_DRAW_BIT) {
467 /* write no pixels */
468 return;
469 }
470
471 /* logic op or blending */
472 if (ctx->Color.SWLogicOpEnabled) {
474 }
475 else if (ctx->Color.BlendEnabled) {
477 }
478
479 /* Color component masking */
480 if (ctx->Color.SWmasking) {
482 }
483
484 /* write pixels */
485 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
486 write_all ? NULL : mask );
487 if (ctx->RasterMask & ALPHABUF_BIT) {
488 gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask );
489 }
490
491 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
492 /*** Also render to back buffer ***/
493 MEMCPY( rtmp, r, n * sizeof(GLubyte) );
494 MEMCPY( gtmp, g, n * sizeof(GLubyte) );
495 MEMCPY( btmp, b, n * sizeof(GLubyte) );
496 MEMCPY( atmp, a, n * sizeof(GLubyte) );
497 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
498 if (ctx->Color.SWLogicOpEnabled) {
500 }
501 else if (ctx->Color.BlendEnabled) {
503 }
504 if (ctx->Color.SWmasking) {
506 }
507 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
508 write_all ? NULL : mask );
509 if (ctx->RasterMask & ALPHABUF_BIT) {
510 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
511 gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask );
512 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
513 }
514 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
515 }
516
517}
GLint gl_alpha_test(GLcontext *ctx, GLuint n, const GLubyte alpha[], GLubyte mask[])
Definition: alpha.c:92
void gl_write_alpha_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte alpha[], GLubyte mask[])
Definition: alphabuf.c:155
void gl_blend_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], GLubyte mask[])
Definition: blend.c:507
#define NULL
Definition: types.h:112
#define MAX_WIDTH
Definition: config.h:130
#define FRONT_AND_BACK_BIT
Definition: types.h:1225
#define NO_DRAW_BIT
Definition: types.h:1226
#define WINCLIP_BIT
Definition: types.h:1224
void gl_fog_color_pixels(GLcontext *ctx, GLuint n, const GLdepth z[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: fog.c:252
unsigned char GLubyte
Definition: gl.h:157
#define GL_TRUE
Definition: gl.h:174
#define GL_NICEST
Definition: gl.h:585
#define GL_BACK
Definition: gl.h:271
#define GL_BITMAP
Definition: gl.h:497
#define GL_FALSE
Definition: gl.h:173
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GL_POLYGON
Definition: gl.h:199
#define GL_FRONT
Definition: gl.h:270
unsigned char GLboolean
Definition: gl.h:151
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLdouble GLdouble z
Definition: glext.h:5874
const GLfloat * m
Definition: glext.h:10848
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
void gl_logicop_rgba_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], GLubyte mask[])
Definition: logic.c:364
#define MEMSET(DST, VAL, N)
Definition: macros.h:241
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
void gl_mask_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: masking.c:93
GLint gl_scissor_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte mask[])
Definition: scissor.c:87
static GLuint clip_span(GLcontext *ctx, GLint n, GLint x, GLint y, GLubyte mask[])
Definition: span.c:122
static void stipple_polygon_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte mask[])
Definition: span.c:96
GLint gl_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte mask[])
Definition: stencil.c:339
void gl_depth_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], GLubyte mask[])
Definition: stencil.c:514

Referenced by copy_depth_pixels(), copy_rgb_pixels(), draw_color_pixels(), draw_depth_pixels(), draw_index_pixels(), and gl_write_zoomed_color_span().

◆ gl_write_index_span()

void gl_write_index_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLdepth  z[],
GLuint  index[],
GLenum  primitive 
)

Definition at line 167 of file span.c.

170{
172 GLuint index_save[MAX_WIDTH];
173
174 /* init mask to 1's (all pixels are to be written) */
175 MEMSET(mask, 1, n);
176
177 if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
178 if (clip_span(ctx,n,x,y,mask)==0) {
179 return;
180 }
181 }
182
183 /* Per-pixel fog */
184 if (ctx->Fog.Enabled
185 && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP)) {
187 }
188
189 /* Do the scissor test */
190 if (ctx->Scissor.Enabled) {
191 if (gl_scissor_span( ctx, n, x, y, mask )==0) {
192 return;
193 }
194 }
195
196 /* Polygon Stippling */
197 if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
199 }
200
201 if (ctx->Stencil.Enabled) {
202 /* first stencil test */
203 if (gl_stencil_span( ctx, n, x, y, mask )==0) {
204 return;
205 }
206 /* depth buffering w/ stencil */
208 }
209 else if (ctx->Depth.Test) {
210 /* regular depth testing */
211 if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0) return;
212 }
213
214 if (ctx->RasterMask & NO_DRAW_BIT) {
215 /* write no pixels */
216 return;
217 }
218
219 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
220 /* Save a copy of the indexes since LogicOp and IndexMask
221 * may change them
222 */
223 MEMCPY( index_save, index, n * sizeof(GLuint) );
224 }
225
226 if (ctx->Color.SWLogicOpEnabled) {
228 }
229 if (ctx->Color.SWmasking) {
231 }
232
233 /* write pixels */
234 (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, index, mask );
235
236
237 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
238 /*** Also draw to back buffer ***/
239 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
240 MEMCPY( index, index_save, n * sizeof(GLuint) );
241 if (ctx->Color.SWLogicOpEnabled) {
243 }
244 if (ctx->Color.SWmasking) {
246 }
247 (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, index, mask );
248 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
249 }
250}
void gl_fog_index_pixels(GLcontext *ctx, GLuint n, const GLdepth z[], GLuint index[])
Definition: fog.c:333
GLuint index
Definition: glext.h:6031
void gl_logicop_ci_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[], GLubyte mask[])
Definition: logic.c:105
void gl_mask_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[])
Definition: masking.c:161

Referenced by copy_ci_pixels(), copy_depth_pixels(), draw_depth_pixels(), draw_index_pixels(), and gl_write_zoomed_index_span().

◆ gl_write_monocolor_span()

void gl_write_monocolor_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLdepth  z[],
GLint  r,
GLint  g,
GLint  b,
GLint  a,
GLenum  primitive 
)

Definition at line 531 of file span.c.

535{
536 GLuint i;
538 GLboolean write_all = GL_TRUE;
540
541 /* init mask to 1's (all pixels are to be written) */
542 MEMSET(mask, 1, n);
543
544 if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
545 if (clip_span( ctx,n,x,y,mask)==0) {
546 return;
547 }
548 write_all = GL_FALSE;
549 }
550
551 /* Do the scissor test */
552 if (ctx->Scissor.Enabled) {
553 if (gl_scissor_span( ctx, n, x, y, mask )==0) {
554 return;
555 }
556 write_all = GL_FALSE;
557 }
558
559 /* Polygon Stippling */
560 if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
562 write_all = GL_FALSE;
563 }
564
565 /* Do the alpha test */
566 if (ctx->Color.AlphaEnabled) {
568 for (i=0;i<n;i++) {
569 alpha[i] = a;
570 }
571 if (gl_alpha_test( ctx, n, alpha, mask )==0) {
572 return;
573 }
574 write_all = GL_FALSE;
575 }
576
577 if (ctx->Stencil.Enabled) {
578 /* first stencil test */
579 if (gl_stencil_span( ctx, n, x, y, mask )==0) {
580 return;
581 }
582 /* depth buffering w/ stencil */
584 write_all = GL_FALSE;
585 }
586 else if (ctx->Depth.Test) {
587 /* regular depth testing */
588 GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
589 if (m==0) {
590 return;
591 }
592 if (m<n) {
593 write_all = GL_FALSE;
594 }
595 }
596
597 if (ctx->RasterMask & NO_DRAW_BIT) {
598 /* write no pixels */
599 return;
600 }
601
602 if (ctx->Color.BlendEnabled || ctx->Color.SWLogicOpEnabled
603 || ctx->Color.SWmasking) {
604 /* assign same color to each pixel */
605 for (i=0;i<n;i++) {
606 if (mask[i]) {
607 red[i] = r;
608 green[i] = g;
609 blue[i] = b;
610 alpha[i] = a;
611 }
612 }
613
614 if (ctx->Color.SWLogicOpEnabled) {
616 }
617 else if (ctx->Color.BlendEnabled) {
619 }
620
621 /* Color component masking */
622 if (ctx->Color.SWmasking) {
624 }
625
626 /* write pixels */
627 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
628 write_all ? NULL : mask );
629 if (ctx->RasterMask & ALPHABUF_BIT) {
630 gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask );
631 }
632
633 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
634 /*** Also draw to back buffer ***/
635 for (i=0;i<n;i++) {
636 if (mask[i]) {
637 red[i] = r;
638 green[i] = g;
639 blue[i] = b;
640 alpha[i] = a;
641 }
642 }
643 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
644 if (ctx->Color.SWLogicOpEnabled) {
646 }
647 else if (ctx->Color.BlendEnabled) {
649 }
650 if (ctx->Color.SWmasking) {
652 }
653 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
654 write_all ? NULL : mask );
655 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
656 if (ctx->RasterMask & ALPHABUF_BIT) {
657 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
659 write_all ? NULL : mask );
660 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
661 }
662 }
663 }
664 else {
665 (*ctx->Driver.WriteMonocolorSpan)( ctx, n, x, y, mask );
666 if (ctx->RasterMask & ALPHABUF_BIT) {
667 gl_write_mono_alpha_span( ctx, n, x, y, a, write_all ? NULL : mask );
668 }
669 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
670 /* Also draw to back buffer */
671 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
672 (*ctx->Driver.WriteMonocolorSpan)( ctx, n, x, y, mask );
673 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
674 if (ctx->RasterMask & ALPHABUF_BIT) {
675 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
677 write_all ? NULL : mask );
678 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
679 }
680 }
681 }
682}
void gl_write_mono_alpha_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte alpha, GLubyte mask[])
Definition: alphabuf.c:177

◆ gl_write_monoindex_span()

void gl_write_monoindex_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLdepth  z[],
GLuint  index,
GLenum  primitive 
)

Definition at line 255 of file span.c.

258{
259 GLuint i;
261 GLuint index_save[MAX_WIDTH];
262
263 /* init mask to 1's (all pixels are to be written) */
264 MEMSET(mask, 1, n);
265
266 if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP)
267 {
268 if (clip_span( ctx,n,x,y,mask)==0) {
269 return;
270 }
271 }
272
273 /* Do the scissor test */
274 if (ctx->Scissor.Enabled)
275 {
276 if (gl_scissor_span( ctx, n, x, y, mask )==0) {
277 return;
278 }
279 }
280
281 /* Polygon Stippling */
282 if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON)
283 {
285 }
286
287 if (ctx->Stencil.Enabled)
288 {
289 /* first stencil test */
290 if (gl_stencil_span( ctx, n, x, y, mask )==0)
291 {
292 return;
293 }
294 /* depth buffering w/ stencil */
296 }
297 else if (ctx->Depth.Test)
298 {
299 /* regular depth testing */
300 if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0)
301 return;
302 }
303
304 if (ctx->RasterMask & NO_DRAW_BIT)
305 {
306 /* write no pixels */
307 return;
308 }
309
310 if ((ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP))
311 || ctx->Color.SWLogicOpEnabled || ctx->Color.SWmasking)
312 {
313 GLuint ispan[MAX_WIDTH];
314 /* index may change, replicate single index into an array */
315 for (i=0;i<n;i++)
316 {
317 ispan[i] = index;
318 }
319
320 if (ctx->Fog.Enabled
321 && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP))
322 {
323 gl_fog_index_pixels( ctx, n, z, ispan );
324 }
325
326 if (ctx->RasterMask & FRONT_AND_BACK_BIT)
327 {
328 MEMCPY( index_save, ispan, n * sizeof(GLuint) );
329 }
330
331 if (ctx->Color.SWLogicOpEnabled)
332 {
333 gl_logicop_ci_span( ctx, n, x, y, ispan, mask );
334 }
335
336 if (ctx->Color.SWmasking)
337 {
338 gl_mask_index_span( ctx, n, x, y, ispan );
339 }
340
341 (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, ispan, mask );
342
343 if (ctx->RasterMask & FRONT_AND_BACK_BIT)
344 {
345 /*** Also draw to back buffer ***/
346 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
347 for (i=0;i<n;i++)
348 {
349 ispan[i] = index;
350 }
351
352 if (ctx->Color.SWLogicOpEnabled) {
353 gl_logicop_ci_span( ctx, n, x, y, ispan, mask );
354 }
355 if (ctx->Color.SWmasking) {
356 gl_mask_index_span( ctx, n, x, y, ispan );
357 }
358 (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, ispan, mask );
359 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
360 }
361 }
362 else
363 {
364 (*ctx->Driver.WriteMonoindexSpan)( ctx, n, x, y, mask );
365
366 if (ctx->RasterMask & FRONT_AND_BACK_BIT)
367 {
368 /*** Also draw to back buffer ***/
369 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
370 (*ctx->Driver.WriteMonoindexSpan)( ctx, n, x, y, mask );
371 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
372 }
373 }
374}
#define index(s, c)
Definition: various.h:29

◆ gl_write_texture_span()

void gl_write_texture_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLdepth  z[],
GLfloat  s[],
GLfloat  t[],
GLfloat  u[],
GLfloat  lambda[],
GLubyte  r[],
GLubyte  g[],
GLubyte  b[],
GLubyte  a[],
GLenum  primitive 
)

Definition at line 699 of file span.c.

706{
708 GLboolean write_all = GL_TRUE;
709 GLubyte rtmp[MAX_WIDTH], gtmp[MAX_WIDTH], btmp[MAX_WIDTH], atmp[MAX_WIDTH];
710 GLubyte *red, *green, *blue, *alpha;
711
712 /* init mask to 1's (all pixels are to be written) */
713 MEMSET(mask, 1, n);
714
715 if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
716 if (clip_span( ctx,n,x,y,mask)==0) {
717 return;
718 }
719 write_all = GL_FALSE;
720 }
721
722
723 if (primitive==GL_BITMAP || (ctx->RasterMask & FRONT_AND_BACK_BIT)) {
724 /* must make a copy of the colors since they may be modified */
725 MEMCPY( rtmp, r, n * sizeof(GLubyte) );
726 MEMCPY( gtmp, g, n * sizeof(GLubyte) );
727 MEMCPY( btmp, b, n * sizeof(GLubyte) );
728 MEMCPY( atmp, a, n * sizeof(GLubyte) );
729 red = rtmp;
730 green = gtmp;
731 blue = btmp;
732 alpha = atmp;
733 }
734 else {
735 red = r;
736 green = g;
737 blue = b;
738 alpha = a;
739 }
740
741 /* Texture */
742 ASSERT(ctx->Texture.Enabled);
743 gl_texture_pixels( ctx, n, s, t, u, lambda, red, green, blue, alpha );
744
745 /* Per-pixel fog */
746 if (ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP
747 || ctx->Texture.Enabled)) {
749 }
750
751 /* Do the scissor test */
752 if (ctx->Scissor.Enabled) {
753 if (gl_scissor_span( ctx, n, x, y, mask )==0) {
754 return;
755 }
756 write_all = GL_FALSE;
757 }
758
759 /* Polygon Stippling */
760 if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) {
762 write_all = GL_FALSE;
763 }
764
765 /* Do the alpha test */
766 if (ctx->Color.AlphaEnabled) {
767 if (gl_alpha_test( ctx, n, alpha, mask )==0) {
768 return;
769 }
770 write_all = GL_FALSE;
771 }
772
773 if (ctx->Stencil.Enabled) {
774 /* first stencil test */
775 if (gl_stencil_span( ctx, n, x, y, mask )==0) {
776 return;
777 }
778 /* depth buffering w/ stencil */
780 write_all = GL_FALSE;
781 }
782 else if (ctx->Depth.Test) {
783 /* regular depth testing */
784 GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
785 if (m==0) {
786 return;
787 }
788 if (m<n) {
789 write_all = GL_FALSE;
790 }
791 }
792
793 if (ctx->RasterMask & NO_DRAW_BIT) {
794 /* write no pixels */
795 return;
796 }
797
798 /* blending */
799 if (ctx->Color.SWLogicOpEnabled) {
801 }
802 else if (ctx->Color.BlendEnabled) {
804 }
805
806 if (ctx->Color.SWmasking) {
808 }
809
810 /* write pixels */
811 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
812 write_all ? NULL : mask );
813 if (ctx->RasterMask & ALPHABUF_BIT) {
814 gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask );
815 }
816
817 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
818 /* Also draw to back buffer */
819 MEMCPY( rtmp, r, n * sizeof(GLubyte) );
820 MEMCPY( gtmp, g, n * sizeof(GLubyte) );
821 MEMCPY( btmp, b, n * sizeof(GLubyte) );
822 MEMCPY( atmp, a, n * sizeof(GLubyte) );
823 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
824 if (ctx->Color.SWLogicOpEnabled) {
826 }
827 else if (ctx->Color.BlendEnabled) {
829 }
830 if (ctx->Color.SWmasking) {
832 }
833 (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha,
834 write_all ? NULL : mask );
835 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
836 if (ctx->RasterMask & ALPHABUF_BIT) {
837 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
838 gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask );
839 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
840 }
841 }
842}
void gl_texture_pixels(GLcontext *ctx, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat r[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1678
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define ASSERT(a)
Definition: mode.c:44

◆ stipple_polygon_span()

static void stipple_polygon_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLubyte  mask[] 
)
static

Definition at line 96 of file span.c.

98{
99 register GLuint i, m, stipple, highbit=0x80000000;
100
101 stipple = ctx->PolygonStipple[y % 32];
102 m = highbit >> (GLuint) (x % 32);
103
104 for (i=0;i<n;i++) {
105 if ((m & stipple)==0) {
106 mask[i] = 0;
107 }
108 m = m >> 1;
109 if (m==0) {
110 m = 0x80000000;
111 }
112 }
113}

Referenced by gl_write_color_span(), gl_write_index_span(), gl_write_monocolor_span(), gl_write_monoindex_span(), and gl_write_texture_span().