home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src / logic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  15.4 KB  |  730 lines

  1. /* $Id: logic.c,v 1.7 1997/07/24 01:24:11 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.4
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: logic.c,v $
  26.  * Revision 1.7  1997/07/24 01:24:11  brianp
  27.  * changed precompiled header symbol from PCH to PC_HEADER
  28.  *
  29.  * Revision 1.6  1997/05/28 03:25:26  brianp
  30.  * added precompiled header (PCH) support
  31.  *
  32.  * Revision 1.5  1997/04/20 20:28:49  brianp
  33.  * replaced abort() with gl_problem()
  34.  *
  35.  * Revision 1.4  1997/03/04 18:56:57  brianp
  36.  * added #include <stdlib.h> for abort()
  37.  *
  38.  * Revision 1.3  1997/01/28 22:16:31  brianp
  39.  * added gl_logicop_rgba_span() and gl_logicop_rgba_pixels()
  40.  *
  41.  * Revision 1.2  1997/01/04 00:13:11  brianp
  42.  * was using ! instead of ~ to invert pixel bits (ugh!)
  43.  *
  44.  * Revision 1.1  1996/09/13 01:38:16  brianp
  45.  * Initial revision
  46.  *
  47.  */
  48.  
  49.  
  50. #ifdef PC_HEADER
  51. #include "all.h"
  52. #else
  53. #include <stdlib.h>
  54. #include "alphabuf.h"
  55. #include "context.h"
  56. #include "dlist.h"
  57. #include "logic.h"
  58. #include "macros.h"
  59. #include "pb.h"
  60. #include "span.h"
  61. #include "types.h"
  62. #endif
  63.  
  64.  
  65.  
  66. void gl_LogicOp( GLcontext *ctx, GLenum opcode )
  67. {
  68.    if (INSIDE_BEGIN_END(ctx)) {
  69.       gl_error( ctx, GL_INVALID_OPERATION, "glLogicOp" );
  70.       return;
  71.    }
  72.    switch (opcode) {
  73.       case GL_CLEAR:
  74.       case GL_SET:
  75.       case GL_COPY:
  76.       case GL_COPY_INVERTED:
  77.       case GL_NOOP:
  78.       case GL_INVERT:
  79.       case GL_AND:
  80.       case GL_NAND:
  81.       case GL_OR:
  82.       case GL_NOR:
  83.       case GL_XOR:
  84.       case GL_EQUIV:
  85.       case GL_AND_REVERSE:
  86.       case GL_AND_INVERTED:
  87.       case GL_OR_REVERSE:
  88.       case GL_OR_INVERTED:
  89.      ctx->Color.LogicOp = opcode;
  90.      {
  91.         int a = ctx->NewState | NEW_RASTER_OPS;
  92.         ctx->NewState = a;
  93.      }
  94.      return;
  95.       default:
  96.      gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
  97.      return;
  98.    }
  99. }
  100.  
  101.  
  102.  
  103.  
  104. /*
  105.  * Apply the current logic operator to a span of CI pixels.  This is only
  106.  * used if the device driver can't do logic ops.
  107.  */
  108. void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
  109.              GLuint index[], GLubyte mask[] )
  110. {
  111.    GLuint dest[MAX_WIDTH];
  112.    GLuint i;
  113.  
  114.    /* Read dest values from frame buffer */
  115.    (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, dest );
  116.  
  117.    switch (ctx->Color.LogicOp) {
  118.       case GL_CLEAR:
  119.      for (i=0;i<n;i++) {
  120.         if (mask[i]) {
  121.            index[i] = 0;
  122.         }
  123.      }
  124.      break;
  125.       case GL_SET:
  126.      for (i=0;i<n;i++) {
  127.         if (mask[i]) {
  128.            index[i] = 1;
  129.         }
  130.      }
  131.      break;
  132.       case GL_COPY:
  133.      /* do nothing */
  134.      break;
  135.       case GL_COPY_INVERTED:
  136.      for (i=0;i<n;i++) {
  137.         if (mask[i]) {
  138.            index[i] = ~index[i];
  139.         }
  140.      }
  141.      break;
  142.       case GL_NOOP:
  143.      for (i=0;i<n;i++) {
  144.         if (mask[i]) {
  145.            index[i] = dest[i];
  146.         }
  147.      }
  148.      break;
  149.       case GL_INVERT:
  150.      for (i=0;i<n;i++) {
  151.         if (mask[i]) {
  152.            index[i] = ~dest[i];
  153.         }
  154.      }
  155.      break;
  156.       case GL_AND:
  157.      for (i=0;i<n;i++) {
  158.         if (mask[i]) {
  159.            index[i] &= dest[i];
  160.         }
  161.      }
  162.      break;
  163.       case GL_NAND:
  164.      for (i=0;i<n;i++) {
  165.         if (mask[i]) {
  166.            index[i] = ~(index[i] & dest[i]);
  167.         }
  168.      }
  169.      break;
  170.       case GL_OR:
  171.      for (i=0;i<n;i++) {
  172.         if (mask[i]) {
  173.            index[i] |= dest[i];
  174.         }
  175.      }
  176.      break;
  177.       case GL_NOR:
  178.      for (i=0;i<n;i++) {
  179.         if (mask[i]) {
  180.            index[i] = ~(index[i] | dest[i]);
  181.         }
  182.      }
  183.      break;
  184.       case GL_XOR:
  185.      for (i=0;i<n;i++) {
  186.         if (mask[i]) {
  187.            index[i] ^= dest[i];
  188.         }
  189.      }
  190.      break;
  191.       case GL_EQUIV:
  192.      for (i=0;i<n;i++) {
  193.         if (mask[i]) {
  194.            index[i] = ~(index[i] ^ dest[i]);
  195.         }
  196.      }
  197.      break;
  198.       case GL_AND_REVERSE:
  199.      for (i=0;i<n;i++) {
  200.         if (mask[i]) {
  201.            index[i] = index[i] & ~dest[i];
  202.         }
  203.      }
  204.      break;
  205.       case GL_AND_INVERTED:
  206.      for (i=0;i<n;i++) {
  207.         if (mask[i]) {
  208.            index[i] = ~index[i] & dest[i];
  209.         }
  210.      }
  211.      break;
  212.       case GL_OR_REVERSE:
  213.      for (i=0;i<n;i++) {
  214.         if (mask[i]) {
  215.            index[i] = index[i] | ~dest[i];
  216.         }
  217.      }
  218.      break;
  219.       case GL_OR_INVERTED:
  220.      for (i=0;i<n;i++) {
  221.         if (mask[i]) {
  222.            index[i] = ~index[i] | dest[i];
  223.         }
  224.      }
  225.      break;
  226.       default:
  227.      gl_error( ctx, GL_INVALID_ENUM, "gl_logic error" );
  228.    }
  229. }
  230.  
  231.  
  232.  
  233. /*
  234.  * Apply the current logic operator to an array of CI pixels.  This is only
  235.  * used if the device driver can't do logic ops.
  236.  */
  237. void gl_logicop_ci_pixels( GLcontext *ctx,
  238.                GLuint n, const GLint x[], const GLint y[],
  239.                GLuint index[], GLubyte mask[] )
  240. {
  241.    GLuint dest[PB_SIZE];
  242.    GLuint i;
  243.  
  244.    /* Read dest values from frame buffer */
  245.    (*ctx->Driver.ReadIndexPixels)( ctx, n, x, y, dest, mask );
  246.  
  247.    switch (ctx->Color.LogicOp) {
  248.       case GL_CLEAR:
  249.      for (i=0;i<n;i++) {
  250.         if (mask[i]) {
  251.            index[i] = 0;
  252.         }
  253.      }
  254.      break;
  255.       case GL_SET:
  256.      for (i=0;i<n;i++) {
  257.         if (mask[i]) {
  258.            index[i] = 1;
  259.         }
  260.      }
  261.      break;
  262.       case GL_COPY:
  263.      /* do nothing */
  264.      break;
  265.       case GL_COPY_INVERTED:
  266.      for (i=0;i<n;i++) {
  267.         if (mask[i]) {
  268.            index[i] = ~index[i];
  269.         }
  270.      }
  271.      break;
  272.       case GL_NOOP:
  273.      for (i=0;i<n;i++) {
  274.         if (mask[i]) {
  275.            index[i] = dest[i];
  276.         }
  277.      }
  278.      break;
  279.       case GL_INVERT:
  280.      for (i=0;i<n;i++) {
  281.         if (mask[i]) {
  282.            index[i] = ~dest[i];
  283.         }
  284.      }
  285.      break;
  286.       case GL_AND:
  287.      for (i=0;i<n;i++) {
  288.         if (mask[i]) {
  289.            index[i] &= dest[i];
  290.         }
  291.      }
  292.      break;
  293.       case GL_NAND:
  294.      for (i=0;i<n;i++) {
  295.         if (mask[i]) {
  296.            index[i] = ~(index[i] & dest[i]);
  297.         }
  298.      }
  299.      break;
  300.       case GL_OR:
  301.      for (i=0;i<n;i++) {
  302.         if (mask[i]) {
  303.            index[i] |= dest[i];
  304.         }
  305.      }
  306.      break;
  307.       case GL_NOR:
  308.      for (i=0;i<n;i++) {
  309.         if (mask[i]) {
  310.            index[i] = ~(index[i] | dest[i]);
  311.         }
  312.      }
  313.      break;
  314.       case GL_XOR:
  315.      for (i=0;i<n;i++) {
  316.         if (mask[i]) {
  317.            index[i] ^= dest[i];
  318.         }
  319.      }
  320.      break;
  321.       case GL_EQUIV:
  322.      for (i=0;i<n;i++) {
  323.         if (mask[i]) {
  324.            index[i] = ~(index[i] ^ dest[i]);
  325.         }
  326.      }
  327.      break;
  328.       case GL_AND_REVERSE:
  329.      for (i=0;i<n;i++) {
  330.         if (mask[i]) {
  331.            index[i] = index[i] & ~dest[i];
  332.         }
  333.      }
  334.      break;
  335.       case GL_AND_INVERTED:
  336.      for (i=0;i<n;i++) {
  337.         if (mask[i]) {
  338.            index[i] = ~index[i] & dest[i];
  339.         }
  340.      }
  341.      break;
  342.       case GL_OR_REVERSE:
  343.      for (i=0;i<n;i++) {
  344.         if (mask[i]) {
  345.            index[i] = index[i] | ~dest[i];
  346.         }
  347.      }
  348.      break;
  349.       case GL_OR_INVERTED:
  350.      for (i=0;i<n;i++) {
  351.         if (mask[i]) {
  352.            index[i] = ~index[i] | dest[i];
  353.         }
  354.      }
  355.      break;
  356.       default:
  357.      gl_error( ctx, GL_INVALID_ENUM, "gl_logic_pixels error" );
  358.    }
  359. }
  360.  
  361.  
  362.  
  363. /*
  364.  * Apply the current logic operator to a span of RGBA pixels.  This is only
  365.  * used if the device driver can't do logic ops.
  366.  */
  367. void gl_logicop_rgba_span( GLcontext *ctx,
  368.                GLuint n, GLint x, GLint y,
  369.                GLubyte red[], GLubyte green[],
  370.                GLubyte blue[], GLubyte alpha[],
  371.                GLubyte mask[] )
  372. {
  373.    GLubyte rdest[MAX_WIDTH], gdest[MAX_WIDTH];
  374.    GLubyte bdest[MAX_WIDTH], adest[MAX_WIDTH];
  375.    GLuint i;
  376.  
  377.    /* Read span of current frame buffer pixels */
  378.    gl_read_color_span( ctx, n, x, y, rdest, gdest, bdest, adest );
  379.  
  380.    /* apply logic op */
  381.    switch (ctx->Color.LogicOp) {
  382.       case GL_CLEAR:
  383.      for (i=0;i<n;i++) {
  384.         if (mask[i]) {
  385.            red[i] = green[i] = blue[i] = alpha[i] = 0;
  386.         }
  387.      }
  388.      break;
  389.       case GL_SET:
  390.      {
  391.         GLubyte r = (GLint) ctx->Visual->RedScale;
  392.         GLubyte g = (GLint) ctx->Visual->GreenScale;
  393.         GLubyte b = (GLint) ctx->Visual->BlueScale;
  394.         GLubyte a = (GLint) ctx->Visual->AlphaScale;
  395.         for (i=0;i<n;i++) {
  396.            if (mask[i]) {
  397.           red[i]   = r;
  398.           green[i] = g;
  399.           blue[i]  = b;
  400.           alpha[i] = a;
  401.            }
  402.         }
  403.      }
  404.      break;
  405.       case GL_COPY:
  406.      /* do nothing */
  407.      break;
  408.       case GL_COPY_INVERTED:
  409.      for (i=0;i<n;i++) {
  410.         if (mask[i]) {
  411.            red[i]   = ~red[i];
  412.            green[i] = ~green[i];
  413.            blue[i]  = ~blue[i];
  414.            alpha[i] = ~alpha[i];
  415.         }
  416.      }
  417.      break;
  418.       case GL_NOOP:
  419.      for (i=0;i<n;i++) {
  420.         if (mask[i]) {
  421.            red[i]   = rdest[i];
  422.            green[i] = gdest[i];
  423.            blue[i]  = bdest[i];
  424.            alpha[i] = adest[i];
  425.         }
  426.      }
  427.      break;
  428.       case GL_INVERT:
  429.      for (i=0;i<n;i++) {
  430.         if (mask[i]) {
  431.            red[i]   = ~rdest[i];
  432.            green[i] = ~gdest[i];
  433.            blue[i]  = ~bdest[i];
  434.            alpha[i] = ~adest[i];
  435.         }
  436.      }
  437.      break;
  438.       case GL_AND:
  439.      for (i=0;i<n;i++) {
  440.         if (mask[i]) {
  441.            red[i]   &= rdest[i];
  442.            green[i] &= gdest[i];
  443.            blue[i]  &= bdest[i];
  444.            alpha[i] &= adest[i];
  445.         }
  446.      }
  447.      break;
  448.       case GL_NAND:
  449.      for (i=0;i<n;i++) {
  450.         if (mask[i]) {
  451.            red[i]   = ~(red[i]   & rdest[i]);
  452.            green[i] = ~(green[i] & gdest[i]);
  453.            blue[i]  = ~(blue[i]  & bdest[i]);
  454.            alpha[i] = ~(alpha[i] & adest[i]);
  455.         }
  456.      }
  457.      break;
  458.       case GL_OR:
  459.      for (i=0;i<n;i++) {
  460.         if (mask[i]) {
  461.            red[i]   |= rdest[i];
  462.            green[i] |= gdest[i];
  463.            blue[i]  |= bdest[i];
  464.            alpha[i] |= adest[i];
  465.         }
  466.      }
  467.      break;
  468.       case GL_NOR:
  469.      for (i=0;i<n;i++) {
  470.         if (mask[i]) {
  471.            red[i]   = ~(red[i]   | rdest[i]);
  472.            green[i] = ~(green[i] | gdest[i]);
  473.            blue[i]  = ~(blue[i]  | bdest[i]);
  474.            alpha[i] = ~(alpha[i] | adest[i]);
  475.         }
  476.      }
  477.      break;
  478.       case GL_XOR:
  479.      for (i=0;i<n;i++) {
  480.         if (mask[i]) {
  481.            red[i]   ^= rdest[i];
  482.            green[i] ^= gdest[i];
  483.            blue[i]  ^= bdest[i];
  484.            alpha[i] ^= adest[i];
  485.         }
  486.      }
  487.      break;
  488.       case GL_EQUIV:
  489.      for (i=0;i<n;i++) {
  490.         if (mask[i]) {
  491.            red[i]   = ~(red[i]   ^ rdest[i]);
  492.            green[i] = ~(green[i] ^ gdest[i]);
  493.            blue[i]  = ~(blue[i]  ^ bdest[i]);
  494.            alpha[i] = ~(alpha[i] ^ adest[i]);
  495.         }
  496.      }
  497.      break;
  498.       case GL_AND_REVERSE:
  499.      for (i=0;i<n;i++) {
  500.         if (mask[i]) {
  501.            red[i]   = red[i]   & ~rdest[i];
  502.            green[i] = green[i] & ~gdest[i];
  503.            blue[i]  = blue[i]  & ~bdest[i];
  504.            alpha[i] = alpha[i] & ~adest[i];
  505.         }
  506.      }
  507.      break;
  508.       case GL_AND_INVERTED:
  509.      for (i=0;i<n;i++) {
  510.         if (mask[i]) {
  511.            red[i]   = ~red[i]   & rdest[i];
  512.            green[i] = ~green[i] & gdest[i];
  513.            blue[i]  = ~blue[i]  & bdest[i];
  514.            alpha[i] = ~alpha[i] & adest[i];
  515.         }
  516.      }
  517.      break;
  518.       case GL_OR_REVERSE:
  519.      for (i=0;i<n;i++) {
  520.         if (mask[i]) {
  521.            red[i]   = red[i]   | ~rdest[i];
  522.            green[i] = green[i] | ~gdest[i];
  523.            blue[i]  = blue[i]  | ~bdest[i];
  524.            alpha[i] = alpha[i] | ~adest[i];
  525.         }
  526.      }
  527.      break;
  528.       case GL_OR_INVERTED:
  529.      for (i=0;i<n;i++) {
  530.         if (mask[i]) {
  531.            red[i]   = ~red[i]   | rdest[i];
  532.            green[i] = ~green[i] | gdest[i];
  533.            blue[i]  = ~blue[i]  | bdest[i];
  534.            alpha[i] = ~alpha[i] | adest[i];
  535.         }
  536.      }
  537.      break;
  538.       default:
  539.      /* should never happen */
  540.      gl_problem(ctx, "Bad function in gl_logicop_rgba_span");
  541.      return;
  542.    }
  543. }
  544.  
  545.  
  546.  
  547. /*
  548.  * Apply the current logic operator to an array of RGBA pixels.  This is only
  549.  * used if the device driver can't do logic ops.
  550.  */
  551. void gl_logicop_rgba_pixels( GLcontext *ctx,
  552.                  GLuint n, const GLint x[], const GLint y[],
  553.                  GLubyte red[], GLubyte green[],
  554.                  GLubyte blue[], GLubyte alpha[],
  555.                  GLubyte mask[] )
  556. {
  557.    GLubyte rdest[PB_SIZE], gdest[PB_SIZE], bdest[PB_SIZE], adest[PB_SIZE];
  558.    GLuint i;
  559.  
  560.    /* Read pixels from current color buffer */
  561.    (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask );
  562.    if (ctx->RasterMask & ALPHABUF_BIT) {
  563.       gl_read_alpha_pixels( ctx, n, x, y, adest, mask );
  564.    }
  565.  
  566.    /* apply logic op */
  567.    switch (ctx->Color.LogicOp) {
  568.       case GL_CLEAR:
  569.      for (i=0;i<n;i++) {
  570.         if (mask[i]) {
  571.            red[i] = green[i] = blue[i] = alpha[i] = 0;
  572.         }
  573.      }
  574.      break;
  575.       case GL_SET:
  576.      {
  577.         GLubyte r = (GLint) ctx->Visual->RedScale;
  578.         GLubyte g = (GLint) ctx->Visual->GreenScale;
  579.         GLubyte b = (GLint) ctx->Visual->BlueScale;
  580.         GLubyte a = (GLint) ctx->Visual->AlphaScale;
  581.         for (i=0;i<n;i++) {
  582.            if (mask[i]) {
  583.           red[i]   = r;
  584.           green[i] = g;
  585.           blue[i]  = b;
  586.           alpha[i] = a;
  587.            }
  588.         }
  589.      }
  590.      break;
  591.       case GL_COPY:
  592.      /* do nothing */
  593.      break;
  594.       case GL_COPY_INVERTED:
  595.      for (i=0;i<n;i++) {
  596.         if (mask[i]) {
  597.            red[i]   = ~red[i];
  598.            green[i] = ~green[i];
  599.            blue[i]  = ~blue[i];
  600.            alpha[i] = ~alpha[i];
  601.         }
  602.      }
  603.      break;
  604.       case GL_NOOP:
  605.      for (i=0;i<n;i++) {
  606.         if (mask[i]) {
  607.            red[i]   = rdest[i];
  608.            green[i] = gdest[i];
  609.            blue[i]  = bdest[i];
  610.            alpha[i] = adest[i];
  611.         }
  612.      }
  613.      break;
  614.       case GL_INVERT:
  615.      for (i=0;i<n;i++) {
  616.         if (mask[i]) {
  617.            red[i]   = ~rdest[i];
  618.            green[i] = ~gdest[i];
  619.            blue[i]  = ~bdest[i];
  620.            alpha[i] = ~adest[i];
  621.         }
  622.      }
  623.      break;
  624.       case GL_AND:
  625.      for (i=0;i<n;i++) {
  626.         if (mask[i]) {
  627.            red[i]   &= rdest[i];
  628.            green[i] &= gdest[i];
  629.            blue[i]  &= bdest[i];
  630.            alpha[i] &= adest[i];
  631.         }
  632.      }
  633.      break;
  634.       case GL_NAND:
  635.      for (i=0;i<n;i++) {
  636.         if (mask[i]) {
  637.            red[i]   = ~(red[i]   & rdest[i]);
  638.            green[i] = ~(green[i] & gdest[i]);
  639.            blue[i]  = ~(blue[i]  & bdest[i]);
  640.            alpha[i] = ~(alpha[i] & adest[i]);
  641.         }
  642.      }
  643.      break;
  644.       case GL_OR:
  645.      for (i=0;i<n;i++) {
  646.         if (mask[i]) {
  647.            red[i]   |= rdest[i];
  648.            green[i] |= gdest[i];
  649.            blue[i]  |= bdest[i];
  650.            alpha[i] |= adest[i];
  651.         }
  652.      }
  653.      break;
  654.       case GL_NOR:
  655.      for (i=0;i<n;i++) {
  656.         if (mask[i]) {
  657.            red[i]   = ~(red[i]   | rdest[i]);
  658.            green[i] = ~(green[i] | gdest[i]);
  659.            blue[i]  = ~(blue[i]  | bdest[i]);
  660.            alpha[i] = ~(alpha[i] | adest[i]);
  661.         }
  662.      }
  663.      break;
  664.       case GL_XOR:
  665.      for (i=0;i<n;i++) {
  666.         if (mask[i]) {
  667.            red[i]   ^= rdest[i];
  668.            green[i] ^= gdest[i];
  669.            blue[i]  ^= bdest[i];
  670.            alpha[i] ^= adest[i];
  671.         }
  672.      }
  673.      break;
  674.       case GL_EQUIV:
  675.      for (i=0;i<n;i++) {
  676.         if (mask[i]) {
  677.            red[i]   = ~(red[i]   ^ rdest[i]);
  678.            green[i] = ~(green[i] ^ gdest[i]);
  679.            blue[i]  = ~(blue[i]  ^ bdest[i]);
  680.            alpha[i] = ~(alpha[i] ^ adest[i]);
  681.         }
  682.      }
  683.      break;
  684.       case GL_AND_REVERSE:
  685.      for (i=0;i<n;i++) {
  686.         if (mask[i]) {
  687.            red[i]   = red[i]   & ~rdest[i];
  688.            green[i] = green[i] & ~gdest[i];
  689.            blue[i]  = blue[i]  & ~bdest[i];
  690.            alpha[i] = alpha[i] & ~adest[i];
  691.         }
  692.      }
  693.      break;
  694.       case GL_AND_INVERTED:
  695.      for (i=0;i<n;i++) {
  696.         if (mask[i]) {
  697.            red[i]   = ~red[i]   & rdest[i];
  698.            green[i] = ~green[i] & gdest[i];
  699.            blue[i]  = ~blue[i]  & bdest[i];
  700.            alpha[i] = ~alpha[i] & adest[i];
  701.         }
  702.      }
  703.      break;
  704.       case GL_OR_REVERSE:
  705.      for (i=0;i<n;i++) {
  706.         if (mask[i]) {
  707.            red[i]   = red[i]   | ~rdest[i];
  708.            green[i] = green[i] | ~gdest[i];
  709.            blue[i]  = blue[i]  | ~bdest[i];
  710.            alpha[i] = alpha[i] | ~adest[i];
  711.         }
  712.      }
  713.      break;
  714.       case GL_OR_INVERTED:
  715.      for (i=0;i<n;i++) {
  716.         if (mask[i]) {
  717.            red[i]   = ~red[i]   | rdest[i];
  718.            green[i] = ~green[i] | gdest[i];
  719.            blue[i]  = ~blue[i]  | bdest[i];
  720.            alpha[i] = ~alpha[i] | adest[i];
  721.         }
  722.      }
  723.      break;
  724.       default:
  725.      /* should never happen */
  726.      gl_problem(ctx, "Bad function in gl_logicop_rgba_pixels");
  727.      return;
  728.    }
  729. }
  730.