VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_context.c@ 69373

最後變更 在這個檔案從69373是 52451,由 vboxsync 提交於 10 年 前

crOpenGL: command blocks flushing

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 4.3 KB
 
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
19void PACK_APIENTRY
20crPackCreateContext( 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_CMDBLOCK_CHECK_FLUSH(pc);
49 CR_UNLOCK_PACKER_CONTEXT(pc);
50}
51
52void PACK_APIENTRY
53crPackCreateContextSWAP( const char *dpyName, GLint visual, GLint shareCtx,
54 GLint *return_value, int *writeback )
55{
56 char displayName[DISPLAY_NAME_LEN];
57 CR_GET_PACKER_CONTEXT(pc);
58 unsigned char *data_ptr;
59 int len = DISPLAY_NAME_LEN + 32;
60
61 /* clear the buffer, to silence valgrind */
62 crMemZero(displayName, DISPLAY_NAME_LEN);
63
64 if (dpyName) {
65 crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
66 displayName[DISPLAY_NAME_LEN - 1] = 0;
67 }
68 else {
69 displayName[0] = 0;
70 }
71
72 CR_GET_BUFFERED_POINTER(pc, len);
73 WRITE_DATA( 0, GLint, SWAP32(len) );
74 WRITE_DATA( 4, GLenum, SWAP32(CR_CREATECONTEXT_EXTEND_OPCODE) );
75 WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
76 WRITE_DATA( DISPLAY_NAME_LEN + 8, GLenum, SWAP32(visual) );
77 WRITE_DATA( DISPLAY_NAME_LEN + 12, GLenum, SWAP32(shareCtx) );
78 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
79 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
80 WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
81 CR_CMDBLOCK_CHECK_FLUSH(pc);
82 CR_UNLOCK_PACKER_CONTEXT(pc);
83}
84
85
86void PACK_APIENTRY crPackWindowCreate( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
87{
88 char displayName[DISPLAY_NAME_LEN];
89 CR_GET_PACKER_CONTEXT(pc);
90 unsigned char *data_ptr;
91
92 /* clear the buffer, to silence valgrind */
93 crMemZero(displayName, DISPLAY_NAME_LEN);
94
95 if (dpyName) {
96 crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
97 displayName[DISPLAY_NAME_LEN - 1] = 0;
98 }
99 else {
100 displayName[0] = 0;
101 }
102
103 CR_GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
104 WRITE_DATA( 0, GLint, 28 );
105 WRITE_DATA( 4, GLenum, CR_WINDOWCREATE_EXTEND_OPCODE );
106 WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
107 WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, visBits );
108 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
109 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
110 WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
111 CR_CMDBLOCK_CHECK_FLUSH(pc);
112 CR_UNLOCK_PACKER_CONTEXT(pc);
113}
114
115void PACK_APIENTRY crPackWindowCreateSWAP( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
116{
117 char displayName[DISPLAY_NAME_LEN];
118 CR_GET_PACKER_CONTEXT(pc);
119 unsigned char *data_ptr;
120
121 /* clear the buffer, to silence valgrind */
122 crMemZero(displayName, DISPLAY_NAME_LEN);
123
124 if (dpyName) {
125 crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
126 displayName[DISPLAY_NAME_LEN - 1] = 0;
127 }
128 else {
129 displayName[0] = 0;
130 }
131
132 CR_GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
133 WRITE_DATA( 0, GLint, SWAP32(28) );
134 WRITE_DATA( 4, GLenum, SWAP32(CR_WINDOWCREATE_EXTEND_OPCODE) );
135 WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
136 WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, SWAP32(visBits) );
137 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
138 WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
139 WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
140 CR_CMDBLOCK_CHECK_FLUSH(pc);
141 CR_UNLOCK_PACKER_CONTEXT(pc);
142}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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