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

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/tnl/t_eval_api.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:  4.0.3
 
5
 *
 
6
 * Copyright (C) 1999-2002  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
#include "glheader.h"
 
28
#include "colormac.h"
 
29
#include "context.h"
 
30
#include "macros.h"
 
31
#include "mem.h"
 
32
#include "mmath.h"
 
33
#include "mtypes.h"
 
34
#include "math/m_eval.h"
 
35
 
 
36
#include "t_eval_api.h"
 
37
#include "t_imm_api.h"
 
38
#include "t_imm_alloc.h"
 
39
#include "t_imm_exec.h"
 
40
 
 
41
 
 
42
 
 
43
 
 
44
 
 
45
/* KW: If are compiling, we don't know whether eval will produce a
 
46
 *     vertex when it is run in the future.  If this is pure immediate
 
47
 *     mode, eval is a noop if neither vertex map is enabled.
 
48
 *
 
49
 *     Thus we need to have a check in the display list code or
 
50
 *     elsewhere for eval(1,2) vertices in the case where
 
51
 *     map(1,2)_vertex is disabled, and to purge those vertices from
 
52
 *     the vb.
 
53
 */
 
54
void
 
55
_tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
 
56
{
 
57
   GET_CURRENT_CONTEXT(ctx);
 
58
   GLint i;
 
59
   GLfloat u, du;
 
60
   GLenum prim;
 
61
   ASSERT_OUTSIDE_BEGIN_END(ctx);
 
62
 
 
63
/*     fprintf(stderr, "%s\n", __FUNCTION__); */
 
64
 
 
65
   switch (mode) {
 
66
      case GL_POINT:
 
67
         prim = GL_POINTS;
 
68
         break;
 
69
      case GL_LINE:
 
70
         prim = GL_LINE_STRIP;
 
71
         break;
 
72
      default:
 
73
         _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
 
74
         return;
 
75
   }
 
76
 
 
77
   /* No effect if vertex maps disabled.
 
78
    */
 
79
   if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
 
80
      return;
 
81
 
 
82
   du = ctx->Eval.MapGrid1du;
 
83
   u = ctx->Eval.MapGrid1u1 + i1 * du;
 
84
 
 
85
   /* Need to turn off compilation -- this is already saved, and the
 
86
    * coordinates generated and the test above depend on state that
 
87
    * may change before the list is executed.
 
88
    *
 
89
    * TODO: Anaylse display lists to determine if this state is
 
90
    * constant.
 
91
    *
 
92
    * State to watch:
 
93
    *       - enabled maps
 
94
    *       - map state for each enabled map, including control points
 
95
    *       - grid state
 
96
    *
 
97
    * Could alternatively cache individual maps in arrays, rather than
 
98
    * building immediates.  
 
99
    */
 
100
   {
 
101
      GLboolean compiling = ctx->CompileFlag;
 
102
      TNLcontext *tnl = TNL_CONTEXT(ctx);
 
103
      struct immediate *im = TNL_CURRENT_IM(ctx);
 
104
      GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
 
105
 
 
106
      NotifyBegin = tnl->Driver.NotifyBegin;
 
107
      tnl->Driver.NotifyBegin = 0;
 
108
 
 
109
      if (compiling) {
 
110
         struct immediate *IM = _tnl_alloc_immediate( ctx );
 
111
         FLUSH_VERTICES( ctx, 0 );
 
112
         SET_IMMEDIATE( ctx, IM );
 
113
         IM->ref_count++;        
 
114
         ctx->CompileFlag = GL_FALSE;
 
115
      }
 
116
 
 
117
      _tnl_Begin( prim );
 
118
      for (i=i1;i<=i2;i++,u+=du) {
 
119
         _tnl_eval_coord1f( ctx, u );
 
120
      }
 
121
      _tnl_end(ctx);
 
122
 
 
123
      /* Need this for replay *and* compile:
 
124
       */
 
125
      FLUSH_VERTICES( ctx, 0 );
 
126
      tnl->Driver.NotifyBegin = NotifyBegin;
 
127
 
 
128
      if (compiling) {
 
129
         TNL_CURRENT_IM(ctx)->ref_count--;
 
130
         ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 );
 
131
         _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) );
 
132
         SET_IMMEDIATE( ctx, im );
 
133
         ctx->CompileFlag = GL_TRUE;
 
134
      }
 
135
   }
 
136
}
 
137
 
 
138
 
 
139
 
 
140
void
 
141
_tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
 
142
{
 
143
   GET_CURRENT_CONTEXT(ctx);
 
144
   GLint i, j;
 
145
   GLfloat u, du, v, dv, v1, u1;
 
146
   ASSERT_OUTSIDE_BEGIN_END(ctx);
 
147
 
 
148
/*     fprintf(stderr, "%s\n", __FUNCTION__); */
 
149
 
 
150
   /* No effect if vertex maps disabled.
 
151
    */
 
152
   if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
 
153
      return;
 
154
 
 
155
 
 
156
   du = ctx->Eval.MapGrid2du;
 
157
   dv = ctx->Eval.MapGrid2dv;
 
158
   v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
 
159
   u1 = ctx->Eval.MapGrid2u1 + i1 * du;
 
160
 
 
161
   /* Need to turn off compilation -- this is already saved, and the
 
162
    * coordinates generated and the test above depend on state that
 
163
    * may change before the list is executed.
 
164
    */
 
165
   {
 
166
      GLboolean compiling = ctx->CompileFlag;
 
167
      struct immediate *im = TNL_CURRENT_IM(ctx);
 
168
      TNLcontext *tnl = TNL_CONTEXT(ctx);
 
169
      GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
 
170
 
 
171
      NotifyBegin = tnl->Driver.NotifyBegin;
 
172
      tnl->Driver.NotifyBegin = 0;
 
173
 
 
174
      if (compiling) {
 
175
         struct immediate *IM =  _tnl_alloc_immediate( ctx );
 
176
         FLUSH_VERTICES( ctx, 0 );
 
177
         SET_IMMEDIATE( ctx, IM );
 
178
         IM->ref_count++;        
 
179
         ctx->CompileFlag = GL_FALSE;
 
180
      }
 
181
 
 
182
      switch (mode) {
 
183
      case GL_POINT:
 
184
         _tnl_Begin( GL_POINTS );
 
185
         for (v=v1,j=j1;j<=j2;j++,v+=dv) {
 
186
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
 
187
               _tnl_eval_coord2f( ctx, u, v );
 
188
            }
 
189
         }
 
190
         _tnl_end(ctx);
 
191
         break;
 
192
      case GL_LINE:
 
193
         for (v=v1,j=j1;j<=j2;j++,v+=dv) {
 
194
            _tnl_Begin( GL_LINE_STRIP );
 
195
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
 
196
               _tnl_eval_coord2f( ctx, u, v );
 
197
            }
 
198
            _tnl_end(ctx);
 
199
         }
 
200
         for (u=u1,i=i1;i<=i2;i++,u+=du) {
 
201
            _tnl_Begin( GL_LINE_STRIP );
 
202
            for (v=v1,j=j1;j<=j2;j++,v+=dv) {
 
203
               _tnl_eval_coord2f( ctx, u, v );
 
204
            }
 
205
            _tnl_end(ctx);
 
206
         }
 
207
         break;
 
208
      case GL_FILL:
 
209
         for (v=v1,j=j1;j<j2;j++,v+=dv) {
 
210
            _tnl_Begin( GL_TRIANGLE_STRIP );
 
211
            for (u=u1,i=i1;i<=i2;i++,u+=du) {
 
212
               _tnl_eval_coord2f( ctx, u, v );
 
213
               _tnl_eval_coord2f( ctx, u, v+dv );
 
214
            }
 
215
            _tnl_end(ctx);
 
216
         }
 
217
         break;
 
218
      default:
 
219
         _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
 
220
         return;
 
221
      }
 
222
 
 
223
      /* Need this for replay *and* compile:
 
224
       */
 
225
      FLUSH_VERTICES( ctx, 0 );
 
226
      tnl->Driver.NotifyBegin = NotifyBegin;
 
227
         
 
228
      if (compiling) {
 
229
         TNL_CURRENT_IM(ctx)->ref_count--;
 
230
         _tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) );
 
231
         SET_IMMEDIATE( ctx, im );
 
232
         ctx->CompileFlag = GL_TRUE;
 
233
      }
 
234
   }
 
235
}
 
236
 
 
237
 
 
238
 
 
239
void _tnl_eval_init( GLcontext *ctx )
 
240
{
 
241
   GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt);
 
242
   vfmt->EvalMesh1 = _tnl_exec_EvalMesh1;
 
243
   vfmt->EvalMesh2 = _tnl_exec_EvalMesh2;
 
244
}