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
)( GLcontext
*ctx
,
60 struct gl_renderbuffer
*rb
,
61 GLuint n
, GLint x
, GLint y
,
62 const void *values
, const GLubyte mask
[] )
66 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
76 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
78 if (DBG
) fprintf(stderr
, "WriteRGBASpan %d..%d (x1 %d)\n",
79 (int)i
, (int)n1
, (int)x1
);
83 for (;n1
>0;i
++,x1
++,n1
--)
86 rgba
[i
][0], rgba
[i
][1],
87 rgba
[i
][2], rgba
[i
][3] );
91 for (;n1
>0;i
++,x1
++,n1
--)
93 rgba
[i
][0], rgba
[i
][1],
94 rgba
[i
][2], rgba
[i
][3] );
102 static void TAG(WriteRGBSpan
)( GLcontext
*ctx
,
103 struct gl_renderbuffer
*rb
,
104 GLuint n
, GLint x
, GLint y
,
105 const void *values
, const GLubyte mask
[] )
109 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
119 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
121 if (DBG
) fprintf(stderr
, "WriteRGBSpan %d..%d (x1 %d)\n",
122 (int)i
, (int)n1
, (int)x1
);
126 for (;n1
>0;i
++,x1
++,n1
--)
128 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
132 for (;n1
>0;i
++,x1
++,n1
--)
133 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
141 static void TAG(WriteRGBAPixels
)( GLcontext
*ctx
,
142 struct gl_renderbuffer
*rb
,
143 GLuint n
, const GLint x
[], const GLint y
[],
144 const void *values
, const GLubyte mask
[] )
148 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
152 if (DBG
) fprintf(stderr
, "WriteRGBAPixels\n");
161 const int fy
= Y_FLIP(y
[i
]);
162 if (CLIPPIXEL(x
[i
],fy
))
163 WRITE_RGBA( x
[i
], fy
,
164 rgba
[i
][0], rgba
[i
][1],
165 rgba
[i
][2], rgba
[i
][3] );
173 const int fy
= Y_FLIP(y
[i
]);
174 if (CLIPPIXEL(x
[i
],fy
))
175 WRITE_RGBA( x
[i
], fy
,
176 rgba
[i
][0], rgba
[i
][1],
177 rgba
[i
][2], rgba
[i
][3] );
187 static void TAG(WriteMonoRGBASpan
)( GLcontext
*ctx
,
188 struct gl_renderbuffer
*rb
,
189 GLuint n
, GLint x
, GLint y
,
191 const GLubyte mask
[] )
195 const GLubyte
*color
= (const GLubyte
*) value
;
199 INIT_MONO_PIXEL(p
, color
);
203 if (DBG
) fprintf(stderr
, "WriteMonoRGBASpan\n");
208 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
211 for (;n1
>0;i
++,x1
++,n1
--)
213 WRITE_PIXEL( x1
, y
, p
);
217 for (;n1
>0;i
++,x1
++,n1
--)
218 WRITE_PIXEL( x1
, y
, p
);
227 static void TAG(WriteMonoRGBAPixels
)( GLcontext
*ctx
,
228 struct gl_renderbuffer
*rb
,
230 const GLint x
[], const GLint y
[],
232 const GLubyte mask
[] )
236 const GLubyte
*color
= (const GLubyte
*) value
;
239 INIT_MONO_PIXEL(p
, color
);
241 if (DBG
) fprintf(stderr
, "WriteMonoRGBAPixels\n");
249 int fy
= Y_FLIP(y
[i
]);
250 if (CLIPPIXEL( x
[i
], fy
))
251 WRITE_PIXEL( x
[i
], fy
, p
);
257 int fy
= Y_FLIP(y
[i
]);
258 if (CLIPPIXEL( x
[i
], fy
))
259 WRITE_PIXEL( x
[i
], fy
, p
);
269 static void TAG(ReadRGBASpan
)( GLcontext
*ctx
,
270 struct gl_renderbuffer
*rb
,
271 GLuint n
, GLint x
, GLint y
,
276 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
282 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
287 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
288 for (;n1
>0;i
++,x1
++,n1
--)
289 READ_RGBA( rgba
[i
], x1
, y
);
297 static void TAG(ReadRGBAPixels
)( GLcontext
*ctx
,
298 struct gl_renderbuffer
*rb
,
299 GLuint n
, const GLint x
[], const GLint y
[],
304 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
305 const GLubyte
*mask
= NULL
; /* remove someday */
309 if (DBG
) fprintf(stderr
, "ReadRGBAPixels\n");
317 int fy
= Y_FLIP( y
[i
] );
318 if (CLIPPIXEL( x
[i
], fy
))
319 READ_RGBA( rgba
[i
], x
[i
], fy
);
325 int fy
= Y_FLIP( y
[i
] );
326 if (CLIPPIXEL( x
[i
], fy
))
327 READ_RGBA( rgba
[i
], x
[i
], fy
);