2
* Mesa 3-D graphics library
4
* Copyright (C) 1995-1998 Brian Paul
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the Free
18
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#define DESTINATION(BMP, X, Y, TYPE) \
26
(TYPE*)(_bmp->line[_bmp->h - (Y) - 1]) + (X); \
30
#define IMPLEMENT_WRITE_RGBA_SPAN(DEPTH, TYPE) \
31
static void write_rgba_span_##DEPTH (const GLcontext *ctx, \
32
GLuint n, GLint x, GLint y, \
33
const GLubyte rgba[][4], \
34
const GLubyte mask[]) \
36
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
37
TYPE *d = DESTINATION(context->Buffer->Active, x, y, TYPE); \
43
if (mask[0]) d[0] = makecol##DEPTH(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]); \
44
d++; rgba++; mask++; \
51
d[0] = makecol##DEPTH(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]); \
58
#define IMPLEMENT_WRITE_RGB_SPAN(DEPTH, TYPE) \
59
static void write_rgb_span_##DEPTH (const GLcontext *ctx, \
60
GLuint n, GLint x, GLint y, \
61
const GLubyte rgb[][3], \
62
const GLubyte mask[]) \
64
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
65
TYPE *d = DESTINATION(context->Buffer->Active, x, y, TYPE); \
71
if (mask[0]) d[0] = makecol##DEPTH(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]); \
79
d[0] = makecol##DEPTH(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]); \
86
#define IMPLEMENT_WRITE_MONO_RGBA_SPAN(DEPTH, TYPE) \
87
static void write_mono_rgba_span_##DEPTH (const GLcontext *ctx, \
88
GLuint n, GLint x, GLint y, \
89
const GLubyte mask[]) \
91
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
92
TYPE color = context->CurrentColor; \
93
TYPE *d = DESTINATION(context->Buffer->Active, x, y, TYPE); \
97
if (mask[0]) d[0] = color; \
103
#define IMPLEMENT_READ_RGBA_SPAN(DEPTH, TYPE) \
104
static void read_rgba_span_##DEPTH (const GLcontext *ctx, \
105
GLuint n, GLint x, GLint y, \
108
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
109
BITMAP *bmp = context->Buffer->Active; \
110
TYPE *d = DESTINATION(bmp, x, y, TYPE); \
114
rgba[0][RCOMP] = getr##DEPTH(d[0]); \
115
rgba[0][GCOMP] = getg##DEPTH(d[0]); \
116
rgba[0][BCOMP] = getb##DEPTH(d[0]); \
117
rgba[0][ACOMP] = 255; \
124
#define IMPLEMENT_WRITE_RGBA_PIXELS(DEPTH, TYPE) \
125
static void write_rgba_pixels_##DEPTH (const GLcontext *ctx, \
129
const GLubyte rgba[][4], \
130
const GLubyte mask[]) \
132
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
133
BITMAP *bmp = context->Buffer->Active; \
137
if (mask[0]) *DESTINATION(bmp, x[0], y[0], TYPE) = makecol##DEPTH(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]); \
138
rgba++; x++; y++; mask++; \
144
#define IMPLEMENT_WRITE_MONO_RGBA_PIXELS(DEPTH, TYPE) \
145
static void write_mono_rgba_pixels_##DEPTH (const GLcontext *ctx, \
149
const GLubyte mask[]) \
151
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
152
TYPE color = context->CurrentColor; \
153
BITMAP *bmp = context->Buffer->Active; \
157
if (mask[0]) *DESTINATION(bmp, x[0], y[0], TYPE) = color; \
163
#define IMPLEMENT_READ_RGBA_PIXELS(DEPTH, TYPE) \
164
static void read_rgba_pixels_##DEPTH (const GLcontext *ctx, \
169
const GLubyte mask[]) \
171
AMesaContext context = (AMesaContext)(ctx->DriverCtx); \
172
BITMAP *bmp = context->Buffer->Active; \
178
int color = *DESTINATION(bmp, x[0], y[0], TYPE); \
180
rgba[0][RCOMP] = getr##DEPTH(color); \
181
rgba[0][GCOMP] = getg##DEPTH(color); \
182
rgba[0][BCOMP] = getb##DEPTH(color); \
183
rgba[0][ACOMP] = 255; \
186
x++; y++; rgba++; mask++; \