Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_autogen.h
blob9a27c2f9f4f048ccd4e29aab08ae439196cb3919
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
9 // DO NOT EDIT!
11 // It is included by gles2_cmd_decoder.cc
12 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
13 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
15 error::Error GLES2DecoderImpl::HandleActiveTexture(uint32_t immediate_data_size,
16 const void* cmd_data) {
17 const gles2::cmds::ActiveTexture& c =
18 *static_cast<const gles2::cmds::ActiveTexture*>(cmd_data);
19 (void)c;
20 GLenum texture = static_cast<GLenum>(c.texture);
21 DoActiveTexture(texture);
22 return error::kNoError;
25 error::Error GLES2DecoderImpl::HandleAttachShader(uint32_t immediate_data_size,
26 const void* cmd_data) {
27 const gles2::cmds::AttachShader& c =
28 *static_cast<const gles2::cmds::AttachShader*>(cmd_data);
29 (void)c;
30 GLuint program = c.program;
31 GLuint shader = c.shader;
32 DoAttachShader(program, shader);
33 return error::kNoError;
36 error::Error GLES2DecoderImpl::HandleBindBuffer(uint32_t immediate_data_size,
37 const void* cmd_data) {
38 const gles2::cmds::BindBuffer& c =
39 *static_cast<const gles2::cmds::BindBuffer*>(cmd_data);
40 (void)c;
41 GLenum target = static_cast<GLenum>(c.target);
42 GLuint buffer = c.buffer;
43 if (!validators_->buffer_target.IsValid(target)) {
44 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBuffer", target, "target");
45 return error::kNoError;
47 DoBindBuffer(target, buffer);
48 return error::kNoError;
51 error::Error GLES2DecoderImpl::HandleBindBufferBase(
52 uint32_t immediate_data_size,
53 const void* cmd_data) {
54 if (!unsafe_es3_apis_enabled())
55 return error::kUnknownCommand;
56 const gles2::cmds::BindBufferBase& c =
57 *static_cast<const gles2::cmds::BindBufferBase*>(cmd_data);
58 (void)c;
59 GLenum target = static_cast<GLenum>(c.target);
60 GLuint index = static_cast<GLuint>(c.index);
61 GLuint buffer = c.buffer;
62 if (!group_->GetBufferServiceId(buffer, &buffer)) {
63 if (!group_->bind_generates_resource()) {
64 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindBufferBase",
65 "invalid buffer id");
66 return error::kNoError;
68 GLuint client_id = buffer;
69 glGenBuffersARB(1, &buffer);
70 CreateBuffer(client_id, buffer);
72 glBindBufferBase(target, index, buffer);
73 return error::kNoError;
76 error::Error GLES2DecoderImpl::HandleBindBufferRange(
77 uint32_t immediate_data_size,
78 const void* cmd_data) {
79 if (!unsafe_es3_apis_enabled())
80 return error::kUnknownCommand;
81 const gles2::cmds::BindBufferRange& c =
82 *static_cast<const gles2::cmds::BindBufferRange*>(cmd_data);
83 (void)c;
84 GLenum target = static_cast<GLenum>(c.target);
85 GLuint index = static_cast<GLuint>(c.index);
86 GLuint buffer = c.buffer;
87 GLintptr offset = static_cast<GLintptr>(c.offset);
88 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
89 if (!group_->GetBufferServiceId(buffer, &buffer)) {
90 if (!group_->bind_generates_resource()) {
91 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindBufferRange",
92 "invalid buffer id");
93 return error::kNoError;
95 GLuint client_id = buffer;
96 glGenBuffersARB(1, &buffer);
97 CreateBuffer(client_id, buffer);
99 glBindBufferRange(target, index, buffer, offset, size);
100 return error::kNoError;
103 error::Error GLES2DecoderImpl::HandleBindFramebuffer(
104 uint32_t immediate_data_size,
105 const void* cmd_data) {
106 const gles2::cmds::BindFramebuffer& c =
107 *static_cast<const gles2::cmds::BindFramebuffer*>(cmd_data);
108 (void)c;
109 GLenum target = static_cast<GLenum>(c.target);
110 GLuint framebuffer = c.framebuffer;
111 if (!validators_->frame_buffer_target.IsValid(target)) {
112 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target, "target");
113 return error::kNoError;
115 DoBindFramebuffer(target, framebuffer);
116 return error::kNoError;
119 error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
120 uint32_t immediate_data_size,
121 const void* cmd_data) {
122 const gles2::cmds::BindRenderbuffer& c =
123 *static_cast<const gles2::cmds::BindRenderbuffer*>(cmd_data);
124 (void)c;
125 GLenum target = static_cast<GLenum>(c.target);
126 GLuint renderbuffer = c.renderbuffer;
127 if (!validators_->render_buffer_target.IsValid(target)) {
128 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target, "target");
129 return error::kNoError;
131 DoBindRenderbuffer(target, renderbuffer);
132 return error::kNoError;
135 error::Error GLES2DecoderImpl::HandleBindSampler(uint32_t immediate_data_size,
136 const void* cmd_data) {
137 if (!unsafe_es3_apis_enabled())
138 return error::kUnknownCommand;
139 const gles2::cmds::BindSampler& c =
140 *static_cast<const gles2::cmds::BindSampler*>(cmd_data);
141 (void)c;
142 GLuint unit = static_cast<GLuint>(c.unit);
143 GLuint sampler = c.sampler;
144 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
145 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindSampler",
146 "invalid sampler id");
147 return error::kNoError;
149 glBindSampler(unit, sampler);
150 return error::kNoError;
153 error::Error GLES2DecoderImpl::HandleBindTexture(uint32_t immediate_data_size,
154 const void* cmd_data) {
155 const gles2::cmds::BindTexture& c =
156 *static_cast<const gles2::cmds::BindTexture*>(cmd_data);
157 (void)c;
158 GLenum target = static_cast<GLenum>(c.target);
159 GLuint texture = c.texture;
160 if (!validators_->texture_bind_target.IsValid(target)) {
161 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target, "target");
162 return error::kNoError;
164 DoBindTexture(target, texture);
165 return error::kNoError;
168 error::Error GLES2DecoderImpl::HandleBindTransformFeedback(
169 uint32_t immediate_data_size,
170 const void* cmd_data) {
171 if (!unsafe_es3_apis_enabled())
172 return error::kUnknownCommand;
173 const gles2::cmds::BindTransformFeedback& c =
174 *static_cast<const gles2::cmds::BindTransformFeedback*>(cmd_data);
175 (void)c;
176 GLenum target = static_cast<GLenum>(c.target);
177 GLuint transformfeedback = c.transformfeedback;
178 if (!group_->GetTransformFeedbackServiceId(transformfeedback,
179 &transformfeedback)) {
180 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTransformFeedback",
181 "invalid transformfeedback id");
182 return error::kNoError;
184 glBindTransformFeedback(target, transformfeedback);
185 return error::kNoError;
188 error::Error GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size,
189 const void* cmd_data) {
190 const gles2::cmds::BlendColor& c =
191 *static_cast<const gles2::cmds::BlendColor*>(cmd_data);
192 (void)c;
193 GLclampf red = static_cast<GLclampf>(c.red);
194 GLclampf green = static_cast<GLclampf>(c.green);
195 GLclampf blue = static_cast<GLclampf>(c.blue);
196 GLclampf alpha = static_cast<GLclampf>(c.alpha);
197 if (state_.blend_color_red != red || state_.blend_color_green != green ||
198 state_.blend_color_blue != blue || state_.blend_color_alpha != alpha) {
199 state_.blend_color_red = red;
200 state_.blend_color_green = green;
201 state_.blend_color_blue = blue;
202 state_.blend_color_alpha = alpha;
203 glBlendColor(red, green, blue, alpha);
205 return error::kNoError;
208 error::Error GLES2DecoderImpl::HandleBlendEquation(uint32_t immediate_data_size,
209 const void* cmd_data) {
210 const gles2::cmds::BlendEquation& c =
211 *static_cast<const gles2::cmds::BlendEquation*>(cmd_data);
212 (void)c;
213 GLenum mode = static_cast<GLenum>(c.mode);
214 if (!validators_->equation.IsValid(mode)) {
215 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode, "mode");
216 return error::kNoError;
218 if (state_.blend_equation_rgb != mode ||
219 state_.blend_equation_alpha != mode) {
220 state_.blend_equation_rgb = mode;
221 state_.blend_equation_alpha = mode;
222 glBlendEquation(mode);
224 return error::kNoError;
227 error::Error GLES2DecoderImpl::HandleBlendEquationSeparate(
228 uint32_t immediate_data_size,
229 const void* cmd_data) {
230 const gles2::cmds::BlendEquationSeparate& c =
231 *static_cast<const gles2::cmds::BlendEquationSeparate*>(cmd_data);
232 (void)c;
233 GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
234 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
235 if (!validators_->equation.IsValid(modeRGB)) {
236 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB,
237 "modeRGB");
238 return error::kNoError;
240 if (!validators_->equation.IsValid(modeAlpha)) {
241 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha,
242 "modeAlpha");
243 return error::kNoError;
245 if (state_.blend_equation_rgb != modeRGB ||
246 state_.blend_equation_alpha != modeAlpha) {
247 state_.blend_equation_rgb = modeRGB;
248 state_.blend_equation_alpha = modeAlpha;
249 glBlendEquationSeparate(modeRGB, modeAlpha);
251 return error::kNoError;
254 error::Error GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size,
255 const void* cmd_data) {
256 const gles2::cmds::BlendFunc& c =
257 *static_cast<const gles2::cmds::BlendFunc*>(cmd_data);
258 (void)c;
259 GLenum sfactor = static_cast<GLenum>(c.sfactor);
260 GLenum dfactor = static_cast<GLenum>(c.dfactor);
261 if (!validators_->src_blend_factor.IsValid(sfactor)) {
262 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor, "sfactor");
263 return error::kNoError;
265 if (!validators_->dst_blend_factor.IsValid(dfactor)) {
266 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor, "dfactor");
267 return error::kNoError;
269 if (state_.blend_source_rgb != sfactor || state_.blend_dest_rgb != dfactor ||
270 state_.blend_source_alpha != sfactor ||
271 state_.blend_dest_alpha != dfactor) {
272 state_.blend_source_rgb = sfactor;
273 state_.blend_dest_rgb = dfactor;
274 state_.blend_source_alpha = sfactor;
275 state_.blend_dest_alpha = dfactor;
276 glBlendFunc(sfactor, dfactor);
278 return error::kNoError;
281 error::Error GLES2DecoderImpl::HandleBlendFuncSeparate(
282 uint32_t immediate_data_size,
283 const void* cmd_data) {
284 const gles2::cmds::BlendFuncSeparate& c =
285 *static_cast<const gles2::cmds::BlendFuncSeparate*>(cmd_data);
286 (void)c;
287 GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
288 GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
289 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
290 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
291 if (!validators_->src_blend_factor.IsValid(srcRGB)) {
292 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB, "srcRGB");
293 return error::kNoError;
295 if (!validators_->dst_blend_factor.IsValid(dstRGB)) {
296 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB, "dstRGB");
297 return error::kNoError;
299 if (!validators_->src_blend_factor.IsValid(srcAlpha)) {
300 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha,
301 "srcAlpha");
302 return error::kNoError;
304 if (!validators_->dst_blend_factor.IsValid(dstAlpha)) {
305 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha,
306 "dstAlpha");
307 return error::kNoError;
309 if (state_.blend_source_rgb != srcRGB || state_.blend_dest_rgb != dstRGB ||
310 state_.blend_source_alpha != srcAlpha ||
311 state_.blend_dest_alpha != dstAlpha) {
312 state_.blend_source_rgb = srcRGB;
313 state_.blend_dest_rgb = dstRGB;
314 state_.blend_source_alpha = srcAlpha;
315 state_.blend_dest_alpha = dstAlpha;
316 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
318 return error::kNoError;
321 error::Error GLES2DecoderImpl::HandleBufferSubData(uint32_t immediate_data_size,
322 const void* cmd_data) {
323 const gles2::cmds::BufferSubData& c =
324 *static_cast<const gles2::cmds::BufferSubData*>(cmd_data);
325 (void)c;
326 GLenum target = static_cast<GLenum>(c.target);
327 GLintptr offset = static_cast<GLintptr>(c.offset);
328 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
329 uint32_t data_size = size;
330 const void* data = GetSharedMemoryAs<const void*>(
331 c.data_shm_id, c.data_shm_offset, data_size);
332 if (!validators_->buffer_target.IsValid(target)) {
333 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target, "target");
334 return error::kNoError;
336 if (size < 0) {
337 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
338 return error::kNoError;
340 if (data == NULL) {
341 return error::kOutOfBounds;
343 DoBufferSubData(target, offset, size, data);
344 return error::kNoError;
347 error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus(
348 uint32_t immediate_data_size,
349 const void* cmd_data) {
350 const gles2::cmds::CheckFramebufferStatus& c =
351 *static_cast<const gles2::cmds::CheckFramebufferStatus*>(cmd_data);
352 (void)c;
353 GLenum target = static_cast<GLenum>(c.target);
354 typedef cmds::CheckFramebufferStatus::Result Result;
355 Result* result_dst = GetSharedMemoryAs<Result*>(
356 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
357 if (!result_dst) {
358 return error::kOutOfBounds;
360 if (!validators_->frame_buffer_target.IsValid(target)) {
361 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target,
362 "target");
363 return error::kNoError;
365 *result_dst = DoCheckFramebufferStatus(target);
366 return error::kNoError;
369 error::Error GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size,
370 const void* cmd_data) {
371 const gles2::cmds::Clear& c =
372 *static_cast<const gles2::cmds::Clear*>(cmd_data);
373 (void)c;
374 error::Error error;
375 error = WillAccessBoundFramebufferForDraw();
376 if (error != error::kNoError)
377 return error;
378 GLbitfield mask = static_cast<GLbitfield>(c.mask);
379 DoClear(mask);
380 return error::kNoError;
383 error::Error GLES2DecoderImpl::HandleClearBufferfi(uint32_t immediate_data_size,
384 const void* cmd_data) {
385 if (!unsafe_es3_apis_enabled())
386 return error::kUnknownCommand;
387 const gles2::cmds::ClearBufferfi& c =
388 *static_cast<const gles2::cmds::ClearBufferfi*>(cmd_data);
389 (void)c;
390 GLenum buffer = static_cast<GLenum>(c.buffer);
391 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
392 GLfloat depth = static_cast<GLfloat>(c.depth);
393 GLint stencil = static_cast<GLint>(c.stencil);
394 glClearBufferfi(buffer, drawbuffers, depth, stencil);
395 return error::kNoError;
398 error::Error GLES2DecoderImpl::HandleClearBufferfvImmediate(
399 uint32_t immediate_data_size,
400 const void* cmd_data) {
401 if (!unsafe_es3_apis_enabled())
402 return error::kUnknownCommand;
403 const gles2::cmds::ClearBufferfvImmediate& c =
404 *static_cast<const gles2::cmds::ClearBufferfvImmediate*>(cmd_data);
405 (void)c;
406 GLenum buffer = static_cast<GLenum>(c.buffer);
407 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
408 uint32_t data_size;
409 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
410 return error::kOutOfBounds;
412 if (data_size > immediate_data_size) {
413 return error::kOutOfBounds;
415 const GLfloat* value =
416 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
417 if (value == NULL) {
418 return error::kOutOfBounds;
420 glClearBufferfv(buffer, drawbuffers, value);
421 return error::kNoError;
424 error::Error GLES2DecoderImpl::HandleClearBufferivImmediate(
425 uint32_t immediate_data_size,
426 const void* cmd_data) {
427 if (!unsafe_es3_apis_enabled())
428 return error::kUnknownCommand;
429 const gles2::cmds::ClearBufferivImmediate& c =
430 *static_cast<const gles2::cmds::ClearBufferivImmediate*>(cmd_data);
431 (void)c;
432 GLenum buffer = static_cast<GLenum>(c.buffer);
433 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
434 uint32_t data_size;
435 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
436 return error::kOutOfBounds;
438 if (data_size > immediate_data_size) {
439 return error::kOutOfBounds;
441 const GLint* value =
442 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
443 if (value == NULL) {
444 return error::kOutOfBounds;
446 glClearBufferiv(buffer, drawbuffers, value);
447 return error::kNoError;
450 error::Error GLES2DecoderImpl::HandleClearBufferuivImmediate(
451 uint32_t immediate_data_size,
452 const void* cmd_data) {
453 if (!unsafe_es3_apis_enabled())
454 return error::kUnknownCommand;
455 const gles2::cmds::ClearBufferuivImmediate& c =
456 *static_cast<const gles2::cmds::ClearBufferuivImmediate*>(cmd_data);
457 (void)c;
458 GLenum buffer = static_cast<GLenum>(c.buffer);
459 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
460 uint32_t data_size;
461 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
462 return error::kOutOfBounds;
464 if (data_size > immediate_data_size) {
465 return error::kOutOfBounds;
467 const GLuint* value =
468 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
469 if (value == NULL) {
470 return error::kOutOfBounds;
472 glClearBufferuiv(buffer, drawbuffers, value);
473 return error::kNoError;
476 error::Error GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size,
477 const void* cmd_data) {
478 const gles2::cmds::ClearColor& c =
479 *static_cast<const gles2::cmds::ClearColor*>(cmd_data);
480 (void)c;
481 GLclampf red = static_cast<GLclampf>(c.red);
482 GLclampf green = static_cast<GLclampf>(c.green);
483 GLclampf blue = static_cast<GLclampf>(c.blue);
484 GLclampf alpha = static_cast<GLclampf>(c.alpha);
485 if (state_.color_clear_red != red || state_.color_clear_green != green ||
486 state_.color_clear_blue != blue || state_.color_clear_alpha != alpha) {
487 state_.color_clear_red = red;
488 state_.color_clear_green = green;
489 state_.color_clear_blue = blue;
490 state_.color_clear_alpha = alpha;
491 glClearColor(red, green, blue, alpha);
493 return error::kNoError;
496 error::Error GLES2DecoderImpl::HandleClearDepthf(uint32_t immediate_data_size,
497 const void* cmd_data) {
498 const gles2::cmds::ClearDepthf& c =
499 *static_cast<const gles2::cmds::ClearDepthf*>(cmd_data);
500 (void)c;
501 GLclampf depth = static_cast<GLclampf>(c.depth);
502 if (state_.depth_clear != depth) {
503 state_.depth_clear = depth;
504 glClearDepth(depth);
506 return error::kNoError;
509 error::Error GLES2DecoderImpl::HandleClearStencil(uint32_t immediate_data_size,
510 const void* cmd_data) {
511 const gles2::cmds::ClearStencil& c =
512 *static_cast<const gles2::cmds::ClearStencil*>(cmd_data);
513 (void)c;
514 GLint s = static_cast<GLint>(c.s);
515 if (state_.stencil_clear != s) {
516 state_.stencil_clear = s;
517 glClearStencil(s);
519 return error::kNoError;
522 error::Error GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size,
523 const void* cmd_data) {
524 const gles2::cmds::ColorMask& c =
525 *static_cast<const gles2::cmds::ColorMask*>(cmd_data);
526 (void)c;
527 GLboolean red = static_cast<GLboolean>(c.red);
528 GLboolean green = static_cast<GLboolean>(c.green);
529 GLboolean blue = static_cast<GLboolean>(c.blue);
530 GLboolean alpha = static_cast<GLboolean>(c.alpha);
531 if (state_.color_mask_red != red || state_.color_mask_green != green ||
532 state_.color_mask_blue != blue || state_.color_mask_alpha != alpha) {
533 state_.color_mask_red = red;
534 state_.color_mask_green = green;
535 state_.color_mask_blue = blue;
536 state_.color_mask_alpha = alpha;
537 framebuffer_state_.clear_state_dirty = true;
539 return error::kNoError;
542 error::Error GLES2DecoderImpl::HandleCompileShader(uint32_t immediate_data_size,
543 const void* cmd_data) {
544 const gles2::cmds::CompileShader& c =
545 *static_cast<const gles2::cmds::CompileShader*>(cmd_data);
546 (void)c;
547 GLuint shader = c.shader;
548 DoCompileShader(shader);
549 return error::kNoError;
552 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2D(
553 uint32_t immediate_data_size,
554 const void* cmd_data) {
555 const gles2::cmds::CompressedTexSubImage2D& c =
556 *static_cast<const gles2::cmds::CompressedTexSubImage2D*>(cmd_data);
557 (void)c;
558 GLenum target = static_cast<GLenum>(c.target);
559 GLint level = static_cast<GLint>(c.level);
560 GLint xoffset = static_cast<GLint>(c.xoffset);
561 GLint yoffset = static_cast<GLint>(c.yoffset);
562 GLsizei width = static_cast<GLsizei>(c.width);
563 GLsizei height = static_cast<GLsizei>(c.height);
564 GLenum format = static_cast<GLenum>(c.format);
565 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
566 uint32_t data_size = imageSize;
567 const void* data = GetSharedMemoryAs<const void*>(
568 c.data_shm_id, c.data_shm_offset, data_size);
569 if (!validators_->texture_target.IsValid(target)) {
570 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", target,
571 "target");
572 return error::kNoError;
574 if (width < 0) {
575 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
576 "width < 0");
577 return error::kNoError;
579 if (height < 0) {
580 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
581 "height < 0");
582 return error::kNoError;
584 if (!validators_->compressed_texture_format.IsValid(format)) {
585 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", format,
586 "format");
587 return error::kNoError;
589 if (imageSize < 0) {
590 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
591 "imageSize < 0");
592 return error::kNoError;
594 if (data == NULL) {
595 return error::kOutOfBounds;
597 DoCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
598 format, imageSize, data);
599 return error::kNoError;
602 error::Error GLES2DecoderImpl::HandleCopyBufferSubData(
603 uint32_t immediate_data_size,
604 const void* cmd_data) {
605 if (!unsafe_es3_apis_enabled())
606 return error::kUnknownCommand;
607 const gles2::cmds::CopyBufferSubData& c =
608 *static_cast<const gles2::cmds::CopyBufferSubData*>(cmd_data);
609 (void)c;
610 GLenum readtarget = static_cast<GLenum>(c.readtarget);
611 GLenum writetarget = static_cast<GLenum>(c.writetarget);
612 GLintptr readoffset = static_cast<GLintptr>(c.readoffset);
613 GLintptr writeoffset = static_cast<GLintptr>(c.writeoffset);
614 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
615 glCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
616 return error::kNoError;
619 error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
620 uint32_t immediate_data_size,
621 const void* cmd_data) {
622 const gles2::cmds::CopyTexImage2D& c =
623 *static_cast<const gles2::cmds::CopyTexImage2D*>(cmd_data);
624 (void)c;
625 error::Error error;
626 error = WillAccessBoundFramebufferForRead();
627 if (error != error::kNoError)
628 return error;
629 GLenum target = static_cast<GLenum>(c.target);
630 GLint level = static_cast<GLint>(c.level);
631 GLenum internalformat = static_cast<GLenum>(c.internalformat);
632 GLint x = static_cast<GLint>(c.x);
633 GLint y = static_cast<GLint>(c.y);
634 GLsizei width = static_cast<GLsizei>(c.width);
635 GLsizei height = static_cast<GLsizei>(c.height);
636 GLint border = static_cast<GLint>(c.border);
637 if (!validators_->texture_target.IsValid(target)) {
638 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target, "target");
639 return error::kNoError;
641 if (!validators_->texture_internal_format.IsValid(internalformat)) {
642 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat,
643 "internalformat");
644 return error::kNoError;
646 if (width < 0) {
647 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
648 return error::kNoError;
650 if (height < 0) {
651 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
652 return error::kNoError;
654 DoCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
655 return error::kNoError;
658 error::Error GLES2DecoderImpl::HandleCopyTexSubImage2D(
659 uint32_t immediate_data_size,
660 const void* cmd_data) {
661 const gles2::cmds::CopyTexSubImage2D& c =
662 *static_cast<const gles2::cmds::CopyTexSubImage2D*>(cmd_data);
663 (void)c;
664 error::Error error;
665 error = WillAccessBoundFramebufferForRead();
666 if (error != error::kNoError)
667 return error;
668 GLenum target = static_cast<GLenum>(c.target);
669 GLint level = static_cast<GLint>(c.level);
670 GLint xoffset = static_cast<GLint>(c.xoffset);
671 GLint yoffset = static_cast<GLint>(c.yoffset);
672 GLint x = static_cast<GLint>(c.x);
673 GLint y = static_cast<GLint>(c.y);
674 GLsizei width = static_cast<GLsizei>(c.width);
675 GLsizei height = static_cast<GLsizei>(c.height);
676 if (!validators_->texture_target.IsValid(target)) {
677 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target, "target");
678 return error::kNoError;
680 if (width < 0) {
681 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
682 return error::kNoError;
684 if (height < 0) {
685 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
686 return error::kNoError;
688 DoCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
689 return error::kNoError;
692 error::Error GLES2DecoderImpl::HandleCopyTexSubImage3D(
693 uint32_t immediate_data_size,
694 const void* cmd_data) {
695 if (!unsafe_es3_apis_enabled())
696 return error::kUnknownCommand;
697 const gles2::cmds::CopyTexSubImage3D& c =
698 *static_cast<const gles2::cmds::CopyTexSubImage3D*>(cmd_data);
699 (void)c;
700 error::Error error;
701 error = WillAccessBoundFramebufferForRead();
702 if (error != error::kNoError)
703 return error;
704 GLenum target = static_cast<GLenum>(c.target);
705 GLint level = static_cast<GLint>(c.level);
706 GLint xoffset = static_cast<GLint>(c.xoffset);
707 GLint yoffset = static_cast<GLint>(c.yoffset);
708 GLint zoffset = static_cast<GLint>(c.zoffset);
709 GLint x = static_cast<GLint>(c.x);
710 GLint y = static_cast<GLint>(c.y);
711 GLsizei width = static_cast<GLsizei>(c.width);
712 GLsizei height = static_cast<GLsizei>(c.height);
713 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
714 height);
715 return error::kNoError;
718 error::Error GLES2DecoderImpl::HandleCreateProgram(uint32_t immediate_data_size,
719 const void* cmd_data) {
720 const gles2::cmds::CreateProgram& c =
721 *static_cast<const gles2::cmds::CreateProgram*>(cmd_data);
722 (void)c;
723 uint32_t client_id = c.client_id;
724 if (GetProgram(client_id)) {
725 return error::kInvalidArguments;
727 GLuint service_id = glCreateProgram();
728 if (service_id) {
729 CreateProgram(client_id, service_id);
731 return error::kNoError;
734 error::Error GLES2DecoderImpl::HandleCreateShader(uint32_t immediate_data_size,
735 const void* cmd_data) {
736 const gles2::cmds::CreateShader& c =
737 *static_cast<const gles2::cmds::CreateShader*>(cmd_data);
738 (void)c;
739 GLenum type = static_cast<GLenum>(c.type);
740 if (!validators_->shader_type.IsValid(type)) {
741 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type, "type");
742 return error::kNoError;
744 uint32_t client_id = c.client_id;
745 if (GetShader(client_id)) {
746 return error::kInvalidArguments;
748 GLuint service_id = glCreateShader(type);
749 if (service_id) {
750 CreateShader(client_id, service_id, type);
752 return error::kNoError;
755 error::Error GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size,
756 const void* cmd_data) {
757 const gles2::cmds::CullFace& c =
758 *static_cast<const gles2::cmds::CullFace*>(cmd_data);
759 (void)c;
760 GLenum mode = static_cast<GLenum>(c.mode);
761 if (!validators_->face_type.IsValid(mode)) {
762 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode, "mode");
763 return error::kNoError;
765 if (state_.cull_mode != mode) {
766 state_.cull_mode = mode;
767 glCullFace(mode);
769 return error::kNoError;
772 error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
773 uint32_t immediate_data_size,
774 const void* cmd_data) {
775 const gles2::cmds::DeleteBuffersImmediate& c =
776 *static_cast<const gles2::cmds::DeleteBuffersImmediate*>(cmd_data);
777 (void)c;
778 GLsizei n = static_cast<GLsizei>(c.n);
779 uint32_t data_size;
780 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
781 return error::kOutOfBounds;
783 const GLuint* buffers =
784 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
785 if (buffers == NULL) {
786 return error::kOutOfBounds;
788 DeleteBuffersHelper(n, buffers);
789 return error::kNoError;
792 error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
793 uint32_t immediate_data_size,
794 const void* cmd_data) {
795 const gles2::cmds::DeleteFramebuffersImmediate& c =
796 *static_cast<const gles2::cmds::DeleteFramebuffersImmediate*>(cmd_data);
797 (void)c;
798 GLsizei n = static_cast<GLsizei>(c.n);
799 uint32_t data_size;
800 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
801 return error::kOutOfBounds;
803 const GLuint* framebuffers =
804 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
805 if (framebuffers == NULL) {
806 return error::kOutOfBounds;
808 DeleteFramebuffersHelper(n, framebuffers);
809 return error::kNoError;
812 error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
813 uint32_t immediate_data_size,
814 const void* cmd_data) {
815 const gles2::cmds::DeleteRenderbuffersImmediate& c =
816 *static_cast<const gles2::cmds::DeleteRenderbuffersImmediate*>(cmd_data);
817 (void)c;
818 GLsizei n = static_cast<GLsizei>(c.n);
819 uint32_t data_size;
820 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
821 return error::kOutOfBounds;
823 const GLuint* renderbuffers =
824 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
825 if (renderbuffers == NULL) {
826 return error::kOutOfBounds;
828 DeleteRenderbuffersHelper(n, renderbuffers);
829 return error::kNoError;
832 error::Error GLES2DecoderImpl::HandleDeleteSamplersImmediate(
833 uint32_t immediate_data_size,
834 const void* cmd_data) {
835 if (!unsafe_es3_apis_enabled())
836 return error::kUnknownCommand;
837 const gles2::cmds::DeleteSamplersImmediate& c =
838 *static_cast<const gles2::cmds::DeleteSamplersImmediate*>(cmd_data);
839 (void)c;
840 GLsizei n = static_cast<GLsizei>(c.n);
841 uint32_t data_size;
842 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
843 return error::kOutOfBounds;
845 const GLuint* samplers =
846 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
847 if (samplers == NULL) {
848 return error::kOutOfBounds;
850 for (GLsizei ii = 0; ii < n; ++ii) {
851 GLuint service_id = 0;
852 if (group_->GetSamplerServiceId(samplers[ii], &service_id)) {
853 glDeleteSamplers(1, &service_id);
854 group_->RemoveSamplerId(samplers[ii]);
857 return error::kNoError;
860 error::Error GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size,
861 const void* cmd_data) {
862 if (!unsafe_es3_apis_enabled())
863 return error::kUnknownCommand;
864 const gles2::cmds::DeleteSync& c =
865 *static_cast<const gles2::cmds::DeleteSync*>(cmd_data);
866 (void)c;
867 GLuint sync = c.sync;
868 GLsync service_id = 0;
869 if (group_->GetSyncServiceId(sync, &service_id)) {
870 glDeleteSync(service_id);
871 group_->RemoveSyncId(sync);
872 } else {
873 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDeleteSync", "unknown sync");
875 return error::kNoError;
878 error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
879 uint32_t immediate_data_size,
880 const void* cmd_data) {
881 const gles2::cmds::DeleteTexturesImmediate& c =
882 *static_cast<const gles2::cmds::DeleteTexturesImmediate*>(cmd_data);
883 (void)c;
884 GLsizei n = static_cast<GLsizei>(c.n);
885 uint32_t data_size;
886 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
887 return error::kOutOfBounds;
889 const GLuint* textures =
890 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
891 if (textures == NULL) {
892 return error::kOutOfBounds;
894 DeleteTexturesHelper(n, textures);
895 return error::kNoError;
898 error::Error GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
899 uint32_t immediate_data_size,
900 const void* cmd_data) {
901 if (!unsafe_es3_apis_enabled())
902 return error::kUnknownCommand;
903 const gles2::cmds::DeleteTransformFeedbacksImmediate& c =
904 *static_cast<const gles2::cmds::DeleteTransformFeedbacksImmediate*>(
905 cmd_data);
906 (void)c;
907 GLsizei n = static_cast<GLsizei>(c.n);
908 uint32_t data_size;
909 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
910 return error::kOutOfBounds;
912 const GLuint* ids =
913 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
914 if (ids == NULL) {
915 return error::kOutOfBounds;
917 for (GLsizei ii = 0; ii < n; ++ii) {
918 GLuint service_id = 0;
919 if (group_->GetTransformFeedbackServiceId(ids[ii], &service_id)) {
920 glDeleteTransformFeedbacks(1, &service_id);
921 group_->RemoveTransformFeedbackId(ids[ii]);
924 return error::kNoError;
927 error::Error GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size,
928 const void* cmd_data) {
929 const gles2::cmds::DepthFunc& c =
930 *static_cast<const gles2::cmds::DepthFunc*>(cmd_data);
931 (void)c;
932 GLenum func = static_cast<GLenum>(c.func);
933 if (!validators_->cmp_function.IsValid(func)) {
934 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func, "func");
935 return error::kNoError;
937 if (state_.depth_func != func) {
938 state_.depth_func = func;
939 glDepthFunc(func);
941 return error::kNoError;
944 error::Error GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size,
945 const void* cmd_data) {
946 const gles2::cmds::DepthMask& c =
947 *static_cast<const gles2::cmds::DepthMask*>(cmd_data);
948 (void)c;
949 GLboolean flag = static_cast<GLboolean>(c.flag);
950 if (state_.depth_mask != flag) {
951 state_.depth_mask = flag;
952 framebuffer_state_.clear_state_dirty = true;
954 return error::kNoError;
957 error::Error GLES2DecoderImpl::HandleDepthRangef(uint32_t immediate_data_size,
958 const void* cmd_data) {
959 const gles2::cmds::DepthRangef& c =
960 *static_cast<const gles2::cmds::DepthRangef*>(cmd_data);
961 (void)c;
962 GLclampf zNear = static_cast<GLclampf>(c.zNear);
963 GLclampf zFar = static_cast<GLclampf>(c.zFar);
964 DoDepthRangef(zNear, zFar);
965 return error::kNoError;
968 error::Error GLES2DecoderImpl::HandleDetachShader(uint32_t immediate_data_size,
969 const void* cmd_data) {
970 const gles2::cmds::DetachShader& c =
971 *static_cast<const gles2::cmds::DetachShader*>(cmd_data);
972 (void)c;
973 GLuint program = c.program;
974 GLuint shader = c.shader;
975 DoDetachShader(program, shader);
976 return error::kNoError;
979 error::Error GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size,
980 const void* cmd_data) {
981 const gles2::cmds::Disable& c =
982 *static_cast<const gles2::cmds::Disable*>(cmd_data);
983 (void)c;
984 GLenum cap = static_cast<GLenum>(c.cap);
985 if (!validators_->capability.IsValid(cap)) {
986 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap, "cap");
987 return error::kNoError;
989 DoDisable(cap);
990 return error::kNoError;
993 error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
994 uint32_t immediate_data_size,
995 const void* cmd_data) {
996 const gles2::cmds::DisableVertexAttribArray& c =
997 *static_cast<const gles2::cmds::DisableVertexAttribArray*>(cmd_data);
998 (void)c;
999 GLuint index = static_cast<GLuint>(c.index);
1000 DoDisableVertexAttribArray(index);
1001 return error::kNoError;
1004 error::Error GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size,
1005 const void* cmd_data) {
1006 const gles2::cmds::Enable& c =
1007 *static_cast<const gles2::cmds::Enable*>(cmd_data);
1008 (void)c;
1009 GLenum cap = static_cast<GLenum>(c.cap);
1010 if (!validators_->capability.IsValid(cap)) {
1011 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap, "cap");
1012 return error::kNoError;
1014 DoEnable(cap);
1015 return error::kNoError;
1018 error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
1019 uint32_t immediate_data_size,
1020 const void* cmd_data) {
1021 const gles2::cmds::EnableVertexAttribArray& c =
1022 *static_cast<const gles2::cmds::EnableVertexAttribArray*>(cmd_data);
1023 (void)c;
1024 GLuint index = static_cast<GLuint>(c.index);
1025 DoEnableVertexAttribArray(index);
1026 return error::kNoError;
1029 error::Error GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size,
1030 const void* cmd_data) {
1031 if (!unsafe_es3_apis_enabled())
1032 return error::kUnknownCommand;
1033 const gles2::cmds::FenceSync& c =
1034 *static_cast<const gles2::cmds::FenceSync*>(cmd_data);
1035 (void)c;
1036 GLenum condition = static_cast<GLenum>(c.condition);
1037 GLbitfield flags = static_cast<GLbitfield>(c.flags);
1038 uint32_t client_id = c.client_id;
1039 GLsync service_id = 0;
1040 if (group_->GetSyncServiceId(client_id, &service_id)) {
1041 return error::kInvalidArguments;
1043 service_id = glFenceSync(condition, flags);
1044 if (service_id) {
1045 group_->AddSyncId(client_id, service_id);
1047 return error::kNoError;
1050 error::Error GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size,
1051 const void* cmd_data) {
1052 const gles2::cmds::Finish& c =
1053 *static_cast<const gles2::cmds::Finish*>(cmd_data);
1054 (void)c;
1055 error::Error error;
1056 error = WillAccessBoundFramebufferForRead();
1057 if (error != error::kNoError)
1058 return error;
1059 DoFinish();
1060 return error::kNoError;
1063 error::Error GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size,
1064 const void* cmd_data) {
1065 const gles2::cmds::Flush& c =
1066 *static_cast<const gles2::cmds::Flush*>(cmd_data);
1067 (void)c;
1068 DoFlush();
1069 return error::kNoError;
1072 error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
1073 uint32_t immediate_data_size,
1074 const void* cmd_data) {
1075 const gles2::cmds::FramebufferRenderbuffer& c =
1076 *static_cast<const gles2::cmds::FramebufferRenderbuffer*>(cmd_data);
1077 (void)c;
1078 GLenum target = static_cast<GLenum>(c.target);
1079 GLenum attachment = static_cast<GLenum>(c.attachment);
1080 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
1081 GLuint renderbuffer = c.renderbuffer;
1082 if (!validators_->frame_buffer_target.IsValid(target)) {
1083 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target,
1084 "target");
1085 return error::kNoError;
1087 if (!validators_->attachment.IsValid(attachment)) {
1088 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment,
1089 "attachment");
1090 return error::kNoError;
1092 if (!validators_->render_buffer_target.IsValid(renderbuffertarget)) {
1093 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
1094 renderbuffertarget, "renderbuffertarget");
1095 return error::kNoError;
1097 DoFramebufferRenderbuffer(target, attachment, renderbuffertarget,
1098 renderbuffer);
1099 return error::kNoError;
1102 error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
1103 uint32_t immediate_data_size,
1104 const void* cmd_data) {
1105 const gles2::cmds::FramebufferTexture2D& c =
1106 *static_cast<const gles2::cmds::FramebufferTexture2D*>(cmd_data);
1107 (void)c;
1108 GLenum target = static_cast<GLenum>(c.target);
1109 GLenum attachment = static_cast<GLenum>(c.attachment);
1110 GLenum textarget = static_cast<GLenum>(c.textarget);
1111 GLuint texture = c.texture;
1112 GLint level = static_cast<GLint>(c.level);
1113 if (!validators_->frame_buffer_target.IsValid(target)) {
1114 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target, "target");
1115 return error::kNoError;
1117 if (!validators_->attachment.IsValid(attachment)) {
1118 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment,
1119 "attachment");
1120 return error::kNoError;
1122 if (!validators_->texture_target.IsValid(textarget)) {
1123 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget,
1124 "textarget");
1125 return error::kNoError;
1127 DoFramebufferTexture2D(target, attachment, textarget, texture, level);
1128 return error::kNoError;
1131 error::Error GLES2DecoderImpl::HandleFramebufferTextureLayer(
1132 uint32_t immediate_data_size,
1133 const void* cmd_data) {
1134 if (!unsafe_es3_apis_enabled())
1135 return error::kUnknownCommand;
1136 const gles2::cmds::FramebufferTextureLayer& c =
1137 *static_cast<const gles2::cmds::FramebufferTextureLayer*>(cmd_data);
1138 (void)c;
1139 GLenum target = static_cast<GLenum>(c.target);
1140 GLenum attachment = static_cast<GLenum>(c.attachment);
1141 GLuint texture = c.texture;
1142 GLint level = static_cast<GLint>(c.level);
1143 GLint layer = static_cast<GLint>(c.layer);
1144 DoFramebufferTextureLayer(target, attachment, texture, level, layer);
1145 return error::kNoError;
1148 error::Error GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size,
1149 const void* cmd_data) {
1150 const gles2::cmds::FrontFace& c =
1151 *static_cast<const gles2::cmds::FrontFace*>(cmd_data);
1152 (void)c;
1153 GLenum mode = static_cast<GLenum>(c.mode);
1154 if (!validators_->face_mode.IsValid(mode)) {
1155 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode, "mode");
1156 return error::kNoError;
1158 if (state_.front_face != mode) {
1159 state_.front_face = mode;
1160 glFrontFace(mode);
1162 return error::kNoError;
1165 error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
1166 uint32_t immediate_data_size,
1167 const void* cmd_data) {
1168 const gles2::cmds::GenBuffersImmediate& c =
1169 *static_cast<const gles2::cmds::GenBuffersImmediate*>(cmd_data);
1170 (void)c;
1171 GLsizei n = static_cast<GLsizei>(c.n);
1172 uint32_t data_size;
1173 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1174 return error::kOutOfBounds;
1176 GLuint* buffers =
1177 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1178 if (buffers == NULL) {
1179 return error::kOutOfBounds;
1181 if (!GenBuffersHelper(n, buffers)) {
1182 return error::kInvalidArguments;
1184 return error::kNoError;
1187 error::Error GLES2DecoderImpl::HandleGenerateMipmap(
1188 uint32_t immediate_data_size,
1189 const void* cmd_data) {
1190 const gles2::cmds::GenerateMipmap& c =
1191 *static_cast<const gles2::cmds::GenerateMipmap*>(cmd_data);
1192 (void)c;
1193 GLenum target = static_cast<GLenum>(c.target);
1194 if (!validators_->texture_bind_target.IsValid(target)) {
1195 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target, "target");
1196 return error::kNoError;
1198 DoGenerateMipmap(target);
1199 return error::kNoError;
1202 error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
1203 uint32_t immediate_data_size,
1204 const void* cmd_data) {
1205 const gles2::cmds::GenFramebuffersImmediate& c =
1206 *static_cast<const gles2::cmds::GenFramebuffersImmediate*>(cmd_data);
1207 (void)c;
1208 GLsizei n = static_cast<GLsizei>(c.n);
1209 uint32_t data_size;
1210 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1211 return error::kOutOfBounds;
1213 GLuint* framebuffers =
1214 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1215 if (framebuffers == NULL) {
1216 return error::kOutOfBounds;
1218 if (!GenFramebuffersHelper(n, framebuffers)) {
1219 return error::kInvalidArguments;
1221 return error::kNoError;
1224 error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
1225 uint32_t immediate_data_size,
1226 const void* cmd_data) {
1227 const gles2::cmds::GenRenderbuffersImmediate& c =
1228 *static_cast<const gles2::cmds::GenRenderbuffersImmediate*>(cmd_data);
1229 (void)c;
1230 GLsizei n = static_cast<GLsizei>(c.n);
1231 uint32_t data_size;
1232 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1233 return error::kOutOfBounds;
1235 GLuint* renderbuffers =
1236 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1237 if (renderbuffers == NULL) {
1238 return error::kOutOfBounds;
1240 if (!GenRenderbuffersHelper(n, renderbuffers)) {
1241 return error::kInvalidArguments;
1243 return error::kNoError;
1246 error::Error GLES2DecoderImpl::HandleGenSamplersImmediate(
1247 uint32_t immediate_data_size,
1248 const void* cmd_data) {
1249 if (!unsafe_es3_apis_enabled())
1250 return error::kUnknownCommand;
1251 const gles2::cmds::GenSamplersImmediate& c =
1252 *static_cast<const gles2::cmds::GenSamplersImmediate*>(cmd_data);
1253 (void)c;
1254 GLsizei n = static_cast<GLsizei>(c.n);
1255 uint32_t data_size;
1256 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1257 return error::kOutOfBounds;
1259 GLuint* samplers =
1260 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1261 if (samplers == NULL) {
1262 return error::kOutOfBounds;
1264 for (GLsizei ii = 0; ii < n; ++ii) {
1265 if (group_->GetSamplerServiceId(samplers[ii], NULL)) {
1266 return error::kInvalidArguments;
1269 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1270 glGenSamplers(n, service_ids.get());
1271 for (GLsizei ii = 0; ii < n; ++ii) {
1272 group_->AddSamplerId(samplers[ii], service_ids[ii]);
1274 return error::kNoError;
1277 error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
1278 uint32_t immediate_data_size,
1279 const void* cmd_data) {
1280 const gles2::cmds::GenTexturesImmediate& c =
1281 *static_cast<const gles2::cmds::GenTexturesImmediate*>(cmd_data);
1282 (void)c;
1283 GLsizei n = static_cast<GLsizei>(c.n);
1284 uint32_t data_size;
1285 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1286 return error::kOutOfBounds;
1288 GLuint* textures =
1289 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1290 if (textures == NULL) {
1291 return error::kOutOfBounds;
1293 if (!GenTexturesHelper(n, textures)) {
1294 return error::kInvalidArguments;
1296 return error::kNoError;
1299 error::Error GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
1300 uint32_t immediate_data_size,
1301 const void* cmd_data) {
1302 if (!unsafe_es3_apis_enabled())
1303 return error::kUnknownCommand;
1304 const gles2::cmds::GenTransformFeedbacksImmediate& c =
1305 *static_cast<const gles2::cmds::GenTransformFeedbacksImmediate*>(
1306 cmd_data);
1307 (void)c;
1308 GLsizei n = static_cast<GLsizei>(c.n);
1309 uint32_t data_size;
1310 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1311 return error::kOutOfBounds;
1313 GLuint* ids = GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1314 if (ids == NULL) {
1315 return error::kOutOfBounds;
1317 for (GLsizei ii = 0; ii < n; ++ii) {
1318 if (group_->GetTransformFeedbackServiceId(ids[ii], NULL)) {
1319 return error::kInvalidArguments;
1322 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1323 glGenTransformFeedbacks(n, service_ids.get());
1324 for (GLsizei ii = 0; ii < n; ++ii) {
1325 group_->AddTransformFeedbackId(ids[ii], service_ids[ii]);
1327 return error::kNoError;
1330 error::Error GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size,
1331 const void* cmd_data) {
1332 const gles2::cmds::GetBooleanv& c =
1333 *static_cast<const gles2::cmds::GetBooleanv*>(cmd_data);
1334 (void)c;
1335 GLenum pname = static_cast<GLenum>(c.pname);
1336 typedef cmds::GetBooleanv::Result Result;
1337 GLsizei num_values = 0;
1338 GetNumValuesReturnedForGLGet(pname, &num_values);
1339 Result* result = GetSharedMemoryAs<Result*>(
1340 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1341 GLboolean* params = result ? result->GetData() : NULL;
1342 if (!validators_->g_l_state.IsValid(pname)) {
1343 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname, "pname");
1344 return error::kNoError;
1346 if (params == NULL) {
1347 return error::kOutOfBounds;
1349 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
1350 // Check that the client initialized the result.
1351 if (result->size != 0) {
1352 return error::kInvalidArguments;
1354 DoGetBooleanv(pname, params);
1355 GLenum error = glGetError();
1356 if (error == GL_NO_ERROR) {
1357 result->SetNumResults(num_values);
1358 } else {
1359 LOCAL_SET_GL_ERROR(error, "GetBooleanv", "");
1361 return error::kNoError;
1364 error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
1365 uint32_t immediate_data_size,
1366 const void* cmd_data) {
1367 const gles2::cmds::GetBufferParameteriv& c =
1368 *static_cast<const gles2::cmds::GetBufferParameteriv*>(cmd_data);
1369 (void)c;
1370 GLenum target = static_cast<GLenum>(c.target);
1371 GLenum pname = static_cast<GLenum>(c.pname);
1372 typedef cmds::GetBufferParameteriv::Result Result;
1373 GLsizei num_values = 0;
1374 GetNumValuesReturnedForGLGet(pname, &num_values);
1375 Result* result = GetSharedMemoryAs<Result*>(
1376 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1377 GLint* params = result ? result->GetData() : NULL;
1378 if (!validators_->buffer_target.IsValid(target)) {
1379 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
1380 return error::kNoError;
1382 if (!validators_->buffer_parameter.IsValid(pname)) {
1383 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
1384 return error::kNoError;
1386 if (params == NULL) {
1387 return error::kOutOfBounds;
1389 // Check that the client initialized the result.
1390 if (result->size != 0) {
1391 return error::kInvalidArguments;
1393 DoGetBufferParameteriv(target, pname, params);
1394 result->SetNumResults(num_values);
1395 return error::kNoError;
1397 error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
1398 const void* cmd_data) {
1399 const gles2::cmds::GetError& c =
1400 *static_cast<const gles2::cmds::GetError*>(cmd_data);
1401 (void)c;
1402 typedef cmds::GetError::Result Result;
1403 Result* result_dst = GetSharedMemoryAs<Result*>(
1404 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1405 if (!result_dst) {
1406 return error::kOutOfBounds;
1408 *result_dst = GetErrorState()->GetGLError();
1409 return error::kNoError;
1412 error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
1413 const void* cmd_data) {
1414 const gles2::cmds::GetFloatv& c =
1415 *static_cast<const gles2::cmds::GetFloatv*>(cmd_data);
1416 (void)c;
1417 GLenum pname = static_cast<GLenum>(c.pname);
1418 typedef cmds::GetFloatv::Result Result;
1419 GLsizei num_values = 0;
1420 GetNumValuesReturnedForGLGet(pname, &num_values);
1421 Result* result = GetSharedMemoryAs<Result*>(
1422 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1423 GLfloat* params = result ? result->GetData() : NULL;
1424 if (!validators_->g_l_state.IsValid(pname)) {
1425 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
1426 return error::kNoError;
1428 if (params == NULL) {
1429 return error::kOutOfBounds;
1431 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1432 // Check that the client initialized the result.
1433 if (result->size != 0) {
1434 return error::kInvalidArguments;
1436 DoGetFloatv(pname, params);
1437 GLenum error = glGetError();
1438 if (error == GL_NO_ERROR) {
1439 result->SetNumResults(num_values);
1440 } else {
1441 LOCAL_SET_GL_ERROR(error, "GetFloatv", "");
1443 return error::kNoError;
1446 error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1447 uint32_t immediate_data_size,
1448 const void* cmd_data) {
1449 const gles2::cmds::GetFramebufferAttachmentParameteriv& c =
1450 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv*>(
1451 cmd_data);
1452 (void)c;
1453 GLenum target = static_cast<GLenum>(c.target);
1454 GLenum attachment = static_cast<GLenum>(c.attachment);
1455 GLenum pname = static_cast<GLenum>(c.pname);
1456 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
1457 GLsizei num_values = 0;
1458 GetNumValuesReturnedForGLGet(pname, &num_values);
1459 Result* result = GetSharedMemoryAs<Result*>(
1460 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1461 GLint* params = result ? result->GetData() : NULL;
1462 if (!validators_->frame_buffer_target.IsValid(target)) {
1463 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1464 target, "target");
1465 return error::kNoError;
1467 if (!validators_->attachment.IsValid(attachment)) {
1468 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1469 attachment, "attachment");
1470 return error::kNoError;
1472 if (!validators_->frame_buffer_parameter.IsValid(pname)) {
1473 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1474 pname, "pname");
1475 return error::kNoError;
1477 if (params == NULL) {
1478 return error::kOutOfBounds;
1480 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1481 // Check that the client initialized the result.
1482 if (result->size != 0) {
1483 return error::kInvalidArguments;
1485 DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1486 GLenum error = glGetError();
1487 if (error == GL_NO_ERROR) {
1488 result->SetNumResults(num_values);
1489 } else {
1490 LOCAL_SET_GL_ERROR(error, "GetFramebufferAttachmentParameteriv", "");
1492 return error::kNoError;
1495 error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size,
1496 const void* cmd_data) {
1497 const gles2::cmds::GetIntegerv& c =
1498 *static_cast<const gles2::cmds::GetIntegerv*>(cmd_data);
1499 (void)c;
1500 GLenum pname = static_cast<GLenum>(c.pname);
1501 typedef cmds::GetIntegerv::Result Result;
1502 GLsizei num_values = 0;
1503 GetNumValuesReturnedForGLGet(pname, &num_values);
1504 Result* result = GetSharedMemoryAs<Result*>(
1505 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1506 GLint* params = result ? result->GetData() : NULL;
1507 if (!validators_->g_l_state.IsValid(pname)) {
1508 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
1509 return error::kNoError;
1511 if (params == NULL) {
1512 return error::kOutOfBounds;
1514 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1515 // Check that the client initialized the result.
1516 if (result->size != 0) {
1517 return error::kInvalidArguments;
1519 DoGetIntegerv(pname, params);
1520 GLenum error = glGetError();
1521 if (error == GL_NO_ERROR) {
1522 result->SetNumResults(num_values);
1523 } else {
1524 LOCAL_SET_GL_ERROR(error, "GetIntegerv", "");
1526 return error::kNoError;
1529 error::Error GLES2DecoderImpl::HandleGetInternalformativ(
1530 uint32_t immediate_data_size,
1531 const void* cmd_data) {
1532 if (!unsafe_es3_apis_enabled())
1533 return error::kUnknownCommand;
1534 const gles2::cmds::GetInternalformativ& c =
1535 *static_cast<const gles2::cmds::GetInternalformativ*>(cmd_data);
1536 (void)c;
1537 GLenum target = static_cast<GLenum>(c.target);
1538 GLenum format = static_cast<GLenum>(c.format);
1539 GLenum pname = static_cast<GLenum>(c.pname);
1540 GLsizei bufSize = static_cast<GLsizei>(c.bufSize);
1541 typedef cmds::GetInternalformativ::Result Result;
1542 GLsizei num_values = 0;
1543 GetNumValuesReturnedForGLGet(pname, &num_values);
1544 Result* result = GetSharedMemoryAs<Result*>(
1545 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1546 GLint* params = result ? result->GetData() : NULL;
1547 if (params == NULL) {
1548 return error::kOutOfBounds;
1550 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInternalformativ");
1551 // Check that the client initialized the result.
1552 if (result->size != 0) {
1553 return error::kInvalidArguments;
1555 glGetInternalformativ(target, format, pname, bufSize, params);
1556 GLenum error = glGetError();
1557 if (error == GL_NO_ERROR) {
1558 result->SetNumResults(num_values);
1559 } else {
1560 LOCAL_SET_GL_ERROR(error, "GetInternalformativ", "");
1562 return error::kNoError;
1565 error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size,
1566 const void* cmd_data) {
1567 const gles2::cmds::GetProgramiv& c =
1568 *static_cast<const gles2::cmds::GetProgramiv*>(cmd_data);
1569 (void)c;
1570 GLuint program = c.program;
1571 GLenum pname = static_cast<GLenum>(c.pname);
1572 typedef cmds::GetProgramiv::Result Result;
1573 GLsizei num_values = 0;
1574 GetNumValuesReturnedForGLGet(pname, &num_values);
1575 Result* result = GetSharedMemoryAs<Result*>(
1576 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1577 GLint* params = result ? result->GetData() : NULL;
1578 if (!validators_->program_parameter.IsValid(pname)) {
1579 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
1580 return error::kNoError;
1582 if (params == NULL) {
1583 return error::kOutOfBounds;
1585 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1586 // Check that the client initialized the result.
1587 if (result->size != 0) {
1588 return error::kInvalidArguments;
1590 DoGetProgramiv(program, pname, params);
1591 GLenum error = glGetError();
1592 if (error == GL_NO_ERROR) {
1593 result->SetNumResults(num_values);
1594 } else {
1595 LOCAL_SET_GL_ERROR(error, "GetProgramiv", "");
1597 return error::kNoError;
1600 error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1601 uint32_t immediate_data_size,
1602 const void* cmd_data) {
1603 const gles2::cmds::GetRenderbufferParameteriv& c =
1604 *static_cast<const gles2::cmds::GetRenderbufferParameteriv*>(cmd_data);
1605 (void)c;
1606 GLenum target = static_cast<GLenum>(c.target);
1607 GLenum pname = static_cast<GLenum>(c.pname);
1608 typedef cmds::GetRenderbufferParameteriv::Result Result;
1609 GLsizei num_values = 0;
1610 GetNumValuesReturnedForGLGet(pname, &num_values);
1611 Result* result = GetSharedMemoryAs<Result*>(
1612 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1613 GLint* params = result ? result->GetData() : NULL;
1614 if (!validators_->render_buffer_target.IsValid(target)) {
1615 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
1616 "target");
1617 return error::kNoError;
1619 if (!validators_->render_buffer_parameter.IsValid(pname)) {
1620 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
1621 "pname");
1622 return error::kNoError;
1624 if (params == NULL) {
1625 return error::kOutOfBounds;
1627 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1628 // Check that the client initialized the result.
1629 if (result->size != 0) {
1630 return error::kInvalidArguments;
1632 DoGetRenderbufferParameteriv(target, pname, params);
1633 GLenum error = glGetError();
1634 if (error == GL_NO_ERROR) {
1635 result->SetNumResults(num_values);
1636 } else {
1637 LOCAL_SET_GL_ERROR(error, "GetRenderbufferParameteriv", "");
1639 return error::kNoError;
1642 error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
1643 uint32_t immediate_data_size,
1644 const void* cmd_data) {
1645 if (!unsafe_es3_apis_enabled())
1646 return error::kUnknownCommand;
1647 const gles2::cmds::GetSamplerParameterfv& c =
1648 *static_cast<const gles2::cmds::GetSamplerParameterfv*>(cmd_data);
1649 (void)c;
1650 GLuint sampler = c.sampler;
1651 GLenum pname = static_cast<GLenum>(c.pname);
1652 typedef cmds::GetSamplerParameterfv::Result Result;
1653 GLsizei num_values = 0;
1654 GetNumValuesReturnedForGLGet(pname, &num_values);
1655 Result* result = GetSharedMemoryAs<Result*>(
1656 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1657 GLfloat* params = result ? result->GetData() : NULL;
1658 if (params == NULL) {
1659 return error::kOutOfBounds;
1661 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1662 // Check that the client initialized the result.
1663 if (result->size != 0) {
1664 return error::kInvalidArguments;
1666 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1667 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameterfv",
1668 "invalid sampler id");
1669 return error::kNoError;
1671 glGetSamplerParameterfv(sampler, pname, params);
1672 GLenum error = glGetError();
1673 if (error == GL_NO_ERROR) {
1674 result->SetNumResults(num_values);
1675 } else {
1676 LOCAL_SET_GL_ERROR(error, "GetSamplerParameterfv", "");
1678 return error::kNoError;
1681 error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
1682 uint32_t immediate_data_size,
1683 const void* cmd_data) {
1684 if (!unsafe_es3_apis_enabled())
1685 return error::kUnknownCommand;
1686 const gles2::cmds::GetSamplerParameteriv& c =
1687 *static_cast<const gles2::cmds::GetSamplerParameteriv*>(cmd_data);
1688 (void)c;
1689 GLuint sampler = c.sampler;
1690 GLenum pname = static_cast<GLenum>(c.pname);
1691 typedef cmds::GetSamplerParameteriv::Result Result;
1692 GLsizei num_values = 0;
1693 GetNumValuesReturnedForGLGet(pname, &num_values);
1694 Result* result = GetSharedMemoryAs<Result*>(
1695 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1696 GLint* params = result ? result->GetData() : NULL;
1697 if (params == NULL) {
1698 return error::kOutOfBounds;
1700 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1701 // Check that the client initialized the result.
1702 if (result->size != 0) {
1703 return error::kInvalidArguments;
1705 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1706 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameteriv",
1707 "invalid sampler id");
1708 return error::kNoError;
1710 glGetSamplerParameteriv(sampler, pname, params);
1711 GLenum error = glGetError();
1712 if (error == GL_NO_ERROR) {
1713 result->SetNumResults(num_values);
1714 } else {
1715 LOCAL_SET_GL_ERROR(error, "GetSamplerParameteriv", "");
1717 return error::kNoError;
1720 error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size,
1721 const void* cmd_data) {
1722 const gles2::cmds::GetShaderiv& c =
1723 *static_cast<const gles2::cmds::GetShaderiv*>(cmd_data);
1724 (void)c;
1725 GLuint shader = c.shader;
1726 GLenum pname = static_cast<GLenum>(c.pname);
1727 typedef cmds::GetShaderiv::Result Result;
1728 GLsizei num_values = 0;
1729 GetNumValuesReturnedForGLGet(pname, &num_values);
1730 Result* result = GetSharedMemoryAs<Result*>(
1731 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1732 GLint* params = result ? result->GetData() : NULL;
1733 if (!validators_->shader_parameter.IsValid(pname)) {
1734 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
1735 return error::kNoError;
1737 if (params == NULL) {
1738 return error::kOutOfBounds;
1740 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1741 // Check that the client initialized the result.
1742 if (result->size != 0) {
1743 return error::kInvalidArguments;
1745 DoGetShaderiv(shader, pname, params);
1746 GLenum error = glGetError();
1747 if (error == GL_NO_ERROR) {
1748 result->SetNumResults(num_values);
1749 } else {
1750 LOCAL_SET_GL_ERROR(error, "GetShaderiv", "");
1752 return error::kNoError;
1755 error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
1756 const void* cmd_data) {
1757 if (!unsafe_es3_apis_enabled())
1758 return error::kUnknownCommand;
1759 const gles2::cmds::GetSynciv& c =
1760 *static_cast<const gles2::cmds::GetSynciv*>(cmd_data);
1761 (void)c;
1762 GLuint sync = static_cast<GLuint>(c.sync);
1763 GLenum pname = static_cast<GLenum>(c.pname);
1764 typedef cmds::GetSynciv::Result Result;
1765 GLsizei num_values = 0;
1766 GetNumValuesReturnedForGLGet(pname, &num_values);
1767 Result* result = GetSharedMemoryAs<Result*>(
1768 c.values_shm_id, c.values_shm_offset, Result::ComputeSize(num_values));
1769 GLint* values = result ? result->GetData() : NULL;
1770 if (values == NULL) {
1771 return error::kOutOfBounds;
1773 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1774 // Check that the client initialized the result.
1775 if (result->size != 0) {
1776 return error::kInvalidArguments;
1778 GLsync service_sync = 0;
1779 if (!group_->GetSyncServiceId(sync, &service_sync)) {
1780 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSynciv", "invalid sync id");
1781 return error::kNoError;
1783 glGetSynciv(service_sync, pname, num_values, nullptr, values);
1784 GLenum error = glGetError();
1785 if (error == GL_NO_ERROR) {
1786 result->SetNumResults(num_values);
1787 } else {
1788 LOCAL_SET_GL_ERROR(error, "GetSynciv", "");
1790 return error::kNoError;
1793 error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
1794 uint32_t immediate_data_size,
1795 const void* cmd_data) {
1796 const gles2::cmds::GetTexParameterfv& c =
1797 *static_cast<const gles2::cmds::GetTexParameterfv*>(cmd_data);
1798 (void)c;
1799 GLenum target = static_cast<GLenum>(c.target);
1800 GLenum pname = static_cast<GLenum>(c.pname);
1801 typedef cmds::GetTexParameterfv::Result Result;
1802 GLsizei num_values = 0;
1803 GetNumValuesReturnedForGLGet(pname, &num_values);
1804 Result* result = GetSharedMemoryAs<Result*>(
1805 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1806 GLfloat* params = result ? result->GetData() : NULL;
1807 if (!validators_->get_tex_param_target.IsValid(target)) {
1808 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
1809 return error::kNoError;
1811 if (!validators_->texture_parameter.IsValid(pname)) {
1812 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
1813 return error::kNoError;
1815 if (params == NULL) {
1816 return error::kOutOfBounds;
1818 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1819 // Check that the client initialized the result.
1820 if (result->size != 0) {
1821 return error::kInvalidArguments;
1823 DoGetTexParameterfv(target, pname, params);
1824 GLenum error = glGetError();
1825 if (error == GL_NO_ERROR) {
1826 result->SetNumResults(num_values);
1827 } else {
1828 LOCAL_SET_GL_ERROR(error, "GetTexParameterfv", "");
1830 return error::kNoError;
1833 error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
1834 uint32_t immediate_data_size,
1835 const void* cmd_data) {
1836 const gles2::cmds::GetTexParameteriv& c =
1837 *static_cast<const gles2::cmds::GetTexParameteriv*>(cmd_data);
1838 (void)c;
1839 GLenum target = static_cast<GLenum>(c.target);
1840 GLenum pname = static_cast<GLenum>(c.pname);
1841 typedef cmds::GetTexParameteriv::Result Result;
1842 GLsizei num_values = 0;
1843 GetNumValuesReturnedForGLGet(pname, &num_values);
1844 Result* result = GetSharedMemoryAs<Result*>(
1845 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1846 GLint* params = result ? result->GetData() : NULL;
1847 if (!validators_->get_tex_param_target.IsValid(target)) {
1848 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
1849 return error::kNoError;
1851 if (!validators_->texture_parameter.IsValid(pname)) {
1852 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
1853 return error::kNoError;
1855 if (params == NULL) {
1856 return error::kOutOfBounds;
1858 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1859 // Check that the client initialized the result.
1860 if (result->size != 0) {
1861 return error::kInvalidArguments;
1863 DoGetTexParameteriv(target, pname, params);
1864 GLenum error = glGetError();
1865 if (error == GL_NO_ERROR) {
1866 result->SetNumResults(num_values);
1867 } else {
1868 LOCAL_SET_GL_ERROR(error, "GetTexParameteriv", "");
1870 return error::kNoError;
1873 error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
1874 uint32_t immediate_data_size,
1875 const void* cmd_data) {
1876 const gles2::cmds::GetVertexAttribfv& c =
1877 *static_cast<const gles2::cmds::GetVertexAttribfv*>(cmd_data);
1878 (void)c;
1879 GLuint index = static_cast<GLuint>(c.index);
1880 GLenum pname = static_cast<GLenum>(c.pname);
1881 typedef cmds::GetVertexAttribfv::Result Result;
1882 GLsizei num_values = 0;
1883 GetNumValuesReturnedForGLGet(pname, &num_values);
1884 Result* result = GetSharedMemoryAs<Result*>(
1885 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1886 GLfloat* params = result ? result->GetData() : NULL;
1887 if (!validators_->vertex_attribute.IsValid(pname)) {
1888 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
1889 return error::kNoError;
1891 if (params == NULL) {
1892 return error::kOutOfBounds;
1894 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1895 // Check that the client initialized the result.
1896 if (result->size != 0) {
1897 return error::kInvalidArguments;
1899 DoGetVertexAttribfv(index, pname, params);
1900 GLenum error = glGetError();
1901 if (error == GL_NO_ERROR) {
1902 result->SetNumResults(num_values);
1903 } else {
1904 LOCAL_SET_GL_ERROR(error, "GetVertexAttribfv", "");
1906 return error::kNoError;
1909 error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
1910 uint32_t immediate_data_size,
1911 const void* cmd_data) {
1912 const gles2::cmds::GetVertexAttribiv& c =
1913 *static_cast<const gles2::cmds::GetVertexAttribiv*>(cmd_data);
1914 (void)c;
1915 GLuint index = static_cast<GLuint>(c.index);
1916 GLenum pname = static_cast<GLenum>(c.pname);
1917 typedef cmds::GetVertexAttribiv::Result Result;
1918 GLsizei num_values = 0;
1919 GetNumValuesReturnedForGLGet(pname, &num_values);
1920 Result* result = GetSharedMemoryAs<Result*>(
1921 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1922 GLint* params = result ? result->GetData() : NULL;
1923 if (!validators_->vertex_attribute.IsValid(pname)) {
1924 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
1925 return error::kNoError;
1927 if (params == NULL) {
1928 return error::kOutOfBounds;
1930 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
1931 // Check that the client initialized the result.
1932 if (result->size != 0) {
1933 return error::kInvalidArguments;
1935 DoGetVertexAttribiv(index, pname, params);
1936 GLenum error = glGetError();
1937 if (error == GL_NO_ERROR) {
1938 result->SetNumResults(num_values);
1939 } else {
1940 LOCAL_SET_GL_ERROR(error, "GetVertexAttribiv", "");
1942 return error::kNoError;
1945 error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
1946 const void* cmd_data) {
1947 const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data);
1948 (void)c;
1949 GLenum target = static_cast<GLenum>(c.target);
1950 GLenum mode = static_cast<GLenum>(c.mode);
1951 if (!validators_->hint_target.IsValid(target)) {
1952 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
1953 return error::kNoError;
1955 if (!validators_->hint_mode.IsValid(mode)) {
1956 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
1957 return error::kNoError;
1959 switch (target) {
1960 case GL_GENERATE_MIPMAP_HINT:
1961 if (state_.hint_generate_mipmap != mode) {
1962 state_.hint_generate_mipmap = mode;
1963 glHint(target, mode);
1965 break;
1966 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
1967 if (state_.hint_fragment_shader_derivative != mode) {
1968 state_.hint_fragment_shader_derivative = mode;
1969 glHint(target, mode);
1971 break;
1972 default:
1973 NOTREACHED();
1975 return error::kNoError;
1978 error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
1979 uint32_t immediate_data_size,
1980 const void* cmd_data) {
1981 if (!unsafe_es3_apis_enabled())
1982 return error::kUnknownCommand;
1983 const gles2::cmds::InvalidateFramebufferImmediate& c =
1984 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate*>(
1985 cmd_data);
1986 (void)c;
1987 GLenum target = static_cast<GLenum>(c.target);
1988 GLsizei count = static_cast<GLsizei>(c.count);
1989 uint32_t data_size;
1990 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
1991 return error::kOutOfBounds;
1993 if (data_size > immediate_data_size) {
1994 return error::kOutOfBounds;
1996 const GLenum* attachments =
1997 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
1998 if (attachments == NULL) {
1999 return error::kOutOfBounds;
2001 glInvalidateFramebuffer(target, count, attachments);
2002 return error::kNoError;
2005 error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2006 uint32_t immediate_data_size,
2007 const void* cmd_data) {
2008 if (!unsafe_es3_apis_enabled())
2009 return error::kUnknownCommand;
2010 const gles2::cmds::InvalidateSubFramebufferImmediate& c =
2011 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate*>(
2012 cmd_data);
2013 (void)c;
2014 GLenum target = static_cast<GLenum>(c.target);
2015 GLsizei count = static_cast<GLsizei>(c.count);
2016 uint32_t data_size;
2017 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2018 return error::kOutOfBounds;
2020 if (data_size > immediate_data_size) {
2021 return error::kOutOfBounds;
2023 const GLenum* attachments =
2024 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2025 GLint x = static_cast<GLint>(c.x);
2026 GLint y = static_cast<GLint>(c.y);
2027 GLsizei width = static_cast<GLsizei>(c.width);
2028 GLsizei height = static_cast<GLsizei>(c.height);
2029 if (attachments == NULL) {
2030 return error::kOutOfBounds;
2032 glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height);
2033 return error::kNoError;
2036 error::Error GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size,
2037 const void* cmd_data) {
2038 const gles2::cmds::IsBuffer& c =
2039 *static_cast<const gles2::cmds::IsBuffer*>(cmd_data);
2040 (void)c;
2041 GLuint buffer = c.buffer;
2042 typedef cmds::IsBuffer::Result Result;
2043 Result* result_dst = GetSharedMemoryAs<Result*>(
2044 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2045 if (!result_dst) {
2046 return error::kOutOfBounds;
2048 *result_dst = DoIsBuffer(buffer);
2049 return error::kNoError;
2052 error::Error GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size,
2053 const void* cmd_data) {
2054 const gles2::cmds::IsEnabled& c =
2055 *static_cast<const gles2::cmds::IsEnabled*>(cmd_data);
2056 (void)c;
2057 GLenum cap = static_cast<GLenum>(c.cap);
2058 typedef cmds::IsEnabled::Result Result;
2059 Result* result_dst = GetSharedMemoryAs<Result*>(
2060 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2061 if (!result_dst) {
2062 return error::kOutOfBounds;
2064 if (!validators_->capability.IsValid(cap)) {
2065 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap, "cap");
2066 return error::kNoError;
2068 *result_dst = DoIsEnabled(cap);
2069 return error::kNoError;
2072 error::Error GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size,
2073 const void* cmd_data) {
2074 const gles2::cmds::IsFramebuffer& c =
2075 *static_cast<const gles2::cmds::IsFramebuffer*>(cmd_data);
2076 (void)c;
2077 GLuint framebuffer = c.framebuffer;
2078 typedef cmds::IsFramebuffer::Result Result;
2079 Result* result_dst = GetSharedMemoryAs<Result*>(
2080 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2081 if (!result_dst) {
2082 return error::kOutOfBounds;
2084 *result_dst = DoIsFramebuffer(framebuffer);
2085 return error::kNoError;
2088 error::Error GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size,
2089 const void* cmd_data) {
2090 const gles2::cmds::IsProgram& c =
2091 *static_cast<const gles2::cmds::IsProgram*>(cmd_data);
2092 (void)c;
2093 GLuint program = c.program;
2094 typedef cmds::IsProgram::Result Result;
2095 Result* result_dst = GetSharedMemoryAs<Result*>(
2096 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2097 if (!result_dst) {
2098 return error::kOutOfBounds;
2100 *result_dst = DoIsProgram(program);
2101 return error::kNoError;
2104 error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
2105 uint32_t immediate_data_size,
2106 const void* cmd_data) {
2107 const gles2::cmds::IsRenderbuffer& c =
2108 *static_cast<const gles2::cmds::IsRenderbuffer*>(cmd_data);
2109 (void)c;
2110 GLuint renderbuffer = c.renderbuffer;
2111 typedef cmds::IsRenderbuffer::Result Result;
2112 Result* result_dst = GetSharedMemoryAs<Result*>(
2113 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2114 if (!result_dst) {
2115 return error::kOutOfBounds;
2117 *result_dst = DoIsRenderbuffer(renderbuffer);
2118 return error::kNoError;
2121 error::Error GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size,
2122 const void* cmd_data) {
2123 if (!unsafe_es3_apis_enabled())
2124 return error::kUnknownCommand;
2125 const gles2::cmds::IsSampler& c =
2126 *static_cast<const gles2::cmds::IsSampler*>(cmd_data);
2127 (void)c;
2128 GLuint sampler = c.sampler;
2129 typedef cmds::IsSampler::Result Result;
2130 Result* result_dst = GetSharedMemoryAs<Result*>(
2131 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2132 if (!result_dst) {
2133 return error::kOutOfBounds;
2135 GLuint service_sampler = 0;
2136 *result_dst = group_->GetSamplerServiceId(sampler, &service_sampler);
2137 return error::kNoError;
2140 error::Error GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size,
2141 const void* cmd_data) {
2142 const gles2::cmds::IsShader& c =
2143 *static_cast<const gles2::cmds::IsShader*>(cmd_data);
2144 (void)c;
2145 GLuint shader = c.shader;
2146 typedef cmds::IsShader::Result Result;
2147 Result* result_dst = GetSharedMemoryAs<Result*>(
2148 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2149 if (!result_dst) {
2150 return error::kOutOfBounds;
2152 *result_dst = DoIsShader(shader);
2153 return error::kNoError;
2156 error::Error GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size,
2157 const void* cmd_data) {
2158 if (!unsafe_es3_apis_enabled())
2159 return error::kUnknownCommand;
2160 const gles2::cmds::IsSync& c =
2161 *static_cast<const gles2::cmds::IsSync*>(cmd_data);
2162 (void)c;
2163 GLuint sync = c.sync;
2164 typedef cmds::IsSync::Result Result;
2165 Result* result_dst = GetSharedMemoryAs<Result*>(
2166 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2167 if (!result_dst) {
2168 return error::kOutOfBounds;
2170 GLsync service_sync = 0;
2171 *result_dst = group_->GetSyncServiceId(sync, &service_sync);
2172 return error::kNoError;
2175 error::Error GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size,
2176 const void* cmd_data) {
2177 const gles2::cmds::IsTexture& c =
2178 *static_cast<const gles2::cmds::IsTexture*>(cmd_data);
2179 (void)c;
2180 GLuint texture = c.texture;
2181 typedef cmds::IsTexture::Result Result;
2182 Result* result_dst = GetSharedMemoryAs<Result*>(
2183 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2184 if (!result_dst) {
2185 return error::kOutOfBounds;
2187 *result_dst = DoIsTexture(texture);
2188 return error::kNoError;
2191 error::Error GLES2DecoderImpl::HandleIsTransformFeedback(
2192 uint32_t immediate_data_size,
2193 const void* cmd_data) {
2194 if (!unsafe_es3_apis_enabled())
2195 return error::kUnknownCommand;
2196 const gles2::cmds::IsTransformFeedback& c =
2197 *static_cast<const gles2::cmds::IsTransformFeedback*>(cmd_data);
2198 (void)c;
2199 GLuint transformfeedback = c.transformfeedback;
2200 typedef cmds::IsTransformFeedback::Result Result;
2201 Result* result_dst = GetSharedMemoryAs<Result*>(
2202 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2203 if (!result_dst) {
2204 return error::kOutOfBounds;
2206 GLuint service_transformfeedback = 0;
2207 *result_dst = group_->GetTransformFeedbackServiceId(
2208 transformfeedback, &service_transformfeedback);
2209 return error::kNoError;
2212 error::Error GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size,
2213 const void* cmd_data) {
2214 const gles2::cmds::LineWidth& c =
2215 *static_cast<const gles2::cmds::LineWidth*>(cmd_data);
2216 (void)c;
2217 GLfloat width = static_cast<GLfloat>(c.width);
2218 if (width <= 0.0f || base::IsNaN(width)) {
2219 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "LineWidth", "width out of range");
2220 return error::kNoError;
2222 if (state_.line_width != width) {
2223 state_.line_width = width;
2224 glLineWidth(width);
2226 return error::kNoError;
2229 error::Error GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size,
2230 const void* cmd_data) {
2231 const gles2::cmds::LinkProgram& c =
2232 *static_cast<const gles2::cmds::LinkProgram*>(cmd_data);
2233 (void)c;
2234 GLuint program = c.program;
2235 DoLinkProgram(program);
2236 return error::kNoError;
2239 error::Error GLES2DecoderImpl::HandlePauseTransformFeedback(
2240 uint32_t immediate_data_size,
2241 const void* cmd_data) {
2242 if (!unsafe_es3_apis_enabled())
2243 return error::kUnknownCommand;
2244 const gles2::cmds::PauseTransformFeedback& c =
2245 *static_cast<const gles2::cmds::PauseTransformFeedback*>(cmd_data);
2246 (void)c;
2247 glPauseTransformFeedback();
2248 return error::kNoError;
2251 error::Error GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size,
2252 const void* cmd_data) {
2253 const gles2::cmds::PolygonOffset& c =
2254 *static_cast<const gles2::cmds::PolygonOffset*>(cmd_data);
2255 (void)c;
2256 GLfloat factor = static_cast<GLfloat>(c.factor);
2257 GLfloat units = static_cast<GLfloat>(c.units);
2258 if (state_.polygon_offset_factor != factor ||
2259 state_.polygon_offset_units != units) {
2260 state_.polygon_offset_factor = factor;
2261 state_.polygon_offset_units = units;
2262 glPolygonOffset(factor, units);
2264 return error::kNoError;
2267 error::Error GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size,
2268 const void* cmd_data) {
2269 if (!unsafe_es3_apis_enabled())
2270 return error::kUnknownCommand;
2271 const gles2::cmds::ReadBuffer& c =
2272 *static_cast<const gles2::cmds::ReadBuffer*>(cmd_data);
2273 (void)c;
2274 GLenum src = static_cast<GLenum>(c.src);
2275 glReadBuffer(src);
2276 return error::kNoError;
2279 error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler(
2280 uint32_t immediate_data_size,
2281 const void* cmd_data) {
2282 const gles2::cmds::ReleaseShaderCompiler& c =
2283 *static_cast<const gles2::cmds::ReleaseShaderCompiler*>(cmd_data);
2284 (void)c;
2285 DoReleaseShaderCompiler();
2286 return error::kNoError;
2289 error::Error GLES2DecoderImpl::HandleRenderbufferStorage(
2290 uint32_t immediate_data_size,
2291 const void* cmd_data) {
2292 const gles2::cmds::RenderbufferStorage& c =
2293 *static_cast<const gles2::cmds::RenderbufferStorage*>(cmd_data);
2294 (void)c;
2295 GLenum target = static_cast<GLenum>(c.target);
2296 GLenum internalformat = static_cast<GLenum>(c.internalformat);
2297 GLsizei width = static_cast<GLsizei>(c.width);
2298 GLsizei height = static_cast<GLsizei>(c.height);
2299 if (!validators_->render_buffer_target.IsValid(target)) {
2300 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target, "target");
2301 return error::kNoError;
2303 if (!validators_->render_buffer_format.IsValid(internalformat)) {
2304 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat,
2305 "internalformat");
2306 return error::kNoError;
2308 if (width < 0) {
2309 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
2310 return error::kNoError;
2312 if (height < 0) {
2313 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
2314 return error::kNoError;
2316 DoRenderbufferStorage(target, internalformat, width, height);
2317 return error::kNoError;
2320 error::Error GLES2DecoderImpl::HandleResumeTransformFeedback(
2321 uint32_t immediate_data_size,
2322 const void* cmd_data) {
2323 if (!unsafe_es3_apis_enabled())
2324 return error::kUnknownCommand;
2325 const gles2::cmds::ResumeTransformFeedback& c =
2326 *static_cast<const gles2::cmds::ResumeTransformFeedback*>(cmd_data);
2327 (void)c;
2328 glResumeTransformFeedback();
2329 return error::kNoError;
2332 error::Error GLES2DecoderImpl::HandleSampleCoverage(
2333 uint32_t immediate_data_size,
2334 const void* cmd_data) {
2335 const gles2::cmds::SampleCoverage& c =
2336 *static_cast<const gles2::cmds::SampleCoverage*>(cmd_data);
2337 (void)c;
2338 GLclampf value = static_cast<GLclampf>(c.value);
2339 GLboolean invert = static_cast<GLboolean>(c.invert);
2340 DoSampleCoverage(value, invert);
2341 return error::kNoError;
2344 error::Error GLES2DecoderImpl::HandleSamplerParameterf(
2345 uint32_t immediate_data_size,
2346 const void* cmd_data) {
2347 if (!unsafe_es3_apis_enabled())
2348 return error::kUnknownCommand;
2349 const gles2::cmds::SamplerParameterf& c =
2350 *static_cast<const gles2::cmds::SamplerParameterf*>(cmd_data);
2351 (void)c;
2352 GLuint sampler = c.sampler;
2353 GLenum pname = static_cast<GLenum>(c.pname);
2354 GLfloat param = static_cast<GLfloat>(c.param);
2355 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2356 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameterf",
2357 "invalid sampler id");
2358 return error::kNoError;
2360 glSamplerParameterf(sampler, pname, param);
2361 return error::kNoError;
2364 error::Error GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2365 uint32_t immediate_data_size,
2366 const void* cmd_data) {
2367 if (!unsafe_es3_apis_enabled())
2368 return error::kUnknownCommand;
2369 const gles2::cmds::SamplerParameterfvImmediate& c =
2370 *static_cast<const gles2::cmds::SamplerParameterfvImmediate*>(cmd_data);
2371 (void)c;
2372 GLuint sampler = c.sampler;
2373 GLenum pname = static_cast<GLenum>(c.pname);
2374 uint32_t data_size;
2375 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2376 return error::kOutOfBounds;
2378 if (data_size > immediate_data_size) {
2379 return error::kOutOfBounds;
2381 const GLfloat* params =
2382 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2383 if (params == NULL) {
2384 return error::kOutOfBounds;
2386 group_->GetSamplerServiceId(sampler, &sampler);
2387 DoSamplerParameterfv(sampler, pname, params);
2388 return error::kNoError;
2391 error::Error GLES2DecoderImpl::HandleSamplerParameteri(
2392 uint32_t immediate_data_size,
2393 const void* cmd_data) {
2394 if (!unsafe_es3_apis_enabled())
2395 return error::kUnknownCommand;
2396 const gles2::cmds::SamplerParameteri& c =
2397 *static_cast<const gles2::cmds::SamplerParameteri*>(cmd_data);
2398 (void)c;
2399 GLuint sampler = c.sampler;
2400 GLenum pname = static_cast<GLenum>(c.pname);
2401 GLint param = static_cast<GLint>(c.param);
2402 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2403 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameteri",
2404 "invalid sampler id");
2405 return error::kNoError;
2407 glSamplerParameteri(sampler, pname, param);
2408 return error::kNoError;
2411 error::Error GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2412 uint32_t immediate_data_size,
2413 const void* cmd_data) {
2414 if (!unsafe_es3_apis_enabled())
2415 return error::kUnknownCommand;
2416 const gles2::cmds::SamplerParameterivImmediate& c =
2417 *static_cast<const gles2::cmds::SamplerParameterivImmediate*>(cmd_data);
2418 (void)c;
2419 GLuint sampler = c.sampler;
2420 GLenum pname = static_cast<GLenum>(c.pname);
2421 uint32_t data_size;
2422 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2423 return error::kOutOfBounds;
2425 if (data_size > immediate_data_size) {
2426 return error::kOutOfBounds;
2428 const GLint* params =
2429 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2430 if (params == NULL) {
2431 return error::kOutOfBounds;
2433 DoSamplerParameteriv(sampler, pname, params);
2434 return error::kNoError;
2437 error::Error GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size,
2438 const void* cmd_data) {
2439 const gles2::cmds::Scissor& c =
2440 *static_cast<const gles2::cmds::Scissor*>(cmd_data);
2441 (void)c;
2442 GLint x = static_cast<GLint>(c.x);
2443 GLint y = static_cast<GLint>(c.y);
2444 GLsizei width = static_cast<GLsizei>(c.width);
2445 GLsizei height = static_cast<GLsizei>(c.height);
2446 if (width < 0) {
2447 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "width < 0");
2448 return error::kNoError;
2450 if (height < 0) {
2451 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "height < 0");
2452 return error::kNoError;
2454 if (state_.scissor_x != x || state_.scissor_y != y ||
2455 state_.scissor_width != width || state_.scissor_height != height) {
2456 state_.scissor_x = x;
2457 state_.scissor_y = y;
2458 state_.scissor_width = width;
2459 state_.scissor_height = height;
2460 glScissor(x, y, width, height);
2462 return error::kNoError;
2465 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2466 uint32_t immediate_data_size,
2467 const void* cmd_data) {
2468 const gles2::cmds::ShaderSourceBucket& c =
2469 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data);
2470 (void)c;
2471 GLuint shader = static_cast<GLuint>(c.shader);
2473 Bucket* bucket = GetBucket(c.str_bucket_id);
2474 if (!bucket) {
2475 return error::kInvalidArguments;
2477 GLsizei count = 0;
2478 std::vector<char*> strs;
2479 std::vector<GLint> len;
2480 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2481 return error::kInvalidArguments;
2483 const char** str =
2484 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2485 const GLint* length =
2486 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2487 (void)length;
2488 DoShaderSource(shader, count, str, length);
2489 return error::kNoError;
2492 error::Error GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size,
2493 const void* cmd_data) {
2494 const gles2::cmds::StencilFunc& c =
2495 *static_cast<const gles2::cmds::StencilFunc*>(cmd_data);
2496 (void)c;
2497 GLenum func = static_cast<GLenum>(c.func);
2498 GLint ref = static_cast<GLint>(c.ref);
2499 GLuint mask = static_cast<GLuint>(c.mask);
2500 if (!validators_->cmp_function.IsValid(func)) {
2501 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func, "func");
2502 return error::kNoError;
2504 if (state_.stencil_front_func != func || state_.stencil_front_ref != ref ||
2505 state_.stencil_front_mask != mask || state_.stencil_back_func != func ||
2506 state_.stencil_back_ref != ref || state_.stencil_back_mask != mask) {
2507 state_.stencil_front_func = func;
2508 state_.stencil_front_ref = ref;
2509 state_.stencil_front_mask = mask;
2510 state_.stencil_back_func = func;
2511 state_.stencil_back_ref = ref;
2512 state_.stencil_back_mask = mask;
2513 glStencilFunc(func, ref, mask);
2515 return error::kNoError;
2518 error::Error GLES2DecoderImpl::HandleStencilFuncSeparate(
2519 uint32_t immediate_data_size,
2520 const void* cmd_data) {
2521 const gles2::cmds::StencilFuncSeparate& c =
2522 *static_cast<const gles2::cmds::StencilFuncSeparate*>(cmd_data);
2523 (void)c;
2524 GLenum face = static_cast<GLenum>(c.face);
2525 GLenum func = static_cast<GLenum>(c.func);
2526 GLint ref = static_cast<GLint>(c.ref);
2527 GLuint mask = static_cast<GLuint>(c.mask);
2528 if (!validators_->face_type.IsValid(face)) {
2529 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face, "face");
2530 return error::kNoError;
2532 if (!validators_->cmp_function.IsValid(func)) {
2533 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func, "func");
2534 return error::kNoError;
2536 bool changed = false;
2537 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2538 changed |= state_.stencil_front_func != func ||
2539 state_.stencil_front_ref != ref ||
2540 state_.stencil_front_mask != mask;
2542 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2543 changed |= state_.stencil_back_func != func ||
2544 state_.stencil_back_ref != ref ||
2545 state_.stencil_back_mask != mask;
2547 if (changed) {
2548 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2549 state_.stencil_front_func = func;
2550 state_.stencil_front_ref = ref;
2551 state_.stencil_front_mask = mask;
2553 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2554 state_.stencil_back_func = func;
2555 state_.stencil_back_ref = ref;
2556 state_.stencil_back_mask = mask;
2558 glStencilFuncSeparate(face, func, ref, mask);
2560 return error::kNoError;
2563 error::Error GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size,
2564 const void* cmd_data) {
2565 const gles2::cmds::StencilMask& c =
2566 *static_cast<const gles2::cmds::StencilMask*>(cmd_data);
2567 (void)c;
2568 GLuint mask = static_cast<GLuint>(c.mask);
2569 if (state_.stencil_front_writemask != mask ||
2570 state_.stencil_back_writemask != mask) {
2571 state_.stencil_front_writemask = mask;
2572 state_.stencil_back_writemask = mask;
2573 framebuffer_state_.clear_state_dirty = true;
2575 return error::kNoError;
2578 error::Error GLES2DecoderImpl::HandleStencilMaskSeparate(
2579 uint32_t immediate_data_size,
2580 const void* cmd_data) {
2581 const gles2::cmds::StencilMaskSeparate& c =
2582 *static_cast<const gles2::cmds::StencilMaskSeparate*>(cmd_data);
2583 (void)c;
2584 GLenum face = static_cast<GLenum>(c.face);
2585 GLuint mask = static_cast<GLuint>(c.mask);
2586 if (!validators_->face_type.IsValid(face)) {
2587 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face, "face");
2588 return error::kNoError;
2590 bool changed = false;
2591 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2592 changed |= state_.stencil_front_writemask != mask;
2594 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2595 changed |= state_.stencil_back_writemask != mask;
2597 if (changed) {
2598 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2599 state_.stencil_front_writemask = mask;
2601 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2602 state_.stencil_back_writemask = mask;
2604 framebuffer_state_.clear_state_dirty = true;
2606 return error::kNoError;
2609 error::Error GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size,
2610 const void* cmd_data) {
2611 const gles2::cmds::StencilOp& c =
2612 *static_cast<const gles2::cmds::StencilOp*>(cmd_data);
2613 (void)c;
2614 GLenum fail = static_cast<GLenum>(c.fail);
2615 GLenum zfail = static_cast<GLenum>(c.zfail);
2616 GLenum zpass = static_cast<GLenum>(c.zpass);
2617 if (!validators_->stencil_op.IsValid(fail)) {
2618 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail, "fail");
2619 return error::kNoError;
2621 if (!validators_->stencil_op.IsValid(zfail)) {
2622 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail, "zfail");
2623 return error::kNoError;
2625 if (!validators_->stencil_op.IsValid(zpass)) {
2626 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass, "zpass");
2627 return error::kNoError;
2629 if (state_.stencil_front_fail_op != fail ||
2630 state_.stencil_front_z_fail_op != zfail ||
2631 state_.stencil_front_z_pass_op != zpass ||
2632 state_.stencil_back_fail_op != fail ||
2633 state_.stencil_back_z_fail_op != zfail ||
2634 state_.stencil_back_z_pass_op != zpass) {
2635 state_.stencil_front_fail_op = fail;
2636 state_.stencil_front_z_fail_op = zfail;
2637 state_.stencil_front_z_pass_op = zpass;
2638 state_.stencil_back_fail_op = fail;
2639 state_.stencil_back_z_fail_op = zfail;
2640 state_.stencil_back_z_pass_op = zpass;
2641 glStencilOp(fail, zfail, zpass);
2643 return error::kNoError;
2646 error::Error GLES2DecoderImpl::HandleStencilOpSeparate(
2647 uint32_t immediate_data_size,
2648 const void* cmd_data) {
2649 const gles2::cmds::StencilOpSeparate& c =
2650 *static_cast<const gles2::cmds::StencilOpSeparate*>(cmd_data);
2651 (void)c;
2652 GLenum face = static_cast<GLenum>(c.face);
2653 GLenum fail = static_cast<GLenum>(c.fail);
2654 GLenum zfail = static_cast<GLenum>(c.zfail);
2655 GLenum zpass = static_cast<GLenum>(c.zpass);
2656 if (!validators_->face_type.IsValid(face)) {
2657 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face, "face");
2658 return error::kNoError;
2660 if (!validators_->stencil_op.IsValid(fail)) {
2661 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail, "fail");
2662 return error::kNoError;
2664 if (!validators_->stencil_op.IsValid(zfail)) {
2665 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail, "zfail");
2666 return error::kNoError;
2668 if (!validators_->stencil_op.IsValid(zpass)) {
2669 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass, "zpass");
2670 return error::kNoError;
2672 bool changed = false;
2673 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2674 changed |= state_.stencil_front_fail_op != fail ||
2675 state_.stencil_front_z_fail_op != zfail ||
2676 state_.stencil_front_z_pass_op != zpass;
2678 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2679 changed |= state_.stencil_back_fail_op != fail ||
2680 state_.stencil_back_z_fail_op != zfail ||
2681 state_.stencil_back_z_pass_op != zpass;
2683 if (changed) {
2684 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2685 state_.stencil_front_fail_op = fail;
2686 state_.stencil_front_z_fail_op = zfail;
2687 state_.stencil_front_z_pass_op = zpass;
2689 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2690 state_.stencil_back_fail_op = fail;
2691 state_.stencil_back_z_fail_op = zfail;
2692 state_.stencil_back_z_pass_op = zpass;
2694 glStencilOpSeparate(face, fail, zfail, zpass);
2696 return error::kNoError;
2699 error::Error GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size,
2700 const void* cmd_data) {
2701 const gles2::cmds::TexParameterf& c =
2702 *static_cast<const gles2::cmds::TexParameterf*>(cmd_data);
2703 (void)c;
2704 GLenum target = static_cast<GLenum>(c.target);
2705 GLenum pname = static_cast<GLenum>(c.pname);
2706 GLfloat param = static_cast<GLfloat>(c.param);
2707 if (!validators_->texture_bind_target.IsValid(target)) {
2708 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target, "target");
2709 return error::kNoError;
2711 if (!validators_->texture_parameter.IsValid(pname)) {
2712 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname, "pname");
2713 return error::kNoError;
2715 DoTexParameterf(target, pname, param);
2716 return error::kNoError;
2719 error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
2720 uint32_t immediate_data_size,
2721 const void* cmd_data) {
2722 const gles2::cmds::TexParameterfvImmediate& c =
2723 *static_cast<const gles2::cmds::TexParameterfvImmediate*>(cmd_data);
2724 (void)c;
2725 GLenum target = static_cast<GLenum>(c.target);
2726 GLenum pname = static_cast<GLenum>(c.pname);
2727 uint32_t data_size;
2728 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2729 return error::kOutOfBounds;
2731 if (data_size > immediate_data_size) {
2732 return error::kOutOfBounds;
2734 const GLfloat* params =
2735 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2736 if (!validators_->texture_bind_target.IsValid(target)) {
2737 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target, "target");
2738 return error::kNoError;
2740 if (!validators_->texture_parameter.IsValid(pname)) {
2741 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname, "pname");
2742 return error::kNoError;
2744 if (params == NULL) {
2745 return error::kOutOfBounds;
2747 DoTexParameterfv(target, pname, params);
2748 return error::kNoError;
2751 error::Error GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size,
2752 const void* cmd_data) {
2753 const gles2::cmds::TexParameteri& c =
2754 *static_cast<const gles2::cmds::TexParameteri*>(cmd_data);
2755 (void)c;
2756 GLenum target = static_cast<GLenum>(c.target);
2757 GLenum pname = static_cast<GLenum>(c.pname);
2758 GLint param = static_cast<GLint>(c.param);
2759 if (!validators_->texture_bind_target.IsValid(target)) {
2760 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target, "target");
2761 return error::kNoError;
2763 if (!validators_->texture_parameter.IsValid(pname)) {
2764 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname, "pname");
2765 return error::kNoError;
2767 DoTexParameteri(target, pname, param);
2768 return error::kNoError;
2771 error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
2772 uint32_t immediate_data_size,
2773 const void* cmd_data) {
2774 const gles2::cmds::TexParameterivImmediate& c =
2775 *static_cast<const gles2::cmds::TexParameterivImmediate*>(cmd_data);
2776 (void)c;
2777 GLenum target = static_cast<GLenum>(c.target);
2778 GLenum pname = static_cast<GLenum>(c.pname);
2779 uint32_t data_size;
2780 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2781 return error::kOutOfBounds;
2783 if (data_size > immediate_data_size) {
2784 return error::kOutOfBounds;
2786 const GLint* params =
2787 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2788 if (!validators_->texture_bind_target.IsValid(target)) {
2789 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target, "target");
2790 return error::kNoError;
2792 if (!validators_->texture_parameter.IsValid(pname)) {
2793 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname, "pname");
2794 return error::kNoError;
2796 if (params == NULL) {
2797 return error::kOutOfBounds;
2799 DoTexParameteriv(target, pname, params);
2800 return error::kNoError;
2803 error::Error GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size,
2804 const void* cmd_data) {
2805 if (!unsafe_es3_apis_enabled())
2806 return error::kUnknownCommand;
2807 const gles2::cmds::TexStorage3D& c =
2808 *static_cast<const gles2::cmds::TexStorage3D*>(cmd_data);
2809 (void)c;
2810 GLenum target = static_cast<GLenum>(c.target);
2811 GLsizei levels = static_cast<GLsizei>(c.levels);
2812 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
2813 GLsizei width = static_cast<GLsizei>(c.width);
2814 GLsizei height = static_cast<GLsizei>(c.height);
2815 GLsizei depth = static_cast<GLsizei>(c.depth);
2816 glTexStorage3D(target, levels, internalFormat, width, height, depth);
2817 return error::kNoError;
2820 error::Error GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
2821 uint32_t immediate_data_size,
2822 const void* cmd_data) {
2823 if (!unsafe_es3_apis_enabled())
2824 return error::kUnknownCommand;
2825 const gles2::cmds::TransformFeedbackVaryingsBucket& c =
2826 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket*>(
2827 cmd_data);
2828 (void)c;
2829 GLuint program = static_cast<GLuint>(c.program);
2831 Bucket* bucket = GetBucket(c.varyings_bucket_id);
2832 if (!bucket) {
2833 return error::kInvalidArguments;
2835 GLsizei count = 0;
2836 std::vector<char*> strs;
2837 std::vector<GLint> len;
2838 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2839 return error::kInvalidArguments;
2841 const char** varyings =
2842 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2843 const GLint* length =
2844 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2845 (void)length;
2846 GLenum buffermode = static_cast<GLenum>(c.buffermode);
2847 DoTransformFeedbackVaryings(program, count, varyings, buffermode);
2848 return error::kNoError;
2851 error::Error GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size,
2852 const void* cmd_data) {
2853 const gles2::cmds::Uniform1f& c =
2854 *static_cast<const gles2::cmds::Uniform1f*>(cmd_data);
2855 (void)c;
2856 GLint location = static_cast<GLint>(c.location);
2857 GLfloat x = static_cast<GLfloat>(c.x);
2858 GLfloat temp[1] = {
2861 DoUniform1fv(location, 1, &temp[0]);
2862 return error::kNoError;
2865 error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
2866 uint32_t immediate_data_size,
2867 const void* cmd_data) {
2868 const gles2::cmds::Uniform1fvImmediate& c =
2869 *static_cast<const gles2::cmds::Uniform1fvImmediate*>(cmd_data);
2870 (void)c;
2871 GLint location = static_cast<GLint>(c.location);
2872 GLsizei count = static_cast<GLsizei>(c.count);
2873 uint32_t data_size;
2874 if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
2875 return error::kOutOfBounds;
2877 if (data_size > immediate_data_size) {
2878 return error::kOutOfBounds;
2880 const GLfloat* v =
2881 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2882 if (v == NULL) {
2883 return error::kOutOfBounds;
2885 DoUniform1fv(location, count, v);
2886 return error::kNoError;
2889 error::Error GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size,
2890 const void* cmd_data) {
2891 const gles2::cmds::Uniform1i& c =
2892 *static_cast<const gles2::cmds::Uniform1i*>(cmd_data);
2893 (void)c;
2894 GLint location = static_cast<GLint>(c.location);
2895 GLint x = static_cast<GLint>(c.x);
2896 DoUniform1i(location, x);
2897 return error::kNoError;
2900 error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
2901 uint32_t immediate_data_size,
2902 const void* cmd_data) {
2903 const gles2::cmds::Uniform1ivImmediate& c =
2904 *static_cast<const gles2::cmds::Uniform1ivImmediate*>(cmd_data);
2905 (void)c;
2906 GLint location = static_cast<GLint>(c.location);
2907 GLsizei count = static_cast<GLsizei>(c.count);
2908 uint32_t data_size;
2909 if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
2910 return error::kOutOfBounds;
2912 if (data_size > immediate_data_size) {
2913 return error::kOutOfBounds;
2915 const GLint* v =
2916 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2917 if (v == NULL) {
2918 return error::kOutOfBounds;
2920 DoUniform1iv(location, count, v);
2921 return error::kNoError;
2924 error::Error GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size,
2925 const void* cmd_data) {
2926 if (!unsafe_es3_apis_enabled())
2927 return error::kUnknownCommand;
2928 const gles2::cmds::Uniform1ui& c =
2929 *static_cast<const gles2::cmds::Uniform1ui*>(cmd_data);
2930 (void)c;
2931 GLint location = static_cast<GLint>(c.location);
2932 GLuint x = static_cast<GLuint>(c.x);
2933 GLuint temp[1] = {
2936 glUniform1uiv(location, 1, &temp[0]);
2937 return error::kNoError;
2940 error::Error GLES2DecoderImpl::HandleUniform1uivImmediate(
2941 uint32_t immediate_data_size,
2942 const void* cmd_data) {
2943 if (!unsafe_es3_apis_enabled())
2944 return error::kUnknownCommand;
2945 const gles2::cmds::Uniform1uivImmediate& c =
2946 *static_cast<const gles2::cmds::Uniform1uivImmediate*>(cmd_data);
2947 (void)c;
2948 GLint location = static_cast<GLint>(c.location);
2949 GLsizei count = static_cast<GLsizei>(c.count);
2950 uint32_t data_size;
2951 if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) {
2952 return error::kOutOfBounds;
2954 if (data_size > immediate_data_size) {
2955 return error::kOutOfBounds;
2957 const GLuint* v =
2958 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
2959 if (v == NULL) {
2960 return error::kOutOfBounds;
2962 glUniform1uiv(location, count, v);
2963 return error::kNoError;
2966 error::Error GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size,
2967 const void* cmd_data) {
2968 const gles2::cmds::Uniform2f& c =
2969 *static_cast<const gles2::cmds::Uniform2f*>(cmd_data);
2970 (void)c;
2971 GLint location = static_cast<GLint>(c.location);
2972 GLfloat x = static_cast<GLfloat>(c.x);
2973 GLfloat y = static_cast<GLfloat>(c.y);
2974 GLfloat temp[2] = {
2975 x, y,
2977 DoUniform2fv(location, 1, &temp[0]);
2978 return error::kNoError;
2981 error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
2982 uint32_t immediate_data_size,
2983 const void* cmd_data) {
2984 const gles2::cmds::Uniform2fvImmediate& c =
2985 *static_cast<const gles2::cmds::Uniform2fvImmediate*>(cmd_data);
2986 (void)c;
2987 GLint location = static_cast<GLint>(c.location);
2988 GLsizei count = static_cast<GLsizei>(c.count);
2989 uint32_t data_size;
2990 if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
2991 return error::kOutOfBounds;
2993 if (data_size > immediate_data_size) {
2994 return error::kOutOfBounds;
2996 const GLfloat* v =
2997 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2998 if (v == NULL) {
2999 return error::kOutOfBounds;
3001 DoUniform2fv(location, count, v);
3002 return error::kNoError;
3005 error::Error GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size,
3006 const void* cmd_data) {
3007 const gles2::cmds::Uniform2i& c =
3008 *static_cast<const gles2::cmds::Uniform2i*>(cmd_data);
3009 (void)c;
3010 GLint location = static_cast<GLint>(c.location);
3011 GLint x = static_cast<GLint>(c.x);
3012 GLint y = static_cast<GLint>(c.y);
3013 GLint temp[2] = {
3014 x, y,
3016 DoUniform2iv(location, 1, &temp[0]);
3017 return error::kNoError;
3020 error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
3021 uint32_t immediate_data_size,
3022 const void* cmd_data) {
3023 const gles2::cmds::Uniform2ivImmediate& c =
3024 *static_cast<const gles2::cmds::Uniform2ivImmediate*>(cmd_data);
3025 (void)c;
3026 GLint location = static_cast<GLint>(c.location);
3027 GLsizei count = static_cast<GLsizei>(c.count);
3028 uint32_t data_size;
3029 if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
3030 return error::kOutOfBounds;
3032 if (data_size > immediate_data_size) {
3033 return error::kOutOfBounds;
3035 const GLint* v =
3036 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3037 if (v == NULL) {
3038 return error::kOutOfBounds;
3040 DoUniform2iv(location, count, v);
3041 return error::kNoError;
3044 error::Error GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size,
3045 const void* cmd_data) {
3046 if (!unsafe_es3_apis_enabled())
3047 return error::kUnknownCommand;
3048 const gles2::cmds::Uniform2ui& c =
3049 *static_cast<const gles2::cmds::Uniform2ui*>(cmd_data);
3050 (void)c;
3051 GLint location = static_cast<GLint>(c.location);
3052 GLuint x = static_cast<GLuint>(c.x);
3053 GLuint y = static_cast<GLuint>(c.y);
3054 GLuint temp[2] = {
3055 x, y,
3057 glUniform2uiv(location, 1, &temp[0]);
3058 return error::kNoError;
3061 error::Error GLES2DecoderImpl::HandleUniform2uivImmediate(
3062 uint32_t immediate_data_size,
3063 const void* cmd_data) {
3064 if (!unsafe_es3_apis_enabled())
3065 return error::kUnknownCommand;
3066 const gles2::cmds::Uniform2uivImmediate& c =
3067 *static_cast<const gles2::cmds::Uniform2uivImmediate*>(cmd_data);
3068 (void)c;
3069 GLint location = static_cast<GLint>(c.location);
3070 GLsizei count = static_cast<GLsizei>(c.count);
3071 uint32_t data_size;
3072 if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) {
3073 return error::kOutOfBounds;
3075 if (data_size > immediate_data_size) {
3076 return error::kOutOfBounds;
3078 const GLuint* v =
3079 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3080 if (v == NULL) {
3081 return error::kOutOfBounds;
3083 glUniform2uiv(location, count, v);
3084 return error::kNoError;
3087 error::Error GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size,
3088 const void* cmd_data) {
3089 const gles2::cmds::Uniform3f& c =
3090 *static_cast<const gles2::cmds::Uniform3f*>(cmd_data);
3091 (void)c;
3092 GLint location = static_cast<GLint>(c.location);
3093 GLfloat x = static_cast<GLfloat>(c.x);
3094 GLfloat y = static_cast<GLfloat>(c.y);
3095 GLfloat z = static_cast<GLfloat>(c.z);
3096 GLfloat temp[3] = {
3097 x, y, z,
3099 DoUniform3fv(location, 1, &temp[0]);
3100 return error::kNoError;
3103 error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
3104 uint32_t immediate_data_size,
3105 const void* cmd_data) {
3106 const gles2::cmds::Uniform3fvImmediate& c =
3107 *static_cast<const gles2::cmds::Uniform3fvImmediate*>(cmd_data);
3108 (void)c;
3109 GLint location = static_cast<GLint>(c.location);
3110 GLsizei count = static_cast<GLsizei>(c.count);
3111 uint32_t data_size;
3112 if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
3113 return error::kOutOfBounds;
3115 if (data_size > immediate_data_size) {
3116 return error::kOutOfBounds;
3118 const GLfloat* v =
3119 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3120 if (v == NULL) {
3121 return error::kOutOfBounds;
3123 DoUniform3fv(location, count, v);
3124 return error::kNoError;
3127 error::Error GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size,
3128 const void* cmd_data) {
3129 const gles2::cmds::Uniform3i& c =
3130 *static_cast<const gles2::cmds::Uniform3i*>(cmd_data);
3131 (void)c;
3132 GLint location = static_cast<GLint>(c.location);
3133 GLint x = static_cast<GLint>(c.x);
3134 GLint y = static_cast<GLint>(c.y);
3135 GLint z = static_cast<GLint>(c.z);
3136 GLint temp[3] = {
3137 x, y, z,
3139 DoUniform3iv(location, 1, &temp[0]);
3140 return error::kNoError;
3143 error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
3144 uint32_t immediate_data_size,
3145 const void* cmd_data) {
3146 const gles2::cmds::Uniform3ivImmediate& c =
3147 *static_cast<const gles2::cmds::Uniform3ivImmediate*>(cmd_data);
3148 (void)c;
3149 GLint location = static_cast<GLint>(c.location);
3150 GLsizei count = static_cast<GLsizei>(c.count);
3151 uint32_t data_size;
3152 if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
3153 return error::kOutOfBounds;
3155 if (data_size > immediate_data_size) {
3156 return error::kOutOfBounds;
3158 const GLint* v =
3159 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3160 if (v == NULL) {
3161 return error::kOutOfBounds;
3163 DoUniform3iv(location, count, v);
3164 return error::kNoError;
3167 error::Error GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size,
3168 const void* cmd_data) {
3169 if (!unsafe_es3_apis_enabled())
3170 return error::kUnknownCommand;
3171 const gles2::cmds::Uniform3ui& c =
3172 *static_cast<const gles2::cmds::Uniform3ui*>(cmd_data);
3173 (void)c;
3174 GLint location = static_cast<GLint>(c.location);
3175 GLuint x = static_cast<GLuint>(c.x);
3176 GLuint y = static_cast<GLuint>(c.y);
3177 GLuint z = static_cast<GLuint>(c.z);
3178 GLuint temp[3] = {
3179 x, y, z,
3181 glUniform3uiv(location, 1, &temp[0]);
3182 return error::kNoError;
3185 error::Error GLES2DecoderImpl::HandleUniform3uivImmediate(
3186 uint32_t immediate_data_size,
3187 const void* cmd_data) {
3188 if (!unsafe_es3_apis_enabled())
3189 return error::kUnknownCommand;
3190 const gles2::cmds::Uniform3uivImmediate& c =
3191 *static_cast<const gles2::cmds::Uniform3uivImmediate*>(cmd_data);
3192 (void)c;
3193 GLint location = static_cast<GLint>(c.location);
3194 GLsizei count = static_cast<GLsizei>(c.count);
3195 uint32_t data_size;
3196 if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) {
3197 return error::kOutOfBounds;
3199 if (data_size > immediate_data_size) {
3200 return error::kOutOfBounds;
3202 const GLuint* v =
3203 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3204 if (v == NULL) {
3205 return error::kOutOfBounds;
3207 glUniform3uiv(location, count, v);
3208 return error::kNoError;
3211 error::Error GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size,
3212 const void* cmd_data) {
3213 const gles2::cmds::Uniform4f& c =
3214 *static_cast<const gles2::cmds::Uniform4f*>(cmd_data);
3215 (void)c;
3216 GLint location = static_cast<GLint>(c.location);
3217 GLfloat x = static_cast<GLfloat>(c.x);
3218 GLfloat y = static_cast<GLfloat>(c.y);
3219 GLfloat z = static_cast<GLfloat>(c.z);
3220 GLfloat w = static_cast<GLfloat>(c.w);
3221 GLfloat temp[4] = {
3222 x, y, z, w,
3224 DoUniform4fv(location, 1, &temp[0]);
3225 return error::kNoError;
3228 error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
3229 uint32_t immediate_data_size,
3230 const void* cmd_data) {
3231 const gles2::cmds::Uniform4fvImmediate& c =
3232 *static_cast<const gles2::cmds::Uniform4fvImmediate*>(cmd_data);
3233 (void)c;
3234 GLint location = static_cast<GLint>(c.location);
3235 GLsizei count = static_cast<GLsizei>(c.count);
3236 uint32_t data_size;
3237 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3238 return error::kOutOfBounds;
3240 if (data_size > immediate_data_size) {
3241 return error::kOutOfBounds;
3243 const GLfloat* v =
3244 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3245 if (v == NULL) {
3246 return error::kOutOfBounds;
3248 DoUniform4fv(location, count, v);
3249 return error::kNoError;
3252 error::Error GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size,
3253 const void* cmd_data) {
3254 const gles2::cmds::Uniform4i& c =
3255 *static_cast<const gles2::cmds::Uniform4i*>(cmd_data);
3256 (void)c;
3257 GLint location = static_cast<GLint>(c.location);
3258 GLint x = static_cast<GLint>(c.x);
3259 GLint y = static_cast<GLint>(c.y);
3260 GLint z = static_cast<GLint>(c.z);
3261 GLint w = static_cast<GLint>(c.w);
3262 GLint temp[4] = {
3263 x, y, z, w,
3265 DoUniform4iv(location, 1, &temp[0]);
3266 return error::kNoError;
3269 error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
3270 uint32_t immediate_data_size,
3271 const void* cmd_data) {
3272 const gles2::cmds::Uniform4ivImmediate& c =
3273 *static_cast<const gles2::cmds::Uniform4ivImmediate*>(cmd_data);
3274 (void)c;
3275 GLint location = static_cast<GLint>(c.location);
3276 GLsizei count = static_cast<GLsizei>(c.count);
3277 uint32_t data_size;
3278 if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
3279 return error::kOutOfBounds;
3281 if (data_size > immediate_data_size) {
3282 return error::kOutOfBounds;
3284 const GLint* v =
3285 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3286 if (v == NULL) {
3287 return error::kOutOfBounds;
3289 DoUniform4iv(location, count, v);
3290 return error::kNoError;
3293 error::Error GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size,
3294 const void* cmd_data) {
3295 if (!unsafe_es3_apis_enabled())
3296 return error::kUnknownCommand;
3297 const gles2::cmds::Uniform4ui& c =
3298 *static_cast<const gles2::cmds::Uniform4ui*>(cmd_data);
3299 (void)c;
3300 GLint location = static_cast<GLint>(c.location);
3301 GLuint x = static_cast<GLuint>(c.x);
3302 GLuint y = static_cast<GLuint>(c.y);
3303 GLuint z = static_cast<GLuint>(c.z);
3304 GLuint w = static_cast<GLuint>(c.w);
3305 GLuint temp[4] = {
3306 x, y, z, w,
3308 glUniform4uiv(location, 1, &temp[0]);
3309 return error::kNoError;
3312 error::Error GLES2DecoderImpl::HandleUniform4uivImmediate(
3313 uint32_t immediate_data_size,
3314 const void* cmd_data) {
3315 if (!unsafe_es3_apis_enabled())
3316 return error::kUnknownCommand;
3317 const gles2::cmds::Uniform4uivImmediate& c =
3318 *static_cast<const gles2::cmds::Uniform4uivImmediate*>(cmd_data);
3319 (void)c;
3320 GLint location = static_cast<GLint>(c.location);
3321 GLsizei count = static_cast<GLsizei>(c.count);
3322 uint32_t data_size;
3323 if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) {
3324 return error::kOutOfBounds;
3326 if (data_size > immediate_data_size) {
3327 return error::kOutOfBounds;
3329 const GLuint* v =
3330 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3331 if (v == NULL) {
3332 return error::kOutOfBounds;
3334 glUniform4uiv(location, count, v);
3335 return error::kNoError;
3338 error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3339 uint32_t immediate_data_size,
3340 const void* cmd_data) {
3341 const gles2::cmds::UniformMatrix2fvImmediate& c =
3342 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate*>(cmd_data);
3343 (void)c;
3344 GLint location = static_cast<GLint>(c.location);
3345 GLsizei count = static_cast<GLsizei>(c.count);
3346 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3347 uint32_t data_size;
3348 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3349 return error::kOutOfBounds;
3351 if (data_size > immediate_data_size) {
3352 return error::kOutOfBounds;
3354 const GLfloat* value =
3355 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3356 if (value == NULL) {
3357 return error::kOutOfBounds;
3359 DoUniformMatrix2fv(location, count, transpose, value);
3360 return error::kNoError;
3363 error::Error GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3364 uint32_t immediate_data_size,
3365 const void* cmd_data) {
3366 if (!unsafe_es3_apis_enabled())
3367 return error::kUnknownCommand;
3368 const gles2::cmds::UniformMatrix2x3fvImmediate& c =
3369 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate*>(cmd_data);
3370 (void)c;
3371 GLint location = static_cast<GLint>(c.location);
3372 GLsizei count = static_cast<GLsizei>(c.count);
3373 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3374 uint32_t data_size;
3375 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3376 return error::kOutOfBounds;
3378 if (data_size > immediate_data_size) {
3379 return error::kOutOfBounds;
3381 const GLfloat* value =
3382 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3383 if (value == NULL) {
3384 return error::kOutOfBounds;
3386 glUniformMatrix2x3fv(location, count, transpose, value);
3387 return error::kNoError;
3390 error::Error GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3391 uint32_t immediate_data_size,
3392 const void* cmd_data) {
3393 if (!unsafe_es3_apis_enabled())
3394 return error::kUnknownCommand;
3395 const gles2::cmds::UniformMatrix2x4fvImmediate& c =
3396 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate*>(cmd_data);
3397 (void)c;
3398 GLint location = static_cast<GLint>(c.location);
3399 GLsizei count = static_cast<GLsizei>(c.count);
3400 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3401 uint32_t data_size;
3402 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3403 return error::kOutOfBounds;
3405 if (data_size > immediate_data_size) {
3406 return error::kOutOfBounds;
3408 const GLfloat* value =
3409 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3410 if (value == NULL) {
3411 return error::kOutOfBounds;
3413 glUniformMatrix2x4fv(location, count, transpose, value);
3414 return error::kNoError;
3417 error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3418 uint32_t immediate_data_size,
3419 const void* cmd_data) {
3420 const gles2::cmds::UniformMatrix3fvImmediate& c =
3421 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate*>(cmd_data);
3422 (void)c;
3423 GLint location = static_cast<GLint>(c.location);
3424 GLsizei count = static_cast<GLsizei>(c.count);
3425 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3426 uint32_t data_size;
3427 if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
3428 return error::kOutOfBounds;
3430 if (data_size > immediate_data_size) {
3431 return error::kOutOfBounds;
3433 const GLfloat* value =
3434 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3435 if (value == NULL) {
3436 return error::kOutOfBounds;
3438 DoUniformMatrix3fv(location, count, transpose, value);
3439 return error::kNoError;
3442 error::Error GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3443 uint32_t immediate_data_size,
3444 const void* cmd_data) {
3445 if (!unsafe_es3_apis_enabled())
3446 return error::kUnknownCommand;
3447 const gles2::cmds::UniformMatrix3x2fvImmediate& c =
3448 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate*>(cmd_data);
3449 (void)c;
3450 GLint location = static_cast<GLint>(c.location);
3451 GLsizei count = static_cast<GLsizei>(c.count);
3452 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3453 uint32_t data_size;
3454 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3455 return error::kOutOfBounds;
3457 if (data_size > immediate_data_size) {
3458 return error::kOutOfBounds;
3460 const GLfloat* value =
3461 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3462 if (value == NULL) {
3463 return error::kOutOfBounds;
3465 glUniformMatrix3x2fv(location, count, transpose, value);
3466 return error::kNoError;
3469 error::Error GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3470 uint32_t immediate_data_size,
3471 const void* cmd_data) {
3472 if (!unsafe_es3_apis_enabled())
3473 return error::kUnknownCommand;
3474 const gles2::cmds::UniformMatrix3x4fvImmediate& c =
3475 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate*>(cmd_data);
3476 (void)c;
3477 GLint location = static_cast<GLint>(c.location);
3478 GLsizei count = static_cast<GLsizei>(c.count);
3479 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3480 uint32_t data_size;
3481 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3482 return error::kOutOfBounds;
3484 if (data_size > immediate_data_size) {
3485 return error::kOutOfBounds;
3487 const GLfloat* value =
3488 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3489 if (value == NULL) {
3490 return error::kOutOfBounds;
3492 glUniformMatrix3x4fv(location, count, transpose, value);
3493 return error::kNoError;
3496 error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3497 uint32_t immediate_data_size,
3498 const void* cmd_data) {
3499 const gles2::cmds::UniformMatrix4fvImmediate& c =
3500 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate*>(cmd_data);
3501 (void)c;
3502 GLint location = static_cast<GLint>(c.location);
3503 GLsizei count = static_cast<GLsizei>(c.count);
3504 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3505 uint32_t data_size;
3506 if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
3507 return error::kOutOfBounds;
3509 if (data_size > immediate_data_size) {
3510 return error::kOutOfBounds;
3512 const GLfloat* value =
3513 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3514 if (value == NULL) {
3515 return error::kOutOfBounds;
3517 DoUniformMatrix4fv(location, count, transpose, value);
3518 return error::kNoError;
3521 error::Error GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3522 uint32_t immediate_data_size,
3523 const void* cmd_data) {
3524 if (!unsafe_es3_apis_enabled())
3525 return error::kUnknownCommand;
3526 const gles2::cmds::UniformMatrix4x2fvImmediate& c =
3527 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate*>(cmd_data);
3528 (void)c;
3529 GLint location = static_cast<GLint>(c.location);
3530 GLsizei count = static_cast<GLsizei>(c.count);
3531 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3532 uint32_t data_size;
3533 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3534 return error::kOutOfBounds;
3536 if (data_size > immediate_data_size) {
3537 return error::kOutOfBounds;
3539 const GLfloat* value =
3540 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3541 if (value == NULL) {
3542 return error::kOutOfBounds;
3544 glUniformMatrix4x2fv(location, count, transpose, value);
3545 return error::kNoError;
3548 error::Error GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3549 uint32_t immediate_data_size,
3550 const void* cmd_data) {
3551 if (!unsafe_es3_apis_enabled())
3552 return error::kUnknownCommand;
3553 const gles2::cmds::UniformMatrix4x3fvImmediate& c =
3554 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate*>(cmd_data);
3555 (void)c;
3556 GLint location = static_cast<GLint>(c.location);
3557 GLsizei count = static_cast<GLsizei>(c.count);
3558 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3559 uint32_t data_size;
3560 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3561 return error::kOutOfBounds;
3563 if (data_size > immediate_data_size) {
3564 return error::kOutOfBounds;
3566 const GLfloat* value =
3567 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3568 if (value == NULL) {
3569 return error::kOutOfBounds;
3571 glUniformMatrix4x3fv(location, count, transpose, value);
3572 return error::kNoError;
3575 error::Error GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size,
3576 const void* cmd_data) {
3577 const gles2::cmds::UseProgram& c =
3578 *static_cast<const gles2::cmds::UseProgram*>(cmd_data);
3579 (void)c;
3580 GLuint program = c.program;
3581 DoUseProgram(program);
3582 return error::kNoError;
3585 error::Error GLES2DecoderImpl::HandleValidateProgram(
3586 uint32_t immediate_data_size,
3587 const void* cmd_data) {
3588 const gles2::cmds::ValidateProgram& c =
3589 *static_cast<const gles2::cmds::ValidateProgram*>(cmd_data);
3590 (void)c;
3591 GLuint program = c.program;
3592 DoValidateProgram(program);
3593 return error::kNoError;
3596 error::Error GLES2DecoderImpl::HandleVertexAttrib1f(
3597 uint32_t immediate_data_size,
3598 const void* cmd_data) {
3599 const gles2::cmds::VertexAttrib1f& c =
3600 *static_cast<const gles2::cmds::VertexAttrib1f*>(cmd_data);
3601 (void)c;
3602 GLuint indx = static_cast<GLuint>(c.indx);
3603 GLfloat x = static_cast<GLfloat>(c.x);
3604 DoVertexAttrib1f(indx, x);
3605 return error::kNoError;
3608 error::Error GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3609 uint32_t immediate_data_size,
3610 const void* cmd_data) {
3611 const gles2::cmds::VertexAttrib1fvImmediate& c =
3612 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate*>(cmd_data);
3613 (void)c;
3614 GLuint indx = static_cast<GLuint>(c.indx);
3615 uint32_t data_size;
3616 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
3617 return error::kOutOfBounds;
3619 if (data_size > immediate_data_size) {
3620 return error::kOutOfBounds;
3622 const GLfloat* values =
3623 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3624 if (values == NULL) {
3625 return error::kOutOfBounds;
3627 DoVertexAttrib1fv(indx, values);
3628 return error::kNoError;
3631 error::Error GLES2DecoderImpl::HandleVertexAttrib2f(
3632 uint32_t immediate_data_size,
3633 const void* cmd_data) {
3634 const gles2::cmds::VertexAttrib2f& c =
3635 *static_cast<const gles2::cmds::VertexAttrib2f*>(cmd_data);
3636 (void)c;
3637 GLuint indx = static_cast<GLuint>(c.indx);
3638 GLfloat x = static_cast<GLfloat>(c.x);
3639 GLfloat y = static_cast<GLfloat>(c.y);
3640 DoVertexAttrib2f(indx, x, y);
3641 return error::kNoError;
3644 error::Error GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3645 uint32_t immediate_data_size,
3646 const void* cmd_data) {
3647 const gles2::cmds::VertexAttrib2fvImmediate& c =
3648 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate*>(cmd_data);
3649 (void)c;
3650 GLuint indx = static_cast<GLuint>(c.indx);
3651 uint32_t data_size;
3652 if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
3653 return error::kOutOfBounds;
3655 if (data_size > immediate_data_size) {
3656 return error::kOutOfBounds;
3658 const GLfloat* values =
3659 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3660 if (values == NULL) {
3661 return error::kOutOfBounds;
3663 DoVertexAttrib2fv(indx, values);
3664 return error::kNoError;
3667 error::Error GLES2DecoderImpl::HandleVertexAttrib3f(
3668 uint32_t immediate_data_size,
3669 const void* cmd_data) {
3670 const gles2::cmds::VertexAttrib3f& c =
3671 *static_cast<const gles2::cmds::VertexAttrib3f*>(cmd_data);
3672 (void)c;
3673 GLuint indx = static_cast<GLuint>(c.indx);
3674 GLfloat x = static_cast<GLfloat>(c.x);
3675 GLfloat y = static_cast<GLfloat>(c.y);
3676 GLfloat z = static_cast<GLfloat>(c.z);
3677 DoVertexAttrib3f(indx, x, y, z);
3678 return error::kNoError;
3681 error::Error GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3682 uint32_t immediate_data_size,
3683 const void* cmd_data) {
3684 const gles2::cmds::VertexAttrib3fvImmediate& c =
3685 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate*>(cmd_data);
3686 (void)c;
3687 GLuint indx = static_cast<GLuint>(c.indx);
3688 uint32_t data_size;
3689 if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
3690 return error::kOutOfBounds;
3692 if (data_size > immediate_data_size) {
3693 return error::kOutOfBounds;
3695 const GLfloat* values =
3696 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3697 if (values == NULL) {
3698 return error::kOutOfBounds;
3700 DoVertexAttrib3fv(indx, values);
3701 return error::kNoError;
3704 error::Error GLES2DecoderImpl::HandleVertexAttrib4f(
3705 uint32_t immediate_data_size,
3706 const void* cmd_data) {
3707 const gles2::cmds::VertexAttrib4f& c =
3708 *static_cast<const gles2::cmds::VertexAttrib4f*>(cmd_data);
3709 (void)c;
3710 GLuint indx = static_cast<GLuint>(c.indx);
3711 GLfloat x = static_cast<GLfloat>(c.x);
3712 GLfloat y = static_cast<GLfloat>(c.y);
3713 GLfloat z = static_cast<GLfloat>(c.z);
3714 GLfloat w = static_cast<GLfloat>(c.w);
3715 DoVertexAttrib4f(indx, x, y, z, w);
3716 return error::kNoError;
3719 error::Error GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3720 uint32_t immediate_data_size,
3721 const void* cmd_data) {
3722 const gles2::cmds::VertexAttrib4fvImmediate& c =
3723 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate*>(cmd_data);
3724 (void)c;
3725 GLuint indx = static_cast<GLuint>(c.indx);
3726 uint32_t data_size;
3727 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
3728 return error::kOutOfBounds;
3730 if (data_size > immediate_data_size) {
3731 return error::kOutOfBounds;
3733 const GLfloat* values =
3734 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3735 if (values == NULL) {
3736 return error::kOutOfBounds;
3738 DoVertexAttrib4fv(indx, values);
3739 return error::kNoError;
3742 error::Error GLES2DecoderImpl::HandleVertexAttribI4i(
3743 uint32_t immediate_data_size,
3744 const void* cmd_data) {
3745 if (!unsafe_es3_apis_enabled())
3746 return error::kUnknownCommand;
3747 const gles2::cmds::VertexAttribI4i& c =
3748 *static_cast<const gles2::cmds::VertexAttribI4i*>(cmd_data);
3749 (void)c;
3750 GLuint indx = static_cast<GLuint>(c.indx);
3751 GLint x = static_cast<GLint>(c.x);
3752 GLint y = static_cast<GLint>(c.y);
3753 GLint z = static_cast<GLint>(c.z);
3754 GLint w = static_cast<GLint>(c.w);
3755 glVertexAttribI4i(indx, x, y, z, w);
3756 return error::kNoError;
3759 error::Error GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3760 uint32_t immediate_data_size,
3761 const void* cmd_data) {
3762 if (!unsafe_es3_apis_enabled())
3763 return error::kUnknownCommand;
3764 const gles2::cmds::VertexAttribI4ivImmediate& c =
3765 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate*>(cmd_data);
3766 (void)c;
3767 GLuint indx = static_cast<GLuint>(c.indx);
3768 uint32_t data_size;
3769 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
3770 return error::kOutOfBounds;
3772 if (data_size > immediate_data_size) {
3773 return error::kOutOfBounds;
3775 const GLint* values =
3776 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3777 if (values == NULL) {
3778 return error::kOutOfBounds;
3780 glVertexAttribI4iv(indx, values);
3781 return error::kNoError;
3784 error::Error GLES2DecoderImpl::HandleVertexAttribI4ui(
3785 uint32_t immediate_data_size,
3786 const void* cmd_data) {
3787 if (!unsafe_es3_apis_enabled())
3788 return error::kUnknownCommand;
3789 const gles2::cmds::VertexAttribI4ui& c =
3790 *static_cast<const gles2::cmds::VertexAttribI4ui*>(cmd_data);
3791 (void)c;
3792 GLuint indx = static_cast<GLuint>(c.indx);
3793 GLuint x = static_cast<GLuint>(c.x);
3794 GLuint y = static_cast<GLuint>(c.y);
3795 GLuint z = static_cast<GLuint>(c.z);
3796 GLuint w = static_cast<GLuint>(c.w);
3797 glVertexAttribI4ui(indx, x, y, z, w);
3798 return error::kNoError;
3801 error::Error GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3802 uint32_t immediate_data_size,
3803 const void* cmd_data) {
3804 if (!unsafe_es3_apis_enabled())
3805 return error::kUnknownCommand;
3806 const gles2::cmds::VertexAttribI4uivImmediate& c =
3807 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate*>(cmd_data);
3808 (void)c;
3809 GLuint indx = static_cast<GLuint>(c.indx);
3810 uint32_t data_size;
3811 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
3812 return error::kOutOfBounds;
3814 if (data_size > immediate_data_size) {
3815 return error::kOutOfBounds;
3817 const GLuint* values =
3818 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3819 if (values == NULL) {
3820 return error::kOutOfBounds;
3822 glVertexAttribI4uiv(indx, values);
3823 return error::kNoError;
3826 error::Error GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size,
3827 const void* cmd_data) {
3828 const gles2::cmds::Viewport& c =
3829 *static_cast<const gles2::cmds::Viewport*>(cmd_data);
3830 (void)c;
3831 GLint x = static_cast<GLint>(c.x);
3832 GLint y = static_cast<GLint>(c.y);
3833 GLsizei width = static_cast<GLsizei>(c.width);
3834 GLsizei height = static_cast<GLsizei>(c.height);
3835 if (width < 0) {
3836 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "width < 0");
3837 return error::kNoError;
3839 if (height < 0) {
3840 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "height < 0");
3841 return error::kNoError;
3843 DoViewport(x, y, width, height);
3844 return error::kNoError;
3847 error::Error GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
3848 uint32_t immediate_data_size,
3849 const void* cmd_data) {
3850 const gles2::cmds::BlitFramebufferCHROMIUM& c =
3851 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM*>(cmd_data);
3852 (void)c;
3853 if (!features().chromium_framebuffer_multisample) {
3854 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlitFramebufferCHROMIUM",
3855 "function not available");
3856 return error::kNoError;
3859 error::Error error;
3860 error = WillAccessBoundFramebufferForDraw();
3861 if (error != error::kNoError)
3862 return error;
3863 error = WillAccessBoundFramebufferForRead();
3864 if (error != error::kNoError)
3865 return error;
3866 GLint srcX0 = static_cast<GLint>(c.srcX0);
3867 GLint srcY0 = static_cast<GLint>(c.srcY0);
3868 GLint srcX1 = static_cast<GLint>(c.srcX1);
3869 GLint srcY1 = static_cast<GLint>(c.srcY1);
3870 GLint dstX0 = static_cast<GLint>(c.dstX0);
3871 GLint dstY0 = static_cast<GLint>(c.dstY0);
3872 GLint dstX1 = static_cast<GLint>(c.dstX1);
3873 GLint dstY1 = static_cast<GLint>(c.dstY1);
3874 GLbitfield mask = static_cast<GLbitfield>(c.mask);
3875 GLenum filter = static_cast<GLenum>(c.filter);
3876 if (!validators_->blit_filter.IsValid(filter)) {
3877 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter,
3878 "filter");
3879 return error::kNoError;
3881 DoBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
3882 dstY1, mask, filter);
3883 return error::kNoError;
3886 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
3887 uint32_t immediate_data_size,
3888 const void* cmd_data) {
3889 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM& c =
3890 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM*>(
3891 cmd_data);
3892 (void)c;
3893 if (!features().chromium_framebuffer_multisample) {
3894 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3895 "glRenderbufferStorageMultisampleCHROMIUM",
3896 "function not available");
3897 return error::kNoError;
3900 GLenum target = static_cast<GLenum>(c.target);
3901 GLsizei samples = static_cast<GLsizei>(c.samples);
3902 GLenum internalformat = static_cast<GLenum>(c.internalformat);
3903 GLsizei width = static_cast<GLsizei>(c.width);
3904 GLsizei height = static_cast<GLsizei>(c.height);
3905 if (!validators_->render_buffer_target.IsValid(target)) {
3906 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
3907 target, "target");
3908 return error::kNoError;
3910 if (samples < 0) {
3911 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
3912 "glRenderbufferStorageMultisampleCHROMIUM",
3913 "samples < 0");
3914 return error::kNoError;
3916 if (!validators_->render_buffer_format.IsValid(internalformat)) {
3917 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
3918 internalformat, "internalformat");
3919 return error::kNoError;
3921 if (width < 0) {
3922 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
3923 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
3924 return error::kNoError;
3926 if (height < 0) {
3927 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
3928 "glRenderbufferStorageMultisampleCHROMIUM",
3929 "height < 0");
3930 return error::kNoError;
3932 DoRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
3933 width, height);
3934 return error::kNoError;
3937 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
3938 uint32_t immediate_data_size,
3939 const void* cmd_data) {
3940 const gles2::cmds::RenderbufferStorageMultisampleEXT& c =
3941 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT*>(
3942 cmd_data);
3943 (void)c;
3944 if (!features().multisampled_render_to_texture) {
3945 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3946 "glRenderbufferStorageMultisampleEXT",
3947 "function not available");
3948 return error::kNoError;
3951 GLenum target = static_cast<GLenum>(c.target);
3952 GLsizei samples = static_cast<GLsizei>(c.samples);
3953 GLenum internalformat = static_cast<GLenum>(c.internalformat);
3954 GLsizei width = static_cast<GLsizei>(c.width);
3955 GLsizei height = static_cast<GLsizei>(c.height);
3956 if (!validators_->render_buffer_target.IsValid(target)) {
3957 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
3958 target, "target");
3959 return error::kNoError;
3961 if (samples < 0) {
3962 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
3963 "samples < 0");
3964 return error::kNoError;
3966 if (!validators_->render_buffer_format.IsValid(internalformat)) {
3967 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
3968 internalformat, "internalformat");
3969 return error::kNoError;
3971 if (width < 0) {
3972 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
3973 "width < 0");
3974 return error::kNoError;
3976 if (height < 0) {
3977 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
3978 "height < 0");
3979 return error::kNoError;
3981 DoRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
3982 height);
3983 return error::kNoError;
3986 error::Error GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
3987 uint32_t immediate_data_size,
3988 const void* cmd_data) {
3989 const gles2::cmds::FramebufferTexture2DMultisampleEXT& c =
3990 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT*>(
3991 cmd_data);
3992 (void)c;
3993 if (!features().multisampled_render_to_texture) {
3994 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
3995 "glFramebufferTexture2DMultisampleEXT",
3996 "function not available");
3997 return error::kNoError;
4000 GLenum target = static_cast<GLenum>(c.target);
4001 GLenum attachment = static_cast<GLenum>(c.attachment);
4002 GLenum textarget = static_cast<GLenum>(c.textarget);
4003 GLuint texture = c.texture;
4004 GLint level = static_cast<GLint>(c.level);
4005 GLsizei samples = static_cast<GLsizei>(c.samples);
4006 if (!validators_->frame_buffer_target.IsValid(target)) {
4007 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4008 target, "target");
4009 return error::kNoError;
4011 if (!validators_->attachment.IsValid(attachment)) {
4012 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4013 attachment, "attachment");
4014 return error::kNoError;
4016 if (!validators_->texture_target.IsValid(textarget)) {
4017 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4018 textarget, "textarget");
4019 return error::kNoError;
4021 if (samples < 0) {
4022 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glFramebufferTexture2DMultisampleEXT",
4023 "samples < 0");
4024 return error::kNoError;
4026 DoFramebufferTexture2DMultisample(target, attachment, textarget, texture,
4027 level, samples);
4028 return error::kNoError;
4031 error::Error GLES2DecoderImpl::HandleTexStorage2DEXT(
4032 uint32_t immediate_data_size,
4033 const void* cmd_data) {
4034 const gles2::cmds::TexStorage2DEXT& c =
4035 *static_cast<const gles2::cmds::TexStorage2DEXT*>(cmd_data);
4036 (void)c;
4037 GLenum target = static_cast<GLenum>(c.target);
4038 GLsizei levels = static_cast<GLsizei>(c.levels);
4039 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
4040 GLsizei width = static_cast<GLsizei>(c.width);
4041 GLsizei height = static_cast<GLsizei>(c.height);
4042 if (!validators_->texture_target.IsValid(target)) {
4043 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target, "target");
4044 return error::kNoError;
4046 if (levels < 0) {
4047 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
4048 return error::kNoError;
4050 if (!validators_->texture_internal_format_storage.IsValid(internalFormat)) {
4051 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat,
4052 "internalFormat");
4053 return error::kNoError;
4055 if (width < 0) {
4056 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
4057 return error::kNoError;
4059 if (height < 0) {
4060 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
4061 return error::kNoError;
4063 DoTexStorage2DEXT(target, levels, internalFormat, width, height);
4064 return error::kNoError;
4067 error::Error GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4068 uint32_t immediate_data_size,
4069 const void* cmd_data) {
4070 const gles2::cmds::GenQueriesEXTImmediate& c =
4071 *static_cast<const gles2::cmds::GenQueriesEXTImmediate*>(cmd_data);
4072 (void)c;
4073 GLsizei n = static_cast<GLsizei>(c.n);
4074 uint32_t data_size;
4075 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4076 return error::kOutOfBounds;
4078 GLuint* queries =
4079 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4080 if (queries == NULL) {
4081 return error::kOutOfBounds;
4083 if (!GenQueriesEXTHelper(n, queries)) {
4084 return error::kInvalidArguments;
4086 return error::kNoError;
4089 error::Error GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4090 uint32_t immediate_data_size,
4091 const void* cmd_data) {
4092 const gles2::cmds::DeleteQueriesEXTImmediate& c =
4093 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate*>(cmd_data);
4094 (void)c;
4095 GLsizei n = static_cast<GLsizei>(c.n);
4096 uint32_t data_size;
4097 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4098 return error::kOutOfBounds;
4100 const GLuint* queries =
4101 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4102 if (queries == NULL) {
4103 return error::kOutOfBounds;
4105 DeleteQueriesEXTHelper(n, queries);
4106 return error::kNoError;
4109 error::Error GLES2DecoderImpl::HandleBeginTransformFeedback(
4110 uint32_t immediate_data_size,
4111 const void* cmd_data) {
4112 if (!unsafe_es3_apis_enabled())
4113 return error::kUnknownCommand;
4114 const gles2::cmds::BeginTransformFeedback& c =
4115 *static_cast<const gles2::cmds::BeginTransformFeedback*>(cmd_data);
4116 (void)c;
4117 GLenum primitivemode = static_cast<GLenum>(c.primitivemode);
4118 glBeginTransformFeedback(primitivemode);
4119 return error::kNoError;
4122 error::Error GLES2DecoderImpl::HandleEndTransformFeedback(
4123 uint32_t immediate_data_size,
4124 const void* cmd_data) {
4125 if (!unsafe_es3_apis_enabled())
4126 return error::kUnknownCommand;
4127 const gles2::cmds::EndTransformFeedback& c =
4128 *static_cast<const gles2::cmds::EndTransformFeedback*>(cmd_data);
4129 (void)c;
4130 glEndTransformFeedback();
4131 return error::kNoError;
4134 error::Error GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4135 uint32_t immediate_data_size,
4136 const void* cmd_data) {
4137 const gles2::cmds::InsertEventMarkerEXT& c =
4138 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data);
4139 (void)c;
4141 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4142 Bucket* bucket = GetBucket(bucket_id);
4143 if (!bucket || bucket->size() == 0) {
4144 return error::kInvalidArguments;
4146 std::string str;
4147 if (!bucket->GetAsString(&str)) {
4148 return error::kInvalidArguments;
4150 DoInsertEventMarkerEXT(0, str.c_str());
4151 return error::kNoError;
4154 error::Error GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4155 uint32_t immediate_data_size,
4156 const void* cmd_data) {
4157 const gles2::cmds::PushGroupMarkerEXT& c =
4158 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data);
4159 (void)c;
4161 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4162 Bucket* bucket = GetBucket(bucket_id);
4163 if (!bucket || bucket->size() == 0) {
4164 return error::kInvalidArguments;
4166 std::string str;
4167 if (!bucket->GetAsString(&str)) {
4168 return error::kInvalidArguments;
4170 DoPushGroupMarkerEXT(0, str.c_str());
4171 return error::kNoError;
4174 error::Error GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4175 uint32_t immediate_data_size,
4176 const void* cmd_data) {
4177 const gles2::cmds::PopGroupMarkerEXT& c =
4178 *static_cast<const gles2::cmds::PopGroupMarkerEXT*>(cmd_data);
4179 (void)c;
4180 DoPopGroupMarkerEXT();
4181 return error::kNoError;
4184 error::Error GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4185 uint32_t immediate_data_size,
4186 const void* cmd_data) {
4187 const gles2::cmds::GenVertexArraysOESImmediate& c =
4188 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate*>(cmd_data);
4189 (void)c;
4190 GLsizei n = static_cast<GLsizei>(c.n);
4191 uint32_t data_size;
4192 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4193 return error::kOutOfBounds;
4195 GLuint* arrays =
4196 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4197 if (arrays == NULL) {
4198 return error::kOutOfBounds;
4200 if (!GenVertexArraysOESHelper(n, arrays)) {
4201 return error::kInvalidArguments;
4203 return error::kNoError;
4206 error::Error GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4207 uint32_t immediate_data_size,
4208 const void* cmd_data) {
4209 const gles2::cmds::DeleteVertexArraysOESImmediate& c =
4210 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate*>(
4211 cmd_data);
4212 (void)c;
4213 GLsizei n = static_cast<GLsizei>(c.n);
4214 uint32_t data_size;
4215 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4216 return error::kOutOfBounds;
4218 const GLuint* arrays =
4219 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4220 if (arrays == NULL) {
4221 return error::kOutOfBounds;
4223 DeleteVertexArraysOESHelper(n, arrays);
4224 return error::kNoError;
4227 error::Error GLES2DecoderImpl::HandleIsVertexArrayOES(
4228 uint32_t immediate_data_size,
4229 const void* cmd_data) {
4230 const gles2::cmds::IsVertexArrayOES& c =
4231 *static_cast<const gles2::cmds::IsVertexArrayOES*>(cmd_data);
4232 (void)c;
4233 GLuint array = c.array;
4234 typedef cmds::IsVertexArrayOES::Result Result;
4235 Result* result_dst = GetSharedMemoryAs<Result*>(
4236 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4237 if (!result_dst) {
4238 return error::kOutOfBounds;
4240 *result_dst = DoIsVertexArrayOES(array);
4241 return error::kNoError;
4244 error::Error GLES2DecoderImpl::HandleBindVertexArrayOES(
4245 uint32_t immediate_data_size,
4246 const void* cmd_data) {
4247 const gles2::cmds::BindVertexArrayOES& c =
4248 *static_cast<const gles2::cmds::BindVertexArrayOES*>(cmd_data);
4249 (void)c;
4250 GLuint array = c.array;
4251 DoBindVertexArrayOES(array);
4252 return error::kNoError;
4255 error::Error GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size,
4256 const void* cmd_data) {
4257 const gles2::cmds::SwapBuffers& c =
4258 *static_cast<const gles2::cmds::SwapBuffers*>(cmd_data);
4259 (void)c;
4260 DoSwapBuffers();
4261 return error::kNoError;
4264 error::Error GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4265 uint32_t immediate_data_size,
4266 const void* cmd_data) {
4267 const gles2::cmds::GetMaxValueInBufferCHROMIUM& c =
4268 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM*>(cmd_data);
4269 (void)c;
4270 GLuint buffer_id = c.buffer_id;
4271 GLsizei count = static_cast<GLsizei>(c.count);
4272 GLenum type = static_cast<GLenum>(c.type);
4273 GLuint offset = static_cast<GLuint>(c.offset);
4274 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result;
4275 Result* result_dst = GetSharedMemoryAs<Result*>(
4276 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4277 if (!result_dst) {
4278 return error::kOutOfBounds;
4280 if (count < 0) {
4281 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetMaxValueInBufferCHROMIUM",
4282 "count < 0");
4283 return error::kNoError;
4285 if (!validators_->get_max_index_type.IsValid(type)) {
4286 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type,
4287 "type");
4288 return error::kNoError;
4290 *result_dst = DoGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
4291 return error::kNoError;
4294 error::Error GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4295 uint32_t immediate_data_size,
4296 const void* cmd_data) {
4297 const gles2::cmds::TexImageIOSurface2DCHROMIUM& c =
4298 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM*>(cmd_data);
4299 (void)c;
4300 GLenum target = static_cast<GLenum>(c.target);
4301 GLsizei width = static_cast<GLsizei>(c.width);
4302 GLsizei height = static_cast<GLsizei>(c.height);
4303 GLuint ioSurfaceId = static_cast<GLuint>(c.ioSurfaceId);
4304 GLuint plane = static_cast<GLuint>(c.plane);
4305 if (!validators_->texture_bind_target.IsValid(target)) {
4306 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target,
4307 "target");
4308 return error::kNoError;
4310 if (width < 0) {
4311 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4312 "width < 0");
4313 return error::kNoError;
4315 if (height < 0) {
4316 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4317 "height < 0");
4318 return error::kNoError;
4320 DoTexImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
4321 return error::kNoError;
4324 error::Error GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4325 uint32_t immediate_data_size,
4326 const void* cmd_data) {
4327 const gles2::cmds::CopyTextureCHROMIUM& c =
4328 *static_cast<const gles2::cmds::CopyTextureCHROMIUM*>(cmd_data);
4329 (void)c;
4330 GLenum target = static_cast<GLenum>(c.target);
4331 GLenum source_id = static_cast<GLenum>(c.source_id);
4332 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4333 GLint internalformat = static_cast<GLint>(c.internalformat);
4334 GLenum dest_type = static_cast<GLenum>(c.dest_type);
4335 if (!validators_->texture_internal_format.IsValid(internalformat)) {
4336 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM",
4337 "internalformat GL_INVALID_VALUE");
4338 return error::kNoError;
4340 if (!validators_->pixel_type.IsValid(dest_type)) {
4341 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type,
4342 "dest_type");
4343 return error::kNoError;
4345 DoCopyTextureCHROMIUM(target, source_id, dest_id, internalformat, dest_type);
4346 return error::kNoError;
4349 error::Error GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4350 uint32_t immediate_data_size,
4351 const void* cmd_data) {
4352 const gles2::cmds::CopySubTextureCHROMIUM& c =
4353 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM*>(cmd_data);
4354 (void)c;
4355 GLenum target = static_cast<GLenum>(c.target);
4356 GLenum source_id = static_cast<GLenum>(c.source_id);
4357 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4358 GLint xoffset = static_cast<GLint>(c.xoffset);
4359 GLint yoffset = static_cast<GLint>(c.yoffset);
4360 DoCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset, yoffset);
4361 return error::kNoError;
4364 error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4365 uint32_t immediate_data_size,
4366 const void* cmd_data) {
4367 const gles2::cmds::ProduceTextureCHROMIUMImmediate& c =
4368 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate*>(
4369 cmd_data);
4370 (void)c;
4371 GLenum target = static_cast<GLenum>(c.target);
4372 uint32_t data_size;
4373 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4374 return error::kOutOfBounds;
4376 if (data_size > immediate_data_size) {
4377 return error::kOutOfBounds;
4379 const GLbyte* mailbox =
4380 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4381 if (!validators_->texture_bind_target.IsValid(target)) {
4382 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target,
4383 "target");
4384 return error::kNoError;
4386 if (mailbox == NULL) {
4387 return error::kOutOfBounds;
4389 DoProduceTextureCHROMIUM(target, mailbox);
4390 return error::kNoError;
4393 error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4394 uint32_t immediate_data_size,
4395 const void* cmd_data) {
4396 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c =
4397 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>(
4398 cmd_data);
4399 (void)c;
4400 GLuint texture = c.texture;
4401 GLenum target = static_cast<GLenum>(c.target);
4402 uint32_t data_size;
4403 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4404 return error::kOutOfBounds;
4406 if (data_size > immediate_data_size) {
4407 return error::kOutOfBounds;
4409 const GLbyte* mailbox =
4410 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4411 if (!validators_->texture_bind_target.IsValid(target)) {
4412 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target,
4413 "target");
4414 return error::kNoError;
4416 if (mailbox == NULL) {
4417 return error::kOutOfBounds;
4419 DoProduceTextureDirectCHROMIUM(texture, target, mailbox);
4420 return error::kNoError;
4423 error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4424 uint32_t immediate_data_size,
4425 const void* cmd_data) {
4426 const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c =
4427 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate*>(
4428 cmd_data);
4429 (void)c;
4430 GLenum target = static_cast<GLenum>(c.target);
4431 uint32_t data_size;
4432 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4433 return error::kOutOfBounds;
4435 if (data_size > immediate_data_size) {
4436 return error::kOutOfBounds;
4438 const GLbyte* mailbox =
4439 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4440 if (!validators_->texture_bind_target.IsValid(target)) {
4441 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target,
4442 "target");
4443 return error::kNoError;
4445 if (mailbox == NULL) {
4446 return error::kOutOfBounds;
4448 DoConsumeTextureCHROMIUM(target, mailbox);
4449 return error::kNoError;
4452 error::Error GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4453 uint32_t immediate_data_size,
4454 const void* cmd_data) {
4455 const gles2::cmds::GenValuebuffersCHROMIUMImmediate& c =
4456 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate*>(
4457 cmd_data);
4458 (void)c;
4459 GLsizei n = static_cast<GLsizei>(c.n);
4460 uint32_t data_size;
4461 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4462 return error::kOutOfBounds;
4464 GLuint* buffers =
4465 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4466 if (buffers == NULL) {
4467 return error::kOutOfBounds;
4469 if (!GenValuebuffersCHROMIUMHelper(n, buffers)) {
4470 return error::kInvalidArguments;
4472 return error::kNoError;
4475 error::Error GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4476 uint32_t immediate_data_size,
4477 const void* cmd_data) {
4478 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate& c =
4479 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate*>(
4480 cmd_data);
4481 (void)c;
4482 GLsizei n = static_cast<GLsizei>(c.n);
4483 uint32_t data_size;
4484 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4485 return error::kOutOfBounds;
4487 const GLuint* valuebuffers =
4488 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4489 if (valuebuffers == NULL) {
4490 return error::kOutOfBounds;
4492 DeleteValuebuffersCHROMIUMHelper(n, valuebuffers);
4493 return error::kNoError;
4496 error::Error GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4497 uint32_t immediate_data_size,
4498 const void* cmd_data) {
4499 const gles2::cmds::IsValuebufferCHROMIUM& c =
4500 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM*>(cmd_data);
4501 (void)c;
4502 GLuint valuebuffer = c.valuebuffer;
4503 typedef cmds::IsValuebufferCHROMIUM::Result Result;
4504 Result* result_dst = GetSharedMemoryAs<Result*>(
4505 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4506 if (!result_dst) {
4507 return error::kOutOfBounds;
4509 *result_dst = DoIsValuebufferCHROMIUM(valuebuffer);
4510 return error::kNoError;
4513 error::Error GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4514 uint32_t immediate_data_size,
4515 const void* cmd_data) {
4516 const gles2::cmds::BindValuebufferCHROMIUM& c =
4517 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM*>(cmd_data);
4518 (void)c;
4519 GLenum target = static_cast<GLenum>(c.target);
4520 GLuint valuebuffer = c.valuebuffer;
4521 if (!validators_->value_buffer_target.IsValid(target)) {
4522 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target,
4523 "target");
4524 return error::kNoError;
4526 DoBindValueBufferCHROMIUM(target, valuebuffer);
4527 return error::kNoError;
4530 error::Error GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4531 uint32_t immediate_data_size,
4532 const void* cmd_data) {
4533 const gles2::cmds::SubscribeValueCHROMIUM& c =
4534 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM*>(cmd_data);
4535 (void)c;
4536 GLenum target = static_cast<GLenum>(c.target);
4537 GLenum subscription = static_cast<GLenum>(c.subscription);
4538 if (!validators_->value_buffer_target.IsValid(target)) {
4539 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target,
4540 "target");
4541 return error::kNoError;
4543 if (!validators_->subscription_target.IsValid(subscription)) {
4544 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription,
4545 "subscription");
4546 return error::kNoError;
4548 DoSubscribeValueCHROMIUM(target, subscription);
4549 return error::kNoError;
4552 error::Error GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4553 uint32_t immediate_data_size,
4554 const void* cmd_data) {
4555 const gles2::cmds::PopulateSubscribedValuesCHROMIUM& c =
4556 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM*>(
4557 cmd_data);
4558 (void)c;
4559 GLenum target = static_cast<GLenum>(c.target);
4560 if (!validators_->value_buffer_target.IsValid(target)) {
4561 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4562 target, "target");
4563 return error::kNoError;
4565 DoPopulateSubscribedValuesCHROMIUM(target);
4566 return error::kNoError;
4569 error::Error GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4570 uint32_t immediate_data_size,
4571 const void* cmd_data) {
4572 const gles2::cmds::UniformValuebufferCHROMIUM& c =
4573 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM*>(cmd_data);
4574 (void)c;
4575 GLint location = static_cast<GLint>(c.location);
4576 GLenum target = static_cast<GLenum>(c.target);
4577 GLenum subscription = static_cast<GLenum>(c.subscription);
4578 if (!validators_->value_buffer_target.IsValid(target)) {
4579 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target,
4580 "target");
4581 return error::kNoError;
4583 if (!validators_->subscription_target.IsValid(subscription)) {
4584 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4585 subscription, "subscription");
4586 return error::kNoError;
4588 DoUniformValueBufferCHROMIUM(location, target, subscription);
4589 return error::kNoError;
4592 error::Error GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4593 uint32_t immediate_data_size,
4594 const void* cmd_data) {
4595 const gles2::cmds::BindTexImage2DCHROMIUM& c =
4596 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM*>(cmd_data);
4597 (void)c;
4598 GLenum target = static_cast<GLenum>(c.target);
4599 GLint imageId = static_cast<GLint>(c.imageId);
4600 if (!validators_->texture_bind_target.IsValid(target)) {
4601 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target,
4602 "target");
4603 return error::kNoError;
4605 DoBindTexImage2DCHROMIUM(target, imageId);
4606 return error::kNoError;
4609 error::Error GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4610 uint32_t immediate_data_size,
4611 const void* cmd_data) {
4612 const gles2::cmds::ReleaseTexImage2DCHROMIUM& c =
4613 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM*>(cmd_data);
4614 (void)c;
4615 GLenum target = static_cast<GLenum>(c.target);
4616 GLint imageId = static_cast<GLint>(c.imageId);
4617 if (!validators_->texture_bind_target.IsValid(target)) {
4618 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target,
4619 "target");
4620 return error::kNoError;
4622 DoReleaseTexImage2DCHROMIUM(target, imageId);
4623 return error::kNoError;
4626 error::Error GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4627 uint32_t immediate_data_size,
4628 const void* cmd_data) {
4629 const gles2::cmds::TraceEndCHROMIUM& c =
4630 *static_cast<const gles2::cmds::TraceEndCHROMIUM*>(cmd_data);
4631 (void)c;
4632 DoTraceEndCHROMIUM();
4633 return error::kNoError;
4636 error::Error GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4637 uint32_t immediate_data_size,
4638 const void* cmd_data) {
4639 const gles2::cmds::DiscardFramebufferEXTImmediate& c =
4640 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate*>(
4641 cmd_data);
4642 (void)c;
4643 if (!features().ext_discard_framebuffer) {
4644 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDiscardFramebufferEXT",
4645 "function not available");
4646 return error::kNoError;
4649 GLenum target = static_cast<GLenum>(c.target);
4650 GLsizei count = static_cast<GLsizei>(c.count);
4651 uint32_t data_size;
4652 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4653 return error::kOutOfBounds;
4655 if (data_size > immediate_data_size) {
4656 return error::kOutOfBounds;
4658 const GLenum* attachments =
4659 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4660 if (count < 0) {
4661 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDiscardFramebufferEXT",
4662 "count < 0");
4663 return error::kNoError;
4665 if (attachments == NULL) {
4666 return error::kOutOfBounds;
4668 DoDiscardFramebufferEXT(target, count, attachments);
4669 return error::kNoError;
4672 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4673 uint32_t immediate_data_size,
4674 const void* cmd_data) {
4675 const gles2::cmds::LoseContextCHROMIUM& c =
4676 *static_cast<const gles2::cmds::LoseContextCHROMIUM*>(cmd_data);
4677 (void)c;
4678 GLenum current = static_cast<GLenum>(c.current);
4679 GLenum other = static_cast<GLenum>(c.other);
4680 if (!validators_->reset_status.IsValid(current)) {
4681 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
4682 "current");
4683 return error::kNoError;
4685 if (!validators_->reset_status.IsValid(other)) {
4686 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
4687 return error::kNoError;
4689 DoLoseContextCHROMIUM(current, other);
4690 return error::kNoError;
4693 error::Error GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4694 uint32_t immediate_data_size,
4695 const void* cmd_data) {
4696 const gles2::cmds::DrawBuffersEXTImmediate& c =
4697 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate*>(cmd_data);
4698 (void)c;
4699 GLsizei count = static_cast<GLsizei>(c.count);
4700 uint32_t data_size;
4701 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4702 return error::kOutOfBounds;
4704 if (data_size > immediate_data_size) {
4705 return error::kOutOfBounds;
4707 const GLenum* bufs =
4708 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4709 if (count < 0) {
4710 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
4711 return error::kNoError;
4713 if (bufs == NULL) {
4714 return error::kOutOfBounds;
4716 DoDrawBuffersEXT(count, bufs);
4717 return error::kNoError;
4720 error::Error GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size,
4721 const void* cmd_data) {
4722 const gles2::cmds::SwapInterval& c =
4723 *static_cast<const gles2::cmds::SwapInterval*>(cmd_data);
4724 (void)c;
4725 GLint interval = static_cast<GLint>(c.interval);
4726 DoSwapInterval(interval);
4727 return error::kNoError;
4730 error::Error GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4731 uint32_t immediate_data_size,
4732 const void* cmd_data) {
4733 const gles2::cmds::MatrixLoadfCHROMIUMImmediate& c =
4734 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate*>(cmd_data);
4735 (void)c;
4736 if (!features().chromium_path_rendering) {
4737 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadfCHROMIUM",
4738 "function not available");
4739 return error::kNoError;
4742 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4743 uint32_t data_size;
4744 if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
4745 return error::kOutOfBounds;
4747 if (data_size > immediate_data_size) {
4748 return error::kOutOfBounds;
4750 const GLfloat* m =
4751 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
4752 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4753 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode,
4754 "matrixMode");
4755 return error::kNoError;
4757 if (m == NULL) {
4758 return error::kOutOfBounds;
4760 DoMatrixLoadfCHROMIUM(matrixMode, m);
4761 return error::kNoError;
4764 error::Error GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
4765 uint32_t immediate_data_size,
4766 const void* cmd_data) {
4767 const gles2::cmds::MatrixLoadIdentityCHROMIUM& c =
4768 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM*>(cmd_data);
4769 (void)c;
4770 if (!features().chromium_path_rendering) {
4771 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadIdentityCHROMIUM",
4772 "function not available");
4773 return error::kNoError;
4776 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4777 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4778 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode,
4779 "matrixMode");
4780 return error::kNoError;
4782 DoMatrixLoadIdentityCHROMIUM(matrixMode);
4783 return error::kNoError;
4786 error::Error GLES2DecoderImpl::HandleBlendBarrierKHR(
4787 uint32_t immediate_data_size,
4788 const void* cmd_data) {
4789 const gles2::cmds::BlendBarrierKHR& c =
4790 *static_cast<const gles2::cmds::BlendBarrierKHR*>(cmd_data);
4791 (void)c;
4792 if (!features().blend_equation_advanced) {
4793 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlendBarrierKHR",
4794 "function not available");
4795 return error::kNoError;
4798 glBlendBarrierKHR();
4799 return error::kNoError;
4802 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
4803 switch (cap) {
4804 case GL_BLEND:
4805 state_.enable_flags.blend = enabled;
4806 if (state_.enable_flags.cached_blend != enabled ||
4807 state_.ignore_cached_state) {
4808 state_.enable_flags.cached_blend = enabled;
4809 return true;
4811 return false;
4812 case GL_CULL_FACE:
4813 state_.enable_flags.cull_face = enabled;
4814 if (state_.enable_flags.cached_cull_face != enabled ||
4815 state_.ignore_cached_state) {
4816 state_.enable_flags.cached_cull_face = enabled;
4817 return true;
4819 return false;
4820 case GL_DEPTH_TEST:
4821 state_.enable_flags.depth_test = enabled;
4822 if (state_.enable_flags.cached_depth_test != enabled ||
4823 state_.ignore_cached_state) {
4824 framebuffer_state_.clear_state_dirty = true;
4826 return false;
4827 case GL_DITHER:
4828 state_.enable_flags.dither = enabled;
4829 if (state_.enable_flags.cached_dither != enabled ||
4830 state_.ignore_cached_state) {
4831 state_.enable_flags.cached_dither = enabled;
4832 return true;
4834 return false;
4835 case GL_POLYGON_OFFSET_FILL:
4836 state_.enable_flags.polygon_offset_fill = enabled;
4837 if (state_.enable_flags.cached_polygon_offset_fill != enabled ||
4838 state_.ignore_cached_state) {
4839 state_.enable_flags.cached_polygon_offset_fill = enabled;
4840 return true;
4842 return false;
4843 case GL_SAMPLE_ALPHA_TO_COVERAGE:
4844 state_.enable_flags.sample_alpha_to_coverage = enabled;
4845 if (state_.enable_flags.cached_sample_alpha_to_coverage != enabled ||
4846 state_.ignore_cached_state) {
4847 state_.enable_flags.cached_sample_alpha_to_coverage = enabled;
4848 return true;
4850 return false;
4851 case GL_SAMPLE_COVERAGE:
4852 state_.enable_flags.sample_coverage = enabled;
4853 if (state_.enable_flags.cached_sample_coverage != enabled ||
4854 state_.ignore_cached_state) {
4855 state_.enable_flags.cached_sample_coverage = enabled;
4856 return true;
4858 return false;
4859 case GL_SCISSOR_TEST:
4860 state_.enable_flags.scissor_test = enabled;
4861 if (state_.enable_flags.cached_scissor_test != enabled ||
4862 state_.ignore_cached_state) {
4863 state_.enable_flags.cached_scissor_test = enabled;
4864 return true;
4866 return false;
4867 case GL_STENCIL_TEST:
4868 state_.enable_flags.stencil_test = enabled;
4869 if (state_.enable_flags.cached_stencil_test != enabled ||
4870 state_.ignore_cached_state) {
4871 framebuffer_state_.clear_state_dirty = true;
4873 return false;
4874 case GL_RASTERIZER_DISCARD:
4875 state_.enable_flags.rasterizer_discard = enabled;
4876 if (state_.enable_flags.cached_rasterizer_discard != enabled ||
4877 state_.ignore_cached_state) {
4878 state_.enable_flags.cached_rasterizer_discard = enabled;
4879 return true;
4881 return false;
4882 default:
4883 NOTREACHED();
4884 return false;
4887 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_