/* $Id: logic.c,v 1.2 2000/10/27 15:21:40 mholst Exp $ */ /* * Mesa 3-D graphics library * Version: 2.2 * Copyright (C) 1995-1997 Brian Paul * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "alphabuf.h" #include "context.h" #include "dlist.h" #include "logic.h" #include "macros.h" #include "pb.h" #include "span.h" #include "types.h" void gl_LogicOp( GLcontext *ctx, GLenum opcode ) { if (INSIDE_BEGIN_END(ctx)) { gl_error( ctx, GL_INVALID_OPERATION, "glLogicOp" ); return; } switch (opcode) { case GL_CLEAR: case GL_SET: case GL_COPY: case GL_COPY_INVERTED: case GL_NOOP: case GL_INVERT: case GL_AND: case GL_NAND: case GL_OR: case GL_NOR: case GL_XOR: case GL_EQUIV: case GL_AND_REVERSE: case GL_AND_INVERTED: case GL_OR_REVERSE: case GL_OR_INVERTED: ctx->Color.LogicOp = opcode; ctx->NewState |= NEW_RASTER_OPS; return; default: gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); return; } } /* * Apply the current logic operator to a span of CI pixels. This is only * used if the device driver can't do logic ops. */ void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[], GLubyte mask[] ) { GLuint dest[MAX_WIDTH]; GLuint i; /* Read dest values from frame buffer */ (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, dest ); switch (ctx->Color.LogicOp) { case GL_CLEAR: for (i=0;iDriver.ReadIndexPixels)( ctx, n, x, y, dest, mask ); switch (ctx->Color.LogicOp) { case GL_CLEAR: for (i=0;iColor.LogicOp) { case GL_CLEAR: for (i=0;iVisual->RedScale; GLubyte g = (GLint) ctx->Visual->GreenScale; GLubyte b = (GLint) ctx->Visual->BlueScale; GLubyte a = (GLint) ctx->Visual->AlphaScale; for (i=0;iDriver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { gl_read_alpha_pixels( ctx, n, x, y, adest, mask ); } /* apply logic op */ switch (ctx->Color.LogicOp) { case GL_CLEAR: for (i=0;iVisual->RedScale; GLubyte g = (GLint) ctx->Visual->GreenScale; GLubyte b = (GLint) ctx->Visual->BlueScale; GLubyte a = (GLint) ctx->Visual->AlphaScale; for (i=0;i