VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_misc.c@ 70939

Last change on this file since 70939 was 69392, checked in by vboxsync, 7 years ago

GuestHost/OpenGL: scm updates

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette