ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

s_readpix.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  7.0.3
00004  *
00005  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 
00026 #include "main/glheader.h"
00027 #include "main/bufferobj.h"
00028 #include "main/colormac.h"
00029 #include "main/convolve.h"
00030 #include "main/context.h"
00031 #include "main/feedback.h"
00032 #include "main/image.h"
00033 #include "main/macros.h"
00034 #include "main/imports.h"
00035 #include "main/pixel.h"
00036 #include "main/state.h"
00037 
00038 #include "s_context.h"
00039 #include "s_depth.h"
00040 #include "s_span.h"
00041 #include "s_stencil.h"
00042 
00043 
00044 /*
00045  * Read a block of color index pixels.
00046  */
00047 static void
00048 read_index_pixels( GLcontext *ctx,
00049                    GLint x, GLint y,
00050                    GLsizei width, GLsizei height,
00051                    GLenum type, GLvoid *pixels,
00052                    const struct gl_pixelstore_attrib *packing )
00053 {
00054    struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
00055    GLint i;
00056 
00057    if (!rb)
00058       return;
00059 
00060    /* width should never be > MAX_WIDTH since we did clipping earlier */
00061    ASSERT(width <= MAX_WIDTH);
00062 
00063    /* process image row by row */
00064    for (i = 0; i < height; i++) {
00065       GLuint index[MAX_WIDTH];
00066       GLvoid *dest;
00067       ASSERT(rb->DataType == GL_UNSIGNED_INT);
00068       rb->GetRow(ctx, rb, width, x, y + i, index);
00069 
00070       dest = _mesa_image_address2d(packing, pixels, width, height,
00071                                    GL_COLOR_INDEX, type, i, 0);
00072 
00073       _mesa_pack_index_span(ctx, width, type, dest, index,
00074                             &ctx->Pack, ctx->_ImageTransferState);
00075    }
00076 }
00077 
00078 
00079 
00083 static void
00084 read_depth_pixels( GLcontext *ctx,
00085                    GLint x, GLint y,
00086                    GLsizei width, GLsizei height,
00087                    GLenum type, GLvoid *pixels,
00088                    const struct gl_pixelstore_attrib *packing )
00089 {
00090    struct gl_framebuffer *fb = ctx->ReadBuffer;
00091    struct gl_renderbuffer *rb = fb->_DepthBuffer;
00092    const GLboolean biasOrScale
00093       = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
00094 
00095    if (!rb)
00096       return;
00097 
00098    /* clipping should have been done already */
00099    ASSERT(x >= 0);
00100    ASSERT(y >= 0);
00101    ASSERT(x + width <= (GLint) rb->Width);
00102    ASSERT(y + height <= (GLint) rb->Height);
00103    /* width should never be > MAX_WIDTH since we did clipping earlier */
00104    ASSERT(width <= MAX_WIDTH);
00105 
00106    if (type == GL_UNSIGNED_SHORT && fb->Visual.depthBits == 16
00107        && !biasOrScale && !packing->SwapBytes) {
00108       /* Special case: directly read 16-bit unsigned depth values. */
00109       GLint j;
00110       ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT16);
00111       ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
00112       for (j = 0; j < height; j++, y++) {
00113          void *dest =_mesa_image_address2d(packing, pixels, width, height,
00114                                            GL_DEPTH_COMPONENT, type, j, 0);
00115          rb->GetRow(ctx, rb, width, x, y, dest);
00116       }
00117    }
00118    else if (type == GL_UNSIGNED_INT && fb->Visual.depthBits == 24
00119             && !biasOrScale && !packing->SwapBytes) {
00120       /* Special case: directly read 24-bit unsigned depth values. */
00121       GLint j;
00122       ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT24);
00123       ASSERT(rb->DataType == GL_UNSIGNED_INT);
00124       for (j = 0; j < height; j++, y++) {
00125          GLuint *dest = (GLuint *)
00126             _mesa_image_address2d(packing, pixels, width, height,
00127                                   GL_DEPTH_COMPONENT, type, j, 0);
00128          GLint k;
00129          rb->GetRow(ctx, rb, width, x, y, dest);
00130          /* convert range from 24-bit to 32-bit */
00131          for (k = 0; k < width; k++) {
00132             /* Note: put MSByte of 24-bit value into LSByte */
00133             dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff);
00134          }
00135       }
00136    }
00137    else if (type == GL_UNSIGNED_INT && fb->Visual.depthBits == 32
00138             && !biasOrScale && !packing->SwapBytes) {
00139       /* Special case: directly read 32-bit unsigned depth values. */
00140       GLint j;
00141       ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT32);
00142       ASSERT(rb->DataType == GL_UNSIGNED_INT);
00143       for (j = 0; j < height; j++, y++) {
00144          void *dest = _mesa_image_address2d(packing, pixels, width, height,
00145                                             GL_DEPTH_COMPONENT, type, j, 0);
00146          rb->GetRow(ctx, rb, width, x, y, dest);
00147       }
00148    }
00149    else {
00150       /* General case (slower) */
00151       GLint j;
00152       for (j = 0; j < height; j++, y++) {
00153          GLfloat depthValues[MAX_WIDTH];
00154          GLvoid *dest = _mesa_image_address2d(packing, pixels, width, height,
00155                                               GL_DEPTH_COMPONENT, type, j, 0);
00156          _swrast_read_depth_span_float(ctx, rb, width, x, y, depthValues);
00157          _mesa_pack_depth_span(ctx, width, dest, type, depthValues, packing);
00158       }
00159    }
00160 }
00161 
00162 
00166 static void
00167 read_stencil_pixels( GLcontext *ctx,
00168                      GLint x, GLint y,
00169                      GLsizei width, GLsizei height,
00170                      GLenum type, GLvoid *pixels,
00171                      const struct gl_pixelstore_attrib *packing )
00172 {
00173    struct gl_framebuffer *fb = ctx->ReadBuffer;
00174    struct gl_renderbuffer *rb = fb->_StencilBuffer;
00175    GLint j;
00176 
00177    if (!rb)
00178       return;
00179 
00180    /* width should never be > MAX_WIDTH since we did clipping earlier */
00181    ASSERT(width <= MAX_WIDTH);
00182 
00183    /* process image row by row */
00184    for (j=0;j<height;j++,y++) {
00185       GLvoid *dest;
00186       GLstencil stencil[MAX_WIDTH];
00187 
00188       _swrast_read_stencil_span(ctx, rb, width, x, y, stencil);
00189 
00190       dest = _mesa_image_address2d(packing, pixels, width, height,
00191                                    GL_STENCIL_INDEX, type, j, 0);
00192 
00193       _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing);
00194    }
00195 }
00196 
00197 
00198 
00204 static GLboolean
00205 fast_read_rgba_pixels( GLcontext *ctx,
00206                        GLint x, GLint y,
00207                        GLsizei width, GLsizei height,
00208                        GLenum format, GLenum type,
00209                        GLvoid *pixels,
00210                        const struct gl_pixelstore_attrib *packing,
00211                        GLbitfield transferOps)
00212 {
00213    struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
00214 
00215    if (!rb)
00216       return GL_FALSE;
00217 
00218    ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
00219 
00220    /* clipping should have already been done */
00221    ASSERT(x + width <= (GLint) rb->Width);
00222    ASSERT(y + height <= (GLint) rb->Height);
00223 
00224    /* check for things we can't handle here */
00225    if (transferOps ||
00226        packing->SwapBytes ||
00227        packing->LsbFirst) {
00228       return GL_FALSE;
00229    }
00230 
00231    if (format == GL_RGBA && rb->DataType == type) {
00232       const GLint dstStride = _mesa_image_row_stride(packing, width,
00233                                                      format, type);
00234       GLubyte *dest
00235          = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
00236                                              format, type, 0, 0);
00237       GLint row;
00238       ASSERT(rb->GetRow);
00239       for (row = 0; row < height; row++) {
00240          rb->GetRow(ctx, rb, width, x, y + row, dest);
00241          dest += dstStride;
00242       }
00243       return GL_TRUE;
00244    }
00245 
00246    if (format == GL_RGB &&
00247        rb->DataType == GL_UNSIGNED_BYTE &&
00248        type == GL_UNSIGNED_BYTE) {
00249       const GLint dstStride = _mesa_image_row_stride(packing, width,
00250                                                      format, type);
00251       GLubyte *dest
00252          = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
00253                                              format, type, 0, 0);
00254       GLint row;
00255       ASSERT(rb->GetRow);
00256       for (row = 0; row < height; row++) {
00257          GLubyte tempRow[MAX_WIDTH][4];
00258          GLint col;
00259          rb->GetRow(ctx, rb, width, x, y + row, tempRow);
00260          /* convert RGBA to RGB */
00261          for (col = 0; col < width; col++) {
00262             dest[col * 3 + 0] = tempRow[col][0];
00263             dest[col * 3 + 1] = tempRow[col][1];
00264             dest[col * 3 + 2] = tempRow[col][2];
00265          }
00266          dest += dstStride;
00267       }
00268       return GL_TRUE;
00269    }
00270 
00271    /* not handled */
00272    return GL_FALSE;
00273 }
00274 
00275 
00285 static void
00286 adjust_colors(GLcontext *ctx, GLuint n, GLfloat rgba[][4])
00287 {
00288    const GLuint rShift = 8 - ctx->Visual.redBits;
00289    const GLuint gShift = 8 - ctx->Visual.greenBits;
00290    const GLuint bShift = 8 - ctx->Visual.blueBits;
00291    const GLfloat rScale = 1.0F / (GLfloat) ((1 << ctx->Visual.redBits  ) - 1);
00292    const GLfloat gScale = 1.0F / (GLfloat) ((1 << ctx->Visual.greenBits) - 1);
00293    const GLfloat bScale = 1.0F / (GLfloat) ((1 << ctx->Visual.blueBits ) - 1);
00294    GLuint i;
00295    for (i = 0; i < n; i++) {
00296       GLint r, g, b;
00297       /* convert float back to ubyte */
00298       CLAMPED_FLOAT_TO_UBYTE(r, rgba[i][RCOMP]);
00299       CLAMPED_FLOAT_TO_UBYTE(g, rgba[i][GCOMP]);
00300       CLAMPED_FLOAT_TO_UBYTE(b, rgba[i][BCOMP]);
00301       /* using only the N most significant bits of the ubyte value, convert to
00302        * float in [0,1].
00303        */
00304       rgba[i][RCOMP] = (GLfloat) (r >> rShift) * rScale;
00305       rgba[i][GCOMP] = (GLfloat) (g >> gShift) * gScale;
00306       rgba[i][BCOMP] = (GLfloat) (b >> bShift) * bScale;
00307    }
00308 }
00309 
00310 
00311 
00312 /*
00313  * Read R, G, B, A, RGB, L, or LA pixels.
00314  */
00315 static void
00316 read_rgba_pixels( GLcontext *ctx,
00317                   GLint x, GLint y,
00318                   GLsizei width, GLsizei height,
00319                   GLenum format, GLenum type, GLvoid *pixels,
00320                   const struct gl_pixelstore_attrib *packing )
00321 {
00322    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00323    GLbitfield transferOps = ctx->_ImageTransferState;
00324    struct gl_framebuffer *fb = ctx->ReadBuffer;
00325    struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
00326 
00327    if (!rb)
00328       return;
00329 
00330    if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) ||
00331                             (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB &&
00332                              rb->DataType != GL_FLOAT)))
00333       transferOps |= IMAGE_CLAMP_BIT;
00334 
00335    /* Try optimized path first */
00336    if (fast_read_rgba_pixels(ctx, x, y, width, height,
00337                              format, type, pixels, packing, transferOps)) {
00338       return; /* done! */
00339    }
00340 
00341    /* width should never be > MAX_WIDTH since we did clipping earlier */
00342    ASSERT(width <= MAX_WIDTH);
00343 
00344    if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
00345       GLfloat *dest, *src, *tmpImage, *convImage;
00346       GLint row;
00347 
00348       tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
00349       if (!tmpImage) {
00350          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
00351          return;
00352       }
00353       convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
00354       if (!convImage) {
00355          _mesa_free(tmpImage);
00356          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
00357          return;
00358       }
00359 
00360       /* read full RGBA, FLOAT image */
00361       dest = tmpImage;
00362       for (row = 0; row < height; row++, y++) {
00363          if (fb->Visual.rgbMode) {
00364             _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest);
00365          }
00366          else {
00367             GLuint index[MAX_WIDTH];
00368             ASSERT(rb->DataType == GL_UNSIGNED_INT);
00369             rb->GetRow(ctx, rb, width, x, y, index);
00370             _mesa_apply_ci_transfer_ops(ctx,
00371                                         transferOps & IMAGE_SHIFT_OFFSET_BIT,
00372                                         width, index);
00373             _mesa_map_ci_to_rgba(ctx, width, index, (GLfloat (*)[4]) dest);
00374          }
00375          _mesa_apply_rgba_transfer_ops(ctx, 
00376                                       transferOps & IMAGE_PRE_CONVOLUTION_BITS,
00377                                       width, (GLfloat (*)[4]) dest);
00378          dest += width * 4;
00379       }
00380 
00381       /* do convolution */
00382       if (ctx->Pixel.Convolution2DEnabled) {
00383          _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
00384       }
00385       else {
00386          ASSERT(ctx->Pixel.Separable2DEnabled);
00387          _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
00388       }
00389       _mesa_free(tmpImage);
00390 
00391       /* finish transfer ops and pack the resulting image */
00392       src = convImage;
00393       for (row = 0; row < height; row++) {
00394          GLvoid *dest;
00395          dest = _mesa_image_address2d(packing, pixels, width, height,
00396                                       format, type, row, 0);
00397          _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src,
00398                                     format, type, dest, packing,
00399                                     transferOps & IMAGE_POST_CONVOLUTION_BITS);
00400          src += width * 4;
00401       }
00402       _mesa_free(convImage);
00403    }
00404    else {
00405       /* no convolution */
00406       const GLint dstStride
00407          = _mesa_image_row_stride(packing, width, format, type);
00408       GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
00409       GLint row;
00410       GLubyte *dst
00411          = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
00412                                              format, type, 0, 0);
00413 
00414       /* make sure we don't apply 1D convolution */
00415       transferOps &= ~(IMAGE_CONVOLUTION_BIT |
00416                        IMAGE_POST_CONVOLUTION_SCALE_BIAS);
00417 
00418       for (row = 0; row < height; row++, y++) {
00419 
00420          /* Get float rgba pixels */
00421          if (fb->Visual.rgbMode) {
00422             _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba);
00423          }
00424          else {
00425             /* read CI and convert to RGBA */
00426             GLuint index[MAX_WIDTH];
00427             ASSERT(rb->DataType == GL_UNSIGNED_INT);
00428             rb->GetRow(ctx, rb, width, x, y, index);
00429             _mesa_apply_ci_transfer_ops(ctx,
00430                                         transferOps & IMAGE_SHIFT_OFFSET_BIT,
00431                                         width, index);
00432             _mesa_map_ci_to_rgba(ctx, width, index, rgba);
00433          }
00434 
00435          /* apply fudge factor for shallow color buffers */
00436          if (fb->Visual.redBits < 8 ||
00437              fb->Visual.greenBits < 8 ||
00438              fb->Visual.blueBits < 8) {
00439             adjust_colors(ctx, width, rgba);
00440          }
00441 
00442          /* pack the row of RGBA pixels into user's buffer */
00443          _mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
00444                                     packing, transferOps);
00445 
00446          dst += dstStride;
00447       }
00448    }
00449 }
00450 
00451 
00457 static void
00458 read_depth_stencil_pixels(GLcontext *ctx,
00459                           GLint x, GLint y,
00460                           GLsizei width, GLsizei height,
00461                           GLenum type, GLvoid *pixels,
00462                           const struct gl_pixelstore_attrib *packing )
00463 {
00464    const GLboolean scaleOrBias
00465       = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
00466    const GLboolean stencilTransfer = ctx->Pixel.IndexShift
00467       || ctx->Pixel.IndexOffset || ctx->Pixel.MapStencilFlag;
00468    struct gl_renderbuffer *depthRb, *stencilRb;
00469 
00470    depthRb = ctx->ReadBuffer->_DepthBuffer;
00471    stencilRb = ctx->ReadBuffer->_StencilBuffer;
00472 
00473    if (!depthRb || !stencilRb)
00474       return;
00475 
00476    depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
00477    stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
00478 
00479    if (depthRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
00480        stencilRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
00481        depthRb == stencilRb &&
00482        !scaleOrBias &&
00483        !stencilTransfer) {
00484       /* This is the ideal case.
00485        * Reading GL_DEPTH_STENCIL pixels from combined depth/stencil buffer.
00486        * Plus, no pixel transfer ops to worry about!
00487        */
00488       GLint i;
00489       GLint dstStride = _mesa_image_row_stride(packing, width,
00490                                                GL_DEPTH_STENCIL_EXT, type);
00491       GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
00492                                                        width, height,
00493                                                        GL_DEPTH_STENCIL_EXT,
00494                                                        type, 0, 0);
00495       for (i = 0; i < height; i++) {
00496          depthRb->GetRow(ctx, depthRb, width, x, y + i, dst);
00497          dst += dstStride;
00498       }
00499    }
00500    else {
00501       /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
00502        * or we need pixel transfer.
00503        */
00504       GLint i;
00505       depthRb = ctx->ReadBuffer->_DepthBuffer;
00506       stencilRb = ctx->ReadBuffer->_StencilBuffer;
00507 
00508       for (i = 0; i < height; i++) {
00509          GLstencil stencilVals[MAX_WIDTH];
00510 
00511          GLuint *depthStencilDst = (GLuint *)
00512             _mesa_image_address2d(packing, pixels, width, height,
00513                                   GL_DEPTH_STENCIL_EXT, type, i, 0);
00514 
00515          _swrast_read_stencil_span(ctx, stencilRb, width,
00516                                    x, y + i, stencilVals);
00517 
00518          if (!scaleOrBias && !stencilTransfer
00519              && ctx->ReadBuffer->Visual.depthBits == 24) {
00520             /* ideal case */
00521             GLuint zVals[MAX_WIDTH]; /* 24-bit values! */
00522             GLint j;
00523             ASSERT(depthRb->DataType == GL_UNSIGNED_INT);
00524             /* note, we've already been clipped */
00525             depthRb->GetRow(ctx, depthRb, width, x, y + i, zVals);
00526             for (j = 0; j < width; j++) {
00527                depthStencilDst[j] = (zVals[j] << 8) | (stencilVals[j] & 0xff);
00528             }
00529          }
00530          else {
00531             /* general case */
00532             GLfloat depthVals[MAX_WIDTH];
00533             _swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
00534                                           depthVals);
00535             _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
00536                                           depthVals, stencilVals, packing);
00537          }
00538       }
00539    }
00540 }
00541 
00542 
00543 
00548 void
00549 _swrast_ReadPixels( GLcontext *ctx,
00550             GLint x, GLint y, GLsizei width, GLsizei height,
00551             GLenum format, GLenum type,
00552             const struct gl_pixelstore_attrib *packing,
00553             GLvoid *pixels )
00554 {
00555    SWcontext *swrast = SWRAST_CONTEXT(ctx);
00556    struct gl_pixelstore_attrib clippedPacking = *packing;
00557 
00558    /* Need to do RENDER_START before clipping or anything else since this
00559     * is where a driver may grab the hw lock and get an updated window
00560     * size.
00561     */
00562    RENDER_START(swrast, ctx);
00563 
00564    if (ctx->NewState)
00565       _mesa_update_state(ctx);
00566 
00567    if (swrast->NewState)
00568       _swrast_validate_derived( ctx );
00569 
00570    /* Do all needed clipping here, so that we can forget about it later */
00571    if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
00572       /* The ReadPixels region is totally outside the window bounds */
00573       RENDER_FINISH(swrast, ctx);
00574       return;
00575    }
00576 
00577    pixels = _mesa_map_readpix_pbo(ctx, &clippedPacking, pixels);
00578    if (!pixels)
00579       return;
00580   
00581    switch (format) {
00582       case GL_COLOR_INDEX:
00583          read_index_pixels(ctx, x, y, width, height, type, pixels,
00584                            &clippedPacking);
00585      break;
00586       case GL_STENCIL_INDEX:
00587      read_stencil_pixels(ctx, x, y, width, height, type, pixels,
00588                              &clippedPacking);
00589          break;
00590       case GL_DEPTH_COMPONENT:
00591      read_depth_pixels(ctx, x, y, width, height, type, pixels,
00592                            &clippedPacking);
00593      break;
00594       case GL_RED:
00595       case GL_GREEN:
00596       case GL_BLUE:
00597       case GL_ALPHA:
00598       case GL_RGB:
00599       case GL_LUMINANCE:
00600       case GL_LUMINANCE_ALPHA:
00601       case GL_RGBA:
00602       case GL_BGR:
00603       case GL_BGRA:
00604       case GL_ABGR_EXT:
00605          read_rgba_pixels(ctx, x, y, width, height,
00606                           format, type, pixels, &clippedPacking);
00607      break;
00608       case GL_DEPTH_STENCIL_EXT:
00609          read_depth_stencil_pixels(ctx, x, y, width, height,
00610                                    type, pixels, &clippedPacking);
00611          break;
00612       default:
00613      _mesa_problem(ctx, "unexpected format in _swrast_ReadPixels");
00614          /* don't return yet, clean-up */
00615    }
00616 
00617    RENDER_FINISH(swrast, ctx);
00618 
00619    _mesa_unmap_readpix_pbo(ctx, &clippedPacking);
00620 }

Generated on Sun May 27 2012 04:20:43 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.