~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/allegro/direct.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Mesa 3-D graphics library
3
 
 * Version:  3.0
4
 
 * Copyright (C) 1995-1998  Brian Paul
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 */
20
 
 
21
 
 
22
 
#define DESTINATION(BMP, X, Y, TYPE)                                \
23
 
    ({                                                              \
24
 
    BITMAP *_bmp = BMP;                                             \
25
 
                                                                    \
26
 
    (TYPE*)(_bmp->line[_bmp->h - (Y) - 1]) + (X);                   \
27
 
    })
28
 
 
29
 
 
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[])                                       \
35
 
    {                                                                                            \
36
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                                       \
37
 
    TYPE              *d = DESTINATION(context->Buffer->Active, x, y, TYPE);                     \
38
 
                                                                                                 \
39
 
    if (mask)                                                                                    \
40
 
        {                                                                                        \
41
 
        while (n--)                                                                              \
42
 
            {                                                                                    \
43
 
            if (mask[0]) d[0] = makecol##DEPTH(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]);  \
44
 
            d++; rgba++; mask++;                                                                 \
45
 
            }                                                                                    \
46
 
        }                                                                                        \
47
 
    else                                                                                         \
48
 
        {                                                                                        \
49
 
        while (n--)                                                                              \
50
 
            {                                                                                    \
51
 
            d[0] = makecol##DEPTH(rgba[0][RCOMP], rgba[0][GCOMP], rgba[0][BCOMP]);               \
52
 
            d++; rgba++;                                                                         \
53
 
            }                                                                                    \
54
 
        }                                                                                        \
55
 
    }
56
 
 
57
 
 
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[])                                        \
63
 
    {                                                                                            \
64
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                                       \
65
 
    TYPE              *d = DESTINATION(context->Buffer->Active, x, y, TYPE);                     \
66
 
                                                                                                 \
67
 
    if (mask)                                                                                    \
68
 
        {                                                                                        \
69
 
        while (n--)                                                                              \
70
 
            {                                                                                    \
71
 
            if (mask[0]) d[0] = makecol##DEPTH(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]);     \
72
 
            d++; rgb++; mask++;                                                                  \
73
 
            }                                                                                    \
74
 
        }                                                                                        \
75
 
    else                                                                                         \
76
 
        {                                                                                        \
77
 
        while (n--)                                                                              \
78
 
            {                                                                                    \
79
 
            d[0] = makecol##DEPTH(rgb[0][RCOMP], rgb[0][GCOMP], rgb[0][BCOMP]);                  \
80
 
            d++; rgb++;                                                                          \
81
 
            }                                                                                    \
82
 
        }                                                                                        \
83
 
    }
84
 
 
85
 
 
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[])                                  \
90
 
    {                                                                                            \
91
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                                       \
92
 
    TYPE           color = context->CurrentColor;                                                \
93
 
    TYPE              *d = DESTINATION(context->Buffer->Active, x, y, TYPE);                     \
94
 
                                                                                                 \
95
 
    while (n--)                                                                                  \
96
 
        {                                                                                        \
97
 
        if (mask[0]) d[0] = color;                                                               \
98
 
        d++; mask++;                                                                             \
99
 
        }                                                                                        \
100
 
    }
101
 
 
102
 
 
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,                 \
106
 
                                    GLubyte rgba[][4])                                  \
107
 
    {                                                                                                                                   \
108
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                              \
109
 
    BITMAP          *bmp = context->Buffer->Active;                     \
110
 
    TYPE              *d = DESTINATION(bmp, x, y, TYPE);                \
111
 
                                                                        \
112
 
    while (n--)                                                         \
113
 
        {                                                               \
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;                                           \
118
 
                                                                        \
119
 
        d++; rgba++;                                                    \
120
 
        }                                                               \
121
 
    }
122
 
 
123
 
 
124
 
#define IMPLEMENT_WRITE_RGBA_PIXELS(DEPTH, TYPE)                                                                                 \
125
 
static void write_rgba_pixels_##DEPTH (const GLcontext *ctx,                                                                     \
126
 
                                       GLuint n,                                                                                 \
127
 
                                       const GLint x[],                                                                          \
128
 
                                       const GLint y[],                                                                          \
129
 
                                       const GLubyte rgba[][4],                                                                  \
130
 
                                       const GLubyte mask[])                                                                     \
131
 
    {                                                                                                                            \
132
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                                                                       \
133
 
    BITMAP          *bmp = context->Buffer->Active;                                                                              \
134
 
                                                                                                                                 \
135
 
    while (n--)                                                                                                                  \
136
 
        {                                                                                                                        \
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++;                                                                                                \
139
 
        }                                                                                                                        \
140
 
    }
141
 
 
142
 
 
143
 
 
144
 
#define IMPLEMENT_WRITE_MONO_RGBA_PIXELS(DEPTH, TYPE)                                                                            \
145
 
static void write_mono_rgba_pixels_##DEPTH (const GLcontext *ctx,                                                                \
146
 
                                            GLuint n,                                                                            \
147
 
                                            const GLint x[],                                                                     \
148
 
                                            const GLint y[],                                                                     \
149
 
                                            const GLubyte mask[])                                                                \
150
 
    {                                                                                                                            \
151
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                                                                       \
152
 
    TYPE          color  = context->CurrentColor;                                                                                \
153
 
    BITMAP          *bmp = context->Buffer->Active;                                                                              \
154
 
                                                                                                                                 \
155
 
    while (n--)                                                                                                                  \
156
 
        {                                                                                                                        \
157
 
        if (mask[0]) *DESTINATION(bmp, x[0], y[0], TYPE) = color;                                                                \
158
 
        x++; y++; mask++;                                                                                                        \
159
 
        }                                                                                                                        \
160
 
    }
161
 
 
162
 
 
163
 
#define IMPLEMENT_READ_RGBA_PIXELS(DEPTH, TYPE)                         \
164
 
static void read_rgba_pixels_##DEPTH (const GLcontext *ctx,                             \
165
 
                                          GLuint n,                                                     \
166
 
                                          const GLint x[],                                      \
167
 
                                          const GLint y[],                                      \
168
 
                                          GLubyte rgba[][4],                            \
169
 
                                          const GLubyte mask[])                         \
170
 
    {                                                                                                                                   \
171
 
    AMesaContext context = (AMesaContext)(ctx->DriverCtx);                              \
172
 
    BITMAP          *bmp = context->Buffer->Active;                     \
173
 
                                                                        \
174
 
    while (n--)                                                         \
175
 
        {                                                               \
176
 
        if (mask[0])                                                    \
177
 
            {                                                           \
178
 
            int color = *DESTINATION(bmp, x[0], y[0], TYPE);            \
179
 
                                                                        \
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;                                       \
184
 
            }                                                           \
185
 
                                                                        \
186
 
        x++; y++; rgba++; mask++;                                       \
187
 
        }                                                               \
188
 
    }
189