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_opcodes.h"
|
---|
9 | #include "cr_mem.h"
|
---|
10 | #include "cr_string.h"
|
---|
11 |
|
---|
12 |
|
---|
13 | /* XXX duplicated in unpack_context.c */
|
---|
14 | #define DISPLAY_NAME_LEN 256
|
---|
15 |
|
---|
16 | #define WRITE_BYTES( offset, data, len ) \
|
---|
17 | crMemcpy( data_ptr + (offset), data, len )
|
---|
18 |
|
---|
19 | void PACK_APIENTRY
|
---|
20 | crPackCreateContext( const char *dpyName, GLint visual, GLint shareCtx,
|
---|
21 | GLint *return_value, int *writeback )
|
---|
22 | {
|
---|
23 | char displayName[DISPLAY_NAME_LEN];
|
---|
24 | CR_GET_PACKER_CONTEXT(pc);
|
---|
25 | unsigned char *data_ptr;
|
---|
26 | int len = DISPLAY_NAME_LEN + 32;
|
---|
27 |
|
---|
28 | /* clear the buffer, to silence valgrind */
|
---|
29 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
30 |
|
---|
31 | if (dpyName) {
|
---|
32 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
33 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
34 | }
|
---|
35 | else {
|
---|
36 | displayName[0] = 0;
|
---|
37 | }
|
---|
38 |
|
---|
39 | CR_GET_BUFFERED_POINTER(pc, len);
|
---|
40 | WRITE_DATA( 0, GLint, len );
|
---|
41 | WRITE_DATA( 4, GLenum, CR_CREATECONTEXT_EXTEND_OPCODE );
|
---|
42 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
43 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, visual );
|
---|
44 | WRITE_DATA( DISPLAY_NAME_LEN + 12, GLint, shareCtx );
|
---|
45 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
|
---|
46 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
|
---|
47 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
48 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
49 | }
|
---|
50 |
|
---|
51 | void PACK_APIENTRY
|
---|
52 | crPackCreateContextSWAP( const char *dpyName, GLint visual, GLint shareCtx,
|
---|
53 | GLint *return_value, int *writeback )
|
---|
54 | {
|
---|
55 | char displayName[DISPLAY_NAME_LEN];
|
---|
56 | CR_GET_PACKER_CONTEXT(pc);
|
---|
57 | unsigned char *data_ptr;
|
---|
58 | int len = DISPLAY_NAME_LEN + 32;
|
---|
59 |
|
---|
60 | /* clear the buffer, to silence valgrind */
|
---|
61 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
62 |
|
---|
63 | if (dpyName) {
|
---|
64 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
65 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
66 | }
|
---|
67 | else {
|
---|
68 | displayName[0] = 0;
|
---|
69 | }
|
---|
70 |
|
---|
71 | CR_GET_BUFFERED_POINTER(pc, len);
|
---|
72 | WRITE_DATA( 0, GLint, SWAP32(len) );
|
---|
73 | WRITE_DATA( 4, GLenum, SWAP32(CR_CREATECONTEXT_EXTEND_OPCODE) );
|
---|
74 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
75 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLenum, SWAP32(visual) );
|
---|
76 | WRITE_DATA( DISPLAY_NAME_LEN + 12, GLenum, SWAP32(shareCtx) );
|
---|
77 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
|
---|
78 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
|
---|
79 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
80 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | void PACK_APIENTRY crPackWindowCreate( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
|
---|
85 | {
|
---|
86 | char displayName[DISPLAY_NAME_LEN];
|
---|
87 | CR_GET_PACKER_CONTEXT(pc);
|
---|
88 | unsigned char *data_ptr;
|
---|
89 |
|
---|
90 | /* clear the buffer, to silence valgrind */
|
---|
91 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
92 |
|
---|
93 | if (dpyName) {
|
---|
94 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
95 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
96 | }
|
---|
97 | else {
|
---|
98 | displayName[0] = 0;
|
---|
99 | }
|
---|
100 |
|
---|
101 | CR_GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
|
---|
102 | WRITE_DATA( 0, GLint, 28 );
|
---|
103 | WRITE_DATA( 4, GLenum, CR_WINDOWCREATE_EXTEND_OPCODE );
|
---|
104 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
105 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, visBits );
|
---|
106 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
|
---|
107 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
|
---|
108 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
109 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
110 | }
|
---|
111 |
|
---|
112 | void PACK_APIENTRY crPackWindowCreateSWAP( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
|
---|
113 | {
|
---|
114 | char displayName[DISPLAY_NAME_LEN];
|
---|
115 | CR_GET_PACKER_CONTEXT(pc);
|
---|
116 | unsigned char *data_ptr;
|
---|
117 |
|
---|
118 | /* clear the buffer, to silence valgrind */
|
---|
119 | crMemZero(displayName, DISPLAY_NAME_LEN);
|
---|
120 |
|
---|
121 | if (dpyName) {
|
---|
122 | crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
|
---|
123 | displayName[DISPLAY_NAME_LEN - 1] = 0;
|
---|
124 | }
|
---|
125 | else {
|
---|
126 | displayName[0] = 0;
|
---|
127 | }
|
---|
128 |
|
---|
129 | CR_GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
|
---|
130 | WRITE_DATA( 0, GLint, SWAP32(28) );
|
---|
131 | WRITE_DATA( 4, GLenum, SWAP32(CR_WINDOWCREATE_EXTEND_OPCODE) );
|
---|
132 | WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
|
---|
133 | WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, SWAP32(visBits) );
|
---|
134 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
|
---|
135 | WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
|
---|
136 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
137 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
138 | }
|
---|