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_masking.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.5.2
00004  *
00005  * Copyright (C) 1999-2006  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 /*
00027  * Implement the effect of glColorMask and glIndexMask in software.
00028  */
00029 
00030 
00031 #include "main/glheader.h"
00032 #include "main/macros.h"
00033 
00034 #include "s_context.h"
00035 #include "s_masking.h"
00036 #include "s_span.h"
00037 
00038 
00042 void
00043 _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
00044                        SWspan *span)
00045 {
00046    const GLuint n = span->end;
00047    void *rbPixels;
00048 
00049    ASSERT(n < MAX_WIDTH);
00050    ASSERT(span->arrayMask & SPAN_RGBA);
00051    ASSERT(rb->DataType == span->array->ChanType);
00052 
00053    rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
00054 
00055    /*
00056     * Do component masking.
00057     * Note that we're not using span->array->mask[] here.  We could...
00058     */
00059    if (span->array->ChanType == GL_UNSIGNED_BYTE) {
00060       /* treat 4xGLubyte as 1xGLuint */
00061       const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask);
00062       const GLuint dstMask = ~srcMask;
00063       const GLuint *dst = (const GLuint *) rbPixels;
00064       GLuint *src = (GLuint *) span->array->rgba8;
00065       GLuint i;
00066       for (i = 0; i < n; i++) {
00067          src[i] = (src[i] & srcMask) | (dst[i] & dstMask);
00068       }
00069    }
00070    else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
00071       /* 2-byte components */
00072       /* XXX try to use 64-bit arithmetic someday */
00073       const GLushort rMask = ctx->Color.ColorMask[RCOMP] ? 0xffff : 0x0;
00074       const GLushort gMask = ctx->Color.ColorMask[GCOMP] ? 0xffff : 0x0;
00075       const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0;
00076       const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0;
00077       const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
00078       GLushort (*src)[4] = span->array->rgba16;
00079       GLuint i;
00080       for (i = 0; i < n; i++) {
00081          src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
00082          src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
00083          src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
00084          src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
00085       }
00086    }
00087    else {
00088       /* 4-byte components */
00089       const GLuint rMask = ctx->Color.ColorMask[RCOMP] ? ~0x0 : 0x0;
00090       const GLuint gMask = ctx->Color.ColorMask[GCOMP] ? ~0x0 : 0x0;
00091       const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0;
00092       const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0;
00093       const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
00094       GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
00095       GLuint i;
00096       for (i = 0; i < n; i++) {
00097          src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
00098          src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask);
00099          src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask);
00100          src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask);
00101       }
00102    }
00103 }
00104 
00105 
00109 void
00110 _swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
00111                      SWspan *span)
00112 {
00113    const GLuint srcMask = ctx->Color.IndexMask;
00114    const GLuint dstMask = ~srcMask;
00115    GLuint *index = span->array->index;
00116    GLuint dest[MAX_WIDTH];
00117    GLuint i;
00118 
00119    ASSERT(span->arrayMask & SPAN_INDEX);
00120    ASSERT(span->end <= MAX_WIDTH);
00121    ASSERT(rb->DataType == GL_UNSIGNED_INT);
00122 
00123    if (span->arrayMask & SPAN_XY) {
00124       _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
00125                          dest, sizeof(GLuint));
00126    }
00127    else {
00128       _swrast_read_index_span(ctx, rb, span->end, span->x, span->y, dest);
00129    }
00130 
00131    for (i = 0; i < span->end; i++) {
00132       index[i] = (index[i] & srcMask) | (dest[i] & dstMask);
00133    }
00134 }

Generated on Sat May 26 2012 04:19:32 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.