1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packer.h"
#include "cr_error.h"
void PACK_APIENTRY crPackChromiumParametervCR(CR_PACKER_CONTEXT_ARGDECL GLenum target, GLenum type, GLsizei count, const GLvoid *values)
{
CR_GET_PACKER_CONTEXT(pc);
unsigned int header_length = 2 * sizeof(int) + sizeof(target) + sizeof(type) + sizeof(count);
unsigned int packet_length;
unsigned int params_length = 0;
unsigned char *data_ptr;
int i, pos;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
params_length = sizeof(GLbyte) * count;
break;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
params_length = sizeof(GLshort) * count;
break;
case GL_INT:
case GL_UNSIGNED_INT:
params_length = sizeof(GLint) * count;
break;
#ifndef IN_RING0
case GL_FLOAT:
params_length = sizeof(GLfloat) * count;
break;
#endif
#if 0
case GL_DOUBLE:
params_length = sizeof(GLdouble) * count;
break;
#endif
default:
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackChromiumParametervCR(bad type)" );
return;
}
packet_length = header_length + params_length;
CR_GET_BUFFERED_POINTER(pc, packet_length );
WRITE_DATA( 0, GLint, packet_length );
WRITE_DATA( 4, GLenum, CR_CHROMIUMPARAMETERVCR_EXTEND_OPCODE );
WRITE_DATA( 8, GLenum, target );
WRITE_DATA( 12, GLenum, type );
WRITE_DATA( 16, GLsizei, count );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
pos = header_length;
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
for (i = 0; i < count; i++, pos += sizeof(GLbyte)) {
WRITE_DATA( pos, GLbyte, ((GLbyte *) values)[i]);
}
break;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
for (i = 0; i < count; i++, pos += sizeof(GLshort)) {
WRITE_DATA( pos, GLshort, ((GLshort *) values)[i]);
}
break;
case GL_INT:
case GL_UNSIGNED_INT:
for (i = 0; i < count; i++, pos += sizeof(GLint)) {
WRITE_DATA( pos, GLint, ((GLint *) values)[i]);
}
break;
#ifndef IN_RING0
case GL_FLOAT:
for (i = 0; i < count; i++, pos += sizeof(GLfloat)) {
WRITE_DATA( pos, GLfloat, ((GLfloat *) values)[i]);
}
break;
#endif
#if 0
case GL_DOUBLE:
for (i = 0; i < count; i++) {
WRITE_foo_DATA( sizeof(int) + 12, GLdouble, ((GLdouble *) values)[i]);
}
break;
#endif
default:
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackChromiumParametervCR(bad type)" );
CR_UNLOCK_PACKER_CONTEXT(pc);
return;
}
CR_UNLOCK_PACKER_CONTEXT(pc);
}
#ifndef IN_RING0
void PACK_APIENTRY crPackDeleteQueriesARB(CR_PACKER_CONTEXT_ARGDECL GLsizei n, const GLuint * ids)
{
unsigned char *data_ptr;
int packet_length = sizeof(GLenum)+sizeof(n)+n*sizeof(*ids);
if (!ids) return;
data_ptr = (unsigned char *) crPackAlloc(packet_length);
WRITE_DATA(0, GLenum, CR_DELETEQUERIESARB_EXTEND_OPCODE);
WRITE_DATA(4, GLsizei, n);
crMemcpy(data_ptr + 8, ids, n*sizeof(*ids));
crHugePacket(CR_EXTEND_OPCODE, data_ptr);
crPackFree(data_ptr);
}
#endif
void PACK_APIENTRY crPackVBoxTexPresent( CR_PACKER_CONTEXT_ARGDECL GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, const GLint * pRects )
{
GLint i, size, cnt;
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
size = 28 + cRects * 4 * sizeof(GLint);
CR_GET_BUFFERED_POINTER( pc, size );
WRITE_DATA( 0, GLint, size );
WRITE_DATA( 4, GLenum, CR_VBOXTEXPRESENT_EXTEND_OPCODE );
WRITE_DATA( 8, GLuint, texture );
WRITE_DATA( 12, GLuint, cfg );
WRITE_DATA( 16, GLint, xPos );
WRITE_DATA( 20, GLint, yPos );
WRITE_DATA( 24, GLint, cRects );
cnt = 28;
for (i=0; i<cRects; ++i)
{
WRITE_DATA(cnt, GLint, (GLint) pRects[4*i+0]);
WRITE_DATA(cnt+4, GLint, (GLint) pRects[4*i+1]);
WRITE_DATA(cnt+8, GLint, (GLint) pRects[4*i+2]);
WRITE_DATA(cnt+12, GLint, (GLint) pRects[4*i+3]);
cnt += 16;
}
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackWindowPosition( CR_PACKER_CONTEXT_ARGDECL GLint window, GLint x, GLint y )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
CR_GET_BUFFERED_POINTER( pc, 20 );
WRITE_DATA( 0, GLint, 20 );
WRITE_DATA( 4, GLenum, CR_WINDOWPOSITION_EXTEND_OPCODE );
WRITE_DATA( 8, GLint, window );
WRITE_DATA( 12, GLint, x );
WRITE_DATA( 16, GLint, y );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackWindowShow( CR_PACKER_CONTEXT_ARGDECL GLint window, GLint flag )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
CR_GET_BUFFERED_POINTER( pc, 16 );
WRITE_DATA( 0, GLint, 16 );
WRITE_DATA( 4, GLenum, CR_WINDOWSHOW_EXTEND_OPCODE );
WRITE_DATA( 8, GLint, window );
WRITE_DATA( 12, GLint, flag );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackWindowSize( CR_PACKER_CONTEXT_ARGDECL GLint window, GLint w, GLint h )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
CR_GET_BUFFERED_POINTER( pc, 20 );
WRITE_DATA( 0, GLint, 20 );
WRITE_DATA( 4, GLenum, CR_WINDOWSIZE_EXTEND_OPCODE );
WRITE_DATA( 8, GLint, window );
WRITE_DATA( 12, GLint, w );
WRITE_DATA( 16, GLint, h );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackBeginQueryARB( CR_PACKER_CONTEXT_ARGDECL GLenum target, GLuint id )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
CR_GET_BUFFERED_POINTER( pc, 16 );
WRITE_DATA( 0, GLint, 16 );
WRITE_DATA( 4, GLenum, CR_BEGINQUERYARB_EXTEND_OPCODE );
WRITE_DATA( 8, GLenum, target );
WRITE_DATA( 12, GLuint, id );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackEndQueryARB( CR_PACKER_CONTEXT_ARGDECL GLenum target )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
CR_GET_BUFFERED_POINTER( pc, 12 );
WRITE_DATA( 0, GLint, 12 );
WRITE_DATA( 4, GLenum, CR_ENDQUERYARB_EXTEND_OPCODE );
WRITE_DATA( 8, GLenum, target );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
|