| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.4 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. |
| 6 |
* |
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
* copy of this software and associated documentation files (the "Software"), |
| 9 |
* to deal in the Software without restriction, including without limitation |
| 10 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
* Software is furnished to do so, subject to the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice shall be included |
| 15 |
* in all copies or substantial portions of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 |
*/ |
| 24 |
|
| 25 |
|
| 26 |
#include "glheader.h" |
| 27 |
#include "bufferobj.h" |
| 28 |
#include "context.h" |
| 29 |
#include "convolve.h" |
| 30 |
#include "image.h" |
| 31 |
#include "macros.h" |
| 32 |
#include "imports.h" |
| 33 |
#include "pixel.h" |
| 34 |
|
| 35 |
#include "s_context.h" |
| 36 |
#include "s_drawpix.h" |
| 37 |
#include "s_pixeltex.h" |
| 38 |
#include "s_span.h" |
| 39 |
#include "s_stencil.h" |
| 40 |
#include "s_zoom.h" |
| 41 |
|
| 42 |
|
| 43 |
/* |
| 44 |
* Try to do a fast and simple RGB(a) glDrawPixels. |
| 45 |
* Return: GL_TRUE if success, GL_FALSE if slow path must be used instead |
| 46 |
*/ |
| 47 |
static GLboolean |
| 48 |
fast_draw_pixels(GLcontext *ctx, GLint x, GLint y, |
| 49 |
GLsizei width, GLsizei height, |
| 50 |
GLenum format, GLenum type, |
| 51 |
const struct gl_pixelstore_attrib *unpack, |
| 52 |
const GLvoid *pixels) |
| 53 |
{ |
| 54 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 55 |
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0]; |
| 56 |
struct sw_span span; |
| 57 |
|
| 58 |
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); |
| 59 |
|
| 60 |
if (!ctx->Current.RasterPosValid) { |
| 61 |
return GL_TRUE; /* no-op */ |
| 62 |
} |
| 63 |
|
| 64 |
if (swrast->_RasterMask & MULTI_DRAW_BIT) |
| 65 |
return GL_FALSE; |
| 66 |
|
| 67 |
if (ctx->Depth.Test) |
| 68 |
_swrast_span_default_z(ctx, &span); |
| 69 |
if (swrast->_FogEnabled) |
| 70 |
_swrast_span_default_fog(ctx, &span); |
| 71 |
if (ctx->Texture._EnabledCoordUnits) |
| 72 |
_swrast_span_default_texcoords(ctx, &span); |
| 73 |
|
| 74 |
if ((SWRAST_CONTEXT(ctx)->_RasterMask & ~CLIP_BIT) == 0 |
| 75 |
&& ctx->Texture._EnabledCoordUnits == 0 |
| 76 |
&& unpack->Alignment == 1 |
| 77 |
&& !unpack->SwapBytes |
| 78 |
&& !unpack->LsbFirst) { |
| 79 |
|
| 80 |
GLint destX = x; |
| 81 |
GLint destY = y; |
| 82 |
GLint drawWidth = width; /* actual width drawn */ |
| 83 |
GLint drawHeight = height; /* actual height drawn */ |
| 84 |
GLint skipPixels = unpack->SkipPixels; |
| 85 |
GLint skipRows = unpack->SkipRows; |
| 86 |
GLint rowLength; |
| 87 |
GLint zoomY0 = 0; |
| 88 |
|
| 89 |
if (unpack->RowLength > 0) |
| 90 |
rowLength = unpack->RowLength; |
| 91 |
else |
| 92 |
rowLength = width; |
| 93 |
|
| 94 |
/* If we're not using pixel zoom then do all clipping calculations |
| 95 |
* now. Otherwise, we'll let the _swrast_write_zoomed_*_span() functions |
| 96 |
* handle the clipping. |
| 97 |
*/ |
| 98 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 99 |
/* horizontal clipping */ |
| 100 |
if (destX < ctx->DrawBuffer->_Xmin) { |
| 101 |
skipPixels += (ctx->DrawBuffer->_Xmin - destX); |
| 102 |
drawWidth -= (ctx->DrawBuffer->_Xmin - destX); |
| 103 |
destX = ctx->DrawBuffer->_Xmin; |
| 104 |
} |
| 105 |
if (destX + drawWidth > ctx->DrawBuffer->_Xmax) |
| 106 |
drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax); |
| 107 |
if (drawWidth <= 0) |
| 108 |
return GL_TRUE; |
| 109 |
|
| 110 |
/* vertical clipping */ |
| 111 |
if (destY < ctx->DrawBuffer->_Ymin) { |
| 112 |
skipRows += (ctx->DrawBuffer->_Ymin - destY); |
| 113 |
drawHeight -= (ctx->DrawBuffer->_Ymin - destY); |
| 114 |
destY = ctx->DrawBuffer->_Ymin; |
| 115 |
} |
| 116 |
if (destY + drawHeight > ctx->DrawBuffer->_Ymax) |
| 117 |
drawHeight -= (destY + drawHeight - ctx->DrawBuffer->_Ymax); |
| 118 |
if (drawHeight <= 0) |
| 119 |
return GL_TRUE; |
| 120 |
} |
| 121 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 122 |
/* upside-down image */ |
| 123 |
/* horizontal clipping */ |
| 124 |
if (destX < ctx->DrawBuffer->_Xmin) { |
| 125 |
skipPixels += (ctx->DrawBuffer->_Xmin - destX); |
| 126 |
drawWidth -= (ctx->DrawBuffer->_Xmin - destX); |
| 127 |
destX = ctx->DrawBuffer->_Xmin; |
| 128 |
} |
| 129 |
if (destX + drawWidth > ctx->DrawBuffer->_Xmax) |
| 130 |
drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax); |
| 131 |
if (drawWidth <= 0) |
| 132 |
return GL_TRUE; |
| 133 |
|
| 134 |
/* vertical clipping */ |
| 135 |
if (destY > ctx->DrawBuffer->_Ymax) { |
| 136 |
skipRows += (destY - ctx->DrawBuffer->_Ymax); |
| 137 |
drawHeight -= (destY - ctx->DrawBuffer->_Ymax); |
| 138 |
destY = ctx->DrawBuffer->_Ymax; |
| 139 |
} |
| 140 |
if (destY - drawHeight < ctx->DrawBuffer->_Ymin) |
| 141 |
drawHeight -= (ctx->DrawBuffer->_Ymin - (destY - drawHeight)); |
| 142 |
if (drawHeight <= 0) |
| 143 |
return GL_TRUE; |
| 144 |
} |
| 145 |
else { |
| 146 |
if (drawWidth > MAX_WIDTH) |
| 147 |
return GL_FALSE; /* fall back to general case path */ |
| 148 |
|
| 149 |
/* save Y value of first row */ |
| 150 |
zoomY0 = IROUND(ctx->Current.RasterPos[1]); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
/* |
| 155 |
* Ready to draw! |
| 156 |
* The window region at (destX, destY) of size (drawWidth, drawHeight) |
| 157 |
* will be written to. |
| 158 |
* We'll take pixel data from buffer pointed to by "pixels" but we'll |
| 159 |
* skip "skipRows" rows and skip "skipPixels" pixels/row. |
| 160 |
*/ |
| 161 |
|
| 162 |
if (format == GL_RGBA && type == CHAN_TYPE |
| 163 |
&& ctx->_ImageTransferState==0) { |
| 164 |
if (ctx->Visual.rgbMode) { |
| 165 |
GLchan *src = (GLchan *) pixels |
| 166 |
+ (skipRows * rowLength + skipPixels) * 4; |
| 167 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 168 |
/* no zooming */ |
| 169 |
GLint row; |
| 170 |
for (row=0; row<drawHeight; row++) { |
| 171 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL); |
| 172 |
src += rowLength * 4; |
| 173 |
destY++; |
| 174 |
} |
| 175 |
} |
| 176 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 177 |
/* upside-down */ |
| 178 |
GLint row; |
| 179 |
for (row=0; row<drawHeight; row++) { |
| 180 |
destY--; |
| 181 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL); |
| 182 |
src += rowLength * 4; |
| 183 |
} |
| 184 |
} |
| 185 |
else { |
| 186 |
/* with zooming */ |
| 187 |
GLint row; |
| 188 |
for (row=0; row<drawHeight; row++) { |
| 189 |
span.x = destX; |
| 190 |
span.y = destY; |
| 191 |
span.end = drawWidth; |
| 192 |
_swrast_write_zoomed_rgba_span(ctx, &span, |
| 193 |
(CONST GLchan (*)[4]) src, zoomY0, 0); |
| 194 |
src += rowLength * 4; |
| 195 |
destY++; |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
return GL_TRUE; |
| 200 |
} |
| 201 |
else if (format == GL_RGB && type == CHAN_TYPE |
| 202 |
&& ctx->_ImageTransferState == 0) { |
| 203 |
if (ctx->Visual.rgbMode) { |
| 204 |
GLchan *src = (GLchan *) pixels |
| 205 |
+ (skipRows * rowLength + skipPixels) * 3; |
| 206 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 207 |
GLint row; |
| 208 |
for (row=0; row<drawHeight; row++) { |
| 209 |
rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL); |
| 210 |
src += rowLength * 3; |
| 211 |
destY++; |
| 212 |
} |
| 213 |
} |
| 214 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 215 |
/* upside-down */ |
| 216 |
GLint row; |
| 217 |
for (row=0; row<drawHeight; row++) { |
| 218 |
destY--; |
| 219 |
rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL); |
| 220 |
src += rowLength * 3; |
| 221 |
} |
| 222 |
} |
| 223 |
else { |
| 224 |
/* with zooming */ |
| 225 |
GLint row; |
| 226 |
for (row=0; row<drawHeight; row++) { |
| 227 |
span.x = destX; |
| 228 |
span.y = destY; |
| 229 |
span.end = drawWidth; |
| 230 |
_swrast_write_zoomed_rgb_span(ctx, &span, |
| 231 |
(CONST GLchan (*)[3]) src, zoomY0, 0); |
| 232 |
src += rowLength * 3; |
| 233 |
destY++; |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
return GL_TRUE; |
| 238 |
} |
| 239 |
else if (format == GL_LUMINANCE && type == CHAN_TYPE |
| 240 |
&& ctx->_ImageTransferState==0) { |
| 241 |
if (ctx->Visual.rgbMode) { |
| 242 |
GLchan *src = (GLchan *) pixels |
| 243 |
+ (skipRows * rowLength + skipPixels); |
| 244 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 245 |
/* no zooming */ |
| 246 |
GLint row; |
| 247 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 248 |
for (row=0; row<drawHeight; row++) { |
| 249 |
GLint i; |
| 250 |
for (i=0;i<drawWidth;i++) { |
| 251 |
span.array->rgb[i][0] = src[i]; |
| 252 |
span.array->rgb[i][1] = src[i]; |
| 253 |
span.array->rgb[i][2] = src[i]; |
| 254 |
} |
| 255 |
rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, |
| 256 |
span.array->rgb, NULL); |
| 257 |
src += rowLength; |
| 258 |
destY++; |
| 259 |
} |
| 260 |
} |
| 261 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 262 |
/* upside-down */ |
| 263 |
GLint row; |
| 264 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 265 |
for (row=0; row<drawHeight; row++) { |
| 266 |
GLint i; |
| 267 |
for (i=0;i<drawWidth;i++) { |
| 268 |
span.array->rgb[i][0] = src[i]; |
| 269 |
span.array->rgb[i][1] = src[i]; |
| 270 |
span.array->rgb[i][2] = src[i]; |
| 271 |
} |
| 272 |
destY--; |
| 273 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, |
| 274 |
span.array->rgb, NULL); |
| 275 |
src += rowLength; |
| 276 |
} |
| 277 |
} |
| 278 |
else { |
| 279 |
/* with zooming */ |
| 280 |
GLint row; |
| 281 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 282 |
for (row=0; row<drawHeight; row++) { |
| 283 |
GLint i; |
| 284 |
for (i=0;i<drawWidth;i++) { |
| 285 |
span.array->rgb[i][0] = src[i]; |
| 286 |
span.array->rgb[i][1] = src[i]; |
| 287 |
span.array->rgb[i][2] = src[i]; |
| 288 |
} |
| 289 |
span.x = destX; |
| 290 |
span.y = destY; |
| 291 |
span.end = drawWidth; |
| 292 |
_swrast_write_zoomed_rgb_span(ctx, &span, |
| 293 |
(CONST GLchan (*)[3]) span.array->rgb, zoomY0, 0); |
| 294 |
src += rowLength; |
| 295 |
destY++; |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
return GL_TRUE; |
| 300 |
} |
| 301 |
else if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE |
| 302 |
&& ctx->_ImageTransferState == 0) { |
| 303 |
if (ctx->Visual.rgbMode) { |
| 304 |
GLchan *src = (GLchan *) pixels |
| 305 |
+ (skipRows * rowLength + skipPixels)*2; |
| 306 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 307 |
/* no zooming */ |
| 308 |
GLint row; |
| 309 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 310 |
for (row=0; row<drawHeight; row++) { |
| 311 |
GLint i; |
| 312 |
GLchan *ptr = src; |
| 313 |
for (i=0;i<drawWidth;i++) { |
| 314 |
span.array->rgba[i][0] = *ptr; |
| 315 |
span.array->rgba[i][1] = *ptr; |
| 316 |
span.array->rgba[i][2] = *ptr++; |
| 317 |
span.array->rgba[i][3] = *ptr++; |
| 318 |
} |
| 319 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, |
| 320 |
span.array->rgba, NULL); |
| 321 |
src += rowLength*2; |
| 322 |
destY++; |
| 323 |
} |
| 324 |
} |
| 325 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 326 |
/* upside-down */ |
| 327 |
GLint row; |
| 328 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 329 |
for (row=0; row<drawHeight; row++) { |
| 330 |
GLint i; |
| 331 |
GLchan *ptr = src; |
| 332 |
for (i=0;i<drawWidth;i++) { |
| 333 |
span.array->rgba[i][0] = *ptr; |
| 334 |
span.array->rgba[i][1] = *ptr; |
| 335 |
span.array->rgba[i][2] = *ptr++; |
| 336 |
span.array->rgba[i][3] = *ptr++; |
| 337 |
} |
| 338 |
destY--; |
| 339 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, |
| 340 |
span.array->rgba, NULL); |
| 341 |
src += rowLength*2; |
| 342 |
} |
| 343 |
} |
| 344 |
else { |
| 345 |
/* with zooming */ |
| 346 |
GLint row; |
| 347 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 348 |
for (row=0; row<drawHeight; row++) { |
| 349 |
GLchan *ptr = src; |
| 350 |
GLint i; |
| 351 |
for (i=0;i<drawWidth;i++) { |
| 352 |
span.array->rgba[i][0] = *ptr; |
| 353 |
span.array->rgba[i][1] = *ptr; |
| 354 |
span.array->rgba[i][2] = *ptr++; |
| 355 |
span.array->rgba[i][3] = *ptr++; |
| 356 |
} |
| 357 |
span.x = destX; |
| 358 |
span.y = destY; |
| 359 |
span.end = drawWidth; |
| 360 |
_swrast_write_zoomed_rgba_span(ctx, &span, |
| 361 |
(CONST GLchan (*)[4]) span.array->rgba, zoomY0, 0); |
| 362 |
src += rowLength*2; |
| 363 |
destY++; |
| 364 |
} |
| 365 |
} |
| 366 |
} |
| 367 |
return GL_TRUE; |
| 368 |
} |
| 369 |
else if (format==GL_COLOR_INDEX && type==GL_UNSIGNED_BYTE) { |
| 370 |
GLubyte *src = (GLubyte *) pixels + skipRows * rowLength + skipPixels; |
| 371 |
if (ctx->Visual.rgbMode) { |
| 372 |
/* convert CI data to RGBA */ |
| 373 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 374 |
/* no zooming */ |
| 375 |
GLint row; |
| 376 |
for (row=0; row<drawHeight; row++) { |
| 377 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 378 |
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba); |
| 379 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, |
| 380 |
span.array->rgba, NULL); |
| 381 |
src += rowLength; |
| 382 |
destY++; |
| 383 |
} |
| 384 |
return GL_TRUE; |
| 385 |
} |
| 386 |
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) { |
| 387 |
/* upside-down */ |
| 388 |
GLint row; |
| 389 |
for (row=0; row<drawHeight; row++) { |
| 390 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 391 |
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba); |
| 392 |
destY--; |
| 393 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, |
| 394 |
span.array->rgba, NULL); |
| 395 |
src += rowLength; |
| 396 |
} |
| 397 |
return GL_TRUE; |
| 398 |
} |
| 399 |
else { |
| 400 |
/* with zooming */ |
| 401 |
GLint row; |
| 402 |
for (row=0; row<drawHeight; row++) { |
| 403 |
ASSERT(drawWidth <= MAX_WIDTH); |
| 404 |
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba); |
| 405 |
span.x = destX; |
| 406 |
span.y = destY; |
| 407 |
span.end = drawWidth; |
| 408 |
_swrast_write_zoomed_rgba_span(ctx, &span, |
| 409 |
(CONST GLchan (*)[4]) span.array->rgba, zoomY0, 0); |
| 410 |
src += rowLength; |
| 411 |
destY++; |
| 412 |
} |
| 413 |
return GL_TRUE; |
| 414 |
} |
| 415 |
} |
| 416 |
else if (ctx->_ImageTransferState==0) { |
| 417 |
/* write CI data to CI frame buffer */ |
| 418 |
GLint row; |
| 419 |
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { |
| 420 |
/* no zooming */ |
| 421 |
for (row=0; row<drawHeight; row++) { |
| 422 |
GLuint index32[MAX_WIDTH]; |
| 423 |
GLint col; |
| 424 |
for (col = 0; col < drawWidth; col++) |
| 425 |
index32[col] = src[col]; |
| 426 |
rb->PutRow(ctx, rb, drawWidth, destX, destY, index32, NULL); |
| 427 |
src += rowLength; |
| 428 |
destY++; |
| 429 |
} |
| 430 |
return GL_TRUE; |
| 431 |
} |
| 432 |
else { |
| 433 |
/* with zooming */ |
| 434 |
return GL_FALSE; |
| 435 |
} |
| 436 |
} |
| 437 |
} |
| 438 |
else { |
| 439 |
/* can't handle this pixel format and/or data type here */ |
| 440 |
return GL_FALSE; |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
/* can't do a simple draw, have to use slow path */ |
| 445 |
return GL_FALSE; |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
/* |
| 451 |
* Draw color index image. |
| 452 |
*/ |
| 453 |
static void |
| 454 |
draw_index_pixels( GLcontext *ctx, GLint x, GLint y, |
| 455 |
GLsizei width, GLsizei height, |
| 456 |
GLenum type, |
| 457 |
const struct gl_pixelstore_attrib *unpack, |
| 458 |
const GLvoid *pixels ) |
| 459 |
{ |
| 460 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 461 |
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; |
| 462 |
GLint row, skipPixels; |
| 463 |
struct sw_span span; |
| 464 |
|
| 465 |
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); |
| 466 |
|
| 467 |
if (ctx->Depth.Test) |
| 468 |
_swrast_span_default_z(ctx, &span); |
| 469 |
if (swrast->_FogEnabled) |
| 470 |
_swrast_span_default_fog(ctx, &span); |
| 471 |
|
| 472 |
/* |
| 473 |
* General solution |
| 474 |
*/ |
| 475 |
skipPixels = 0; |
| 476 |
while (skipPixels < width) { |
| 477 |
const GLint spanX = x + (zoom ? 0 : skipPixels); |
| 478 |
GLint spanY = y; |
| 479 |
const GLint spanEnd = (width - skipPixels > MAX_WIDTH) |
| 480 |
? MAX_WIDTH : (width - skipPixels); |
| 481 |
ASSERT(spanEnd <= MAX_WIDTH); |
| 482 |
for (row = 0; row < height; row++, spanY++) { |
| 483 |
const GLvoid *source = _mesa_image_address2d(unpack, pixels, |
| 484 |
width, height, |
| 485 |
GL_COLOR_INDEX, type, |
| 486 |
row, skipPixels); |
| 487 |
_mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT, |
| 488 |
span.array->index, type, source, unpack, |
| 489 |
ctx->_ImageTransferState); |
| 490 |
|
| 491 |
/* These may get changed during writing/clipping */ |
| 492 |
span.x = spanX; |
| 493 |
span.y = spanY; |
| 494 |
span.end = spanEnd; |
| 495 |
|
| 496 |
if (zoom) |
| 497 |
_swrast_write_zoomed_index_span(ctx, &span, y, skipPixels); |
| 498 |
else |
| 499 |
_swrast_write_index_span(ctx, &span); |
| 500 |
} |
| 501 |
skipPixels += spanEnd; |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
/* |
| 508 |
* Draw stencil image. |
| 509 |
*/ |
| 510 |
static void |
| 511 |
draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, |
| 512 |
GLsizei width, GLsizei height, |
| 513 |
GLenum type, |
| 514 |
const struct gl_pixelstore_attrib *unpack, |
| 515 |
const GLvoid *pixels ) |
| 516 |
{ |
| 517 |
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; |
| 518 |
const GLint desty = y; |
| 519 |
GLint row, skipPixels; |
| 520 |
|
| 521 |
if (type != GL_BYTE && |
| 522 |
type != GL_UNSIGNED_BYTE && |
| 523 |
type != GL_SHORT && |
| 524 |
type != GL_UNSIGNED_SHORT && |
| 525 |
type != GL_INT && |
| 526 |
type != GL_UNSIGNED_INT && |
| 527 |
type != GL_FLOAT && |
| 528 |
type != GL_BITMAP) { |
| 529 |
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(stencil type)"); |
| 530 |
return; |
| 531 |
} |
| 532 |
|
| 533 |
if (ctx->Visual.stencilBits == 0) { |
| 534 |
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)"); |
| 535 |
return; |
| 536 |
} |
| 537 |
|
| 538 |
/* if width > MAX_WIDTH, have to process image in chunks */ |
| 539 |
skipPixels = 0; |
| 540 |
while (skipPixels < width) { |
| 541 |
const GLint spanX = x; |
| 542 |
GLint spanY = y; |
| 543 |
const GLint spanWidth = (width - skipPixels > MAX_WIDTH) |
| 544 |
? MAX_WIDTH : (width - skipPixels); |
| 545 |
|
| 546 |
for (row = 0; row < height; row++, spanY++) { |
| 547 |
GLstencil values[MAX_WIDTH]; |
| 548 |
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) |
| 549 |
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; |
| 550 |
const GLvoid *source = _mesa_image_address2d(unpack, pixels, |
| 551 |
width, height, |
| 552 |
GL_COLOR_INDEX, type, |
| 553 |
row, skipPixels); |
| 554 |
_mesa_unpack_index_span(ctx, spanWidth, destType, values, |
| 555 |
type, source, unpack, |
| 556 |
ctx->_ImageTransferState); |
| 557 |
if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) { |
| 558 |
_mesa_shift_and_offset_stencil(ctx, spanWidth, values); |
| 559 |
} |
| 560 |
if (ctx->Pixel.MapStencilFlag) { |
| 561 |
_mesa_map_stencil(ctx, spanWidth, values); |
| 562 |
} |
| 563 |
|
| 564 |
if (zoom) { |
| 565 |
_swrast_write_zoomed_stencil_span(ctx, (GLuint) spanWidth, |
| 566 |
spanX, spanY, values, desty, 0); |
| 567 |
} |
| 568 |
else { |
| 569 |
_swrast_write_stencil_span(ctx, spanWidth, spanX, spanY, values); |
| 570 |
} |
| 571 |
} |
| 572 |
skipPixels += spanWidth; |
| 573 |
} |
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
/* |
| 578 |
* Draw depth image. |
| 579 |
*/ |
| 580 |
static void |
| 581 |
draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, |
| 582 |
GLsizei width, GLsizei height, |
| 583 |
GLenum type, |
| 584 |
const struct gl_pixelstore_attrib *unpack, |
| 585 |
const GLvoid *pixels ) |
| 586 |
{ |
| 587 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 588 |
const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; |
| 589 |
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; |
| 590 |
const GLint desty = y; |
| 591 |
struct sw_span span; |
| 592 |
|
| 593 |
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); |
| 594 |
|
| 595 |
if (type != GL_BYTE |
| 596 |
&& type != GL_UNSIGNED_BYTE |
| 597 |
&& type != GL_SHORT |
| 598 |
&& type != GL_UNSIGNED_SHORT |
| 599 |
&& type != GL_INT |
| 600 |
&& type != GL_UNSIGNED_INT |
| 601 |
&& type != GL_FLOAT) { |
| 602 |
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(type)"); |
| 603 |
return; |
| 604 |
} |
| 605 |
|
| 606 |
_swrast_span_default_color(ctx, &span); |
| 607 |
|
| 608 |
if (swrast->_FogEnabled) |
| 609 |
_swrast_span_default_fog(ctx, &span); |
| 610 |
if (ctx->Texture._EnabledCoordUnits) |
| 611 |
_swrast_span_default_texcoords(ctx, &span); |
| 612 |
|
| 613 |
if (type == GL_UNSIGNED_SHORT |
| 614 |
&& ctx->Visual.depthBits == 16 |
| 615 |
&& !bias_or_scale |
| 616 |
&& !zoom |
| 617 |
&& ctx->Visual.rgbMode |
| 618 |
&& width <= MAX_WIDTH) { |
| 619 |
/* Special case: directly write 16-bit depth values */ |
| 620 |
GLint row, spanY = y; |
| 621 |
for (row = 0; row < height; row++, spanY++) { |
| 622 |
const GLushort *zSrc = (const GLushort *) |
| 623 |
_mesa_image_address2d(unpack, pixels, width, height, |
| 624 |
GL_DEPTH_COMPONENT, type, row, 0); |
| 625 |
GLint i; |
| 626 |
for (i = 0; i < width; i++) |
| 627 |
span.array->z[i] = zSrc[i]; |
| 628 |
span.x = x; |
| 629 |
span.y = spanY; |
| 630 |
span.end = width; |
| 631 |
_swrast_write_rgba_span(ctx, &span); |
| 632 |
} |
| 633 |
} |
| 634 |
else if (type == GL_UNSIGNED_INT |
| 635 |
&& sizeof(GLdepth) == 4 |
| 636 |
&& !bias_or_scale |
| 637 |
&& !zoom |
| 638 |
&& ctx->Visual.rgbMode |
| 639 |
&& width <= MAX_WIDTH) { |
| 640 |
/* Special case: shift 32-bit values down to ctx->Visual.depthBits */ |
| 641 |
const GLint shift = 32 - ctx->Visual.depthBits; |
| 642 |
GLint row, spanY = y; |
| 643 |
for (row = 0; row < height; row++, spanY++) { |
| 644 |
const GLuint *zSrc = (const GLuint *) |
| 645 |
_mesa_image_address2d(unpack, pixels, width, height, |
| 646 |
GL_DEPTH_COMPONENT, type, row, 0); |
| 647 |
if (shift == 0) { |
| 648 |
MEMCPY(span.array->z, zSrc, width * sizeof(GLdepth)); |
| 649 |
} |
| 650 |
else { |
| 651 |
GLint col; |
| 652 |
for (col = 0; col < width; col++) |
| 653 |
span.array->z[col] = zSrc[col] >> shift; |
| 654 |
} |
| 655 |
span.x = x; |
| 656 |
span.y = spanY; |
| 657 |
span.end = width; |
| 658 |
_swrast_write_rgba_span(ctx, &span); |
| 659 |
} |
| 660 |
} |
| 661 |
else { |
| 662 |
/* General case */ |
| 663 |
const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; |
| 664 |
GLint row, skipPixels = 0; |
| 665 |
|
| 666 |
/* in case width > MAX_WIDTH do the copy in chunks */ |
| 667 |
while (skipPixels < width) { |
| 668 |
const GLint spanX = x + (zoom ? 0 : skipPixels); |
| 669 |
GLint spanY = y; |
| 670 |
const GLint spanEnd = (width - skipPixels > MAX_WIDTH) |
| 671 |
? MAX_WIDTH : (width - skipPixels); |
| 672 |
ASSERT(span.end <= MAX_WIDTH); |
| 673 |
for (row = 0; row < height; row++, spanY++) { |
| 674 |
GLfloat floatSpan[MAX_WIDTH]; |
| 675 |
const GLvoid *zSrc = _mesa_image_address2d(unpack, |
| 676 |
pixels, width, height, |
| 677 |
GL_DEPTH_COMPONENT, type, |
| 678 |
row, skipPixels); |
| 679 |
|
| 680 |
/* Set these for each row since the _swrast_write_* function may |
| 681 |
* change them while clipping. |
| 682 |
*/ |
| 683 |
span.x = spanX; |
| 684 |
span.y = spanY; |
| 685 |
span.end = spanEnd; |
| 686 |
|
| 687 |
_mesa_unpack_depth_span(ctx, span.end, floatSpan, type, |
| 688 |
zSrc, unpack); |
| 689 |
/* clamp depth values to [0,1] and convert from floats to ints */ |
| 690 |
{ |
| 691 |
GLuint i; |
| 692 |
for (i = 0; i < span.end; i++) { |
| 693 |
span.array->z[i] = (GLdepth) (floatSpan[i] * depthMax); |
| 694 |
} |
| 695 |
} |
| 696 |
if (zoom) { |
| 697 |
_swrast_write_zoomed_depth_span(ctx, &span, desty, skipPixels); |
| 698 |
} |
| 699 |
else if (ctx->Visual.rgbMode) { |
| 700 |
_swrast_write_rgba_span(ctx, &span); |
| 701 |
} |
| 702 |
else { |
| 703 |
_swrast_write_index_span(ctx, &span); |
| 704 |
} |
| 705 |
} |
| 706 |
skipPixels += spanEnd; |
| 707 |
} |
| 708 |
} |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
/* |
| 714 |
* Draw RGBA image. |
| 715 |
*/ |
| 716 |
static void |
| 717 |
draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, |
| 718 |
GLsizei width, GLsizei height, |
| 719 |
GLenum format, GLenum type, |
| 720 |
const struct gl_pixelstore_attrib *unpack, |
| 721 |
const GLvoid *pixels ) |
| 722 |
{ |
| 723 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 724 |
struct gl_renderbuffer *rb = NULL; /* only used for quickDraw path */ |
| 725 |
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; |
| 726 |
const GLint desty = y; |
| 727 |
GLboolean quickDraw; |
| 728 |
GLfloat *convImage = NULL; |
| 729 |
GLuint transferOps = ctx->_ImageTransferState; |
| 730 |
struct sw_span span; |
| 731 |
|
| 732 |
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); |
| 733 |
|
| 734 |
if (!_mesa_is_legal_format_and_type(ctx, format, type)) { |
| 735 |
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)"); |
| 736 |
return; |
| 737 |
} |
| 738 |
|
| 739 |
/* Try an optimized glDrawPixels first */ |
| 740 |
if (fast_draw_pixels(ctx, x, y, width, height, format, type, unpack, pixels)) |
| 741 |
return; |
| 742 |
|
| 743 |
if (ctx->Depth.Test) |
| 744 |
_swrast_span_default_z(ctx, &span); |
| 745 |
if (swrast->_FogEnabled) |
| 746 |
_swrast_span_default_fog(ctx, &span); |
| 747 |
if (ctx->Texture._EnabledCoordUnits) |
| 748 |
_swrast_span_default_texcoords(ctx, &span); |
| 749 |
|
| 750 |
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0 |
| 751 |
&& x + width <= (GLint) ctx->DrawBuffer->Width |
| 752 |
&& y + height <= (GLint) ctx->DrawBuffer->Height |
| 753 |
&& ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1) { |
| 754 |
quickDraw = GL_TRUE; |
| 755 |
rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0]; |
| 756 |
} |
| 757 |
else { |
| 758 |
quickDraw = GL_FALSE; |
| 759 |
rb = NULL; |
| 760 |
} |
| 761 |
|
| 762 |
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { |
| 763 |
/* Convolution has to be handled specially. We'll create an |
| 764 |
* intermediate image, applying all pixel transfer operations |
| 765 |
* up to convolution. Then we'll convolve the image. Then |
| 766 |
* we'll proceed with the rest of the transfer operations and |
| 767 |
* rasterize the image. |
| 768 |
*/ |
| 769 |
GLint row; |
| 770 |
GLfloat *dest, *tmpImage; |
| 771 |
|
| 772 |
tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); |
| 773 |
if (!tmpImage) { |
| 774 |
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); |
| 775 |
return; |
| 776 |
} |
| 777 |
convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); |
| 778 |
if (!convImage) { |
| 779 |
_mesa_free(tmpImage); |
| 780 |
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); |
| 781 |
return; |
| 782 |
} |
| 783 |
|
| 784 |
/* Unpack the image and apply transfer ops up to convolution */ |
| 785 |
dest = tmpImage; |
| 786 |
for (row = 0; row < height; row++) { |
| 787 |
const GLvoid *source = _mesa_image_address2d(unpack, |
| 788 |
pixels, width, height, format, type, row, 0); |
| 789 |
_mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest, |
| 790 |
format, type, source, unpack, |
| 791 |
transferOps & IMAGE_PRE_CONVOLUTION_BITS); |
| 792 |
dest += width * 4; |
| 793 |
} |
| 794 |
|
| 795 |
/* do convolution */ |
| 796 |
if (ctx->Pixel.Convolution2DEnabled) { |
| 797 |
_mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage); |
| 798 |
} |
| 799 |
else { |
| 800 |
ASSERT(ctx->Pixel.Separable2DEnabled); |
| 801 |
_mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); |
| 802 |
} |
| 803 |
_mesa_free(tmpImage); |
| 804 |
|
| 805 |
/* continue transfer ops and draw the convolved image */ |
| 806 |
unpack = &ctx->DefaultPacking; |
| 807 |
pixels = convImage; |
| 808 |
format = GL_RGBA; |
| 809 |
type = GL_FLOAT; |
| 810 |
transferOps &= IMAGE_POST_CONVOLUTION_BITS; |
| 811 |
} |
| 812 |
|
| 813 |
/* |
| 814 |
* General solution |
| 815 |
*/ |
| 816 |
{ |
| 817 |
const GLuint interpMask = span.interpMask; |
| 818 |
const GLuint arrayMask = span.arrayMask; |
| 819 |
GLint row, skipPixels = 0; |
| 820 |
|
| 821 |
/* if the span is wider than MAX_WIDTH we have to do it in chunks */ |
| 822 |
while (skipPixels < width) { |
| 823 |
const GLint spanX = x + (zoom ? 0 : skipPixels); |
| 824 |
GLint spanY = y; |
| 825 |
const GLint spanEnd = (width - skipPixels > MAX_WIDTH) |
| 826 |
? MAX_WIDTH : (width - skipPixels); |
| 827 |
ASSERT(span.end <= MAX_WIDTH); |
| 828 |
|
| 829 |
for (row = 0; row < height; row++, spanY++) { |
| 830 |
const GLvoid *source = _mesa_image_address2d(unpack, |
| 831 |
pixels, width, height, format, type, row, skipPixels); |
| 832 |
|
| 833 |
/* Set these for each row since the _swrast_write_* function may |
| 834 |
* change them while clipping. |
| 835 |
*/ |
| 836 |
span.x = spanX; |
| 837 |
span.y = spanY; |
| 838 |
span.end = spanEnd; |
| 839 |
span.arrayMask = arrayMask; |
| 840 |
span.interpMask = interpMask; |
| 841 |
|
| 842 |
_mesa_unpack_color_span_chan(ctx, span.end, GL_RGBA, |
| 843 |
(GLchan *) span.array->rgba, |
| 844 |
format, type, source, unpack, |
| 845 |
transferOps); |
| 846 |
|
| 847 |
if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) || |
| 848 |
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink)) |
| 849 |
continue; |
| 850 |
|
| 851 |
if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) { |
| 852 |
_swrast_pixel_texture(ctx, &span); |
| 853 |
} |
| 854 |
|
| 855 |
/* draw the span */ |
| 856 |
if (quickDraw) { |
| 857 |
rb->PutRow(ctx, rb, span.end, span.x, span.y, |
| 858 |
span.array->rgba, NULL); |
| 859 |
} |
| 860 |
else if (zoom) { |
| 861 |
_swrast_write_zoomed_rgba_span(ctx, &span, |
| 862 |
(CONST GLchan (*)[4]) span.array->rgba, desty, skipPixels); |
| 863 |
} |
| 864 |
else { |
| 865 |
_swrast_write_rgba_span(ctx, &span); |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
skipPixels += spanEnd; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
if (convImage) { |
| 874 |
_mesa_free(convImage); |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
/* |
| 881 |
* Execute glDrawPixels |
| 882 |
*/ |
| 883 |
void |
| 884 |
_swrast_DrawPixels( GLcontext *ctx, |
| 885 |
GLint x, GLint y, |
| 886 |
GLsizei width, GLsizei height, |
| 887 |
GLenum format, GLenum type, |
| 888 |
const struct gl_pixelstore_attrib *unpack, |
| 889 |
const GLvoid *pixels ) |
| 890 |
{ |
| 891 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 892 |
|
| 893 |
if (swrast->NewState) |
| 894 |
_swrast_validate_derived( ctx ); |
| 895 |
|
| 896 |
if (unpack->BufferObj->Name) { |
| 897 |
/* unpack from PBO */ |
| 898 |
GLubyte *buf; |
| 899 |
if (!_mesa_validate_pbo_access(2, unpack, width, height, 1, |
| 900 |
format, type, pixels)) { |
| 901 |
_mesa_error(ctx, GL_INVALID_OPERATION, |
| 902 |
"glDrawPixels(invalid PBO access)"); |
| 903 |
return; |
| 904 |
} |
| 905 |
buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, |
| 906 |
GL_READ_ONLY_ARB, |
| 907 |
unpack->BufferObj); |
| 908 |
if (!buf) { |
| 909 |
/* buffer is already mapped - that's an error */ |
| 910 |
_mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)"); |
| 911 |
return; |
| 912 |
} |
| 913 |
pixels = ADD_POINTERS(buf, pixels); |
| 914 |
} |
| 915 |
|
| 916 |
RENDER_START(swrast,ctx); |
| 917 |
|
| 918 |
switch (format) { |
| 919 |
case GL_STENCIL_INDEX: |
| 920 |
draw_stencil_pixels( ctx, x, y, width, height, type, unpack, pixels ); |
| 921 |
break; |
| 922 |
case GL_DEPTH_COMPONENT: |
| 923 |
draw_depth_pixels( ctx, x, y, width, height, type, unpack, pixels ); |
| 924 |
break; |
| 925 |
case GL_COLOR_INDEX: |
| 926 |
if (ctx->Visual.rgbMode) |
| 927 |
draw_rgba_pixels(ctx, x,y, width, height, format, type, unpack, pixels); |
| 928 |
else |
| 929 |
draw_index_pixels(ctx, x, y, width, height, type, unpack, pixels); |
| 930 |
break; |
| 931 |
case GL_RED: |
| 932 |
case GL_GREEN: |
| 933 |
case GL_BLUE: |
| 934 |
case GL_ALPHA: |
| 935 |
case GL_LUMINANCE: |
| 936 |
case GL_LUMINANCE_ALPHA: |
| 937 |
case GL_RGB: |
| 938 |
case GL_BGR: |
| 939 |
case GL_RGBA: |
| 940 |
case GL_BGRA: |
| 941 |
case GL_ABGR_EXT: |
| 942 |
draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels); |
| 943 |
break; |
| 944 |
default: |
| 945 |
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" ); |
| 946 |
/* don't return yet, clean-up */ |
| 947 |
} |
| 948 |
|
| 949 |
RENDER_FINISH(swrast,ctx); |
| 950 |
|
| 951 |
if (unpack->BufferObj->Name) { |
| 952 |
/* done with PBO so unmap it now */ |
| 953 |
ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, |
| 954 |
unpack->BufferObj); |
| 955 |
} |
| 956 |
} |
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
#if 0 /* experimental */ |
| 961 |
/* |
| 962 |
* Execute glDrawDepthPixelsMESA(). |
| 963 |
*/ |
| 964 |
void |
| 965 |
_swrast_DrawDepthPixelsMESA( GLcontext *ctx, |
| 966 |
GLint x, GLint y, |
| 967 |
GLsizei width, GLsizei height, |
| 968 |
GLenum colorFormat, GLenum colorType, |
| 969 |
const GLvoid *colors, |
| 970 |
GLenum depthType, const GLvoid *depths, |
| 971 |
const struct gl_pixelstore_attrib *unpack ) |
| 972 |
{ |
| 973 |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
| 974 |
|
| 975 |
if (swrast->NewState) |
| 976 |
_swrast_validate_derived( ctx ); |
| 977 |
|
| 978 |
RENDER_START(swrast,ctx); |
| 979 |
|
| 980 |
switch (colorFormat) { |
| 981 |
case GL_COLOR_INDEX: |
| 982 |
if (ctx->Visual.rgbMode) |
| 983 |
draw_rgba_pixels(ctx, x,y, width, height, colorFormat, colorType, unpack, colors); |
| 984 |
else |
| 985 |
draw_index_pixels(ctx, x, y, width, height, colorType, unpack, colors); |
| 986 |
break; |
| 987 |
case GL_RED: |
| 988 |
case GL_GREEN: |
| 989 |
case GL_BLUE: |
| 990 |
case GL_ALPHA: |
| 991 |
case GL_LUMINANCE: |
| 992 |
case GL_LUMINANCE_ALPHA: |
| 993 |
case GL_RGB: |
| 994 |
case GL_BGR: |
| 995 |
case GL_RGBA: |
| 996 |
case GL_BGRA: |
| 997 |
case GL_ABGR_EXT: |
| 998 |
draw_rgba_pixels(ctx, x, y, width, height, colorFormat, colorType, unpack, colors); |
| 999 |
break; |
| 1000 |
default: |
| 1001 |
_mesa_error( ctx, GL_INVALID_ENUM, |
| 1002 |
"glDrawDepthPixelsMESA(colorFormat)" ); |
| 1003 |
} |
| 1004 |
|
| 1005 |
RENDER_FINISH(swrast,ctx); |
| 1006 |
} |
| 1007 |
#endif |