2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * (C) Copyright IBM Corporation 2002, 2003
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * on the rights to use, copy, modify, merge, publish, distribute, sub
10 * license, and/or sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Keith Whitwell <keithw@tungstengraphics.com>
27 * Gareth Hughes <gareth@nvidia.com>
35 #define HW_WRITE_LOCK() HW_LOCK()
38 #ifndef HW_WRITE_UNLOCK
39 #define HW_WRITE_UNLOCK() HW_UNLOCK()
43 #define HW_READ_LOCK() HW_LOCK()
46 #ifndef HW_READ_UNLOCK
47 #define HW_READ_UNLOCK() HW_UNLOCK()
50 #ifndef HW_READ_CLIPLOOP
51 #define HW_READ_CLIPLOOP() HW_CLIPLOOP()
54 #ifndef HW_WRITE_CLIPLOOP
55 #define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
59 static void TAG(WriteRGBASpan
)( const GLcontext
*ctx
,
60 GLuint n
, GLint x
, GLint y
,
61 const GLubyte rgba
[][4],
62 const GLubyte mask
[] )
75 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
77 if (DBG
) fprintf(stderr
, "WriteRGBASpan %d..%d (x1 %d)\n",
78 (int)i
, (int)n1
, (int)x1
);
82 for (;n1
>0;i
++,x1
++,n1
--)
85 rgba
[i
][0], rgba
[i
][1],
86 rgba
[i
][2], rgba
[i
][3] );
90 for (;n1
>0;i
++,x1
++,n1
--)
92 rgba
[i
][0], rgba
[i
][1],
93 rgba
[i
][2], rgba
[i
][3] );
101 static void TAG(WriteRGBSpan
)( const GLcontext
*ctx
,
102 GLuint n
, GLint x
, GLint y
,
103 const GLubyte rgb
[][3],
104 const GLubyte mask
[] )
117 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
119 if (DBG
) fprintf(stderr
, "WriteRGBSpan %d..%d (x1 %d)\n",
120 (int)i
, (int)n1
, (int)x1
);
124 for (;n1
>0;i
++,x1
++,n1
--)
126 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
130 for (;n1
>0;i
++,x1
++,n1
--)
131 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
139 static void TAG(WriteRGBAPixels
)( const GLcontext
*ctx
,
143 const GLubyte rgba
[][4],
144 const GLubyte mask
[] )
151 if (DBG
) fprintf(stderr
, "WriteRGBAPixels\n");
160 const int fy
= Y_FLIP(y
[i
]);
161 if (CLIPPIXEL(x
[i
],fy
))
162 WRITE_RGBA( x
[i
], fy
,
163 rgba
[i
][0], rgba
[i
][1],
164 rgba
[i
][2], rgba
[i
][3] );
172 const int fy
= Y_FLIP(y
[i
]);
173 if (CLIPPIXEL(x
[i
],fy
))
174 WRITE_RGBA( x
[i
], fy
,
175 rgba
[i
][0], rgba
[i
][1],
176 rgba
[i
][2], rgba
[i
][3] );
186 static void TAG(WriteMonoRGBASpan
)( const GLcontext
*ctx
,
187 GLuint n
, GLint x
, GLint y
,
188 const GLchan color
[4],
189 const GLubyte mask
[] )
196 INIT_MONO_PIXEL(p
, color
);
200 if (DBG
) fprintf(stderr
, "WriteMonoRGBASpan\n");
205 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
208 for (;n1
>0;i
++,x1
++,n1
--)
210 WRITE_PIXEL( x1
, y
, p
);
214 for (;n1
>0;i
++,x1
++,n1
--)
215 WRITE_PIXEL( x1
, y
, p
);
224 static void TAG(WriteMonoRGBAPixels
)( const GLcontext
*ctx
,
226 const GLint x
[], const GLint y
[],
227 const GLchan color
[],
228 const GLubyte mask
[] )
234 INIT_MONO_PIXEL(p
, color
);
236 if (DBG
) fprintf(stderr
, "WriteMonoRGBAPixels\n");
244 int fy
= Y_FLIP(y
[i
]);
245 if (CLIPPIXEL( x
[i
], fy
))
246 WRITE_PIXEL( x
[i
], fy
, p
);
252 int fy
= Y_FLIP(y
[i
]);
253 if (CLIPPIXEL( x
[i
], fy
))
254 WRITE_PIXEL( x
[i
], fy
, p
);
264 static void TAG(ReadRGBASpan
)( const GLcontext
*ctx
,
265 GLuint n
, GLint x
, GLint y
,
275 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
280 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
281 for (;n1
>0;i
++,x1
++,n1
--)
282 READ_RGBA( rgba
[i
], x1
, y
);
290 static void TAG(ReadRGBAPixels
)( const GLcontext
*ctx
,
291 GLuint n
, const GLint x
[], const GLint y
[],
292 GLubyte rgba
[][4], const GLubyte mask
[] )
299 if (DBG
) fprintf(stderr
, "ReadRGBAPixels\n");
307 int fy
= Y_FLIP( y
[i
] );
308 if (CLIPPIXEL( x
[i
], fy
))
309 READ_RGBA( rgba
[i
], x
[i
], fy
);
315 int fy
= Y_FLIP( y
[i
] );
316 if (CLIPPIXEL( x
[i
], fy
))
317 READ_RGBA( rgba
[i
], x
[i
], fy
);