/* * Apply glColorMask to an array of RGBA pixels. */ void gl_mask_color_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], const GLubyte mask[] ) { GLubyte r[PB_SIZE], g[PB_SIZE], b[PB_SIZE], a[PB_SIZE]; (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, r, g, b, a, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { gl_read_alpha_pixels( ctx, n, x, y, a, mask ); } if ((ctx->Color.ColorMask & 8) == 0) { /* replace source reds with frame buffer reds */ MEMCPY( red, r, n ); } if ((ctx->Color.ColorMask & 4) == 0) { /* replace source greens with frame buffer greens */ MEMCPY( green, g, n ); } if ((ctx->Color.ColorMask & 2) == 0) { /* replace source blues with frame buffer blues */ MEMCPY( blue, b, n ); } if ((ctx->Color.ColorMask & 1) == 0) { /* replace source alphas with frame buffer alphas */ MEMCPY( alpha, a, n ); } }
/* * Apply the current logic operator to an array of RGBA pixels. * This is only used if the device driver can't do logic ops. */ void gl_logicop_rgba_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte dest[PB_SIZE][4]; (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { gl_read_alpha_pixels( ctx, n, x, y, dest, mask ); } rgba_logicop( ctx, n, mask, (GLuint *) rgba, (const GLuint *) dest ); }