~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/swrast/s_masking.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Mesa 3-D graphics library
 
4
 * Version:  3.5
 
5
 *
 
6
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person obtaining a
 
9
 * copy of this software and associated documentation files (the "Software"),
 
10
 * to deal in the Software without restriction, including without limitation
 
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
12
 * and/or sell copies of the Software, and to permit persons to whom the
 
13
 * Software is furnished to do so, subject to the following conditions:
 
14
 *
 
15
 * The above copyright notice and this permission notice shall be included
 
16
 * in all copies or substantial portions of the Software.
 
17
 *
 
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
19
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
21
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
22
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
23
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 */
 
25
 
 
26
 
 
27
/*
 
28
 * Implement the effect of glColorMask and glIndexMask in software.
 
29
 */
 
30
 
 
31
 
 
32
#include "glheader.h"
 
33
#include "enums.h"
 
34
#include "macros.h"
 
35
 
 
36
#include "s_alphabuf.h"
 
37
#include "s_context.h"
 
38
#include "s_masking.h"
 
39
#include "s_pb.h"
 
40
#include "s_span.h"
 
41
 
 
42
 
 
43
/*
 
44
 * Apply glColorMask to a span of RGBA pixels.
 
45
 */
 
46
void
 
47
_mesa_mask_rgba_span( GLcontext *ctx,
 
48
                      GLuint n, GLint x, GLint y, GLchan rgba[][4] )
 
49
{
 
50
   GLchan dest[MAX_WIDTH][4];
 
51
   GLuint i;
 
52
 
 
53
#if CHAN_BITS == 8
 
54
 
 
55
   GLuint srcMask = *((GLuint*)ctx->Color.ColorMask);
 
56
   GLuint dstMask = ~srcMask;
 
57
   GLuint *rgba32 = (GLuint *) rgba;
 
58
   GLuint *dest32 = (GLuint *) dest;
 
59
 
 
60
   _mesa_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
 
61
   for (i = 0; i < n; i++) {
 
62
      rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
 
63
   }
 
64
 
 
65
#else
 
66
 
 
67
   const GLint rMask = ctx->Color.ColorMask[RCOMP];
 
68
   const GLint gMask = ctx->Color.ColorMask[GCOMP];
 
69
   const GLint bMask = ctx->Color.ColorMask[BCOMP];
 
70
   const GLint aMask = ctx->Color.ColorMask[ACOMP];
 
71
 
 
72
   _mesa_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
 
73
   for (i = 0; i < n; i++) {
 
74
      if (!rMask)  rgba[i][RCOMP] = dest[i][RCOMP];
 
75
      if (!gMask)  rgba[i][GCOMP] = dest[i][GCOMP];
 
76
      if (!bMask)  rgba[i][BCOMP] = dest[i][BCOMP];
 
77
      if (!aMask)  rgba[i][ACOMP] = dest[i][ACOMP];
 
78
   }
 
79
 
 
80
#endif
 
81
}
 
82
 
 
83
 
 
84
 
 
85
/*
 
86
 * Apply glColorMask to an array of RGBA pixels.
 
87
 */
 
88
void
 
89
_mesa_mask_rgba_pixels( GLcontext *ctx,
 
90
                        GLuint n, const GLint x[], const GLint y[],
 
91
                        GLchan rgba[][4], const GLubyte mask[] )
 
92
{
 
93
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
 
94
   GLchan dest[PB_SIZE][4];
 
95
   GLuint i;
 
96
 
 
97
#if CHAN_BITS == 8
 
98
 
 
99
   GLuint srcMask = *((GLuint*)ctx->Color.ColorMask);
 
100
   GLuint dstMask = ~srcMask;
 
101
   GLuint *rgba32 = (GLuint *) rgba;
 
102
   GLuint *dest32 = (GLuint *) dest;
 
103
 
 
104
   (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
 
105
   if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
 
106
      _mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
 
107
   }
 
108
 
 
109
   for (i=0; i<n; i++) {
 
110
      rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
 
111
   }
 
112
 
 
113
#else
 
114
 
 
115
   const GLint rMask = ctx->Color.ColorMask[RCOMP];
 
116
   const GLint gMask = ctx->Color.ColorMask[GCOMP];
 
117
   const GLint bMask = ctx->Color.ColorMask[BCOMP];
 
118
   const GLint aMask = ctx->Color.ColorMask[ACOMP];
 
119
 
 
120
   (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
 
121
   if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
 
122
      _mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
 
123
   }
 
124
 
 
125
   for (i = 0; i < n; i++) {
 
126
      if (!rMask)  rgba[i][RCOMP] = dest[i][RCOMP];
 
127
      if (!gMask)  rgba[i][GCOMP] = dest[i][GCOMP];
 
128
      if (!bMask)  rgba[i][BCOMP] = dest[i][BCOMP];
 
129
      if (!aMask)  rgba[i][ACOMP] = dest[i][ACOMP];
 
130
   }
 
131
 
 
132
#endif
 
133
}
 
134
 
 
135
 
 
136
 
 
137
/*
 
138
 * Apply glIndexMask to a span of CI pixels.
 
139
 */
 
140
void
 
141
_mesa_mask_index_span( GLcontext *ctx,
 
142
                       GLuint n, GLint x, GLint y, GLuint index[] )
 
143
{
 
144
   GLuint i;
 
145
   GLuint fbindexes[MAX_WIDTH];
 
146
   GLuint msrc, mdest;
 
147
 
 
148
   _mesa_read_index_span( ctx, ctx->DrawBuffer, n, x, y, fbindexes );
 
149
 
 
150
   msrc = ctx->Color.IndexMask;
 
151
   mdest = ~msrc;
 
152
 
 
153
   for (i=0;i<n;i++) {
 
154
      index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
 
155
   }
 
156
}
 
157
 
 
158
 
 
159
 
 
160
/*
 
161
 * Apply glIndexMask to an array of CI pixels.
 
162
 */
 
163
void
 
164
_mesa_mask_index_pixels( GLcontext *ctx,
 
165
                         GLuint n, const GLint x[], const GLint y[],
 
166
                         GLuint index[], const GLubyte mask[] )
 
167
{
 
168
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
 
169
   GLuint i;
 
170
   GLuint fbindexes[PB_SIZE];
 
171
   GLuint msrc, mdest;
 
172
 
 
173
   (*swrast->Driver.ReadCI32Pixels)( ctx, n, x, y, fbindexes, mask );
 
174
 
 
175
   msrc = ctx->Color.IndexMask;
 
176
   mdest = ~msrc;
 
177
 
 
178
   for (i=0;i<n;i++) {
 
179
      index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
 
180
   }
 
181
}