Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_autogen.h

Issue 505016: Implements Validation for all GLenum arguments and ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This file is auto-generated. DO NOT EDIT! 1 // This file is auto-generated. DO NOT EDIT!
2 2
3 // It is included by gles2_cmd_decoder.cc 3 // It is included by gles2_cmd_decoder.cc
4 4
5 parse_error::ParseError GLES2DecoderImpl::HandleActiveTexture( 5 parse_error::ParseError GLES2DecoderImpl::HandleActiveTexture(
6 uint32 immediate_data_size, const gles2::ActiveTexture& c) { 6 uint32 immediate_data_size, const gles2::ActiveTexture& c) {
7 GLenum texture = static_cast<GLenum>(c.texture); 7 GLenum texture = static_cast<GLenum>(c.texture);
8 parse_error::ParseError result =
9 ValidateActiveTexture(this, immediate_data_size, texture);
10 if (result != parse_error::kParseNoError) {
11 return result;
12 }
13 glActiveTexture(texture); 8 glActiveTexture(texture);
14 return parse_error::kParseNoError; 9 return parse_error::kParseNoError;
15 } 10 }
16 11
17 parse_error::ParseError GLES2DecoderImpl::HandleAttachShader( 12 parse_error::ParseError GLES2DecoderImpl::HandleAttachShader(
18 uint32 immediate_data_size, const gles2::AttachShader& c) { 13 uint32 immediate_data_size, const gles2::AttachShader& c) {
19 GLuint program; 14 GLuint program;
20 if (!id_map_.GetServiceId(c.program, &program)) { 15 if (!id_map_.GetServiceId(c.program, &program)) {
21 SetGLError(GL_INVALID_VALUE); 16 SetGLError(GL_INVALID_VALUE);
22 return parse_error::kParseNoError; 17 return parse_error::kParseNoError;
23 } 18 }
24 GLuint shader; 19 GLuint shader;
25 if (!id_map_.GetServiceId(c.shader, &shader)) { 20 if (!id_map_.GetServiceId(c.shader, &shader)) {
26 SetGLError(GL_INVALID_VALUE); 21 SetGLError(GL_INVALID_VALUE);
27 return parse_error::kParseNoError; 22 return parse_error::kParseNoError;
28 } 23 }
29 parse_error::ParseError result =
30 ValidateAttachShader(this, immediate_data_size, program, shader);
31 if (result != parse_error::kParseNoError) {
32 return result;
33 }
34 glAttachShader(program, shader); 24 glAttachShader(program, shader);
35 return parse_error::kParseNoError; 25 return parse_error::kParseNoError;
36 } 26 }
37 27
38 parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocation( 28 parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocation(
39 uint32 immediate_data_size, const gles2::BindAttribLocation& c) { 29 uint32 immediate_data_size, const gles2::BindAttribLocation& c) {
40 GLuint program; 30 GLuint program;
41 if (!id_map_.GetServiceId(c.program, &program)) { 31 if (!id_map_.GetServiceId(c.program, &program)) {
42 SetGLError(GL_INVALID_VALUE); 32 SetGLError(GL_INVALID_VALUE);
43 return parse_error::kParseNoError; 33 return parse_error::kParseNoError;
44 } 34 }
45 GLuint index = static_cast<GLuint>(c.index); 35 GLuint index = static_cast<GLuint>(c.index);
46 uint32 name_size = c.data_size; 36 uint32 name_size = c.data_size;
47 const char* name = GetSharedMemoryAs<const char*>( 37 const char* name = GetSharedMemoryAs<const char*>(
48 c.name_shm_id, c.name_shm_offset, name_size); 38 c.name_shm_id, c.name_shm_offset, name_size);
49 parse_error::ParseError result = 39 if (name == NULL) {
50 ValidateBindAttribLocation( 40 return parse_error::kParseOutOfBounds;
51 this, immediate_data_size, program, index, name);
52 if (result != parse_error::kParseNoError) {
53 return result;
54 } 41 }
55 String name_str(name, name_size); 42 String name_str(name, name_size);
56 glBindAttribLocation(program, index, name_str.c_str()); 43 glBindAttribLocation(program, index, name_str.c_str());
57 return parse_error::kParseNoError; 44 return parse_error::kParseNoError;
58 } 45 }
59 46
60 parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocationImmediate( 47 parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocationImmediate(
61 uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) { 48 uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) {
62 GLuint program; 49 GLuint program;
63 if (!id_map_.GetServiceId(c.program, &program)) { 50 if (!id_map_.GetServiceId(c.program, &program)) {
64 SetGLError(GL_INVALID_VALUE); 51 SetGLError(GL_INVALID_VALUE);
65 return parse_error::kParseNoError; 52 return parse_error::kParseNoError;
66 } 53 }
67 GLuint index = static_cast<GLuint>(c.index); 54 GLuint index = static_cast<GLuint>(c.index);
68 uint32 name_size = c.data_size; 55 uint32 name_size = c.data_size;
69 const char* name = GetImmediateDataAs<const char*>(c); 56 const char* name = GetImmediateDataAs<const char*>(c);
70 // TODO(gman): Make sure validate checks 57 // TODO(gman): Make sure validate checks
71 // immediate_data_size covers data_size. 58 // immediate_data_size covers data_size.
72 parse_error::ParseError result = 59 if (name == NULL) {
73 ValidateBindAttribLocationImmediate( 60 return parse_error::kParseOutOfBounds;
74 this, immediate_data_size, program, index, name);
75 if (result != parse_error::kParseNoError) {
76 return result;
77 } 61 }
78 String name_str(name, name_size); 62 String name_str(name, name_size);
79 glBindAttribLocation(program, index, name_str.c_str()); 63 glBindAttribLocation(program, index, name_str.c_str());
80 return parse_error::kParseNoError; 64 return parse_error::kParseNoError;
81 } 65 }
82 66
83 parse_error::ParseError GLES2DecoderImpl::HandleBindBuffer( 67 parse_error::ParseError GLES2DecoderImpl::HandleBindBuffer(
84 uint32 immediate_data_size, const gles2::BindBuffer& c) { 68 uint32 immediate_data_size, const gles2::BindBuffer& c) {
85 GLenum target = static_cast<GLenum>(c.target); 69 GLenum target = static_cast<GLenum>(c.target);
86 GLuint buffer; 70 GLuint buffer;
87 if (!id_map_.GetServiceId(c.buffer, &buffer)) { 71 if (!id_map_.GetServiceId(c.buffer, &buffer)) {
88 SetGLError(GL_INVALID_VALUE); 72 SetGLError(GL_INVALID_VALUE);
89 return parse_error::kParseNoError; 73 return parse_error::kParseNoError;
90 } 74 }
91 parse_error::ParseError result = 75 if (!ValidateGLenumBufferTarget(target)) {
92 ValidateBindBuffer(this, immediate_data_size, target, buffer); 76 SetGLError(GL_INVALID_VALUE);
93 if (result != parse_error::kParseNoError) { 77 return parse_error::kParseNoError;
94 return result;
95 } 78 }
96 DoBindBuffer(target, buffer); 79 DoBindBuffer(target, buffer);
97 return parse_error::kParseNoError; 80 return parse_error::kParseNoError;
98 } 81 }
99 82
100 parse_error::ParseError GLES2DecoderImpl::HandleBindFramebuffer( 83 parse_error::ParseError GLES2DecoderImpl::HandleBindFramebuffer(
101 uint32 immediate_data_size, const gles2::BindFramebuffer& c) { 84 uint32 immediate_data_size, const gles2::BindFramebuffer& c) {
102 GLenum target = static_cast<GLenum>(c.target); 85 GLenum target = static_cast<GLenum>(c.target);
103 GLuint framebuffer; 86 GLuint framebuffer;
104 if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) { 87 if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) {
105 SetGLError(GL_INVALID_VALUE); 88 SetGLError(GL_INVALID_VALUE);
106 return parse_error::kParseNoError; 89 return parse_error::kParseNoError;
107 } 90 }
108 parse_error::ParseError result = 91 if (!ValidateGLenumFrameBufferTarget(target)) {
109 ValidateBindFramebuffer(this, immediate_data_size, target, framebuffer); 92 SetGLError(GL_INVALID_VALUE);
110 if (result != parse_error::kParseNoError) { 93 return parse_error::kParseNoError;
111 return result;
112 } 94 }
113 glBindFramebufferEXT(target, framebuffer); 95 glBindFramebufferEXT(target, framebuffer);
114 return parse_error::kParseNoError; 96 return parse_error::kParseNoError;
115 } 97 }
116 98
117 parse_error::ParseError GLES2DecoderImpl::HandleBindRenderbuffer( 99 parse_error::ParseError GLES2DecoderImpl::HandleBindRenderbuffer(
118 uint32 immediate_data_size, const gles2::BindRenderbuffer& c) { 100 uint32 immediate_data_size, const gles2::BindRenderbuffer& c) {
119 GLenum target = static_cast<GLenum>(c.target); 101 GLenum target = static_cast<GLenum>(c.target);
120 GLuint renderbuffer; 102 GLuint renderbuffer;
121 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) { 103 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
122 SetGLError(GL_INVALID_VALUE); 104 SetGLError(GL_INVALID_VALUE);
123 return parse_error::kParseNoError; 105 return parse_error::kParseNoError;
124 } 106 }
125 parse_error::ParseError result = 107 if (!ValidateGLenumRenderBufferTarget(target)) {
126 ValidateBindRenderbuffer( 108 SetGLError(GL_INVALID_VALUE);
127 this, immediate_data_size, target, renderbuffer); 109 return parse_error::kParseNoError;
128 if (result != parse_error::kParseNoError) {
129 return result;
130 } 110 }
131 glBindRenderbufferEXT(target, renderbuffer); 111 glBindRenderbufferEXT(target, renderbuffer);
132 return parse_error::kParseNoError; 112 return parse_error::kParseNoError;
133 } 113 }
134 114
135 parse_error::ParseError GLES2DecoderImpl::HandleBindTexture( 115 parse_error::ParseError GLES2DecoderImpl::HandleBindTexture(
136 uint32 immediate_data_size, const gles2::BindTexture& c) { 116 uint32 immediate_data_size, const gles2::BindTexture& c) {
137 GLenum target = static_cast<GLenum>(c.target); 117 GLenum target = static_cast<GLenum>(c.target);
138 GLuint texture; 118 GLuint texture;
139 if (!id_map_.GetServiceId(c.texture, &texture)) { 119 if (!id_map_.GetServiceId(c.texture, &texture)) {
140 SetGLError(GL_INVALID_VALUE); 120 SetGLError(GL_INVALID_VALUE);
141 return parse_error::kParseNoError; 121 return parse_error::kParseNoError;
142 } 122 }
143 parse_error::ParseError result = 123 if (!ValidateGLenumTextureBindTarget(target)) {
144 ValidateBindTexture(this, immediate_data_size, target, texture); 124 SetGLError(GL_INVALID_VALUE);
145 if (result != parse_error::kParseNoError) { 125 return parse_error::kParseNoError;
146 return result;
147 } 126 }
148 glBindTexture(target, texture); 127 glBindTexture(target, texture);
149 return parse_error::kParseNoError; 128 return parse_error::kParseNoError;
150 } 129 }
151 130
152 parse_error::ParseError GLES2DecoderImpl::HandleBlendColor( 131 parse_error::ParseError GLES2DecoderImpl::HandleBlendColor(
153 uint32 immediate_data_size, const gles2::BlendColor& c) { 132 uint32 immediate_data_size, const gles2::BlendColor& c) {
154 GLclampf red = static_cast<GLclampf>(c.red); 133 GLclampf red = static_cast<GLclampf>(c.red);
155 GLclampf green = static_cast<GLclampf>(c.green); 134 GLclampf green = static_cast<GLclampf>(c.green);
156 GLclampf blue = static_cast<GLclampf>(c.blue); 135 GLclampf blue = static_cast<GLclampf>(c.blue);
157 GLclampf alpha = static_cast<GLclampf>(c.alpha); 136 GLclampf alpha = static_cast<GLclampf>(c.alpha);
158 parse_error::ParseError result =
159 ValidateBlendColor(this, immediate_data_size, red, green, blue, alpha);
160 if (result != parse_error::kParseNoError) {
161 return result;
162 }
163 glBlendColor(red, green, blue, alpha); 137 glBlendColor(red, green, blue, alpha);
164 return parse_error::kParseNoError; 138 return parse_error::kParseNoError;
165 } 139 }
166 140
167 parse_error::ParseError GLES2DecoderImpl::HandleBlendEquation( 141 parse_error::ParseError GLES2DecoderImpl::HandleBlendEquation(
168 uint32 immediate_data_size, const gles2::BlendEquation& c) { 142 uint32 immediate_data_size, const gles2::BlendEquation& c) {
169 GLenum mode = static_cast<GLenum>(c.mode); 143 GLenum mode = static_cast<GLenum>(c.mode);
170 parse_error::ParseError result = 144 if (!ValidateGLenumEquation(mode)) {
171 ValidateBlendEquation(this, immediate_data_size, mode); 145 SetGLError(GL_INVALID_VALUE);
172 if (result != parse_error::kParseNoError) { 146 return parse_error::kParseNoError;
173 return result;
174 } 147 }
175 glBlendEquation(mode); 148 glBlendEquation(mode);
176 return parse_error::kParseNoError; 149 return parse_error::kParseNoError;
177 } 150 }
178 151
179 parse_error::ParseError GLES2DecoderImpl::HandleBlendEquationSeparate( 152 parse_error::ParseError GLES2DecoderImpl::HandleBlendEquationSeparate(
180 uint32 immediate_data_size, const gles2::BlendEquationSeparate& c) { 153 uint32 immediate_data_size, const gles2::BlendEquationSeparate& c) {
181 GLenum modeRGB = static_cast<GLenum>(c.modeRGB); 154 GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
182 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha); 155 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
183 parse_error::ParseError result = 156 if (!ValidateGLenumEquation(modeRGB)) {
184 ValidateBlendEquationSeparate( 157 SetGLError(GL_INVALID_VALUE);
185 this, immediate_data_size, modeRGB, modeAlpha); 158 return parse_error::kParseNoError;
186 if (result != parse_error::kParseNoError) { 159 }
187 return result; 160 if (!ValidateGLenumEquation(modeAlpha)) {
161 SetGLError(GL_INVALID_VALUE);
162 return parse_error::kParseNoError;
188 } 163 }
189 glBlendEquationSeparate(modeRGB, modeAlpha); 164 glBlendEquationSeparate(modeRGB, modeAlpha);
190 return parse_error::kParseNoError; 165 return parse_error::kParseNoError;
191 } 166 }
192 167
193 parse_error::ParseError GLES2DecoderImpl::HandleBlendFunc( 168 parse_error::ParseError GLES2DecoderImpl::HandleBlendFunc(
194 uint32 immediate_data_size, const gles2::BlendFunc& c) { 169 uint32 immediate_data_size, const gles2::BlendFunc& c) {
195 GLenum sfactor = static_cast<GLenum>(c.sfactor); 170 GLenum sfactor = static_cast<GLenum>(c.sfactor);
196 GLenum dfactor = static_cast<GLenum>(c.dfactor); 171 GLenum dfactor = static_cast<GLenum>(c.dfactor);
197 parse_error::ParseError result = 172 if (!ValidateGLenumSrcBlendFactor(sfactor)) {
198 ValidateBlendFunc(this, immediate_data_size, sfactor, dfactor); 173 SetGLError(GL_INVALID_VALUE);
199 if (result != parse_error::kParseNoError) { 174 return parse_error::kParseNoError;
200 return result; 175 }
176 if (!ValidateGLenumDstBlendFactor(dfactor)) {
177 SetGLError(GL_INVALID_VALUE);
178 return parse_error::kParseNoError;
201 } 179 }
202 glBlendFunc(sfactor, dfactor); 180 glBlendFunc(sfactor, dfactor);
203 return parse_error::kParseNoError; 181 return parse_error::kParseNoError;
204 } 182 }
205 183
206 parse_error::ParseError GLES2DecoderImpl::HandleBlendFuncSeparate( 184 parse_error::ParseError GLES2DecoderImpl::HandleBlendFuncSeparate(
207 uint32 immediate_data_size, const gles2::BlendFuncSeparate& c) { 185 uint32 immediate_data_size, const gles2::BlendFuncSeparate& c) {
208 GLenum srcRGB = static_cast<GLenum>(c.srcRGB); 186 GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
209 GLenum dstRGB = static_cast<GLenum>(c.dstRGB); 187 GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
210 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha); 188 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
211 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha); 189 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
212 parse_error::ParseError result = 190 if (!ValidateGLenumSrcBlendFactor(srcRGB)) {
213 ValidateBlendFuncSeparate( 191 SetGLError(GL_INVALID_VALUE);
214 this, immediate_data_size, srcRGB, dstRGB, srcAlpha, dstAlpha); 192 return parse_error::kParseNoError;
215 if (result != parse_error::kParseNoError) { 193 }
216 return result; 194 if (!ValidateGLenumDstBlendFactor(dstRGB)) {
195 SetGLError(GL_INVALID_VALUE);
196 return parse_error::kParseNoError;
197 }
198 if (!ValidateGLenumSrcBlendFactor(srcAlpha)) {
199 SetGLError(GL_INVALID_VALUE);
200 return parse_error::kParseNoError;
201 }
202 if (!ValidateGLenumDstBlendFactor(dstAlpha)) {
203 SetGLError(GL_INVALID_VALUE);
204 return parse_error::kParseNoError;
217 } 205 }
218 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); 206 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
219 return parse_error::kParseNoError; 207 return parse_error::kParseNoError;
220 } 208 }
221 209
222 parse_error::ParseError GLES2DecoderImpl::HandleBufferSubData( 210 parse_error::ParseError GLES2DecoderImpl::HandleBufferSubData(
223 uint32 immediate_data_size, const gles2::BufferSubData& c) { 211 uint32 immediate_data_size, const gles2::BufferSubData& c) {
224 GLenum target = static_cast<GLenum>(c.target); 212 GLenum target = static_cast<GLenum>(c.target);
225 GLintptr offset = static_cast<GLintptr>(c.offset); 213 GLintptr offset = static_cast<GLintptr>(c.offset);
226 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 214 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
227 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 215 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
228 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 216 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
229 uint32 data_size = size; 217 uint32 data_size = size;
230 const void* data = GetSharedMemoryAs<const void*>( 218 const void* data = GetSharedMemoryAs<const void*>(
231 data_shm_id, data_shm_offset, data_size); 219 data_shm_id, data_shm_offset, data_size);
232 parse_error::ParseError result = 220 if (!ValidateGLenumBufferTarget(target)) {
233 ValidateBufferSubData( 221 SetGLError(GL_INVALID_VALUE);
234 this, immediate_data_size, target, offset, size, data); 222 return parse_error::kParseNoError;
235 if (result != parse_error::kParseNoError) { 223 }
236 return result; 224 if (data == NULL) {
225 return parse_error::kParseOutOfBounds;
237 } 226 }
238 glBufferSubData(target, offset, size, data); 227 glBufferSubData(target, offset, size, data);
239 return parse_error::kParseNoError; 228 return parse_error::kParseNoError;
240 } 229 }
241 230
242 parse_error::ParseError GLES2DecoderImpl::HandleBufferSubDataImmediate( 231 parse_error::ParseError GLES2DecoderImpl::HandleBufferSubDataImmediate(
243 uint32 immediate_data_size, const gles2::BufferSubDataImmediate& c) { 232 uint32 immediate_data_size, const gles2::BufferSubDataImmediate& c) {
244 GLenum target = static_cast<GLenum>(c.target); 233 GLenum target = static_cast<GLenum>(c.target);
245 GLintptr offset = static_cast<GLintptr>(c.offset); 234 GLintptr offset = static_cast<GLintptr>(c.offset);
246 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 235 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
247 const void* data = GetImmediateDataAs<const void*>(c); 236 const void* data = GetImmediateDataAs<const void*>(c);
237 if (!ValidateGLenumBufferTarget(target)) {
238 SetGLError(GL_INVALID_VALUE);
239 return parse_error::kParseNoError;
240 }
241 if (data == NULL) {
242 return parse_error::kParseOutOfBounds;
243 }
248 // Immediate version. 244 // Immediate version.
249 parse_error::ParseError result = 245 if (!ValidateGLenumBufferTarget(target)) {
250 ValidateBufferSubDataImmediate( 246 SetGLError(GL_INVALID_VALUE);
251 this, immediate_data_size, target, offset, size, data); 247 return parse_error::kParseNoError;
252 if (result != parse_error::kParseNoError) { 248 }
253 return result; 249 if (data == NULL) {
250 return parse_error::kParseOutOfBounds;
254 } 251 }
255 glBufferSubData(target, offset, size, data); 252 glBufferSubData(target, offset, size, data);
256 return parse_error::kParseNoError; 253 return parse_error::kParseNoError;
257 } 254 }
258 255
259 parse_error::ParseError GLES2DecoderImpl::HandleCheckFramebufferStatus( 256 parse_error::ParseError GLES2DecoderImpl::HandleCheckFramebufferStatus(
260 uint32 immediate_data_size, const gles2::CheckFramebufferStatus& c) { 257 uint32 immediate_data_size, const gles2::CheckFramebufferStatus& c) {
261 GLenum target = static_cast<GLenum>(c.target); 258 GLenum target = static_cast<GLenum>(c.target);
262 parse_error::ParseError result = 259 if (!ValidateGLenumFrameBufferTarget(target)) {
263 ValidateCheckFramebufferStatus(this, immediate_data_size, target); 260 SetGLError(GL_INVALID_VALUE);
264 if (result != parse_error::kParseNoError) { 261 return parse_error::kParseNoError;
265 return result;
266 } 262 }
267 glCheckFramebufferStatusEXT(target); 263 glCheckFramebufferStatusEXT(target);
268 return parse_error::kParseNoError; 264 return parse_error::kParseNoError;
269 } 265 }
270 266
271 parse_error::ParseError GLES2DecoderImpl::HandleClear( 267 parse_error::ParseError GLES2DecoderImpl::HandleClear(
272 uint32 immediate_data_size, const gles2::Clear& c) { 268 uint32 immediate_data_size, const gles2::Clear& c) {
273 GLbitfield mask = static_cast<GLbitfield>(c.mask); 269 GLbitfield mask = static_cast<GLbitfield>(c.mask);
274 parse_error::ParseError result =
275 ValidateClear(this, immediate_data_size, mask);
276 if (result != parse_error::kParseNoError) {
277 return result;
278 }
279 glClear(mask); 270 glClear(mask);
280 return parse_error::kParseNoError; 271 return parse_error::kParseNoError;
281 } 272 }
282 273
283 parse_error::ParseError GLES2DecoderImpl::HandleClearColor( 274 parse_error::ParseError GLES2DecoderImpl::HandleClearColor(
284 uint32 immediate_data_size, const gles2::ClearColor& c) { 275 uint32 immediate_data_size, const gles2::ClearColor& c) {
285 GLclampf red = static_cast<GLclampf>(c.red); 276 GLclampf red = static_cast<GLclampf>(c.red);
286 GLclampf green = static_cast<GLclampf>(c.green); 277 GLclampf green = static_cast<GLclampf>(c.green);
287 GLclampf blue = static_cast<GLclampf>(c.blue); 278 GLclampf blue = static_cast<GLclampf>(c.blue);
288 GLclampf alpha = static_cast<GLclampf>(c.alpha); 279 GLclampf alpha = static_cast<GLclampf>(c.alpha);
289 parse_error::ParseError result =
290 ValidateClearColor(this, immediate_data_size, red, green, blue, alpha);
291 if (result != parse_error::kParseNoError) {
292 return result;
293 }
294 glClearColor(red, green, blue, alpha); 280 glClearColor(red, green, blue, alpha);
295 return parse_error::kParseNoError; 281 return parse_error::kParseNoError;
296 } 282 }
297 283
298 parse_error::ParseError GLES2DecoderImpl::HandleClearDepthf( 284 parse_error::ParseError GLES2DecoderImpl::HandleClearDepthf(
299 uint32 immediate_data_size, const gles2::ClearDepthf& c) { 285 uint32 immediate_data_size, const gles2::ClearDepthf& c) {
300 GLclampf depth = static_cast<GLclampf>(c.depth); 286 GLclampf depth = static_cast<GLclampf>(c.depth);
301 parse_error::ParseError result =
302 ValidateClearDepthf(this, immediate_data_size, depth);
303 if (result != parse_error::kParseNoError) {
304 return result;
305 }
306 glClearDepth(depth); 287 glClearDepth(depth);
307 return parse_error::kParseNoError; 288 return parse_error::kParseNoError;
308 } 289 }
309 290
310 parse_error::ParseError GLES2DecoderImpl::HandleClearStencil( 291 parse_error::ParseError GLES2DecoderImpl::HandleClearStencil(
311 uint32 immediate_data_size, const gles2::ClearStencil& c) { 292 uint32 immediate_data_size, const gles2::ClearStencil& c) {
312 GLint s = static_cast<GLint>(c.s); 293 GLint s = static_cast<GLint>(c.s);
313 parse_error::ParseError result =
314 ValidateClearStencil(this, immediate_data_size, s);
315 if (result != parse_error::kParseNoError) {
316 return result;
317 }
318 glClearStencil(s); 294 glClearStencil(s);
319 return parse_error::kParseNoError; 295 return parse_error::kParseNoError;
320 } 296 }
321 297
322 parse_error::ParseError GLES2DecoderImpl::HandleColorMask( 298 parse_error::ParseError GLES2DecoderImpl::HandleColorMask(
323 uint32 immediate_data_size, const gles2::ColorMask& c) { 299 uint32 immediate_data_size, const gles2::ColorMask& c) {
324 GLboolean red = static_cast<GLboolean>(c.red); 300 GLboolean red = static_cast<GLboolean>(c.red);
325 GLboolean green = static_cast<GLboolean>(c.green); 301 GLboolean green = static_cast<GLboolean>(c.green);
326 GLboolean blue = static_cast<GLboolean>(c.blue); 302 GLboolean blue = static_cast<GLboolean>(c.blue);
327 GLboolean alpha = static_cast<GLboolean>(c.alpha); 303 GLboolean alpha = static_cast<GLboolean>(c.alpha);
328 parse_error::ParseError result =
329 ValidateColorMask(this, immediate_data_size, red, green, blue, alpha);
330 if (result != parse_error::kParseNoError) {
331 return result;
332 }
333 glColorMask(red, green, blue, alpha); 304 glColorMask(red, green, blue, alpha);
334 return parse_error::kParseNoError; 305 return parse_error::kParseNoError;
335 } 306 }
336 307
337 parse_error::ParseError GLES2DecoderImpl::HandleCompileShader( 308 parse_error::ParseError GLES2DecoderImpl::HandleCompileShader(
338 uint32 immediate_data_size, const gles2::CompileShader& c) { 309 uint32 immediate_data_size, const gles2::CompileShader& c) {
339 GLuint shader; 310 GLuint shader;
340 if (!id_map_.GetServiceId(c.shader, &shader)) { 311 if (!id_map_.GetServiceId(c.shader, &shader)) {
341 SetGLError(GL_INVALID_VALUE); 312 SetGLError(GL_INVALID_VALUE);
342 return parse_error::kParseNoError; 313 return parse_error::kParseNoError;
343 } 314 }
344 parse_error::ParseError result =
345 ValidateCompileShader(this, immediate_data_size, shader);
346 if (result != parse_error::kParseNoError) {
347 return result;
348 }
349 glCompileShader(shader); 315 glCompileShader(shader);
350 return parse_error::kParseNoError; 316 return parse_error::kParseNoError;
351 } 317 }
352 318
353 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2D( 319 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2D(
354 uint32 immediate_data_size, const gles2::CompressedTexSubImage2D& c) { 320 uint32 immediate_data_size, const gles2::CompressedTexSubImage2D& c) {
355 GLenum target = static_cast<GLenum>(c.target); 321 GLenum target = static_cast<GLenum>(c.target);
356 GLint level = static_cast<GLint>(c.level); 322 GLint level = static_cast<GLint>(c.level);
357 GLint xoffset = static_cast<GLint>(c.xoffset); 323 GLint xoffset = static_cast<GLint>(c.xoffset);
358 GLint yoffset = static_cast<GLint>(c.yoffset); 324 GLint yoffset = static_cast<GLint>(c.yoffset);
359 GLsizei width = static_cast<GLsizei>(c.width); 325 GLsizei width = static_cast<GLsizei>(c.width);
360 GLsizei height = static_cast<GLsizei>(c.height); 326 GLsizei height = static_cast<GLsizei>(c.height);
361 GLenum format = static_cast<GLenum>(c.format); 327 GLenum format = static_cast<GLenum>(c.format);
362 GLsizei imageSize = static_cast<GLsizei>(c.imageSize); 328 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
363 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 329 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
364 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 330 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
365 uint32 data_size = imageSize; 331 uint32 data_size = imageSize;
366 const void* data = GetSharedMemoryAs<const void*>( 332 const void* data = GetSharedMemoryAs<const void*>(
367 data_shm_id, data_shm_offset, data_size); 333 data_shm_id, data_shm_offset, data_size);
368 parse_error::ParseError result = 334 if (!ValidateGLenumTextureTarget(target)) {
369 ValidateCompressedTexSubImage2D( 335 SetGLError(GL_INVALID_VALUE);
370 this, immediate_data_size, target, level, xoffset, yoffset, width, 336 return parse_error::kParseNoError;
371 height, format, imageSize, data); 337 }
372 if (result != parse_error::kParseNoError) { 338 if (data == NULL) {
373 return result; 339 return parse_error::kParseOutOfBounds;
374 } 340 }
375 glCompressedTexSubImage2D( 341 glCompressedTexSubImage2D(
376 target, level, xoffset, yoffset, width, height, format, imageSize, data); 342 target, level, xoffset, yoffset, width, height, format, imageSize, data);
377 return parse_error::kParseNoError; 343 return parse_error::kParseNoError;
378 } 344 }
379 345
380 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2DImmediate ( 346 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2DImmediate (
381 347
382 uint32 immediate_data_size, 348 uint32 immediate_data_size,
383 const gles2::CompressedTexSubImage2DImmediate& c) { 349 const gles2::CompressedTexSubImage2DImmediate& c) {
384 GLenum target = static_cast<GLenum>(c.target); 350 GLenum target = static_cast<GLenum>(c.target);
385 GLint level = static_cast<GLint>(c.level); 351 GLint level = static_cast<GLint>(c.level);
386 GLint xoffset = static_cast<GLint>(c.xoffset); 352 GLint xoffset = static_cast<GLint>(c.xoffset);
387 GLint yoffset = static_cast<GLint>(c.yoffset); 353 GLint yoffset = static_cast<GLint>(c.yoffset);
388 GLsizei width = static_cast<GLsizei>(c.width); 354 GLsizei width = static_cast<GLsizei>(c.width);
389 GLsizei height = static_cast<GLsizei>(c.height); 355 GLsizei height = static_cast<GLsizei>(c.height);
390 GLenum format = static_cast<GLenum>(c.format); 356 GLenum format = static_cast<GLenum>(c.format);
391 GLsizei imageSize = static_cast<GLsizei>(c.imageSize); 357 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
392 const void* data = GetImmediateDataAs<const void*>(c); 358 const void* data = GetImmediateDataAs<const void*>(c);
359 if (!ValidateGLenumTextureTarget(target)) {
360 SetGLError(GL_INVALID_VALUE);
361 return parse_error::kParseNoError;
362 }
363 if (data == NULL) {
364 return parse_error::kParseOutOfBounds;
365 }
393 // Immediate version. 366 // Immediate version.
394 parse_error::ParseError result = 367 if (!ValidateGLenumTextureTarget(target)) {
395 ValidateCompressedTexSubImage2DImmediate( 368 SetGLError(GL_INVALID_VALUE);
396 this, immediate_data_size, target, level, xoffset, yoffset, width, 369 return parse_error::kParseNoError;
397 height, format, imageSize, data); 370 }
398 if (result != parse_error::kParseNoError) { 371 if (data == NULL) {
399 return result; 372 return parse_error::kParseOutOfBounds;
400 } 373 }
401 glCompressedTexSubImage2D( 374 glCompressedTexSubImage2D(
402 target, level, xoffset, yoffset, width, height, format, imageSize, data); 375 target, level, xoffset, yoffset, width, height, format, imageSize, data);
403 return parse_error::kParseNoError; 376 return parse_error::kParseNoError;
404 } 377 }
405 378
406 parse_error::ParseError GLES2DecoderImpl::HandleCopyTexImage2D( 379 parse_error::ParseError GLES2DecoderImpl::HandleCopyTexImage2D(
407 uint32 immediate_data_size, const gles2::CopyTexImage2D& c) { 380 uint32 immediate_data_size, const gles2::CopyTexImage2D& c) {
408 GLenum target = static_cast<GLenum>(c.target); 381 GLenum target = static_cast<GLenum>(c.target);
409 GLint level = static_cast<GLint>(c.level); 382 GLint level = static_cast<GLint>(c.level);
410 GLenum internalformat = static_cast<GLenum>(c.internalformat); 383 GLenum internalformat = static_cast<GLenum>(c.internalformat);
411 GLint x = static_cast<GLint>(c.x); 384 GLint x = static_cast<GLint>(c.x);
412 GLint y = static_cast<GLint>(c.y); 385 GLint y = static_cast<GLint>(c.y);
413 GLsizei width = static_cast<GLsizei>(c.width); 386 GLsizei width = static_cast<GLsizei>(c.width);
414 GLsizei height = static_cast<GLsizei>(c.height); 387 GLsizei height = static_cast<GLsizei>(c.height);
415 GLint border = static_cast<GLint>(c.border); 388 GLint border = static_cast<GLint>(c.border);
416 parse_error::ParseError result = 389 if (!ValidateGLenumTextureTarget(target)) {
417 ValidateCopyTexImage2D( 390 SetGLError(GL_INVALID_VALUE);
418 this, immediate_data_size, target, level, internalformat, x, y, width, 391 return parse_error::kParseNoError;
419 height, border);
420 if (result != parse_error::kParseNoError) {
421 return result;
422 } 392 }
423 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); 393 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
424 return parse_error::kParseNoError; 394 return parse_error::kParseNoError;
425 } 395 }
426 396
427 parse_error::ParseError GLES2DecoderImpl::HandleCopyTexSubImage2D( 397 parse_error::ParseError GLES2DecoderImpl::HandleCopyTexSubImage2D(
428 uint32 immediate_data_size, const gles2::CopyTexSubImage2D& c) { 398 uint32 immediate_data_size, const gles2::CopyTexSubImage2D& c) {
429 GLenum target = static_cast<GLenum>(c.target); 399 GLenum target = static_cast<GLenum>(c.target);
430 GLint level = static_cast<GLint>(c.level); 400 GLint level = static_cast<GLint>(c.level);
431 GLint xoffset = static_cast<GLint>(c.xoffset); 401 GLint xoffset = static_cast<GLint>(c.xoffset);
432 GLint yoffset = static_cast<GLint>(c.yoffset); 402 GLint yoffset = static_cast<GLint>(c.yoffset);
433 GLint x = static_cast<GLint>(c.x); 403 GLint x = static_cast<GLint>(c.x);
434 GLint y = static_cast<GLint>(c.y); 404 GLint y = static_cast<GLint>(c.y);
435 GLsizei width = static_cast<GLsizei>(c.width); 405 GLsizei width = static_cast<GLsizei>(c.width);
436 GLsizei height = static_cast<GLsizei>(c.height); 406 GLsizei height = static_cast<GLsizei>(c.height);
437 parse_error::ParseError result = 407 if (!ValidateGLenumTextureTarget(target)) {
438 ValidateCopyTexSubImage2D( 408 SetGLError(GL_INVALID_VALUE);
439 this, immediate_data_size, target, level, xoffset, yoffset, x, y, 409 return parse_error::kParseNoError;
440 width, height);
441 if (result != parse_error::kParseNoError) {
442 return result;
443 } 410 }
444 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 411 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
445 return parse_error::kParseNoError; 412 return parse_error::kParseNoError;
446 } 413 }
447 414
448 parse_error::ParseError GLES2DecoderImpl::HandleCreateProgram( 415 parse_error::ParseError GLES2DecoderImpl::HandleCreateProgram(
449 uint32 immediate_data_size, const gles2::CreateProgram& c) { 416 uint32 immediate_data_size, const gles2::CreateProgram& c) {
450 uint32 client_id = c.client_id; 417 uint32 client_id = c.client_id;
451 parse_error::ParseError result =
452 ValidateCreateProgram(this, immediate_data_size);
453 if (result != parse_error::kParseNoError) {
454 return result;
455 }
456 CreateProgramHelper(client_id); 418 CreateProgramHelper(client_id);
457 return parse_error::kParseNoError; 419 return parse_error::kParseNoError;
458 } 420 }
459 421
460 parse_error::ParseError GLES2DecoderImpl::HandleCreateShader( 422 parse_error::ParseError GLES2DecoderImpl::HandleCreateShader(
461 uint32 immediate_data_size, const gles2::CreateShader& c) { 423 uint32 immediate_data_size, const gles2::CreateShader& c) {
462 GLenum type = static_cast<GLenum>(c.type); 424 GLenum type = static_cast<GLenum>(c.type);
425 if (!ValidateGLenumShaderType(type)) {
426 SetGLError(GL_INVALID_VALUE);
427 return parse_error::kParseNoError;
428 }
463 uint32 client_id = c.client_id; 429 uint32 client_id = c.client_id;
464 parse_error::ParseError result = 430 if (!ValidateGLenumShaderType(type)) {
465 ValidateCreateShader(this, immediate_data_size, type); 431 SetGLError(GL_INVALID_VALUE);
466 if (result != parse_error::kParseNoError) { 432 return parse_error::kParseNoError;
467 return result;
468 } 433 }
469 CreateShaderHelper(type, client_id); 434 CreateShaderHelper(type, client_id);
470 return parse_error::kParseNoError; 435 return parse_error::kParseNoError;
471 } 436 }
472 437
473 parse_error::ParseError GLES2DecoderImpl::HandleCullFace( 438 parse_error::ParseError GLES2DecoderImpl::HandleCullFace(
474 uint32 immediate_data_size, const gles2::CullFace& c) { 439 uint32 immediate_data_size, const gles2::CullFace& c) {
475 GLenum mode = static_cast<GLenum>(c.mode); 440 GLenum mode = static_cast<GLenum>(c.mode);
476 parse_error::ParseError result = 441 if (!ValidateGLenumFaceType(mode)) {
477 ValidateCullFace(this, immediate_data_size, mode); 442 SetGLError(GL_INVALID_VALUE);
478 if (result != parse_error::kParseNoError) { 443 return parse_error::kParseNoError;
479 return result;
480 } 444 }
481 glCullFace(mode); 445 glCullFace(mode);
482 return parse_error::kParseNoError; 446 return parse_error::kParseNoError;
483 } 447 }
484 448
485 parse_error::ParseError GLES2DecoderImpl::HandleDeleteBuffers( 449 parse_error::ParseError GLES2DecoderImpl::HandleDeleteBuffers(
486 uint32 immediate_data_size, const gles2::DeleteBuffers& c) { 450 uint32 immediate_data_size, const gles2::DeleteBuffers& c) {
487 GLsizei n = static_cast<GLsizei>(c.n); 451 GLsizei n = static_cast<GLsizei>(c.n);
488 const GLuint* buffers = GetSharedMemoryAs<const GLuint*>( 452 const GLuint* buffers = GetSharedMemoryAs<const GLuint*>(
489 c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */); 453 c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */);
490 parse_error::ParseError result = 454 if (buffers == NULL) {
491 ValidateDeleteBuffers(this, immediate_data_size, n, buffers); 455 return parse_error::kParseOutOfBounds;
492 if (result != parse_error::kParseNoError) { 456 }
493 return result; 457 if (buffers == NULL) {
458 return parse_error::kParseOutOfBounds;
494 } 459 }
495 DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers); 460 DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers);
496 return parse_error::kParseNoError; 461 return parse_error::kParseNoError;
497 } 462 }
498 463
499 parse_error::ParseError GLES2DecoderImpl::HandleDeleteBuffersImmediate( 464 parse_error::ParseError GLES2DecoderImpl::HandleDeleteBuffersImmediate(
500 uint32 immediate_data_size, const gles2::DeleteBuffersImmediate& c) { 465 uint32 immediate_data_size, const gles2::DeleteBuffersImmediate& c) {
501 GLsizei n = static_cast<GLsizei>(c.n); 466 GLsizei n = static_cast<GLsizei>(c.n);
502 const GLuint* buffers = GetImmediateDataAs<const GLuint*>(c); 467 const GLuint* buffers = GetImmediateDataAs<const GLuint*>(c);
503 parse_error::ParseError result = 468 if (buffers == NULL) {
504 ValidateDeleteBuffersImmediate(this, immediate_data_size, n, buffers); 469 return parse_error::kParseOutOfBounds;
505 if (result != parse_error::kParseNoError) { 470 }
506 return result; 471 if (buffers == NULL) {
472 return parse_error::kParseOutOfBounds;
507 } 473 }
508 DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers); 474 DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers);
509 return parse_error::kParseNoError; 475 return parse_error::kParseNoError;
510 } 476 }
511 477
512 parse_error::ParseError GLES2DecoderImpl::HandleDeleteFramebuffers( 478 parse_error::ParseError GLES2DecoderImpl::HandleDeleteFramebuffers(
513 uint32 immediate_data_size, const gles2::DeleteFramebuffers& c) { 479 uint32 immediate_data_size, const gles2::DeleteFramebuffers& c) {
514 GLsizei n = static_cast<GLsizei>(c.n); 480 GLsizei n = static_cast<GLsizei>(c.n);
515 const GLuint* framebuffers = GetSharedMemoryAs<const GLuint*>( 481 const GLuint* framebuffers = GetSharedMemoryAs<const GLuint*>(
516 c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO( 482 c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO(
517 gman): size */); 483 gman): size */);
518 parse_error::ParseError result = 484 if (framebuffers == NULL) {
519 ValidateDeleteFramebuffers(this, immediate_data_size, n, framebuffers); 485 return parse_error::kParseOutOfBounds;
520 if (result != parse_error::kParseNoError) { 486 }
521 return result; 487 if (framebuffers == NULL) {
488 return parse_error::kParseOutOfBounds;
522 } 489 }
523 DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers); 490 DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers);
524 return parse_error::kParseNoError; 491 return parse_error::kParseNoError;
525 } 492 }
526 493
527 parse_error::ParseError GLES2DecoderImpl::HandleDeleteFramebuffersImmediate( 494 parse_error::ParseError GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
528 uint32 immediate_data_size, const gles2::DeleteFramebuffersImmediate& c) { 495 uint32 immediate_data_size, const gles2::DeleteFramebuffersImmediate& c) {
529 GLsizei n = static_cast<GLsizei>(c.n); 496 GLsizei n = static_cast<GLsizei>(c.n);
530 const GLuint* framebuffers = GetImmediateDataAs<const GLuint*>(c); 497 const GLuint* framebuffers = GetImmediateDataAs<const GLuint*>(c);
531 parse_error::ParseError result = 498 if (framebuffers == NULL) {
532 ValidateDeleteFramebuffersImmediate( 499 return parse_error::kParseOutOfBounds;
533 this, immediate_data_size, n, framebuffers); 500 }
534 if (result != parse_error::kParseNoError) { 501 if (framebuffers == NULL) {
535 return result; 502 return parse_error::kParseOutOfBounds;
536 } 503 }
537 DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers); 504 DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers);
538 return parse_error::kParseNoError; 505 return parse_error::kParseNoError;
539 } 506 }
540 507
541 parse_error::ParseError GLES2DecoderImpl::HandleDeleteProgram(
542 uint32 immediate_data_size, const gles2::DeleteProgram& c) {
543 GLuint program;
544 if (!id_map_.GetServiceId(c.program, &program)) {
545 SetGLError(GL_INVALID_VALUE);
546 return parse_error::kParseNoError;
547 }
548 parse_error::ParseError result =
549 ValidateDeleteProgram(this, immediate_data_size, program);
550 if (result != parse_error::kParseNoError) {
551 return result;
552 }
553 DoDeleteProgram(program);
554 return parse_error::kParseNoError;
555 }
556
557 parse_error::ParseError GLES2DecoderImpl::HandleDeleteRenderbuffers( 508 parse_error::ParseError GLES2DecoderImpl::HandleDeleteRenderbuffers(
558 uint32 immediate_data_size, const gles2::DeleteRenderbuffers& c) { 509 uint32 immediate_data_size, const gles2::DeleteRenderbuffers& c) {
559 GLsizei n = static_cast<GLsizei>(c.n); 510 GLsizei n = static_cast<GLsizei>(c.n);
560 const GLuint* renderbuffers = GetSharedMemoryAs<const GLuint*>( 511 const GLuint* renderbuffers = GetSharedMemoryAs<const GLuint*>(
561 c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO( 512 c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO(
562 gman): size */); 513 gman): size */);
563 parse_error::ParseError result = 514 if (renderbuffers == NULL) {
564 ValidateDeleteRenderbuffers(this, immediate_data_size, n, renderbuffers); 515 return parse_error::kParseOutOfBounds;
565 if (result != parse_error::kParseNoError) { 516 }
566 return result; 517 if (renderbuffers == NULL) {
518 return parse_error::kParseOutOfBounds;
567 } 519 }
568 DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers); 520 DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers);
569 return parse_error::kParseNoError; 521 return parse_error::kParseNoError;
570 } 522 }
571 523
572 parse_error::ParseError GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate( 524 parse_error::ParseError GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
573 uint32 immediate_data_size, const gles2::DeleteRenderbuffersImmediate& c) { 525 uint32 immediate_data_size, const gles2::DeleteRenderbuffersImmediate& c) {
574 GLsizei n = static_cast<GLsizei>(c.n); 526 GLsizei n = static_cast<GLsizei>(c.n);
575 const GLuint* renderbuffers = GetImmediateDataAs<const GLuint*>(c); 527 const GLuint* renderbuffers = GetImmediateDataAs<const GLuint*>(c);
576 parse_error::ParseError result = 528 if (renderbuffers == NULL) {
577 ValidateDeleteRenderbuffersImmediate( 529 return parse_error::kParseOutOfBounds;
578 this, immediate_data_size, n, renderbuffers); 530 }
579 if (result != parse_error::kParseNoError) { 531 if (renderbuffers == NULL) {
580 return result; 532 return parse_error::kParseOutOfBounds;
581 } 533 }
582 DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers); 534 DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers);
583 return parse_error::kParseNoError; 535 return parse_error::kParseNoError;
584 } 536 }
585 537
586 parse_error::ParseError GLES2DecoderImpl::HandleDeleteShader(
587 uint32 immediate_data_size, const gles2::DeleteShader& c) {
588 GLuint shader;
589 if (!id_map_.GetServiceId(c.shader, &shader)) {
590 SetGLError(GL_INVALID_VALUE);
591 return parse_error::kParseNoError;
592 }
593 parse_error::ParseError result =
594 ValidateDeleteShader(this, immediate_data_size, shader);
595 if (result != parse_error::kParseNoError) {
596 return result;
597 }
598 DoDeleteShader(shader);
599 return parse_error::kParseNoError;
600 }
601
602 parse_error::ParseError GLES2DecoderImpl::HandleDeleteTextures( 538 parse_error::ParseError GLES2DecoderImpl::HandleDeleteTextures(
603 uint32 immediate_data_size, const gles2::DeleteTextures& c) { 539 uint32 immediate_data_size, const gles2::DeleteTextures& c) {
604 GLsizei n = static_cast<GLsizei>(c.n); 540 GLsizei n = static_cast<GLsizei>(c.n);
605 const GLuint* textures = GetSharedMemoryAs<const GLuint*>( 541 const GLuint* textures = GetSharedMemoryAs<const GLuint*>(
606 c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */); 542 c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */);
607 parse_error::ParseError result = 543 if (textures == NULL) {
608 ValidateDeleteTextures(this, immediate_data_size, n, textures); 544 return parse_error::kParseOutOfBounds;
609 if (result != parse_error::kParseNoError) { 545 }
610 return result; 546 if (textures == NULL) {
547 return parse_error::kParseOutOfBounds;
611 } 548 }
612 DeleteGLObjects<GLDeleteTexturesHelper>(n, textures); 549 DeleteGLObjects<GLDeleteTexturesHelper>(n, textures);
613 return parse_error::kParseNoError; 550 return parse_error::kParseNoError;
614 } 551 }
615 552
616 parse_error::ParseError GLES2DecoderImpl::HandleDeleteTexturesImmediate( 553 parse_error::ParseError GLES2DecoderImpl::HandleDeleteTexturesImmediate(
617 uint32 immediate_data_size, const gles2::DeleteTexturesImmediate& c) { 554 uint32 immediate_data_size, const gles2::DeleteTexturesImmediate& c) {
618 GLsizei n = static_cast<GLsizei>(c.n); 555 GLsizei n = static_cast<GLsizei>(c.n);
619 const GLuint* textures = GetImmediateDataAs<const GLuint*>(c); 556 const GLuint* textures = GetImmediateDataAs<const GLuint*>(c);
620 parse_error::ParseError result = 557 if (textures == NULL) {
621 ValidateDeleteTexturesImmediate(this, immediate_data_size, n, textures); 558 return parse_error::kParseOutOfBounds;
622 if (result != parse_error::kParseNoError) { 559 }
623 return result; 560 if (textures == NULL) {
561 return parse_error::kParseOutOfBounds;
624 } 562 }
625 DeleteGLObjects<GLDeleteTexturesHelper>(n, textures); 563 DeleteGLObjects<GLDeleteTexturesHelper>(n, textures);
626 return parse_error::kParseNoError; 564 return parse_error::kParseNoError;
627 } 565 }
628 566
629 parse_error::ParseError GLES2DecoderImpl::HandleDepthFunc( 567 parse_error::ParseError GLES2DecoderImpl::HandleDepthFunc(
630 uint32 immediate_data_size, const gles2::DepthFunc& c) { 568 uint32 immediate_data_size, const gles2::DepthFunc& c) {
631 GLenum func = static_cast<GLenum>(c.func); 569 GLenum func = static_cast<GLenum>(c.func);
632 parse_error::ParseError result = 570 if (!ValidateGLenumCmpFunction(func)) {
633 ValidateDepthFunc(this, immediate_data_size, func); 571 SetGLError(GL_INVALID_VALUE);
634 if (result != parse_error::kParseNoError) { 572 return parse_error::kParseNoError;
635 return result;
636 } 573 }
637 glDepthFunc(func); 574 glDepthFunc(func);
638 return parse_error::kParseNoError; 575 return parse_error::kParseNoError;
639 } 576 }
640 577
641 parse_error::ParseError GLES2DecoderImpl::HandleDepthMask( 578 parse_error::ParseError GLES2DecoderImpl::HandleDepthMask(
642 uint32 immediate_data_size, const gles2::DepthMask& c) { 579 uint32 immediate_data_size, const gles2::DepthMask& c) {
643 GLboolean flag = static_cast<GLboolean>(c.flag); 580 GLboolean flag = static_cast<GLboolean>(c.flag);
644 parse_error::ParseError result =
645 ValidateDepthMask(this, immediate_data_size, flag);
646 if (result != parse_error::kParseNoError) {
647 return result;
648 }
649 glDepthMask(flag); 581 glDepthMask(flag);
650 return parse_error::kParseNoError; 582 return parse_error::kParseNoError;
651 } 583 }
652 584
653 parse_error::ParseError GLES2DecoderImpl::HandleDepthRangef( 585 parse_error::ParseError GLES2DecoderImpl::HandleDepthRangef(
654 uint32 immediate_data_size, const gles2::DepthRangef& c) { 586 uint32 immediate_data_size, const gles2::DepthRangef& c) {
655 GLclampf zNear = static_cast<GLclampf>(c.zNear); 587 GLclampf zNear = static_cast<GLclampf>(c.zNear);
656 GLclampf zFar = static_cast<GLclampf>(c.zFar); 588 GLclampf zFar = static_cast<GLclampf>(c.zFar);
657 parse_error::ParseError result =
658 ValidateDepthRangef(this, immediate_data_size, zNear, zFar);
659 if (result != parse_error::kParseNoError) {
660 return result;
661 }
662 glDepthRange(zNear, zFar); 589 glDepthRange(zNear, zFar);
663 return parse_error::kParseNoError; 590 return parse_error::kParseNoError;
664 } 591 }
665 592
666 parse_error::ParseError GLES2DecoderImpl::HandleDetachShader( 593 parse_error::ParseError GLES2DecoderImpl::HandleDetachShader(
667 uint32 immediate_data_size, const gles2::DetachShader& c) { 594 uint32 immediate_data_size, const gles2::DetachShader& c) {
668 GLuint program; 595 GLuint program;
669 if (!id_map_.GetServiceId(c.program, &program)) { 596 if (!id_map_.GetServiceId(c.program, &program)) {
670 SetGLError(GL_INVALID_VALUE); 597 SetGLError(GL_INVALID_VALUE);
671 return parse_error::kParseNoError; 598 return parse_error::kParseNoError;
672 } 599 }
673 GLuint shader; 600 GLuint shader;
674 if (!id_map_.GetServiceId(c.shader, &shader)) { 601 if (!id_map_.GetServiceId(c.shader, &shader)) {
675 SetGLError(GL_INVALID_VALUE); 602 SetGLError(GL_INVALID_VALUE);
676 return parse_error::kParseNoError; 603 return parse_error::kParseNoError;
677 } 604 }
678 parse_error::ParseError result =
679 ValidateDetachShader(this, immediate_data_size, program, shader);
680 if (result != parse_error::kParseNoError) {
681 return result;
682 }
683 glDetachShader(program, shader); 605 glDetachShader(program, shader);
684 return parse_error::kParseNoError; 606 return parse_error::kParseNoError;
685 } 607 }
686 608
687 parse_error::ParseError GLES2DecoderImpl::HandleDisable( 609 parse_error::ParseError GLES2DecoderImpl::HandleDisable(
688 uint32 immediate_data_size, const gles2::Disable& c) { 610 uint32 immediate_data_size, const gles2::Disable& c) {
689 GLenum cap = static_cast<GLenum>(c.cap); 611 GLenum cap = static_cast<GLenum>(c.cap);
690 parse_error::ParseError result = 612 if (!ValidateGLenumCapability(cap)) {
691 ValidateDisable(this, immediate_data_size, cap); 613 SetGLError(GL_INVALID_VALUE);
692 if (result != parse_error::kParseNoError) { 614 return parse_error::kParseNoError;
693 return result;
694 } 615 }
695 glDisable(cap); 616 glDisable(cap);
696 return parse_error::kParseNoError; 617 return parse_error::kParseNoError;
697 } 618 }
698 619
699 parse_error::ParseError GLES2DecoderImpl::HandleDisableVertexAttribArray( 620 parse_error::ParseError GLES2DecoderImpl::HandleDisableVertexAttribArray(
700 uint32 immediate_data_size, const gles2::DisableVertexAttribArray& c) { 621 uint32 immediate_data_size, const gles2::DisableVertexAttribArray& c) {
701 GLuint index = static_cast<GLuint>(c.index); 622 GLuint index = static_cast<GLuint>(c.index);
702 parse_error::ParseError result =
703 ValidateDisableVertexAttribArray(this, immediate_data_size, index);
704 if (result != parse_error::kParseNoError) {
705 return result;
706 }
707 glDisableVertexAttribArray(index); 623 glDisableVertexAttribArray(index);
708 return parse_error::kParseNoError; 624 return parse_error::kParseNoError;
709 } 625 }
710 626
711 parse_error::ParseError GLES2DecoderImpl::HandleDrawArrays( 627 parse_error::ParseError GLES2DecoderImpl::HandleDrawArrays(
712 uint32 immediate_data_size, const gles2::DrawArrays& c) { 628 uint32 immediate_data_size, const gles2::DrawArrays& c) {
713 GLenum mode = static_cast<GLenum>(c.mode); 629 GLenum mode = static_cast<GLenum>(c.mode);
714 GLint first = static_cast<GLint>(c.first); 630 GLint first = static_cast<GLint>(c.first);
715 GLsizei count = static_cast<GLsizei>(c.count); 631 GLsizei count = static_cast<GLsizei>(c.count);
716 parse_error::ParseError result = 632 if (!ValidateGLenumDrawMode(mode)) {
717 ValidateDrawArrays(this, immediate_data_size, mode, first, count); 633 SetGLError(GL_INVALID_VALUE);
718 if (result != parse_error::kParseNoError) { 634 return parse_error::kParseNoError;
719 return result;
720 } 635 }
721 glDrawArrays(mode, first, count); 636 glDrawArrays(mode, first, count);
722 return parse_error::kParseNoError; 637 return parse_error::kParseNoError;
723 } 638 }
724 639
725 parse_error::ParseError GLES2DecoderImpl::HandleEnable( 640 parse_error::ParseError GLES2DecoderImpl::HandleEnable(
726 uint32 immediate_data_size, const gles2::Enable& c) { 641 uint32 immediate_data_size, const gles2::Enable& c) {
727 GLenum cap = static_cast<GLenum>(c.cap); 642 GLenum cap = static_cast<GLenum>(c.cap);
728 parse_error::ParseError result = 643 if (!ValidateGLenumCapability(cap)) {
729 ValidateEnable(this, immediate_data_size, cap); 644 SetGLError(GL_INVALID_VALUE);
730 if (result != parse_error::kParseNoError) { 645 return parse_error::kParseNoError;
731 return result;
732 } 646 }
733 glEnable(cap); 647 glEnable(cap);
734 return parse_error::kParseNoError; 648 return parse_error::kParseNoError;
735 } 649 }
736 650
737 parse_error::ParseError GLES2DecoderImpl::HandleEnableVertexAttribArray( 651 parse_error::ParseError GLES2DecoderImpl::HandleEnableVertexAttribArray(
738 uint32 immediate_data_size, const gles2::EnableVertexAttribArray& c) { 652 uint32 immediate_data_size, const gles2::EnableVertexAttribArray& c) {
739 GLuint index = static_cast<GLuint>(c.index); 653 GLuint index = static_cast<GLuint>(c.index);
740 parse_error::ParseError result =
741 ValidateEnableVertexAttribArray(this, immediate_data_size, index);
742 if (result != parse_error::kParseNoError) {
743 return result;
744 }
745 glEnableVertexAttribArray(index); 654 glEnableVertexAttribArray(index);
746 return parse_error::kParseNoError; 655 return parse_error::kParseNoError;
747 } 656 }
748 657
749 parse_error::ParseError GLES2DecoderImpl::HandleFinish( 658 parse_error::ParseError GLES2DecoderImpl::HandleFinish(
750 uint32 immediate_data_size, const gles2::Finish& c) { 659 uint32 immediate_data_size, const gles2::Finish& c) {
751 parse_error::ParseError result =
752 ValidateFinish(this, immediate_data_size);
753 if (result != parse_error::kParseNoError) {
754 return result;
755 }
756 glFinish(); 660 glFinish();
757 return parse_error::kParseNoError; 661 return parse_error::kParseNoError;
758 } 662 }
759 663
760 parse_error::ParseError GLES2DecoderImpl::HandleFlush( 664 parse_error::ParseError GLES2DecoderImpl::HandleFlush(
761 uint32 immediate_data_size, const gles2::Flush& c) { 665 uint32 immediate_data_size, const gles2::Flush& c) {
762 parse_error::ParseError result =
763 ValidateFlush(this, immediate_data_size);
764 if (result != parse_error::kParseNoError) {
765 return result;
766 }
767 glFlush(); 666 glFlush();
768 return parse_error::kParseNoError; 667 return parse_error::kParseNoError;
769 } 668 }
770 669
771 parse_error::ParseError GLES2DecoderImpl::HandleFramebufferRenderbuffer( 670 parse_error::ParseError GLES2DecoderImpl::HandleFramebufferRenderbuffer(
772 uint32 immediate_data_size, const gles2::FramebufferRenderbuffer& c) { 671 uint32 immediate_data_size, const gles2::FramebufferRenderbuffer& c) {
773 GLenum target = static_cast<GLenum>(c.target); 672 GLenum target = static_cast<GLenum>(c.target);
774 GLenum attachment = static_cast<GLenum>(c.attachment); 673 GLenum attachment = static_cast<GLenum>(c.attachment);
775 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget); 674 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
776 GLuint renderbuffer; 675 GLuint renderbuffer;
777 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) { 676 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
778 SetGLError(GL_INVALID_VALUE); 677 SetGLError(GL_INVALID_VALUE);
779 return parse_error::kParseNoError; 678 return parse_error::kParseNoError;
780 } 679 }
781 parse_error::ParseError result = 680 if (!ValidateGLenumFrameBufferTarget(target)) {
782 ValidateFramebufferRenderbuffer( 681 SetGLError(GL_INVALID_VALUE);
783 this, immediate_data_size, target, attachment, renderbuffertarget, 682 return parse_error::kParseNoError;
784 renderbuffer); 683 }
785 if (result != parse_error::kParseNoError) { 684 if (!ValidateGLenumAttachment(attachment)) {
786 return result; 685 SetGLError(GL_INVALID_VALUE);
686 return parse_error::kParseNoError;
687 }
688 if (!ValidateGLenumRenderBufferTarget(renderbuffertarget)) {
689 SetGLError(GL_INVALID_VALUE);
690 return parse_error::kParseNoError;
787 } 691 }
788 glFramebufferRenderbufferEXT( 692 glFramebufferRenderbufferEXT(
789 target, attachment, renderbuffertarget, renderbuffer); 693 target, attachment, renderbuffertarget, renderbuffer);
790 return parse_error::kParseNoError; 694 return parse_error::kParseNoError;
791 } 695 }
792 696
793 parse_error::ParseError GLES2DecoderImpl::HandleFramebufferTexture2D( 697 parse_error::ParseError GLES2DecoderImpl::HandleFramebufferTexture2D(
794 uint32 immediate_data_size, const gles2::FramebufferTexture2D& c) { 698 uint32 immediate_data_size, const gles2::FramebufferTexture2D& c) {
795 GLenum target = static_cast<GLenum>(c.target); 699 GLenum target = static_cast<GLenum>(c.target);
796 GLenum attachment = static_cast<GLenum>(c.attachment); 700 GLenum attachment = static_cast<GLenum>(c.attachment);
797 GLenum textarget = static_cast<GLenum>(c.textarget); 701 GLenum textarget = static_cast<GLenum>(c.textarget);
798 GLuint texture; 702 GLuint texture;
799 if (!id_map_.GetServiceId(c.texture, &texture)) { 703 if (!id_map_.GetServiceId(c.texture, &texture)) {
800 SetGLError(GL_INVALID_VALUE); 704 SetGLError(GL_INVALID_VALUE);
801 return parse_error::kParseNoError; 705 return parse_error::kParseNoError;
802 } 706 }
803 GLint level = static_cast<GLint>(c.level); 707 GLint level = static_cast<GLint>(c.level);
804 parse_error::ParseError result = 708 if (!ValidateGLenumFrameBufferTarget(target)) {
805 ValidateFramebufferTexture2D( 709 SetGLError(GL_INVALID_VALUE);
806 this, immediate_data_size, target, attachment, textarget, texture, 710 return parse_error::kParseNoError;
807 level); 711 }
808 if (result != parse_error::kParseNoError) { 712 if (!ValidateGLenumAttachment(attachment)) {
809 return result; 713 SetGLError(GL_INVALID_VALUE);
714 return parse_error::kParseNoError;
715 }
716 if (!ValidateGLenumTextureTarget(textarget)) {
717 SetGLError(GL_INVALID_VALUE);
718 return parse_error::kParseNoError;
810 } 719 }
811 glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); 720 glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
812 return parse_error::kParseNoError; 721 return parse_error::kParseNoError;
813 } 722 }
814 723
815 parse_error::ParseError GLES2DecoderImpl::HandleFrontFace( 724 parse_error::ParseError GLES2DecoderImpl::HandleFrontFace(
816 uint32 immediate_data_size, const gles2::FrontFace& c) { 725 uint32 immediate_data_size, const gles2::FrontFace& c) {
817 GLenum mode = static_cast<GLenum>(c.mode); 726 GLenum mode = static_cast<GLenum>(c.mode);
818 parse_error::ParseError result = 727 if (!ValidateGLenumFaceMode(mode)) {
819 ValidateFrontFace(this, immediate_data_size, mode); 728 SetGLError(GL_INVALID_VALUE);
820 if (result != parse_error::kParseNoError) { 729 return parse_error::kParseNoError;
821 return result;
822 } 730 }
823 glFrontFace(mode); 731 glFrontFace(mode);
824 return parse_error::kParseNoError; 732 return parse_error::kParseNoError;
825 } 733 }
826 734
827 parse_error::ParseError GLES2DecoderImpl::HandleGenBuffers( 735 parse_error::ParseError GLES2DecoderImpl::HandleGenBuffers(
828 uint32 immediate_data_size, const gles2::GenBuffers& c) { 736 uint32 immediate_data_size, const gles2::GenBuffers& c) {
829 GLsizei n = static_cast<GLsizei>(c.n); 737 GLsizei n = static_cast<GLsizei>(c.n);
830 GLuint* buffers = GetSharedMemoryAs<GLuint*>( 738 GLuint* buffers = GetSharedMemoryAs<GLuint*>(
831 c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */); 739 c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */);
832 parse_error::ParseError result = 740 if (buffers == NULL) {
833 ValidateGenBuffers(this, immediate_data_size, n, buffers); 741 return parse_error::kParseOutOfBounds;
834 if (result != parse_error::kParseNoError) { 742 }
835 return result; 743 if (buffers == NULL) {
744 return parse_error::kParseOutOfBounds;
836 } 745 }
837 GenGLObjects<GLGenBuffersHelper>(n, buffers); 746 GenGLObjects<GLGenBuffersHelper>(n, buffers);
838 return parse_error::kParseNoError; 747 return parse_error::kParseNoError;
839 } 748 }
840 749
841 parse_error::ParseError GLES2DecoderImpl::HandleGenBuffersImmediate( 750 parse_error::ParseError GLES2DecoderImpl::HandleGenBuffersImmediate(
842 uint32 immediate_data_size, const gles2::GenBuffersImmediate& c) { 751 uint32 immediate_data_size, const gles2::GenBuffersImmediate& c) {
843 GLsizei n = static_cast<GLsizei>(c.n); 752 GLsizei n = static_cast<GLsizei>(c.n);
844 GLuint* buffers = GetImmediateDataAs<GLuint*>(c); 753 GLuint* buffers = GetImmediateDataAs<GLuint*>(c);
845 parse_error::ParseError result = 754 if (buffers == NULL) {
846 ValidateGenBuffersImmediate(this, immediate_data_size, n, buffers); 755 return parse_error::kParseOutOfBounds;
847 if (result != parse_error::kParseNoError) { 756 }
848 return result; 757 if (buffers == NULL) {
758 return parse_error::kParseOutOfBounds;
849 } 759 }
850 GenGLObjects<GLGenBuffersHelper>(n, buffers); 760 GenGLObjects<GLGenBuffersHelper>(n, buffers);
851 return parse_error::kParseNoError; 761 return parse_error::kParseNoError;
852 } 762 }
853 763
854 parse_error::ParseError GLES2DecoderImpl::HandleGenerateMipmap( 764 parse_error::ParseError GLES2DecoderImpl::HandleGenerateMipmap(
855 uint32 immediate_data_size, const gles2::GenerateMipmap& c) { 765 uint32 immediate_data_size, const gles2::GenerateMipmap& c) {
856 GLenum target = static_cast<GLenum>(c.target); 766 GLenum target = static_cast<GLenum>(c.target);
857 parse_error::ParseError result = 767 if (!ValidateGLenumTextureBindTarget(target)) {
858 ValidateGenerateMipmap(this, immediate_data_size, target); 768 SetGLError(GL_INVALID_VALUE);
859 if (result != parse_error::kParseNoError) { 769 return parse_error::kParseNoError;
860 return result;
861 } 770 }
862 glGenerateMipmapEXT(target); 771 glGenerateMipmapEXT(target);
863 return parse_error::kParseNoError; 772 return parse_error::kParseNoError;
864 } 773 }
865 774
866 parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffers( 775 parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffers(
867 uint32 immediate_data_size, const gles2::GenFramebuffers& c) { 776 uint32 immediate_data_size, const gles2::GenFramebuffers& c) {
868 GLsizei n = static_cast<GLsizei>(c.n); 777 GLsizei n = static_cast<GLsizei>(c.n);
869 GLuint* framebuffers = GetSharedMemoryAs<GLuint*>( 778 GLuint* framebuffers = GetSharedMemoryAs<GLuint*>(
870 c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO( 779 c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO(
871 gman): size */); 780 gman): size */);
872 parse_error::ParseError result = 781 if (framebuffers == NULL) {
873 ValidateGenFramebuffers(this, immediate_data_size, n, framebuffers); 782 return parse_error::kParseOutOfBounds;
874 if (result != parse_error::kParseNoError) { 783 }
875 return result; 784 if (framebuffers == NULL) {
785 return parse_error::kParseOutOfBounds;
876 } 786 }
877 GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); 787 GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers);
878 return parse_error::kParseNoError; 788 return parse_error::kParseNoError;
879 } 789 }
880 790
881 parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffersImmediate( 791 parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffersImmediate(
882 uint32 immediate_data_size, const gles2::GenFramebuffersImmediate& c) { 792 uint32 immediate_data_size, const gles2::GenFramebuffersImmediate& c) {
883 GLsizei n = static_cast<GLsizei>(c.n); 793 GLsizei n = static_cast<GLsizei>(c.n);
884 GLuint* framebuffers = GetImmediateDataAs<GLuint*>(c); 794 GLuint* framebuffers = GetImmediateDataAs<GLuint*>(c);
885 parse_error::ParseError result = 795 if (framebuffers == NULL) {
886 ValidateGenFramebuffersImmediate( 796 return parse_error::kParseOutOfBounds;
887 this, immediate_data_size, n, framebuffers); 797 }
888 if (result != parse_error::kParseNoError) { 798 if (framebuffers == NULL) {
889 return result; 799 return parse_error::kParseOutOfBounds;
890 } 800 }
891 GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); 801 GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers);
892 return parse_error::kParseNoError; 802 return parse_error::kParseNoError;
893 } 803 }
894 804
895 parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffers( 805 parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffers(
896 uint32 immediate_data_size, const gles2::GenRenderbuffers& c) { 806 uint32 immediate_data_size, const gles2::GenRenderbuffers& c) {
897 GLsizei n = static_cast<GLsizei>(c.n); 807 GLsizei n = static_cast<GLsizei>(c.n);
898 GLuint* renderbuffers = GetSharedMemoryAs<GLuint*>( 808 GLuint* renderbuffers = GetSharedMemoryAs<GLuint*>(
899 c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO( 809 c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO(
900 gman): size */); 810 gman): size */);
901 parse_error::ParseError result = 811 if (renderbuffers == NULL) {
902 ValidateGenRenderbuffers(this, immediate_data_size, n, renderbuffers); 812 return parse_error::kParseOutOfBounds;
903 if (result != parse_error::kParseNoError) { 813 }
904 return result; 814 if (renderbuffers == NULL) {
815 return parse_error::kParseOutOfBounds;
905 } 816 }
906 GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); 817 GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers);
907 return parse_error::kParseNoError; 818 return parse_error::kParseNoError;
908 } 819 }
909 820
910 parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffersImmediate( 821 parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
911 uint32 immediate_data_size, const gles2::GenRenderbuffersImmediate& c) { 822 uint32 immediate_data_size, const gles2::GenRenderbuffersImmediate& c) {
912 GLsizei n = static_cast<GLsizei>(c.n); 823 GLsizei n = static_cast<GLsizei>(c.n);
913 GLuint* renderbuffers = GetImmediateDataAs<GLuint*>(c); 824 GLuint* renderbuffers = GetImmediateDataAs<GLuint*>(c);
914 parse_error::ParseError result = 825 if (renderbuffers == NULL) {
915 ValidateGenRenderbuffersImmediate( 826 return parse_error::kParseOutOfBounds;
916 this, immediate_data_size, n, renderbuffers); 827 }
917 if (result != parse_error::kParseNoError) { 828 if (renderbuffers == NULL) {
918 return result; 829 return parse_error::kParseOutOfBounds;
919 } 830 }
920 GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); 831 GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers);
921 return parse_error::kParseNoError; 832 return parse_error::kParseNoError;
922 } 833 }
923 834
924 parse_error::ParseError GLES2DecoderImpl::HandleGenTextures( 835 parse_error::ParseError GLES2DecoderImpl::HandleGenTextures(
925 uint32 immediate_data_size, const gles2::GenTextures& c) { 836 uint32 immediate_data_size, const gles2::GenTextures& c) {
926 GLsizei n = static_cast<GLsizei>(c.n); 837 GLsizei n = static_cast<GLsizei>(c.n);
927 GLuint* textures = GetSharedMemoryAs<GLuint*>( 838 GLuint* textures = GetSharedMemoryAs<GLuint*>(
928 c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */); 839 c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */);
929 parse_error::ParseError result = 840 if (textures == NULL) {
930 ValidateGenTextures(this, immediate_data_size, n, textures); 841 return parse_error::kParseOutOfBounds;
931 if (result != parse_error::kParseNoError) { 842 }
932 return result; 843 if (textures == NULL) {
844 return parse_error::kParseOutOfBounds;
933 } 845 }
934 GenGLObjects<GLGenTexturesHelper>(n, textures); 846 GenGLObjects<GLGenTexturesHelper>(n, textures);
935 return parse_error::kParseNoError; 847 return parse_error::kParseNoError;
936 } 848 }
937 849
938 parse_error::ParseError GLES2DecoderImpl::HandleGenTexturesImmediate( 850 parse_error::ParseError GLES2DecoderImpl::HandleGenTexturesImmediate(
939 uint32 immediate_data_size, const gles2::GenTexturesImmediate& c) { 851 uint32 immediate_data_size, const gles2::GenTexturesImmediate& c) {
940 GLsizei n = static_cast<GLsizei>(c.n); 852 GLsizei n = static_cast<GLsizei>(c.n);
941 GLuint* textures = GetImmediateDataAs<GLuint*>(c); 853 GLuint* textures = GetImmediateDataAs<GLuint*>(c);
942 parse_error::ParseError result = 854 if (textures == NULL) {
943 ValidateGenTexturesImmediate(this, immediate_data_size, n, textures); 855 return parse_error::kParseOutOfBounds;
944 if (result != parse_error::kParseNoError) { 856 }
945 return result; 857 if (textures == NULL) {
858 return parse_error::kParseOutOfBounds;
946 } 859 }
947 GenGLObjects<GLGenTexturesHelper>(n, textures); 860 GenGLObjects<GLGenTexturesHelper>(n, textures);
948 return parse_error::kParseNoError; 861 return parse_error::kParseNoError;
949 } 862 }
950 863
951 parse_error::ParseError GLES2DecoderImpl::HandleGetBooleanv( 864 parse_error::ParseError GLES2DecoderImpl::HandleGetBooleanv(
952 uint32 immediate_data_size, const gles2::GetBooleanv& c) { 865 uint32 immediate_data_size, const gles2::GetBooleanv& c) {
953 GLenum pname = static_cast<GLenum>(c.pname); 866 GLenum pname = static_cast<GLenum>(c.pname);
954 GLboolean* params; 867 GLboolean* params;
955 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 868 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
956 uint32 params_size = num_values * sizeof(*params); 869 uint32 params_size = num_values * sizeof(*params);
957 params = GetSharedMemoryAs<GLboolean*>( 870 params = GetSharedMemoryAs<GLboolean*>(
958 c.params_shm_id, c.params_shm_offset, params_size); 871 c.params_shm_id, c.params_shm_offset, params_size);
959 parse_error::ParseError result = 872 if (params == NULL) {
960 ValidateGetBooleanv(this, immediate_data_size, pname, params); 873 return parse_error::kParseOutOfBounds;
961 if (result != parse_error::kParseNoError) {
962 return result;
963 } 874 }
964 glGetBooleanv(pname, params); 875 glGetBooleanv(pname, params);
965 return parse_error::kParseNoError; 876 return parse_error::kParseNoError;
966 } 877 }
967 878
968 parse_error::ParseError GLES2DecoderImpl::HandleGetBufferParameteriv( 879 parse_error::ParseError GLES2DecoderImpl::HandleGetBufferParameteriv(
969 uint32 immediate_data_size, const gles2::GetBufferParameteriv& c) { 880 uint32 immediate_data_size, const gles2::GetBufferParameteriv& c) {
970 GLenum target = static_cast<GLenum>(c.target); 881 GLenum target = static_cast<GLenum>(c.target);
971 GLenum pname = static_cast<GLenum>(c.pname); 882 GLenum pname = static_cast<GLenum>(c.pname);
972 GLint* params; 883 GLint* params;
973 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 884 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
974 uint32 params_size = num_values * sizeof(*params); 885 uint32 params_size = num_values * sizeof(*params);
975 params = GetSharedMemoryAs<GLint*>( 886 params = GetSharedMemoryAs<GLint*>(
976 c.params_shm_id, c.params_shm_offset, params_size); 887 c.params_shm_id, c.params_shm_offset, params_size);
977 parse_error::ParseError result = 888 if (!ValidateGLenumBufferTarget(target)) {
978 ValidateGetBufferParameteriv( 889 SetGLError(GL_INVALID_VALUE);
979 this, immediate_data_size, target, pname, params); 890 return parse_error::kParseNoError;
980 if (result != parse_error::kParseNoError) { 891 }
981 return result; 892 if (!ValidateGLenumBufferParameter(pname)) {
893 SetGLError(GL_INVALID_VALUE);
894 return parse_error::kParseNoError;
895 }
896 if (params == NULL) {
897 return parse_error::kParseOutOfBounds;
982 } 898 }
983 glGetBufferParameteriv(target, pname, params); 899 glGetBufferParameteriv(target, pname, params);
984 return parse_error::kParseNoError; 900 return parse_error::kParseNoError;
985 } 901 }
986 902
987 parse_error::ParseError GLES2DecoderImpl::HandleGetError( 903 parse_error::ParseError GLES2DecoderImpl::HandleGetError(
988 uint32 immediate_data_size, const gles2::GetError& c) { 904 uint32 immediate_data_size, const gles2::GetError& c) {
989 GLenum* result_dst = GetSharedMemoryAs<GLenum*>( 905 GLenum* result_dst = GetSharedMemoryAs<GLenum*>(
990 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 906 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
991 parse_error::ParseError result =
992 ValidateGetError(this, immediate_data_size);
993 if (result != parse_error::kParseNoError) {
994 return result;
995 }
996 *result_dst = GetGLError(); 907 *result_dst = GetGLError();
997 return parse_error::kParseNoError; 908 return parse_error::kParseNoError;
998 } 909 }
999 910
1000 parse_error::ParseError GLES2DecoderImpl::HandleGetFloatv( 911 parse_error::ParseError GLES2DecoderImpl::HandleGetFloatv(
1001 uint32 immediate_data_size, const gles2::GetFloatv& c) { 912 uint32 immediate_data_size, const gles2::GetFloatv& c) {
1002 GLenum pname = static_cast<GLenum>(c.pname); 913 GLenum pname = static_cast<GLenum>(c.pname);
1003 GLfloat* params; 914 GLfloat* params;
1004 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 915 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1005 uint32 params_size = num_values * sizeof(*params); 916 uint32 params_size = num_values * sizeof(*params);
1006 params = GetSharedMemoryAs<GLfloat*>( 917 params = GetSharedMemoryAs<GLfloat*>(
1007 c.params_shm_id, c.params_shm_offset, params_size); 918 c.params_shm_id, c.params_shm_offset, params_size);
1008 parse_error::ParseError result = 919 if (params == NULL) {
1009 ValidateGetFloatv(this, immediate_data_size, pname, params); 920 return parse_error::kParseOutOfBounds;
1010 if (result != parse_error::kParseNoError) {
1011 return result;
1012 } 921 }
1013 glGetFloatv(pname, params); 922 glGetFloatv(pname, params);
1014 return parse_error::kParseNoError; 923 return parse_error::kParseNoError;
1015 } 924 }
1016 925
1017 parse_error::ParseError GLES2DecoderImpl::HandleGetFramebufferAttachmentParamete riv( 926 parse_error::ParseError GLES2DecoderImpl::HandleGetFramebufferAttachmentParamete riv(
1018 927
1019 uint32 immediate_data_size, 928 uint32 immediate_data_size,
1020 const gles2::GetFramebufferAttachmentParameteriv& c) { 929 const gles2::GetFramebufferAttachmentParameteriv& c) {
1021 GLenum target = static_cast<GLenum>(c.target); 930 GLenum target = static_cast<GLenum>(c.target);
1022 GLenum attachment = static_cast<GLenum>(c.attachment); 931 GLenum attachment = static_cast<GLenum>(c.attachment);
1023 GLenum pname = static_cast<GLenum>(c.pname); 932 GLenum pname = static_cast<GLenum>(c.pname);
1024 GLint* params; 933 GLint* params;
1025 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 934 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1026 uint32 params_size = num_values * sizeof(*params); 935 uint32 params_size = num_values * sizeof(*params);
1027 params = GetSharedMemoryAs<GLint*>( 936 params = GetSharedMemoryAs<GLint*>(
1028 c.params_shm_id, c.params_shm_offset, params_size); 937 c.params_shm_id, c.params_shm_offset, params_size);
1029 parse_error::ParseError result = 938 if (!ValidateGLenumFrameBufferTarget(target)) {
1030 ValidateGetFramebufferAttachmentParameteriv( 939 SetGLError(GL_INVALID_VALUE);
1031 this, immediate_data_size, target, attachment, pname, params); 940 return parse_error::kParseNoError;
1032 if (result != parse_error::kParseNoError) { 941 }
1033 return result; 942 if (!ValidateGLenumAttachment(attachment)) {
943 SetGLError(GL_INVALID_VALUE);
944 return parse_error::kParseNoError;
945 }
946 if (!ValidateGLenumFrameBufferParameter(pname)) {
947 SetGLError(GL_INVALID_VALUE);
948 return parse_error::kParseNoError;
949 }
950 if (params == NULL) {
951 return parse_error::kParseOutOfBounds;
1034 } 952 }
1035 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); 953 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params);
1036 return parse_error::kParseNoError; 954 return parse_error::kParseNoError;
1037 } 955 }
1038 956
1039 parse_error::ParseError GLES2DecoderImpl::HandleGetIntegerv( 957 parse_error::ParseError GLES2DecoderImpl::HandleGetIntegerv(
1040 uint32 immediate_data_size, const gles2::GetIntegerv& c) { 958 uint32 immediate_data_size, const gles2::GetIntegerv& c) {
1041 GLenum pname = static_cast<GLenum>(c.pname); 959 GLenum pname = static_cast<GLenum>(c.pname);
1042 GLint* params; 960 GLint* params;
1043 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 961 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1044 uint32 params_size = num_values * sizeof(*params); 962 uint32 params_size = num_values * sizeof(*params);
1045 params = GetSharedMemoryAs<GLint*>( 963 params = GetSharedMemoryAs<GLint*>(
1046 c.params_shm_id, c.params_shm_offset, params_size); 964 c.params_shm_id, c.params_shm_offset, params_size);
1047 parse_error::ParseError result = 965 if (params == NULL) {
1048 ValidateGetIntegerv(this, immediate_data_size, pname, params); 966 return parse_error::kParseOutOfBounds;
1049 if (result != parse_error::kParseNoError) {
1050 return result;
1051 } 967 }
1052 glGetIntegerv(pname, params); 968 glGetIntegerv(pname, params);
1053 return parse_error::kParseNoError; 969 return parse_error::kParseNoError;
1054 } 970 }
1055 971
1056 parse_error::ParseError GLES2DecoderImpl::HandleGetProgramiv( 972 parse_error::ParseError GLES2DecoderImpl::HandleGetProgramiv(
1057 uint32 immediate_data_size, const gles2::GetProgramiv& c) { 973 uint32 immediate_data_size, const gles2::GetProgramiv& c) {
1058 GLuint program; 974 GLuint program;
1059 if (!id_map_.GetServiceId(c.program, &program)) { 975 if (!id_map_.GetServiceId(c.program, &program)) {
1060 SetGLError(GL_INVALID_VALUE); 976 SetGLError(GL_INVALID_VALUE);
1061 return parse_error::kParseNoError; 977 return parse_error::kParseNoError;
1062 } 978 }
1063 GLenum pname = static_cast<GLenum>(c.pname); 979 GLenum pname = static_cast<GLenum>(c.pname);
1064 GLint* params; 980 GLint* params;
1065 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 981 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1066 uint32 params_size = num_values * sizeof(*params); 982 uint32 params_size = num_values * sizeof(*params);
1067 params = GetSharedMemoryAs<GLint*>( 983 params = GetSharedMemoryAs<GLint*>(
1068 c.params_shm_id, c.params_shm_offset, params_size); 984 c.params_shm_id, c.params_shm_offset, params_size);
1069 parse_error::ParseError result = 985 if (!ValidateGLenumProgramParameter(pname)) {
1070 ValidateGetProgramiv(this, immediate_data_size, program, pname, params); 986 SetGLError(GL_INVALID_VALUE);
1071 if (result != parse_error::kParseNoError) { 987 return parse_error::kParseNoError;
1072 return result; 988 }
989 if (params == NULL) {
990 return parse_error::kParseOutOfBounds;
1073 } 991 }
1074 glGetProgramiv(program, pname, params); 992 glGetProgramiv(program, pname, params);
1075 return parse_error::kParseNoError; 993 return parse_error::kParseNoError;
1076 } 994 }
1077 995
1078 parse_error::ParseError GLES2DecoderImpl::HandleGetProgramInfoLog( 996 parse_error::ParseError GLES2DecoderImpl::HandleGetProgramInfoLog(
1079 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) { 997 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) {
1080 GLuint program; 998 GLuint program;
1081 if (!id_map_.GetServiceId(c.program, &program)) { 999 if (!id_map_.GetServiceId(c.program, &program)) {
1082 SetGLError(GL_INVALID_VALUE); 1000 SetGLError(GL_INVALID_VALUE);
1083 return parse_error::kParseNoError; 1001 return parse_error::kParseNoError;
1084 } 1002 }
1085 GLsizei bufsize = static_cast<GLsizei>(c.bufsize); 1003 GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
1086 GLsizei* length = GetSharedMemoryAs<GLsizei*>( 1004 GLsizei* length = GetSharedMemoryAs<GLsizei*>(
1087 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); 1005 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
1088 char* infolog = GetSharedMemoryAs<char*>( 1006 char* infolog = GetSharedMemoryAs<char*>(
1089 c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */); 1007 c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */);
1090 parse_error::ParseError result = 1008 if (length == NULL) {
1091 ValidateGetProgramInfoLog( 1009 return parse_error::kParseOutOfBounds;
1092 this, immediate_data_size, program, bufsize, length, infolog); 1010 }
1093 if (result != parse_error::kParseNoError) { 1011 if (infolog == NULL) {
1094 return result; 1012 return parse_error::kParseOutOfBounds;
1095 } 1013 }
1096 glGetProgramInfoLog(program, bufsize, length, infolog); 1014 glGetProgramInfoLog(program, bufsize, length, infolog);
1097 return parse_error::kParseNoError; 1015 return parse_error::kParseNoError;
1098 } 1016 }
1099 1017
1100 parse_error::ParseError GLES2DecoderImpl::HandleGetRenderbufferParameteriv( 1018 parse_error::ParseError GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1101 uint32 immediate_data_size, const gles2::GetRenderbufferParameteriv& c) { 1019 uint32 immediate_data_size, const gles2::GetRenderbufferParameteriv& c) {
1102 GLenum target = static_cast<GLenum>(c.target); 1020 GLenum target = static_cast<GLenum>(c.target);
1103 GLenum pname = static_cast<GLenum>(c.pname); 1021 GLenum pname = static_cast<GLenum>(c.pname);
1104 GLint* params; 1022 GLint* params;
1105 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1023 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1106 uint32 params_size = num_values * sizeof(*params); 1024 uint32 params_size = num_values * sizeof(*params);
1107 params = GetSharedMemoryAs<GLint*>( 1025 params = GetSharedMemoryAs<GLint*>(
1108 c.params_shm_id, c.params_shm_offset, params_size); 1026 c.params_shm_id, c.params_shm_offset, params_size);
1109 parse_error::ParseError result = 1027 if (!ValidateGLenumRenderBufferTarget(target)) {
1110 ValidateGetRenderbufferParameteriv( 1028 SetGLError(GL_INVALID_VALUE);
1111 this, immediate_data_size, target, pname, params); 1029 return parse_error::kParseNoError;
1112 if (result != parse_error::kParseNoError) { 1030 }
1113 return result; 1031 if (!ValidateGLenumRenderBufferParameter(pname)) {
1032 SetGLError(GL_INVALID_VALUE);
1033 return parse_error::kParseNoError;
1034 }
1035 if (params == NULL) {
1036 return parse_error::kParseOutOfBounds;
1114 } 1037 }
1115 glGetRenderbufferParameterivEXT(target, pname, params); 1038 glGetRenderbufferParameterivEXT(target, pname, params);
1116 return parse_error::kParseNoError; 1039 return parse_error::kParseNoError;
1117 } 1040 }
1118 1041
1119 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderiv( 1042 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderiv(
1120 uint32 immediate_data_size, const gles2::GetShaderiv& c) { 1043 uint32 immediate_data_size, const gles2::GetShaderiv& c) {
1121 GLuint shader; 1044 GLuint shader;
1122 if (!id_map_.GetServiceId(c.shader, &shader)) { 1045 if (!id_map_.GetServiceId(c.shader, &shader)) {
1123 SetGLError(GL_INVALID_VALUE); 1046 SetGLError(GL_INVALID_VALUE);
1124 return parse_error::kParseNoError; 1047 return parse_error::kParseNoError;
1125 } 1048 }
1126 GLenum pname = static_cast<GLenum>(c.pname); 1049 GLenum pname = static_cast<GLenum>(c.pname);
1127 GLint* params; 1050 GLint* params;
1128 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1051 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1129 uint32 params_size = num_values * sizeof(*params); 1052 uint32 params_size = num_values * sizeof(*params);
1130 params = GetSharedMemoryAs<GLint*>( 1053 params = GetSharedMemoryAs<GLint*>(
1131 c.params_shm_id, c.params_shm_offset, params_size); 1054 c.params_shm_id, c.params_shm_offset, params_size);
1132 parse_error::ParseError result = 1055 if (!ValidateGLenumShaderParameter(pname)) {
1133 ValidateGetShaderiv(this, immediate_data_size, shader, pname, params); 1056 SetGLError(GL_INVALID_VALUE);
1134 if (result != parse_error::kParseNoError) { 1057 return parse_error::kParseNoError;
1135 return result; 1058 }
1059 if (params == NULL) {
1060 return parse_error::kParseOutOfBounds;
1136 } 1061 }
1137 glGetShaderiv(shader, pname, params); 1062 glGetShaderiv(shader, pname, params);
1138 return parse_error::kParseNoError; 1063 return parse_error::kParseNoError;
1139 } 1064 }
1140 1065
1141 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderInfoLog( 1066 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderInfoLog(
1142 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) { 1067 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) {
1143 GLuint shader; 1068 GLuint shader;
1144 if (!id_map_.GetServiceId(c.shader, &shader)) { 1069 if (!id_map_.GetServiceId(c.shader, &shader)) {
1145 SetGLError(GL_INVALID_VALUE); 1070 SetGLError(GL_INVALID_VALUE);
1146 return parse_error::kParseNoError; 1071 return parse_error::kParseNoError;
1147 } 1072 }
1148 GLsizei bufsize = static_cast<GLsizei>(c.bufsize); 1073 GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
1149 GLsizei* length = GetSharedMemoryAs<GLsizei*>( 1074 GLsizei* length = GetSharedMemoryAs<GLsizei*>(
1150 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); 1075 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
1151 char* infolog = GetSharedMemoryAs<char*>( 1076 char* infolog = GetSharedMemoryAs<char*>(
1152 c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */); 1077 c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */);
1153 parse_error::ParseError result = 1078 if (length == NULL) {
1154 ValidateGetShaderInfoLog( 1079 return parse_error::kParseOutOfBounds;
1155 this, immediate_data_size, shader, bufsize, length, infolog); 1080 }
1156 if (result != parse_error::kParseNoError) { 1081 if (infolog == NULL) {
1157 return result; 1082 return parse_error::kParseOutOfBounds;
1158 } 1083 }
1159 glGetShaderInfoLog(shader, bufsize, length, infolog); 1084 glGetShaderInfoLog(shader, bufsize, length, infolog);
1160 return parse_error::kParseNoError; 1085 return parse_error::kParseNoError;
1161 } 1086 }
1162 1087
1163 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderSource( 1088 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderSource(
1164 uint32 immediate_data_size, const gles2::GetShaderSource& c) { 1089 uint32 immediate_data_size, const gles2::GetShaderSource& c) {
1165 GLuint shader; 1090 GLuint shader;
1166 if (!id_map_.GetServiceId(c.shader, &shader)) { 1091 if (!id_map_.GetServiceId(c.shader, &shader)) {
1167 SetGLError(GL_INVALID_VALUE); 1092 SetGLError(GL_INVALID_VALUE);
1168 return parse_error::kParseNoError; 1093 return parse_error::kParseNoError;
1169 } 1094 }
1170 GLsizei bufsize = static_cast<GLsizei>(c.bufsize); 1095 GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
1171 GLsizei* length = GetSharedMemoryAs<GLsizei*>( 1096 GLsizei* length = GetSharedMemoryAs<GLsizei*>(
1172 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); 1097 c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
1173 char* source = GetSharedMemoryAs<char*>( 1098 char* source = GetSharedMemoryAs<char*>(
1174 c.source_shm_id, c.source_shm_offset, 0 /* TODO(gman): size */); 1099 c.source_shm_id, c.source_shm_offset, 0 /* TODO(gman): size */);
1175 parse_error::ParseError result = 1100 if (length == NULL) {
1176 ValidateGetShaderSource( 1101 return parse_error::kParseOutOfBounds;
1177 this, immediate_data_size, shader, bufsize, length, source); 1102 }
1178 if (result != parse_error::kParseNoError) { 1103 if (source == NULL) {
1179 return result; 1104 return parse_error::kParseOutOfBounds;
1180 } 1105 }
1181 glGetShaderSource(shader, bufsize, length, source); 1106 glGetShaderSource(shader, bufsize, length, source);
1182 return parse_error::kParseNoError; 1107 return parse_error::kParseNoError;
1183 } 1108 }
1184 1109
1185 parse_error::ParseError GLES2DecoderImpl::HandleGetString( 1110 parse_error::ParseError GLES2DecoderImpl::HandleGetString(
1186 uint32 immediate_data_size, const gles2::GetString& c) { 1111 uint32 immediate_data_size, const gles2::GetString& c) {
1187 GLenum name = static_cast<GLenum>(c.name); 1112 GLenum name = static_cast<GLenum>(c.name);
1188 parse_error::ParseError result = 1113 if (!ValidateGLenumStringType(name)) {
1189 ValidateGetString(this, immediate_data_size, name); 1114 SetGLError(GL_INVALID_VALUE);
1190 if (result != parse_error::kParseNoError) { 1115 return parse_error::kParseNoError;
1191 return result;
1192 } 1116 }
1193 glGetString(name); 1117 glGetString(name);
1194 return parse_error::kParseNoError; 1118 return parse_error::kParseNoError;
1195 } 1119 }
1196 1120
1197 parse_error::ParseError GLES2DecoderImpl::HandleGetTexParameterfv( 1121 parse_error::ParseError GLES2DecoderImpl::HandleGetTexParameterfv(
1198 uint32 immediate_data_size, const gles2::GetTexParameterfv& c) { 1122 uint32 immediate_data_size, const gles2::GetTexParameterfv& c) {
1199 GLenum target = static_cast<GLenum>(c.target); 1123 GLenum target = static_cast<GLenum>(c.target);
1200 GLenum pname = static_cast<GLenum>(c.pname); 1124 GLenum pname = static_cast<GLenum>(c.pname);
1201 GLfloat* params; 1125 GLfloat* params;
1202 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1126 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1203 uint32 params_size = num_values * sizeof(*params); 1127 uint32 params_size = num_values * sizeof(*params);
1204 params = GetSharedMemoryAs<GLfloat*>( 1128 params = GetSharedMemoryAs<GLfloat*>(
1205 c.params_shm_id, c.params_shm_offset, params_size); 1129 c.params_shm_id, c.params_shm_offset, params_size);
1206 parse_error::ParseError result = 1130 if (!ValidateGLenumTextureTarget(target)) {
1207 ValidateGetTexParameterfv( 1131 SetGLError(GL_INVALID_VALUE);
1208 this, immediate_data_size, target, pname, params); 1132 return parse_error::kParseNoError;
1209 if (result != parse_error::kParseNoError) { 1133 }
1210 return result; 1134 if (!ValidateGLenumTextureParameter(pname)) {
1135 SetGLError(GL_INVALID_VALUE);
1136 return parse_error::kParseNoError;
1137 }
1138 if (params == NULL) {
1139 return parse_error::kParseOutOfBounds;
1211 } 1140 }
1212 glGetTexParameterfv(target, pname, params); 1141 glGetTexParameterfv(target, pname, params);
1213 return parse_error::kParseNoError; 1142 return parse_error::kParseNoError;
1214 } 1143 }
1215 1144
1216 parse_error::ParseError GLES2DecoderImpl::HandleGetTexParameteriv( 1145 parse_error::ParseError GLES2DecoderImpl::HandleGetTexParameteriv(
1217 uint32 immediate_data_size, const gles2::GetTexParameteriv& c) { 1146 uint32 immediate_data_size, const gles2::GetTexParameteriv& c) {
1218 GLenum target = static_cast<GLenum>(c.target); 1147 GLenum target = static_cast<GLenum>(c.target);
1219 GLenum pname = static_cast<GLenum>(c.pname); 1148 GLenum pname = static_cast<GLenum>(c.pname);
1220 GLint* params; 1149 GLint* params;
1221 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1150 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1222 uint32 params_size = num_values * sizeof(*params); 1151 uint32 params_size = num_values * sizeof(*params);
1223 params = GetSharedMemoryAs<GLint*>( 1152 params = GetSharedMemoryAs<GLint*>(
1224 c.params_shm_id, c.params_shm_offset, params_size); 1153 c.params_shm_id, c.params_shm_offset, params_size);
1225 parse_error::ParseError result = 1154 if (!ValidateGLenumTextureTarget(target)) {
1226 ValidateGetTexParameteriv( 1155 SetGLError(GL_INVALID_VALUE);
1227 this, immediate_data_size, target, pname, params); 1156 return parse_error::kParseNoError;
1228 if (result != parse_error::kParseNoError) { 1157 }
1229 return result; 1158 if (!ValidateGLenumTextureParameter(pname)) {
1159 SetGLError(GL_INVALID_VALUE);
1160 return parse_error::kParseNoError;
1161 }
1162 if (params == NULL) {
1163 return parse_error::kParseOutOfBounds;
1230 } 1164 }
1231 glGetTexParameteriv(target, pname, params); 1165 glGetTexParameteriv(target, pname, params);
1232 return parse_error::kParseNoError; 1166 return parse_error::kParseNoError;
1233 } 1167 }
1234 1168
1235 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribfv( 1169 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribfv(
1236 uint32 immediate_data_size, const gles2::GetVertexAttribfv& c) { 1170 uint32 immediate_data_size, const gles2::GetVertexAttribfv& c) {
1237 GLuint index = static_cast<GLuint>(c.index); 1171 GLuint index = static_cast<GLuint>(c.index);
1238 GLenum pname = static_cast<GLenum>(c.pname); 1172 GLenum pname = static_cast<GLenum>(c.pname);
1239 GLfloat* params; 1173 GLfloat* params;
1240 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1174 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1241 uint32 params_size = num_values * sizeof(*params); 1175 uint32 params_size = num_values * sizeof(*params);
1242 params = GetSharedMemoryAs<GLfloat*>( 1176 params = GetSharedMemoryAs<GLfloat*>(
1243 c.params_shm_id, c.params_shm_offset, params_size); 1177 c.params_shm_id, c.params_shm_offset, params_size);
1244 parse_error::ParseError result = 1178 if (!ValidateGLenumVertexAttribute(pname)) {
1245 ValidateGetVertexAttribfv( 1179 SetGLError(GL_INVALID_VALUE);
1246 this, immediate_data_size, index, pname, params); 1180 return parse_error::kParseNoError;
1247 if (result != parse_error::kParseNoError) { 1181 }
1248 return result; 1182 if (params == NULL) {
1183 return parse_error::kParseOutOfBounds;
1249 } 1184 }
1250 glGetVertexAttribfv(index, pname, params); 1185 glGetVertexAttribfv(index, pname, params);
1251 return parse_error::kParseNoError; 1186 return parse_error::kParseNoError;
1252 } 1187 }
1253 1188
1254 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribiv( 1189 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribiv(
1255 uint32 immediate_data_size, const gles2::GetVertexAttribiv& c) { 1190 uint32 immediate_data_size, const gles2::GetVertexAttribiv& c) {
1256 GLuint index = static_cast<GLuint>(c.index); 1191 GLuint index = static_cast<GLuint>(c.index);
1257 GLenum pname = static_cast<GLenum>(c.pname); 1192 GLenum pname = static_cast<GLenum>(c.pname);
1258 GLint* params; 1193 GLint* params;
1259 GLsizei num_values = util_.GLGetNumValuesReturned(pname); 1194 GLsizei num_values = util_.GLGetNumValuesReturned(pname);
1260 uint32 params_size = num_values * sizeof(*params); 1195 uint32 params_size = num_values * sizeof(*params);
1261 params = GetSharedMemoryAs<GLint*>( 1196 params = GetSharedMemoryAs<GLint*>(
1262 c.params_shm_id, c.params_shm_offset, params_size); 1197 c.params_shm_id, c.params_shm_offset, params_size);
1263 parse_error::ParseError result = 1198 if (!ValidateGLenumVertexAttribute(pname)) {
1264 ValidateGetVertexAttribiv( 1199 SetGLError(GL_INVALID_VALUE);
1265 this, immediate_data_size, index, pname, params); 1200 return parse_error::kParseNoError;
1266 if (result != parse_error::kParseNoError) { 1201 }
1267 return result; 1202 if (params == NULL) {
1203 return parse_error::kParseOutOfBounds;
1268 } 1204 }
1269 glGetVertexAttribiv(index, pname, params); 1205 glGetVertexAttribiv(index, pname, params);
1270 return parse_error::kParseNoError; 1206 return parse_error::kParseNoError;
1271 } 1207 }
1272 1208
1273 parse_error::ParseError GLES2DecoderImpl::HandleHint( 1209 parse_error::ParseError GLES2DecoderImpl::HandleHint(
1274 uint32 immediate_data_size, const gles2::Hint& c) { 1210 uint32 immediate_data_size, const gles2::Hint& c) {
1275 GLenum target = static_cast<GLenum>(c.target); 1211 GLenum target = static_cast<GLenum>(c.target);
1276 GLenum mode = static_cast<GLenum>(c.mode); 1212 GLenum mode = static_cast<GLenum>(c.mode);
1277 parse_error::ParseError result = 1213 if (!ValidateGLenumHintTarget(target)) {
1278 ValidateHint(this, immediate_data_size, target, mode); 1214 SetGLError(GL_INVALID_VALUE);
1279 if (result != parse_error::kParseNoError) { 1215 return parse_error::kParseNoError;
1280 return result; 1216 }
1217 if (!ValidateGLenumHintMode(mode)) {
1218 SetGLError(GL_INVALID_VALUE);
1219 return parse_error::kParseNoError;
1281 } 1220 }
1282 glHint(target, mode); 1221 glHint(target, mode);
1283 return parse_error::kParseNoError; 1222 return parse_error::kParseNoError;
1284 } 1223 }
1285 1224
1286 parse_error::ParseError GLES2DecoderImpl::HandleIsBuffer( 1225 parse_error::ParseError GLES2DecoderImpl::HandleIsBuffer(
1287 uint32 immediate_data_size, const gles2::IsBuffer& c) { 1226 uint32 immediate_data_size, const gles2::IsBuffer& c) {
1288 GLuint buffer; 1227 GLuint buffer;
1289 if (!id_map_.GetServiceId(c.buffer, &buffer)) { 1228 if (!id_map_.GetServiceId(c.buffer, &buffer)) {
1290 SetGLError(GL_INVALID_VALUE); 1229 SetGLError(GL_INVALID_VALUE);
1291 return parse_error::kParseNoError; 1230 return parse_error::kParseNoError;
1292 } 1231 }
1293 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1232 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1294 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1233 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1295 parse_error::ParseError result =
1296 ValidateIsBuffer(this, immediate_data_size, buffer);
1297 if (result != parse_error::kParseNoError) {
1298 return result;
1299 }
1300 *result_dst = glIsBuffer(buffer); 1234 *result_dst = glIsBuffer(buffer);
1301 return parse_error::kParseNoError; 1235 return parse_error::kParseNoError;
1302 } 1236 }
1303 1237
1304 parse_error::ParseError GLES2DecoderImpl::HandleIsEnabled( 1238 parse_error::ParseError GLES2DecoderImpl::HandleIsEnabled(
1305 uint32 immediate_data_size, const gles2::IsEnabled& c) { 1239 uint32 immediate_data_size, const gles2::IsEnabled& c) {
1306 GLenum cap = static_cast<GLenum>(c.cap); 1240 GLenum cap = static_cast<GLenum>(c.cap);
1307 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1241 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1308 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1242 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1309 parse_error::ParseError result = 1243 if (!ValidateGLenumCapability(cap)) {
1310 ValidateIsEnabled(this, immediate_data_size, cap); 1244 SetGLError(GL_INVALID_VALUE);
1311 if (result != parse_error::kParseNoError) { 1245 return parse_error::kParseNoError;
1312 return result;
1313 } 1246 }
1314 *result_dst = glIsEnabled(cap); 1247 *result_dst = glIsEnabled(cap);
1315 return parse_error::kParseNoError; 1248 return parse_error::kParseNoError;
1316 } 1249 }
1317 1250
1318 parse_error::ParseError GLES2DecoderImpl::HandleIsFramebuffer( 1251 parse_error::ParseError GLES2DecoderImpl::HandleIsFramebuffer(
1319 uint32 immediate_data_size, const gles2::IsFramebuffer& c) { 1252 uint32 immediate_data_size, const gles2::IsFramebuffer& c) {
1320 GLuint framebuffer; 1253 GLuint framebuffer;
1321 if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) { 1254 if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) {
1322 SetGLError(GL_INVALID_VALUE); 1255 SetGLError(GL_INVALID_VALUE);
1323 return parse_error::kParseNoError; 1256 return parse_error::kParseNoError;
1324 } 1257 }
1325 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1258 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1326 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1259 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1327 parse_error::ParseError result =
1328 ValidateIsFramebuffer(this, immediate_data_size, framebuffer);
1329 if (result != parse_error::kParseNoError) {
1330 return result;
1331 }
1332 *result_dst = glIsFramebufferEXT(framebuffer); 1260 *result_dst = glIsFramebufferEXT(framebuffer);
1333 return parse_error::kParseNoError; 1261 return parse_error::kParseNoError;
1334 } 1262 }
1335 1263
1336 parse_error::ParseError GLES2DecoderImpl::HandleIsProgram( 1264 parse_error::ParseError GLES2DecoderImpl::HandleIsProgram(
1337 uint32 immediate_data_size, const gles2::IsProgram& c) { 1265 uint32 immediate_data_size, const gles2::IsProgram& c) {
1338 GLuint program; 1266 GLuint program;
1339 if (!id_map_.GetServiceId(c.program, &program)) { 1267 if (!id_map_.GetServiceId(c.program, &program)) {
1340 SetGLError(GL_INVALID_VALUE); 1268 SetGLError(GL_INVALID_VALUE);
1341 return parse_error::kParseNoError; 1269 return parse_error::kParseNoError;
1342 } 1270 }
1343 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1271 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1344 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1272 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1345 parse_error::ParseError result =
1346 ValidateIsProgram(this, immediate_data_size, program);
1347 if (result != parse_error::kParseNoError) {
1348 return result;
1349 }
1350 *result_dst = glIsProgram(program); 1273 *result_dst = glIsProgram(program);
1351 return parse_error::kParseNoError; 1274 return parse_error::kParseNoError;
1352 } 1275 }
1353 1276
1354 parse_error::ParseError GLES2DecoderImpl::HandleIsRenderbuffer( 1277 parse_error::ParseError GLES2DecoderImpl::HandleIsRenderbuffer(
1355 uint32 immediate_data_size, const gles2::IsRenderbuffer& c) { 1278 uint32 immediate_data_size, const gles2::IsRenderbuffer& c) {
1356 GLuint renderbuffer; 1279 GLuint renderbuffer;
1357 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) { 1280 if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
1358 SetGLError(GL_INVALID_VALUE); 1281 SetGLError(GL_INVALID_VALUE);
1359 return parse_error::kParseNoError; 1282 return parse_error::kParseNoError;
1360 } 1283 }
1361 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1284 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1362 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1285 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1363 parse_error::ParseError result =
1364 ValidateIsRenderbuffer(this, immediate_data_size, renderbuffer);
1365 if (result != parse_error::kParseNoError) {
1366 return result;
1367 }
1368 *result_dst = glIsRenderbufferEXT(renderbuffer); 1286 *result_dst = glIsRenderbufferEXT(renderbuffer);
1369 return parse_error::kParseNoError; 1287 return parse_error::kParseNoError;
1370 } 1288 }
1371 1289
1372 parse_error::ParseError GLES2DecoderImpl::HandleIsShader( 1290 parse_error::ParseError GLES2DecoderImpl::HandleIsShader(
1373 uint32 immediate_data_size, const gles2::IsShader& c) { 1291 uint32 immediate_data_size, const gles2::IsShader& c) {
1374 GLuint shader; 1292 GLuint shader;
1375 if (!id_map_.GetServiceId(c.shader, &shader)) { 1293 if (!id_map_.GetServiceId(c.shader, &shader)) {
1376 SetGLError(GL_INVALID_VALUE); 1294 SetGLError(GL_INVALID_VALUE);
1377 return parse_error::kParseNoError; 1295 return parse_error::kParseNoError;
1378 } 1296 }
1379 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1297 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1380 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1298 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1381 parse_error::ParseError result =
1382 ValidateIsShader(this, immediate_data_size, shader);
1383 if (result != parse_error::kParseNoError) {
1384 return result;
1385 }
1386 *result_dst = glIsShader(shader); 1299 *result_dst = glIsShader(shader);
1387 return parse_error::kParseNoError; 1300 return parse_error::kParseNoError;
1388 } 1301 }
1389 1302
1390 parse_error::ParseError GLES2DecoderImpl::HandleIsTexture( 1303 parse_error::ParseError GLES2DecoderImpl::HandleIsTexture(
1391 uint32 immediate_data_size, const gles2::IsTexture& c) { 1304 uint32 immediate_data_size, const gles2::IsTexture& c) {
1392 GLuint texture; 1305 GLuint texture;
1393 if (!id_map_.GetServiceId(c.texture, &texture)) { 1306 if (!id_map_.GetServiceId(c.texture, &texture)) {
1394 SetGLError(GL_INVALID_VALUE); 1307 SetGLError(GL_INVALID_VALUE);
1395 return parse_error::kParseNoError; 1308 return parse_error::kParseNoError;
1396 } 1309 }
1397 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( 1310 GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
1398 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); 1311 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1399 parse_error::ParseError result =
1400 ValidateIsTexture(this, immediate_data_size, texture);
1401 if (result != parse_error::kParseNoError) {
1402 return result;
1403 }
1404 *result_dst = glIsTexture(texture); 1312 *result_dst = glIsTexture(texture);
1405 return parse_error::kParseNoError; 1313 return parse_error::kParseNoError;
1406 } 1314 }
1407 1315
1408 parse_error::ParseError GLES2DecoderImpl::HandleLineWidth( 1316 parse_error::ParseError GLES2DecoderImpl::HandleLineWidth(
1409 uint32 immediate_data_size, const gles2::LineWidth& c) { 1317 uint32 immediate_data_size, const gles2::LineWidth& c) {
1410 GLfloat width = static_cast<GLfloat>(c.width); 1318 GLfloat width = static_cast<GLfloat>(c.width);
1411 parse_error::ParseError result =
1412 ValidateLineWidth(this, immediate_data_size, width);
1413 if (result != parse_error::kParseNoError) {
1414 return result;
1415 }
1416 glLineWidth(width); 1319 glLineWidth(width);
1417 return parse_error::kParseNoError; 1320 return parse_error::kParseNoError;
1418 } 1321 }
1419 1322
1420 parse_error::ParseError GLES2DecoderImpl::HandleLinkProgram( 1323 parse_error::ParseError GLES2DecoderImpl::HandleLinkProgram(
1421 uint32 immediate_data_size, const gles2::LinkProgram& c) { 1324 uint32 immediate_data_size, const gles2::LinkProgram& c) {
1422 GLuint program; 1325 GLuint program;
1423 if (!id_map_.GetServiceId(c.program, &program)) { 1326 if (!id_map_.GetServiceId(c.program, &program)) {
1424 SetGLError(GL_INVALID_VALUE); 1327 SetGLError(GL_INVALID_VALUE);
1425 return parse_error::kParseNoError; 1328 return parse_error::kParseNoError;
1426 } 1329 }
1427 parse_error::ParseError result =
1428 ValidateLinkProgram(this, immediate_data_size, program);
1429 if (result != parse_error::kParseNoError) {
1430 return result;
1431 }
1432 glLinkProgram(program); 1330 glLinkProgram(program);
1433 return parse_error::kParseNoError; 1331 return parse_error::kParseNoError;
1434 } 1332 }
1435 1333
1436 parse_error::ParseError GLES2DecoderImpl::HandlePolygonOffset( 1334 parse_error::ParseError GLES2DecoderImpl::HandlePolygonOffset(
1437 uint32 immediate_data_size, const gles2::PolygonOffset& c) { 1335 uint32 immediate_data_size, const gles2::PolygonOffset& c) {
1438 GLfloat factor = static_cast<GLfloat>(c.factor); 1336 GLfloat factor = static_cast<GLfloat>(c.factor);
1439 GLfloat units = static_cast<GLfloat>(c.units); 1337 GLfloat units = static_cast<GLfloat>(c.units);
1440 parse_error::ParseError result =
1441 ValidatePolygonOffset(this, immediate_data_size, factor, units);
1442 if (result != parse_error::kParseNoError) {
1443 return result;
1444 }
1445 glPolygonOffset(factor, units); 1338 glPolygonOffset(factor, units);
1446 return parse_error::kParseNoError; 1339 return parse_error::kParseNoError;
1447 } 1340 }
1448 1341
1449 parse_error::ParseError GLES2DecoderImpl::HandleRenderbufferStorage( 1342 parse_error::ParseError GLES2DecoderImpl::HandleRenderbufferStorage(
1450 uint32 immediate_data_size, const gles2::RenderbufferStorage& c) { 1343 uint32 immediate_data_size, const gles2::RenderbufferStorage& c) {
1451 GLenum target = static_cast<GLenum>(c.target); 1344 GLenum target = static_cast<GLenum>(c.target);
1452 GLenum internalformat = static_cast<GLenum>(c.internalformat); 1345 GLenum internalformat = static_cast<GLenum>(c.internalformat);
1453 GLsizei width = static_cast<GLsizei>(c.width); 1346 GLsizei width = static_cast<GLsizei>(c.width);
1454 GLsizei height = static_cast<GLsizei>(c.height); 1347 GLsizei height = static_cast<GLsizei>(c.height);
1455 parse_error::ParseError result = 1348 if (!ValidateGLenumRenderBufferTarget(target)) {
1456 ValidateRenderbufferStorage( 1349 SetGLError(GL_INVALID_VALUE);
1457 this, immediate_data_size, target, internalformat, width, height); 1350 return parse_error::kParseNoError;
1458 if (result != parse_error::kParseNoError) { 1351 }
1459 return result; 1352 if (!ValidateGLenumRenderBufferFormat(internalformat)) {
1353 SetGLError(GL_INVALID_VALUE);
1354 return parse_error::kParseNoError;
1460 } 1355 }
1461 glRenderbufferStorageEXT(target, internalformat, width, height); 1356 glRenderbufferStorageEXT(target, internalformat, width, height);
1462 return parse_error::kParseNoError; 1357 return parse_error::kParseNoError;
1463 } 1358 }
1464 1359
1465 parse_error::ParseError GLES2DecoderImpl::HandleSampleCoverage( 1360 parse_error::ParseError GLES2DecoderImpl::HandleSampleCoverage(
1466 uint32 immediate_data_size, const gles2::SampleCoverage& c) { 1361 uint32 immediate_data_size, const gles2::SampleCoverage& c) {
1467 GLclampf value = static_cast<GLclampf>(c.value); 1362 GLclampf value = static_cast<GLclampf>(c.value);
1468 GLboolean invert = static_cast<GLboolean>(c.invert); 1363 GLboolean invert = static_cast<GLboolean>(c.invert);
1469 parse_error::ParseError result =
1470 ValidateSampleCoverage(this, immediate_data_size, value, invert);
1471 if (result != parse_error::kParseNoError) {
1472 return result;
1473 }
1474 glSampleCoverage(value, invert); 1364 glSampleCoverage(value, invert);
1475 return parse_error::kParseNoError; 1365 return parse_error::kParseNoError;
1476 } 1366 }
1477 1367
1478 parse_error::ParseError GLES2DecoderImpl::HandleScissor( 1368 parse_error::ParseError GLES2DecoderImpl::HandleScissor(
1479 uint32 immediate_data_size, const gles2::Scissor& c) { 1369 uint32 immediate_data_size, const gles2::Scissor& c) {
1480 GLint x = static_cast<GLint>(c.x); 1370 GLint x = static_cast<GLint>(c.x);
1481 GLint y = static_cast<GLint>(c.y); 1371 GLint y = static_cast<GLint>(c.y);
1482 GLsizei width = static_cast<GLsizei>(c.width); 1372 GLsizei width = static_cast<GLsizei>(c.width);
1483 GLsizei height = static_cast<GLsizei>(c.height); 1373 GLsizei height = static_cast<GLsizei>(c.height);
1484 parse_error::ParseError result =
1485 ValidateScissor(this, immediate_data_size, x, y, width, height);
1486 if (result != parse_error::kParseNoError) {
1487 return result;
1488 }
1489 glScissor(x, y, width, height); 1374 glScissor(x, y, width, height);
1490 return parse_error::kParseNoError; 1375 return parse_error::kParseNoError;
1491 } 1376 }
1492 1377
1493 parse_error::ParseError GLES2DecoderImpl::HandleStencilFunc( 1378 parse_error::ParseError GLES2DecoderImpl::HandleStencilFunc(
1494 uint32 immediate_data_size, const gles2::StencilFunc& c) { 1379 uint32 immediate_data_size, const gles2::StencilFunc& c) {
1495 GLenum func = static_cast<GLenum>(c.func); 1380 GLenum func = static_cast<GLenum>(c.func);
1496 GLint ref = static_cast<GLint>(c.ref); 1381 GLint ref = static_cast<GLint>(c.ref);
1497 GLuint mask = static_cast<GLuint>(c.mask); 1382 GLuint mask = static_cast<GLuint>(c.mask);
1498 parse_error::ParseError result = 1383 if (!ValidateGLenumCmpFunction(func)) {
1499 ValidateStencilFunc(this, immediate_data_size, func, ref, mask); 1384 SetGLError(GL_INVALID_VALUE);
1500 if (result != parse_error::kParseNoError) { 1385 return parse_error::kParseNoError;
1501 return result;
1502 } 1386 }
1503 glStencilFunc(func, ref, mask); 1387 glStencilFunc(func, ref, mask);
1504 return parse_error::kParseNoError; 1388 return parse_error::kParseNoError;
1505 } 1389 }
1506 1390
1507 parse_error::ParseError GLES2DecoderImpl::HandleStencilFuncSeparate( 1391 parse_error::ParseError GLES2DecoderImpl::HandleStencilFuncSeparate(
1508 uint32 immediate_data_size, const gles2::StencilFuncSeparate& c) { 1392 uint32 immediate_data_size, const gles2::StencilFuncSeparate& c) {
1509 GLenum face = static_cast<GLenum>(c.face); 1393 GLenum face = static_cast<GLenum>(c.face);
1510 GLenum func = static_cast<GLenum>(c.func); 1394 GLenum func = static_cast<GLenum>(c.func);
1511 GLint ref = static_cast<GLint>(c.ref); 1395 GLint ref = static_cast<GLint>(c.ref);
1512 GLuint mask = static_cast<GLuint>(c.mask); 1396 GLuint mask = static_cast<GLuint>(c.mask);
1513 parse_error::ParseError result = 1397 if (!ValidateGLenumFaceType(face)) {
1514 ValidateStencilFuncSeparate( 1398 SetGLError(GL_INVALID_VALUE);
1515 this, immediate_data_size, face, func, ref, mask); 1399 return parse_error::kParseNoError;
1516 if (result != parse_error::kParseNoError) { 1400 }
1517 return result; 1401 if (!ValidateGLenumCmpFunction(func)) {
1402 SetGLError(GL_INVALID_VALUE);
1403 return parse_error::kParseNoError;
1518 } 1404 }
1519 glStencilFuncSeparate(face, func, ref, mask); 1405 glStencilFuncSeparate(face, func, ref, mask);
1520 return parse_error::kParseNoError; 1406 return parse_error::kParseNoError;
1521 } 1407 }
1522 1408
1523 parse_error::ParseError GLES2DecoderImpl::HandleStencilMask( 1409 parse_error::ParseError GLES2DecoderImpl::HandleStencilMask(
1524 uint32 immediate_data_size, const gles2::StencilMask& c) { 1410 uint32 immediate_data_size, const gles2::StencilMask& c) {
1525 GLuint mask = static_cast<GLuint>(c.mask); 1411 GLuint mask = static_cast<GLuint>(c.mask);
1526 parse_error::ParseError result =
1527 ValidateStencilMask(this, immediate_data_size, mask);
1528 if (result != parse_error::kParseNoError) {
1529 return result;
1530 }
1531 glStencilMask(mask); 1412 glStencilMask(mask);
1532 return parse_error::kParseNoError; 1413 return parse_error::kParseNoError;
1533 } 1414 }
1534 1415
1535 parse_error::ParseError GLES2DecoderImpl::HandleStencilMaskSeparate( 1416 parse_error::ParseError GLES2DecoderImpl::HandleStencilMaskSeparate(
1536 uint32 immediate_data_size, const gles2::StencilMaskSeparate& c) { 1417 uint32 immediate_data_size, const gles2::StencilMaskSeparate& c) {
1537 GLenum face = static_cast<GLenum>(c.face); 1418 GLenum face = static_cast<GLenum>(c.face);
1538 GLuint mask = static_cast<GLuint>(c.mask); 1419 GLuint mask = static_cast<GLuint>(c.mask);
1539 parse_error::ParseError result = 1420 if (!ValidateGLenumFaceType(face)) {
1540 ValidateStencilMaskSeparate(this, immediate_data_size, face, mask); 1421 SetGLError(GL_INVALID_VALUE);
1541 if (result != parse_error::kParseNoError) { 1422 return parse_error::kParseNoError;
1542 return result;
1543 } 1423 }
1544 glStencilMaskSeparate(face, mask); 1424 glStencilMaskSeparate(face, mask);
1545 return parse_error::kParseNoError; 1425 return parse_error::kParseNoError;
1546 } 1426 }
1547 1427
1548 parse_error::ParseError GLES2DecoderImpl::HandleStencilOp( 1428 parse_error::ParseError GLES2DecoderImpl::HandleStencilOp(
1549 uint32 immediate_data_size, const gles2::StencilOp& c) { 1429 uint32 immediate_data_size, const gles2::StencilOp& c) {
1550 GLenum fail = static_cast<GLenum>(c.fail); 1430 GLenum fail = static_cast<GLenum>(c.fail);
1551 GLenum zfail = static_cast<GLenum>(c.zfail); 1431 GLenum zfail = static_cast<GLenum>(c.zfail);
1552 GLenum zpass = static_cast<GLenum>(c.zpass); 1432 GLenum zpass = static_cast<GLenum>(c.zpass);
1553 parse_error::ParseError result = 1433 if (!ValidateGLenumStencilOp(fail)) {
1554 ValidateStencilOp(this, immediate_data_size, fail, zfail, zpass); 1434 SetGLError(GL_INVALID_VALUE);
1555 if (result != parse_error::kParseNoError) { 1435 return parse_error::kParseNoError;
1556 return result; 1436 }
1437 if (!ValidateGLenumStencilOp(zfail)) {
1438 SetGLError(GL_INVALID_VALUE);
1439 return parse_error::kParseNoError;
1440 }
1441 if (!ValidateGLenumStencilOp(zpass)) {
1442 SetGLError(GL_INVALID_VALUE);
1443 return parse_error::kParseNoError;
1557 } 1444 }
1558 glStencilOp(fail, zfail, zpass); 1445 glStencilOp(fail, zfail, zpass);
1559 return parse_error::kParseNoError; 1446 return parse_error::kParseNoError;
1560 } 1447 }
1561 1448
1562 parse_error::ParseError GLES2DecoderImpl::HandleStencilOpSeparate( 1449 parse_error::ParseError GLES2DecoderImpl::HandleStencilOpSeparate(
1563 uint32 immediate_data_size, const gles2::StencilOpSeparate& c) { 1450 uint32 immediate_data_size, const gles2::StencilOpSeparate& c) {
1564 GLenum face = static_cast<GLenum>(c.face); 1451 GLenum face = static_cast<GLenum>(c.face);
1565 GLenum fail = static_cast<GLenum>(c.fail); 1452 GLenum fail = static_cast<GLenum>(c.fail);
1566 GLenum zfail = static_cast<GLenum>(c.zfail); 1453 GLenum zfail = static_cast<GLenum>(c.zfail);
1567 GLenum zpass = static_cast<GLenum>(c.zpass); 1454 GLenum zpass = static_cast<GLenum>(c.zpass);
1568 parse_error::ParseError result = 1455 if (!ValidateGLenumFaceType(face)) {
1569 ValidateStencilOpSeparate( 1456 SetGLError(GL_INVALID_VALUE);
1570 this, immediate_data_size, face, fail, zfail, zpass); 1457 return parse_error::kParseNoError;
1571 if (result != parse_error::kParseNoError) { 1458 }
1572 return result; 1459 if (!ValidateGLenumStencilOp(fail)) {
1460 SetGLError(GL_INVALID_VALUE);
1461 return parse_error::kParseNoError;
1462 }
1463 if (!ValidateGLenumStencilOp(zfail)) {
1464 SetGLError(GL_INVALID_VALUE);
1465 return parse_error::kParseNoError;
1466 }
1467 if (!ValidateGLenumStencilOp(zpass)) {
1468 SetGLError(GL_INVALID_VALUE);
1469 return parse_error::kParseNoError;
1573 } 1470 }
1574 glStencilOpSeparate(face, fail, zfail, zpass); 1471 glStencilOpSeparate(face, fail, zfail, zpass);
1575 return parse_error::kParseNoError; 1472 return parse_error::kParseNoError;
1576 } 1473 }
1577 1474
1578 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterf( 1475 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterf(
1579 uint32 immediate_data_size, const gles2::TexParameterf& c) { 1476 uint32 immediate_data_size, const gles2::TexParameterf& c) {
1580 GLenum target = static_cast<GLenum>(c.target); 1477 GLenum target = static_cast<GLenum>(c.target);
1581 GLenum pname = static_cast<GLenum>(c.pname); 1478 GLenum pname = static_cast<GLenum>(c.pname);
1582 GLfloat param = static_cast<GLfloat>(c.param); 1479 GLfloat param = static_cast<GLfloat>(c.param);
1583 parse_error::ParseError result = 1480 if (!ValidateGLenumTextureBindTarget(target)) {
1584 ValidateTexParameterf(this, immediate_data_size, target, pname, param); 1481 SetGLError(GL_INVALID_VALUE);
1585 if (result != parse_error::kParseNoError) { 1482 return parse_error::kParseNoError;
1586 return result; 1483 }
1484 if (!ValidateGLenumTextureParameter(pname)) {
1485 SetGLError(GL_INVALID_VALUE);
1486 return parse_error::kParseNoError;
1587 } 1487 }
1588 glTexParameterf(target, pname, param); 1488 glTexParameterf(target, pname, param);
1589 return parse_error::kParseNoError; 1489 return parse_error::kParseNoError;
1590 } 1490 }
1591 1491
1592 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterfv( 1492 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterfv(
1593 uint32 immediate_data_size, const gles2::TexParameterfv& c) { 1493 uint32 immediate_data_size, const gles2::TexParameterfv& c) {
1594 GLenum target = static_cast<GLenum>(c.target); 1494 GLenum target = static_cast<GLenum>(c.target);
1595 GLenum pname = static_cast<GLenum>(c.pname); 1495 GLenum pname = static_cast<GLenum>(c.pname);
1596 const GLfloat* params = GetSharedMemoryAs<const GLfloat*>( 1496 const GLfloat* params = GetSharedMemoryAs<const GLfloat*>(
1597 c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */); 1497 c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */);
1598 parse_error::ParseError result = 1498 if (!ValidateGLenumTextureBindTarget(target)) {
1599 ValidateTexParameterfv(this, immediate_data_size, target, pname, params); 1499 SetGLError(GL_INVALID_VALUE);
1600 if (result != parse_error::kParseNoError) { 1500 return parse_error::kParseNoError;
1601 return result; 1501 }
1502 if (!ValidateGLenumTextureParameter(pname)) {
1503 SetGLError(GL_INVALID_VALUE);
1504 return parse_error::kParseNoError;
1505 }
1506 if (params == NULL) {
1507 return parse_error::kParseOutOfBounds;
1602 } 1508 }
1603 glTexParameterfv(target, pname, params); 1509 glTexParameterfv(target, pname, params);
1604 return parse_error::kParseNoError; 1510 return parse_error::kParseNoError;
1605 } 1511 }
1606 1512
1607 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterfvImmediate( 1513 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterfvImmediate(
1608 uint32 immediate_data_size, const gles2::TexParameterfvImmediate& c) { 1514 uint32 immediate_data_size, const gles2::TexParameterfvImmediate& c) {
1609 GLenum target = static_cast<GLenum>(c.target); 1515 GLenum target = static_cast<GLenum>(c.target);
1610 GLenum pname = static_cast<GLenum>(c.pname); 1516 GLenum pname = static_cast<GLenum>(c.pname);
1611 const GLfloat* params = GetImmediateDataAs<const GLfloat*>(c); 1517 const GLfloat* params = GetImmediateDataAs<const GLfloat*>(c);
1518 if (!ValidateGLenumTextureBindTarget(target)) {
1519 SetGLError(GL_INVALID_VALUE);
1520 return parse_error::kParseNoError;
1521 }
1522 if (!ValidateGLenumTextureParameter(pname)) {
1523 SetGLError(GL_INVALID_VALUE);
1524 return parse_error::kParseNoError;
1525 }
1526 if (params == NULL) {
1527 return parse_error::kParseOutOfBounds;
1528 }
1529 if (!CheckImmediateDataSize<TexParameterfvImmediate>(
1530 immediate_data_size, 1, sizeof(GLfloat), 1)) {
1531 return parse_error::kParseOutOfBounds;
1532 }
1612 // Immediate version. 1533 // Immediate version.
1613 parse_error::ParseError result = 1534 if (!ValidateGLenumTextureBindTarget(target)) {
1614 ValidateTexParameterfvImmediate( 1535 SetGLError(GL_INVALID_VALUE);
1615 this, immediate_data_size, target, pname, params); 1536 return parse_error::kParseNoError;
1616 if (result != parse_error::kParseNoError) { 1537 }
1617 return result; 1538 if (!ValidateGLenumTextureParameter(pname)) {
1539 SetGLError(GL_INVALID_VALUE);
1540 return parse_error::kParseNoError;
1541 }
1542 if (params == NULL) {
1543 return parse_error::kParseOutOfBounds;
1544 }
1545 if (!CheckImmediateDataSize<TexParameterfvImmediate>(
1546 immediate_data_size, 1, sizeof(GLfloat), 1)) {
1547 return parse_error::kParseOutOfBounds;
1618 } 1548 }
1619 glTexParameterfv(target, pname, params); 1549 glTexParameterfv(target, pname, params);
1620 return parse_error::kParseNoError; 1550 return parse_error::kParseNoError;
1621 } 1551 }
1622 1552
1623 parse_error::ParseError GLES2DecoderImpl::HandleTexParameteri( 1553 parse_error::ParseError GLES2DecoderImpl::HandleTexParameteri(
1624 uint32 immediate_data_size, const gles2::TexParameteri& c) { 1554 uint32 immediate_data_size, const gles2::TexParameteri& c) {
1625 GLenum target = static_cast<GLenum>(c.target); 1555 GLenum target = static_cast<GLenum>(c.target);
1626 GLenum pname = static_cast<GLenum>(c.pname); 1556 GLenum pname = static_cast<GLenum>(c.pname);
1627 GLint param = static_cast<GLint>(c.param); 1557 GLint param = static_cast<GLint>(c.param);
1628 parse_error::ParseError result = 1558 if (!ValidateGLenumTextureBindTarget(target)) {
1629 ValidateTexParameteri(this, immediate_data_size, target, pname, param); 1559 SetGLError(GL_INVALID_VALUE);
1630 if (result != parse_error::kParseNoError) { 1560 return parse_error::kParseNoError;
1631 return result; 1561 }
1562 if (!ValidateGLenumTextureParameter(pname)) {
1563 SetGLError(GL_INVALID_VALUE);
1564 return parse_error::kParseNoError;
1632 } 1565 }
1633 glTexParameteri(target, pname, param); 1566 glTexParameteri(target, pname, param);
1634 return parse_error::kParseNoError; 1567 return parse_error::kParseNoError;
1635 } 1568 }
1636 1569
1637 parse_error::ParseError GLES2DecoderImpl::HandleTexParameteriv( 1570 parse_error::ParseError GLES2DecoderImpl::HandleTexParameteriv(
1638 uint32 immediate_data_size, const gles2::TexParameteriv& c) { 1571 uint32 immediate_data_size, const gles2::TexParameteriv& c) {
1639 GLenum target = static_cast<GLenum>(c.target); 1572 GLenum target = static_cast<GLenum>(c.target);
1640 GLenum pname = static_cast<GLenum>(c.pname); 1573 GLenum pname = static_cast<GLenum>(c.pname);
1641 const GLint* params = GetSharedMemoryAs<const GLint*>( 1574 const GLint* params = GetSharedMemoryAs<const GLint*>(
1642 c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */); 1575 c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */);
1643 parse_error::ParseError result = 1576 if (!ValidateGLenumTextureBindTarget(target)) {
1644 ValidateTexParameteriv(this, immediate_data_size, target, pname, params); 1577 SetGLError(GL_INVALID_VALUE);
1645 if (result != parse_error::kParseNoError) { 1578 return parse_error::kParseNoError;
1646 return result; 1579 }
1580 if (!ValidateGLenumTextureParameter(pname)) {
1581 SetGLError(GL_INVALID_VALUE);
1582 return parse_error::kParseNoError;
1583 }
1584 if (params == NULL) {
1585 return parse_error::kParseOutOfBounds;
1647 } 1586 }
1648 glTexParameteriv(target, pname, params); 1587 glTexParameteriv(target, pname, params);
1649 return parse_error::kParseNoError; 1588 return parse_error::kParseNoError;
1650 } 1589 }
1651 1590
1652 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterivImmediate( 1591 parse_error::ParseError GLES2DecoderImpl::HandleTexParameterivImmediate(
1653 uint32 immediate_data_size, const gles2::TexParameterivImmediate& c) { 1592 uint32 immediate_data_size, const gles2::TexParameterivImmediate& c) {
1654 GLenum target = static_cast<GLenum>(c.target); 1593 GLenum target = static_cast<GLenum>(c.target);
1655 GLenum pname = static_cast<GLenum>(c.pname); 1594 GLenum pname = static_cast<GLenum>(c.pname);
1656 const GLint* params = GetImmediateDataAs<const GLint*>(c); 1595 const GLint* params = GetImmediateDataAs<const GLint*>(c);
1596 if (!ValidateGLenumTextureBindTarget(target)) {
1597 SetGLError(GL_INVALID_VALUE);
1598 return parse_error::kParseNoError;
1599 }
1600 if (!ValidateGLenumTextureParameter(pname)) {
1601 SetGLError(GL_INVALID_VALUE);
1602 return parse_error::kParseNoError;
1603 }
1604 if (params == NULL) {
1605 return parse_error::kParseOutOfBounds;
1606 }
1607 if (!CheckImmediateDataSize<TexParameterivImmediate>(
1608 immediate_data_size, 1, sizeof(GLint), 1)) {
1609 return parse_error::kParseOutOfBounds;
1610 }
1657 // Immediate version. 1611 // Immediate version.
1658 parse_error::ParseError result = 1612 if (!ValidateGLenumTextureBindTarget(target)) {
1659 ValidateTexParameterivImmediate( 1613 SetGLError(GL_INVALID_VALUE);
1660 this, immediate_data_size, target, pname, params); 1614 return parse_error::kParseNoError;
1661 if (result != parse_error::kParseNoError) { 1615 }
1662 return result; 1616 if (!ValidateGLenumTextureParameter(pname)) {
1617 SetGLError(GL_INVALID_VALUE);
1618 return parse_error::kParseNoError;
1619 }
1620 if (params == NULL) {
1621 return parse_error::kParseOutOfBounds;
1622 }
1623 if (!CheckImmediateDataSize<TexParameterivImmediate>(
1624 immediate_data_size, 1, sizeof(GLint), 1)) {
1625 return parse_error::kParseOutOfBounds;
1663 } 1626 }
1664 glTexParameteriv(target, pname, params); 1627 glTexParameteriv(target, pname, params);
1665 return parse_error::kParseNoError; 1628 return parse_error::kParseNoError;
1666 } 1629 }
1667 1630
1668 parse_error::ParseError GLES2DecoderImpl::HandleTexSubImage2D( 1631 parse_error::ParseError GLES2DecoderImpl::HandleTexSubImage2D(
1669 uint32 immediate_data_size, const gles2::TexSubImage2D& c) { 1632 uint32 immediate_data_size, const gles2::TexSubImage2D& c) {
1670 GLenum target = static_cast<GLenum>(c.target); 1633 GLenum target = static_cast<GLenum>(c.target);
1671 GLint level = static_cast<GLint>(c.level); 1634 GLint level = static_cast<GLint>(c.level);
1672 GLint xoffset = static_cast<GLint>(c.xoffset); 1635 GLint xoffset = static_cast<GLint>(c.xoffset);
1673 GLint yoffset = static_cast<GLint>(c.yoffset); 1636 GLint yoffset = static_cast<GLint>(c.yoffset);
1674 GLsizei width = static_cast<GLsizei>(c.width); 1637 GLsizei width = static_cast<GLsizei>(c.width);
1675 GLsizei height = static_cast<GLsizei>(c.height); 1638 GLsizei height = static_cast<GLsizei>(c.height);
1676 GLenum format = static_cast<GLenum>(c.format); 1639 GLenum format = static_cast<GLenum>(c.format);
1677 GLenum type = static_cast<GLenum>(c.type); 1640 GLenum type = static_cast<GLenum>(c.type);
1678 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); 1641 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id);
1679 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); 1642 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset);
1680 uint32 pixels_size = GLES2Util::ComputeImageDataSize( 1643 uint32 pixels_size = GLES2Util::ComputeImageDataSize(
1681 width, height, format, type, unpack_alignment_); 1644 width, height, format, type, unpack_alignment_);
1682 const void* pixels = GetSharedMemoryAs<const void*>( 1645 const void* pixels = GetSharedMemoryAs<const void*>(
1683 pixels_shm_id, pixels_shm_offset, pixels_size); 1646 pixels_shm_id, pixels_shm_offset, pixels_size);
1684 parse_error::ParseError result = 1647 if (!ValidateGLenumTextureTarget(target)) {
1685 ValidateTexSubImage2D( 1648 SetGLError(GL_INVALID_VALUE);
1686 this, immediate_data_size, target, level, xoffset, yoffset, width, 1649 return parse_error::kParseNoError;
1687 height, format, type, pixels); 1650 }
1688 if (result != parse_error::kParseNoError) { 1651 if (!ValidateGLenumTextureFormat(format)) {
1689 return result; 1652 SetGLError(GL_INVALID_VALUE);
1653 return parse_error::kParseNoError;
1654 }
1655 if (!ValidateGLenumPixelType(type)) {
1656 SetGLError(GL_INVALID_VALUE);
1657 return parse_error::kParseNoError;
1658 }
1659 if (pixels == NULL) {
1660 return parse_error::kParseOutOfBounds;
1690 } 1661 }
1691 glTexSubImage2D( 1662 glTexSubImage2D(
1692 target, level, xoffset, yoffset, width, height, format, type, pixels); 1663 target, level, xoffset, yoffset, width, height, format, type, pixels);
1693 return parse_error::kParseNoError; 1664 return parse_error::kParseNoError;
1694 } 1665 }
1695 1666
1696 parse_error::ParseError GLES2DecoderImpl::HandleTexSubImage2DImmediate( 1667 parse_error::ParseError GLES2DecoderImpl::HandleTexSubImage2DImmediate(
1697 uint32 immediate_data_size, const gles2::TexSubImage2DImmediate& c) { 1668 uint32 immediate_data_size, const gles2::TexSubImage2DImmediate& c) {
1698 GLenum target = static_cast<GLenum>(c.target); 1669 GLenum target = static_cast<GLenum>(c.target);
1699 GLint level = static_cast<GLint>(c.level); 1670 GLint level = static_cast<GLint>(c.level);
1700 GLint xoffset = static_cast<GLint>(c.xoffset); 1671 GLint xoffset = static_cast<GLint>(c.xoffset);
1701 GLint yoffset = static_cast<GLint>(c.yoffset); 1672 GLint yoffset = static_cast<GLint>(c.yoffset);
1702 GLsizei width = static_cast<GLsizei>(c.width); 1673 GLsizei width = static_cast<GLsizei>(c.width);
1703 GLsizei height = static_cast<GLsizei>(c.height); 1674 GLsizei height = static_cast<GLsizei>(c.height);
1704 GLenum format = static_cast<GLenum>(c.format); 1675 GLenum format = static_cast<GLenum>(c.format);
1705 GLenum type = static_cast<GLenum>(c.type); 1676 GLenum type = static_cast<GLenum>(c.type);
1706 const void* pixels = GetImmediateDataAs<const void*>(c); 1677 const void* pixels = GetImmediateDataAs<const void*>(c);
1678 if (!ValidateGLenumTextureTarget(target)) {
1679 SetGLError(GL_INVALID_VALUE);
1680 return parse_error::kParseNoError;
1681 }
1682 if (!ValidateGLenumTextureFormat(format)) {
1683 SetGLError(GL_INVALID_VALUE);
1684 return parse_error::kParseNoError;
1685 }
1686 if (!ValidateGLenumPixelType(type)) {
1687 SetGLError(GL_INVALID_VALUE);
1688 return parse_error::kParseNoError;
1689 }
1690 if (pixels == NULL) {
1691 return parse_error::kParseOutOfBounds;
1692 }
1707 // Immediate version. 1693 // Immediate version.
1708 parse_error::ParseError result = 1694 if (!ValidateGLenumTextureTarget(target)) {
1709 ValidateTexSubImage2DImmediate( 1695 SetGLError(GL_INVALID_VALUE);
1710 this, immediate_data_size, target, level, xoffset, yoffset, width, 1696 return parse_error::kParseNoError;
1711 height, format, type, pixels); 1697 }
1712 if (result != parse_error::kParseNoError) { 1698 if (!ValidateGLenumTextureFormat(format)) {
1713 return result; 1699 SetGLError(GL_INVALID_VALUE);
1700 return parse_error::kParseNoError;
1701 }
1702 if (!ValidateGLenumPixelType(type)) {
1703 SetGLError(GL_INVALID_VALUE);
1704 return parse_error::kParseNoError;
1705 }
1706 if (pixels == NULL) {
1707 return parse_error::kParseOutOfBounds;
1714 } 1708 }
1715 glTexSubImage2D( 1709 glTexSubImage2D(
1716 target, level, xoffset, yoffset, width, height, format, type, pixels); 1710 target, level, xoffset, yoffset, width, height, format, type, pixels);
1717 return parse_error::kParseNoError; 1711 return parse_error::kParseNoError;
1718 } 1712 }
1719 1713
1720 parse_error::ParseError GLES2DecoderImpl::HandleUniform1f( 1714 parse_error::ParseError GLES2DecoderImpl::HandleUniform1f(
1721 uint32 immediate_data_size, const gles2::Uniform1f& c) { 1715 uint32 immediate_data_size, const gles2::Uniform1f& c) {
1722 GLint location = static_cast<GLint>(c.location); 1716 GLint location = static_cast<GLint>(c.location);
1723 GLfloat x = static_cast<GLfloat>(c.x); 1717 GLfloat x = static_cast<GLfloat>(c.x);
1724 parse_error::ParseError result =
1725 ValidateUniform1f(this, immediate_data_size, location, x);
1726 if (result != parse_error::kParseNoError) {
1727 return result;
1728 }
1729 glUniform1f(location, x); 1718 glUniform1f(location, x);
1730 return parse_error::kParseNoError; 1719 return parse_error::kParseNoError;
1731 } 1720 }
1732 1721
1733 parse_error::ParseError GLES2DecoderImpl::HandleUniform1fv( 1722 parse_error::ParseError GLES2DecoderImpl::HandleUniform1fv(
1734 uint32 immediate_data_size, const gles2::Uniform1fv& c) { 1723 uint32 immediate_data_size, const gles2::Uniform1fv& c) {
1735 GLint location = static_cast<GLint>(c.location); 1724 GLint location = static_cast<GLint>(c.location);
1736 GLsizei count = static_cast<GLsizei>(c.count); 1725 GLsizei count = static_cast<GLsizei>(c.count);
1737 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( 1726 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
1738 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1727 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1739 parse_error::ParseError result = 1728 if (v == NULL) {
1740 ValidateUniform1fv(this, immediate_data_size, location, count, v); 1729 return parse_error::kParseOutOfBounds;
1741 if (result != parse_error::kParseNoError) {
1742 return result;
1743 } 1730 }
1744 glUniform1fv(location, count, v); 1731 glUniform1fv(location, count, v);
1745 return parse_error::kParseNoError; 1732 return parse_error::kParseNoError;
1746 } 1733 }
1747 1734
1748 parse_error::ParseError GLES2DecoderImpl::HandleUniform1fvImmediate( 1735 parse_error::ParseError GLES2DecoderImpl::HandleUniform1fvImmediate(
1749 uint32 immediate_data_size, const gles2::Uniform1fvImmediate& c) { 1736 uint32 immediate_data_size, const gles2::Uniform1fvImmediate& c) {
1750 GLint location = static_cast<GLint>(c.location); 1737 GLint location = static_cast<GLint>(c.location);
1751 GLsizei count = static_cast<GLsizei>(c.count); 1738 GLsizei count = static_cast<GLsizei>(c.count);
1752 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); 1739 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c);
1740 if (v == NULL) {
1741 return parse_error::kParseOutOfBounds;
1742 }
1743 if (!CheckImmediateDataSize<Uniform1fvImmediate>(
1744 immediate_data_size, count, sizeof(GLfloat), 1)) {
1745 return parse_error::kParseOutOfBounds;
1746 }
1753 // Immediate version. 1747 // Immediate version.
1754 parse_error::ParseError result = 1748 if (v == NULL) {
1755 ValidateUniform1fvImmediate( 1749 return parse_error::kParseOutOfBounds;
1756 this, immediate_data_size, location, count, v); 1750 }
1757 if (result != parse_error::kParseNoError) { 1751 if (!CheckImmediateDataSize<Uniform1fvImmediate>(
1758 return result; 1752 immediate_data_size, count, sizeof(GLfloat), 1)) {
1753 return parse_error::kParseOutOfBounds;
1759 } 1754 }
1760 glUniform1fv(location, count, v); 1755 glUniform1fv(location, count, v);
1761 return parse_error::kParseNoError; 1756 return parse_error::kParseNoError;
1762 } 1757 }
1763 1758
1764 parse_error::ParseError GLES2DecoderImpl::HandleUniform1i( 1759 parse_error::ParseError GLES2DecoderImpl::HandleUniform1i(
1765 uint32 immediate_data_size, const gles2::Uniform1i& c) { 1760 uint32 immediate_data_size, const gles2::Uniform1i& c) {
1766 GLint location = static_cast<GLint>(c.location); 1761 GLint location = static_cast<GLint>(c.location);
1767 GLint x = static_cast<GLint>(c.x); 1762 GLint x = static_cast<GLint>(c.x);
1768 parse_error::ParseError result =
1769 ValidateUniform1i(this, immediate_data_size, location, x);
1770 if (result != parse_error::kParseNoError) {
1771 return result;
1772 }
1773 glUniform1i(location, x); 1763 glUniform1i(location, x);
1774 return parse_error::kParseNoError; 1764 return parse_error::kParseNoError;
1775 } 1765 }
1776 1766
1777 parse_error::ParseError GLES2DecoderImpl::HandleUniform1iv( 1767 parse_error::ParseError GLES2DecoderImpl::HandleUniform1iv(
1778 uint32 immediate_data_size, const gles2::Uniform1iv& c) { 1768 uint32 immediate_data_size, const gles2::Uniform1iv& c) {
1779 GLint location = static_cast<GLint>(c.location); 1769 GLint location = static_cast<GLint>(c.location);
1780 GLsizei count = static_cast<GLsizei>(c.count); 1770 GLsizei count = static_cast<GLsizei>(c.count);
1781 const GLint* v = GetSharedMemoryAs<const GLint*>( 1771 const GLint* v = GetSharedMemoryAs<const GLint*>(
1782 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1772 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1783 parse_error::ParseError result = 1773 if (v == NULL) {
1784 ValidateUniform1iv(this, immediate_data_size, location, count, v); 1774 return parse_error::kParseOutOfBounds;
1785 if (result != parse_error::kParseNoError) {
1786 return result;
1787 } 1775 }
1788 glUniform1iv(location, count, v); 1776 glUniform1iv(location, count, v);
1789 return parse_error::kParseNoError; 1777 return parse_error::kParseNoError;
1790 } 1778 }
1791 1779
1792 parse_error::ParseError GLES2DecoderImpl::HandleUniform1ivImmediate( 1780 parse_error::ParseError GLES2DecoderImpl::HandleUniform1ivImmediate(
1793 uint32 immediate_data_size, const gles2::Uniform1ivImmediate& c) { 1781 uint32 immediate_data_size, const gles2::Uniform1ivImmediate& c) {
1794 GLint location = static_cast<GLint>(c.location); 1782 GLint location = static_cast<GLint>(c.location);
1795 GLsizei count = static_cast<GLsizei>(c.count); 1783 GLsizei count = static_cast<GLsizei>(c.count);
1796 const GLint* v = GetImmediateDataAs<const GLint*>(c); 1784 const GLint* v = GetImmediateDataAs<const GLint*>(c);
1785 if (v == NULL) {
1786 return parse_error::kParseOutOfBounds;
1787 }
1788 if (!CheckImmediateDataSize<Uniform1ivImmediate>(
1789 immediate_data_size, count, sizeof(GLint), 1)) {
1790 return parse_error::kParseOutOfBounds;
1791 }
1797 // Immediate version. 1792 // Immediate version.
1798 parse_error::ParseError result = 1793 if (v == NULL) {
1799 ValidateUniform1ivImmediate( 1794 return parse_error::kParseOutOfBounds;
1800 this, immediate_data_size, location, count, v); 1795 }
1801 if (result != parse_error::kParseNoError) { 1796 if (!CheckImmediateDataSize<Uniform1ivImmediate>(
1802 return result; 1797 immediate_data_size, count, sizeof(GLint), 1)) {
1798 return parse_error::kParseOutOfBounds;
1803 } 1799 }
1804 glUniform1iv(location, count, v); 1800 glUniform1iv(location, count, v);
1805 return parse_error::kParseNoError; 1801 return parse_error::kParseNoError;
1806 } 1802 }
1807 1803
1808 parse_error::ParseError GLES2DecoderImpl::HandleUniform2f( 1804 parse_error::ParseError GLES2DecoderImpl::HandleUniform2f(
1809 uint32 immediate_data_size, const gles2::Uniform2f& c) { 1805 uint32 immediate_data_size, const gles2::Uniform2f& c) {
1810 GLint location = static_cast<GLint>(c.location); 1806 GLint location = static_cast<GLint>(c.location);
1811 GLfloat x = static_cast<GLfloat>(c.x); 1807 GLfloat x = static_cast<GLfloat>(c.x);
1812 GLfloat y = static_cast<GLfloat>(c.y); 1808 GLfloat y = static_cast<GLfloat>(c.y);
1813 parse_error::ParseError result =
1814 ValidateUniform2f(this, immediate_data_size, location, x, y);
1815 if (result != parse_error::kParseNoError) {
1816 return result;
1817 }
1818 glUniform2f(location, x, y); 1809 glUniform2f(location, x, y);
1819 return parse_error::kParseNoError; 1810 return parse_error::kParseNoError;
1820 } 1811 }
1821 1812
1822 parse_error::ParseError GLES2DecoderImpl::HandleUniform2fv( 1813 parse_error::ParseError GLES2DecoderImpl::HandleUniform2fv(
1823 uint32 immediate_data_size, const gles2::Uniform2fv& c) { 1814 uint32 immediate_data_size, const gles2::Uniform2fv& c) {
1824 GLint location = static_cast<GLint>(c.location); 1815 GLint location = static_cast<GLint>(c.location);
1825 GLsizei count = static_cast<GLsizei>(c.count); 1816 GLsizei count = static_cast<GLsizei>(c.count);
1826 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( 1817 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
1827 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1818 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1828 parse_error::ParseError result = 1819 if (v == NULL) {
1829 ValidateUniform2fv(this, immediate_data_size, location, count, v); 1820 return parse_error::kParseOutOfBounds;
1830 if (result != parse_error::kParseNoError) {
1831 return result;
1832 } 1821 }
1833 glUniform2fv(location, count, v); 1822 glUniform2fv(location, count, v);
1834 return parse_error::kParseNoError; 1823 return parse_error::kParseNoError;
1835 } 1824 }
1836 1825
1837 parse_error::ParseError GLES2DecoderImpl::HandleUniform2fvImmediate( 1826 parse_error::ParseError GLES2DecoderImpl::HandleUniform2fvImmediate(
1838 uint32 immediate_data_size, const gles2::Uniform2fvImmediate& c) { 1827 uint32 immediate_data_size, const gles2::Uniform2fvImmediate& c) {
1839 GLint location = static_cast<GLint>(c.location); 1828 GLint location = static_cast<GLint>(c.location);
1840 GLsizei count = static_cast<GLsizei>(c.count); 1829 GLsizei count = static_cast<GLsizei>(c.count);
1841 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); 1830 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c);
1831 if (v == NULL) {
1832 return parse_error::kParseOutOfBounds;
1833 }
1834 if (!CheckImmediateDataSize<Uniform2fvImmediate>(
1835 immediate_data_size, count, sizeof(GLfloat), 2)) {
1836 return parse_error::kParseOutOfBounds;
1837 }
1842 // Immediate version. 1838 // Immediate version.
1843 parse_error::ParseError result = 1839 if (v == NULL) {
1844 ValidateUniform2fvImmediate( 1840 return parse_error::kParseOutOfBounds;
1845 this, immediate_data_size, location, count, v); 1841 }
1846 if (result != parse_error::kParseNoError) { 1842 if (!CheckImmediateDataSize<Uniform2fvImmediate>(
1847 return result; 1843 immediate_data_size, count, sizeof(GLfloat), 2)) {
1844 return parse_error::kParseOutOfBounds;
1848 } 1845 }
1849 glUniform2fv(location, count, v); 1846 glUniform2fv(location, count, v);
1850 return parse_error::kParseNoError; 1847 return parse_error::kParseNoError;
1851 } 1848 }
1852 1849
1853 parse_error::ParseError GLES2DecoderImpl::HandleUniform2i( 1850 parse_error::ParseError GLES2DecoderImpl::HandleUniform2i(
1854 uint32 immediate_data_size, const gles2::Uniform2i& c) { 1851 uint32 immediate_data_size, const gles2::Uniform2i& c) {
1855 GLint location = static_cast<GLint>(c.location); 1852 GLint location = static_cast<GLint>(c.location);
1856 GLint x = static_cast<GLint>(c.x); 1853 GLint x = static_cast<GLint>(c.x);
1857 GLint y = static_cast<GLint>(c.y); 1854 GLint y = static_cast<GLint>(c.y);
1858 parse_error::ParseError result =
1859 ValidateUniform2i(this, immediate_data_size, location, x, y);
1860 if (result != parse_error::kParseNoError) {
1861 return result;
1862 }
1863 glUniform2i(location, x, y); 1855 glUniform2i(location, x, y);
1864 return parse_error::kParseNoError; 1856 return parse_error::kParseNoError;
1865 } 1857 }
1866 1858
1867 parse_error::ParseError GLES2DecoderImpl::HandleUniform2iv( 1859 parse_error::ParseError GLES2DecoderImpl::HandleUniform2iv(
1868 uint32 immediate_data_size, const gles2::Uniform2iv& c) { 1860 uint32 immediate_data_size, const gles2::Uniform2iv& c) {
1869 GLint location = static_cast<GLint>(c.location); 1861 GLint location = static_cast<GLint>(c.location);
1870 GLsizei count = static_cast<GLsizei>(c.count); 1862 GLsizei count = static_cast<GLsizei>(c.count);
1871 const GLint* v = GetSharedMemoryAs<const GLint*>( 1863 const GLint* v = GetSharedMemoryAs<const GLint*>(
1872 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1864 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1873 parse_error::ParseError result = 1865 if (v == NULL) {
1874 ValidateUniform2iv(this, immediate_data_size, location, count, v); 1866 return parse_error::kParseOutOfBounds;
1875 if (result != parse_error::kParseNoError) {
1876 return result;
1877 } 1867 }
1878 glUniform2iv(location, count, v); 1868 glUniform2iv(location, count, v);
1879 return parse_error::kParseNoError; 1869 return parse_error::kParseNoError;
1880 } 1870 }
1881 1871
1882 parse_error::ParseError GLES2DecoderImpl::HandleUniform2ivImmediate( 1872 parse_error::ParseError GLES2DecoderImpl::HandleUniform2ivImmediate(
1883 uint32 immediate_data_size, const gles2::Uniform2ivImmediate& c) { 1873 uint32 immediate_data_size, const gles2::Uniform2ivImmediate& c) {
1884 GLint location = static_cast<GLint>(c.location); 1874 GLint location = static_cast<GLint>(c.location);
1885 GLsizei count = static_cast<GLsizei>(c.count); 1875 GLsizei count = static_cast<GLsizei>(c.count);
1886 const GLint* v = GetImmediateDataAs<const GLint*>(c); 1876 const GLint* v = GetImmediateDataAs<const GLint*>(c);
1877 if (v == NULL) {
1878 return parse_error::kParseOutOfBounds;
1879 }
1880 if (!CheckImmediateDataSize<Uniform2ivImmediate>(
1881 immediate_data_size, count, sizeof(GLint), 2)) {
1882 return parse_error::kParseOutOfBounds;
1883 }
1887 // Immediate version. 1884 // Immediate version.
1888 parse_error::ParseError result = 1885 if (v == NULL) {
1889 ValidateUniform2ivImmediate( 1886 return parse_error::kParseOutOfBounds;
1890 this, immediate_data_size, location, count, v); 1887 }
1891 if (result != parse_error::kParseNoError) { 1888 if (!CheckImmediateDataSize<Uniform2ivImmediate>(
1892 return result; 1889 immediate_data_size, count, sizeof(GLint), 2)) {
1890 return parse_error::kParseOutOfBounds;
1893 } 1891 }
1894 glUniform2iv(location, count, v); 1892 glUniform2iv(location, count, v);
1895 return parse_error::kParseNoError; 1893 return parse_error::kParseNoError;
1896 } 1894 }
1897 1895
1898 parse_error::ParseError GLES2DecoderImpl::HandleUniform3f( 1896 parse_error::ParseError GLES2DecoderImpl::HandleUniform3f(
1899 uint32 immediate_data_size, const gles2::Uniform3f& c) { 1897 uint32 immediate_data_size, const gles2::Uniform3f& c) {
1900 GLint location = static_cast<GLint>(c.location); 1898 GLint location = static_cast<GLint>(c.location);
1901 GLfloat x = static_cast<GLfloat>(c.x); 1899 GLfloat x = static_cast<GLfloat>(c.x);
1902 GLfloat y = static_cast<GLfloat>(c.y); 1900 GLfloat y = static_cast<GLfloat>(c.y);
1903 GLfloat z = static_cast<GLfloat>(c.z); 1901 GLfloat z = static_cast<GLfloat>(c.z);
1904 parse_error::ParseError result =
1905 ValidateUniform3f(this, immediate_data_size, location, x, y, z);
1906 if (result != parse_error::kParseNoError) {
1907 return result;
1908 }
1909 glUniform3f(location, x, y, z); 1902 glUniform3f(location, x, y, z);
1910 return parse_error::kParseNoError; 1903 return parse_error::kParseNoError;
1911 } 1904 }
1912 1905
1913 parse_error::ParseError GLES2DecoderImpl::HandleUniform3fv( 1906 parse_error::ParseError GLES2DecoderImpl::HandleUniform3fv(
1914 uint32 immediate_data_size, const gles2::Uniform3fv& c) { 1907 uint32 immediate_data_size, const gles2::Uniform3fv& c) {
1915 GLint location = static_cast<GLint>(c.location); 1908 GLint location = static_cast<GLint>(c.location);
1916 GLsizei count = static_cast<GLsizei>(c.count); 1909 GLsizei count = static_cast<GLsizei>(c.count);
1917 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( 1910 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
1918 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1911 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1919 parse_error::ParseError result = 1912 if (v == NULL) {
1920 ValidateUniform3fv(this, immediate_data_size, location, count, v); 1913 return parse_error::kParseOutOfBounds;
1921 if (result != parse_error::kParseNoError) {
1922 return result;
1923 } 1914 }
1924 glUniform3fv(location, count, v); 1915 glUniform3fv(location, count, v);
1925 return parse_error::kParseNoError; 1916 return parse_error::kParseNoError;
1926 } 1917 }
1927 1918
1928 parse_error::ParseError GLES2DecoderImpl::HandleUniform3fvImmediate( 1919 parse_error::ParseError GLES2DecoderImpl::HandleUniform3fvImmediate(
1929 uint32 immediate_data_size, const gles2::Uniform3fvImmediate& c) { 1920 uint32 immediate_data_size, const gles2::Uniform3fvImmediate& c) {
1930 GLint location = static_cast<GLint>(c.location); 1921 GLint location = static_cast<GLint>(c.location);
1931 GLsizei count = static_cast<GLsizei>(c.count); 1922 GLsizei count = static_cast<GLsizei>(c.count);
1932 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); 1923 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c);
1924 if (v == NULL) {
1925 return parse_error::kParseOutOfBounds;
1926 }
1927 if (!CheckImmediateDataSize<Uniform3fvImmediate>(
1928 immediate_data_size, count, sizeof(GLfloat), 3)) {
1929 return parse_error::kParseOutOfBounds;
1930 }
1933 // Immediate version. 1931 // Immediate version.
1934 parse_error::ParseError result = 1932 if (v == NULL) {
1935 ValidateUniform3fvImmediate( 1933 return parse_error::kParseOutOfBounds;
1936 this, immediate_data_size, location, count, v); 1934 }
1937 if (result != parse_error::kParseNoError) { 1935 if (!CheckImmediateDataSize<Uniform3fvImmediate>(
1938 return result; 1936 immediate_data_size, count, sizeof(GLfloat), 3)) {
1937 return parse_error::kParseOutOfBounds;
1939 } 1938 }
1940 glUniform3fv(location, count, v); 1939 glUniform3fv(location, count, v);
1941 return parse_error::kParseNoError; 1940 return parse_error::kParseNoError;
1942 } 1941 }
1943 1942
1944 parse_error::ParseError GLES2DecoderImpl::HandleUniform3i( 1943 parse_error::ParseError GLES2DecoderImpl::HandleUniform3i(
1945 uint32 immediate_data_size, const gles2::Uniform3i& c) { 1944 uint32 immediate_data_size, const gles2::Uniform3i& c) {
1946 GLint location = static_cast<GLint>(c.location); 1945 GLint location = static_cast<GLint>(c.location);
1947 GLint x = static_cast<GLint>(c.x); 1946 GLint x = static_cast<GLint>(c.x);
1948 GLint y = static_cast<GLint>(c.y); 1947 GLint y = static_cast<GLint>(c.y);
1949 GLint z = static_cast<GLint>(c.z); 1948 GLint z = static_cast<GLint>(c.z);
1950 parse_error::ParseError result =
1951 ValidateUniform3i(this, immediate_data_size, location, x, y, z);
1952 if (result != parse_error::kParseNoError) {
1953 return result;
1954 }
1955 glUniform3i(location, x, y, z); 1949 glUniform3i(location, x, y, z);
1956 return parse_error::kParseNoError; 1950 return parse_error::kParseNoError;
1957 } 1951 }
1958 1952
1959 parse_error::ParseError GLES2DecoderImpl::HandleUniform3iv( 1953 parse_error::ParseError GLES2DecoderImpl::HandleUniform3iv(
1960 uint32 immediate_data_size, const gles2::Uniform3iv& c) { 1954 uint32 immediate_data_size, const gles2::Uniform3iv& c) {
1961 GLint location = static_cast<GLint>(c.location); 1955 GLint location = static_cast<GLint>(c.location);
1962 GLsizei count = static_cast<GLsizei>(c.count); 1956 GLsizei count = static_cast<GLsizei>(c.count);
1963 const GLint* v = GetSharedMemoryAs<const GLint*>( 1957 const GLint* v = GetSharedMemoryAs<const GLint*>(
1964 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 1958 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
1965 parse_error::ParseError result = 1959 if (v == NULL) {
1966 ValidateUniform3iv(this, immediate_data_size, location, count, v); 1960 return parse_error::kParseOutOfBounds;
1967 if (result != parse_error::kParseNoError) {
1968 return result;
1969 } 1961 }
1970 glUniform3iv(location, count, v); 1962 glUniform3iv(location, count, v);
1971 return parse_error::kParseNoError; 1963 return parse_error::kParseNoError;
1972 } 1964 }
1973 1965
1974 parse_error::ParseError GLES2DecoderImpl::HandleUniform3ivImmediate( 1966 parse_error::ParseError GLES2DecoderImpl::HandleUniform3ivImmediate(
1975 uint32 immediate_data_size, const gles2::Uniform3ivImmediate& c) { 1967 uint32 immediate_data_size, const gles2::Uniform3ivImmediate& c) {
1976 GLint location = static_cast<GLint>(c.location); 1968 GLint location = static_cast<GLint>(c.location);
1977 GLsizei count = static_cast<GLsizei>(c.count); 1969 GLsizei count = static_cast<GLsizei>(c.count);
1978 const GLint* v = GetImmediateDataAs<const GLint*>(c); 1970 const GLint* v = GetImmediateDataAs<const GLint*>(c);
1971 if (v == NULL) {
1972 return parse_error::kParseOutOfBounds;
1973 }
1974 if (!CheckImmediateDataSize<Uniform3ivImmediate>(
1975 immediate_data_size, count, sizeof(GLint), 3)) {
1976 return parse_error::kParseOutOfBounds;
1977 }
1979 // Immediate version. 1978 // Immediate version.
1980 parse_error::ParseError result = 1979 if (v == NULL) {
1981 ValidateUniform3ivImmediate( 1980 return parse_error::kParseOutOfBounds;
1982 this, immediate_data_size, location, count, v); 1981 }
1983 if (result != parse_error::kParseNoError) { 1982 if (!CheckImmediateDataSize<Uniform3ivImmediate>(
1984 return result; 1983 immediate_data_size, count, sizeof(GLint), 3)) {
1984 return parse_error::kParseOutOfBounds;
1985 } 1985 }
1986 glUniform3iv(location, count, v); 1986 glUniform3iv(location, count, v);
1987 return parse_error::kParseNoError; 1987 return parse_error::kParseNoError;
1988 } 1988 }
1989 1989
1990 parse_error::ParseError GLES2DecoderImpl::HandleUniform4f( 1990 parse_error::ParseError GLES2DecoderImpl::HandleUniform4f(
1991 uint32 immediate_data_size, const gles2::Uniform4f& c) { 1991 uint32 immediate_data_size, const gles2::Uniform4f& c) {
1992 GLint location = static_cast<GLint>(c.location); 1992 GLint location = static_cast<GLint>(c.location);
1993 GLfloat x = static_cast<GLfloat>(c.x); 1993 GLfloat x = static_cast<GLfloat>(c.x);
1994 GLfloat y = static_cast<GLfloat>(c.y); 1994 GLfloat y = static_cast<GLfloat>(c.y);
1995 GLfloat z = static_cast<GLfloat>(c.z); 1995 GLfloat z = static_cast<GLfloat>(c.z);
1996 GLfloat w = static_cast<GLfloat>(c.w); 1996 GLfloat w = static_cast<GLfloat>(c.w);
1997 parse_error::ParseError result =
1998 ValidateUniform4f(this, immediate_data_size, location, x, y, z, w);
1999 if (result != parse_error::kParseNoError) {
2000 return result;
2001 }
2002 glUniform4f(location, x, y, z, w); 1997 glUniform4f(location, x, y, z, w);
2003 return parse_error::kParseNoError; 1998 return parse_error::kParseNoError;
2004 } 1999 }
2005 2000
2006 parse_error::ParseError GLES2DecoderImpl::HandleUniform4fv( 2001 parse_error::ParseError GLES2DecoderImpl::HandleUniform4fv(
2007 uint32 immediate_data_size, const gles2::Uniform4fv& c) { 2002 uint32 immediate_data_size, const gles2::Uniform4fv& c) {
2008 GLint location = static_cast<GLint>(c.location); 2003 GLint location = static_cast<GLint>(c.location);
2009 GLsizei count = static_cast<GLsizei>(c.count); 2004 GLsizei count = static_cast<GLsizei>(c.count);
2010 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( 2005 const GLfloat* v = GetSharedMemoryAs<const GLfloat*>(
2011 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 2006 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
2012 parse_error::ParseError result = 2007 if (v == NULL) {
2013 ValidateUniform4fv(this, immediate_data_size, location, count, v); 2008 return parse_error::kParseOutOfBounds;
2014 if (result != parse_error::kParseNoError) {
2015 return result;
2016 } 2009 }
2017 glUniform4fv(location, count, v); 2010 glUniform4fv(location, count, v);
2018 return parse_error::kParseNoError; 2011 return parse_error::kParseNoError;
2019 } 2012 }
2020 2013
2021 parse_error::ParseError GLES2DecoderImpl::HandleUniform4fvImmediate( 2014 parse_error::ParseError GLES2DecoderImpl::HandleUniform4fvImmediate(
2022 uint32 immediate_data_size, const gles2::Uniform4fvImmediate& c) { 2015 uint32 immediate_data_size, const gles2::Uniform4fvImmediate& c) {
2023 GLint location = static_cast<GLint>(c.location); 2016 GLint location = static_cast<GLint>(c.location);
2024 GLsizei count = static_cast<GLsizei>(c.count); 2017 GLsizei count = static_cast<GLsizei>(c.count);
2025 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); 2018 const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c);
2019 if (v == NULL) {
2020 return parse_error::kParseOutOfBounds;
2021 }
2022 if (!CheckImmediateDataSize<Uniform4fvImmediate>(
2023 immediate_data_size, count, sizeof(GLfloat), 4)) {
2024 return parse_error::kParseOutOfBounds;
2025 }
2026 // Immediate version. 2026 // Immediate version.
2027 parse_error::ParseError result = 2027 if (v == NULL) {
2028 ValidateUniform4fvImmediate( 2028 return parse_error::kParseOutOfBounds;
2029 this, immediate_data_size, location, count, v); 2029 }
2030 if (result != parse_error::kParseNoError) { 2030 if (!CheckImmediateDataSize<Uniform4fvImmediate>(
2031 return result; 2031 immediate_data_size, count, sizeof(GLfloat), 4)) {
2032 return parse_error::kParseOutOfBounds;
2032 } 2033 }
2033 glUniform4fv(location, count, v); 2034 glUniform4fv(location, count, v);
2034 return parse_error::kParseNoError; 2035 return parse_error::kParseNoError;
2035 } 2036 }
2036 2037
2037 parse_error::ParseError GLES2DecoderImpl::HandleUniform4i( 2038 parse_error::ParseError GLES2DecoderImpl::HandleUniform4i(
2038 uint32 immediate_data_size, const gles2::Uniform4i& c) { 2039 uint32 immediate_data_size, const gles2::Uniform4i& c) {
2039 GLint location = static_cast<GLint>(c.location); 2040 GLint location = static_cast<GLint>(c.location);
2040 GLint x = static_cast<GLint>(c.x); 2041 GLint x = static_cast<GLint>(c.x);
2041 GLint y = static_cast<GLint>(c.y); 2042 GLint y = static_cast<GLint>(c.y);
2042 GLint z = static_cast<GLint>(c.z); 2043 GLint z = static_cast<GLint>(c.z);
2043 GLint w = static_cast<GLint>(c.w); 2044 GLint w = static_cast<GLint>(c.w);
2044 parse_error::ParseError result =
2045 ValidateUniform4i(this, immediate_data_size, location, x, y, z, w);
2046 if (result != parse_error::kParseNoError) {
2047 return result;
2048 }
2049 glUniform4i(location, x, y, z, w); 2045 glUniform4i(location, x, y, z, w);
2050 return parse_error::kParseNoError; 2046 return parse_error::kParseNoError;
2051 } 2047 }
2052 2048
2053 parse_error::ParseError GLES2DecoderImpl::HandleUniform4iv( 2049 parse_error::ParseError GLES2DecoderImpl::HandleUniform4iv(
2054 uint32 immediate_data_size, const gles2::Uniform4iv& c) { 2050 uint32 immediate_data_size, const gles2::Uniform4iv& c) {
2055 GLint location = static_cast<GLint>(c.location); 2051 GLint location = static_cast<GLint>(c.location);
2056 GLsizei count = static_cast<GLsizei>(c.count); 2052 GLsizei count = static_cast<GLsizei>(c.count);
2057 const GLint* v = GetSharedMemoryAs<const GLint*>( 2053 const GLint* v = GetSharedMemoryAs<const GLint*>(
2058 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); 2054 c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */);
2059 parse_error::ParseError result = 2055 if (v == NULL) {
2060 ValidateUniform4iv(this, immediate_data_size, location, count, v); 2056 return parse_error::kParseOutOfBounds;
2061 if (result != parse_error::kParseNoError) {
2062 return result;
2063 } 2057 }
2064 glUniform4iv(location, count, v); 2058 glUniform4iv(location, count, v);
2065 return parse_error::kParseNoError; 2059 return parse_error::kParseNoError;
2066 } 2060 }
2067 2061
2068 parse_error::ParseError GLES2DecoderImpl::HandleUniform4ivImmediate( 2062 parse_error::ParseError GLES2DecoderImpl::HandleUniform4ivImmediate(
2069 uint32 immediate_data_size, const gles2::Uniform4ivImmediate& c) { 2063 uint32 immediate_data_size, const gles2::Uniform4ivImmediate& c) {
2070 GLint location = static_cast<GLint>(c.location); 2064 GLint location = static_cast<GLint>(c.location);
2071 GLsizei count = static_cast<GLsizei>(c.count); 2065 GLsizei count = static_cast<GLsizei>(c.count);
2072 const GLint* v = GetImmediateDataAs<const GLint*>(c); 2066 const GLint* v = GetImmediateDataAs<const GLint*>(c);
2067 if (v == NULL) {
2068 return parse_error::kParseOutOfBounds;
2069 }
2070 if (!CheckImmediateDataSize<Uniform4ivImmediate>(
2071 immediate_data_size, count, sizeof(GLint), 4)) {
2072 return parse_error::kParseOutOfBounds;
2073 }
2073 // Immediate version. 2074 // Immediate version.
2074 parse_error::ParseError result = 2075 if (v == NULL) {
2075 ValidateUniform4ivImmediate( 2076 return parse_error::kParseOutOfBounds;
2076 this, immediate_data_size, location, count, v); 2077 }
2077 if (result != parse_error::kParseNoError) { 2078 if (!CheckImmediateDataSize<Uniform4ivImmediate>(
2078 return result; 2079 immediate_data_size, count, sizeof(GLint), 4)) {
2080 return parse_error::kParseOutOfBounds;
2079 } 2081 }
2080 glUniform4iv(location, count, v); 2082 glUniform4iv(location, count, v);
2081 return parse_error::kParseNoError; 2083 return parse_error::kParseNoError;
2082 } 2084 }
2083 2085
2084 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fv( 2086 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fv(
2085 uint32 immediate_data_size, const gles2::UniformMatrix2fv& c) { 2087 uint32 immediate_data_size, const gles2::UniformMatrix2fv& c) {
2086 GLint location = static_cast<GLint>(c.location); 2088 GLint location = static_cast<GLint>(c.location);
2087 GLsizei count = static_cast<GLsizei>(c.count); 2089 GLsizei count = static_cast<GLsizei>(c.count);
2088 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2090 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2089 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( 2091 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
2090 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); 2092 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */);
2091 parse_error::ParseError result = 2093 if (value == NULL) {
2092 ValidateUniformMatrix2fv( 2094 return parse_error::kParseOutOfBounds;
2093 this, immediate_data_size, location, count, transpose, value);
2094 if (result != parse_error::kParseNoError) {
2095 return result;
2096 } 2095 }
2097 glUniformMatrix2fv(location, count, transpose, value); 2096 glUniformMatrix2fv(location, count, transpose, value);
2098 return parse_error::kParseNoError; 2097 return parse_error::kParseNoError;
2099 } 2098 }
2100 2099
2101 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( 2100 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
2102 uint32 immediate_data_size, const gles2::UniformMatrix2fvImmediate& c) { 2101 uint32 immediate_data_size, const gles2::UniformMatrix2fvImmediate& c) {
2103 GLint location = static_cast<GLint>(c.location); 2102 GLint location = static_cast<GLint>(c.location);
2104 GLsizei count = static_cast<GLsizei>(c.count); 2103 GLsizei count = static_cast<GLsizei>(c.count);
2105 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2104 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2106 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); 2105 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c);
2106 if (value == NULL) {
2107 return parse_error::kParseOutOfBounds;
2108 }
2109 if (!CheckImmediateDataSize<UniformMatrix2fvImmediate>(
2110 immediate_data_size, count, sizeof(GLfloat), 4)) {
2111 return parse_error::kParseOutOfBounds;
2112 }
2107 // Immediate version. 2113 // Immediate version.
2108 parse_error::ParseError result = 2114 if (value == NULL) {
2109 ValidateUniformMatrix2fvImmediate( 2115 return parse_error::kParseOutOfBounds;
2110 this, immediate_data_size, location, count, transpose, value); 2116 }
2111 if (result != parse_error::kParseNoError) { 2117 if (!CheckImmediateDataSize<UniformMatrix2fvImmediate>(
2112 return result; 2118 immediate_data_size, count, sizeof(GLfloat), 4)) {
2119 return parse_error::kParseOutOfBounds;
2113 } 2120 }
2114 glUniformMatrix2fv(location, count, transpose, value); 2121 glUniformMatrix2fv(location, count, transpose, value);
2115 return parse_error::kParseNoError; 2122 return parse_error::kParseNoError;
2116 } 2123 }
2117 2124
2118 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fv( 2125 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fv(
2119 uint32 immediate_data_size, const gles2::UniformMatrix3fv& c) { 2126 uint32 immediate_data_size, const gles2::UniformMatrix3fv& c) {
2120 GLint location = static_cast<GLint>(c.location); 2127 GLint location = static_cast<GLint>(c.location);
2121 GLsizei count = static_cast<GLsizei>(c.count); 2128 GLsizei count = static_cast<GLsizei>(c.count);
2122 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2129 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2123 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( 2130 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
2124 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); 2131 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */);
2125 parse_error::ParseError result = 2132 if (value == NULL) {
2126 ValidateUniformMatrix3fv( 2133 return parse_error::kParseOutOfBounds;
2127 this, immediate_data_size, location, count, transpose, value);
2128 if (result != parse_error::kParseNoError) {
2129 return result;
2130 } 2134 }
2131 glUniformMatrix3fv(location, count, transpose, value); 2135 glUniformMatrix3fv(location, count, transpose, value);
2132 return parse_error::kParseNoError; 2136 return parse_error::kParseNoError;
2133 } 2137 }
2134 2138
2135 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( 2139 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
2136 uint32 immediate_data_size, const gles2::UniformMatrix3fvImmediate& c) { 2140 uint32 immediate_data_size, const gles2::UniformMatrix3fvImmediate& c) {
2137 GLint location = static_cast<GLint>(c.location); 2141 GLint location = static_cast<GLint>(c.location);
2138 GLsizei count = static_cast<GLsizei>(c.count); 2142 GLsizei count = static_cast<GLsizei>(c.count);
2139 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2143 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2140 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); 2144 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c);
2145 if (value == NULL) {
2146 return parse_error::kParseOutOfBounds;
2147 }
2148 if (!CheckImmediateDataSize<UniformMatrix3fvImmediate>(
2149 immediate_data_size, count, sizeof(GLfloat), 9)) {
2150 return parse_error::kParseOutOfBounds;
2151 }
2141 // Immediate version. 2152 // Immediate version.
2142 parse_error::ParseError result = 2153 if (value == NULL) {
2143 ValidateUniformMatrix3fvImmediate( 2154 return parse_error::kParseOutOfBounds;
2144 this, immediate_data_size, location, count, transpose, value); 2155 }
2145 if (result != parse_error::kParseNoError) { 2156 if (!CheckImmediateDataSize<UniformMatrix3fvImmediate>(
2146 return result; 2157 immediate_data_size, count, sizeof(GLfloat), 9)) {
2158 return parse_error::kParseOutOfBounds;
2147 } 2159 }
2148 glUniformMatrix3fv(location, count, transpose, value); 2160 glUniformMatrix3fv(location, count, transpose, value);
2149 return parse_error::kParseNoError; 2161 return parse_error::kParseNoError;
2150 } 2162 }
2151 2163
2152 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fv( 2164 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fv(
2153 uint32 immediate_data_size, const gles2::UniformMatrix4fv& c) { 2165 uint32 immediate_data_size, const gles2::UniformMatrix4fv& c) {
2154 GLint location = static_cast<GLint>(c.location); 2166 GLint location = static_cast<GLint>(c.location);
2155 GLsizei count = static_cast<GLsizei>(c.count); 2167 GLsizei count = static_cast<GLsizei>(c.count);
2156 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2168 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2157 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( 2169 const GLfloat* value = GetSharedMemoryAs<const GLfloat*>(
2158 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); 2170 c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */);
2159 parse_error::ParseError result = 2171 if (value == NULL) {
2160 ValidateUniformMatrix4fv( 2172 return parse_error::kParseOutOfBounds;
2161 this, immediate_data_size, location, count, transpose, value);
2162 if (result != parse_error::kParseNoError) {
2163 return result;
2164 } 2173 }
2165 glUniformMatrix4fv(location, count, transpose, value); 2174 glUniformMatrix4fv(location, count, transpose, value);
2166 return parse_error::kParseNoError; 2175 return parse_error::kParseNoError;
2167 } 2176 }
2168 2177
2169 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fvImmediate( 2178 parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
2170 uint32 immediate_data_size, const gles2::UniformMatrix4fvImmediate& c) { 2179 uint32 immediate_data_size, const gles2::UniformMatrix4fvImmediate& c) {
2171 GLint location = static_cast<GLint>(c.location); 2180 GLint location = static_cast<GLint>(c.location);
2172 GLsizei count = static_cast<GLsizei>(c.count); 2181 GLsizei count = static_cast<GLsizei>(c.count);
2173 GLboolean transpose = static_cast<GLboolean>(c.transpose); 2182 GLboolean transpose = static_cast<GLboolean>(c.transpose);
2174 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); 2183 const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c);
2184 if (value == NULL) {
2185 return parse_error::kParseOutOfBounds;
2186 }
2187 if (!CheckImmediateDataSize<UniformMatrix4fvImmediate>(
2188 immediate_data_size, count, sizeof(GLfloat), 16)) {
2189 return parse_error::kParseOutOfBounds;
2190 }
2175 // Immediate version. 2191 // Immediate version.
2176 parse_error::ParseError result = 2192 if (value == NULL) {
2177 ValidateUniformMatrix4fvImmediate( 2193 return parse_error::kParseOutOfBounds;
2178 this, immediate_data_size, location, count, transpose, value); 2194 }
2179 if (result != parse_error::kParseNoError) { 2195 if (!CheckImmediateDataSize<UniformMatrix4fvImmediate>(
2180 return result; 2196 immediate_data_size, count, sizeof(GLfloat), 16)) {
2197 return parse_error::kParseOutOfBounds;
2181 } 2198 }
2182 glUniformMatrix4fv(location, count, transpose, value); 2199 glUniformMatrix4fv(location, count, transpose, value);
2183 return parse_error::kParseNoError; 2200 return parse_error::kParseNoError;
2184 } 2201 }
2185 2202
2186 parse_error::ParseError GLES2DecoderImpl::HandleUseProgram( 2203 parse_error::ParseError GLES2DecoderImpl::HandleUseProgram(
2187 uint32 immediate_data_size, const gles2::UseProgram& c) { 2204 uint32 immediate_data_size, const gles2::UseProgram& c) {
2188 GLuint program; 2205 GLuint program;
2189 if (!id_map_.GetServiceId(c.program, &program)) { 2206 if (!id_map_.GetServiceId(c.program, &program)) {
2190 SetGLError(GL_INVALID_VALUE); 2207 SetGLError(GL_INVALID_VALUE);
2191 return parse_error::kParseNoError; 2208 return parse_error::kParseNoError;
2192 } 2209 }
2193 parse_error::ParseError result =
2194 ValidateUseProgram(this, immediate_data_size, program);
2195 if (result != parse_error::kParseNoError) {
2196 return result;
2197 }
2198 glUseProgram(program); 2210 glUseProgram(program);
2199 return parse_error::kParseNoError; 2211 return parse_error::kParseNoError;
2200 } 2212 }
2201 2213
2202 parse_error::ParseError GLES2DecoderImpl::HandleValidateProgram( 2214 parse_error::ParseError GLES2DecoderImpl::HandleValidateProgram(
2203 uint32 immediate_data_size, const gles2::ValidateProgram& c) { 2215 uint32 immediate_data_size, const gles2::ValidateProgram& c) {
2204 GLuint program; 2216 GLuint program;
2205 if (!id_map_.GetServiceId(c.program, &program)) { 2217 if (!id_map_.GetServiceId(c.program, &program)) {
2206 SetGLError(GL_INVALID_VALUE); 2218 SetGLError(GL_INVALID_VALUE);
2207 return parse_error::kParseNoError; 2219 return parse_error::kParseNoError;
2208 } 2220 }
2209 parse_error::ParseError result =
2210 ValidateValidateProgram(this, immediate_data_size, program);
2211 if (result != parse_error::kParseNoError) {
2212 return result;
2213 }
2214 glValidateProgram(program); 2221 glValidateProgram(program);
2215 return parse_error::kParseNoError; 2222 return parse_error::kParseNoError;
2216 } 2223 }
2217 2224
2218 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1f( 2225 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1f(
2219 uint32 immediate_data_size, const gles2::VertexAttrib1f& c) { 2226 uint32 immediate_data_size, const gles2::VertexAttrib1f& c) {
2220 GLuint indx = static_cast<GLuint>(c.indx); 2227 GLuint indx = static_cast<GLuint>(c.indx);
2221 GLfloat x = static_cast<GLfloat>(c.x); 2228 GLfloat x = static_cast<GLfloat>(c.x);
2222 parse_error::ParseError result =
2223 ValidateVertexAttrib1f(this, immediate_data_size, indx, x);
2224 if (result != parse_error::kParseNoError) {
2225 return result;
2226 }
2227 glVertexAttrib1f(indx, x); 2229 glVertexAttrib1f(indx, x);
2228 return parse_error::kParseNoError; 2230 return parse_error::kParseNoError;
2229 } 2231 }
2230 2232
2231 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1fv( 2233 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1fv(
2232 uint32 immediate_data_size, const gles2::VertexAttrib1fv& c) { 2234 uint32 immediate_data_size, const gles2::VertexAttrib1fv& c) {
2233 GLuint indx = static_cast<GLuint>(c.indx); 2235 GLuint indx = static_cast<GLuint>(c.indx);
2234 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( 2236 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>(
2235 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); 2237 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */);
2236 parse_error::ParseError result = 2238 if (values == NULL) {
2237 ValidateVertexAttrib1fv(this, immediate_data_size, indx, values); 2239 return parse_error::kParseOutOfBounds;
2238 if (result != parse_error::kParseNoError) {
2239 return result;
2240 } 2240 }
2241 glVertexAttrib1fv(indx, values); 2241 glVertexAttrib1fv(indx, values);
2242 return parse_error::kParseNoError; 2242 return parse_error::kParseNoError;
2243 } 2243 }
2244 2244
2245 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1fvImmediate( 2245 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
2246 uint32 immediate_data_size, const gles2::VertexAttrib1fvImmediate& c) { 2246 uint32 immediate_data_size, const gles2::VertexAttrib1fvImmediate& c) {
2247 GLuint indx = static_cast<GLuint>(c.indx); 2247 GLuint indx = static_cast<GLuint>(c.indx);
2248 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); 2248 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c);
2249 if (values == NULL) {
2250 return parse_error::kParseOutOfBounds;
2251 }
2252 if (!CheckImmediateDataSize<VertexAttrib1fvImmediate>(
2253 immediate_data_size, 1, sizeof(GLfloat), 1)) {
2254 return parse_error::kParseOutOfBounds;
2255 }
2249 // Immediate version. 2256 // Immediate version.
2250 parse_error::ParseError result = 2257 if (values == NULL) {
2251 ValidateVertexAttrib1fvImmediate( 2258 return parse_error::kParseOutOfBounds;
2252 this, immediate_data_size, indx, values); 2259 }
2253 if (result != parse_error::kParseNoError) { 2260 if (!CheckImmediateDataSize<VertexAttrib1fvImmediate>(
2254 return result; 2261 immediate_data_size, 1, sizeof(GLfloat), 1)) {
2262 return parse_error::kParseOutOfBounds;
2255 } 2263 }
2256 glVertexAttrib1fv(indx, values); 2264 glVertexAttrib1fv(indx, values);
2257 return parse_error::kParseNoError; 2265 return parse_error::kParseNoError;
2258 } 2266 }
2259 2267
2260 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2f( 2268 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2f(
2261 uint32 immediate_data_size, const gles2::VertexAttrib2f& c) { 2269 uint32 immediate_data_size, const gles2::VertexAttrib2f& c) {
2262 GLuint indx = static_cast<GLuint>(c.indx); 2270 GLuint indx = static_cast<GLuint>(c.indx);
2263 GLfloat x = static_cast<GLfloat>(c.x); 2271 GLfloat x = static_cast<GLfloat>(c.x);
2264 GLfloat y = static_cast<GLfloat>(c.y); 2272 GLfloat y = static_cast<GLfloat>(c.y);
2265 parse_error::ParseError result =
2266 ValidateVertexAttrib2f(this, immediate_data_size, indx, x, y);
2267 if (result != parse_error::kParseNoError) {
2268 return result;
2269 }
2270 glVertexAttrib2f(indx, x, y); 2273 glVertexAttrib2f(indx, x, y);
2271 return parse_error::kParseNoError; 2274 return parse_error::kParseNoError;
2272 } 2275 }
2273 2276
2274 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2fv( 2277 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2fv(
2275 uint32 immediate_data_size, const gles2::VertexAttrib2fv& c) { 2278 uint32 immediate_data_size, const gles2::VertexAttrib2fv& c) {
2276 GLuint indx = static_cast<GLuint>(c.indx); 2279 GLuint indx = static_cast<GLuint>(c.indx);
2277 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( 2280 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>(
2278 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); 2281 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */);
2279 parse_error::ParseError result = 2282 if (values == NULL) {
2280 ValidateVertexAttrib2fv(this, immediate_data_size, indx, values); 2283 return parse_error::kParseOutOfBounds;
2281 if (result != parse_error::kParseNoError) {
2282 return result;
2283 } 2284 }
2284 glVertexAttrib2fv(indx, values); 2285 glVertexAttrib2fv(indx, values);
2285 return parse_error::kParseNoError; 2286 return parse_error::kParseNoError;
2286 } 2287 }
2287 2288
2288 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2fvImmediate( 2289 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
2289 uint32 immediate_data_size, const gles2::VertexAttrib2fvImmediate& c) { 2290 uint32 immediate_data_size, const gles2::VertexAttrib2fvImmediate& c) {
2290 GLuint indx = static_cast<GLuint>(c.indx); 2291 GLuint indx = static_cast<GLuint>(c.indx);
2291 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); 2292 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c);
2293 if (values == NULL) {
2294 return parse_error::kParseOutOfBounds;
2295 }
2296 if (!CheckImmediateDataSize<VertexAttrib2fvImmediate>(
2297 immediate_data_size, 1, sizeof(GLfloat), 2)) {
2298 return parse_error::kParseOutOfBounds;
2299 }
2292 // Immediate version. 2300 // Immediate version.
2293 parse_error::ParseError result = 2301 if (values == NULL) {
2294 ValidateVertexAttrib2fvImmediate( 2302 return parse_error::kParseOutOfBounds;
2295 this, immediate_data_size, indx, values); 2303 }
2296 if (result != parse_error::kParseNoError) { 2304 if (!CheckImmediateDataSize<VertexAttrib2fvImmediate>(
2297 return result; 2305 immediate_data_size, 1, sizeof(GLfloat), 2)) {
2306 return parse_error::kParseOutOfBounds;
2298 } 2307 }
2299 glVertexAttrib2fv(indx, values); 2308 glVertexAttrib2fv(indx, values);
2300 return parse_error::kParseNoError; 2309 return parse_error::kParseNoError;
2301 } 2310 }
2302 2311
2303 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3f( 2312 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3f(
2304 uint32 immediate_data_size, const gles2::VertexAttrib3f& c) { 2313 uint32 immediate_data_size, const gles2::VertexAttrib3f& c) {
2305 GLuint indx = static_cast<GLuint>(c.indx); 2314 GLuint indx = static_cast<GLuint>(c.indx);
2306 GLfloat x = static_cast<GLfloat>(c.x); 2315 GLfloat x = static_cast<GLfloat>(c.x);
2307 GLfloat y = static_cast<GLfloat>(c.y); 2316 GLfloat y = static_cast<GLfloat>(c.y);
2308 GLfloat z = static_cast<GLfloat>(c.z); 2317 GLfloat z = static_cast<GLfloat>(c.z);
2309 parse_error::ParseError result =
2310 ValidateVertexAttrib3f(this, immediate_data_size, indx, x, y, z);
2311 if (result != parse_error::kParseNoError) {
2312 return result;
2313 }
2314 glVertexAttrib3f(indx, x, y, z); 2318 glVertexAttrib3f(indx, x, y, z);
2315 return parse_error::kParseNoError; 2319 return parse_error::kParseNoError;
2316 } 2320 }
2317 2321
2318 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3fv( 2322 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3fv(
2319 uint32 immediate_data_size, const gles2::VertexAttrib3fv& c) { 2323 uint32 immediate_data_size, const gles2::VertexAttrib3fv& c) {
2320 GLuint indx = static_cast<GLuint>(c.indx); 2324 GLuint indx = static_cast<GLuint>(c.indx);
2321 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( 2325 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>(
2322 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); 2326 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */);
2323 parse_error::ParseError result = 2327 if (values == NULL) {
2324 ValidateVertexAttrib3fv(this, immediate_data_size, indx, values); 2328 return parse_error::kParseOutOfBounds;
2325 if (result != parse_error::kParseNoError) {
2326 return result;
2327 } 2329 }
2328 glVertexAttrib3fv(indx, values); 2330 glVertexAttrib3fv(indx, values);
2329 return parse_error::kParseNoError; 2331 return parse_error::kParseNoError;
2330 } 2332 }
2331 2333
2332 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3fvImmediate( 2334 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
2333 uint32 immediate_data_size, const gles2::VertexAttrib3fvImmediate& c) { 2335 uint32 immediate_data_size, const gles2::VertexAttrib3fvImmediate& c) {
2334 GLuint indx = static_cast<GLuint>(c.indx); 2336 GLuint indx = static_cast<GLuint>(c.indx);
2335 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); 2337 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c);
2338 if (values == NULL) {
2339 return parse_error::kParseOutOfBounds;
2340 }
2341 if (!CheckImmediateDataSize<VertexAttrib3fvImmediate>(
2342 immediate_data_size, 1, sizeof(GLfloat), 3)) {
2343 return parse_error::kParseOutOfBounds;
2344 }
2336 // Immediate version. 2345 // Immediate version.
2337 parse_error::ParseError result = 2346 if (values == NULL) {
2338 ValidateVertexAttrib3fvImmediate( 2347 return parse_error::kParseOutOfBounds;
2339 this, immediate_data_size, indx, values); 2348 }
2340 if (result != parse_error::kParseNoError) { 2349 if (!CheckImmediateDataSize<VertexAttrib3fvImmediate>(
2341 return result; 2350 immediate_data_size, 1, sizeof(GLfloat), 3)) {
2351 return parse_error::kParseOutOfBounds;
2342 } 2352 }
2343 glVertexAttrib3fv(indx, values); 2353 glVertexAttrib3fv(indx, values);
2344 return parse_error::kParseNoError; 2354 return parse_error::kParseNoError;
2345 } 2355 }
2346 2356
2347 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4f( 2357 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4f(
2348 uint32 immediate_data_size, const gles2::VertexAttrib4f& c) { 2358 uint32 immediate_data_size, const gles2::VertexAttrib4f& c) {
2349 GLuint indx = static_cast<GLuint>(c.indx); 2359 GLuint indx = static_cast<GLuint>(c.indx);
2350 GLfloat x = static_cast<GLfloat>(c.x); 2360 GLfloat x = static_cast<GLfloat>(c.x);
2351 GLfloat y = static_cast<GLfloat>(c.y); 2361 GLfloat y = static_cast<GLfloat>(c.y);
2352 GLfloat z = static_cast<GLfloat>(c.z); 2362 GLfloat z = static_cast<GLfloat>(c.z);
2353 GLfloat w = static_cast<GLfloat>(c.w); 2363 GLfloat w = static_cast<GLfloat>(c.w);
2354 parse_error::ParseError result =
2355 ValidateVertexAttrib4f(this, immediate_data_size, indx, x, y, z, w);
2356 if (result != parse_error::kParseNoError) {
2357 return result;
2358 }
2359 glVertexAttrib4f(indx, x, y, z, w); 2364 glVertexAttrib4f(indx, x, y, z, w);
2360 return parse_error::kParseNoError; 2365 return parse_error::kParseNoError;
2361 } 2366 }
2362 2367
2363 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4fv( 2368 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4fv(
2364 uint32 immediate_data_size, const gles2::VertexAttrib4fv& c) { 2369 uint32 immediate_data_size, const gles2::VertexAttrib4fv& c) {
2365 GLuint indx = static_cast<GLuint>(c.indx); 2370 GLuint indx = static_cast<GLuint>(c.indx);
2366 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( 2371 const GLfloat* values = GetSharedMemoryAs<const GLfloat*>(
2367 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); 2372 c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */);
2368 parse_error::ParseError result = 2373 if (values == NULL) {
2369 ValidateVertexAttrib4fv(this, immediate_data_size, indx, values); 2374 return parse_error::kParseOutOfBounds;
2370 if (result != parse_error::kParseNoError) {
2371 return result;
2372 } 2375 }
2373 glVertexAttrib4fv(indx, values); 2376 glVertexAttrib4fv(indx, values);
2374 return parse_error::kParseNoError; 2377 return parse_error::kParseNoError;
2375 } 2378 }
2376 2379
2377 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4fvImmediate( 2380 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
2378 uint32 immediate_data_size, const gles2::VertexAttrib4fvImmediate& c) { 2381 uint32 immediate_data_size, const gles2::VertexAttrib4fvImmediate& c) {
2379 GLuint indx = static_cast<GLuint>(c.indx); 2382 GLuint indx = static_cast<GLuint>(c.indx);
2380 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); 2383 const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c);
2384 if (values == NULL) {
2385 return parse_error::kParseOutOfBounds;
2386 }
2387 if (!CheckImmediateDataSize<VertexAttrib4fvImmediate>(
2388 immediate_data_size, 1, sizeof(GLfloat), 4)) {
2389 return parse_error::kParseOutOfBounds;
2390 }
2381 // Immediate version. 2391 // Immediate version.
2382 parse_error::ParseError result = 2392 if (values == NULL) {
2383 ValidateVertexAttrib4fvImmediate( 2393 return parse_error::kParseOutOfBounds;
2384 this, immediate_data_size, indx, values); 2394 }
2385 if (result != parse_error::kParseNoError) { 2395 if (!CheckImmediateDataSize<VertexAttrib4fvImmediate>(
2386 return result; 2396 immediate_data_size, 1, sizeof(GLfloat), 4)) {
2397 return parse_error::kParseOutOfBounds;
2387 } 2398 }
2388 glVertexAttrib4fv(indx, values); 2399 glVertexAttrib4fv(indx, values);
2389 return parse_error::kParseNoError; 2400 return parse_error::kParseNoError;
2390 } 2401 }
2391 2402
2392 parse_error::ParseError GLES2DecoderImpl::HandleViewport( 2403 parse_error::ParseError GLES2DecoderImpl::HandleViewport(
2393 uint32 immediate_data_size, const gles2::Viewport& c) { 2404 uint32 immediate_data_size, const gles2::Viewport& c) {
2394 GLint x = static_cast<GLint>(c.x); 2405 GLint x = static_cast<GLint>(c.x);
2395 GLint y = static_cast<GLint>(c.y); 2406 GLint y = static_cast<GLint>(c.y);
2396 GLsizei width = static_cast<GLsizei>(c.width); 2407 GLsizei width = static_cast<GLsizei>(c.width);
2397 GLsizei height = static_cast<GLsizei>(c.height); 2408 GLsizei height = static_cast<GLsizei>(c.height);
2398 parse_error::ParseError result =
2399 ValidateViewport(this, immediate_data_size, x, y, width, height);
2400 if (result != parse_error::kParseNoError) {
2401 return result;
2402 }
2403 glViewport(x, y, width, height); 2409 glViewport(x, y, width, height);
2404 return parse_error::kParseNoError; 2410 return parse_error::kParseNoError;
2405 } 2411 }
2406 2412
2407 parse_error::ParseError GLES2DecoderImpl::HandleSwapBuffers( 2413 parse_error::ParseError GLES2DecoderImpl::HandleSwapBuffers(
2408 uint32 immediate_data_size, const gles2::SwapBuffers& c) { 2414 uint32 immediate_data_size, const gles2::SwapBuffers& c) {
2409 parse_error::ParseError result =
2410 ValidateSwapBuffers(this, immediate_data_size);
2411 if (result != parse_error::kParseNoError) {
2412 return result;
2413 }
2414 DoSwapBuffers(); 2415 DoSwapBuffers();
2415 return parse_error::kParseNoError; 2416 return parse_error::kParseNoError;
2416 } 2417 }
2417 2418
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_validate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698