119
119
* index/depth_span().
122
zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const struct sw_span *span,
122
zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
123
123
const GLvoid *src, GLenum format )
125
struct sw_span zoomed;
126
struct span_arrays zoomed_arrays; /* this is big! */
126
SWspanarrays zoomed_arrays; /* this is big! */
127
127
GLint x0, x1, y0, y1;
128
128
GLint zoomedWidth;
145
145
zoomed.end = zoomedWidth;
146
146
zoomed.array = &zoomed_arrays;
147
zoomed_arrays.ChanType = span->array->ChanType;
149
#if CHAN_TYPE == GL_UNSIGNED_BYTE
150
zoomed_arrays.rgba = zoomed_arrays.color.sz1.rgba;
151
zoomed_arrays.spec = zoomed_arrays.color.sz1.spec;
152
#elif CHAN_TYPE == GL_UNSIGNED_SHORT
153
zoomed_arrays.rgba = zoomed_arrays.color.sz2.rgba;
154
zoomed_arrays.spec = zoomed_arrays.color.sz2.spec;
156
zoomed_arrays.rgba = zoomed_arrays.color.sz4.rgba;
157
zoomed_arrays.spec = zoomed_arrays.color.sz4.spec;
148
161
/* copy fog interp info */
149
162
zoomed.fog = span->fog;
191
204
/* zoom the span horizontally */
192
205
if (format == GL_RGBA) {
193
const GLchan (*rgba)[4] = (const GLchan (*)[4]) src;
195
for (i = 0; i < zoomedWidth; i++) {
196
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
198
ASSERT(j < span->end);
199
COPY_CHAN4(zoomed.array->rgba[i], rgba[j]);
206
if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) {
207
const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) src;
209
for (i = 0; i < zoomedWidth; i++) {
210
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
212
ASSERT(j < span->end);
213
COPY_4UBV(zoomed.array->color.sz1.rgba[i], rgba[j]);
216
else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) {
217
const GLushort (*rgba)[4] = (const GLushort (*)[4]) src;
219
for (i = 0; i < zoomedWidth; i++) {
220
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
222
ASSERT(j < span->end);
223
COPY_4V(zoomed.array->color.sz2.rgba[i], rgba[j]);
227
const GLfloat (*rgba)[4] = (const GLfloat (*)[4]) src;
229
for (i = 0; i < zoomedWidth; i++) {
230
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
232
ASSERT(j < span->end);
233
COPY_4V(zoomed.array->color.sz4.rgba[i], rgba[j]);
202
237
else if (format == GL_RGB) {
203
const GLchan (*rgb)[3] = (const GLchan (*)[3]) src;
205
for (i = 0; i < zoomedWidth; i++) {
206
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
208
ASSERT(j < span->end);
209
zoomed.array->rgba[i][0] = rgb[j][0];
210
zoomed.array->rgba[i][1] = rgb[j][1];
211
zoomed.array->rgba[i][2] = rgb[j][2];
212
zoomed.array->rgba[i][3] = CHAN_MAX;
238
if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) {
239
const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) src;
241
for (i = 0; i < zoomedWidth; i++) {
242
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
244
ASSERT(j < span->end);
245
zoomed.array->color.sz1.rgba[i][0] = rgb[j][0];
246
zoomed.array->color.sz1.rgba[i][1] = rgb[j][1];
247
zoomed.array->color.sz1.rgba[i][2] = rgb[j][2];
248
zoomed.array->color.sz1.rgba[i][3] = 0xff;
251
else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) {
252
const GLushort (*rgb)[3] = (const GLushort (*)[3]) src;
254
for (i = 0; i < zoomedWidth; i++) {
255
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
257
ASSERT(j < span->end);
258
zoomed.array->color.sz2.rgba[i][0] = rgb[j][0];
259
zoomed.array->color.sz2.rgba[i][1] = rgb[j][1];
260
zoomed.array->color.sz2.rgba[i][2] = rgb[j][2];
261
zoomed.array->color.sz2.rgba[i][3] = 0xffff;
265
const GLfloat (*rgb)[3] = (const GLfloat (*)[3]) src;
267
for (i = 0; i < zoomedWidth; i++) {
268
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
270
ASSERT(j < span->end);
271
zoomed.array->color.sz4.rgba[i][0] = rgb[j][0];
272
zoomed.array->color.sz4.rgba[i][1] = rgb[j][1];
273
zoomed.array->color.sz4.rgba[i][2] = rgb[j][2];
274
zoomed.array->color.sz4.rgba[i][3] = 1.0F;
215
278
else if (format == GL_COLOR_INDEX) {
241
304
* going to call _swrast_write_zoomed_span() more than once.
242
305
* Also, clipping may change the span end value, so store it as well.
244
GLchan rgbaSave[MAX_WIDTH][4];
245
307
const GLint end = zoomed.end; /* save */
308
/* use specular color array for temp storage */
309
void *rgbaSave = zoomed.array->spec;
310
const GLint pixelSize =
311
(zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) :
312
((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort)
313
: 4 * sizeof(GLfloat));
246
314
if (y1 - y0 > 1) {
247
MEMCPY(rgbaSave, zoomed.array->rgba, zoomed.end * 4 * sizeof(GLchan));
315
MEMCPY(rgbaSave, zoomed.array->rgba, zoomed.end * pixelSize);
249
317
for (zoomed.y = y0; zoomed.y < y1; zoomed.y++) {
250
318
_swrast_write_rgba_span(ctx, &zoomed);
251
319
zoomed.end = end; /* restore */
252
320
if (y1 - y0 > 1) {
253
321
/* restore the colors */
254
MEMCPY(zoomed.array->rgba, rgbaSave, zoomed.end*4 * sizeof(GLchan));
322
MEMCPY(zoomed.array->rgba, rgbaSave, zoomed.end * pixelSize);
258
326
else if (format == GL_COLOR_INDEX) {
259
GLuint indexSave[MAX_WIDTH];
327
/* use specular color array for temp storage */
328
GLuint *indexSave = (GLuint *) zoomed.array->spec;
260
329
const GLint end = zoomed.end; /* save */
261
330
if (y1 - y0 > 1) {
262
331
MEMCPY(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint));
277
_swrast_write_zoomed_rgba_span( GLcontext *ctx, GLint imgX, GLint imgY,
278
const struct sw_span *span,
279
CONST GLchan rgba[][4])
346
_swrast_write_zoomed_rgba_span(GLcontext *ctx, GLint imgX, GLint imgY,
347
const SWspan *span, const GLvoid *rgba)
281
zoom_span(ctx, imgX, imgY, span, (const GLvoid *) rgba, GL_RGBA);
349
zoom_span(ctx, imgX, imgY, span, rgba, GL_RGBA);
286
354
_swrast_write_zoomed_rgb_span(GLcontext *ctx, GLint imgX, GLint imgY,
287
const struct sw_span *span,
288
CONST GLchan rgb[][3])
355
const SWspan *span, const GLvoid *rgb)
290
zoom_span(ctx, imgX, imgY, span, (const GLvoid *) rgb, GL_RGB);
357
zoom_span(ctx, imgX, imgY, span, rgb, GL_RGB);
295
362
_swrast_write_zoomed_index_span(GLcontext *ctx, GLint imgX, GLint imgY,
296
const struct sw_span *span)
298
365
zoom_span(ctx, imgX, imgY, span,
299
366
(const GLvoid *) span->array->index, GL_COLOR_INDEX);