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_logic.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 #include "main/glheader.h"
00027 #include "main/context.h"
00028 #include "main/imports.h"
00029 #include "main/macros.h"
00030 
00031 #include "s_context.h"
00032 #include "s_logic.h"
00033 #include "s_span.h"
00034 
00035 
00041 #define LOGIC_OP_LOOP(MODE, MASKSTRIDE)     \
00042 do {                        \
00043    GLuint i;                    \
00044    switch (MODE) {              \
00045       case GL_CLEAR:                \
00046          for (i = 0; i < n; i++) {      \
00047         if (mask[i / MASKSTRIDE]) {     \
00048            src[i] = 0;          \
00049         }                   \
00050      }                  \
00051      break;                 \
00052       case GL_SET:              \
00053          for (i = 0; i < n; i++) {      \
00054         if (mask[i / MASKSTRIDE]) {     \
00055            src[i] = ~0;         \
00056         }                   \
00057      }                  \
00058      break;                 \
00059       case GL_COPY:             \
00060      /* do nothing */           \
00061      break;                 \
00062       case GL_COPY_INVERTED:            \
00063          for (i = 0; i < n; i++) {      \
00064         if (mask[i / MASKSTRIDE]) {     \
00065            src[i] = ~src[i];        \
00066         }                   \
00067      }                  \
00068      break;                 \
00069       case GL_NOOP:             \
00070          for (i = 0; i < n; i++) {      \
00071         if (mask[i / MASKSTRIDE]) {     \
00072            src[i] = dest[i];        \
00073         }                   \
00074      }                  \
00075      break;                 \
00076       case GL_INVERT:               \
00077          for (i = 0; i < n; i++) {      \
00078         if (mask[i / MASKSTRIDE]) {     \
00079            src[i] = ~dest[i];       \
00080         }                   \
00081      }                  \
00082      break;                 \
00083       case GL_AND:              \
00084          for (i = 0; i < n; i++) {      \
00085         if (mask[i / MASKSTRIDE]) {     \
00086            src[i] &= dest[i];       \
00087         }                   \
00088      }                  \
00089      break;                 \
00090       case GL_NAND:             \
00091          for (i = 0; i < n; i++) {      \
00092         if (mask[i / MASKSTRIDE]) {     \
00093            src[i] = ~(src[i] & dest[i]);    \
00094         }                   \
00095      }                  \
00096      break;                 \
00097       case GL_OR:               \
00098          for (i = 0; i < n; i++) {      \
00099         if (mask[i / MASKSTRIDE]) {     \
00100            src[i] |= dest[i];       \
00101         }                   \
00102      }                  \
00103      break;                 \
00104       case GL_NOR:              \
00105          for (i = 0; i < n; i++) {      \
00106         if (mask[i / MASKSTRIDE]) {     \
00107            src[i] = ~(src[i] | dest[i]);    \
00108         }                   \
00109      }                  \
00110      break;                 \
00111       case GL_XOR:              \
00112          for (i = 0; i < n; i++) {      \
00113         if (mask[i / MASKSTRIDE]) {     \
00114            src[i] ^= dest[i];       \
00115         }                   \
00116      }                  \
00117      break;                 \
00118       case GL_EQUIV:                \
00119          for (i = 0; i < n; i++) {      \
00120         if (mask[i / MASKSTRIDE]) {     \
00121            src[i] = ~(src[i] ^ dest[i]);    \
00122         }                   \
00123      }                  \
00124      break;                 \
00125       case GL_AND_REVERSE:          \
00126          for (i = 0; i < n; i++) {      \
00127         if (mask[i / MASKSTRIDE]) {     \
00128            src[i] = src[i] & ~dest[i];  \
00129         }                   \
00130      }                  \
00131      break;                 \
00132       case GL_AND_INVERTED:         \
00133          for (i = 0; i < n; i++) {      \
00134         if (mask[i / MASKSTRIDE]) {     \
00135            src[i] = ~src[i] & dest[i];  \
00136         }                   \
00137      }                  \
00138      break;                 \
00139       case GL_OR_REVERSE:           \
00140          for (i = 0; i < n; i++) {      \
00141         if (mask[i / MASKSTRIDE]) {     \
00142            src[i] = src[i] | ~dest[i];  \
00143         }                   \
00144      }                  \
00145      break;                 \
00146       case GL_OR_INVERTED:          \
00147          for (i = 0; i < n; i++) {      \
00148         if (mask[i / MASKSTRIDE]) {     \
00149            src[i] = ~src[i] | dest[i];  \
00150         }                   \
00151      }                  \
00152      break;                 \
00153       default:                  \
00154      _mesa_problem(ctx, "bad logicop mode");\
00155    }                        \
00156 } while (0)
00157 
00158 
00159 
00160 static INLINE void
00161 logicop_uint1(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[],
00162               const GLubyte mask[])
00163 {
00164    LOGIC_OP_LOOP(ctx->Color.LogicOp, 1);
00165 }
00166 
00167 
00168 static INLINE void
00169 logicop_uint2(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[],
00170               const GLubyte mask[])
00171 {
00172    LOGIC_OP_LOOP(ctx->Color.LogicOp, 2);
00173 }
00174 
00175 
00176 static INLINE void
00177 logicop_uint4(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[],
00178               const GLubyte mask[])
00179 {
00180    LOGIC_OP_LOOP(ctx->Color.LogicOp, 4);
00181 }
00182 
00183 
00184 
00185 /*
00186  * Apply the current logic operator to a span of CI pixels.  This is only
00187  * used if the device driver can't do logic ops.
00188  */
00189 void
00190 _swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
00191                         SWspan *span)
00192 {
00193    GLuint dest[MAX_WIDTH];
00194    GLuint *index = span->array->index;
00195 
00196    ASSERT(span->end < MAX_WIDTH);
00197    ASSERT(rb->DataType == GL_UNSIGNED_INT);
00198 
00199    /* Read dest values from frame buffer */
00200    if (span->arrayMask & SPAN_XY) {
00201       _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
00202                          dest, sizeof(GLuint));
00203    }
00204    else {
00205       rb->GetRow(ctx, rb, span->end, span->x, span->y, dest);
00206    }
00207 
00208    logicop_uint1(ctx, span->end, index, dest, span->array->mask);
00209 }
00210 
00211 
00217 void
00218 _swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
00219                           SWspan *span)
00220 {
00221    void *rbPixels;
00222 
00223    ASSERT(span->end < MAX_WIDTH);
00224    ASSERT(span->arrayMask & SPAN_RGBA);
00225    ASSERT(rb->DataType == span->array->ChanType);
00226 
00227    rbPixels = _swrast_get_dest_rgba(ctx, rb, span);
00228 
00229    if (span->array->ChanType == GL_UNSIGNED_BYTE) {
00230       /* treat 4*GLubyte as GLuint */
00231       logicop_uint1(ctx, span->end,
00232                     (GLuint *) span->array->rgba8,
00233                     (const GLuint *) rbPixels, span->array->mask);
00234    }
00235    else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
00236       /* treat 2*GLushort as GLuint */
00237       logicop_uint2(ctx, 2 * span->end,
00238                     (GLuint *) span->array->rgba16,
00239                     (const GLuint *) rbPixels, span->array->mask);
00240    }
00241    else {
00242       logicop_uint4(ctx, 4 * span->end,
00243                     (GLuint *) span->array->attribs[FRAG_ATTRIB_COL0],
00244                     (const GLuint *) rbPixels, span->array->mask);
00245    }
00246 }

Generated on Fri May 25 2012 04:18:51 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.