VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.cpp@ 78975

Last change on this file since 78975 was 78794, checked in by vboxsync, 6 years ago

HostServices/SharedOpenGL/crserverlib/server_getpixelmap.cpp: Error checking

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.6 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 "cr_spu.h"
8#include "chromium.h"
9#include "cr_error.h"
10#include "cr_mem.h"
11#include "cr_net.h"
12#include "server_dispatch.h"
13#include "server.h"
14
15static GLint __sizeQuery( GLenum map )
16{
17 GLint get_values = 0;
18 /* Windows compiler gets mad if variables might be uninitialized */
19 GLenum newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
20
21 switch( map )
22 {
23 case GL_PIXEL_MAP_I_TO_I:
24 newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
25 break;
26 case GL_PIXEL_MAP_S_TO_S:
27 newmap = GL_PIXEL_MAP_S_TO_S_SIZE;
28 break;
29 case GL_PIXEL_MAP_I_TO_R:
30 newmap = GL_PIXEL_MAP_I_TO_R_SIZE;
31 break;
32 case GL_PIXEL_MAP_I_TO_G:
33 newmap = GL_PIXEL_MAP_I_TO_G_SIZE;
34 break;
35 case GL_PIXEL_MAP_I_TO_B:
36 newmap = GL_PIXEL_MAP_I_TO_B_SIZE;
37 break;
38 case GL_PIXEL_MAP_I_TO_A:
39 newmap = GL_PIXEL_MAP_I_TO_A_SIZE;
40 break;
41 case GL_PIXEL_MAP_R_TO_R:
42 newmap = GL_PIXEL_MAP_R_TO_R_SIZE;
43 break;
44 case GL_PIXEL_MAP_G_TO_G:
45 newmap = GL_PIXEL_MAP_G_TO_G_SIZE;
46 break;
47 case GL_PIXEL_MAP_B_TO_B:
48 newmap = GL_PIXEL_MAP_B_TO_B_SIZE;
49 break;
50 case GL_PIXEL_MAP_A_TO_A:
51 newmap = GL_PIXEL_MAP_A_TO_A_SIZE;
52 break;
53 default:
54 crError( "Bad map in crServerDispatchGetPixelMap: %d", map );
55 break;
56 }
57
58 cr_server.head_spu->dispatch_table.GetIntegerv( newmap, &get_values );
59
60 return get_values;
61}
62
63void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapfv( GLenum map, GLfloat *values )
64{
65#ifdef CR_ARB_pixel_buffer_object
66 if (crStateIsBufferBound(&cr_server.StateTracker, GL_PIXEL_PACK_BUFFER_ARB))
67 {
68 GLvoid *pbo_offset;
69
70 pbo_offset = (GLfloat*) ((uintptr_t) *((GLint*)values));
71
72 cr_server.head_spu->dispatch_table.GetPixelMapfv( map, (GLfloat *)pbo_offset );
73 }
74 else
75#endif
76 {
77 int size = sizeof( GLfloat );
78 int tabsize = __sizeQuery( map );
79 GLfloat *local_values;
80
81 size *= tabsize;
82 if (size)
83 {
84 local_values = (GLfloat*)crCalloc( size );
85
86 cr_server.head_spu->dispatch_table.GetPixelMapfv( map, local_values );
87 crServerReturnValue( local_values, size );
88 crFree( local_values );
89 }
90 else
91 {
92 crError("crServerDispatchGetPixelMapfv: __sizeQuery() returned 0");
93 crServerReturnValue(NULL, 0);
94 }
95 }
96}
97
98void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapuiv( GLenum map, GLuint *values )
99{
100#ifdef CR_ARB_pixel_buffer_object
101 if (crStateIsBufferBound(&cr_server.StateTracker, GL_PIXEL_PACK_BUFFER_ARB))
102 {
103 GLvoid *pbo_offset;
104
105 pbo_offset = (GLuint*) ((uintptr_t) *((GLint*)values));
106
107 cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, (GLuint *)pbo_offset );
108 }
109 else
110#endif
111 {
112 int size = sizeof( GLuint );
113 int tabsize = __sizeQuery( map );
114 GLuint *local_values;
115
116 size *= tabsize;
117 if (size)
118 {
119 local_values = (GLuint*)crCalloc( size );
120
121 cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, local_values );
122 crServerReturnValue( local_values, size );
123 crFree( local_values );
124 }
125 else
126 {
127 crError( "crServerDispatchGetPixelMapuiv: __sizeQuery() returned 0");
128 crServerReturnValue(NULL, 0);
129 }
130 }
131}
132
133void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapusv( GLenum map, GLushort *values )
134{
135#ifdef CR_ARB_pixel_buffer_object
136 if (crStateIsBufferBound(&cr_server.StateTracker, GL_PIXEL_PACK_BUFFER_ARB))
137 {
138 GLvoid *pbo_offset;
139
140 pbo_offset = (GLushort*) ((uintptr_t) *((GLint*)values));
141
142 cr_server.head_spu->dispatch_table.GetPixelMapusv( map, (GLushort *)pbo_offset );
143 }
144 else
145#endif
146 {
147 int size = sizeof( GLushort );
148 int tabsize = __sizeQuery( map );
149 GLushort *local_values;
150
151 size *= tabsize;
152 if (size)
153 {
154 local_values = (GLushort*)crCalloc( size );
155
156 cr_server.head_spu->dispatch_table.GetPixelMapusv( map, local_values );
157 crServerReturnValue( local_values, size );
158 crFree( local_values );
159 }
160 else
161 {
162 crError( "crServerDispatchGetPixelMapuiv: __sizeQuery() returned 0");
163 crServerReturnValue(NULL, 0);
164 }
165 }
166}
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