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>
30 #include "spantmp_common.h"
36 #ifndef HW_READ_CLIPLOOP
37 #define HW_READ_CLIPLOOP() HW_CLIPLOOP()
40 #ifndef HW_WRITE_CLIPLOOP
41 #define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
45 static void TAG(WriteRGBASpan
)( GLcontext
*ctx
,
46 struct gl_renderbuffer
*rb
,
47 GLuint n
, GLint x
, GLint y
,
48 const void *values
, const GLubyte mask
[] )
52 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
62 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
64 if (DBG
) fprintf(stderr
, "WriteRGBASpan %d..%d (x1 %d)\n",
65 (int)i
, (int)n1
, (int)x1
);
69 for (;n1
>0;i
++,x1
++,n1
--)
72 rgba
[i
][0], rgba
[i
][1],
73 rgba
[i
][2], rgba
[i
][3] );
77 for (;n1
>0;i
++,x1
++,n1
--)
79 rgba
[i
][0], rgba
[i
][1],
80 rgba
[i
][2], rgba
[i
][3] );
88 static void TAG(WriteRGBSpan
)( GLcontext
*ctx
,
89 struct gl_renderbuffer
*rb
,
90 GLuint n
, GLint x
, GLint y
,
91 const void *values
, const GLubyte mask
[] )
95 const GLubyte (*rgb
)[3] = (const GLubyte (*)[3]) values
;
105 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
107 if (DBG
) fprintf(stderr
, "WriteRGBSpan %d..%d (x1 %d)\n",
108 (int)i
, (int)n1
, (int)x1
);
112 for (;n1
>0;i
++,x1
++,n1
--)
114 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
118 for (;n1
>0;i
++,x1
++,n1
--)
119 WRITE_RGBA( x1
, y
, rgb
[i
][0], rgb
[i
][1], rgb
[i
][2], 255 );
127 static void TAG(WriteRGBAPixels
)( GLcontext
*ctx
,
128 struct gl_renderbuffer
*rb
,
129 GLuint n
, const GLint x
[], const GLint y
[],
130 const void *values
, const GLubyte mask
[] )
134 const GLubyte (*rgba
)[4] = (const GLubyte (*)[4]) values
;
138 if (DBG
) fprintf(stderr
, "WriteRGBAPixels\n");
147 const int fy
= Y_FLIP(y
[i
]);
148 if (CLIPPIXEL(x
[i
],fy
))
149 WRITE_RGBA( x
[i
], fy
,
150 rgba
[i
][0], rgba
[i
][1],
151 rgba
[i
][2], rgba
[i
][3] );
159 const int fy
= Y_FLIP(y
[i
]);
160 if (CLIPPIXEL(x
[i
],fy
))
161 WRITE_RGBA( x
[i
], fy
,
162 rgba
[i
][0], rgba
[i
][1],
163 rgba
[i
][2], rgba
[i
][3] );
173 static void TAG(WriteMonoRGBASpan
)( GLcontext
*ctx
,
174 struct gl_renderbuffer
*rb
,
175 GLuint n
, GLint x
, GLint y
,
177 const GLubyte mask
[] )
181 const GLubyte
*color
= (const GLubyte
*) value
;
185 INIT_MONO_PIXEL(p
, color
);
189 if (DBG
) fprintf(stderr
, "WriteMonoRGBASpan\n");
194 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
197 for (;n1
>0;i
++,x1
++,n1
--)
199 WRITE_PIXEL( x1
, y
, p
);
203 for (;n1
>0;i
++,x1
++,n1
--)
204 WRITE_PIXEL( x1
, y
, p
);
213 static void TAG(WriteMonoRGBAPixels
)( GLcontext
*ctx
,
214 struct gl_renderbuffer
*rb
,
216 const GLint x
[], const GLint y
[],
218 const GLubyte mask
[] )
222 const GLubyte
*color
= (const GLubyte
*) value
;
225 INIT_MONO_PIXEL(p
, color
);
227 if (DBG
) fprintf(stderr
, "WriteMonoRGBAPixels\n");
235 int fy
= Y_FLIP(y
[i
]);
236 if (CLIPPIXEL( x
[i
], fy
))
237 WRITE_PIXEL( x
[i
], fy
, p
);
243 int fy
= Y_FLIP(y
[i
]);
244 if (CLIPPIXEL( x
[i
], fy
))
245 WRITE_PIXEL( x
[i
], fy
, p
);
255 static void TAG(ReadRGBASpan
)( GLcontext
*ctx
,
256 struct gl_renderbuffer
*rb
,
257 GLuint n
, GLint x
, GLint y
,
262 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
268 if (DBG
) fprintf(stderr
, "ReadRGBASpan\n");
273 CLIPSPAN(x
,y
,n
,x1
,n1
,i
);
274 for (;n1
>0;i
++,x1
++,n1
--)
275 READ_RGBA( rgba
[i
], x1
, y
);
283 static void TAG(ReadRGBAPixels
)( GLcontext
*ctx
,
284 struct gl_renderbuffer
*rb
,
285 GLuint n
, const GLint x
[], const GLint y
[],
290 GLubyte (*rgba
)[4] = (GLubyte (*)[4]) values
;
291 const GLubyte
*mask
= NULL
; /* remove someday */
295 if (DBG
) fprintf(stderr
, "ReadRGBAPixels\n");
303 int fy
= Y_FLIP( y
[i
] );
304 if (CLIPPIXEL( x
[i
], fy
))
305 READ_RGBA( rgba
[i
], x
[i
], fy
);
311 int fy
= Y_FLIP( y
[i
] );
312 if (CLIPPIXEL( x
[i
], fy
))
313 READ_RGBA( rgba
[i
], x
[i
], fy
);
323 static void TAG(InitPointers
)(struct gl_renderbuffer
*rb
)
325 rb
->PutRow
= TAG(WriteRGBASpan
);
326 rb
->PutRowRGB
= TAG(WriteRGBSpan
);
327 rb
->PutMonoRow
= TAG(WriteMonoRGBASpan
);
328 rb
->PutValues
= TAG(WriteRGBAPixels
);
329 rb
->PutMonoValues
= TAG(WriteMonoRGBAPixels
);
330 rb
->GetValues
= TAG(ReadRGBAPixels
);
331 rb
->GetRow
= TAG(ReadRGBASpan
);