Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_autogen.h
blob86c3c6720a58b51e9d1889e9bba85decc21831b7
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 (sampler == 0) {
145 glBindSampler(unit, sampler);
146 return error::kNoError;
148 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
149 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindSampler",
150 "invalid sampler id");
151 return error::kNoError;
153 glBindSampler(unit, sampler);
154 return error::kNoError;
157 error::Error GLES2DecoderImpl::HandleBindTexture(uint32_t immediate_data_size,
158 const void* cmd_data) {
159 const gles2::cmds::BindTexture& c =
160 *static_cast<const gles2::cmds::BindTexture*>(cmd_data);
161 (void)c;
162 GLenum target = static_cast<GLenum>(c.target);
163 GLuint texture = c.texture;
164 if (!validators_->texture_bind_target.IsValid(target)) {
165 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target, "target");
166 return error::kNoError;
168 DoBindTexture(target, texture);
169 return error::kNoError;
172 error::Error GLES2DecoderImpl::HandleBindTransformFeedback(
173 uint32_t immediate_data_size,
174 const void* cmd_data) {
175 if (!unsafe_es3_apis_enabled())
176 return error::kUnknownCommand;
177 const gles2::cmds::BindTransformFeedback& c =
178 *static_cast<const gles2::cmds::BindTransformFeedback*>(cmd_data);
179 (void)c;
180 GLenum target = static_cast<GLenum>(c.target);
181 GLuint transformfeedback = c.transformfeedback;
182 if (!group_->GetTransformFeedbackServiceId(transformfeedback,
183 &transformfeedback)) {
184 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTransformFeedback",
185 "invalid transformfeedback id");
186 return error::kNoError;
188 glBindTransformFeedback(target, transformfeedback);
189 return error::kNoError;
192 error::Error GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size,
193 const void* cmd_data) {
194 const gles2::cmds::BlendColor& c =
195 *static_cast<const gles2::cmds::BlendColor*>(cmd_data);
196 (void)c;
197 GLclampf red = static_cast<GLclampf>(c.red);
198 GLclampf green = static_cast<GLclampf>(c.green);
199 GLclampf blue = static_cast<GLclampf>(c.blue);
200 GLclampf alpha = static_cast<GLclampf>(c.alpha);
201 if (state_.blend_color_red != red || state_.blend_color_green != green ||
202 state_.blend_color_blue != blue || state_.blend_color_alpha != alpha) {
203 state_.blend_color_red = red;
204 state_.blend_color_green = green;
205 state_.blend_color_blue = blue;
206 state_.blend_color_alpha = alpha;
207 glBlendColor(red, green, blue, alpha);
209 return error::kNoError;
212 error::Error GLES2DecoderImpl::HandleBlendEquation(uint32_t immediate_data_size,
213 const void* cmd_data) {
214 const gles2::cmds::BlendEquation& c =
215 *static_cast<const gles2::cmds::BlendEquation*>(cmd_data);
216 (void)c;
217 GLenum mode = static_cast<GLenum>(c.mode);
218 if (!validators_->equation.IsValid(mode)) {
219 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode, "mode");
220 return error::kNoError;
222 if (state_.blend_equation_rgb != mode ||
223 state_.blend_equation_alpha != mode) {
224 state_.blend_equation_rgb = mode;
225 state_.blend_equation_alpha = mode;
226 glBlendEquation(mode);
228 return error::kNoError;
231 error::Error GLES2DecoderImpl::HandleBlendEquationSeparate(
232 uint32_t immediate_data_size,
233 const void* cmd_data) {
234 const gles2::cmds::BlendEquationSeparate& c =
235 *static_cast<const gles2::cmds::BlendEquationSeparate*>(cmd_data);
236 (void)c;
237 GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
238 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
239 if (!validators_->equation.IsValid(modeRGB)) {
240 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB,
241 "modeRGB");
242 return error::kNoError;
244 if (!validators_->equation.IsValid(modeAlpha)) {
245 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha,
246 "modeAlpha");
247 return error::kNoError;
249 if (state_.blend_equation_rgb != modeRGB ||
250 state_.blend_equation_alpha != modeAlpha) {
251 state_.blend_equation_rgb = modeRGB;
252 state_.blend_equation_alpha = modeAlpha;
253 glBlendEquationSeparate(modeRGB, modeAlpha);
255 return error::kNoError;
258 error::Error GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size,
259 const void* cmd_data) {
260 const gles2::cmds::BlendFunc& c =
261 *static_cast<const gles2::cmds::BlendFunc*>(cmd_data);
262 (void)c;
263 GLenum sfactor = static_cast<GLenum>(c.sfactor);
264 GLenum dfactor = static_cast<GLenum>(c.dfactor);
265 if (!validators_->src_blend_factor.IsValid(sfactor)) {
266 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor, "sfactor");
267 return error::kNoError;
269 if (!validators_->dst_blend_factor.IsValid(dfactor)) {
270 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor, "dfactor");
271 return error::kNoError;
273 if (state_.blend_source_rgb != sfactor || state_.blend_dest_rgb != dfactor ||
274 state_.blend_source_alpha != sfactor ||
275 state_.blend_dest_alpha != dfactor) {
276 state_.blend_source_rgb = sfactor;
277 state_.blend_dest_rgb = dfactor;
278 state_.blend_source_alpha = sfactor;
279 state_.blend_dest_alpha = dfactor;
280 glBlendFunc(sfactor, dfactor);
282 return error::kNoError;
285 error::Error GLES2DecoderImpl::HandleBlendFuncSeparate(
286 uint32_t immediate_data_size,
287 const void* cmd_data) {
288 const gles2::cmds::BlendFuncSeparate& c =
289 *static_cast<const gles2::cmds::BlendFuncSeparate*>(cmd_data);
290 (void)c;
291 GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
292 GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
293 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
294 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
295 if (!validators_->src_blend_factor.IsValid(srcRGB)) {
296 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB, "srcRGB");
297 return error::kNoError;
299 if (!validators_->dst_blend_factor.IsValid(dstRGB)) {
300 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB, "dstRGB");
301 return error::kNoError;
303 if (!validators_->src_blend_factor.IsValid(srcAlpha)) {
304 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha,
305 "srcAlpha");
306 return error::kNoError;
308 if (!validators_->dst_blend_factor.IsValid(dstAlpha)) {
309 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha,
310 "dstAlpha");
311 return error::kNoError;
313 if (state_.blend_source_rgb != srcRGB || state_.blend_dest_rgb != dstRGB ||
314 state_.blend_source_alpha != srcAlpha ||
315 state_.blend_dest_alpha != dstAlpha) {
316 state_.blend_source_rgb = srcRGB;
317 state_.blend_dest_rgb = dstRGB;
318 state_.blend_source_alpha = srcAlpha;
319 state_.blend_dest_alpha = dstAlpha;
320 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
322 return error::kNoError;
325 error::Error GLES2DecoderImpl::HandleBufferSubData(uint32_t immediate_data_size,
326 const void* cmd_data) {
327 const gles2::cmds::BufferSubData& c =
328 *static_cast<const gles2::cmds::BufferSubData*>(cmd_data);
329 (void)c;
330 GLenum target = static_cast<GLenum>(c.target);
331 GLintptr offset = static_cast<GLintptr>(c.offset);
332 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
333 uint32_t data_size = size;
334 const void* data = GetSharedMemoryAs<const void*>(
335 c.data_shm_id, c.data_shm_offset, data_size);
336 if (!validators_->buffer_target.IsValid(target)) {
337 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target, "target");
338 return error::kNoError;
340 if (size < 0) {
341 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
342 return error::kNoError;
344 if (data == NULL) {
345 return error::kOutOfBounds;
347 DoBufferSubData(target, offset, size, data);
348 return error::kNoError;
351 error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus(
352 uint32_t immediate_data_size,
353 const void* cmd_data) {
354 const gles2::cmds::CheckFramebufferStatus& c =
355 *static_cast<const gles2::cmds::CheckFramebufferStatus*>(cmd_data);
356 (void)c;
357 GLenum target = static_cast<GLenum>(c.target);
358 typedef cmds::CheckFramebufferStatus::Result Result;
359 Result* result_dst = GetSharedMemoryAs<Result*>(
360 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
361 if (!result_dst) {
362 return error::kOutOfBounds;
364 if (!validators_->frame_buffer_target.IsValid(target)) {
365 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target,
366 "target");
367 return error::kNoError;
369 *result_dst = DoCheckFramebufferStatus(target);
370 return error::kNoError;
373 error::Error GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size,
374 const void* cmd_data) {
375 const gles2::cmds::Clear& c =
376 *static_cast<const gles2::cmds::Clear*>(cmd_data);
377 (void)c;
378 error::Error error;
379 error = WillAccessBoundFramebufferForDraw();
380 if (error != error::kNoError)
381 return error;
382 GLbitfield mask = static_cast<GLbitfield>(c.mask);
383 DoClear(mask);
384 return error::kNoError;
387 error::Error GLES2DecoderImpl::HandleClearBufferfi(uint32_t immediate_data_size,
388 const void* cmd_data) {
389 if (!unsafe_es3_apis_enabled())
390 return error::kUnknownCommand;
391 const gles2::cmds::ClearBufferfi& c =
392 *static_cast<const gles2::cmds::ClearBufferfi*>(cmd_data);
393 (void)c;
394 GLenum buffer = static_cast<GLenum>(c.buffer);
395 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
396 GLfloat depth = static_cast<GLfloat>(c.depth);
397 GLint stencil = static_cast<GLint>(c.stencil);
398 glClearBufferfi(buffer, drawbuffers, depth, stencil);
399 return error::kNoError;
402 error::Error GLES2DecoderImpl::HandleClearBufferfvImmediate(
403 uint32_t immediate_data_size,
404 const void* cmd_data) {
405 if (!unsafe_es3_apis_enabled())
406 return error::kUnknownCommand;
407 const gles2::cmds::ClearBufferfvImmediate& c =
408 *static_cast<const gles2::cmds::ClearBufferfvImmediate*>(cmd_data);
409 (void)c;
410 GLenum buffer = static_cast<GLenum>(c.buffer);
411 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
412 uint32_t data_size;
413 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
414 return error::kOutOfBounds;
416 if (data_size > immediate_data_size) {
417 return error::kOutOfBounds;
419 const GLfloat* value =
420 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
421 if (value == NULL) {
422 return error::kOutOfBounds;
424 glClearBufferfv(buffer, drawbuffers, value);
425 return error::kNoError;
428 error::Error GLES2DecoderImpl::HandleClearBufferivImmediate(
429 uint32_t immediate_data_size,
430 const void* cmd_data) {
431 if (!unsafe_es3_apis_enabled())
432 return error::kUnknownCommand;
433 const gles2::cmds::ClearBufferivImmediate& c =
434 *static_cast<const gles2::cmds::ClearBufferivImmediate*>(cmd_data);
435 (void)c;
436 GLenum buffer = static_cast<GLenum>(c.buffer);
437 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
438 uint32_t data_size;
439 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
440 return error::kOutOfBounds;
442 if (data_size > immediate_data_size) {
443 return error::kOutOfBounds;
445 const GLint* value =
446 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
447 if (value == NULL) {
448 return error::kOutOfBounds;
450 glClearBufferiv(buffer, drawbuffers, value);
451 return error::kNoError;
454 error::Error GLES2DecoderImpl::HandleClearBufferuivImmediate(
455 uint32_t immediate_data_size,
456 const void* cmd_data) {
457 if (!unsafe_es3_apis_enabled())
458 return error::kUnknownCommand;
459 const gles2::cmds::ClearBufferuivImmediate& c =
460 *static_cast<const gles2::cmds::ClearBufferuivImmediate*>(cmd_data);
461 (void)c;
462 GLenum buffer = static_cast<GLenum>(c.buffer);
463 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
464 uint32_t data_size;
465 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
466 return error::kOutOfBounds;
468 if (data_size > immediate_data_size) {
469 return error::kOutOfBounds;
471 const GLuint* value =
472 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
473 if (value == NULL) {
474 return error::kOutOfBounds;
476 glClearBufferuiv(buffer, drawbuffers, value);
477 return error::kNoError;
480 error::Error GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size,
481 const void* cmd_data) {
482 const gles2::cmds::ClearColor& c =
483 *static_cast<const gles2::cmds::ClearColor*>(cmd_data);
484 (void)c;
485 GLclampf red = static_cast<GLclampf>(c.red);
486 GLclampf green = static_cast<GLclampf>(c.green);
487 GLclampf blue = static_cast<GLclampf>(c.blue);
488 GLclampf alpha = static_cast<GLclampf>(c.alpha);
489 if (state_.color_clear_red != red || state_.color_clear_green != green ||
490 state_.color_clear_blue != blue || state_.color_clear_alpha != alpha) {
491 state_.color_clear_red = red;
492 state_.color_clear_green = green;
493 state_.color_clear_blue = blue;
494 state_.color_clear_alpha = alpha;
495 glClearColor(red, green, blue, alpha);
497 return error::kNoError;
500 error::Error GLES2DecoderImpl::HandleClearDepthf(uint32_t immediate_data_size,
501 const void* cmd_data) {
502 const gles2::cmds::ClearDepthf& c =
503 *static_cast<const gles2::cmds::ClearDepthf*>(cmd_data);
504 (void)c;
505 GLclampf depth = static_cast<GLclampf>(c.depth);
506 if (state_.depth_clear != depth) {
507 state_.depth_clear = depth;
508 glClearDepth(depth);
510 return error::kNoError;
513 error::Error GLES2DecoderImpl::HandleClearStencil(uint32_t immediate_data_size,
514 const void* cmd_data) {
515 const gles2::cmds::ClearStencil& c =
516 *static_cast<const gles2::cmds::ClearStencil*>(cmd_data);
517 (void)c;
518 GLint s = static_cast<GLint>(c.s);
519 if (state_.stencil_clear != s) {
520 state_.stencil_clear = s;
521 glClearStencil(s);
523 return error::kNoError;
526 error::Error GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size,
527 const void* cmd_data) {
528 const gles2::cmds::ColorMask& c =
529 *static_cast<const gles2::cmds::ColorMask*>(cmd_data);
530 (void)c;
531 GLboolean red = static_cast<GLboolean>(c.red);
532 GLboolean green = static_cast<GLboolean>(c.green);
533 GLboolean blue = static_cast<GLboolean>(c.blue);
534 GLboolean alpha = static_cast<GLboolean>(c.alpha);
535 if (state_.color_mask_red != red || state_.color_mask_green != green ||
536 state_.color_mask_blue != blue || state_.color_mask_alpha != alpha) {
537 state_.color_mask_red = red;
538 state_.color_mask_green = green;
539 state_.color_mask_blue = blue;
540 state_.color_mask_alpha = alpha;
541 framebuffer_state_.clear_state_dirty = true;
543 return error::kNoError;
546 error::Error GLES2DecoderImpl::HandleCompileShader(uint32_t immediate_data_size,
547 const void* cmd_data) {
548 const gles2::cmds::CompileShader& c =
549 *static_cast<const gles2::cmds::CompileShader*>(cmd_data);
550 (void)c;
551 GLuint shader = c.shader;
552 DoCompileShader(shader);
553 return error::kNoError;
556 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2D(
557 uint32_t immediate_data_size,
558 const void* cmd_data) {
559 const gles2::cmds::CompressedTexSubImage2D& c =
560 *static_cast<const gles2::cmds::CompressedTexSubImage2D*>(cmd_data);
561 (void)c;
562 GLenum target = static_cast<GLenum>(c.target);
563 GLint level = static_cast<GLint>(c.level);
564 GLint xoffset = static_cast<GLint>(c.xoffset);
565 GLint yoffset = static_cast<GLint>(c.yoffset);
566 GLsizei width = static_cast<GLsizei>(c.width);
567 GLsizei height = static_cast<GLsizei>(c.height);
568 GLenum format = static_cast<GLenum>(c.format);
569 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
570 uint32_t data_size = imageSize;
571 const void* data = GetSharedMemoryAs<const void*>(
572 c.data_shm_id, c.data_shm_offset, data_size);
573 if (!validators_->texture_target.IsValid(target)) {
574 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", target,
575 "target");
576 return error::kNoError;
578 if (width < 0) {
579 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
580 "width < 0");
581 return error::kNoError;
583 if (height < 0) {
584 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
585 "height < 0");
586 return error::kNoError;
588 if (!validators_->compressed_texture_format.IsValid(format)) {
589 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", format,
590 "format");
591 return error::kNoError;
593 if (imageSize < 0) {
594 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
595 "imageSize < 0");
596 return error::kNoError;
598 if (data == NULL) {
599 return error::kOutOfBounds;
601 DoCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
602 format, imageSize, data);
603 return error::kNoError;
606 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage3D(
607 uint32_t immediate_data_size,
608 const void* cmd_data) {
609 if (!unsafe_es3_apis_enabled())
610 return error::kUnknownCommand;
611 const gles2::cmds::CompressedTexSubImage3D& c =
612 *static_cast<const gles2::cmds::CompressedTexSubImage3D*>(cmd_data);
613 (void)c;
614 GLenum target = static_cast<GLenum>(c.target);
615 GLint level = static_cast<GLint>(c.level);
616 GLint xoffset = static_cast<GLint>(c.xoffset);
617 GLint yoffset = static_cast<GLint>(c.yoffset);
618 GLint zoffset = static_cast<GLint>(c.zoffset);
619 GLsizei width = static_cast<GLsizei>(c.width);
620 GLsizei height = static_cast<GLsizei>(c.height);
621 GLsizei depth = static_cast<GLsizei>(c.depth);
622 GLenum format = static_cast<GLenum>(c.format);
623 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
624 uint32_t data_size = imageSize;
625 const void* data = GetSharedMemoryAs<const void*>(
626 c.data_shm_id, c.data_shm_offset, data_size);
627 if (data == NULL) {
628 return error::kOutOfBounds;
630 DoCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width,
631 height, depth, format, imageSize, data);
632 return error::kNoError;
635 error::Error GLES2DecoderImpl::HandleCopyBufferSubData(
636 uint32_t immediate_data_size,
637 const void* cmd_data) {
638 if (!unsafe_es3_apis_enabled())
639 return error::kUnknownCommand;
640 const gles2::cmds::CopyBufferSubData& c =
641 *static_cast<const gles2::cmds::CopyBufferSubData*>(cmd_data);
642 (void)c;
643 GLenum readtarget = static_cast<GLenum>(c.readtarget);
644 GLenum writetarget = static_cast<GLenum>(c.writetarget);
645 GLintptr readoffset = static_cast<GLintptr>(c.readoffset);
646 GLintptr writeoffset = static_cast<GLintptr>(c.writeoffset);
647 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
648 glCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
649 return error::kNoError;
652 error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
653 uint32_t immediate_data_size,
654 const void* cmd_data) {
655 const gles2::cmds::CopyTexImage2D& c =
656 *static_cast<const gles2::cmds::CopyTexImage2D*>(cmd_data);
657 (void)c;
658 error::Error error;
659 error = WillAccessBoundFramebufferForRead();
660 if (error != error::kNoError)
661 return error;
662 GLenum target = static_cast<GLenum>(c.target);
663 GLint level = static_cast<GLint>(c.level);
664 GLenum internalformat = static_cast<GLenum>(c.internalformat);
665 GLint x = static_cast<GLint>(c.x);
666 GLint y = static_cast<GLint>(c.y);
667 GLsizei width = static_cast<GLsizei>(c.width);
668 GLsizei height = static_cast<GLsizei>(c.height);
669 GLint border = static_cast<GLint>(c.border);
670 if (!validators_->texture_target.IsValid(target)) {
671 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target, "target");
672 return error::kNoError;
674 if (!validators_->texture_internal_format.IsValid(internalformat)) {
675 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat,
676 "internalformat");
677 return error::kNoError;
679 if (width < 0) {
680 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
681 return error::kNoError;
683 if (height < 0) {
684 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
685 return error::kNoError;
687 DoCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
688 return error::kNoError;
691 error::Error GLES2DecoderImpl::HandleCopyTexSubImage2D(
692 uint32_t immediate_data_size,
693 const void* cmd_data) {
694 const gles2::cmds::CopyTexSubImage2D& c =
695 *static_cast<const gles2::cmds::CopyTexSubImage2D*>(cmd_data);
696 (void)c;
697 error::Error error;
698 error = WillAccessBoundFramebufferForRead();
699 if (error != error::kNoError)
700 return error;
701 GLenum target = static_cast<GLenum>(c.target);
702 GLint level = static_cast<GLint>(c.level);
703 GLint xoffset = static_cast<GLint>(c.xoffset);
704 GLint yoffset = static_cast<GLint>(c.yoffset);
705 GLint x = static_cast<GLint>(c.x);
706 GLint y = static_cast<GLint>(c.y);
707 GLsizei width = static_cast<GLsizei>(c.width);
708 GLsizei height = static_cast<GLsizei>(c.height);
709 if (!validators_->texture_target.IsValid(target)) {
710 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target, "target");
711 return error::kNoError;
713 if (width < 0) {
714 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
715 return error::kNoError;
717 if (height < 0) {
718 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
719 return error::kNoError;
721 DoCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
722 return error::kNoError;
725 error::Error GLES2DecoderImpl::HandleCopyTexSubImage3D(
726 uint32_t immediate_data_size,
727 const void* cmd_data) {
728 if (!unsafe_es3_apis_enabled())
729 return error::kUnknownCommand;
730 const gles2::cmds::CopyTexSubImage3D& c =
731 *static_cast<const gles2::cmds::CopyTexSubImage3D*>(cmd_data);
732 (void)c;
733 error::Error error;
734 error = WillAccessBoundFramebufferForRead();
735 if (error != error::kNoError)
736 return error;
737 GLenum target = static_cast<GLenum>(c.target);
738 GLint level = static_cast<GLint>(c.level);
739 GLint xoffset = static_cast<GLint>(c.xoffset);
740 GLint yoffset = static_cast<GLint>(c.yoffset);
741 GLint zoffset = static_cast<GLint>(c.zoffset);
742 GLint x = static_cast<GLint>(c.x);
743 GLint y = static_cast<GLint>(c.y);
744 GLsizei width = static_cast<GLsizei>(c.width);
745 GLsizei height = static_cast<GLsizei>(c.height);
746 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
747 height);
748 return error::kNoError;
751 error::Error GLES2DecoderImpl::HandleCreateProgram(uint32_t immediate_data_size,
752 const void* cmd_data) {
753 const gles2::cmds::CreateProgram& c =
754 *static_cast<const gles2::cmds::CreateProgram*>(cmd_data);
755 (void)c;
756 uint32_t client_id = c.client_id;
757 if (GetProgram(client_id)) {
758 return error::kInvalidArguments;
760 GLuint service_id = glCreateProgram();
761 if (service_id) {
762 CreateProgram(client_id, service_id);
764 return error::kNoError;
767 error::Error GLES2DecoderImpl::HandleCreateShader(uint32_t immediate_data_size,
768 const void* cmd_data) {
769 const gles2::cmds::CreateShader& c =
770 *static_cast<const gles2::cmds::CreateShader*>(cmd_data);
771 (void)c;
772 GLenum type = static_cast<GLenum>(c.type);
773 if (!validators_->shader_type.IsValid(type)) {
774 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type, "type");
775 return error::kNoError;
777 uint32_t client_id = c.client_id;
778 if (GetShader(client_id)) {
779 return error::kInvalidArguments;
781 GLuint service_id = glCreateShader(type);
782 if (service_id) {
783 CreateShader(client_id, service_id, type);
785 return error::kNoError;
788 error::Error GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size,
789 const void* cmd_data) {
790 const gles2::cmds::CullFace& c =
791 *static_cast<const gles2::cmds::CullFace*>(cmd_data);
792 (void)c;
793 GLenum mode = static_cast<GLenum>(c.mode);
794 if (!validators_->face_type.IsValid(mode)) {
795 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode, "mode");
796 return error::kNoError;
798 if (state_.cull_mode != mode) {
799 state_.cull_mode = mode;
800 glCullFace(mode);
802 return error::kNoError;
805 error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
806 uint32_t immediate_data_size,
807 const void* cmd_data) {
808 const gles2::cmds::DeleteBuffersImmediate& c =
809 *static_cast<const gles2::cmds::DeleteBuffersImmediate*>(cmd_data);
810 (void)c;
811 GLsizei n = static_cast<GLsizei>(c.n);
812 uint32_t data_size;
813 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
814 return error::kOutOfBounds;
816 const GLuint* buffers =
817 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
818 if (buffers == NULL) {
819 return error::kOutOfBounds;
821 DeleteBuffersHelper(n, buffers);
822 return error::kNoError;
825 error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
826 uint32_t immediate_data_size,
827 const void* cmd_data) {
828 const gles2::cmds::DeleteFramebuffersImmediate& c =
829 *static_cast<const gles2::cmds::DeleteFramebuffersImmediate*>(cmd_data);
830 (void)c;
831 GLsizei n = static_cast<GLsizei>(c.n);
832 uint32_t data_size;
833 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
834 return error::kOutOfBounds;
836 const GLuint* framebuffers =
837 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
838 if (framebuffers == NULL) {
839 return error::kOutOfBounds;
841 DeleteFramebuffersHelper(n, framebuffers);
842 return error::kNoError;
845 error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
846 uint32_t immediate_data_size,
847 const void* cmd_data) {
848 const gles2::cmds::DeleteRenderbuffersImmediate& c =
849 *static_cast<const gles2::cmds::DeleteRenderbuffersImmediate*>(cmd_data);
850 (void)c;
851 GLsizei n = static_cast<GLsizei>(c.n);
852 uint32_t data_size;
853 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
854 return error::kOutOfBounds;
856 const GLuint* renderbuffers =
857 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
858 if (renderbuffers == NULL) {
859 return error::kOutOfBounds;
861 DeleteRenderbuffersHelper(n, renderbuffers);
862 return error::kNoError;
865 error::Error GLES2DecoderImpl::HandleDeleteSamplersImmediate(
866 uint32_t immediate_data_size,
867 const void* cmd_data) {
868 if (!unsafe_es3_apis_enabled())
869 return error::kUnknownCommand;
870 const gles2::cmds::DeleteSamplersImmediate& c =
871 *static_cast<const gles2::cmds::DeleteSamplersImmediate*>(cmd_data);
872 (void)c;
873 GLsizei n = static_cast<GLsizei>(c.n);
874 uint32_t data_size;
875 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
876 return error::kOutOfBounds;
878 const GLuint* samplers =
879 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
880 if (samplers == NULL) {
881 return error::kOutOfBounds;
883 for (GLsizei ii = 0; ii < n; ++ii) {
884 GLuint service_id = 0;
885 if (group_->GetSamplerServiceId(samplers[ii], &service_id)) {
886 glDeleteSamplers(1, &service_id);
887 group_->RemoveSamplerId(samplers[ii]);
890 return error::kNoError;
893 error::Error GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size,
894 const void* cmd_data) {
895 if (!unsafe_es3_apis_enabled())
896 return error::kUnknownCommand;
897 const gles2::cmds::DeleteSync& c =
898 *static_cast<const gles2::cmds::DeleteSync*>(cmd_data);
899 (void)c;
900 GLuint sync = c.sync;
901 GLsync service_id = 0;
902 if (group_->GetSyncServiceId(sync, &service_id)) {
903 glDeleteSync(service_id);
904 group_->RemoveSyncId(sync);
905 } else {
906 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDeleteSync", "unknown sync");
908 return error::kNoError;
911 error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
912 uint32_t immediate_data_size,
913 const void* cmd_data) {
914 const gles2::cmds::DeleteTexturesImmediate& c =
915 *static_cast<const gles2::cmds::DeleteTexturesImmediate*>(cmd_data);
916 (void)c;
917 GLsizei n = static_cast<GLsizei>(c.n);
918 uint32_t data_size;
919 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
920 return error::kOutOfBounds;
922 const GLuint* textures =
923 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
924 if (textures == NULL) {
925 return error::kOutOfBounds;
927 DeleteTexturesHelper(n, textures);
928 return error::kNoError;
931 error::Error GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
932 uint32_t immediate_data_size,
933 const void* cmd_data) {
934 if (!unsafe_es3_apis_enabled())
935 return error::kUnknownCommand;
936 const gles2::cmds::DeleteTransformFeedbacksImmediate& c =
937 *static_cast<const gles2::cmds::DeleteTransformFeedbacksImmediate*>(
938 cmd_data);
939 (void)c;
940 GLsizei n = static_cast<GLsizei>(c.n);
941 uint32_t data_size;
942 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
943 return error::kOutOfBounds;
945 const GLuint* ids =
946 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
947 if (ids == NULL) {
948 return error::kOutOfBounds;
950 for (GLsizei ii = 0; ii < n; ++ii) {
951 GLuint service_id = 0;
952 if (group_->GetTransformFeedbackServiceId(ids[ii], &service_id)) {
953 glDeleteTransformFeedbacks(1, &service_id);
954 group_->RemoveTransformFeedbackId(ids[ii]);
957 return error::kNoError;
960 error::Error GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size,
961 const void* cmd_data) {
962 const gles2::cmds::DepthFunc& c =
963 *static_cast<const gles2::cmds::DepthFunc*>(cmd_data);
964 (void)c;
965 GLenum func = static_cast<GLenum>(c.func);
966 if (!validators_->cmp_function.IsValid(func)) {
967 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func, "func");
968 return error::kNoError;
970 if (state_.depth_func != func) {
971 state_.depth_func = func;
972 glDepthFunc(func);
974 return error::kNoError;
977 error::Error GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size,
978 const void* cmd_data) {
979 const gles2::cmds::DepthMask& c =
980 *static_cast<const gles2::cmds::DepthMask*>(cmd_data);
981 (void)c;
982 GLboolean flag = static_cast<GLboolean>(c.flag);
983 if (state_.depth_mask != flag) {
984 state_.depth_mask = flag;
985 framebuffer_state_.clear_state_dirty = true;
987 return error::kNoError;
990 error::Error GLES2DecoderImpl::HandleDepthRangef(uint32_t immediate_data_size,
991 const void* cmd_data) {
992 const gles2::cmds::DepthRangef& c =
993 *static_cast<const gles2::cmds::DepthRangef*>(cmd_data);
994 (void)c;
995 GLclampf zNear = static_cast<GLclampf>(c.zNear);
996 GLclampf zFar = static_cast<GLclampf>(c.zFar);
997 DoDepthRangef(zNear, zFar);
998 return error::kNoError;
1001 error::Error GLES2DecoderImpl::HandleDetachShader(uint32_t immediate_data_size,
1002 const void* cmd_data) {
1003 const gles2::cmds::DetachShader& c =
1004 *static_cast<const gles2::cmds::DetachShader*>(cmd_data);
1005 (void)c;
1006 GLuint program = c.program;
1007 GLuint shader = c.shader;
1008 DoDetachShader(program, shader);
1009 return error::kNoError;
1012 error::Error GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size,
1013 const void* cmd_data) {
1014 const gles2::cmds::Disable& c =
1015 *static_cast<const gles2::cmds::Disable*>(cmd_data);
1016 (void)c;
1017 GLenum cap = static_cast<GLenum>(c.cap);
1018 if (!validators_->capability.IsValid(cap)) {
1019 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap, "cap");
1020 return error::kNoError;
1022 DoDisable(cap);
1023 return error::kNoError;
1026 error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
1027 uint32_t immediate_data_size,
1028 const void* cmd_data) {
1029 const gles2::cmds::DisableVertexAttribArray& c =
1030 *static_cast<const gles2::cmds::DisableVertexAttribArray*>(cmd_data);
1031 (void)c;
1032 GLuint index = static_cast<GLuint>(c.index);
1033 DoDisableVertexAttribArray(index);
1034 return error::kNoError;
1037 error::Error GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size,
1038 const void* cmd_data) {
1039 const gles2::cmds::Enable& c =
1040 *static_cast<const gles2::cmds::Enable*>(cmd_data);
1041 (void)c;
1042 GLenum cap = static_cast<GLenum>(c.cap);
1043 if (!validators_->capability.IsValid(cap)) {
1044 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap, "cap");
1045 return error::kNoError;
1047 DoEnable(cap);
1048 return error::kNoError;
1051 error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
1052 uint32_t immediate_data_size,
1053 const void* cmd_data) {
1054 const gles2::cmds::EnableVertexAttribArray& c =
1055 *static_cast<const gles2::cmds::EnableVertexAttribArray*>(cmd_data);
1056 (void)c;
1057 GLuint index = static_cast<GLuint>(c.index);
1058 DoEnableVertexAttribArray(index);
1059 return error::kNoError;
1062 error::Error GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size,
1063 const void* cmd_data) {
1064 if (!unsafe_es3_apis_enabled())
1065 return error::kUnknownCommand;
1066 const gles2::cmds::FenceSync& c =
1067 *static_cast<const gles2::cmds::FenceSync*>(cmd_data);
1068 (void)c;
1069 GLenum condition = static_cast<GLenum>(c.condition);
1070 GLbitfield flags = static_cast<GLbitfield>(c.flags);
1071 uint32_t client_id = c.client_id;
1072 GLsync service_id = 0;
1073 if (group_->GetSyncServiceId(client_id, &service_id)) {
1074 return error::kInvalidArguments;
1076 service_id = glFenceSync(condition, flags);
1077 if (service_id) {
1078 group_->AddSyncId(client_id, service_id);
1080 return error::kNoError;
1083 error::Error GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size,
1084 const void* cmd_data) {
1085 const gles2::cmds::Finish& c =
1086 *static_cast<const gles2::cmds::Finish*>(cmd_data);
1087 (void)c;
1088 error::Error error;
1089 error = WillAccessBoundFramebufferForRead();
1090 if (error != error::kNoError)
1091 return error;
1092 DoFinish();
1093 return error::kNoError;
1096 error::Error GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size,
1097 const void* cmd_data) {
1098 const gles2::cmds::Flush& c =
1099 *static_cast<const gles2::cmds::Flush*>(cmd_data);
1100 (void)c;
1101 DoFlush();
1102 return error::kNoError;
1105 error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
1106 uint32_t immediate_data_size,
1107 const void* cmd_data) {
1108 const gles2::cmds::FramebufferRenderbuffer& c =
1109 *static_cast<const gles2::cmds::FramebufferRenderbuffer*>(cmd_data);
1110 (void)c;
1111 GLenum target = static_cast<GLenum>(c.target);
1112 GLenum attachment = static_cast<GLenum>(c.attachment);
1113 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
1114 GLuint renderbuffer = c.renderbuffer;
1115 if (!validators_->frame_buffer_target.IsValid(target)) {
1116 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target,
1117 "target");
1118 return error::kNoError;
1120 if (!validators_->attachment.IsValid(attachment)) {
1121 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment,
1122 "attachment");
1123 return error::kNoError;
1125 if (!validators_->render_buffer_target.IsValid(renderbuffertarget)) {
1126 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
1127 renderbuffertarget, "renderbuffertarget");
1128 return error::kNoError;
1130 DoFramebufferRenderbuffer(target, attachment, renderbuffertarget,
1131 renderbuffer);
1132 return error::kNoError;
1135 error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
1136 uint32_t immediate_data_size,
1137 const void* cmd_data) {
1138 const gles2::cmds::FramebufferTexture2D& c =
1139 *static_cast<const gles2::cmds::FramebufferTexture2D*>(cmd_data);
1140 (void)c;
1141 GLenum target = static_cast<GLenum>(c.target);
1142 GLenum attachment = static_cast<GLenum>(c.attachment);
1143 GLenum textarget = static_cast<GLenum>(c.textarget);
1144 GLuint texture = c.texture;
1145 GLint level = static_cast<GLint>(c.level);
1146 if (!validators_->frame_buffer_target.IsValid(target)) {
1147 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target, "target");
1148 return error::kNoError;
1150 if (!validators_->attachment.IsValid(attachment)) {
1151 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment,
1152 "attachment");
1153 return error::kNoError;
1155 if (!validators_->texture_target.IsValid(textarget)) {
1156 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget,
1157 "textarget");
1158 return error::kNoError;
1160 DoFramebufferTexture2D(target, attachment, textarget, texture, level);
1161 return error::kNoError;
1164 error::Error GLES2DecoderImpl::HandleFramebufferTextureLayer(
1165 uint32_t immediate_data_size,
1166 const void* cmd_data) {
1167 if (!unsafe_es3_apis_enabled())
1168 return error::kUnknownCommand;
1169 const gles2::cmds::FramebufferTextureLayer& c =
1170 *static_cast<const gles2::cmds::FramebufferTextureLayer*>(cmd_data);
1171 (void)c;
1172 GLenum target = static_cast<GLenum>(c.target);
1173 GLenum attachment = static_cast<GLenum>(c.attachment);
1174 GLuint texture = c.texture;
1175 GLint level = static_cast<GLint>(c.level);
1176 GLint layer = static_cast<GLint>(c.layer);
1177 DoFramebufferTextureLayer(target, attachment, texture, level, layer);
1178 return error::kNoError;
1181 error::Error GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size,
1182 const void* cmd_data) {
1183 const gles2::cmds::FrontFace& c =
1184 *static_cast<const gles2::cmds::FrontFace*>(cmd_data);
1185 (void)c;
1186 GLenum mode = static_cast<GLenum>(c.mode);
1187 if (!validators_->face_mode.IsValid(mode)) {
1188 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode, "mode");
1189 return error::kNoError;
1191 if (state_.front_face != mode) {
1192 state_.front_face = mode;
1193 glFrontFace(mode);
1195 return error::kNoError;
1198 error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
1199 uint32_t immediate_data_size,
1200 const void* cmd_data) {
1201 const gles2::cmds::GenBuffersImmediate& c =
1202 *static_cast<const gles2::cmds::GenBuffersImmediate*>(cmd_data);
1203 (void)c;
1204 GLsizei n = static_cast<GLsizei>(c.n);
1205 uint32_t data_size;
1206 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1207 return error::kOutOfBounds;
1209 GLuint* buffers =
1210 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1211 if (buffers == NULL) {
1212 return error::kOutOfBounds;
1214 if (!GenBuffersHelper(n, buffers)) {
1215 return error::kInvalidArguments;
1217 return error::kNoError;
1220 error::Error GLES2DecoderImpl::HandleGenerateMipmap(
1221 uint32_t immediate_data_size,
1222 const void* cmd_data) {
1223 const gles2::cmds::GenerateMipmap& c =
1224 *static_cast<const gles2::cmds::GenerateMipmap*>(cmd_data);
1225 (void)c;
1226 GLenum target = static_cast<GLenum>(c.target);
1227 if (!validators_->texture_bind_target.IsValid(target)) {
1228 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target, "target");
1229 return error::kNoError;
1231 DoGenerateMipmap(target);
1232 return error::kNoError;
1235 error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
1236 uint32_t immediate_data_size,
1237 const void* cmd_data) {
1238 const gles2::cmds::GenFramebuffersImmediate& c =
1239 *static_cast<const gles2::cmds::GenFramebuffersImmediate*>(cmd_data);
1240 (void)c;
1241 GLsizei n = static_cast<GLsizei>(c.n);
1242 uint32_t data_size;
1243 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1244 return error::kOutOfBounds;
1246 GLuint* framebuffers =
1247 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1248 if (framebuffers == NULL) {
1249 return error::kOutOfBounds;
1251 if (!GenFramebuffersHelper(n, framebuffers)) {
1252 return error::kInvalidArguments;
1254 return error::kNoError;
1257 error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
1258 uint32_t immediate_data_size,
1259 const void* cmd_data) {
1260 const gles2::cmds::GenRenderbuffersImmediate& c =
1261 *static_cast<const gles2::cmds::GenRenderbuffersImmediate*>(cmd_data);
1262 (void)c;
1263 GLsizei n = static_cast<GLsizei>(c.n);
1264 uint32_t data_size;
1265 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1266 return error::kOutOfBounds;
1268 GLuint* renderbuffers =
1269 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1270 if (renderbuffers == NULL) {
1271 return error::kOutOfBounds;
1273 if (!GenRenderbuffersHelper(n, renderbuffers)) {
1274 return error::kInvalidArguments;
1276 return error::kNoError;
1279 error::Error GLES2DecoderImpl::HandleGenSamplersImmediate(
1280 uint32_t immediate_data_size,
1281 const void* cmd_data) {
1282 if (!unsafe_es3_apis_enabled())
1283 return error::kUnknownCommand;
1284 const gles2::cmds::GenSamplersImmediate& c =
1285 *static_cast<const gles2::cmds::GenSamplersImmediate*>(cmd_data);
1286 (void)c;
1287 GLsizei n = static_cast<GLsizei>(c.n);
1288 uint32_t data_size;
1289 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1290 return error::kOutOfBounds;
1292 GLuint* samplers =
1293 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1294 if (samplers == NULL) {
1295 return error::kOutOfBounds;
1297 for (GLsizei ii = 0; ii < n; ++ii) {
1298 if (group_->GetSamplerServiceId(samplers[ii], NULL)) {
1299 return error::kInvalidArguments;
1302 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1303 glGenSamplers(n, service_ids.get());
1304 for (GLsizei ii = 0; ii < n; ++ii) {
1305 group_->AddSamplerId(samplers[ii], service_ids[ii]);
1307 return error::kNoError;
1310 error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
1311 uint32_t immediate_data_size,
1312 const void* cmd_data) {
1313 const gles2::cmds::GenTexturesImmediate& c =
1314 *static_cast<const gles2::cmds::GenTexturesImmediate*>(cmd_data);
1315 (void)c;
1316 GLsizei n = static_cast<GLsizei>(c.n);
1317 uint32_t data_size;
1318 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1319 return error::kOutOfBounds;
1321 GLuint* textures =
1322 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1323 if (textures == NULL) {
1324 return error::kOutOfBounds;
1326 if (!GenTexturesHelper(n, textures)) {
1327 return error::kInvalidArguments;
1329 return error::kNoError;
1332 error::Error GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
1333 uint32_t immediate_data_size,
1334 const void* cmd_data) {
1335 if (!unsafe_es3_apis_enabled())
1336 return error::kUnknownCommand;
1337 const gles2::cmds::GenTransformFeedbacksImmediate& c =
1338 *static_cast<const gles2::cmds::GenTransformFeedbacksImmediate*>(
1339 cmd_data);
1340 (void)c;
1341 GLsizei n = static_cast<GLsizei>(c.n);
1342 uint32_t data_size;
1343 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1344 return error::kOutOfBounds;
1346 GLuint* ids = GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1347 if (ids == NULL) {
1348 return error::kOutOfBounds;
1350 for (GLsizei ii = 0; ii < n; ++ii) {
1351 if (group_->GetTransformFeedbackServiceId(ids[ii], NULL)) {
1352 return error::kInvalidArguments;
1355 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1356 glGenTransformFeedbacks(n, service_ids.get());
1357 for (GLsizei ii = 0; ii < n; ++ii) {
1358 group_->AddTransformFeedbackId(ids[ii], service_ids[ii]);
1360 return error::kNoError;
1363 error::Error GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size,
1364 const void* cmd_data) {
1365 const gles2::cmds::GetBooleanv& c =
1366 *static_cast<const gles2::cmds::GetBooleanv*>(cmd_data);
1367 (void)c;
1368 GLenum pname = static_cast<GLenum>(c.pname);
1369 typedef cmds::GetBooleanv::Result Result;
1370 GLsizei num_values = 0;
1371 GetNumValuesReturnedForGLGet(pname, &num_values);
1372 Result* result = GetSharedMemoryAs<Result*>(
1373 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1374 GLboolean* params = result ? result->GetData() : NULL;
1375 if (!validators_->g_l_state.IsValid(pname)) {
1376 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname, "pname");
1377 return error::kNoError;
1379 if (params == NULL) {
1380 return error::kOutOfBounds;
1382 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
1383 // Check that the client initialized the result.
1384 if (result->size != 0) {
1385 return error::kInvalidArguments;
1387 DoGetBooleanv(pname, params);
1388 GLenum error = LOCAL_PEEK_GL_ERROR("GetBooleanv");
1389 if (error == GL_NO_ERROR) {
1390 result->SetNumResults(num_values);
1392 return error::kNoError;
1395 error::Error GLES2DecoderImpl::HandleGetBufferParameteri64v(
1396 uint32_t immediate_data_size,
1397 const void* cmd_data) {
1398 if (!unsafe_es3_apis_enabled())
1399 return error::kUnknownCommand;
1400 const gles2::cmds::GetBufferParameteri64v& c =
1401 *static_cast<const gles2::cmds::GetBufferParameteri64v*>(cmd_data);
1402 (void)c;
1403 GLenum target = static_cast<GLenum>(c.target);
1404 GLenum pname = static_cast<GLenum>(c.pname);
1405 typedef cmds::GetBufferParameteri64v::Result Result;
1406 GLsizei num_values = 0;
1407 GetNumValuesReturnedForGLGet(pname, &num_values);
1408 Result* result = GetSharedMemoryAs<Result*>(
1409 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1410 GLint64* params = result ? result->GetData() : NULL;
1411 if (params == NULL) {
1412 return error::kOutOfBounds;
1414 // Check that the client initialized the result.
1415 if (result->size != 0) {
1416 return error::kInvalidArguments;
1418 DoGetBufferParameteri64v(target, pname, params);
1419 result->SetNumResults(num_values);
1420 return error::kNoError;
1422 error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
1423 uint32_t immediate_data_size,
1424 const void* cmd_data) {
1425 const gles2::cmds::GetBufferParameteriv& c =
1426 *static_cast<const gles2::cmds::GetBufferParameteriv*>(cmd_data);
1427 (void)c;
1428 GLenum target = static_cast<GLenum>(c.target);
1429 GLenum pname = static_cast<GLenum>(c.pname);
1430 typedef cmds::GetBufferParameteriv::Result Result;
1431 GLsizei num_values = 0;
1432 GetNumValuesReturnedForGLGet(pname, &num_values);
1433 Result* result = GetSharedMemoryAs<Result*>(
1434 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1435 GLint* params = result ? result->GetData() : NULL;
1436 if (!validators_->buffer_target.IsValid(target)) {
1437 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
1438 return error::kNoError;
1440 if (!validators_->buffer_parameter.IsValid(pname)) {
1441 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
1442 return error::kNoError;
1444 if (params == NULL) {
1445 return error::kOutOfBounds;
1447 // Check that the client initialized the result.
1448 if (result->size != 0) {
1449 return error::kInvalidArguments;
1451 DoGetBufferParameteriv(target, pname, params);
1452 result->SetNumResults(num_values);
1453 return error::kNoError;
1455 error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
1456 const void* cmd_data) {
1457 const gles2::cmds::GetError& c =
1458 *static_cast<const gles2::cmds::GetError*>(cmd_data);
1459 (void)c;
1460 typedef cmds::GetError::Result Result;
1461 Result* result_dst = GetSharedMemoryAs<Result*>(
1462 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1463 if (!result_dst) {
1464 return error::kOutOfBounds;
1466 *result_dst = GetErrorState()->GetGLError();
1467 return error::kNoError;
1470 error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
1471 const void* cmd_data) {
1472 const gles2::cmds::GetFloatv& c =
1473 *static_cast<const gles2::cmds::GetFloatv*>(cmd_data);
1474 (void)c;
1475 GLenum pname = static_cast<GLenum>(c.pname);
1476 typedef cmds::GetFloatv::Result Result;
1477 GLsizei num_values = 0;
1478 GetNumValuesReturnedForGLGet(pname, &num_values);
1479 Result* result = GetSharedMemoryAs<Result*>(
1480 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1481 GLfloat* params = result ? result->GetData() : NULL;
1482 if (!validators_->g_l_state.IsValid(pname)) {
1483 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
1484 return error::kNoError;
1486 if (params == NULL) {
1487 return error::kOutOfBounds;
1489 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1490 // Check that the client initialized the result.
1491 if (result->size != 0) {
1492 return error::kInvalidArguments;
1494 DoGetFloatv(pname, params);
1495 GLenum error = LOCAL_PEEK_GL_ERROR("GetFloatv");
1496 if (error == GL_NO_ERROR) {
1497 result->SetNumResults(num_values);
1499 return error::kNoError;
1502 error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1503 uint32_t immediate_data_size,
1504 const void* cmd_data) {
1505 const gles2::cmds::GetFramebufferAttachmentParameteriv& c =
1506 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv*>(
1507 cmd_data);
1508 (void)c;
1509 GLenum target = static_cast<GLenum>(c.target);
1510 GLenum attachment = static_cast<GLenum>(c.attachment);
1511 GLenum pname = static_cast<GLenum>(c.pname);
1512 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
1513 GLsizei num_values = 0;
1514 GetNumValuesReturnedForGLGet(pname, &num_values);
1515 Result* result = GetSharedMemoryAs<Result*>(
1516 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1517 GLint* params = result ? result->GetData() : NULL;
1518 if (!validators_->frame_buffer_target.IsValid(target)) {
1519 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1520 target, "target");
1521 return error::kNoError;
1523 if (!validators_->attachment.IsValid(attachment)) {
1524 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1525 attachment, "attachment");
1526 return error::kNoError;
1528 if (!validators_->frame_buffer_parameter.IsValid(pname)) {
1529 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1530 pname, "pname");
1531 return error::kNoError;
1533 if (params == NULL) {
1534 return error::kOutOfBounds;
1536 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1537 // Check that the client initialized the result.
1538 if (result->size != 0) {
1539 return error::kInvalidArguments;
1541 DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1542 GLenum error = LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv");
1543 if (error == GL_NO_ERROR) {
1544 result->SetNumResults(num_values);
1546 return error::kNoError;
1549 error::Error GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size,
1550 const void* cmd_data) {
1551 if (!unsafe_es3_apis_enabled())
1552 return error::kUnknownCommand;
1553 const gles2::cmds::GetInteger64v& c =
1554 *static_cast<const gles2::cmds::GetInteger64v*>(cmd_data);
1555 (void)c;
1556 GLenum pname = static_cast<GLenum>(c.pname);
1557 typedef cmds::GetInteger64v::Result Result;
1558 GLsizei num_values = 0;
1559 GetNumValuesReturnedForGLGet(pname, &num_values);
1560 Result* result = GetSharedMemoryAs<Result*>(
1561 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1562 GLint64* params = result ? result->GetData() : NULL;
1563 if (params == NULL) {
1564 return error::kOutOfBounds;
1566 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
1567 // Check that the client initialized the result.
1568 if (result->size != 0) {
1569 return error::kInvalidArguments;
1571 DoGetInteger64v(pname, params);
1572 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64v");
1573 if (error == GL_NO_ERROR) {
1574 result->SetNumResults(num_values);
1576 return error::kNoError;
1579 error::Error GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size,
1580 const void* cmd_data) {
1581 if (!unsafe_es3_apis_enabled())
1582 return error::kUnknownCommand;
1583 const gles2::cmds::GetIntegeri_v& c =
1584 *static_cast<const gles2::cmds::GetIntegeri_v*>(cmd_data);
1585 (void)c;
1586 GLenum pname = static_cast<GLenum>(c.pname);
1587 GLuint index = static_cast<GLuint>(c.index);
1588 typedef cmds::GetIntegeri_v::Result Result;
1589 GLsizei num_values = 0;
1590 GetNumValuesReturnedForGLGet(pname, &num_values);
1591 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1592 Result::ComputeSize(num_values));
1593 GLint* data = result ? result->GetData() : NULL;
1594 if (data == NULL) {
1595 return error::kOutOfBounds;
1597 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegeri_v");
1598 // Check that the client initialized the result.
1599 if (result->size != 0) {
1600 return error::kInvalidArguments;
1602 glGetIntegeri_v(pname, index, data);
1603 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegeri_v");
1604 if (error == GL_NO_ERROR) {
1605 result->SetNumResults(num_values);
1607 return error::kNoError;
1610 error::Error GLES2DecoderImpl::HandleGetInteger64i_v(
1611 uint32_t immediate_data_size,
1612 const void* cmd_data) {
1613 if (!unsafe_es3_apis_enabled())
1614 return error::kUnknownCommand;
1615 const gles2::cmds::GetInteger64i_v& c =
1616 *static_cast<const gles2::cmds::GetInteger64i_v*>(cmd_data);
1617 (void)c;
1618 GLenum pname = static_cast<GLenum>(c.pname);
1619 GLuint index = static_cast<GLuint>(c.index);
1620 typedef cmds::GetInteger64i_v::Result Result;
1621 GLsizei num_values = 0;
1622 GetNumValuesReturnedForGLGet(pname, &num_values);
1623 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1624 Result::ComputeSize(num_values));
1625 GLint64* data = result ? result->GetData() : NULL;
1626 if (data == NULL) {
1627 return error::kOutOfBounds;
1629 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64i_v");
1630 // Check that the client initialized the result.
1631 if (result->size != 0) {
1632 return error::kInvalidArguments;
1634 glGetInteger64i_v(pname, index, data);
1635 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64i_v");
1636 if (error == GL_NO_ERROR) {
1637 result->SetNumResults(num_values);
1639 return error::kNoError;
1642 error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size,
1643 const void* cmd_data) {
1644 const gles2::cmds::GetIntegerv& c =
1645 *static_cast<const gles2::cmds::GetIntegerv*>(cmd_data);
1646 (void)c;
1647 GLenum pname = static_cast<GLenum>(c.pname);
1648 typedef cmds::GetIntegerv::Result Result;
1649 GLsizei num_values = 0;
1650 GetNumValuesReturnedForGLGet(pname, &num_values);
1651 Result* result = GetSharedMemoryAs<Result*>(
1652 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1653 GLint* params = result ? result->GetData() : NULL;
1654 if (!validators_->g_l_state.IsValid(pname)) {
1655 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
1656 return error::kNoError;
1658 if (params == NULL) {
1659 return error::kOutOfBounds;
1661 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1662 // Check that the client initialized the result.
1663 if (result->size != 0) {
1664 return error::kInvalidArguments;
1666 DoGetIntegerv(pname, params);
1667 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegerv");
1668 if (error == GL_NO_ERROR) {
1669 result->SetNumResults(num_values);
1671 return error::kNoError;
1674 error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size,
1675 const void* cmd_data) {
1676 const gles2::cmds::GetProgramiv& c =
1677 *static_cast<const gles2::cmds::GetProgramiv*>(cmd_data);
1678 (void)c;
1679 GLuint program = c.program;
1680 GLenum pname = static_cast<GLenum>(c.pname);
1681 typedef cmds::GetProgramiv::Result Result;
1682 GLsizei num_values = 0;
1683 GetNumValuesReturnedForGLGet(pname, &num_values);
1684 Result* result = GetSharedMemoryAs<Result*>(
1685 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1686 GLint* params = result ? result->GetData() : NULL;
1687 if (!validators_->program_parameter.IsValid(pname)) {
1688 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
1689 return error::kNoError;
1691 if (params == NULL) {
1692 return error::kOutOfBounds;
1694 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1695 // Check that the client initialized the result.
1696 if (result->size != 0) {
1697 return error::kInvalidArguments;
1699 DoGetProgramiv(program, pname, params);
1700 GLenum error = LOCAL_PEEK_GL_ERROR("GetProgramiv");
1701 if (error == GL_NO_ERROR) {
1702 result->SetNumResults(num_values);
1704 return error::kNoError;
1707 error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1708 uint32_t immediate_data_size,
1709 const void* cmd_data) {
1710 const gles2::cmds::GetRenderbufferParameteriv& c =
1711 *static_cast<const gles2::cmds::GetRenderbufferParameteriv*>(cmd_data);
1712 (void)c;
1713 GLenum target = static_cast<GLenum>(c.target);
1714 GLenum pname = static_cast<GLenum>(c.pname);
1715 typedef cmds::GetRenderbufferParameteriv::Result Result;
1716 GLsizei num_values = 0;
1717 GetNumValuesReturnedForGLGet(pname, &num_values);
1718 Result* result = GetSharedMemoryAs<Result*>(
1719 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1720 GLint* params = result ? result->GetData() : NULL;
1721 if (!validators_->render_buffer_target.IsValid(target)) {
1722 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
1723 "target");
1724 return error::kNoError;
1726 if (!validators_->render_buffer_parameter.IsValid(pname)) {
1727 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
1728 "pname");
1729 return error::kNoError;
1731 if (params == NULL) {
1732 return error::kOutOfBounds;
1734 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1735 // Check that the client initialized the result.
1736 if (result->size != 0) {
1737 return error::kInvalidArguments;
1739 DoGetRenderbufferParameteriv(target, pname, params);
1740 GLenum error = LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv");
1741 if (error == GL_NO_ERROR) {
1742 result->SetNumResults(num_values);
1744 return error::kNoError;
1747 error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
1748 uint32_t immediate_data_size,
1749 const void* cmd_data) {
1750 if (!unsafe_es3_apis_enabled())
1751 return error::kUnknownCommand;
1752 const gles2::cmds::GetSamplerParameterfv& c =
1753 *static_cast<const gles2::cmds::GetSamplerParameterfv*>(cmd_data);
1754 (void)c;
1755 GLuint sampler = c.sampler;
1756 GLenum pname = static_cast<GLenum>(c.pname);
1757 typedef cmds::GetSamplerParameterfv::Result Result;
1758 GLsizei num_values = 0;
1759 GetNumValuesReturnedForGLGet(pname, &num_values);
1760 Result* result = GetSharedMemoryAs<Result*>(
1761 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1762 GLfloat* params = result ? result->GetData() : NULL;
1763 if (params == NULL) {
1764 return error::kOutOfBounds;
1766 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1767 // Check that the client initialized the result.
1768 if (result->size != 0) {
1769 return error::kInvalidArguments;
1771 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1772 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameterfv",
1773 "invalid sampler id");
1774 return error::kNoError;
1776 glGetSamplerParameterfv(sampler, pname, params);
1777 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv");
1778 if (error == GL_NO_ERROR) {
1779 result->SetNumResults(num_values);
1781 return error::kNoError;
1784 error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
1785 uint32_t immediate_data_size,
1786 const void* cmd_data) {
1787 if (!unsafe_es3_apis_enabled())
1788 return error::kUnknownCommand;
1789 const gles2::cmds::GetSamplerParameteriv& c =
1790 *static_cast<const gles2::cmds::GetSamplerParameteriv*>(cmd_data);
1791 (void)c;
1792 GLuint sampler = c.sampler;
1793 GLenum pname = static_cast<GLenum>(c.pname);
1794 typedef cmds::GetSamplerParameteriv::Result Result;
1795 GLsizei num_values = 0;
1796 GetNumValuesReturnedForGLGet(pname, &num_values);
1797 Result* result = GetSharedMemoryAs<Result*>(
1798 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1799 GLint* params = result ? result->GetData() : NULL;
1800 if (params == NULL) {
1801 return error::kOutOfBounds;
1803 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1804 // Check that the client initialized the result.
1805 if (result->size != 0) {
1806 return error::kInvalidArguments;
1808 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1809 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameteriv",
1810 "invalid sampler id");
1811 return error::kNoError;
1813 glGetSamplerParameteriv(sampler, pname, params);
1814 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv");
1815 if (error == GL_NO_ERROR) {
1816 result->SetNumResults(num_values);
1818 return error::kNoError;
1821 error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size,
1822 const void* cmd_data) {
1823 const gles2::cmds::GetShaderiv& c =
1824 *static_cast<const gles2::cmds::GetShaderiv*>(cmd_data);
1825 (void)c;
1826 GLuint shader = c.shader;
1827 GLenum pname = static_cast<GLenum>(c.pname);
1828 typedef cmds::GetShaderiv::Result Result;
1829 GLsizei num_values = 0;
1830 GetNumValuesReturnedForGLGet(pname, &num_values);
1831 Result* result = GetSharedMemoryAs<Result*>(
1832 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1833 GLint* params = result ? result->GetData() : NULL;
1834 if (!validators_->shader_parameter.IsValid(pname)) {
1835 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
1836 return error::kNoError;
1838 if (params == NULL) {
1839 return error::kOutOfBounds;
1841 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1842 // Check that the client initialized the result.
1843 if (result->size != 0) {
1844 return error::kInvalidArguments;
1846 DoGetShaderiv(shader, pname, params);
1847 GLenum error = LOCAL_PEEK_GL_ERROR("GetShaderiv");
1848 if (error == GL_NO_ERROR) {
1849 result->SetNumResults(num_values);
1851 return error::kNoError;
1854 error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
1855 const void* cmd_data) {
1856 if (!unsafe_es3_apis_enabled())
1857 return error::kUnknownCommand;
1858 const gles2::cmds::GetSynciv& c =
1859 *static_cast<const gles2::cmds::GetSynciv*>(cmd_data);
1860 (void)c;
1861 GLuint sync = static_cast<GLuint>(c.sync);
1862 GLenum pname = static_cast<GLenum>(c.pname);
1863 typedef cmds::GetSynciv::Result Result;
1864 GLsizei num_values = 0;
1865 GetNumValuesReturnedForGLGet(pname, &num_values);
1866 Result* result = GetSharedMemoryAs<Result*>(
1867 c.values_shm_id, c.values_shm_offset, Result::ComputeSize(num_values));
1868 GLint* values = result ? result->GetData() : NULL;
1869 if (values == NULL) {
1870 return error::kOutOfBounds;
1872 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1873 // Check that the client initialized the result.
1874 if (result->size != 0) {
1875 return error::kInvalidArguments;
1877 GLsync service_sync = 0;
1878 if (!group_->GetSyncServiceId(sync, &service_sync)) {
1879 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSynciv", "invalid sync id");
1880 return error::kNoError;
1882 glGetSynciv(service_sync, pname, num_values, nullptr, values);
1883 GLenum error = LOCAL_PEEK_GL_ERROR("GetSynciv");
1884 if (error == GL_NO_ERROR) {
1885 result->SetNumResults(num_values);
1887 return error::kNoError;
1890 error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
1891 uint32_t immediate_data_size,
1892 const void* cmd_data) {
1893 const gles2::cmds::GetTexParameterfv& c =
1894 *static_cast<const gles2::cmds::GetTexParameterfv*>(cmd_data);
1895 (void)c;
1896 GLenum target = static_cast<GLenum>(c.target);
1897 GLenum pname = static_cast<GLenum>(c.pname);
1898 typedef cmds::GetTexParameterfv::Result Result;
1899 GLsizei num_values = 0;
1900 GetNumValuesReturnedForGLGet(pname, &num_values);
1901 Result* result = GetSharedMemoryAs<Result*>(
1902 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1903 GLfloat* params = result ? result->GetData() : NULL;
1904 if (!validators_->get_tex_param_target.IsValid(target)) {
1905 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
1906 return error::kNoError;
1908 if (!validators_->texture_parameter.IsValid(pname)) {
1909 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
1910 return error::kNoError;
1912 if (params == NULL) {
1913 return error::kOutOfBounds;
1915 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1916 // Check that the client initialized the result.
1917 if (result->size != 0) {
1918 return error::kInvalidArguments;
1920 DoGetTexParameterfv(target, pname, params);
1921 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameterfv");
1922 if (error == GL_NO_ERROR) {
1923 result->SetNumResults(num_values);
1925 return error::kNoError;
1928 error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
1929 uint32_t immediate_data_size,
1930 const void* cmd_data) {
1931 const gles2::cmds::GetTexParameteriv& c =
1932 *static_cast<const gles2::cmds::GetTexParameteriv*>(cmd_data);
1933 (void)c;
1934 GLenum target = static_cast<GLenum>(c.target);
1935 GLenum pname = static_cast<GLenum>(c.pname);
1936 typedef cmds::GetTexParameteriv::Result Result;
1937 GLsizei num_values = 0;
1938 GetNumValuesReturnedForGLGet(pname, &num_values);
1939 Result* result = GetSharedMemoryAs<Result*>(
1940 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1941 GLint* params = result ? result->GetData() : NULL;
1942 if (!validators_->get_tex_param_target.IsValid(target)) {
1943 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
1944 return error::kNoError;
1946 if (!validators_->texture_parameter.IsValid(pname)) {
1947 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
1948 return error::kNoError;
1950 if (params == NULL) {
1951 return error::kOutOfBounds;
1953 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1954 // Check that the client initialized the result.
1955 if (result->size != 0) {
1956 return error::kInvalidArguments;
1958 DoGetTexParameteriv(target, pname, params);
1959 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameteriv");
1960 if (error == GL_NO_ERROR) {
1961 result->SetNumResults(num_values);
1963 return error::kNoError;
1966 error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
1967 uint32_t immediate_data_size,
1968 const void* cmd_data) {
1969 const gles2::cmds::GetVertexAttribfv& c =
1970 *static_cast<const gles2::cmds::GetVertexAttribfv*>(cmd_data);
1971 (void)c;
1972 GLuint index = static_cast<GLuint>(c.index);
1973 GLenum pname = static_cast<GLenum>(c.pname);
1974 typedef cmds::GetVertexAttribfv::Result Result;
1975 GLsizei num_values = 0;
1976 GetNumValuesReturnedForGLGet(pname, &num_values);
1977 Result* result = GetSharedMemoryAs<Result*>(
1978 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1979 GLfloat* params = result ? result->GetData() : NULL;
1980 if (!validators_->vertex_attribute.IsValid(pname)) {
1981 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
1982 return error::kNoError;
1984 if (params == NULL) {
1985 return error::kOutOfBounds;
1987 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1988 // Check that the client initialized the result.
1989 if (result->size != 0) {
1990 return error::kInvalidArguments;
1992 DoGetVertexAttribfv(index, pname, params);
1993 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribfv");
1994 if (error == GL_NO_ERROR) {
1995 result->SetNumResults(num_values);
1997 return error::kNoError;
2000 error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
2001 uint32_t immediate_data_size,
2002 const void* cmd_data) {
2003 const gles2::cmds::GetVertexAttribiv& c =
2004 *static_cast<const gles2::cmds::GetVertexAttribiv*>(cmd_data);
2005 (void)c;
2006 GLuint index = static_cast<GLuint>(c.index);
2007 GLenum pname = static_cast<GLenum>(c.pname);
2008 typedef cmds::GetVertexAttribiv::Result Result;
2009 GLsizei num_values = 0;
2010 GetNumValuesReturnedForGLGet(pname, &num_values);
2011 Result* result = GetSharedMemoryAs<Result*>(
2012 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2013 GLint* params = result ? result->GetData() : NULL;
2014 if (!validators_->vertex_attribute.IsValid(pname)) {
2015 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
2016 return error::kNoError;
2018 if (params == NULL) {
2019 return error::kOutOfBounds;
2021 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
2022 // Check that the client initialized the result.
2023 if (result->size != 0) {
2024 return error::kInvalidArguments;
2026 DoGetVertexAttribiv(index, pname, params);
2027 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribiv");
2028 if (error == GL_NO_ERROR) {
2029 result->SetNumResults(num_values);
2031 return error::kNoError;
2034 error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv(
2035 uint32_t immediate_data_size,
2036 const void* cmd_data) {
2037 if (!unsafe_es3_apis_enabled())
2038 return error::kUnknownCommand;
2039 const gles2::cmds::GetVertexAttribIiv& c =
2040 *static_cast<const gles2::cmds::GetVertexAttribIiv*>(cmd_data);
2041 (void)c;
2042 GLuint index = static_cast<GLuint>(c.index);
2043 GLenum pname = static_cast<GLenum>(c.pname);
2044 typedef cmds::GetVertexAttribIiv::Result Result;
2045 GLsizei num_values = 0;
2046 GetNumValuesReturnedForGLGet(pname, &num_values);
2047 Result* result = GetSharedMemoryAs<Result*>(
2048 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2049 GLint* params = result ? result->GetData() : NULL;
2050 if (params == NULL) {
2051 return error::kOutOfBounds;
2053 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
2054 // Check that the client initialized the result.
2055 if (result->size != 0) {
2056 return error::kInvalidArguments;
2058 DoGetVertexAttribIiv(index, pname, params);
2059 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv");
2060 if (error == GL_NO_ERROR) {
2061 result->SetNumResults(num_values);
2063 return error::kNoError;
2066 error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv(
2067 uint32_t immediate_data_size,
2068 const void* cmd_data) {
2069 if (!unsafe_es3_apis_enabled())
2070 return error::kUnknownCommand;
2071 const gles2::cmds::GetVertexAttribIuiv& c =
2072 *static_cast<const gles2::cmds::GetVertexAttribIuiv*>(cmd_data);
2073 (void)c;
2074 GLuint index = static_cast<GLuint>(c.index);
2075 GLenum pname = static_cast<GLenum>(c.pname);
2076 typedef cmds::GetVertexAttribIuiv::Result Result;
2077 GLsizei num_values = 0;
2078 GetNumValuesReturnedForGLGet(pname, &num_values);
2079 Result* result = GetSharedMemoryAs<Result*>(
2080 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2081 GLuint* params = result ? result->GetData() : NULL;
2082 if (params == NULL) {
2083 return error::kOutOfBounds;
2085 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
2086 // Check that the client initialized the result.
2087 if (result->size != 0) {
2088 return error::kInvalidArguments;
2090 DoGetVertexAttribIuiv(index, pname, params);
2091 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv");
2092 if (error == GL_NO_ERROR) {
2093 result->SetNumResults(num_values);
2095 return error::kNoError;
2098 error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
2099 const void* cmd_data) {
2100 const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data);
2101 (void)c;
2102 GLenum target = static_cast<GLenum>(c.target);
2103 GLenum mode = static_cast<GLenum>(c.mode);
2104 if (!validators_->hint_target.IsValid(target)) {
2105 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
2106 return error::kNoError;
2108 if (!validators_->hint_mode.IsValid(mode)) {
2109 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
2110 return error::kNoError;
2112 switch (target) {
2113 case GL_GENERATE_MIPMAP_HINT:
2114 if (state_.hint_generate_mipmap != mode) {
2115 state_.hint_generate_mipmap = mode;
2116 glHint(target, mode);
2118 break;
2119 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
2120 if (state_.hint_fragment_shader_derivative != mode) {
2121 state_.hint_fragment_shader_derivative = mode;
2122 glHint(target, mode);
2124 break;
2125 default:
2126 NOTREACHED();
2128 return error::kNoError;
2131 error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
2132 uint32_t immediate_data_size,
2133 const void* cmd_data) {
2134 if (!unsafe_es3_apis_enabled())
2135 return error::kUnknownCommand;
2136 const gles2::cmds::InvalidateFramebufferImmediate& c =
2137 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate*>(
2138 cmd_data);
2139 (void)c;
2140 GLenum target = static_cast<GLenum>(c.target);
2141 GLsizei count = static_cast<GLsizei>(c.count);
2142 uint32_t data_size;
2143 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2144 return error::kOutOfBounds;
2146 if (data_size > immediate_data_size) {
2147 return error::kOutOfBounds;
2149 const GLenum* attachments =
2150 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2151 if (attachments == NULL) {
2152 return error::kOutOfBounds;
2154 glInvalidateFramebuffer(target, count, attachments);
2155 return error::kNoError;
2158 error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2159 uint32_t immediate_data_size,
2160 const void* cmd_data) {
2161 if (!unsafe_es3_apis_enabled())
2162 return error::kUnknownCommand;
2163 const gles2::cmds::InvalidateSubFramebufferImmediate& c =
2164 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate*>(
2165 cmd_data);
2166 (void)c;
2167 GLenum target = static_cast<GLenum>(c.target);
2168 GLsizei count = static_cast<GLsizei>(c.count);
2169 uint32_t data_size;
2170 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2171 return error::kOutOfBounds;
2173 if (data_size > immediate_data_size) {
2174 return error::kOutOfBounds;
2176 const GLenum* attachments =
2177 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2178 GLint x = static_cast<GLint>(c.x);
2179 GLint y = static_cast<GLint>(c.y);
2180 GLsizei width = static_cast<GLsizei>(c.width);
2181 GLsizei height = static_cast<GLsizei>(c.height);
2182 if (attachments == NULL) {
2183 return error::kOutOfBounds;
2185 glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height);
2186 return error::kNoError;
2189 error::Error GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size,
2190 const void* cmd_data) {
2191 const gles2::cmds::IsBuffer& c =
2192 *static_cast<const gles2::cmds::IsBuffer*>(cmd_data);
2193 (void)c;
2194 GLuint buffer = c.buffer;
2195 typedef cmds::IsBuffer::Result Result;
2196 Result* result_dst = GetSharedMemoryAs<Result*>(
2197 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2198 if (!result_dst) {
2199 return error::kOutOfBounds;
2201 *result_dst = DoIsBuffer(buffer);
2202 return error::kNoError;
2205 error::Error GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size,
2206 const void* cmd_data) {
2207 const gles2::cmds::IsEnabled& c =
2208 *static_cast<const gles2::cmds::IsEnabled*>(cmd_data);
2209 (void)c;
2210 GLenum cap = static_cast<GLenum>(c.cap);
2211 typedef cmds::IsEnabled::Result Result;
2212 Result* result_dst = GetSharedMemoryAs<Result*>(
2213 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2214 if (!result_dst) {
2215 return error::kOutOfBounds;
2217 if (!validators_->capability.IsValid(cap)) {
2218 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap, "cap");
2219 return error::kNoError;
2221 *result_dst = DoIsEnabled(cap);
2222 return error::kNoError;
2225 error::Error GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size,
2226 const void* cmd_data) {
2227 const gles2::cmds::IsFramebuffer& c =
2228 *static_cast<const gles2::cmds::IsFramebuffer*>(cmd_data);
2229 (void)c;
2230 GLuint framebuffer = c.framebuffer;
2231 typedef cmds::IsFramebuffer::Result Result;
2232 Result* result_dst = GetSharedMemoryAs<Result*>(
2233 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2234 if (!result_dst) {
2235 return error::kOutOfBounds;
2237 *result_dst = DoIsFramebuffer(framebuffer);
2238 return error::kNoError;
2241 error::Error GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size,
2242 const void* cmd_data) {
2243 const gles2::cmds::IsProgram& c =
2244 *static_cast<const gles2::cmds::IsProgram*>(cmd_data);
2245 (void)c;
2246 GLuint program = c.program;
2247 typedef cmds::IsProgram::Result Result;
2248 Result* result_dst = GetSharedMemoryAs<Result*>(
2249 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2250 if (!result_dst) {
2251 return error::kOutOfBounds;
2253 *result_dst = DoIsProgram(program);
2254 return error::kNoError;
2257 error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
2258 uint32_t immediate_data_size,
2259 const void* cmd_data) {
2260 const gles2::cmds::IsRenderbuffer& c =
2261 *static_cast<const gles2::cmds::IsRenderbuffer*>(cmd_data);
2262 (void)c;
2263 GLuint renderbuffer = c.renderbuffer;
2264 typedef cmds::IsRenderbuffer::Result Result;
2265 Result* result_dst = GetSharedMemoryAs<Result*>(
2266 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2267 if (!result_dst) {
2268 return error::kOutOfBounds;
2270 *result_dst = DoIsRenderbuffer(renderbuffer);
2271 return error::kNoError;
2274 error::Error GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size,
2275 const void* cmd_data) {
2276 if (!unsafe_es3_apis_enabled())
2277 return error::kUnknownCommand;
2278 const gles2::cmds::IsSampler& c =
2279 *static_cast<const gles2::cmds::IsSampler*>(cmd_data);
2280 (void)c;
2281 GLuint sampler = c.sampler;
2282 typedef cmds::IsSampler::Result Result;
2283 Result* result_dst = GetSharedMemoryAs<Result*>(
2284 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2285 if (!result_dst) {
2286 return error::kOutOfBounds;
2288 GLuint service_sampler = 0;
2289 *result_dst = group_->GetSamplerServiceId(sampler, &service_sampler);
2290 return error::kNoError;
2293 error::Error GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size,
2294 const void* cmd_data) {
2295 const gles2::cmds::IsShader& c =
2296 *static_cast<const gles2::cmds::IsShader*>(cmd_data);
2297 (void)c;
2298 GLuint shader = c.shader;
2299 typedef cmds::IsShader::Result Result;
2300 Result* result_dst = GetSharedMemoryAs<Result*>(
2301 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2302 if (!result_dst) {
2303 return error::kOutOfBounds;
2305 *result_dst = DoIsShader(shader);
2306 return error::kNoError;
2309 error::Error GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size,
2310 const void* cmd_data) {
2311 if (!unsafe_es3_apis_enabled())
2312 return error::kUnknownCommand;
2313 const gles2::cmds::IsSync& c =
2314 *static_cast<const gles2::cmds::IsSync*>(cmd_data);
2315 (void)c;
2316 GLuint sync = c.sync;
2317 typedef cmds::IsSync::Result Result;
2318 Result* result_dst = GetSharedMemoryAs<Result*>(
2319 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2320 if (!result_dst) {
2321 return error::kOutOfBounds;
2323 GLsync service_sync = 0;
2324 *result_dst = group_->GetSyncServiceId(sync, &service_sync);
2325 return error::kNoError;
2328 error::Error GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size,
2329 const void* cmd_data) {
2330 const gles2::cmds::IsTexture& c =
2331 *static_cast<const gles2::cmds::IsTexture*>(cmd_data);
2332 (void)c;
2333 GLuint texture = c.texture;
2334 typedef cmds::IsTexture::Result Result;
2335 Result* result_dst = GetSharedMemoryAs<Result*>(
2336 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2337 if (!result_dst) {
2338 return error::kOutOfBounds;
2340 *result_dst = DoIsTexture(texture);
2341 return error::kNoError;
2344 error::Error GLES2DecoderImpl::HandleIsTransformFeedback(
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::IsTransformFeedback& c =
2350 *static_cast<const gles2::cmds::IsTransformFeedback*>(cmd_data);
2351 (void)c;
2352 GLuint transformfeedback = c.transformfeedback;
2353 typedef cmds::IsTransformFeedback::Result Result;
2354 Result* result_dst = GetSharedMemoryAs<Result*>(
2355 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2356 if (!result_dst) {
2357 return error::kOutOfBounds;
2359 GLuint service_transformfeedback = 0;
2360 *result_dst = group_->GetTransformFeedbackServiceId(
2361 transformfeedback, &service_transformfeedback);
2362 return error::kNoError;
2365 error::Error GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size,
2366 const void* cmd_data) {
2367 const gles2::cmds::LineWidth& c =
2368 *static_cast<const gles2::cmds::LineWidth*>(cmd_data);
2369 (void)c;
2370 GLfloat width = static_cast<GLfloat>(c.width);
2371 if (width <= 0.0f || std::isnan(width)) {
2372 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "LineWidth", "width out of range");
2373 return error::kNoError;
2375 if (state_.line_width != width) {
2376 state_.line_width = width;
2377 glLineWidth(width);
2379 return error::kNoError;
2382 error::Error GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size,
2383 const void* cmd_data) {
2384 const gles2::cmds::LinkProgram& c =
2385 *static_cast<const gles2::cmds::LinkProgram*>(cmd_data);
2386 (void)c;
2387 GLuint program = c.program;
2388 DoLinkProgram(program);
2389 return error::kNoError;
2392 error::Error GLES2DecoderImpl::HandlePauseTransformFeedback(
2393 uint32_t immediate_data_size,
2394 const void* cmd_data) {
2395 if (!unsafe_es3_apis_enabled())
2396 return error::kUnknownCommand;
2397 const gles2::cmds::PauseTransformFeedback& c =
2398 *static_cast<const gles2::cmds::PauseTransformFeedback*>(cmd_data);
2399 (void)c;
2400 glPauseTransformFeedback();
2401 return error::kNoError;
2404 error::Error GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size,
2405 const void* cmd_data) {
2406 const gles2::cmds::PolygonOffset& c =
2407 *static_cast<const gles2::cmds::PolygonOffset*>(cmd_data);
2408 (void)c;
2409 GLfloat factor = static_cast<GLfloat>(c.factor);
2410 GLfloat units = static_cast<GLfloat>(c.units);
2411 if (state_.polygon_offset_factor != factor ||
2412 state_.polygon_offset_units != units) {
2413 state_.polygon_offset_factor = factor;
2414 state_.polygon_offset_units = units;
2415 glPolygonOffset(factor, units);
2417 return error::kNoError;
2420 error::Error GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size,
2421 const void* cmd_data) {
2422 if (!unsafe_es3_apis_enabled())
2423 return error::kUnknownCommand;
2424 const gles2::cmds::ReadBuffer& c =
2425 *static_cast<const gles2::cmds::ReadBuffer*>(cmd_data);
2426 (void)c;
2427 GLenum src = static_cast<GLenum>(c.src);
2428 DoReadBuffer(src);
2429 return error::kNoError;
2432 error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler(
2433 uint32_t immediate_data_size,
2434 const void* cmd_data) {
2435 const gles2::cmds::ReleaseShaderCompiler& c =
2436 *static_cast<const gles2::cmds::ReleaseShaderCompiler*>(cmd_data);
2437 (void)c;
2438 DoReleaseShaderCompiler();
2439 return error::kNoError;
2442 error::Error GLES2DecoderImpl::HandleRenderbufferStorage(
2443 uint32_t immediate_data_size,
2444 const void* cmd_data) {
2445 const gles2::cmds::RenderbufferStorage& c =
2446 *static_cast<const gles2::cmds::RenderbufferStorage*>(cmd_data);
2447 (void)c;
2448 GLenum target = static_cast<GLenum>(c.target);
2449 GLenum internalformat = static_cast<GLenum>(c.internalformat);
2450 GLsizei width = static_cast<GLsizei>(c.width);
2451 GLsizei height = static_cast<GLsizei>(c.height);
2452 if (!validators_->render_buffer_target.IsValid(target)) {
2453 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target, "target");
2454 return error::kNoError;
2456 if (!validators_->render_buffer_format.IsValid(internalformat)) {
2457 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat,
2458 "internalformat");
2459 return error::kNoError;
2461 if (width < 0) {
2462 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
2463 return error::kNoError;
2465 if (height < 0) {
2466 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
2467 return error::kNoError;
2469 DoRenderbufferStorage(target, internalformat, width, height);
2470 return error::kNoError;
2473 error::Error GLES2DecoderImpl::HandleResumeTransformFeedback(
2474 uint32_t immediate_data_size,
2475 const void* cmd_data) {
2476 if (!unsafe_es3_apis_enabled())
2477 return error::kUnknownCommand;
2478 const gles2::cmds::ResumeTransformFeedback& c =
2479 *static_cast<const gles2::cmds::ResumeTransformFeedback*>(cmd_data);
2480 (void)c;
2481 glResumeTransformFeedback();
2482 return error::kNoError;
2485 error::Error GLES2DecoderImpl::HandleSampleCoverage(
2486 uint32_t immediate_data_size,
2487 const void* cmd_data) {
2488 const gles2::cmds::SampleCoverage& c =
2489 *static_cast<const gles2::cmds::SampleCoverage*>(cmd_data);
2490 (void)c;
2491 GLclampf value = static_cast<GLclampf>(c.value);
2492 GLboolean invert = static_cast<GLboolean>(c.invert);
2493 DoSampleCoverage(value, invert);
2494 return error::kNoError;
2497 error::Error GLES2DecoderImpl::HandleSamplerParameterf(
2498 uint32_t immediate_data_size,
2499 const void* cmd_data) {
2500 if (!unsafe_es3_apis_enabled())
2501 return error::kUnknownCommand;
2502 const gles2::cmds::SamplerParameterf& c =
2503 *static_cast<const gles2::cmds::SamplerParameterf*>(cmd_data);
2504 (void)c;
2505 GLuint sampler = c.sampler;
2506 GLenum pname = static_cast<GLenum>(c.pname);
2507 GLfloat param = static_cast<GLfloat>(c.param);
2508 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2509 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameterf",
2510 "invalid sampler id");
2511 return error::kNoError;
2513 glSamplerParameterf(sampler, pname, param);
2514 return error::kNoError;
2517 error::Error GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2518 uint32_t immediate_data_size,
2519 const void* cmd_data) {
2520 if (!unsafe_es3_apis_enabled())
2521 return error::kUnknownCommand;
2522 const gles2::cmds::SamplerParameterfvImmediate& c =
2523 *static_cast<const gles2::cmds::SamplerParameterfvImmediate*>(cmd_data);
2524 (void)c;
2525 GLuint sampler = c.sampler;
2526 GLenum pname = static_cast<GLenum>(c.pname);
2527 uint32_t data_size;
2528 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2529 return error::kOutOfBounds;
2531 if (data_size > immediate_data_size) {
2532 return error::kOutOfBounds;
2534 const GLfloat* params =
2535 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2536 if (params == NULL) {
2537 return error::kOutOfBounds;
2539 group_->GetSamplerServiceId(sampler, &sampler);
2540 DoSamplerParameterfv(sampler, pname, params);
2541 return error::kNoError;
2544 error::Error GLES2DecoderImpl::HandleSamplerParameteri(
2545 uint32_t immediate_data_size,
2546 const void* cmd_data) {
2547 if (!unsafe_es3_apis_enabled())
2548 return error::kUnknownCommand;
2549 const gles2::cmds::SamplerParameteri& c =
2550 *static_cast<const gles2::cmds::SamplerParameteri*>(cmd_data);
2551 (void)c;
2552 GLuint sampler = c.sampler;
2553 GLenum pname = static_cast<GLenum>(c.pname);
2554 GLint param = static_cast<GLint>(c.param);
2555 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2556 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameteri",
2557 "invalid sampler id");
2558 return error::kNoError;
2560 glSamplerParameteri(sampler, pname, param);
2561 return error::kNoError;
2564 error::Error GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2565 uint32_t immediate_data_size,
2566 const void* cmd_data) {
2567 if (!unsafe_es3_apis_enabled())
2568 return error::kUnknownCommand;
2569 const gles2::cmds::SamplerParameterivImmediate& c =
2570 *static_cast<const gles2::cmds::SamplerParameterivImmediate*>(cmd_data);
2571 (void)c;
2572 GLuint sampler = c.sampler;
2573 GLenum pname = static_cast<GLenum>(c.pname);
2574 uint32_t data_size;
2575 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2576 return error::kOutOfBounds;
2578 if (data_size > immediate_data_size) {
2579 return error::kOutOfBounds;
2581 const GLint* params =
2582 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2583 if (params == NULL) {
2584 return error::kOutOfBounds;
2586 DoSamplerParameteriv(sampler, pname, params);
2587 return error::kNoError;
2590 error::Error GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size,
2591 const void* cmd_data) {
2592 const gles2::cmds::Scissor& c =
2593 *static_cast<const gles2::cmds::Scissor*>(cmd_data);
2594 (void)c;
2595 GLint x = static_cast<GLint>(c.x);
2596 GLint y = static_cast<GLint>(c.y);
2597 GLsizei width = static_cast<GLsizei>(c.width);
2598 GLsizei height = static_cast<GLsizei>(c.height);
2599 if (width < 0) {
2600 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "width < 0");
2601 return error::kNoError;
2603 if (height < 0) {
2604 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "height < 0");
2605 return error::kNoError;
2607 if (state_.scissor_x != x || state_.scissor_y != y ||
2608 state_.scissor_width != width || state_.scissor_height != height) {
2609 state_.scissor_x = x;
2610 state_.scissor_y = y;
2611 state_.scissor_width = width;
2612 state_.scissor_height = height;
2613 glScissor(x, y, width, height);
2615 return error::kNoError;
2618 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2619 uint32_t immediate_data_size,
2620 const void* cmd_data) {
2621 const gles2::cmds::ShaderSourceBucket& c =
2622 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data);
2623 (void)c;
2624 GLuint shader = static_cast<GLuint>(c.shader);
2626 Bucket* bucket = GetBucket(c.str_bucket_id);
2627 if (!bucket) {
2628 return error::kInvalidArguments;
2630 GLsizei count = 0;
2631 std::vector<char*> strs;
2632 std::vector<GLint> len;
2633 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2634 return error::kInvalidArguments;
2636 const char** str =
2637 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2638 const GLint* length =
2639 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2640 (void)length;
2641 DoShaderSource(shader, count, str, length);
2642 return error::kNoError;
2645 error::Error GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size,
2646 const void* cmd_data) {
2647 const gles2::cmds::StencilFunc& c =
2648 *static_cast<const gles2::cmds::StencilFunc*>(cmd_data);
2649 (void)c;
2650 GLenum func = static_cast<GLenum>(c.func);
2651 GLint ref = static_cast<GLint>(c.ref);
2652 GLuint mask = static_cast<GLuint>(c.mask);
2653 if (!validators_->cmp_function.IsValid(func)) {
2654 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func, "func");
2655 return error::kNoError;
2657 if (state_.stencil_front_func != func || state_.stencil_front_ref != ref ||
2658 state_.stencil_front_mask != mask || state_.stencil_back_func != func ||
2659 state_.stencil_back_ref != ref || state_.stencil_back_mask != mask) {
2660 state_.stencil_front_func = func;
2661 state_.stencil_front_ref = ref;
2662 state_.stencil_front_mask = mask;
2663 state_.stencil_back_func = func;
2664 state_.stencil_back_ref = ref;
2665 state_.stencil_back_mask = mask;
2666 glStencilFunc(func, ref, mask);
2668 return error::kNoError;
2671 error::Error GLES2DecoderImpl::HandleStencilFuncSeparate(
2672 uint32_t immediate_data_size,
2673 const void* cmd_data) {
2674 const gles2::cmds::StencilFuncSeparate& c =
2675 *static_cast<const gles2::cmds::StencilFuncSeparate*>(cmd_data);
2676 (void)c;
2677 GLenum face = static_cast<GLenum>(c.face);
2678 GLenum func = static_cast<GLenum>(c.func);
2679 GLint ref = static_cast<GLint>(c.ref);
2680 GLuint mask = static_cast<GLuint>(c.mask);
2681 if (!validators_->face_type.IsValid(face)) {
2682 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face, "face");
2683 return error::kNoError;
2685 if (!validators_->cmp_function.IsValid(func)) {
2686 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func, "func");
2687 return error::kNoError;
2689 bool changed = false;
2690 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2691 changed |= state_.stencil_front_func != func ||
2692 state_.stencil_front_ref != ref ||
2693 state_.stencil_front_mask != mask;
2695 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2696 changed |= state_.stencil_back_func != func ||
2697 state_.stencil_back_ref != ref ||
2698 state_.stencil_back_mask != mask;
2700 if (changed) {
2701 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2702 state_.stencil_front_func = func;
2703 state_.stencil_front_ref = ref;
2704 state_.stencil_front_mask = mask;
2706 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2707 state_.stencil_back_func = func;
2708 state_.stencil_back_ref = ref;
2709 state_.stencil_back_mask = mask;
2711 glStencilFuncSeparate(face, func, ref, mask);
2713 return error::kNoError;
2716 error::Error GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size,
2717 const void* cmd_data) {
2718 const gles2::cmds::StencilMask& c =
2719 *static_cast<const gles2::cmds::StencilMask*>(cmd_data);
2720 (void)c;
2721 GLuint mask = static_cast<GLuint>(c.mask);
2722 if (state_.stencil_front_writemask != mask ||
2723 state_.stencil_back_writemask != mask) {
2724 state_.stencil_front_writemask = mask;
2725 state_.stencil_back_writemask = mask;
2726 framebuffer_state_.clear_state_dirty = true;
2728 return error::kNoError;
2731 error::Error GLES2DecoderImpl::HandleStencilMaskSeparate(
2732 uint32_t immediate_data_size,
2733 const void* cmd_data) {
2734 const gles2::cmds::StencilMaskSeparate& c =
2735 *static_cast<const gles2::cmds::StencilMaskSeparate*>(cmd_data);
2736 (void)c;
2737 GLenum face = static_cast<GLenum>(c.face);
2738 GLuint mask = static_cast<GLuint>(c.mask);
2739 if (!validators_->face_type.IsValid(face)) {
2740 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face, "face");
2741 return error::kNoError;
2743 bool changed = false;
2744 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2745 changed |= state_.stencil_front_writemask != mask;
2747 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2748 changed |= state_.stencil_back_writemask != mask;
2750 if (changed) {
2751 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2752 state_.stencil_front_writemask = mask;
2754 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2755 state_.stencil_back_writemask = mask;
2757 framebuffer_state_.clear_state_dirty = true;
2759 return error::kNoError;
2762 error::Error GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size,
2763 const void* cmd_data) {
2764 const gles2::cmds::StencilOp& c =
2765 *static_cast<const gles2::cmds::StencilOp*>(cmd_data);
2766 (void)c;
2767 GLenum fail = static_cast<GLenum>(c.fail);
2768 GLenum zfail = static_cast<GLenum>(c.zfail);
2769 GLenum zpass = static_cast<GLenum>(c.zpass);
2770 if (!validators_->stencil_op.IsValid(fail)) {
2771 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail, "fail");
2772 return error::kNoError;
2774 if (!validators_->stencil_op.IsValid(zfail)) {
2775 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail, "zfail");
2776 return error::kNoError;
2778 if (!validators_->stencil_op.IsValid(zpass)) {
2779 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass, "zpass");
2780 return error::kNoError;
2782 if (state_.stencil_front_fail_op != fail ||
2783 state_.stencil_front_z_fail_op != zfail ||
2784 state_.stencil_front_z_pass_op != zpass ||
2785 state_.stencil_back_fail_op != fail ||
2786 state_.stencil_back_z_fail_op != zfail ||
2787 state_.stencil_back_z_pass_op != zpass) {
2788 state_.stencil_front_fail_op = fail;
2789 state_.stencil_front_z_fail_op = zfail;
2790 state_.stencil_front_z_pass_op = zpass;
2791 state_.stencil_back_fail_op = fail;
2792 state_.stencil_back_z_fail_op = zfail;
2793 state_.stencil_back_z_pass_op = zpass;
2794 glStencilOp(fail, zfail, zpass);
2796 return error::kNoError;
2799 error::Error GLES2DecoderImpl::HandleStencilOpSeparate(
2800 uint32_t immediate_data_size,
2801 const void* cmd_data) {
2802 const gles2::cmds::StencilOpSeparate& c =
2803 *static_cast<const gles2::cmds::StencilOpSeparate*>(cmd_data);
2804 (void)c;
2805 GLenum face = static_cast<GLenum>(c.face);
2806 GLenum fail = static_cast<GLenum>(c.fail);
2807 GLenum zfail = static_cast<GLenum>(c.zfail);
2808 GLenum zpass = static_cast<GLenum>(c.zpass);
2809 if (!validators_->face_type.IsValid(face)) {
2810 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face, "face");
2811 return error::kNoError;
2813 if (!validators_->stencil_op.IsValid(fail)) {
2814 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail, "fail");
2815 return error::kNoError;
2817 if (!validators_->stencil_op.IsValid(zfail)) {
2818 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail, "zfail");
2819 return error::kNoError;
2821 if (!validators_->stencil_op.IsValid(zpass)) {
2822 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass, "zpass");
2823 return error::kNoError;
2825 bool changed = false;
2826 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2827 changed |= state_.stencil_front_fail_op != fail ||
2828 state_.stencil_front_z_fail_op != zfail ||
2829 state_.stencil_front_z_pass_op != zpass;
2831 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2832 changed |= state_.stencil_back_fail_op != fail ||
2833 state_.stencil_back_z_fail_op != zfail ||
2834 state_.stencil_back_z_pass_op != zpass;
2836 if (changed) {
2837 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2838 state_.stencil_front_fail_op = fail;
2839 state_.stencil_front_z_fail_op = zfail;
2840 state_.stencil_front_z_pass_op = zpass;
2842 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2843 state_.stencil_back_fail_op = fail;
2844 state_.stencil_back_z_fail_op = zfail;
2845 state_.stencil_back_z_pass_op = zpass;
2847 glStencilOpSeparate(face, fail, zfail, zpass);
2849 return error::kNoError;
2852 error::Error GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size,
2853 const void* cmd_data) {
2854 const gles2::cmds::TexParameterf& c =
2855 *static_cast<const gles2::cmds::TexParameterf*>(cmd_data);
2856 (void)c;
2857 GLenum target = static_cast<GLenum>(c.target);
2858 GLenum pname = static_cast<GLenum>(c.pname);
2859 GLfloat param = static_cast<GLfloat>(c.param);
2860 if (!validators_->texture_bind_target.IsValid(target)) {
2861 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target, "target");
2862 return error::kNoError;
2864 if (!validators_->texture_parameter.IsValid(pname)) {
2865 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname, "pname");
2866 return error::kNoError;
2868 DoTexParameterf(target, pname, param);
2869 return error::kNoError;
2872 error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
2873 uint32_t immediate_data_size,
2874 const void* cmd_data) {
2875 const gles2::cmds::TexParameterfvImmediate& c =
2876 *static_cast<const gles2::cmds::TexParameterfvImmediate*>(cmd_data);
2877 (void)c;
2878 GLenum target = static_cast<GLenum>(c.target);
2879 GLenum pname = static_cast<GLenum>(c.pname);
2880 uint32_t data_size;
2881 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2882 return error::kOutOfBounds;
2884 if (data_size > immediate_data_size) {
2885 return error::kOutOfBounds;
2887 const GLfloat* params =
2888 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2889 if (!validators_->texture_bind_target.IsValid(target)) {
2890 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target, "target");
2891 return error::kNoError;
2893 if (!validators_->texture_parameter.IsValid(pname)) {
2894 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname, "pname");
2895 return error::kNoError;
2897 if (params == NULL) {
2898 return error::kOutOfBounds;
2900 DoTexParameterfv(target, pname, params);
2901 return error::kNoError;
2904 error::Error GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size,
2905 const void* cmd_data) {
2906 const gles2::cmds::TexParameteri& c =
2907 *static_cast<const gles2::cmds::TexParameteri*>(cmd_data);
2908 (void)c;
2909 GLenum target = static_cast<GLenum>(c.target);
2910 GLenum pname = static_cast<GLenum>(c.pname);
2911 GLint param = static_cast<GLint>(c.param);
2912 if (!validators_->texture_bind_target.IsValid(target)) {
2913 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target, "target");
2914 return error::kNoError;
2916 if (!validators_->texture_parameter.IsValid(pname)) {
2917 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname, "pname");
2918 return error::kNoError;
2920 DoTexParameteri(target, pname, param);
2921 return error::kNoError;
2924 error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
2925 uint32_t immediate_data_size,
2926 const void* cmd_data) {
2927 const gles2::cmds::TexParameterivImmediate& c =
2928 *static_cast<const gles2::cmds::TexParameterivImmediate*>(cmd_data);
2929 (void)c;
2930 GLenum target = static_cast<GLenum>(c.target);
2931 GLenum pname = static_cast<GLenum>(c.pname);
2932 uint32_t data_size;
2933 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2934 return error::kOutOfBounds;
2936 if (data_size > immediate_data_size) {
2937 return error::kOutOfBounds;
2939 const GLint* params =
2940 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2941 if (!validators_->texture_bind_target.IsValid(target)) {
2942 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target, "target");
2943 return error::kNoError;
2945 if (!validators_->texture_parameter.IsValid(pname)) {
2946 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname, "pname");
2947 return error::kNoError;
2949 if (params == NULL) {
2950 return error::kOutOfBounds;
2952 DoTexParameteriv(target, pname, params);
2953 return error::kNoError;
2956 error::Error GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size,
2957 const void* cmd_data) {
2958 if (!unsafe_es3_apis_enabled())
2959 return error::kUnknownCommand;
2960 const gles2::cmds::TexStorage3D& c =
2961 *static_cast<const gles2::cmds::TexStorage3D*>(cmd_data);
2962 (void)c;
2963 GLenum target = static_cast<GLenum>(c.target);
2964 GLsizei levels = static_cast<GLsizei>(c.levels);
2965 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
2966 GLsizei width = static_cast<GLsizei>(c.width);
2967 GLsizei height = static_cast<GLsizei>(c.height);
2968 GLsizei depth = static_cast<GLsizei>(c.depth);
2969 glTexStorage3D(target, levels, internalFormat, width, height, depth);
2970 return error::kNoError;
2973 error::Error GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
2974 uint32_t immediate_data_size,
2975 const void* cmd_data) {
2976 if (!unsafe_es3_apis_enabled())
2977 return error::kUnknownCommand;
2978 const gles2::cmds::TransformFeedbackVaryingsBucket& c =
2979 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket*>(
2980 cmd_data);
2981 (void)c;
2982 GLuint program = static_cast<GLuint>(c.program);
2984 Bucket* bucket = GetBucket(c.varyings_bucket_id);
2985 if (!bucket) {
2986 return error::kInvalidArguments;
2988 GLsizei count = 0;
2989 std::vector<char*> strs;
2990 std::vector<GLint> len;
2991 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2992 return error::kInvalidArguments;
2994 const char** varyings =
2995 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2996 const GLint* length =
2997 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2998 (void)length;
2999 GLenum buffermode = static_cast<GLenum>(c.buffermode);
3000 DoTransformFeedbackVaryings(program, count, varyings, buffermode);
3001 return error::kNoError;
3004 error::Error GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size,
3005 const void* cmd_data) {
3006 const gles2::cmds::Uniform1f& c =
3007 *static_cast<const gles2::cmds::Uniform1f*>(cmd_data);
3008 (void)c;
3009 GLint location = static_cast<GLint>(c.location);
3010 GLfloat x = static_cast<GLfloat>(c.x);
3011 GLfloat temp[1] = {
3014 DoUniform1fv(location, 1, &temp[0]);
3015 return error::kNoError;
3018 error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
3019 uint32_t immediate_data_size,
3020 const void* cmd_data) {
3021 const gles2::cmds::Uniform1fvImmediate& c =
3022 *static_cast<const gles2::cmds::Uniform1fvImmediate*>(cmd_data);
3023 (void)c;
3024 GLint location = static_cast<GLint>(c.location);
3025 GLsizei count = static_cast<GLsizei>(c.count);
3026 uint32_t data_size;
3027 if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
3028 return error::kOutOfBounds;
3030 if (data_size > immediate_data_size) {
3031 return error::kOutOfBounds;
3033 const GLfloat* v =
3034 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3035 if (v == NULL) {
3036 return error::kOutOfBounds;
3038 DoUniform1fv(location, count, v);
3039 return error::kNoError;
3042 error::Error GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size,
3043 const void* cmd_data) {
3044 const gles2::cmds::Uniform1i& c =
3045 *static_cast<const gles2::cmds::Uniform1i*>(cmd_data);
3046 (void)c;
3047 GLint location = static_cast<GLint>(c.location);
3048 GLint x = static_cast<GLint>(c.x);
3049 DoUniform1i(location, x);
3050 return error::kNoError;
3053 error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
3054 uint32_t immediate_data_size,
3055 const void* cmd_data) {
3056 const gles2::cmds::Uniform1ivImmediate& c =
3057 *static_cast<const gles2::cmds::Uniform1ivImmediate*>(cmd_data);
3058 (void)c;
3059 GLint location = static_cast<GLint>(c.location);
3060 GLsizei count = static_cast<GLsizei>(c.count);
3061 uint32_t data_size;
3062 if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
3063 return error::kOutOfBounds;
3065 if (data_size > immediate_data_size) {
3066 return error::kOutOfBounds;
3068 const GLint* v =
3069 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3070 if (v == NULL) {
3071 return error::kOutOfBounds;
3073 DoUniform1iv(location, count, v);
3074 return error::kNoError;
3077 error::Error GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size,
3078 const void* cmd_data) {
3079 if (!unsafe_es3_apis_enabled())
3080 return error::kUnknownCommand;
3081 const gles2::cmds::Uniform1ui& c =
3082 *static_cast<const gles2::cmds::Uniform1ui*>(cmd_data);
3083 (void)c;
3084 GLint location = static_cast<GLint>(c.location);
3085 GLuint x = static_cast<GLuint>(c.x);
3086 GLuint temp[1] = {
3089 glUniform1uiv(location, 1, &temp[0]);
3090 return error::kNoError;
3093 error::Error GLES2DecoderImpl::HandleUniform1uivImmediate(
3094 uint32_t immediate_data_size,
3095 const void* cmd_data) {
3096 if (!unsafe_es3_apis_enabled())
3097 return error::kUnknownCommand;
3098 const gles2::cmds::Uniform1uivImmediate& c =
3099 *static_cast<const gles2::cmds::Uniform1uivImmediate*>(cmd_data);
3100 (void)c;
3101 GLint location = static_cast<GLint>(c.location);
3102 GLsizei count = static_cast<GLsizei>(c.count);
3103 uint32_t data_size;
3104 if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) {
3105 return error::kOutOfBounds;
3107 if (data_size > immediate_data_size) {
3108 return error::kOutOfBounds;
3110 const GLuint* v =
3111 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3112 if (v == NULL) {
3113 return error::kOutOfBounds;
3115 glUniform1uiv(location, count, v);
3116 return error::kNoError;
3119 error::Error GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size,
3120 const void* cmd_data) {
3121 const gles2::cmds::Uniform2f& c =
3122 *static_cast<const gles2::cmds::Uniform2f*>(cmd_data);
3123 (void)c;
3124 GLint location = static_cast<GLint>(c.location);
3125 GLfloat x = static_cast<GLfloat>(c.x);
3126 GLfloat y = static_cast<GLfloat>(c.y);
3127 GLfloat temp[2] = {
3128 x, y,
3130 DoUniform2fv(location, 1, &temp[0]);
3131 return error::kNoError;
3134 error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
3135 uint32_t immediate_data_size,
3136 const void* cmd_data) {
3137 const gles2::cmds::Uniform2fvImmediate& c =
3138 *static_cast<const gles2::cmds::Uniform2fvImmediate*>(cmd_data);
3139 (void)c;
3140 GLint location = static_cast<GLint>(c.location);
3141 GLsizei count = static_cast<GLsizei>(c.count);
3142 uint32_t data_size;
3143 if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
3144 return error::kOutOfBounds;
3146 if (data_size > immediate_data_size) {
3147 return error::kOutOfBounds;
3149 const GLfloat* v =
3150 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3151 if (v == NULL) {
3152 return error::kOutOfBounds;
3154 DoUniform2fv(location, count, v);
3155 return error::kNoError;
3158 error::Error GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size,
3159 const void* cmd_data) {
3160 const gles2::cmds::Uniform2i& c =
3161 *static_cast<const gles2::cmds::Uniform2i*>(cmd_data);
3162 (void)c;
3163 GLint location = static_cast<GLint>(c.location);
3164 GLint x = static_cast<GLint>(c.x);
3165 GLint y = static_cast<GLint>(c.y);
3166 GLint temp[2] = {
3167 x, y,
3169 DoUniform2iv(location, 1, &temp[0]);
3170 return error::kNoError;
3173 error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
3174 uint32_t immediate_data_size,
3175 const void* cmd_data) {
3176 const gles2::cmds::Uniform2ivImmediate& c =
3177 *static_cast<const gles2::cmds::Uniform2ivImmediate*>(cmd_data);
3178 (void)c;
3179 GLint location = static_cast<GLint>(c.location);
3180 GLsizei count = static_cast<GLsizei>(c.count);
3181 uint32_t data_size;
3182 if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
3183 return error::kOutOfBounds;
3185 if (data_size > immediate_data_size) {
3186 return error::kOutOfBounds;
3188 const GLint* v =
3189 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3190 if (v == NULL) {
3191 return error::kOutOfBounds;
3193 DoUniform2iv(location, count, v);
3194 return error::kNoError;
3197 error::Error GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size,
3198 const void* cmd_data) {
3199 if (!unsafe_es3_apis_enabled())
3200 return error::kUnknownCommand;
3201 const gles2::cmds::Uniform2ui& c =
3202 *static_cast<const gles2::cmds::Uniform2ui*>(cmd_data);
3203 (void)c;
3204 GLint location = static_cast<GLint>(c.location);
3205 GLuint x = static_cast<GLuint>(c.x);
3206 GLuint y = static_cast<GLuint>(c.y);
3207 GLuint temp[2] = {
3208 x, y,
3210 glUniform2uiv(location, 1, &temp[0]);
3211 return error::kNoError;
3214 error::Error GLES2DecoderImpl::HandleUniform2uivImmediate(
3215 uint32_t immediate_data_size,
3216 const void* cmd_data) {
3217 if (!unsafe_es3_apis_enabled())
3218 return error::kUnknownCommand;
3219 const gles2::cmds::Uniform2uivImmediate& c =
3220 *static_cast<const gles2::cmds::Uniform2uivImmediate*>(cmd_data);
3221 (void)c;
3222 GLint location = static_cast<GLint>(c.location);
3223 GLsizei count = static_cast<GLsizei>(c.count);
3224 uint32_t data_size;
3225 if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) {
3226 return error::kOutOfBounds;
3228 if (data_size > immediate_data_size) {
3229 return error::kOutOfBounds;
3231 const GLuint* v =
3232 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3233 if (v == NULL) {
3234 return error::kOutOfBounds;
3236 glUniform2uiv(location, count, v);
3237 return error::kNoError;
3240 error::Error GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size,
3241 const void* cmd_data) {
3242 const gles2::cmds::Uniform3f& c =
3243 *static_cast<const gles2::cmds::Uniform3f*>(cmd_data);
3244 (void)c;
3245 GLint location = static_cast<GLint>(c.location);
3246 GLfloat x = static_cast<GLfloat>(c.x);
3247 GLfloat y = static_cast<GLfloat>(c.y);
3248 GLfloat z = static_cast<GLfloat>(c.z);
3249 GLfloat temp[3] = {
3250 x, y, z,
3252 DoUniform3fv(location, 1, &temp[0]);
3253 return error::kNoError;
3256 error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
3257 uint32_t immediate_data_size,
3258 const void* cmd_data) {
3259 const gles2::cmds::Uniform3fvImmediate& c =
3260 *static_cast<const gles2::cmds::Uniform3fvImmediate*>(cmd_data);
3261 (void)c;
3262 GLint location = static_cast<GLint>(c.location);
3263 GLsizei count = static_cast<GLsizei>(c.count);
3264 uint32_t data_size;
3265 if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
3266 return error::kOutOfBounds;
3268 if (data_size > immediate_data_size) {
3269 return error::kOutOfBounds;
3271 const GLfloat* v =
3272 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3273 if (v == NULL) {
3274 return error::kOutOfBounds;
3276 DoUniform3fv(location, count, v);
3277 return error::kNoError;
3280 error::Error GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size,
3281 const void* cmd_data) {
3282 const gles2::cmds::Uniform3i& c =
3283 *static_cast<const gles2::cmds::Uniform3i*>(cmd_data);
3284 (void)c;
3285 GLint location = static_cast<GLint>(c.location);
3286 GLint x = static_cast<GLint>(c.x);
3287 GLint y = static_cast<GLint>(c.y);
3288 GLint z = static_cast<GLint>(c.z);
3289 GLint temp[3] = {
3290 x, y, z,
3292 DoUniform3iv(location, 1, &temp[0]);
3293 return error::kNoError;
3296 error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
3297 uint32_t immediate_data_size,
3298 const void* cmd_data) {
3299 const gles2::cmds::Uniform3ivImmediate& c =
3300 *static_cast<const gles2::cmds::Uniform3ivImmediate*>(cmd_data);
3301 (void)c;
3302 GLint location = static_cast<GLint>(c.location);
3303 GLsizei count = static_cast<GLsizei>(c.count);
3304 uint32_t data_size;
3305 if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
3306 return error::kOutOfBounds;
3308 if (data_size > immediate_data_size) {
3309 return error::kOutOfBounds;
3311 const GLint* v =
3312 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3313 if (v == NULL) {
3314 return error::kOutOfBounds;
3316 DoUniform3iv(location, count, v);
3317 return error::kNoError;
3320 error::Error GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size,
3321 const void* cmd_data) {
3322 if (!unsafe_es3_apis_enabled())
3323 return error::kUnknownCommand;
3324 const gles2::cmds::Uniform3ui& c =
3325 *static_cast<const gles2::cmds::Uniform3ui*>(cmd_data);
3326 (void)c;
3327 GLint location = static_cast<GLint>(c.location);
3328 GLuint x = static_cast<GLuint>(c.x);
3329 GLuint y = static_cast<GLuint>(c.y);
3330 GLuint z = static_cast<GLuint>(c.z);
3331 GLuint temp[3] = {
3332 x, y, z,
3334 glUniform3uiv(location, 1, &temp[0]);
3335 return error::kNoError;
3338 error::Error GLES2DecoderImpl::HandleUniform3uivImmediate(
3339 uint32_t immediate_data_size,
3340 const void* cmd_data) {
3341 if (!unsafe_es3_apis_enabled())
3342 return error::kUnknownCommand;
3343 const gles2::cmds::Uniform3uivImmediate& c =
3344 *static_cast<const gles2::cmds::Uniform3uivImmediate*>(cmd_data);
3345 (void)c;
3346 GLint location = static_cast<GLint>(c.location);
3347 GLsizei count = static_cast<GLsizei>(c.count);
3348 uint32_t data_size;
3349 if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) {
3350 return error::kOutOfBounds;
3352 if (data_size > immediate_data_size) {
3353 return error::kOutOfBounds;
3355 const GLuint* v =
3356 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3357 if (v == NULL) {
3358 return error::kOutOfBounds;
3360 glUniform3uiv(location, count, v);
3361 return error::kNoError;
3364 error::Error GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size,
3365 const void* cmd_data) {
3366 const gles2::cmds::Uniform4f& c =
3367 *static_cast<const gles2::cmds::Uniform4f*>(cmd_data);
3368 (void)c;
3369 GLint location = static_cast<GLint>(c.location);
3370 GLfloat x = static_cast<GLfloat>(c.x);
3371 GLfloat y = static_cast<GLfloat>(c.y);
3372 GLfloat z = static_cast<GLfloat>(c.z);
3373 GLfloat w = static_cast<GLfloat>(c.w);
3374 GLfloat temp[4] = {
3375 x, y, z, w,
3377 DoUniform4fv(location, 1, &temp[0]);
3378 return error::kNoError;
3381 error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
3382 uint32_t immediate_data_size,
3383 const void* cmd_data) {
3384 const gles2::cmds::Uniform4fvImmediate& c =
3385 *static_cast<const gles2::cmds::Uniform4fvImmediate*>(cmd_data);
3386 (void)c;
3387 GLint location = static_cast<GLint>(c.location);
3388 GLsizei count = static_cast<GLsizei>(c.count);
3389 uint32_t data_size;
3390 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3391 return error::kOutOfBounds;
3393 if (data_size > immediate_data_size) {
3394 return error::kOutOfBounds;
3396 const GLfloat* v =
3397 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3398 if (v == NULL) {
3399 return error::kOutOfBounds;
3401 DoUniform4fv(location, count, v);
3402 return error::kNoError;
3405 error::Error GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size,
3406 const void* cmd_data) {
3407 const gles2::cmds::Uniform4i& c =
3408 *static_cast<const gles2::cmds::Uniform4i*>(cmd_data);
3409 (void)c;
3410 GLint location = static_cast<GLint>(c.location);
3411 GLint x = static_cast<GLint>(c.x);
3412 GLint y = static_cast<GLint>(c.y);
3413 GLint z = static_cast<GLint>(c.z);
3414 GLint w = static_cast<GLint>(c.w);
3415 GLint temp[4] = {
3416 x, y, z, w,
3418 DoUniform4iv(location, 1, &temp[0]);
3419 return error::kNoError;
3422 error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
3423 uint32_t immediate_data_size,
3424 const void* cmd_data) {
3425 const gles2::cmds::Uniform4ivImmediate& c =
3426 *static_cast<const gles2::cmds::Uniform4ivImmediate*>(cmd_data);
3427 (void)c;
3428 GLint location = static_cast<GLint>(c.location);
3429 GLsizei count = static_cast<GLsizei>(c.count);
3430 uint32_t data_size;
3431 if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
3432 return error::kOutOfBounds;
3434 if (data_size > immediate_data_size) {
3435 return error::kOutOfBounds;
3437 const GLint* v =
3438 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3439 if (v == NULL) {
3440 return error::kOutOfBounds;
3442 DoUniform4iv(location, count, v);
3443 return error::kNoError;
3446 error::Error GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size,
3447 const void* cmd_data) {
3448 if (!unsafe_es3_apis_enabled())
3449 return error::kUnknownCommand;
3450 const gles2::cmds::Uniform4ui& c =
3451 *static_cast<const gles2::cmds::Uniform4ui*>(cmd_data);
3452 (void)c;
3453 GLint location = static_cast<GLint>(c.location);
3454 GLuint x = static_cast<GLuint>(c.x);
3455 GLuint y = static_cast<GLuint>(c.y);
3456 GLuint z = static_cast<GLuint>(c.z);
3457 GLuint w = static_cast<GLuint>(c.w);
3458 GLuint temp[4] = {
3459 x, y, z, w,
3461 glUniform4uiv(location, 1, &temp[0]);
3462 return error::kNoError;
3465 error::Error GLES2DecoderImpl::HandleUniform4uivImmediate(
3466 uint32_t immediate_data_size,
3467 const void* cmd_data) {
3468 if (!unsafe_es3_apis_enabled())
3469 return error::kUnknownCommand;
3470 const gles2::cmds::Uniform4uivImmediate& c =
3471 *static_cast<const gles2::cmds::Uniform4uivImmediate*>(cmd_data);
3472 (void)c;
3473 GLint location = static_cast<GLint>(c.location);
3474 GLsizei count = static_cast<GLsizei>(c.count);
3475 uint32_t data_size;
3476 if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) {
3477 return error::kOutOfBounds;
3479 if (data_size > immediate_data_size) {
3480 return error::kOutOfBounds;
3482 const GLuint* v =
3483 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3484 if (v == NULL) {
3485 return error::kOutOfBounds;
3487 glUniform4uiv(location, count, v);
3488 return error::kNoError;
3491 error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3492 uint32_t immediate_data_size,
3493 const void* cmd_data) {
3494 const gles2::cmds::UniformMatrix2fvImmediate& c =
3495 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate*>(cmd_data);
3496 (void)c;
3497 GLint location = static_cast<GLint>(c.location);
3498 GLsizei count = static_cast<GLsizei>(c.count);
3499 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3500 uint32_t data_size;
3501 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3502 return error::kOutOfBounds;
3504 if (data_size > immediate_data_size) {
3505 return error::kOutOfBounds;
3507 const GLfloat* value =
3508 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3509 if (value == NULL) {
3510 return error::kOutOfBounds;
3512 DoUniformMatrix2fv(location, count, transpose, value);
3513 return error::kNoError;
3516 error::Error GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3517 uint32_t immediate_data_size,
3518 const void* cmd_data) {
3519 if (!unsafe_es3_apis_enabled())
3520 return error::kUnknownCommand;
3521 const gles2::cmds::UniformMatrix2x3fvImmediate& c =
3522 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate*>(cmd_data);
3523 (void)c;
3524 GLint location = static_cast<GLint>(c.location);
3525 GLsizei count = static_cast<GLsizei>(c.count);
3526 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3527 uint32_t data_size;
3528 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3529 return error::kOutOfBounds;
3531 if (data_size > immediate_data_size) {
3532 return error::kOutOfBounds;
3534 const GLfloat* value =
3535 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3536 if (value == NULL) {
3537 return error::kOutOfBounds;
3539 glUniformMatrix2x3fv(location, count, transpose, value);
3540 return error::kNoError;
3543 error::Error GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3544 uint32_t immediate_data_size,
3545 const void* cmd_data) {
3546 if (!unsafe_es3_apis_enabled())
3547 return error::kUnknownCommand;
3548 const gles2::cmds::UniformMatrix2x4fvImmediate& c =
3549 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate*>(cmd_data);
3550 (void)c;
3551 GLint location = static_cast<GLint>(c.location);
3552 GLsizei count = static_cast<GLsizei>(c.count);
3553 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3554 uint32_t data_size;
3555 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3556 return error::kOutOfBounds;
3558 if (data_size > immediate_data_size) {
3559 return error::kOutOfBounds;
3561 const GLfloat* value =
3562 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3563 if (value == NULL) {
3564 return error::kOutOfBounds;
3566 glUniformMatrix2x4fv(location, count, transpose, value);
3567 return error::kNoError;
3570 error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3571 uint32_t immediate_data_size,
3572 const void* cmd_data) {
3573 const gles2::cmds::UniformMatrix3fvImmediate& c =
3574 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate*>(cmd_data);
3575 (void)c;
3576 GLint location = static_cast<GLint>(c.location);
3577 GLsizei count = static_cast<GLsizei>(c.count);
3578 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3579 uint32_t data_size;
3580 if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
3581 return error::kOutOfBounds;
3583 if (data_size > immediate_data_size) {
3584 return error::kOutOfBounds;
3586 const GLfloat* value =
3587 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3588 if (value == NULL) {
3589 return error::kOutOfBounds;
3591 DoUniformMatrix3fv(location, count, transpose, value);
3592 return error::kNoError;
3595 error::Error GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3596 uint32_t immediate_data_size,
3597 const void* cmd_data) {
3598 if (!unsafe_es3_apis_enabled())
3599 return error::kUnknownCommand;
3600 const gles2::cmds::UniformMatrix3x2fvImmediate& c =
3601 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate*>(cmd_data);
3602 (void)c;
3603 GLint location = static_cast<GLint>(c.location);
3604 GLsizei count = static_cast<GLsizei>(c.count);
3605 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3606 uint32_t data_size;
3607 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3608 return error::kOutOfBounds;
3610 if (data_size > immediate_data_size) {
3611 return error::kOutOfBounds;
3613 const GLfloat* value =
3614 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3615 if (value == NULL) {
3616 return error::kOutOfBounds;
3618 glUniformMatrix3x2fv(location, count, transpose, value);
3619 return error::kNoError;
3622 error::Error GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3623 uint32_t immediate_data_size,
3624 const void* cmd_data) {
3625 if (!unsafe_es3_apis_enabled())
3626 return error::kUnknownCommand;
3627 const gles2::cmds::UniformMatrix3x4fvImmediate& c =
3628 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate*>(cmd_data);
3629 (void)c;
3630 GLint location = static_cast<GLint>(c.location);
3631 GLsizei count = static_cast<GLsizei>(c.count);
3632 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3633 uint32_t data_size;
3634 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3635 return error::kOutOfBounds;
3637 if (data_size > immediate_data_size) {
3638 return error::kOutOfBounds;
3640 const GLfloat* value =
3641 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3642 if (value == NULL) {
3643 return error::kOutOfBounds;
3645 glUniformMatrix3x4fv(location, count, transpose, value);
3646 return error::kNoError;
3649 error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3650 uint32_t immediate_data_size,
3651 const void* cmd_data) {
3652 const gles2::cmds::UniformMatrix4fvImmediate& c =
3653 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate*>(cmd_data);
3654 (void)c;
3655 GLint location = static_cast<GLint>(c.location);
3656 GLsizei count = static_cast<GLsizei>(c.count);
3657 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3658 uint32_t data_size;
3659 if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
3660 return error::kOutOfBounds;
3662 if (data_size > immediate_data_size) {
3663 return error::kOutOfBounds;
3665 const GLfloat* value =
3666 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3667 if (value == NULL) {
3668 return error::kOutOfBounds;
3670 DoUniformMatrix4fv(location, count, transpose, value);
3671 return error::kNoError;
3674 error::Error GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3675 uint32_t immediate_data_size,
3676 const void* cmd_data) {
3677 if (!unsafe_es3_apis_enabled())
3678 return error::kUnknownCommand;
3679 const gles2::cmds::UniformMatrix4x2fvImmediate& c =
3680 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate*>(cmd_data);
3681 (void)c;
3682 GLint location = static_cast<GLint>(c.location);
3683 GLsizei count = static_cast<GLsizei>(c.count);
3684 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3685 uint32_t data_size;
3686 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3687 return error::kOutOfBounds;
3689 if (data_size > immediate_data_size) {
3690 return error::kOutOfBounds;
3692 const GLfloat* value =
3693 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3694 if (value == NULL) {
3695 return error::kOutOfBounds;
3697 glUniformMatrix4x2fv(location, count, transpose, value);
3698 return error::kNoError;
3701 error::Error GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3702 uint32_t immediate_data_size,
3703 const void* cmd_data) {
3704 if (!unsafe_es3_apis_enabled())
3705 return error::kUnknownCommand;
3706 const gles2::cmds::UniformMatrix4x3fvImmediate& c =
3707 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate*>(cmd_data);
3708 (void)c;
3709 GLint location = static_cast<GLint>(c.location);
3710 GLsizei count = static_cast<GLsizei>(c.count);
3711 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3712 uint32_t data_size;
3713 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3714 return error::kOutOfBounds;
3716 if (data_size > immediate_data_size) {
3717 return error::kOutOfBounds;
3719 const GLfloat* value =
3720 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3721 if (value == NULL) {
3722 return error::kOutOfBounds;
3724 glUniformMatrix4x3fv(location, count, transpose, value);
3725 return error::kNoError;
3728 error::Error GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size,
3729 const void* cmd_data) {
3730 const gles2::cmds::UseProgram& c =
3731 *static_cast<const gles2::cmds::UseProgram*>(cmd_data);
3732 (void)c;
3733 GLuint program = c.program;
3734 DoUseProgram(program);
3735 return error::kNoError;
3738 error::Error GLES2DecoderImpl::HandleValidateProgram(
3739 uint32_t immediate_data_size,
3740 const void* cmd_data) {
3741 const gles2::cmds::ValidateProgram& c =
3742 *static_cast<const gles2::cmds::ValidateProgram*>(cmd_data);
3743 (void)c;
3744 GLuint program = c.program;
3745 DoValidateProgram(program);
3746 return error::kNoError;
3749 error::Error GLES2DecoderImpl::HandleVertexAttrib1f(
3750 uint32_t immediate_data_size,
3751 const void* cmd_data) {
3752 const gles2::cmds::VertexAttrib1f& c =
3753 *static_cast<const gles2::cmds::VertexAttrib1f*>(cmd_data);
3754 (void)c;
3755 GLuint indx = static_cast<GLuint>(c.indx);
3756 GLfloat x = static_cast<GLfloat>(c.x);
3757 DoVertexAttrib1f(indx, x);
3758 return error::kNoError;
3761 error::Error GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3762 uint32_t immediate_data_size,
3763 const void* cmd_data) {
3764 const gles2::cmds::VertexAttrib1fvImmediate& c =
3765 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate*>(cmd_data);
3766 (void)c;
3767 GLuint indx = static_cast<GLuint>(c.indx);
3768 uint32_t data_size;
3769 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
3770 return error::kOutOfBounds;
3772 if (data_size > immediate_data_size) {
3773 return error::kOutOfBounds;
3775 const GLfloat* values =
3776 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3777 if (values == NULL) {
3778 return error::kOutOfBounds;
3780 DoVertexAttrib1fv(indx, values);
3781 return error::kNoError;
3784 error::Error GLES2DecoderImpl::HandleVertexAttrib2f(
3785 uint32_t immediate_data_size,
3786 const void* cmd_data) {
3787 const gles2::cmds::VertexAttrib2f& c =
3788 *static_cast<const gles2::cmds::VertexAttrib2f*>(cmd_data);
3789 (void)c;
3790 GLuint indx = static_cast<GLuint>(c.indx);
3791 GLfloat x = static_cast<GLfloat>(c.x);
3792 GLfloat y = static_cast<GLfloat>(c.y);
3793 DoVertexAttrib2f(indx, x, y);
3794 return error::kNoError;
3797 error::Error GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3798 uint32_t immediate_data_size,
3799 const void* cmd_data) {
3800 const gles2::cmds::VertexAttrib2fvImmediate& c =
3801 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate*>(cmd_data);
3802 (void)c;
3803 GLuint indx = static_cast<GLuint>(c.indx);
3804 uint32_t data_size;
3805 if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
3806 return error::kOutOfBounds;
3808 if (data_size > immediate_data_size) {
3809 return error::kOutOfBounds;
3811 const GLfloat* values =
3812 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3813 if (values == NULL) {
3814 return error::kOutOfBounds;
3816 DoVertexAttrib2fv(indx, values);
3817 return error::kNoError;
3820 error::Error GLES2DecoderImpl::HandleVertexAttrib3f(
3821 uint32_t immediate_data_size,
3822 const void* cmd_data) {
3823 const gles2::cmds::VertexAttrib3f& c =
3824 *static_cast<const gles2::cmds::VertexAttrib3f*>(cmd_data);
3825 (void)c;
3826 GLuint indx = static_cast<GLuint>(c.indx);
3827 GLfloat x = static_cast<GLfloat>(c.x);
3828 GLfloat y = static_cast<GLfloat>(c.y);
3829 GLfloat z = static_cast<GLfloat>(c.z);
3830 DoVertexAttrib3f(indx, x, y, z);
3831 return error::kNoError;
3834 error::Error GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3835 uint32_t immediate_data_size,
3836 const void* cmd_data) {
3837 const gles2::cmds::VertexAttrib3fvImmediate& c =
3838 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate*>(cmd_data);
3839 (void)c;
3840 GLuint indx = static_cast<GLuint>(c.indx);
3841 uint32_t data_size;
3842 if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
3843 return error::kOutOfBounds;
3845 if (data_size > immediate_data_size) {
3846 return error::kOutOfBounds;
3848 const GLfloat* values =
3849 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3850 if (values == NULL) {
3851 return error::kOutOfBounds;
3853 DoVertexAttrib3fv(indx, values);
3854 return error::kNoError;
3857 error::Error GLES2DecoderImpl::HandleVertexAttrib4f(
3858 uint32_t immediate_data_size,
3859 const void* cmd_data) {
3860 const gles2::cmds::VertexAttrib4f& c =
3861 *static_cast<const gles2::cmds::VertexAttrib4f*>(cmd_data);
3862 (void)c;
3863 GLuint indx = static_cast<GLuint>(c.indx);
3864 GLfloat x = static_cast<GLfloat>(c.x);
3865 GLfloat y = static_cast<GLfloat>(c.y);
3866 GLfloat z = static_cast<GLfloat>(c.z);
3867 GLfloat w = static_cast<GLfloat>(c.w);
3868 DoVertexAttrib4f(indx, x, y, z, w);
3869 return error::kNoError;
3872 error::Error GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3873 uint32_t immediate_data_size,
3874 const void* cmd_data) {
3875 const gles2::cmds::VertexAttrib4fvImmediate& c =
3876 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate*>(cmd_data);
3877 (void)c;
3878 GLuint indx = static_cast<GLuint>(c.indx);
3879 uint32_t data_size;
3880 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
3881 return error::kOutOfBounds;
3883 if (data_size > immediate_data_size) {
3884 return error::kOutOfBounds;
3886 const GLfloat* values =
3887 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3888 if (values == NULL) {
3889 return error::kOutOfBounds;
3891 DoVertexAttrib4fv(indx, values);
3892 return error::kNoError;
3895 error::Error GLES2DecoderImpl::HandleVertexAttribI4i(
3896 uint32_t immediate_data_size,
3897 const void* cmd_data) {
3898 if (!unsafe_es3_apis_enabled())
3899 return error::kUnknownCommand;
3900 const gles2::cmds::VertexAttribI4i& c =
3901 *static_cast<const gles2::cmds::VertexAttribI4i*>(cmd_data);
3902 (void)c;
3903 GLuint indx = static_cast<GLuint>(c.indx);
3904 GLint x = static_cast<GLint>(c.x);
3905 GLint y = static_cast<GLint>(c.y);
3906 GLint z = static_cast<GLint>(c.z);
3907 GLint w = static_cast<GLint>(c.w);
3908 DoVertexAttribI4i(indx, x, y, z, w);
3909 return error::kNoError;
3912 error::Error GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3913 uint32_t immediate_data_size,
3914 const void* cmd_data) {
3915 if (!unsafe_es3_apis_enabled())
3916 return error::kUnknownCommand;
3917 const gles2::cmds::VertexAttribI4ivImmediate& c =
3918 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate*>(cmd_data);
3919 (void)c;
3920 GLuint indx = static_cast<GLuint>(c.indx);
3921 uint32_t data_size;
3922 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
3923 return error::kOutOfBounds;
3925 if (data_size > immediate_data_size) {
3926 return error::kOutOfBounds;
3928 const GLint* values =
3929 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3930 if (values == NULL) {
3931 return error::kOutOfBounds;
3933 DoVertexAttribI4iv(indx, values);
3934 return error::kNoError;
3937 error::Error GLES2DecoderImpl::HandleVertexAttribI4ui(
3938 uint32_t immediate_data_size,
3939 const void* cmd_data) {
3940 if (!unsafe_es3_apis_enabled())
3941 return error::kUnknownCommand;
3942 const gles2::cmds::VertexAttribI4ui& c =
3943 *static_cast<const gles2::cmds::VertexAttribI4ui*>(cmd_data);
3944 (void)c;
3945 GLuint indx = static_cast<GLuint>(c.indx);
3946 GLuint x = static_cast<GLuint>(c.x);
3947 GLuint y = static_cast<GLuint>(c.y);
3948 GLuint z = static_cast<GLuint>(c.z);
3949 GLuint w = static_cast<GLuint>(c.w);
3950 DoVertexAttribI4ui(indx, x, y, z, w);
3951 return error::kNoError;
3954 error::Error GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3955 uint32_t immediate_data_size,
3956 const void* cmd_data) {
3957 if (!unsafe_es3_apis_enabled())
3958 return error::kUnknownCommand;
3959 const gles2::cmds::VertexAttribI4uivImmediate& c =
3960 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate*>(cmd_data);
3961 (void)c;
3962 GLuint indx = static_cast<GLuint>(c.indx);
3963 uint32_t data_size;
3964 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
3965 return error::kOutOfBounds;
3967 if (data_size > immediate_data_size) {
3968 return error::kOutOfBounds;
3970 const GLuint* values =
3971 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3972 if (values == NULL) {
3973 return error::kOutOfBounds;
3975 DoVertexAttribI4uiv(indx, values);
3976 return error::kNoError;
3979 error::Error GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size,
3980 const void* cmd_data) {
3981 const gles2::cmds::Viewport& c =
3982 *static_cast<const gles2::cmds::Viewport*>(cmd_data);
3983 (void)c;
3984 GLint x = static_cast<GLint>(c.x);
3985 GLint y = static_cast<GLint>(c.y);
3986 GLsizei width = static_cast<GLsizei>(c.width);
3987 GLsizei height = static_cast<GLsizei>(c.height);
3988 if (width < 0) {
3989 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "width < 0");
3990 return error::kNoError;
3992 if (height < 0) {
3993 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "height < 0");
3994 return error::kNoError;
3996 DoViewport(x, y, width, height);
3997 return error::kNoError;
4000 error::Error GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
4001 uint32_t immediate_data_size,
4002 const void* cmd_data) {
4003 const gles2::cmds::BlitFramebufferCHROMIUM& c =
4004 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM*>(cmd_data);
4005 (void)c;
4006 if (!features().chromium_framebuffer_multisample) {
4007 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlitFramebufferCHROMIUM",
4008 "function not available");
4009 return error::kNoError;
4012 error::Error error;
4013 error = WillAccessBoundFramebufferForDraw();
4014 if (error != error::kNoError)
4015 return error;
4016 error = WillAccessBoundFramebufferForRead();
4017 if (error != error::kNoError)
4018 return error;
4019 GLint srcX0 = static_cast<GLint>(c.srcX0);
4020 GLint srcY0 = static_cast<GLint>(c.srcY0);
4021 GLint srcX1 = static_cast<GLint>(c.srcX1);
4022 GLint srcY1 = static_cast<GLint>(c.srcY1);
4023 GLint dstX0 = static_cast<GLint>(c.dstX0);
4024 GLint dstY0 = static_cast<GLint>(c.dstY0);
4025 GLint dstX1 = static_cast<GLint>(c.dstX1);
4026 GLint dstY1 = static_cast<GLint>(c.dstY1);
4027 GLbitfield mask = static_cast<GLbitfield>(c.mask);
4028 GLenum filter = static_cast<GLenum>(c.filter);
4029 if (!validators_->blit_filter.IsValid(filter)) {
4030 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter,
4031 "filter");
4032 return error::kNoError;
4034 DoBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
4035 dstY1, mask, filter);
4036 return error::kNoError;
4039 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
4040 uint32_t immediate_data_size,
4041 const void* cmd_data) {
4042 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM& c =
4043 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM*>(
4044 cmd_data);
4045 (void)c;
4046 if (!features().chromium_framebuffer_multisample) {
4047 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4048 "glRenderbufferStorageMultisampleCHROMIUM",
4049 "function not available");
4050 return error::kNoError;
4053 GLenum target = static_cast<GLenum>(c.target);
4054 GLsizei samples = static_cast<GLsizei>(c.samples);
4055 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4056 GLsizei width = static_cast<GLsizei>(c.width);
4057 GLsizei height = static_cast<GLsizei>(c.height);
4058 if (!validators_->render_buffer_target.IsValid(target)) {
4059 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4060 target, "target");
4061 return error::kNoError;
4063 if (samples < 0) {
4064 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4065 "glRenderbufferStorageMultisampleCHROMIUM",
4066 "samples < 0");
4067 return error::kNoError;
4069 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4070 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4071 internalformat, "internalformat");
4072 return error::kNoError;
4074 if (width < 0) {
4075 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4076 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
4077 return error::kNoError;
4079 if (height < 0) {
4080 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4081 "glRenderbufferStorageMultisampleCHROMIUM",
4082 "height < 0");
4083 return error::kNoError;
4085 DoRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
4086 width, height);
4087 return error::kNoError;
4090 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
4091 uint32_t immediate_data_size,
4092 const void* cmd_data) {
4093 const gles2::cmds::RenderbufferStorageMultisampleEXT& c =
4094 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT*>(
4095 cmd_data);
4096 (void)c;
4097 if (!features().multisampled_render_to_texture) {
4098 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4099 "glRenderbufferStorageMultisampleEXT",
4100 "function not available");
4101 return error::kNoError;
4104 GLenum target = static_cast<GLenum>(c.target);
4105 GLsizei samples = static_cast<GLsizei>(c.samples);
4106 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4107 GLsizei width = static_cast<GLsizei>(c.width);
4108 GLsizei height = static_cast<GLsizei>(c.height);
4109 if (!validators_->render_buffer_target.IsValid(target)) {
4110 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4111 target, "target");
4112 return error::kNoError;
4114 if (samples < 0) {
4115 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4116 "samples < 0");
4117 return error::kNoError;
4119 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4120 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4121 internalformat, "internalformat");
4122 return error::kNoError;
4124 if (width < 0) {
4125 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4126 "width < 0");
4127 return error::kNoError;
4129 if (height < 0) {
4130 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4131 "height < 0");
4132 return error::kNoError;
4134 DoRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
4135 height);
4136 return error::kNoError;
4139 error::Error GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
4140 uint32_t immediate_data_size,
4141 const void* cmd_data) {
4142 const gles2::cmds::FramebufferTexture2DMultisampleEXT& c =
4143 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT*>(
4144 cmd_data);
4145 (void)c;
4146 if (!features().multisampled_render_to_texture) {
4147 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4148 "glFramebufferTexture2DMultisampleEXT",
4149 "function not available");
4150 return error::kNoError;
4153 GLenum target = static_cast<GLenum>(c.target);
4154 GLenum attachment = static_cast<GLenum>(c.attachment);
4155 GLenum textarget = static_cast<GLenum>(c.textarget);
4156 GLuint texture = c.texture;
4157 GLint level = static_cast<GLint>(c.level);
4158 GLsizei samples = static_cast<GLsizei>(c.samples);
4159 if (!validators_->frame_buffer_target.IsValid(target)) {
4160 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4161 target, "target");
4162 return error::kNoError;
4164 if (!validators_->attachment.IsValid(attachment)) {
4165 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4166 attachment, "attachment");
4167 return error::kNoError;
4169 if (!validators_->texture_target.IsValid(textarget)) {
4170 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4171 textarget, "textarget");
4172 return error::kNoError;
4174 if (samples < 0) {
4175 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glFramebufferTexture2DMultisampleEXT",
4176 "samples < 0");
4177 return error::kNoError;
4179 DoFramebufferTexture2DMultisample(target, attachment, textarget, texture,
4180 level, samples);
4181 return error::kNoError;
4184 error::Error GLES2DecoderImpl::HandleTexStorage2DEXT(
4185 uint32_t immediate_data_size,
4186 const void* cmd_data) {
4187 const gles2::cmds::TexStorage2DEXT& c =
4188 *static_cast<const gles2::cmds::TexStorage2DEXT*>(cmd_data);
4189 (void)c;
4190 GLenum target = static_cast<GLenum>(c.target);
4191 GLsizei levels = static_cast<GLsizei>(c.levels);
4192 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
4193 GLsizei width = static_cast<GLsizei>(c.width);
4194 GLsizei height = static_cast<GLsizei>(c.height);
4195 if (!validators_->texture_bind_target.IsValid(target)) {
4196 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target, "target");
4197 return error::kNoError;
4199 if (levels < 0) {
4200 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
4201 return error::kNoError;
4203 if (!validators_->texture_internal_format_storage.IsValid(internalFormat)) {
4204 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat,
4205 "internalFormat");
4206 return error::kNoError;
4208 if (width < 0) {
4209 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
4210 return error::kNoError;
4212 if (height < 0) {
4213 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
4214 return error::kNoError;
4216 DoTexStorage2DEXT(target, levels, internalFormat, width, height);
4217 return error::kNoError;
4220 error::Error GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4221 uint32_t immediate_data_size,
4222 const void* cmd_data) {
4223 const gles2::cmds::GenQueriesEXTImmediate& c =
4224 *static_cast<const gles2::cmds::GenQueriesEXTImmediate*>(cmd_data);
4225 (void)c;
4226 GLsizei n = static_cast<GLsizei>(c.n);
4227 uint32_t data_size;
4228 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4229 return error::kOutOfBounds;
4231 GLuint* queries =
4232 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4233 if (queries == NULL) {
4234 return error::kOutOfBounds;
4236 if (!GenQueriesEXTHelper(n, queries)) {
4237 return error::kInvalidArguments;
4239 return error::kNoError;
4242 error::Error GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4243 uint32_t immediate_data_size,
4244 const void* cmd_data) {
4245 const gles2::cmds::DeleteQueriesEXTImmediate& c =
4246 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate*>(cmd_data);
4247 (void)c;
4248 GLsizei n = static_cast<GLsizei>(c.n);
4249 uint32_t data_size;
4250 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4251 return error::kOutOfBounds;
4253 const GLuint* queries =
4254 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4255 if (queries == NULL) {
4256 return error::kOutOfBounds;
4258 DeleteQueriesEXTHelper(n, queries);
4259 return error::kNoError;
4262 error::Error GLES2DecoderImpl::HandleBeginTransformFeedback(
4263 uint32_t immediate_data_size,
4264 const void* cmd_data) {
4265 if (!unsafe_es3_apis_enabled())
4266 return error::kUnknownCommand;
4267 const gles2::cmds::BeginTransformFeedback& c =
4268 *static_cast<const gles2::cmds::BeginTransformFeedback*>(cmd_data);
4269 (void)c;
4270 GLenum primitivemode = static_cast<GLenum>(c.primitivemode);
4271 glBeginTransformFeedback(primitivemode);
4272 return error::kNoError;
4275 error::Error GLES2DecoderImpl::HandleEndTransformFeedback(
4276 uint32_t immediate_data_size,
4277 const void* cmd_data) {
4278 if (!unsafe_es3_apis_enabled())
4279 return error::kUnknownCommand;
4280 const gles2::cmds::EndTransformFeedback& c =
4281 *static_cast<const gles2::cmds::EndTransformFeedback*>(cmd_data);
4282 (void)c;
4283 glEndTransformFeedback();
4284 return error::kNoError;
4287 error::Error GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4288 uint32_t immediate_data_size,
4289 const void* cmd_data) {
4290 const gles2::cmds::InsertEventMarkerEXT& c =
4291 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data);
4292 (void)c;
4294 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4295 Bucket* bucket = GetBucket(bucket_id);
4296 if (!bucket || bucket->size() == 0) {
4297 return error::kInvalidArguments;
4299 std::string str;
4300 if (!bucket->GetAsString(&str)) {
4301 return error::kInvalidArguments;
4303 DoInsertEventMarkerEXT(0, str.c_str());
4304 return error::kNoError;
4307 error::Error GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4308 uint32_t immediate_data_size,
4309 const void* cmd_data) {
4310 const gles2::cmds::PushGroupMarkerEXT& c =
4311 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data);
4312 (void)c;
4314 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4315 Bucket* bucket = GetBucket(bucket_id);
4316 if (!bucket || bucket->size() == 0) {
4317 return error::kInvalidArguments;
4319 std::string str;
4320 if (!bucket->GetAsString(&str)) {
4321 return error::kInvalidArguments;
4323 DoPushGroupMarkerEXT(0, str.c_str());
4324 return error::kNoError;
4327 error::Error GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4328 uint32_t immediate_data_size,
4329 const void* cmd_data) {
4330 const gles2::cmds::PopGroupMarkerEXT& c =
4331 *static_cast<const gles2::cmds::PopGroupMarkerEXT*>(cmd_data);
4332 (void)c;
4333 DoPopGroupMarkerEXT();
4334 return error::kNoError;
4337 error::Error GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4338 uint32_t immediate_data_size,
4339 const void* cmd_data) {
4340 const gles2::cmds::GenVertexArraysOESImmediate& c =
4341 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate*>(cmd_data);
4342 (void)c;
4343 GLsizei n = static_cast<GLsizei>(c.n);
4344 uint32_t data_size;
4345 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4346 return error::kOutOfBounds;
4348 GLuint* arrays =
4349 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4350 if (arrays == NULL) {
4351 return error::kOutOfBounds;
4353 if (!GenVertexArraysOESHelper(n, arrays)) {
4354 return error::kInvalidArguments;
4356 return error::kNoError;
4359 error::Error GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4360 uint32_t immediate_data_size,
4361 const void* cmd_data) {
4362 const gles2::cmds::DeleteVertexArraysOESImmediate& c =
4363 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate*>(
4364 cmd_data);
4365 (void)c;
4366 GLsizei n = static_cast<GLsizei>(c.n);
4367 uint32_t data_size;
4368 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4369 return error::kOutOfBounds;
4371 const GLuint* arrays =
4372 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4373 if (arrays == NULL) {
4374 return error::kOutOfBounds;
4376 DeleteVertexArraysOESHelper(n, arrays);
4377 return error::kNoError;
4380 error::Error GLES2DecoderImpl::HandleIsVertexArrayOES(
4381 uint32_t immediate_data_size,
4382 const void* cmd_data) {
4383 const gles2::cmds::IsVertexArrayOES& c =
4384 *static_cast<const gles2::cmds::IsVertexArrayOES*>(cmd_data);
4385 (void)c;
4386 GLuint array = c.array;
4387 typedef cmds::IsVertexArrayOES::Result Result;
4388 Result* result_dst = GetSharedMemoryAs<Result*>(
4389 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4390 if (!result_dst) {
4391 return error::kOutOfBounds;
4393 *result_dst = DoIsVertexArrayOES(array);
4394 return error::kNoError;
4397 error::Error GLES2DecoderImpl::HandleBindVertexArrayOES(
4398 uint32_t immediate_data_size,
4399 const void* cmd_data) {
4400 const gles2::cmds::BindVertexArrayOES& c =
4401 *static_cast<const gles2::cmds::BindVertexArrayOES*>(cmd_data);
4402 (void)c;
4403 GLuint array = c.array;
4404 DoBindVertexArrayOES(array);
4405 return error::kNoError;
4408 error::Error GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size,
4409 const void* cmd_data) {
4410 const gles2::cmds::SwapBuffers& c =
4411 *static_cast<const gles2::cmds::SwapBuffers*>(cmd_data);
4412 (void)c;
4413 DoSwapBuffers();
4414 return error::kNoError;
4417 error::Error GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4418 uint32_t immediate_data_size,
4419 const void* cmd_data) {
4420 const gles2::cmds::GetMaxValueInBufferCHROMIUM& c =
4421 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM*>(cmd_data);
4422 (void)c;
4423 GLuint buffer_id = c.buffer_id;
4424 GLsizei count = static_cast<GLsizei>(c.count);
4425 GLenum type = static_cast<GLenum>(c.type);
4426 GLuint offset = static_cast<GLuint>(c.offset);
4427 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result;
4428 Result* result_dst = GetSharedMemoryAs<Result*>(
4429 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4430 if (!result_dst) {
4431 return error::kOutOfBounds;
4433 if (count < 0) {
4434 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetMaxValueInBufferCHROMIUM",
4435 "count < 0");
4436 return error::kNoError;
4438 if (!validators_->get_max_index_type.IsValid(type)) {
4439 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type,
4440 "type");
4441 return error::kNoError;
4443 *result_dst = DoGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
4444 return error::kNoError;
4447 error::Error GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4448 uint32_t immediate_data_size,
4449 const void* cmd_data) {
4450 const gles2::cmds::TexImageIOSurface2DCHROMIUM& c =
4451 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM*>(cmd_data);
4452 (void)c;
4453 GLenum target = static_cast<GLenum>(c.target);
4454 GLsizei width = static_cast<GLsizei>(c.width);
4455 GLsizei height = static_cast<GLsizei>(c.height);
4456 GLuint ioSurfaceId = static_cast<GLuint>(c.ioSurfaceId);
4457 GLuint plane = static_cast<GLuint>(c.plane);
4458 if (!validators_->texture_bind_target.IsValid(target)) {
4459 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target,
4460 "target");
4461 return error::kNoError;
4463 if (width < 0) {
4464 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4465 "width < 0");
4466 return error::kNoError;
4468 if (height < 0) {
4469 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4470 "height < 0");
4471 return error::kNoError;
4473 DoTexImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
4474 return error::kNoError;
4477 error::Error GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4478 uint32_t immediate_data_size,
4479 const void* cmd_data) {
4480 const gles2::cmds::CopyTextureCHROMIUM& c =
4481 *static_cast<const gles2::cmds::CopyTextureCHROMIUM*>(cmd_data);
4482 (void)c;
4483 GLenum target = static_cast<GLenum>(c.target);
4484 GLenum source_id = static_cast<GLenum>(c.source_id);
4485 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4486 GLint internalformat = static_cast<GLint>(c.internalformat);
4487 GLenum dest_type = static_cast<GLenum>(c.dest_type);
4488 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4489 GLboolean unpack_premultiply_alpha =
4490 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4491 GLboolean unpack_unmultiply_alpha =
4492 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4493 if (!validators_->texture_internal_format.IsValid(internalformat)) {
4494 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM",
4495 "internalformat GL_INVALID_VALUE");
4496 return error::kNoError;
4498 if (!validators_->pixel_type.IsValid(dest_type)) {
4499 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type,
4500 "dest_type");
4501 return error::kNoError;
4503 DoCopyTextureCHROMIUM(target, source_id, dest_id, internalformat, dest_type,
4504 unpack_flip_y, unpack_premultiply_alpha,
4505 unpack_unmultiply_alpha);
4506 return error::kNoError;
4509 error::Error GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4510 uint32_t immediate_data_size,
4511 const void* cmd_data) {
4512 const gles2::cmds::CopySubTextureCHROMIUM& c =
4513 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM*>(cmd_data);
4514 (void)c;
4515 GLenum target = static_cast<GLenum>(c.target);
4516 GLenum source_id = static_cast<GLenum>(c.source_id);
4517 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4518 GLint xoffset = static_cast<GLint>(c.xoffset);
4519 GLint yoffset = static_cast<GLint>(c.yoffset);
4520 GLint x = static_cast<GLint>(c.x);
4521 GLint y = static_cast<GLint>(c.y);
4522 GLsizei width = static_cast<GLsizei>(c.width);
4523 GLsizei height = static_cast<GLsizei>(c.height);
4524 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4525 GLboolean unpack_premultiply_alpha =
4526 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4527 GLboolean unpack_unmultiply_alpha =
4528 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4529 if (width < 0) {
4530 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4531 "width < 0");
4532 return error::kNoError;
4534 if (height < 0) {
4535 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4536 "height < 0");
4537 return error::kNoError;
4539 DoCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset, yoffset, x, y,
4540 width, height, unpack_flip_y,
4541 unpack_premultiply_alpha, unpack_unmultiply_alpha);
4542 return error::kNoError;
4545 error::Error GLES2DecoderImpl::HandleCompressedCopyTextureCHROMIUM(
4546 uint32_t immediate_data_size,
4547 const void* cmd_data) {
4548 const gles2::cmds::CompressedCopyTextureCHROMIUM& c =
4549 *static_cast<const gles2::cmds::CompressedCopyTextureCHROMIUM*>(cmd_data);
4550 (void)c;
4551 GLenum target = static_cast<GLenum>(c.target);
4552 GLenum source_id = static_cast<GLenum>(c.source_id);
4553 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4554 DoCompressedCopyTextureCHROMIUM(target, source_id, dest_id);
4555 return error::kNoError;
4558 error::Error GLES2DecoderImpl::HandleCompressedCopySubTextureCHROMIUM(
4559 uint32_t immediate_data_size,
4560 const void* cmd_data) {
4561 const gles2::cmds::CompressedCopySubTextureCHROMIUM& c =
4562 *static_cast<const gles2::cmds::CompressedCopySubTextureCHROMIUM*>(
4563 cmd_data);
4564 (void)c;
4565 GLenum target = static_cast<GLenum>(c.target);
4566 GLenum source_id = static_cast<GLenum>(c.source_id);
4567 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4568 GLint xoffset = static_cast<GLint>(c.xoffset);
4569 GLint yoffset = static_cast<GLint>(c.yoffset);
4570 GLint x = static_cast<GLint>(c.x);
4571 GLint y = static_cast<GLint>(c.y);
4572 GLsizei width = static_cast<GLsizei>(c.width);
4573 GLsizei height = static_cast<GLsizei>(c.height);
4574 if (width < 0) {
4575 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
4576 "width < 0");
4577 return error::kNoError;
4579 if (height < 0) {
4580 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
4581 "height < 0");
4582 return error::kNoError;
4584 DoCompressedCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset,
4585 yoffset, x, y, width, height);
4586 return error::kNoError;
4589 error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4590 uint32_t immediate_data_size,
4591 const void* cmd_data) {
4592 const gles2::cmds::ProduceTextureCHROMIUMImmediate& c =
4593 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate*>(
4594 cmd_data);
4595 (void)c;
4596 GLenum target = static_cast<GLenum>(c.target);
4597 uint32_t data_size;
4598 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4599 return error::kOutOfBounds;
4601 if (data_size > immediate_data_size) {
4602 return error::kOutOfBounds;
4604 const GLbyte* mailbox =
4605 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4606 if (!validators_->texture_bind_target.IsValid(target)) {
4607 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target,
4608 "target");
4609 return error::kNoError;
4611 if (mailbox == NULL) {
4612 return error::kOutOfBounds;
4614 DoProduceTextureCHROMIUM(target, mailbox);
4615 return error::kNoError;
4618 error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4619 uint32_t immediate_data_size,
4620 const void* cmd_data) {
4621 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c =
4622 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>(
4623 cmd_data);
4624 (void)c;
4625 GLuint texture = c.texture;
4626 GLenum target = static_cast<GLenum>(c.target);
4627 uint32_t data_size;
4628 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4629 return error::kOutOfBounds;
4631 if (data_size > immediate_data_size) {
4632 return error::kOutOfBounds;
4634 const GLbyte* mailbox =
4635 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4636 if (!validators_->texture_bind_target.IsValid(target)) {
4637 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target,
4638 "target");
4639 return error::kNoError;
4641 if (mailbox == NULL) {
4642 return error::kOutOfBounds;
4644 DoProduceTextureDirectCHROMIUM(texture, target, mailbox);
4645 return error::kNoError;
4648 error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4649 uint32_t immediate_data_size,
4650 const void* cmd_data) {
4651 const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c =
4652 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate*>(
4653 cmd_data);
4654 (void)c;
4655 GLenum target = static_cast<GLenum>(c.target);
4656 uint32_t data_size;
4657 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4658 return error::kOutOfBounds;
4660 if (data_size > immediate_data_size) {
4661 return error::kOutOfBounds;
4663 const GLbyte* mailbox =
4664 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4665 if (!validators_->texture_bind_target.IsValid(target)) {
4666 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target,
4667 "target");
4668 return error::kNoError;
4670 if (mailbox == NULL) {
4671 return error::kOutOfBounds;
4673 DoConsumeTextureCHROMIUM(target, mailbox);
4674 return error::kNoError;
4677 error::Error GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4678 uint32_t immediate_data_size,
4679 const void* cmd_data) {
4680 const gles2::cmds::GenValuebuffersCHROMIUMImmediate& c =
4681 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate*>(
4682 cmd_data);
4683 (void)c;
4684 GLsizei n = static_cast<GLsizei>(c.n);
4685 uint32_t data_size;
4686 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4687 return error::kOutOfBounds;
4689 GLuint* buffers =
4690 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4691 if (buffers == NULL) {
4692 return error::kOutOfBounds;
4694 if (!GenValuebuffersCHROMIUMHelper(n, buffers)) {
4695 return error::kInvalidArguments;
4697 return error::kNoError;
4700 error::Error GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4701 uint32_t immediate_data_size,
4702 const void* cmd_data) {
4703 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate& c =
4704 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate*>(
4705 cmd_data);
4706 (void)c;
4707 GLsizei n = static_cast<GLsizei>(c.n);
4708 uint32_t data_size;
4709 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4710 return error::kOutOfBounds;
4712 const GLuint* valuebuffers =
4713 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4714 if (valuebuffers == NULL) {
4715 return error::kOutOfBounds;
4717 DeleteValuebuffersCHROMIUMHelper(n, valuebuffers);
4718 return error::kNoError;
4721 error::Error GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4722 uint32_t immediate_data_size,
4723 const void* cmd_data) {
4724 const gles2::cmds::IsValuebufferCHROMIUM& c =
4725 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM*>(cmd_data);
4726 (void)c;
4727 GLuint valuebuffer = c.valuebuffer;
4728 typedef cmds::IsValuebufferCHROMIUM::Result Result;
4729 Result* result_dst = GetSharedMemoryAs<Result*>(
4730 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4731 if (!result_dst) {
4732 return error::kOutOfBounds;
4734 *result_dst = DoIsValuebufferCHROMIUM(valuebuffer);
4735 return error::kNoError;
4738 error::Error GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4739 uint32_t immediate_data_size,
4740 const void* cmd_data) {
4741 const gles2::cmds::BindValuebufferCHROMIUM& c =
4742 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM*>(cmd_data);
4743 (void)c;
4744 GLenum target = static_cast<GLenum>(c.target);
4745 GLuint valuebuffer = c.valuebuffer;
4746 if (!validators_->value_buffer_target.IsValid(target)) {
4747 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target,
4748 "target");
4749 return error::kNoError;
4751 DoBindValueBufferCHROMIUM(target, valuebuffer);
4752 return error::kNoError;
4755 error::Error GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4756 uint32_t immediate_data_size,
4757 const void* cmd_data) {
4758 const gles2::cmds::SubscribeValueCHROMIUM& c =
4759 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM*>(cmd_data);
4760 (void)c;
4761 GLenum target = static_cast<GLenum>(c.target);
4762 GLenum subscription = static_cast<GLenum>(c.subscription);
4763 if (!validators_->value_buffer_target.IsValid(target)) {
4764 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target,
4765 "target");
4766 return error::kNoError;
4768 if (!validators_->subscription_target.IsValid(subscription)) {
4769 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription,
4770 "subscription");
4771 return error::kNoError;
4773 DoSubscribeValueCHROMIUM(target, subscription);
4774 return error::kNoError;
4777 error::Error GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4778 uint32_t immediate_data_size,
4779 const void* cmd_data) {
4780 const gles2::cmds::PopulateSubscribedValuesCHROMIUM& c =
4781 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM*>(
4782 cmd_data);
4783 (void)c;
4784 GLenum target = static_cast<GLenum>(c.target);
4785 if (!validators_->value_buffer_target.IsValid(target)) {
4786 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4787 target, "target");
4788 return error::kNoError;
4790 DoPopulateSubscribedValuesCHROMIUM(target);
4791 return error::kNoError;
4794 error::Error GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4795 uint32_t immediate_data_size,
4796 const void* cmd_data) {
4797 const gles2::cmds::UniformValuebufferCHROMIUM& c =
4798 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM*>(cmd_data);
4799 (void)c;
4800 GLint location = static_cast<GLint>(c.location);
4801 GLenum target = static_cast<GLenum>(c.target);
4802 GLenum subscription = static_cast<GLenum>(c.subscription);
4803 if (!validators_->value_buffer_target.IsValid(target)) {
4804 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target,
4805 "target");
4806 return error::kNoError;
4808 if (!validators_->subscription_target.IsValid(subscription)) {
4809 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4810 subscription, "subscription");
4811 return error::kNoError;
4813 DoUniformValueBufferCHROMIUM(location, target, subscription);
4814 return error::kNoError;
4817 error::Error GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4818 uint32_t immediate_data_size,
4819 const void* cmd_data) {
4820 const gles2::cmds::BindTexImage2DCHROMIUM& c =
4821 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM*>(cmd_data);
4822 (void)c;
4823 GLenum target = static_cast<GLenum>(c.target);
4824 GLint imageId = static_cast<GLint>(c.imageId);
4825 if (!validators_->texture_bind_target.IsValid(target)) {
4826 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target,
4827 "target");
4828 return error::kNoError;
4830 DoBindTexImage2DCHROMIUM(target, imageId);
4831 return error::kNoError;
4834 error::Error GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4835 uint32_t immediate_data_size,
4836 const void* cmd_data) {
4837 const gles2::cmds::ReleaseTexImage2DCHROMIUM& c =
4838 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM*>(cmd_data);
4839 (void)c;
4840 GLenum target = static_cast<GLenum>(c.target);
4841 GLint imageId = static_cast<GLint>(c.imageId);
4842 if (!validators_->texture_bind_target.IsValid(target)) {
4843 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target,
4844 "target");
4845 return error::kNoError;
4847 DoReleaseTexImage2DCHROMIUM(target, imageId);
4848 return error::kNoError;
4851 error::Error GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4852 uint32_t immediate_data_size,
4853 const void* cmd_data) {
4854 const gles2::cmds::TraceEndCHROMIUM& c =
4855 *static_cast<const gles2::cmds::TraceEndCHROMIUM*>(cmd_data);
4856 (void)c;
4857 DoTraceEndCHROMIUM();
4858 return error::kNoError;
4861 error::Error GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4862 uint32_t immediate_data_size,
4863 const void* cmd_data) {
4864 const gles2::cmds::DiscardFramebufferEXTImmediate& c =
4865 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate*>(
4866 cmd_data);
4867 (void)c;
4868 if (!features().ext_discard_framebuffer) {
4869 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDiscardFramebufferEXT",
4870 "function not available");
4871 return error::kNoError;
4874 GLenum target = static_cast<GLenum>(c.target);
4875 GLsizei count = static_cast<GLsizei>(c.count);
4876 uint32_t data_size;
4877 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4878 return error::kOutOfBounds;
4880 if (data_size > immediate_data_size) {
4881 return error::kOutOfBounds;
4883 const GLenum* attachments =
4884 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4885 if (count < 0) {
4886 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDiscardFramebufferEXT",
4887 "count < 0");
4888 return error::kNoError;
4890 if (attachments == NULL) {
4891 return error::kOutOfBounds;
4893 DoDiscardFramebufferEXT(target, count, attachments);
4894 return error::kNoError;
4897 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4898 uint32_t immediate_data_size,
4899 const void* cmd_data) {
4900 const gles2::cmds::LoseContextCHROMIUM& c =
4901 *static_cast<const gles2::cmds::LoseContextCHROMIUM*>(cmd_data);
4902 (void)c;
4903 GLenum current = static_cast<GLenum>(c.current);
4904 GLenum other = static_cast<GLenum>(c.other);
4905 if (!validators_->reset_status.IsValid(current)) {
4906 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
4907 "current");
4908 return error::kNoError;
4910 if (!validators_->reset_status.IsValid(other)) {
4911 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
4912 return error::kNoError;
4914 DoLoseContextCHROMIUM(current, other);
4915 return error::kNoError;
4918 error::Error GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4919 uint32_t immediate_data_size,
4920 const void* cmd_data) {
4921 const gles2::cmds::DrawBuffersEXTImmediate& c =
4922 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate*>(cmd_data);
4923 (void)c;
4924 GLsizei count = static_cast<GLsizei>(c.count);
4925 uint32_t data_size;
4926 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4927 return error::kOutOfBounds;
4929 if (data_size > immediate_data_size) {
4930 return error::kOutOfBounds;
4932 const GLenum* bufs =
4933 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4934 if (count < 0) {
4935 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
4936 return error::kNoError;
4938 if (bufs == NULL) {
4939 return error::kOutOfBounds;
4941 DoDrawBuffersEXT(count, bufs);
4942 return error::kNoError;
4945 error::Error GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size,
4946 const void* cmd_data) {
4947 const gles2::cmds::SwapInterval& c =
4948 *static_cast<const gles2::cmds::SwapInterval*>(cmd_data);
4949 (void)c;
4950 GLint interval = static_cast<GLint>(c.interval);
4951 DoSwapInterval(interval);
4952 return error::kNoError;
4955 error::Error GLES2DecoderImpl::HandleFlushDriverCachesCHROMIUM(
4956 uint32_t immediate_data_size,
4957 const void* cmd_data) {
4958 const gles2::cmds::FlushDriverCachesCHROMIUM& c =
4959 *static_cast<const gles2::cmds::FlushDriverCachesCHROMIUM*>(cmd_data);
4960 (void)c;
4961 DoFlushDriverCachesCHROMIUM();
4962 return error::kNoError;
4965 error::Error GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4966 uint32_t immediate_data_size,
4967 const void* cmd_data) {
4968 const gles2::cmds::MatrixLoadfCHROMIUMImmediate& c =
4969 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate*>(cmd_data);
4970 (void)c;
4971 if (!features().chromium_path_rendering) {
4972 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadfCHROMIUM",
4973 "function not available");
4974 return error::kNoError;
4977 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4978 uint32_t data_size;
4979 if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
4980 return error::kOutOfBounds;
4982 if (data_size > immediate_data_size) {
4983 return error::kOutOfBounds;
4985 const GLfloat* m =
4986 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
4987 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4988 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode,
4989 "matrixMode");
4990 return error::kNoError;
4992 if (m == NULL) {
4993 return error::kOutOfBounds;
4995 DoMatrixLoadfCHROMIUM(matrixMode, m);
4996 return error::kNoError;
4999 error::Error GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
5000 uint32_t immediate_data_size,
5001 const void* cmd_data) {
5002 const gles2::cmds::MatrixLoadIdentityCHROMIUM& c =
5003 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM*>(cmd_data);
5004 (void)c;
5005 if (!features().chromium_path_rendering) {
5006 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadIdentityCHROMIUM",
5007 "function not available");
5008 return error::kNoError;
5011 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
5012 if (!validators_->matrix_mode.IsValid(matrixMode)) {
5013 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode,
5014 "matrixMode");
5015 return error::kNoError;
5017 DoMatrixLoadIdentityCHROMIUM(matrixMode);
5018 return error::kNoError;
5021 error::Error GLES2DecoderImpl::HandleIsPathCHROMIUM(
5022 uint32_t immediate_data_size,
5023 const void* cmd_data) {
5024 const gles2::cmds::IsPathCHROMIUM& c =
5025 *static_cast<const gles2::cmds::IsPathCHROMIUM*>(cmd_data);
5026 (void)c;
5027 if (!features().chromium_path_rendering) {
5028 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glIsPathCHROMIUM",
5029 "function not available");
5030 return error::kNoError;
5033 GLuint path = c.path;
5034 typedef cmds::IsPathCHROMIUM::Result Result;
5035 Result* result_dst = GetSharedMemoryAs<Result*>(
5036 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
5037 if (!result_dst) {
5038 return error::kOutOfBounds;
5040 *result_dst = DoIsPathCHROMIUM(path);
5041 return error::kNoError;
5044 error::Error GLES2DecoderImpl::HandlePathStencilFuncCHROMIUM(
5045 uint32_t immediate_data_size,
5046 const void* cmd_data) {
5047 const gles2::cmds::PathStencilFuncCHROMIUM& c =
5048 *static_cast<const gles2::cmds::PathStencilFuncCHROMIUM*>(cmd_data);
5049 (void)c;
5050 if (!features().chromium_path_rendering) {
5051 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glPathStencilFuncCHROMIUM",
5052 "function not available");
5053 return error::kNoError;
5056 GLenum func = static_cast<GLenum>(c.func);
5057 GLint ref = static_cast<GLint>(c.ref);
5058 GLuint mask = static_cast<GLuint>(c.mask);
5059 if (!validators_->cmp_function.IsValid(func)) {
5060 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPathStencilFuncCHROMIUM", func, "func");
5061 return error::kNoError;
5063 if (state_.stencil_path_func != func || state_.stencil_path_ref != ref ||
5064 state_.stencil_path_mask != mask) {
5065 state_.stencil_path_func = func;
5066 state_.stencil_path_ref = ref;
5067 state_.stencil_path_mask = mask;
5068 glPathStencilFuncNV(func, ref, mask);
5070 return error::kNoError;
5073 error::Error GLES2DecoderImpl::HandleBlendBarrierKHR(
5074 uint32_t immediate_data_size,
5075 const void* cmd_data) {
5076 const gles2::cmds::BlendBarrierKHR& c =
5077 *static_cast<const gles2::cmds::BlendBarrierKHR*>(cmd_data);
5078 (void)c;
5079 if (!features().blend_equation_advanced) {
5080 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlendBarrierKHR",
5081 "function not available");
5082 return error::kNoError;
5085 glBlendBarrierKHR();
5086 return error::kNoError;
5089 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
5090 switch (cap) {
5091 case GL_BLEND:
5092 state_.enable_flags.blend = enabled;
5093 if (state_.enable_flags.cached_blend != enabled ||
5094 state_.ignore_cached_state) {
5095 state_.enable_flags.cached_blend = enabled;
5096 return true;
5098 return false;
5099 case GL_CULL_FACE:
5100 state_.enable_flags.cull_face = enabled;
5101 if (state_.enable_flags.cached_cull_face != enabled ||
5102 state_.ignore_cached_state) {
5103 state_.enable_flags.cached_cull_face = enabled;
5104 return true;
5106 return false;
5107 case GL_DEPTH_TEST:
5108 state_.enable_flags.depth_test = enabled;
5109 if (state_.enable_flags.cached_depth_test != enabled ||
5110 state_.ignore_cached_state) {
5111 framebuffer_state_.clear_state_dirty = true;
5113 return false;
5114 case GL_DITHER:
5115 state_.enable_flags.dither = enabled;
5116 if (state_.enable_flags.cached_dither != enabled ||
5117 state_.ignore_cached_state) {
5118 state_.enable_flags.cached_dither = enabled;
5119 return true;
5121 return false;
5122 case GL_POLYGON_OFFSET_FILL:
5123 state_.enable_flags.polygon_offset_fill = enabled;
5124 if (state_.enable_flags.cached_polygon_offset_fill != enabled ||
5125 state_.ignore_cached_state) {
5126 state_.enable_flags.cached_polygon_offset_fill = enabled;
5127 return true;
5129 return false;
5130 case GL_SAMPLE_ALPHA_TO_COVERAGE:
5131 state_.enable_flags.sample_alpha_to_coverage = enabled;
5132 if (state_.enable_flags.cached_sample_alpha_to_coverage != enabled ||
5133 state_.ignore_cached_state) {
5134 state_.enable_flags.cached_sample_alpha_to_coverage = enabled;
5135 return true;
5137 return false;
5138 case GL_SAMPLE_COVERAGE:
5139 state_.enable_flags.sample_coverage = enabled;
5140 if (state_.enable_flags.cached_sample_coverage != enabled ||
5141 state_.ignore_cached_state) {
5142 state_.enable_flags.cached_sample_coverage = enabled;
5143 return true;
5145 return false;
5146 case GL_SCISSOR_TEST:
5147 state_.enable_flags.scissor_test = enabled;
5148 if (state_.enable_flags.cached_scissor_test != enabled ||
5149 state_.ignore_cached_state) {
5150 state_.enable_flags.cached_scissor_test = enabled;
5151 return true;
5153 return false;
5154 case GL_STENCIL_TEST:
5155 state_.enable_flags.stencil_test = enabled;
5156 if (state_.enable_flags.cached_stencil_test != enabled ||
5157 state_.ignore_cached_state) {
5158 framebuffer_state_.clear_state_dirty = true;
5160 return false;
5161 case GL_RASTERIZER_DISCARD:
5162 state_.enable_flags.rasterizer_discard = enabled;
5163 if (state_.enable_flags.cached_rasterizer_discard != enabled ||
5164 state_.ignore_cached_state) {
5165 state_.enable_flags.cached_rasterizer_discard = enabled;
5166 return true;
5168 return false;
5169 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
5170 state_.enable_flags.primitive_restart_fixed_index = enabled;
5171 if (state_.enable_flags.cached_primitive_restart_fixed_index != enabled ||
5172 state_.ignore_cached_state) {
5173 state_.enable_flags.cached_primitive_restart_fixed_index = enabled;
5174 return true;
5176 return false;
5177 default:
5178 NOTREACHED();
5179 return false;
5182 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_