ReactOS 0.4.15-dev-7788-g1ad9096
masking.c
Go to the documentation of this file.
1/* $Id: masking.c,v 1.5 1997/07/24 01:23:16 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 2.4
6 * Copyright (C) 1995-1997 Brian Paul
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24/*
25 * $Log: masking.c,v $
26 * Revision 1.5 1997/07/24 01:23:16 brianp
27 * changed precompiled header symbol from PCH to PC_HEADER
28 *
29 * Revision 1.4 1997/05/28 03:25:43 brianp
30 * added precompiled header (PCH) support
31 *
32 * Revision 1.3 1996/11/06 04:19:40 brianp
33 * now call gl_read_color/index_span() instead of device driver function
34 *
35 * Revision 1.2 1996/10/25 00:07:46 brianp
36 * changed MAX_WIDTH to PB_SIZE in gl_mask_index_pixels()
37 *
38 * Revision 1.1 1996/09/13 01:38:16 brianp
39 * Initial revision
40 *
41 */
42
43
44/*
45 * Implement the effect of glColorMask and glIndexMask in software.
46 */
47
48
49#ifdef PC_HEADER
50#include "all.h"
51#else
52#include <string.h>
53#include "alphabuf.h"
54#include "context.h"
55#include "macros.h"
56#include "masking.h"
57#include "pb.h"
58#include "span.h"
59#include "types.h"
60#endif
61
62
63
65{
66 if (INSIDE_BEGIN_END(ctx)) {
67 gl_error( ctx, GL_INVALID_OPERATION, "glIndexMask" );
68 return;
69 }
70 ctx->Color.IndexMask = mask;
71 ctx->NewState |= NEW_RASTER_OPS;
72}
73
74
75
78{
79 if (INSIDE_BEGIN_END(ctx)) {
80 gl_error( ctx, GL_INVALID_OPERATION, "glColorMask" );
81 return;
82 }
83 ctx->Color.ColorMask = (red << 3) | (green << 2) | (blue << 1) | alpha;
84 ctx->NewState |= NEW_RASTER_OPS;
85}
86
87
88
89
90/*
91 * Apply glColorMask to a span of RGBA pixels.
92 */
97{
99
100 gl_read_color_span( ctx, n, x, y, r, g, b, a );
101
102 if ((ctx->Color.ColorMask & 8) == 0) {
103 /* replace source reds with frame buffer reds */
104 MEMCPY( red, r, n );
105 }
106 if ((ctx->Color.ColorMask & 4) == 0) {
107 /* replace source greens with frame buffer greens */
108 MEMCPY( green, g, n );
109 }
110 if ((ctx->Color.ColorMask & 2) == 0) {
111 /* replace source blues with frame buffer blues */
112 MEMCPY( blue, b, n );
113 }
114 if ((ctx->Color.ColorMask & 1) == 0) {
115 /* replace source alphas with frame buffer alphas */
116 MEMCPY( alpha, a, n );
117 }
118}
119
120
121
122/*
123 * Apply glColorMask to an array of RGBA pixels.
124 */
126 GLuint n, const GLint x[], const GLint y[],
129 const GLubyte mask[] )
130{
132
133 (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, r, g, b, a, mask );
134 if (ctx->RasterMask & ALPHABUF_BIT) {
136 }
137
138 if ((ctx->Color.ColorMask & 8) == 0) {
139 /* replace source reds with frame buffer reds */
140 MEMCPY( red, r, n );
141 }
142 if ((ctx->Color.ColorMask & 4) == 0) {
143 /* replace source greens with frame buffer greens */
144 MEMCPY( green, g, n );
145 }
146 if ((ctx->Color.ColorMask & 2) == 0) {
147 /* replace source blues with frame buffer blues */
148 MEMCPY( blue, b, n );
149 }
150 if ((ctx->Color.ColorMask & 1) == 0) {
151 /* replace source alphas with frame buffer alphas */
152 MEMCPY( alpha, a, n );
153 }
154}
155
156
157
158/*
159 * Apply glIndexMask to a span of CI pixels.
160 */
163{
164 GLuint i;
165 GLuint fbindexes[MAX_WIDTH];
166 GLuint msrc, mdest;
167
168 gl_read_index_span( ctx, n, x, y, fbindexes );
169
170 msrc = ctx->Color.IndexMask;
171 mdest = ~msrc;
172
173 for (i=0;i<n;i++) {
174 index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
175 }
176}
177
178
179
180/*
181 * Apply glIndexMask to an array of CI pixels.
182 */
184 GLuint n, const GLint x[], const GLint y[],
185 GLuint index[], const GLubyte mask[] )
186{
187 GLuint i;
188 GLuint fbindexes[PB_SIZE];
189 GLuint msrc, mdest;
190
191 (*ctx->Driver.ReadIndexPixels)( ctx, n, x, y, fbindexes, mask );
192
193 msrc = ctx->Color.IndexMask;
194 mdest = ~msrc;
195
196 for (i=0;i<n;i++) {
197 index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
198 }
199}
200
void gl_read_alpha_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte alpha[], const GLubyte mask[])
Definition: alphabuf.c:257
#define MAX_WIDTH
Definition: config.h:130
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define NEW_RASTER_OPS
Definition: types.h:1233
#define ALPHABUF_BIT
Definition: types.h:1223
unsigned char GLubyte
Definition: gl.h:157
GLclampf green
Definition: gl.h:1740
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GL_INVALID_OPERATION
Definition: gl.h:696
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLclampf GLclampf blue
Definition: gl.h:1740
int GLint
Definition: gl.h:156
unsigned char GLboolean
Definition: gl.h:151
GLdouble n
Definition: glext.h:7729
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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
#define red
Definition: linetest.c:67
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
void gl_mask_color_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], const GLubyte mask[])
Definition: masking.c:125
void gl_IndexMask(GLcontext *ctx, GLuint mask)
Definition: masking.c:64
void gl_mask_index_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLuint index[], const GLubyte mask[])
Definition: masking.c:183
void gl_ColorMask(GLcontext *ctx, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
Definition: masking.c:76
void gl_mask_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[])
Definition: masking.c:161
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
#define PB_SIZE
Definition: pb.h:52
void gl_read_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: span.c:850
void gl_read_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint indx[])
Definition: span.c:897