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

« back to all changes in this revision

Viewing changes to unix/xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h

  • 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
Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
 
4
All Rights Reserved.
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining a
 
7
copy of this software and associated documentation files (the
 
8
"Software"), to deal in the Software without restriction, including
 
9
without limitation the rights to use, copy, modify, merge, publish,
 
10
distribute, sub license, and/or sell copies of the Software, and to
 
11
permit persons to whom the Software is furnished to do so, subject to
 
12
the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice (including the
 
15
next paragraph) shall be included in all copies or substantial portions
 
16
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
 
20
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
21
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 
22
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
23
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
24
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
25
 
 
26
**************************************************************************/
 
27
/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
 
28
 
 
29
/*
 
30
 * Authors:
 
31
 *    Sung-Ching Lin <sclin@sis.com.tw>
 
32
 *
 
33
 */
 
34
 
 
35
#define SIS_TRI_FUNC 0
 
36
 
 
37
#define SIS_MMIO_WRITE_VERTEX(v, i) \
 
38
  if(SIS_STEREO && hwcx->stereoEnabled) \
 
39
  { \
 
40
    MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \
 
41
    MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
 
42
  } \
 
43
  else \
 
44
  { \
 
45
    MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = VB->Win.data[v][0] - 0.5 ; \
 
46
    MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
 
47
  } \
 
48
\
 
49
  if (ctx->TriangleCaps & DD_TRI_OFFSET) \
 
50
    { \
 
51
      if(SIS_TRI_FUNC){ \
 
52
        MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
 
53
        (VB->Win.data[v][2] + ctx->PolygonZoffset) / SIS_DEPTH_SCALE; \
 
54
      } \
 
55
      else{ \
 
56
        MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
 
57
        (VB->Win.data[v][2] + ctx->LineZoffset) / SIS_DEPTH_SCALE; \
 
58
      } \
 
59
    } \
 
60
  else \
 
61
    { \
 
62
      MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = VB->Win.data[v][2] / SIS_DEPTH_SCALE; \
 
63
    } \
 
64
\
 
65
  if (SIS_STATES & SIS_TEXTURE0) \
 
66
    { \
 
67
      if(VB->TexCoordPtr[0]->size == 4){ \
 
68
        MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][0] / \
 
69
                                   VB->TexCoordPtr[0]->data[v][3]; \
 
70
        MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][1] / \
 
71
                                   VB->TexCoordPtr[0]->data[v][3]; \
 
72
      } \
 
73
      else{ \
 
74
        MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][0]; \
 
75
        MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = VB->TexCoordPtr[0]->data[v][1]; \
 
76
      } \
 
77
    } \
 
78
\
 
79
  if (SIS_STATES & SIS_TEXTURE1) \
 
80
    { \
 
81
      if(VB->TexCoordPtr[1]->size == 4){ \
 
82
        MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][0] / \
 
83
                                   VB->TexCoordPtr[1]->data[v][3]; \
 
84
        MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][1] / \
 
85
                                   VB->TexCoordPtr[1]->data[v][3]; \
 
86
      } \
 
87
      else{ \
 
88
        MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][0]; \
 
89
        MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = VB->TexCoordPtr[1]->data[v][1]; \
 
90
      } \
 
91
    } \
 
92
\
 
93
  if (SIS_STATES & (SIS_USE_W)) \
 
94
    { \
 
95
      if(VB->TexCoordPtr[0]->size == 4){ \
 
96
        MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = VB->Win.data[v][3] * \
 
97
                                     VB->TexCoordPtr[0]->data[v][3]; \
 
98
      } \
 
99
      else{ \
 
100
        MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = VB->Win.data[v][3]; \
 
101
      } \
 
102
    } \
 
103
\
 
104
  if (SIS_STATES & (SIS_SMOOTH)) \
 
105
    { \
 
106
      DWORD dcSARGB; \
 
107
\
 
108
      RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \
 
109
\
 
110
      ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \
 
111
    } \
 
112
  else if(LAST_VERTEX) \
 
113
    { \
 
114
      DWORD dcSARGB; \
 
115
\
 
116
      RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \
 
117
\
 
118
      ((DWORD *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = dcSARGB; \
 
119
    } \
 
120
 
 
121
static void
 
122
SIS_TAG (sis_line) (GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pv)
 
123
{
 
124
  XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
 
125
  __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
 
126
 
 
127
  struct vertex_buffer *VB = ctx->VB;
 
128
  float *MMIOBase = (float *) GET_IOBase (hwcx);
 
129
 
 
130
  STEREO_SAMPLE(vert0);
 
131
 
 
132
  mWait3DCmdQueue (10 * 2 + 1);
 
133
 
 
134
  if (SIS_STATES & (SIS_SMOOTH))
 
135
    {
 
136
      hwcx->dwPrimitiveSet &= ~0x07001f07;
 
137
      hwcx->dwPrimitiveSet |= 
 
138
        (OP_3D_FIRE_TSARGBb | SHADE_GOURAUD | OP_3D_LINE_DRAW);
 
139
 
 
140
      ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet;
 
141
    }
 
142
  else
 
143
    {
 
144
      hwcx->dwPrimitiveSet &= ~0x07001f07;
 
145
      hwcx->dwPrimitiveSet |= 
 
146
        (OP_3D_FIRE_TSARGBb | SHADE_FLAT_VertexB | OP_3D_LINE_DRAW);
 
147
 
 
148
      ((DWORD *) MMIOBase)[REG_3D_PrimitiveSet / 4] = hwcx->dwPrimitiveSet;
 
149
    }
 
150
 
 
151
#define LAST_VERTEX 0
 
152
  SIS_MMIO_WRITE_VERTEX (vert0, 0);
 
153
#undef LAST_VERTEX
 
154
#define LAST_VERTEX 1
 
155
  SIS_MMIO_WRITE_VERTEX (vert1, 1);
 
156
#undef LAST_VERTEX
 
157
 
 
158
  /* debug
 
159
  mEndPrimitive ();
 
160
  WaitEngIdle(hwcx);  
 
161
  d2f_once (ctx);
 
162
  */
 
163
}
 
164
 
 
165
#define SIS_AGP_WRITE_VERTEX(v) \
 
166
do{ \
 
167
if(SIS_STEREO && hwcx->stereoEnabled) \
 
168
{ \
 
169
  AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5 + STEREO_OFFSET(v); \
 
170
} \
 
171
else \
 
172
{ \
 
173
  AGP_CurrentPtr[0] = VB->Win.data[v][0] - 0.5; \
 
174
} \
 
175
AGP_CurrentPtr[1] = Y_FLIP (VB->Win.data[v][1]) + 0.5; \
 
176
\
 
177
if (ctx->TriangleCaps & DD_TRI_OFFSET){ \
 
178
  if(SIS_TRI_FUNC){ \
 
179
    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->PolygonZoffset) / SIS_DEPTH_SCALE; \
 
180
  } \
 
181
  else{ \
 
182
    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->LineZoffset) / SIS_DEPTH_SCALE; \
 
183
  } \
 
184
} \
 
185
else{ \
 
186
  AGP_CurrentPtr[2] = VB->Win.data[v][2] / SIS_DEPTH_SCALE; \
 
187
}\
 
188
AGP_CurrentPtr+=3; \
 
189
if (SIS_STATES & (SIS_USE_W)) \
 
190
{ \
 
191
   if(VB->TexCoordPtr[0]->size == 4){ \
 
192
     AGP_CurrentPtr[0] = VB->Win.data[v][3] * \
 
193
                         VB->TexCoordPtr[0]->data[v][3]; \
 
194
   } \
 
195
   else{ \
 
196
     AGP_CurrentPtr[0] = VB->Win.data[v][3]; \
 
197
   } \
 
198
   AGP_CurrentPtr+=1; \
 
199
} \
 
200
\
 
201
if (SIS_STATES & (SIS_SMOOTH)) \
 
202
{ \
 
203
  RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[v]); \
 
204
  ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
 
205
} \
 
206
else if(FIRST_VERTEX) \
 
207
{ \
 
208
  RGBA8ConvertToBGRA8 (&dcSARGB, VB->ColorPtr->data[pv]); \
 
209
  ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
 
210
} \
 
211
else \
 
212
{ \
 
213
  ((DWORD *)AGP_CurrentPtr)[0] = dcSARGB; \
 
214
} \
 
215
AGP_CurrentPtr+=1; \
 
216
\
 
217
if (SIS_STATES & SIS_TEXTURE0) \
 
218
{ \
 
219
  if(VB->TexCoordPtr[0]->size == 4){ \
 
220
    AGP_CurrentPtr[0] = VB->TexCoordPtr[0]->data[v][0] / \
 
221
                        VB->TexCoordPtr[0]->data[v][3]; \
 
222
    AGP_CurrentPtr[1] = VB->TexCoordPtr[0]->data[v][1] / \
 
223
                        VB->TexCoordPtr[0]->data[v][3]; \
 
224
  } \
 
225
  else{ \
 
226
    AGP_CurrentPtr[0] = VB->TexCoordPtr[0]->data[v][0]; \
 
227
    AGP_CurrentPtr[1] = VB->TexCoordPtr[0]->data[v][1]; \
 
228
  } \
 
229
  AGP_CurrentPtr+=2; \
 
230
} \
 
231
\
 
232
if (SIS_STATES & SIS_TEXTURE1) \
 
233
{ \
 
234
  if(VB->TexCoordPtr[1]->size == 4){ \
 
235
    AGP_CurrentPtr[0] = VB->TexCoordPtr[1]->data[v][0] / \
 
236
                        VB->TexCoordPtr[1]->data[v][3]; \
 
237
    AGP_CurrentPtr[1] = VB->TexCoordPtr[1]->data[v][1] / \
 
238
                        VB->TexCoordPtr[1]->data[v][3]; \
 
239
  } \
 
240
  else{ \
 
241
    AGP_CurrentPtr[0] = VB->TexCoordPtr[1]->data[v][0]; \
 
242
    AGP_CurrentPtr[1] = VB->TexCoordPtr[1]->data[v][1]; \
 
243
  } \
 
244
  AGP_CurrentPtr+=2; \
 
245
} \
 
246
}while(0)
 
247
 
 
248
static void
 
249
SIS_TAG (sis_agp_line) (GLcontext * ctx, GLuint vert0, GLuint vert1,
 
250
                        GLuint pv)
 
251
{
 
252
  XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
 
253
  __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
 
254
 
 
255
  struct vertex_buffer *VB = ctx->VB;
 
256
 
 
257
  DWORD dcSARGB;
 
258
 
 
259
  STEREO_SAMPLE(vert0);
 
260
 
 
261
#if 0
 
262
  if ((DWORD) AGP_CurrentPtr - (DWORD) AGP_StartPtr >= (AGP_ALLOC_SIZE - 0x10))
 
263
    {
 
264
      sis_FlushAGP (ctx);
 
265
      sis_StartAGP (ctx);
 
266
    }
 
267
#endif
 
268
 
 
269
#define FIRST_VERTEX 1
 
270
  SIS_AGP_WRITE_VERTEX (vert0);
 
271
#undef FIRST_VERTEX
 
272
#define FIRST_VERTEX 0
 
273
  SIS_AGP_WRITE_VERTEX (vert1);
 
274
#undef FIRST_VERTEX
 
275
}
 
276
 
 
277
#undef SIS_TRI_FUNC