Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_autogen.h
blob09d07c0b587862b0d8f9769f504db5bede9bd5df
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
9 // DO NOT EDIT!
11 // It is included by gles2_cmd_decoder.cc
12 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
13 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
15 error::Error GLES2DecoderImpl::HandleActiveTexture(uint32_t immediate_data_size,
16 const void* cmd_data) {
17 const gles2::cmds::ActiveTexture& c =
18 *static_cast<const gles2::cmds::ActiveTexture*>(cmd_data);
19 (void)c;
20 GLenum texture = static_cast<GLenum>(c.texture);
21 DoActiveTexture(texture);
22 return error::kNoError;
25 error::Error GLES2DecoderImpl::HandleAttachShader(uint32_t immediate_data_size,
26 const void* cmd_data) {
27 const gles2::cmds::AttachShader& c =
28 *static_cast<const gles2::cmds::AttachShader*>(cmd_data);
29 (void)c;
30 GLuint program = c.program;
31 GLuint shader = c.shader;
32 DoAttachShader(program, shader);
33 return error::kNoError;
36 error::Error GLES2DecoderImpl::HandleBindBuffer(uint32_t immediate_data_size,
37 const void* cmd_data) {
38 const gles2::cmds::BindBuffer& c =
39 *static_cast<const gles2::cmds::BindBuffer*>(cmd_data);
40 (void)c;
41 GLenum target = static_cast<GLenum>(c.target);
42 GLuint buffer = c.buffer;
43 if (!validators_->buffer_target.IsValid(target)) {
44 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBuffer", target, "target");
45 return error::kNoError;
47 DoBindBuffer(target, buffer);
48 return error::kNoError;
51 error::Error GLES2DecoderImpl::HandleBindBufferBase(
52 uint32_t immediate_data_size,
53 const void* cmd_data) {
54 if (!unsafe_es3_apis_enabled())
55 return error::kUnknownCommand;
56 const gles2::cmds::BindBufferBase& c =
57 *static_cast<const gles2::cmds::BindBufferBase*>(cmd_data);
58 (void)c;
59 GLenum target = static_cast<GLenum>(c.target);
60 GLuint index = static_cast<GLuint>(c.index);
61 GLuint buffer = c.buffer;
62 if (!group_->GetBufferServiceId(buffer, &buffer)) {
63 if (!group_->bind_generates_resource()) {
64 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindBufferBase",
65 "invalid buffer id");
66 return error::kNoError;
68 GLuint client_id = buffer;
69 glGenBuffersARB(1, &buffer);
70 CreateBuffer(client_id, buffer);
72 glBindBufferBase(target, index, buffer);
73 return error::kNoError;
76 error::Error GLES2DecoderImpl::HandleBindBufferRange(
77 uint32_t immediate_data_size,
78 const void* cmd_data) {
79 if (!unsafe_es3_apis_enabled())
80 return error::kUnknownCommand;
81 const gles2::cmds::BindBufferRange& c =
82 *static_cast<const gles2::cmds::BindBufferRange*>(cmd_data);
83 (void)c;
84 GLenum target = static_cast<GLenum>(c.target);
85 GLuint index = static_cast<GLuint>(c.index);
86 GLuint buffer = c.buffer;
87 GLintptr offset = static_cast<GLintptr>(c.offset);
88 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
89 if (!group_->GetBufferServiceId(buffer, &buffer)) {
90 if (!group_->bind_generates_resource()) {
91 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindBufferRange",
92 "invalid buffer id");
93 return error::kNoError;
95 GLuint client_id = buffer;
96 glGenBuffersARB(1, &buffer);
97 CreateBuffer(client_id, buffer);
99 glBindBufferRange(target, index, buffer, offset, size);
100 return error::kNoError;
103 error::Error GLES2DecoderImpl::HandleBindFramebuffer(
104 uint32_t immediate_data_size,
105 const void* cmd_data) {
106 const gles2::cmds::BindFramebuffer& c =
107 *static_cast<const gles2::cmds::BindFramebuffer*>(cmd_data);
108 (void)c;
109 GLenum target = static_cast<GLenum>(c.target);
110 GLuint framebuffer = c.framebuffer;
111 if (!validators_->frame_buffer_target.IsValid(target)) {
112 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target, "target");
113 return error::kNoError;
115 DoBindFramebuffer(target, framebuffer);
116 return error::kNoError;
119 error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
120 uint32_t immediate_data_size,
121 const void* cmd_data) {
122 const gles2::cmds::BindRenderbuffer& c =
123 *static_cast<const gles2::cmds::BindRenderbuffer*>(cmd_data);
124 (void)c;
125 GLenum target = static_cast<GLenum>(c.target);
126 GLuint renderbuffer = c.renderbuffer;
127 if (!validators_->render_buffer_target.IsValid(target)) {
128 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target, "target");
129 return error::kNoError;
131 DoBindRenderbuffer(target, renderbuffer);
132 return error::kNoError;
135 error::Error GLES2DecoderImpl::HandleBindSampler(uint32_t immediate_data_size,
136 const void* cmd_data) {
137 if (!unsafe_es3_apis_enabled())
138 return error::kUnknownCommand;
139 const gles2::cmds::BindSampler& c =
140 *static_cast<const gles2::cmds::BindSampler*>(cmd_data);
141 (void)c;
142 GLuint unit = static_cast<GLuint>(c.unit);
143 GLuint sampler = c.sampler;
144 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
145 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindSampler",
146 "invalid sampler id");
147 return error::kNoError;
149 glBindSampler(unit, sampler);
150 return error::kNoError;
153 error::Error GLES2DecoderImpl::HandleBindTexture(uint32_t immediate_data_size,
154 const void* cmd_data) {
155 const gles2::cmds::BindTexture& c =
156 *static_cast<const gles2::cmds::BindTexture*>(cmd_data);
157 (void)c;
158 GLenum target = static_cast<GLenum>(c.target);
159 GLuint texture = c.texture;
160 if (!validators_->texture_bind_target.IsValid(target)) {
161 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target, "target");
162 return error::kNoError;
164 DoBindTexture(target, texture);
165 return error::kNoError;
168 error::Error GLES2DecoderImpl::HandleBindTransformFeedback(
169 uint32_t immediate_data_size,
170 const void* cmd_data) {
171 if (!unsafe_es3_apis_enabled())
172 return error::kUnknownCommand;
173 const gles2::cmds::BindTransformFeedback& c =
174 *static_cast<const gles2::cmds::BindTransformFeedback*>(cmd_data);
175 (void)c;
176 GLenum target = static_cast<GLenum>(c.target);
177 GLuint transformfeedback = c.transformfeedback;
178 if (!group_->GetTransformFeedbackServiceId(transformfeedback,
179 &transformfeedback)) {
180 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTransformFeedback",
181 "invalid transformfeedback id");
182 return error::kNoError;
184 glBindTransformFeedback(target, transformfeedback);
185 return error::kNoError;
188 error::Error GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size,
189 const void* cmd_data) {
190 const gles2::cmds::BlendColor& c =
191 *static_cast<const gles2::cmds::BlendColor*>(cmd_data);
192 (void)c;
193 GLclampf red = static_cast<GLclampf>(c.red);
194 GLclampf green = static_cast<GLclampf>(c.green);
195 GLclampf blue = static_cast<GLclampf>(c.blue);
196 GLclampf alpha = static_cast<GLclampf>(c.alpha);
197 if (state_.blend_color_red != red || state_.blend_color_green != green ||
198 state_.blend_color_blue != blue || state_.blend_color_alpha != alpha) {
199 state_.blend_color_red = red;
200 state_.blend_color_green = green;
201 state_.blend_color_blue = blue;
202 state_.blend_color_alpha = alpha;
203 glBlendColor(red, green, blue, alpha);
205 return error::kNoError;
208 error::Error GLES2DecoderImpl::HandleBlendEquation(uint32_t immediate_data_size,
209 const void* cmd_data) {
210 const gles2::cmds::BlendEquation& c =
211 *static_cast<const gles2::cmds::BlendEquation*>(cmd_data);
212 (void)c;
213 GLenum mode = static_cast<GLenum>(c.mode);
214 if (!validators_->equation.IsValid(mode)) {
215 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode, "mode");
216 return error::kNoError;
218 if (state_.blend_equation_rgb != mode ||
219 state_.blend_equation_alpha != mode) {
220 state_.blend_equation_rgb = mode;
221 state_.blend_equation_alpha = mode;
222 glBlendEquation(mode);
224 return error::kNoError;
227 error::Error GLES2DecoderImpl::HandleBlendEquationSeparate(
228 uint32_t immediate_data_size,
229 const void* cmd_data) {
230 const gles2::cmds::BlendEquationSeparate& c =
231 *static_cast<const gles2::cmds::BlendEquationSeparate*>(cmd_data);
232 (void)c;
233 GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
234 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
235 if (!validators_->equation.IsValid(modeRGB)) {
236 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB,
237 "modeRGB");
238 return error::kNoError;
240 if (!validators_->equation.IsValid(modeAlpha)) {
241 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha,
242 "modeAlpha");
243 return error::kNoError;
245 if (state_.blend_equation_rgb != modeRGB ||
246 state_.blend_equation_alpha != modeAlpha) {
247 state_.blend_equation_rgb = modeRGB;
248 state_.blend_equation_alpha = modeAlpha;
249 glBlendEquationSeparate(modeRGB, modeAlpha);
251 return error::kNoError;
254 error::Error GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size,
255 const void* cmd_data) {
256 const gles2::cmds::BlendFunc& c =
257 *static_cast<const gles2::cmds::BlendFunc*>(cmd_data);
258 (void)c;
259 GLenum sfactor = static_cast<GLenum>(c.sfactor);
260 GLenum dfactor = static_cast<GLenum>(c.dfactor);
261 if (!validators_->src_blend_factor.IsValid(sfactor)) {
262 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor, "sfactor");
263 return error::kNoError;
265 if (!validators_->dst_blend_factor.IsValid(dfactor)) {
266 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor, "dfactor");
267 return error::kNoError;
269 if (state_.blend_source_rgb != sfactor || state_.blend_dest_rgb != dfactor ||
270 state_.blend_source_alpha != sfactor ||
271 state_.blend_dest_alpha != dfactor) {
272 state_.blend_source_rgb = sfactor;
273 state_.blend_dest_rgb = dfactor;
274 state_.blend_source_alpha = sfactor;
275 state_.blend_dest_alpha = dfactor;
276 glBlendFunc(sfactor, dfactor);
278 return error::kNoError;
281 error::Error GLES2DecoderImpl::HandleBlendFuncSeparate(
282 uint32_t immediate_data_size,
283 const void* cmd_data) {
284 const gles2::cmds::BlendFuncSeparate& c =
285 *static_cast<const gles2::cmds::BlendFuncSeparate*>(cmd_data);
286 (void)c;
287 GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
288 GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
289 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
290 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
291 if (!validators_->src_blend_factor.IsValid(srcRGB)) {
292 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB, "srcRGB");
293 return error::kNoError;
295 if (!validators_->dst_blend_factor.IsValid(dstRGB)) {
296 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB, "dstRGB");
297 return error::kNoError;
299 if (!validators_->src_blend_factor.IsValid(srcAlpha)) {
300 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha,
301 "srcAlpha");
302 return error::kNoError;
304 if (!validators_->dst_blend_factor.IsValid(dstAlpha)) {
305 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha,
306 "dstAlpha");
307 return error::kNoError;
309 if (state_.blend_source_rgb != srcRGB || state_.blend_dest_rgb != dstRGB ||
310 state_.blend_source_alpha != srcAlpha ||
311 state_.blend_dest_alpha != dstAlpha) {
312 state_.blend_source_rgb = srcRGB;
313 state_.blend_dest_rgb = dstRGB;
314 state_.blend_source_alpha = srcAlpha;
315 state_.blend_dest_alpha = dstAlpha;
316 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
318 return error::kNoError;
321 error::Error GLES2DecoderImpl::HandleBufferSubData(uint32_t immediate_data_size,
322 const void* cmd_data) {
323 const gles2::cmds::BufferSubData& c =
324 *static_cast<const gles2::cmds::BufferSubData*>(cmd_data);
325 (void)c;
326 GLenum target = static_cast<GLenum>(c.target);
327 GLintptr offset = static_cast<GLintptr>(c.offset);
328 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
329 uint32_t data_size = size;
330 const void* data = GetSharedMemoryAs<const void*>(
331 c.data_shm_id, c.data_shm_offset, data_size);
332 if (!validators_->buffer_target.IsValid(target)) {
333 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target, "target");
334 return error::kNoError;
336 if (size < 0) {
337 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
338 return error::kNoError;
340 if (data == NULL) {
341 return error::kOutOfBounds;
343 DoBufferSubData(target, offset, size, data);
344 return error::kNoError;
347 error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus(
348 uint32_t immediate_data_size,
349 const void* cmd_data) {
350 const gles2::cmds::CheckFramebufferStatus& c =
351 *static_cast<const gles2::cmds::CheckFramebufferStatus*>(cmd_data);
352 (void)c;
353 GLenum target = static_cast<GLenum>(c.target);
354 typedef cmds::CheckFramebufferStatus::Result Result;
355 Result* result_dst = GetSharedMemoryAs<Result*>(
356 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
357 if (!result_dst) {
358 return error::kOutOfBounds;
360 if (!validators_->frame_buffer_target.IsValid(target)) {
361 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target,
362 "target");
363 return error::kNoError;
365 *result_dst = DoCheckFramebufferStatus(target);
366 return error::kNoError;
369 error::Error GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size,
370 const void* cmd_data) {
371 const gles2::cmds::Clear& c =
372 *static_cast<const gles2::cmds::Clear*>(cmd_data);
373 (void)c;
374 error::Error error;
375 error = WillAccessBoundFramebufferForDraw();
376 if (error != error::kNoError)
377 return error;
378 GLbitfield mask = static_cast<GLbitfield>(c.mask);
379 DoClear(mask);
380 return error::kNoError;
383 error::Error GLES2DecoderImpl::HandleClearBufferfi(uint32_t immediate_data_size,
384 const void* cmd_data) {
385 if (!unsafe_es3_apis_enabled())
386 return error::kUnknownCommand;
387 const gles2::cmds::ClearBufferfi& c =
388 *static_cast<const gles2::cmds::ClearBufferfi*>(cmd_data);
389 (void)c;
390 GLenum buffer = static_cast<GLenum>(c.buffer);
391 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
392 GLfloat depth = static_cast<GLfloat>(c.depth);
393 GLint stencil = static_cast<GLint>(c.stencil);
394 glClearBufferfi(buffer, drawbuffers, depth, stencil);
395 return error::kNoError;
398 error::Error GLES2DecoderImpl::HandleClearBufferfvImmediate(
399 uint32_t immediate_data_size,
400 const void* cmd_data) {
401 if (!unsafe_es3_apis_enabled())
402 return error::kUnknownCommand;
403 const gles2::cmds::ClearBufferfvImmediate& c =
404 *static_cast<const gles2::cmds::ClearBufferfvImmediate*>(cmd_data);
405 (void)c;
406 GLenum buffer = static_cast<GLenum>(c.buffer);
407 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
408 uint32_t data_size;
409 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
410 return error::kOutOfBounds;
412 if (data_size > immediate_data_size) {
413 return error::kOutOfBounds;
415 const GLfloat* value =
416 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
417 if (value == NULL) {
418 return error::kOutOfBounds;
420 glClearBufferfv(buffer, drawbuffers, value);
421 return error::kNoError;
424 error::Error GLES2DecoderImpl::HandleClearBufferivImmediate(
425 uint32_t immediate_data_size,
426 const void* cmd_data) {
427 if (!unsafe_es3_apis_enabled())
428 return error::kUnknownCommand;
429 const gles2::cmds::ClearBufferivImmediate& c =
430 *static_cast<const gles2::cmds::ClearBufferivImmediate*>(cmd_data);
431 (void)c;
432 GLenum buffer = static_cast<GLenum>(c.buffer);
433 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
434 uint32_t data_size;
435 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
436 return error::kOutOfBounds;
438 if (data_size > immediate_data_size) {
439 return error::kOutOfBounds;
441 const GLint* value =
442 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
443 if (value == NULL) {
444 return error::kOutOfBounds;
446 glClearBufferiv(buffer, drawbuffers, value);
447 return error::kNoError;
450 error::Error GLES2DecoderImpl::HandleClearBufferuivImmediate(
451 uint32_t immediate_data_size,
452 const void* cmd_data) {
453 if (!unsafe_es3_apis_enabled())
454 return error::kUnknownCommand;
455 const gles2::cmds::ClearBufferuivImmediate& c =
456 *static_cast<const gles2::cmds::ClearBufferuivImmediate*>(cmd_data);
457 (void)c;
458 GLenum buffer = static_cast<GLenum>(c.buffer);
459 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
460 uint32_t data_size;
461 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
462 return error::kOutOfBounds;
464 if (data_size > immediate_data_size) {
465 return error::kOutOfBounds;
467 const GLuint* value =
468 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
469 if (value == NULL) {
470 return error::kOutOfBounds;
472 glClearBufferuiv(buffer, drawbuffers, value);
473 return error::kNoError;
476 error::Error GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size,
477 const void* cmd_data) {
478 const gles2::cmds::ClearColor& c =
479 *static_cast<const gles2::cmds::ClearColor*>(cmd_data);
480 (void)c;
481 GLclampf red = static_cast<GLclampf>(c.red);
482 GLclampf green = static_cast<GLclampf>(c.green);
483 GLclampf blue = static_cast<GLclampf>(c.blue);
484 GLclampf alpha = static_cast<GLclampf>(c.alpha);
485 if (state_.color_clear_red != red || state_.color_clear_green != green ||
486 state_.color_clear_blue != blue || state_.color_clear_alpha != alpha) {
487 state_.color_clear_red = red;
488 state_.color_clear_green = green;
489 state_.color_clear_blue = blue;
490 state_.color_clear_alpha = alpha;
491 glClearColor(red, green, blue, alpha);
493 return error::kNoError;
496 error::Error GLES2DecoderImpl::HandleClearDepthf(uint32_t immediate_data_size,
497 const void* cmd_data) {
498 const gles2::cmds::ClearDepthf& c =
499 *static_cast<const gles2::cmds::ClearDepthf*>(cmd_data);
500 (void)c;
501 GLclampf depth = static_cast<GLclampf>(c.depth);
502 if (state_.depth_clear != depth) {
503 state_.depth_clear = depth;
504 glClearDepth(depth);
506 return error::kNoError;
509 error::Error GLES2DecoderImpl::HandleClearStencil(uint32_t immediate_data_size,
510 const void* cmd_data) {
511 const gles2::cmds::ClearStencil& c =
512 *static_cast<const gles2::cmds::ClearStencil*>(cmd_data);
513 (void)c;
514 GLint s = static_cast<GLint>(c.s);
515 if (state_.stencil_clear != s) {
516 state_.stencil_clear = s;
517 glClearStencil(s);
519 return error::kNoError;
522 error::Error GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size,
523 const void* cmd_data) {
524 const gles2::cmds::ColorMask& c =
525 *static_cast<const gles2::cmds::ColorMask*>(cmd_data);
526 (void)c;
527 GLboolean red = static_cast<GLboolean>(c.red);
528 GLboolean green = static_cast<GLboolean>(c.green);
529 GLboolean blue = static_cast<GLboolean>(c.blue);
530 GLboolean alpha = static_cast<GLboolean>(c.alpha);
531 if (state_.color_mask_red != red || state_.color_mask_green != green ||
532 state_.color_mask_blue != blue || state_.color_mask_alpha != alpha) {
533 state_.color_mask_red = red;
534 state_.color_mask_green = green;
535 state_.color_mask_blue = blue;
536 state_.color_mask_alpha = alpha;
537 framebuffer_state_.clear_state_dirty = true;
539 return error::kNoError;
542 error::Error GLES2DecoderImpl::HandleCompileShader(uint32_t immediate_data_size,
543 const void* cmd_data) {
544 const gles2::cmds::CompileShader& c =
545 *static_cast<const gles2::cmds::CompileShader*>(cmd_data);
546 (void)c;
547 GLuint shader = c.shader;
548 DoCompileShader(shader);
549 return error::kNoError;
552 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2D(
553 uint32_t immediate_data_size,
554 const void* cmd_data) {
555 const gles2::cmds::CompressedTexSubImage2D& c =
556 *static_cast<const gles2::cmds::CompressedTexSubImage2D*>(cmd_data);
557 (void)c;
558 GLenum target = static_cast<GLenum>(c.target);
559 GLint level = static_cast<GLint>(c.level);
560 GLint xoffset = static_cast<GLint>(c.xoffset);
561 GLint yoffset = static_cast<GLint>(c.yoffset);
562 GLsizei width = static_cast<GLsizei>(c.width);
563 GLsizei height = static_cast<GLsizei>(c.height);
564 GLenum format = static_cast<GLenum>(c.format);
565 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
566 uint32_t data_size = imageSize;
567 const void* data = GetSharedMemoryAs<const void*>(
568 c.data_shm_id, c.data_shm_offset, data_size);
569 if (!validators_->texture_target.IsValid(target)) {
570 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", target,
571 "target");
572 return error::kNoError;
574 if (width < 0) {
575 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
576 "width < 0");
577 return error::kNoError;
579 if (height < 0) {
580 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
581 "height < 0");
582 return error::kNoError;
584 if (!validators_->compressed_texture_format.IsValid(format)) {
585 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", format,
586 "format");
587 return error::kNoError;
589 if (imageSize < 0) {
590 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
591 "imageSize < 0");
592 return error::kNoError;
594 if (data == NULL) {
595 return error::kOutOfBounds;
597 DoCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
598 format, imageSize, data);
599 return error::kNoError;
602 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage3D(
603 uint32_t immediate_data_size,
604 const void* cmd_data) {
605 if (!unsafe_es3_apis_enabled())
606 return error::kUnknownCommand;
607 const gles2::cmds::CompressedTexSubImage3D& c =
608 *static_cast<const gles2::cmds::CompressedTexSubImage3D*>(cmd_data);
609 (void)c;
610 GLenum target = static_cast<GLenum>(c.target);
611 GLint level = static_cast<GLint>(c.level);
612 GLint xoffset = static_cast<GLint>(c.xoffset);
613 GLint yoffset = static_cast<GLint>(c.yoffset);
614 GLint zoffset = static_cast<GLint>(c.zoffset);
615 GLsizei width = static_cast<GLsizei>(c.width);
616 GLsizei height = static_cast<GLsizei>(c.height);
617 GLsizei depth = static_cast<GLsizei>(c.depth);
618 GLenum format = static_cast<GLenum>(c.format);
619 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
620 uint32_t data_size = imageSize;
621 const void* data = GetSharedMemoryAs<const void*>(
622 c.data_shm_id, c.data_shm_offset, data_size);
623 if (data == NULL) {
624 return error::kOutOfBounds;
626 DoCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width,
627 height, depth, format, imageSize, data);
628 return error::kNoError;
631 error::Error GLES2DecoderImpl::HandleCopyBufferSubData(
632 uint32_t immediate_data_size,
633 const void* cmd_data) {
634 if (!unsafe_es3_apis_enabled())
635 return error::kUnknownCommand;
636 const gles2::cmds::CopyBufferSubData& c =
637 *static_cast<const gles2::cmds::CopyBufferSubData*>(cmd_data);
638 (void)c;
639 GLenum readtarget = static_cast<GLenum>(c.readtarget);
640 GLenum writetarget = static_cast<GLenum>(c.writetarget);
641 GLintptr readoffset = static_cast<GLintptr>(c.readoffset);
642 GLintptr writeoffset = static_cast<GLintptr>(c.writeoffset);
643 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
644 glCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
645 return error::kNoError;
648 error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
649 uint32_t immediate_data_size,
650 const void* cmd_data) {
651 const gles2::cmds::CopyTexImage2D& c =
652 *static_cast<const gles2::cmds::CopyTexImage2D*>(cmd_data);
653 (void)c;
654 error::Error error;
655 error = WillAccessBoundFramebufferForRead();
656 if (error != error::kNoError)
657 return error;
658 GLenum target = static_cast<GLenum>(c.target);
659 GLint level = static_cast<GLint>(c.level);
660 GLenum internalformat = static_cast<GLenum>(c.internalformat);
661 GLint x = static_cast<GLint>(c.x);
662 GLint y = static_cast<GLint>(c.y);
663 GLsizei width = static_cast<GLsizei>(c.width);
664 GLsizei height = static_cast<GLsizei>(c.height);
665 GLint border = static_cast<GLint>(c.border);
666 if (!validators_->texture_target.IsValid(target)) {
667 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target, "target");
668 return error::kNoError;
670 if (!validators_->texture_internal_format.IsValid(internalformat)) {
671 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat,
672 "internalformat");
673 return error::kNoError;
675 if (width < 0) {
676 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
677 return error::kNoError;
679 if (height < 0) {
680 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
681 return error::kNoError;
683 DoCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
684 return error::kNoError;
687 error::Error GLES2DecoderImpl::HandleCopyTexSubImage2D(
688 uint32_t immediate_data_size,
689 const void* cmd_data) {
690 const gles2::cmds::CopyTexSubImage2D& c =
691 *static_cast<const gles2::cmds::CopyTexSubImage2D*>(cmd_data);
692 (void)c;
693 error::Error error;
694 error = WillAccessBoundFramebufferForRead();
695 if (error != error::kNoError)
696 return error;
697 GLenum target = static_cast<GLenum>(c.target);
698 GLint level = static_cast<GLint>(c.level);
699 GLint xoffset = static_cast<GLint>(c.xoffset);
700 GLint yoffset = static_cast<GLint>(c.yoffset);
701 GLint x = static_cast<GLint>(c.x);
702 GLint y = static_cast<GLint>(c.y);
703 GLsizei width = static_cast<GLsizei>(c.width);
704 GLsizei height = static_cast<GLsizei>(c.height);
705 if (!validators_->texture_target.IsValid(target)) {
706 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target, "target");
707 return error::kNoError;
709 if (width < 0) {
710 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
711 return error::kNoError;
713 if (height < 0) {
714 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
715 return error::kNoError;
717 DoCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
718 return error::kNoError;
721 error::Error GLES2DecoderImpl::HandleCopyTexSubImage3D(
722 uint32_t immediate_data_size,
723 const void* cmd_data) {
724 if (!unsafe_es3_apis_enabled())
725 return error::kUnknownCommand;
726 const gles2::cmds::CopyTexSubImage3D& c =
727 *static_cast<const gles2::cmds::CopyTexSubImage3D*>(cmd_data);
728 (void)c;
729 error::Error error;
730 error = WillAccessBoundFramebufferForRead();
731 if (error != error::kNoError)
732 return error;
733 GLenum target = static_cast<GLenum>(c.target);
734 GLint level = static_cast<GLint>(c.level);
735 GLint xoffset = static_cast<GLint>(c.xoffset);
736 GLint yoffset = static_cast<GLint>(c.yoffset);
737 GLint zoffset = static_cast<GLint>(c.zoffset);
738 GLint x = static_cast<GLint>(c.x);
739 GLint y = static_cast<GLint>(c.y);
740 GLsizei width = static_cast<GLsizei>(c.width);
741 GLsizei height = static_cast<GLsizei>(c.height);
742 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
743 height);
744 return error::kNoError;
747 error::Error GLES2DecoderImpl::HandleCreateProgram(uint32_t immediate_data_size,
748 const void* cmd_data) {
749 const gles2::cmds::CreateProgram& c =
750 *static_cast<const gles2::cmds::CreateProgram*>(cmd_data);
751 (void)c;
752 uint32_t client_id = c.client_id;
753 if (GetProgram(client_id)) {
754 return error::kInvalidArguments;
756 GLuint service_id = glCreateProgram();
757 if (service_id) {
758 CreateProgram(client_id, service_id);
760 return error::kNoError;
763 error::Error GLES2DecoderImpl::HandleCreateShader(uint32_t immediate_data_size,
764 const void* cmd_data) {
765 const gles2::cmds::CreateShader& c =
766 *static_cast<const gles2::cmds::CreateShader*>(cmd_data);
767 (void)c;
768 GLenum type = static_cast<GLenum>(c.type);
769 if (!validators_->shader_type.IsValid(type)) {
770 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type, "type");
771 return error::kNoError;
773 uint32_t client_id = c.client_id;
774 if (GetShader(client_id)) {
775 return error::kInvalidArguments;
777 GLuint service_id = glCreateShader(type);
778 if (service_id) {
779 CreateShader(client_id, service_id, type);
781 return error::kNoError;
784 error::Error GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size,
785 const void* cmd_data) {
786 const gles2::cmds::CullFace& c =
787 *static_cast<const gles2::cmds::CullFace*>(cmd_data);
788 (void)c;
789 GLenum mode = static_cast<GLenum>(c.mode);
790 if (!validators_->face_type.IsValid(mode)) {
791 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode, "mode");
792 return error::kNoError;
794 if (state_.cull_mode != mode) {
795 state_.cull_mode = mode;
796 glCullFace(mode);
798 return error::kNoError;
801 error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
802 uint32_t immediate_data_size,
803 const void* cmd_data) {
804 const gles2::cmds::DeleteBuffersImmediate& c =
805 *static_cast<const gles2::cmds::DeleteBuffersImmediate*>(cmd_data);
806 (void)c;
807 GLsizei n = static_cast<GLsizei>(c.n);
808 uint32_t data_size;
809 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
810 return error::kOutOfBounds;
812 const GLuint* buffers =
813 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
814 if (buffers == NULL) {
815 return error::kOutOfBounds;
817 DeleteBuffersHelper(n, buffers);
818 return error::kNoError;
821 error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
822 uint32_t immediate_data_size,
823 const void* cmd_data) {
824 const gles2::cmds::DeleteFramebuffersImmediate& c =
825 *static_cast<const gles2::cmds::DeleteFramebuffersImmediate*>(cmd_data);
826 (void)c;
827 GLsizei n = static_cast<GLsizei>(c.n);
828 uint32_t data_size;
829 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
830 return error::kOutOfBounds;
832 const GLuint* framebuffers =
833 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
834 if (framebuffers == NULL) {
835 return error::kOutOfBounds;
837 DeleteFramebuffersHelper(n, framebuffers);
838 return error::kNoError;
841 error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
842 uint32_t immediate_data_size,
843 const void* cmd_data) {
844 const gles2::cmds::DeleteRenderbuffersImmediate& c =
845 *static_cast<const gles2::cmds::DeleteRenderbuffersImmediate*>(cmd_data);
846 (void)c;
847 GLsizei n = static_cast<GLsizei>(c.n);
848 uint32_t data_size;
849 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
850 return error::kOutOfBounds;
852 const GLuint* renderbuffers =
853 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
854 if (renderbuffers == NULL) {
855 return error::kOutOfBounds;
857 DeleteRenderbuffersHelper(n, renderbuffers);
858 return error::kNoError;
861 error::Error GLES2DecoderImpl::HandleDeleteSamplersImmediate(
862 uint32_t immediate_data_size,
863 const void* cmd_data) {
864 if (!unsafe_es3_apis_enabled())
865 return error::kUnknownCommand;
866 const gles2::cmds::DeleteSamplersImmediate& c =
867 *static_cast<const gles2::cmds::DeleteSamplersImmediate*>(cmd_data);
868 (void)c;
869 GLsizei n = static_cast<GLsizei>(c.n);
870 uint32_t data_size;
871 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
872 return error::kOutOfBounds;
874 const GLuint* samplers =
875 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
876 if (samplers == NULL) {
877 return error::kOutOfBounds;
879 for (GLsizei ii = 0; ii < n; ++ii) {
880 GLuint service_id = 0;
881 if (group_->GetSamplerServiceId(samplers[ii], &service_id)) {
882 glDeleteSamplers(1, &service_id);
883 group_->RemoveSamplerId(samplers[ii]);
886 return error::kNoError;
889 error::Error GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size,
890 const void* cmd_data) {
891 if (!unsafe_es3_apis_enabled())
892 return error::kUnknownCommand;
893 const gles2::cmds::DeleteSync& c =
894 *static_cast<const gles2::cmds::DeleteSync*>(cmd_data);
895 (void)c;
896 GLuint sync = c.sync;
897 GLsync service_id = 0;
898 if (group_->GetSyncServiceId(sync, &service_id)) {
899 glDeleteSync(service_id);
900 group_->RemoveSyncId(sync);
901 } else {
902 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDeleteSync", "unknown sync");
904 return error::kNoError;
907 error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
908 uint32_t immediate_data_size,
909 const void* cmd_data) {
910 const gles2::cmds::DeleteTexturesImmediate& c =
911 *static_cast<const gles2::cmds::DeleteTexturesImmediate*>(cmd_data);
912 (void)c;
913 GLsizei n = static_cast<GLsizei>(c.n);
914 uint32_t data_size;
915 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
916 return error::kOutOfBounds;
918 const GLuint* textures =
919 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
920 if (textures == NULL) {
921 return error::kOutOfBounds;
923 DeleteTexturesHelper(n, textures);
924 return error::kNoError;
927 error::Error GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
928 uint32_t immediate_data_size,
929 const void* cmd_data) {
930 if (!unsafe_es3_apis_enabled())
931 return error::kUnknownCommand;
932 const gles2::cmds::DeleteTransformFeedbacksImmediate& c =
933 *static_cast<const gles2::cmds::DeleteTransformFeedbacksImmediate*>(
934 cmd_data);
935 (void)c;
936 GLsizei n = static_cast<GLsizei>(c.n);
937 uint32_t data_size;
938 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
939 return error::kOutOfBounds;
941 const GLuint* ids =
942 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
943 if (ids == NULL) {
944 return error::kOutOfBounds;
946 for (GLsizei ii = 0; ii < n; ++ii) {
947 GLuint service_id = 0;
948 if (group_->GetTransformFeedbackServiceId(ids[ii], &service_id)) {
949 glDeleteTransformFeedbacks(1, &service_id);
950 group_->RemoveTransformFeedbackId(ids[ii]);
953 return error::kNoError;
956 error::Error GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size,
957 const void* cmd_data) {
958 const gles2::cmds::DepthFunc& c =
959 *static_cast<const gles2::cmds::DepthFunc*>(cmd_data);
960 (void)c;
961 GLenum func = static_cast<GLenum>(c.func);
962 if (!validators_->cmp_function.IsValid(func)) {
963 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func, "func");
964 return error::kNoError;
966 if (state_.depth_func != func) {
967 state_.depth_func = func;
968 glDepthFunc(func);
970 return error::kNoError;
973 error::Error GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size,
974 const void* cmd_data) {
975 const gles2::cmds::DepthMask& c =
976 *static_cast<const gles2::cmds::DepthMask*>(cmd_data);
977 (void)c;
978 GLboolean flag = static_cast<GLboolean>(c.flag);
979 if (state_.depth_mask != flag) {
980 state_.depth_mask = flag;
981 framebuffer_state_.clear_state_dirty = true;
983 return error::kNoError;
986 error::Error GLES2DecoderImpl::HandleDepthRangef(uint32_t immediate_data_size,
987 const void* cmd_data) {
988 const gles2::cmds::DepthRangef& c =
989 *static_cast<const gles2::cmds::DepthRangef*>(cmd_data);
990 (void)c;
991 GLclampf zNear = static_cast<GLclampf>(c.zNear);
992 GLclampf zFar = static_cast<GLclampf>(c.zFar);
993 DoDepthRangef(zNear, zFar);
994 return error::kNoError;
997 error::Error GLES2DecoderImpl::HandleDetachShader(uint32_t immediate_data_size,
998 const void* cmd_data) {
999 const gles2::cmds::DetachShader& c =
1000 *static_cast<const gles2::cmds::DetachShader*>(cmd_data);
1001 (void)c;
1002 GLuint program = c.program;
1003 GLuint shader = c.shader;
1004 DoDetachShader(program, shader);
1005 return error::kNoError;
1008 error::Error GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size,
1009 const void* cmd_data) {
1010 const gles2::cmds::Disable& c =
1011 *static_cast<const gles2::cmds::Disable*>(cmd_data);
1012 (void)c;
1013 GLenum cap = static_cast<GLenum>(c.cap);
1014 if (!validators_->capability.IsValid(cap)) {
1015 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap, "cap");
1016 return error::kNoError;
1018 DoDisable(cap);
1019 return error::kNoError;
1022 error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
1023 uint32_t immediate_data_size,
1024 const void* cmd_data) {
1025 const gles2::cmds::DisableVertexAttribArray& c =
1026 *static_cast<const gles2::cmds::DisableVertexAttribArray*>(cmd_data);
1027 (void)c;
1028 GLuint index = static_cast<GLuint>(c.index);
1029 DoDisableVertexAttribArray(index);
1030 return error::kNoError;
1033 error::Error GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size,
1034 const void* cmd_data) {
1035 const gles2::cmds::Enable& c =
1036 *static_cast<const gles2::cmds::Enable*>(cmd_data);
1037 (void)c;
1038 GLenum cap = static_cast<GLenum>(c.cap);
1039 if (!validators_->capability.IsValid(cap)) {
1040 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap, "cap");
1041 return error::kNoError;
1043 DoEnable(cap);
1044 return error::kNoError;
1047 error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
1048 uint32_t immediate_data_size,
1049 const void* cmd_data) {
1050 const gles2::cmds::EnableVertexAttribArray& c =
1051 *static_cast<const gles2::cmds::EnableVertexAttribArray*>(cmd_data);
1052 (void)c;
1053 GLuint index = static_cast<GLuint>(c.index);
1054 DoEnableVertexAttribArray(index);
1055 return error::kNoError;
1058 error::Error GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size,
1059 const void* cmd_data) {
1060 if (!unsafe_es3_apis_enabled())
1061 return error::kUnknownCommand;
1062 const gles2::cmds::FenceSync& c =
1063 *static_cast<const gles2::cmds::FenceSync*>(cmd_data);
1064 (void)c;
1065 GLenum condition = static_cast<GLenum>(c.condition);
1066 GLbitfield flags = static_cast<GLbitfield>(c.flags);
1067 uint32_t client_id = c.client_id;
1068 GLsync service_id = 0;
1069 if (group_->GetSyncServiceId(client_id, &service_id)) {
1070 return error::kInvalidArguments;
1072 service_id = glFenceSync(condition, flags);
1073 if (service_id) {
1074 group_->AddSyncId(client_id, service_id);
1076 return error::kNoError;
1079 error::Error GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size,
1080 const void* cmd_data) {
1081 const gles2::cmds::Finish& c =
1082 *static_cast<const gles2::cmds::Finish*>(cmd_data);
1083 (void)c;
1084 error::Error error;
1085 error = WillAccessBoundFramebufferForRead();
1086 if (error != error::kNoError)
1087 return error;
1088 DoFinish();
1089 return error::kNoError;
1092 error::Error GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size,
1093 const void* cmd_data) {
1094 const gles2::cmds::Flush& c =
1095 *static_cast<const gles2::cmds::Flush*>(cmd_data);
1096 (void)c;
1097 DoFlush();
1098 return error::kNoError;
1101 error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
1102 uint32_t immediate_data_size,
1103 const void* cmd_data) {
1104 const gles2::cmds::FramebufferRenderbuffer& c =
1105 *static_cast<const gles2::cmds::FramebufferRenderbuffer*>(cmd_data);
1106 (void)c;
1107 GLenum target = static_cast<GLenum>(c.target);
1108 GLenum attachment = static_cast<GLenum>(c.attachment);
1109 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
1110 GLuint renderbuffer = c.renderbuffer;
1111 if (!validators_->frame_buffer_target.IsValid(target)) {
1112 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target,
1113 "target");
1114 return error::kNoError;
1116 if (!validators_->attachment.IsValid(attachment)) {
1117 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment,
1118 "attachment");
1119 return error::kNoError;
1121 if (!validators_->render_buffer_target.IsValid(renderbuffertarget)) {
1122 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
1123 renderbuffertarget, "renderbuffertarget");
1124 return error::kNoError;
1126 DoFramebufferRenderbuffer(target, attachment, renderbuffertarget,
1127 renderbuffer);
1128 return error::kNoError;
1131 error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
1132 uint32_t immediate_data_size,
1133 const void* cmd_data) {
1134 const gles2::cmds::FramebufferTexture2D& c =
1135 *static_cast<const gles2::cmds::FramebufferTexture2D*>(cmd_data);
1136 (void)c;
1137 GLenum target = static_cast<GLenum>(c.target);
1138 GLenum attachment = static_cast<GLenum>(c.attachment);
1139 GLenum textarget = static_cast<GLenum>(c.textarget);
1140 GLuint texture = c.texture;
1141 GLint level = static_cast<GLint>(c.level);
1142 if (!validators_->frame_buffer_target.IsValid(target)) {
1143 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target, "target");
1144 return error::kNoError;
1146 if (!validators_->attachment.IsValid(attachment)) {
1147 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment,
1148 "attachment");
1149 return error::kNoError;
1151 if (!validators_->texture_target.IsValid(textarget)) {
1152 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget,
1153 "textarget");
1154 return error::kNoError;
1156 DoFramebufferTexture2D(target, attachment, textarget, texture, level);
1157 return error::kNoError;
1160 error::Error GLES2DecoderImpl::HandleFramebufferTextureLayer(
1161 uint32_t immediate_data_size,
1162 const void* cmd_data) {
1163 if (!unsafe_es3_apis_enabled())
1164 return error::kUnknownCommand;
1165 const gles2::cmds::FramebufferTextureLayer& c =
1166 *static_cast<const gles2::cmds::FramebufferTextureLayer*>(cmd_data);
1167 (void)c;
1168 GLenum target = static_cast<GLenum>(c.target);
1169 GLenum attachment = static_cast<GLenum>(c.attachment);
1170 GLuint texture = c.texture;
1171 GLint level = static_cast<GLint>(c.level);
1172 GLint layer = static_cast<GLint>(c.layer);
1173 DoFramebufferTextureLayer(target, attachment, texture, level, layer);
1174 return error::kNoError;
1177 error::Error GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size,
1178 const void* cmd_data) {
1179 const gles2::cmds::FrontFace& c =
1180 *static_cast<const gles2::cmds::FrontFace*>(cmd_data);
1181 (void)c;
1182 GLenum mode = static_cast<GLenum>(c.mode);
1183 if (!validators_->face_mode.IsValid(mode)) {
1184 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode, "mode");
1185 return error::kNoError;
1187 if (state_.front_face != mode) {
1188 state_.front_face = mode;
1189 glFrontFace(mode);
1191 return error::kNoError;
1194 error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
1195 uint32_t immediate_data_size,
1196 const void* cmd_data) {
1197 const gles2::cmds::GenBuffersImmediate& c =
1198 *static_cast<const gles2::cmds::GenBuffersImmediate*>(cmd_data);
1199 (void)c;
1200 GLsizei n = static_cast<GLsizei>(c.n);
1201 uint32_t data_size;
1202 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1203 return error::kOutOfBounds;
1205 GLuint* buffers =
1206 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1207 if (buffers == NULL) {
1208 return error::kOutOfBounds;
1210 if (!GenBuffersHelper(n, buffers)) {
1211 return error::kInvalidArguments;
1213 return error::kNoError;
1216 error::Error GLES2DecoderImpl::HandleGenerateMipmap(
1217 uint32_t immediate_data_size,
1218 const void* cmd_data) {
1219 const gles2::cmds::GenerateMipmap& c =
1220 *static_cast<const gles2::cmds::GenerateMipmap*>(cmd_data);
1221 (void)c;
1222 GLenum target = static_cast<GLenum>(c.target);
1223 if (!validators_->texture_bind_target.IsValid(target)) {
1224 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target, "target");
1225 return error::kNoError;
1227 DoGenerateMipmap(target);
1228 return error::kNoError;
1231 error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
1232 uint32_t immediate_data_size,
1233 const void* cmd_data) {
1234 const gles2::cmds::GenFramebuffersImmediate& c =
1235 *static_cast<const gles2::cmds::GenFramebuffersImmediate*>(cmd_data);
1236 (void)c;
1237 GLsizei n = static_cast<GLsizei>(c.n);
1238 uint32_t data_size;
1239 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1240 return error::kOutOfBounds;
1242 GLuint* framebuffers =
1243 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1244 if (framebuffers == NULL) {
1245 return error::kOutOfBounds;
1247 if (!GenFramebuffersHelper(n, framebuffers)) {
1248 return error::kInvalidArguments;
1250 return error::kNoError;
1253 error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
1254 uint32_t immediate_data_size,
1255 const void* cmd_data) {
1256 const gles2::cmds::GenRenderbuffersImmediate& c =
1257 *static_cast<const gles2::cmds::GenRenderbuffersImmediate*>(cmd_data);
1258 (void)c;
1259 GLsizei n = static_cast<GLsizei>(c.n);
1260 uint32_t data_size;
1261 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1262 return error::kOutOfBounds;
1264 GLuint* renderbuffers =
1265 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1266 if (renderbuffers == NULL) {
1267 return error::kOutOfBounds;
1269 if (!GenRenderbuffersHelper(n, renderbuffers)) {
1270 return error::kInvalidArguments;
1272 return error::kNoError;
1275 error::Error GLES2DecoderImpl::HandleGenSamplersImmediate(
1276 uint32_t immediate_data_size,
1277 const void* cmd_data) {
1278 if (!unsafe_es3_apis_enabled())
1279 return error::kUnknownCommand;
1280 const gles2::cmds::GenSamplersImmediate& c =
1281 *static_cast<const gles2::cmds::GenSamplersImmediate*>(cmd_data);
1282 (void)c;
1283 GLsizei n = static_cast<GLsizei>(c.n);
1284 uint32_t data_size;
1285 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1286 return error::kOutOfBounds;
1288 GLuint* samplers =
1289 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1290 if (samplers == NULL) {
1291 return error::kOutOfBounds;
1293 for (GLsizei ii = 0; ii < n; ++ii) {
1294 if (group_->GetSamplerServiceId(samplers[ii], NULL)) {
1295 return error::kInvalidArguments;
1298 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1299 glGenSamplers(n, service_ids.get());
1300 for (GLsizei ii = 0; ii < n; ++ii) {
1301 group_->AddSamplerId(samplers[ii], service_ids[ii]);
1303 return error::kNoError;
1306 error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
1307 uint32_t immediate_data_size,
1308 const void* cmd_data) {
1309 const gles2::cmds::GenTexturesImmediate& c =
1310 *static_cast<const gles2::cmds::GenTexturesImmediate*>(cmd_data);
1311 (void)c;
1312 GLsizei n = static_cast<GLsizei>(c.n);
1313 uint32_t data_size;
1314 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1315 return error::kOutOfBounds;
1317 GLuint* textures =
1318 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1319 if (textures == NULL) {
1320 return error::kOutOfBounds;
1322 if (!GenTexturesHelper(n, textures)) {
1323 return error::kInvalidArguments;
1325 return error::kNoError;
1328 error::Error GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
1329 uint32_t immediate_data_size,
1330 const void* cmd_data) {
1331 if (!unsafe_es3_apis_enabled())
1332 return error::kUnknownCommand;
1333 const gles2::cmds::GenTransformFeedbacksImmediate& c =
1334 *static_cast<const gles2::cmds::GenTransformFeedbacksImmediate*>(
1335 cmd_data);
1336 (void)c;
1337 GLsizei n = static_cast<GLsizei>(c.n);
1338 uint32_t data_size;
1339 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1340 return error::kOutOfBounds;
1342 GLuint* ids = GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1343 if (ids == NULL) {
1344 return error::kOutOfBounds;
1346 for (GLsizei ii = 0; ii < n; ++ii) {
1347 if (group_->GetTransformFeedbackServiceId(ids[ii], NULL)) {
1348 return error::kInvalidArguments;
1351 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1352 glGenTransformFeedbacks(n, service_ids.get());
1353 for (GLsizei ii = 0; ii < n; ++ii) {
1354 group_->AddTransformFeedbackId(ids[ii], service_ids[ii]);
1356 return error::kNoError;
1359 error::Error GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size,
1360 const void* cmd_data) {
1361 const gles2::cmds::GetBooleanv& c =
1362 *static_cast<const gles2::cmds::GetBooleanv*>(cmd_data);
1363 (void)c;
1364 GLenum pname = static_cast<GLenum>(c.pname);
1365 typedef cmds::GetBooleanv::Result Result;
1366 GLsizei num_values = 0;
1367 GetNumValuesReturnedForGLGet(pname, &num_values);
1368 Result* result = GetSharedMemoryAs<Result*>(
1369 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1370 GLboolean* params = result ? result->GetData() : NULL;
1371 if (!validators_->g_l_state.IsValid(pname)) {
1372 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname, "pname");
1373 return error::kNoError;
1375 if (params == NULL) {
1376 return error::kOutOfBounds;
1378 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
1379 // Check that the client initialized the result.
1380 if (result->size != 0) {
1381 return error::kInvalidArguments;
1383 DoGetBooleanv(pname, params);
1384 GLenum error = glGetError();
1385 if (error == GL_NO_ERROR) {
1386 result->SetNumResults(num_values);
1387 } else {
1388 LOCAL_SET_GL_ERROR(error, "GetBooleanv", "");
1390 return error::kNoError;
1393 error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
1394 uint32_t immediate_data_size,
1395 const void* cmd_data) {
1396 const gles2::cmds::GetBufferParameteriv& c =
1397 *static_cast<const gles2::cmds::GetBufferParameteriv*>(cmd_data);
1398 (void)c;
1399 GLenum target = static_cast<GLenum>(c.target);
1400 GLenum pname = static_cast<GLenum>(c.pname);
1401 typedef cmds::GetBufferParameteriv::Result Result;
1402 GLsizei num_values = 0;
1403 GetNumValuesReturnedForGLGet(pname, &num_values);
1404 Result* result = GetSharedMemoryAs<Result*>(
1405 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1406 GLint* params = result ? result->GetData() : NULL;
1407 if (!validators_->buffer_target.IsValid(target)) {
1408 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
1409 return error::kNoError;
1411 if (!validators_->buffer_parameter.IsValid(pname)) {
1412 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
1413 return error::kNoError;
1415 if (params == NULL) {
1416 return error::kOutOfBounds;
1418 // Check that the client initialized the result.
1419 if (result->size != 0) {
1420 return error::kInvalidArguments;
1422 DoGetBufferParameteriv(target, pname, params);
1423 result->SetNumResults(num_values);
1424 return error::kNoError;
1426 error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
1427 const void* cmd_data) {
1428 const gles2::cmds::GetError& c =
1429 *static_cast<const gles2::cmds::GetError*>(cmd_data);
1430 (void)c;
1431 typedef cmds::GetError::Result Result;
1432 Result* result_dst = GetSharedMemoryAs<Result*>(
1433 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1434 if (!result_dst) {
1435 return error::kOutOfBounds;
1437 *result_dst = GetErrorState()->GetGLError();
1438 return error::kNoError;
1441 error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
1442 const void* cmd_data) {
1443 const gles2::cmds::GetFloatv& c =
1444 *static_cast<const gles2::cmds::GetFloatv*>(cmd_data);
1445 (void)c;
1446 GLenum pname = static_cast<GLenum>(c.pname);
1447 typedef cmds::GetFloatv::Result Result;
1448 GLsizei num_values = 0;
1449 GetNumValuesReturnedForGLGet(pname, &num_values);
1450 Result* result = GetSharedMemoryAs<Result*>(
1451 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1452 GLfloat* params = result ? result->GetData() : NULL;
1453 if (!validators_->g_l_state.IsValid(pname)) {
1454 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
1455 return error::kNoError;
1457 if (params == NULL) {
1458 return error::kOutOfBounds;
1460 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1461 // Check that the client initialized the result.
1462 if (result->size != 0) {
1463 return error::kInvalidArguments;
1465 DoGetFloatv(pname, params);
1466 GLenum error = glGetError();
1467 if (error == GL_NO_ERROR) {
1468 result->SetNumResults(num_values);
1469 } else {
1470 LOCAL_SET_GL_ERROR(error, "GetFloatv", "");
1472 return error::kNoError;
1475 error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1476 uint32_t immediate_data_size,
1477 const void* cmd_data) {
1478 const gles2::cmds::GetFramebufferAttachmentParameteriv& c =
1479 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv*>(
1480 cmd_data);
1481 (void)c;
1482 GLenum target = static_cast<GLenum>(c.target);
1483 GLenum attachment = static_cast<GLenum>(c.attachment);
1484 GLenum pname = static_cast<GLenum>(c.pname);
1485 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
1486 GLsizei num_values = 0;
1487 GetNumValuesReturnedForGLGet(pname, &num_values);
1488 Result* result = GetSharedMemoryAs<Result*>(
1489 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1490 GLint* params = result ? result->GetData() : NULL;
1491 if (!validators_->frame_buffer_target.IsValid(target)) {
1492 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1493 target, "target");
1494 return error::kNoError;
1496 if (!validators_->attachment.IsValid(attachment)) {
1497 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1498 attachment, "attachment");
1499 return error::kNoError;
1501 if (!validators_->frame_buffer_parameter.IsValid(pname)) {
1502 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1503 pname, "pname");
1504 return error::kNoError;
1506 if (params == NULL) {
1507 return error::kOutOfBounds;
1509 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1510 // Check that the client initialized the result.
1511 if (result->size != 0) {
1512 return error::kInvalidArguments;
1514 DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1515 GLenum error = glGetError();
1516 if (error == GL_NO_ERROR) {
1517 result->SetNumResults(num_values);
1518 } else {
1519 LOCAL_SET_GL_ERROR(error, "GetFramebufferAttachmentParameteriv", "");
1521 return error::kNoError;
1524 error::Error GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size,
1525 const void* cmd_data) {
1526 if (!unsafe_es3_apis_enabled())
1527 return error::kUnknownCommand;
1528 const gles2::cmds::GetInteger64v& c =
1529 *static_cast<const gles2::cmds::GetInteger64v*>(cmd_data);
1530 (void)c;
1531 GLenum pname = static_cast<GLenum>(c.pname);
1532 typedef cmds::GetInteger64v::Result Result;
1533 GLsizei num_values = 0;
1534 GetNumValuesReturnedForGLGet(pname, &num_values);
1535 Result* result = GetSharedMemoryAs<Result*>(
1536 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1537 GLint64* params = result ? result->GetData() : NULL;
1538 if (params == NULL) {
1539 return error::kOutOfBounds;
1541 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
1542 // Check that the client initialized the result.
1543 if (result->size != 0) {
1544 return error::kInvalidArguments;
1546 DoGetInteger64v(pname, params);
1547 GLenum error = glGetError();
1548 if (error == GL_NO_ERROR) {
1549 result->SetNumResults(num_values);
1550 } else {
1551 LOCAL_SET_GL_ERROR(error, "GetInteger64v", "");
1553 return error::kNoError;
1556 error::Error GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size,
1557 const void* cmd_data) {
1558 if (!unsafe_es3_apis_enabled())
1559 return error::kUnknownCommand;
1560 const gles2::cmds::GetIntegeri_v& c =
1561 *static_cast<const gles2::cmds::GetIntegeri_v*>(cmd_data);
1562 (void)c;
1563 GLenum pname = static_cast<GLenum>(c.pname);
1564 GLuint index = static_cast<GLuint>(c.index);
1565 typedef cmds::GetIntegeri_v::Result Result;
1566 GLsizei num_values = 0;
1567 GetNumValuesReturnedForGLGet(pname, &num_values);
1568 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1569 Result::ComputeSize(num_values));
1570 GLint* data = result ? result->GetData() : NULL;
1571 if (data == NULL) {
1572 return error::kOutOfBounds;
1574 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegeri_v");
1575 // Check that the client initialized the result.
1576 if (result->size != 0) {
1577 return error::kInvalidArguments;
1579 glGetIntegeri_v(pname, index, data);
1580 GLenum error = glGetError();
1581 if (error == GL_NO_ERROR) {
1582 result->SetNumResults(num_values);
1583 } else {
1584 LOCAL_SET_GL_ERROR(error, "GetIntegeri_v", "");
1586 return error::kNoError;
1589 error::Error GLES2DecoderImpl::HandleGetInteger64i_v(
1590 uint32_t immediate_data_size,
1591 const void* cmd_data) {
1592 if (!unsafe_es3_apis_enabled())
1593 return error::kUnknownCommand;
1594 const gles2::cmds::GetInteger64i_v& c =
1595 *static_cast<const gles2::cmds::GetInteger64i_v*>(cmd_data);
1596 (void)c;
1597 GLenum pname = static_cast<GLenum>(c.pname);
1598 GLuint index = static_cast<GLuint>(c.index);
1599 typedef cmds::GetInteger64i_v::Result Result;
1600 GLsizei num_values = 0;
1601 GetNumValuesReturnedForGLGet(pname, &num_values);
1602 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1603 Result::ComputeSize(num_values));
1604 GLint64* data = result ? result->GetData() : NULL;
1605 if (data == NULL) {
1606 return error::kOutOfBounds;
1608 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64i_v");
1609 // Check that the client initialized the result.
1610 if (result->size != 0) {
1611 return error::kInvalidArguments;
1613 glGetInteger64i_v(pname, index, data);
1614 GLenum error = glGetError();
1615 if (error == GL_NO_ERROR) {
1616 result->SetNumResults(num_values);
1617 } else {
1618 LOCAL_SET_GL_ERROR(error, "GetInteger64i_v", "");
1620 return error::kNoError;
1623 error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size,
1624 const void* cmd_data) {
1625 const gles2::cmds::GetIntegerv& c =
1626 *static_cast<const gles2::cmds::GetIntegerv*>(cmd_data);
1627 (void)c;
1628 GLenum pname = static_cast<GLenum>(c.pname);
1629 typedef cmds::GetIntegerv::Result Result;
1630 GLsizei num_values = 0;
1631 GetNumValuesReturnedForGLGet(pname, &num_values);
1632 Result* result = GetSharedMemoryAs<Result*>(
1633 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1634 GLint* params = result ? result->GetData() : NULL;
1635 if (!validators_->g_l_state.IsValid(pname)) {
1636 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
1637 return error::kNoError;
1639 if (params == NULL) {
1640 return error::kOutOfBounds;
1642 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1643 // Check that the client initialized the result.
1644 if (result->size != 0) {
1645 return error::kInvalidArguments;
1647 DoGetIntegerv(pname, params);
1648 GLenum error = glGetError();
1649 if (error == GL_NO_ERROR) {
1650 result->SetNumResults(num_values);
1651 } else {
1652 LOCAL_SET_GL_ERROR(error, "GetIntegerv", "");
1654 return error::kNoError;
1657 error::Error GLES2DecoderImpl::HandleGetInternalformativ(
1658 uint32_t immediate_data_size,
1659 const void* cmd_data) {
1660 if (!unsafe_es3_apis_enabled())
1661 return error::kUnknownCommand;
1662 const gles2::cmds::GetInternalformativ& c =
1663 *static_cast<const gles2::cmds::GetInternalformativ*>(cmd_data);
1664 (void)c;
1665 GLenum target = static_cast<GLenum>(c.target);
1666 GLenum format = static_cast<GLenum>(c.format);
1667 GLenum pname = static_cast<GLenum>(c.pname);
1668 GLsizei bufSize = static_cast<GLsizei>(c.bufSize);
1669 typedef cmds::GetInternalformativ::Result Result;
1670 GLsizei num_values = 0;
1671 GetNumValuesReturnedForGLGet(pname, &num_values);
1672 Result* result = GetSharedMemoryAs<Result*>(
1673 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1674 GLint* params = result ? result->GetData() : NULL;
1675 if (params == NULL) {
1676 return error::kOutOfBounds;
1678 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInternalformativ");
1679 // Check that the client initialized the result.
1680 if (result->size != 0) {
1681 return error::kInvalidArguments;
1683 glGetInternalformativ(target, format, pname, bufSize, params);
1684 GLenum error = glGetError();
1685 if (error == GL_NO_ERROR) {
1686 result->SetNumResults(num_values);
1687 } else {
1688 LOCAL_SET_GL_ERROR(error, "GetInternalformativ", "");
1690 return error::kNoError;
1693 error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size,
1694 const void* cmd_data) {
1695 const gles2::cmds::GetProgramiv& c =
1696 *static_cast<const gles2::cmds::GetProgramiv*>(cmd_data);
1697 (void)c;
1698 GLuint program = c.program;
1699 GLenum pname = static_cast<GLenum>(c.pname);
1700 typedef cmds::GetProgramiv::Result Result;
1701 GLsizei num_values = 0;
1702 GetNumValuesReturnedForGLGet(pname, &num_values);
1703 Result* result = GetSharedMemoryAs<Result*>(
1704 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1705 GLint* params = result ? result->GetData() : NULL;
1706 if (!validators_->program_parameter.IsValid(pname)) {
1707 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
1708 return error::kNoError;
1710 if (params == NULL) {
1711 return error::kOutOfBounds;
1713 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1714 // Check that the client initialized the result.
1715 if (result->size != 0) {
1716 return error::kInvalidArguments;
1718 DoGetProgramiv(program, pname, params);
1719 GLenum error = glGetError();
1720 if (error == GL_NO_ERROR) {
1721 result->SetNumResults(num_values);
1722 } else {
1723 LOCAL_SET_GL_ERROR(error, "GetProgramiv", "");
1725 return error::kNoError;
1728 error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1729 uint32_t immediate_data_size,
1730 const void* cmd_data) {
1731 const gles2::cmds::GetRenderbufferParameteriv& c =
1732 *static_cast<const gles2::cmds::GetRenderbufferParameteriv*>(cmd_data);
1733 (void)c;
1734 GLenum target = static_cast<GLenum>(c.target);
1735 GLenum pname = static_cast<GLenum>(c.pname);
1736 typedef cmds::GetRenderbufferParameteriv::Result Result;
1737 GLsizei num_values = 0;
1738 GetNumValuesReturnedForGLGet(pname, &num_values);
1739 Result* result = GetSharedMemoryAs<Result*>(
1740 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1741 GLint* params = result ? result->GetData() : NULL;
1742 if (!validators_->render_buffer_target.IsValid(target)) {
1743 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
1744 "target");
1745 return error::kNoError;
1747 if (!validators_->render_buffer_parameter.IsValid(pname)) {
1748 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
1749 "pname");
1750 return error::kNoError;
1752 if (params == NULL) {
1753 return error::kOutOfBounds;
1755 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1756 // Check that the client initialized the result.
1757 if (result->size != 0) {
1758 return error::kInvalidArguments;
1760 DoGetRenderbufferParameteriv(target, pname, params);
1761 GLenum error = glGetError();
1762 if (error == GL_NO_ERROR) {
1763 result->SetNumResults(num_values);
1764 } else {
1765 LOCAL_SET_GL_ERROR(error, "GetRenderbufferParameteriv", "");
1767 return error::kNoError;
1770 error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
1771 uint32_t immediate_data_size,
1772 const void* cmd_data) {
1773 if (!unsafe_es3_apis_enabled())
1774 return error::kUnknownCommand;
1775 const gles2::cmds::GetSamplerParameterfv& c =
1776 *static_cast<const gles2::cmds::GetSamplerParameterfv*>(cmd_data);
1777 (void)c;
1778 GLuint sampler = c.sampler;
1779 GLenum pname = static_cast<GLenum>(c.pname);
1780 typedef cmds::GetSamplerParameterfv::Result Result;
1781 GLsizei num_values = 0;
1782 GetNumValuesReturnedForGLGet(pname, &num_values);
1783 Result* result = GetSharedMemoryAs<Result*>(
1784 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1785 GLfloat* params = result ? result->GetData() : NULL;
1786 if (params == NULL) {
1787 return error::kOutOfBounds;
1789 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1790 // Check that the client initialized the result.
1791 if (result->size != 0) {
1792 return error::kInvalidArguments;
1794 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1795 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameterfv",
1796 "invalid sampler id");
1797 return error::kNoError;
1799 glGetSamplerParameterfv(sampler, pname, params);
1800 GLenum error = glGetError();
1801 if (error == GL_NO_ERROR) {
1802 result->SetNumResults(num_values);
1803 } else {
1804 LOCAL_SET_GL_ERROR(error, "GetSamplerParameterfv", "");
1806 return error::kNoError;
1809 error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
1810 uint32_t immediate_data_size,
1811 const void* cmd_data) {
1812 if (!unsafe_es3_apis_enabled())
1813 return error::kUnknownCommand;
1814 const gles2::cmds::GetSamplerParameteriv& c =
1815 *static_cast<const gles2::cmds::GetSamplerParameteriv*>(cmd_data);
1816 (void)c;
1817 GLuint sampler = c.sampler;
1818 GLenum pname = static_cast<GLenum>(c.pname);
1819 typedef cmds::GetSamplerParameteriv::Result Result;
1820 GLsizei num_values = 0;
1821 GetNumValuesReturnedForGLGet(pname, &num_values);
1822 Result* result = GetSharedMemoryAs<Result*>(
1823 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1824 GLint* params = result ? result->GetData() : NULL;
1825 if (params == NULL) {
1826 return error::kOutOfBounds;
1828 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1829 // Check that the client initialized the result.
1830 if (result->size != 0) {
1831 return error::kInvalidArguments;
1833 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1834 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameteriv",
1835 "invalid sampler id");
1836 return error::kNoError;
1838 glGetSamplerParameteriv(sampler, pname, params);
1839 GLenum error = glGetError();
1840 if (error == GL_NO_ERROR) {
1841 result->SetNumResults(num_values);
1842 } else {
1843 LOCAL_SET_GL_ERROR(error, "GetSamplerParameteriv", "");
1845 return error::kNoError;
1848 error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size,
1849 const void* cmd_data) {
1850 const gles2::cmds::GetShaderiv& c =
1851 *static_cast<const gles2::cmds::GetShaderiv*>(cmd_data);
1852 (void)c;
1853 GLuint shader = c.shader;
1854 GLenum pname = static_cast<GLenum>(c.pname);
1855 typedef cmds::GetShaderiv::Result Result;
1856 GLsizei num_values = 0;
1857 GetNumValuesReturnedForGLGet(pname, &num_values);
1858 Result* result = GetSharedMemoryAs<Result*>(
1859 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1860 GLint* params = result ? result->GetData() : NULL;
1861 if (!validators_->shader_parameter.IsValid(pname)) {
1862 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
1863 return error::kNoError;
1865 if (params == NULL) {
1866 return error::kOutOfBounds;
1868 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1869 // Check that the client initialized the result.
1870 if (result->size != 0) {
1871 return error::kInvalidArguments;
1873 DoGetShaderiv(shader, pname, params);
1874 GLenum error = glGetError();
1875 if (error == GL_NO_ERROR) {
1876 result->SetNumResults(num_values);
1877 } else {
1878 LOCAL_SET_GL_ERROR(error, "GetShaderiv", "");
1880 return error::kNoError;
1883 error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
1884 const void* cmd_data) {
1885 if (!unsafe_es3_apis_enabled())
1886 return error::kUnknownCommand;
1887 const gles2::cmds::GetSynciv& c =
1888 *static_cast<const gles2::cmds::GetSynciv*>(cmd_data);
1889 (void)c;
1890 GLuint sync = static_cast<GLuint>(c.sync);
1891 GLenum pname = static_cast<GLenum>(c.pname);
1892 typedef cmds::GetSynciv::Result Result;
1893 GLsizei num_values = 0;
1894 GetNumValuesReturnedForGLGet(pname, &num_values);
1895 Result* result = GetSharedMemoryAs<Result*>(
1896 c.values_shm_id, c.values_shm_offset, Result::ComputeSize(num_values));
1897 GLint* values = result ? result->GetData() : NULL;
1898 if (values == NULL) {
1899 return error::kOutOfBounds;
1901 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1902 // Check that the client initialized the result.
1903 if (result->size != 0) {
1904 return error::kInvalidArguments;
1906 GLsync service_sync = 0;
1907 if (!group_->GetSyncServiceId(sync, &service_sync)) {
1908 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSynciv", "invalid sync id");
1909 return error::kNoError;
1911 glGetSynciv(service_sync, pname, num_values, nullptr, values);
1912 GLenum error = glGetError();
1913 if (error == GL_NO_ERROR) {
1914 result->SetNumResults(num_values);
1915 } else {
1916 LOCAL_SET_GL_ERROR(error, "GetSynciv", "");
1918 return error::kNoError;
1921 error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
1922 uint32_t immediate_data_size,
1923 const void* cmd_data) {
1924 const gles2::cmds::GetTexParameterfv& c =
1925 *static_cast<const gles2::cmds::GetTexParameterfv*>(cmd_data);
1926 (void)c;
1927 GLenum target = static_cast<GLenum>(c.target);
1928 GLenum pname = static_cast<GLenum>(c.pname);
1929 typedef cmds::GetTexParameterfv::Result Result;
1930 GLsizei num_values = 0;
1931 GetNumValuesReturnedForGLGet(pname, &num_values);
1932 Result* result = GetSharedMemoryAs<Result*>(
1933 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1934 GLfloat* params = result ? result->GetData() : NULL;
1935 if (!validators_->get_tex_param_target.IsValid(target)) {
1936 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
1937 return error::kNoError;
1939 if (!validators_->texture_parameter.IsValid(pname)) {
1940 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
1941 return error::kNoError;
1943 if (params == NULL) {
1944 return error::kOutOfBounds;
1946 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1947 // Check that the client initialized the result.
1948 if (result->size != 0) {
1949 return error::kInvalidArguments;
1951 DoGetTexParameterfv(target, pname, params);
1952 GLenum error = glGetError();
1953 if (error == GL_NO_ERROR) {
1954 result->SetNumResults(num_values);
1955 } else {
1956 LOCAL_SET_GL_ERROR(error, "GetTexParameterfv", "");
1958 return error::kNoError;
1961 error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
1962 uint32_t immediate_data_size,
1963 const void* cmd_data) {
1964 const gles2::cmds::GetTexParameteriv& c =
1965 *static_cast<const gles2::cmds::GetTexParameteriv*>(cmd_data);
1966 (void)c;
1967 GLenum target = static_cast<GLenum>(c.target);
1968 GLenum pname = static_cast<GLenum>(c.pname);
1969 typedef cmds::GetTexParameteriv::Result Result;
1970 GLsizei num_values = 0;
1971 GetNumValuesReturnedForGLGet(pname, &num_values);
1972 Result* result = GetSharedMemoryAs<Result*>(
1973 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1974 GLint* params = result ? result->GetData() : NULL;
1975 if (!validators_->get_tex_param_target.IsValid(target)) {
1976 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
1977 return error::kNoError;
1979 if (!validators_->texture_parameter.IsValid(pname)) {
1980 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
1981 return error::kNoError;
1983 if (params == NULL) {
1984 return error::kOutOfBounds;
1986 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1987 // Check that the client initialized the result.
1988 if (result->size != 0) {
1989 return error::kInvalidArguments;
1991 DoGetTexParameteriv(target, pname, params);
1992 GLenum error = glGetError();
1993 if (error == GL_NO_ERROR) {
1994 result->SetNumResults(num_values);
1995 } else {
1996 LOCAL_SET_GL_ERROR(error, "GetTexParameteriv", "");
1998 return error::kNoError;
2001 error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
2002 uint32_t immediate_data_size,
2003 const void* cmd_data) {
2004 const gles2::cmds::GetVertexAttribfv& c =
2005 *static_cast<const gles2::cmds::GetVertexAttribfv*>(cmd_data);
2006 (void)c;
2007 GLuint index = static_cast<GLuint>(c.index);
2008 GLenum pname = static_cast<GLenum>(c.pname);
2009 typedef cmds::GetVertexAttribfv::Result Result;
2010 GLsizei num_values = 0;
2011 GetNumValuesReturnedForGLGet(pname, &num_values);
2012 Result* result = GetSharedMemoryAs<Result*>(
2013 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2014 GLfloat* params = result ? result->GetData() : NULL;
2015 if (!validators_->vertex_attribute.IsValid(pname)) {
2016 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
2017 return error::kNoError;
2019 if (params == NULL) {
2020 return error::kOutOfBounds;
2022 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
2023 // Check that the client initialized the result.
2024 if (result->size != 0) {
2025 return error::kInvalidArguments;
2027 DoGetVertexAttribfv(index, pname, params);
2028 GLenum error = glGetError();
2029 if (error == GL_NO_ERROR) {
2030 result->SetNumResults(num_values);
2031 } else {
2032 LOCAL_SET_GL_ERROR(error, "GetVertexAttribfv", "");
2034 return error::kNoError;
2037 error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
2038 uint32_t immediate_data_size,
2039 const void* cmd_data) {
2040 const gles2::cmds::GetVertexAttribiv& c =
2041 *static_cast<const gles2::cmds::GetVertexAttribiv*>(cmd_data);
2042 (void)c;
2043 GLuint index = static_cast<GLuint>(c.index);
2044 GLenum pname = static_cast<GLenum>(c.pname);
2045 typedef cmds::GetVertexAttribiv::Result Result;
2046 GLsizei num_values = 0;
2047 GetNumValuesReturnedForGLGet(pname, &num_values);
2048 Result* result = GetSharedMemoryAs<Result*>(
2049 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2050 GLint* params = result ? result->GetData() : NULL;
2051 if (!validators_->vertex_attribute.IsValid(pname)) {
2052 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
2053 return error::kNoError;
2055 if (params == NULL) {
2056 return error::kOutOfBounds;
2058 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
2059 // Check that the client initialized the result.
2060 if (result->size != 0) {
2061 return error::kInvalidArguments;
2063 DoGetVertexAttribiv(index, pname, params);
2064 GLenum error = glGetError();
2065 if (error == GL_NO_ERROR) {
2066 result->SetNumResults(num_values);
2067 } else {
2068 LOCAL_SET_GL_ERROR(error, "GetVertexAttribiv", "");
2070 return error::kNoError;
2073 error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv(
2074 uint32_t immediate_data_size,
2075 const void* cmd_data) {
2076 if (!unsafe_es3_apis_enabled())
2077 return error::kUnknownCommand;
2078 const gles2::cmds::GetVertexAttribIiv& c =
2079 *static_cast<const gles2::cmds::GetVertexAttribIiv*>(cmd_data);
2080 (void)c;
2081 GLuint index = static_cast<GLuint>(c.index);
2082 GLenum pname = static_cast<GLenum>(c.pname);
2083 typedef cmds::GetVertexAttribIiv::Result Result;
2084 GLsizei num_values = 0;
2085 GetNumValuesReturnedForGLGet(pname, &num_values);
2086 Result* result = GetSharedMemoryAs<Result*>(
2087 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2088 GLint* params = result ? result->GetData() : NULL;
2089 if (params == NULL) {
2090 return error::kOutOfBounds;
2092 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
2093 // Check that the client initialized the result.
2094 if (result->size != 0) {
2095 return error::kInvalidArguments;
2097 DoGetVertexAttribIiv(index, pname, params);
2098 GLenum error = glGetError();
2099 if (error == GL_NO_ERROR) {
2100 result->SetNumResults(num_values);
2101 } else {
2102 LOCAL_SET_GL_ERROR(error, "GetVertexAttribIiv", "");
2104 return error::kNoError;
2107 error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv(
2108 uint32_t immediate_data_size,
2109 const void* cmd_data) {
2110 if (!unsafe_es3_apis_enabled())
2111 return error::kUnknownCommand;
2112 const gles2::cmds::GetVertexAttribIuiv& c =
2113 *static_cast<const gles2::cmds::GetVertexAttribIuiv*>(cmd_data);
2114 (void)c;
2115 GLuint index = static_cast<GLuint>(c.index);
2116 GLenum pname = static_cast<GLenum>(c.pname);
2117 typedef cmds::GetVertexAttribIuiv::Result Result;
2118 GLsizei num_values = 0;
2119 GetNumValuesReturnedForGLGet(pname, &num_values);
2120 Result* result = GetSharedMemoryAs<Result*>(
2121 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2122 GLuint* params = result ? result->GetData() : NULL;
2123 if (params == NULL) {
2124 return error::kOutOfBounds;
2126 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
2127 // Check that the client initialized the result.
2128 if (result->size != 0) {
2129 return error::kInvalidArguments;
2131 DoGetVertexAttribIuiv(index, pname, params);
2132 GLenum error = glGetError();
2133 if (error == GL_NO_ERROR) {
2134 result->SetNumResults(num_values);
2135 } else {
2136 LOCAL_SET_GL_ERROR(error, "GetVertexAttribIuiv", "");
2138 return error::kNoError;
2141 error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
2142 const void* cmd_data) {
2143 const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data);
2144 (void)c;
2145 GLenum target = static_cast<GLenum>(c.target);
2146 GLenum mode = static_cast<GLenum>(c.mode);
2147 if (!validators_->hint_target.IsValid(target)) {
2148 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
2149 return error::kNoError;
2151 if (!validators_->hint_mode.IsValid(mode)) {
2152 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
2153 return error::kNoError;
2155 switch (target) {
2156 case GL_GENERATE_MIPMAP_HINT:
2157 if (state_.hint_generate_mipmap != mode) {
2158 state_.hint_generate_mipmap = mode;
2159 glHint(target, mode);
2161 break;
2162 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
2163 if (state_.hint_fragment_shader_derivative != mode) {
2164 state_.hint_fragment_shader_derivative = mode;
2165 glHint(target, mode);
2167 break;
2168 default:
2169 NOTREACHED();
2171 return error::kNoError;
2174 error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
2175 uint32_t immediate_data_size,
2176 const void* cmd_data) {
2177 if (!unsafe_es3_apis_enabled())
2178 return error::kUnknownCommand;
2179 const gles2::cmds::InvalidateFramebufferImmediate& c =
2180 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate*>(
2181 cmd_data);
2182 (void)c;
2183 GLenum target = static_cast<GLenum>(c.target);
2184 GLsizei count = static_cast<GLsizei>(c.count);
2185 uint32_t data_size;
2186 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2187 return error::kOutOfBounds;
2189 if (data_size > immediate_data_size) {
2190 return error::kOutOfBounds;
2192 const GLenum* attachments =
2193 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2194 if (attachments == NULL) {
2195 return error::kOutOfBounds;
2197 glInvalidateFramebuffer(target, count, attachments);
2198 return error::kNoError;
2201 error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2202 uint32_t immediate_data_size,
2203 const void* cmd_data) {
2204 if (!unsafe_es3_apis_enabled())
2205 return error::kUnknownCommand;
2206 const gles2::cmds::InvalidateSubFramebufferImmediate& c =
2207 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate*>(
2208 cmd_data);
2209 (void)c;
2210 GLenum target = static_cast<GLenum>(c.target);
2211 GLsizei count = static_cast<GLsizei>(c.count);
2212 uint32_t data_size;
2213 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2214 return error::kOutOfBounds;
2216 if (data_size > immediate_data_size) {
2217 return error::kOutOfBounds;
2219 const GLenum* attachments =
2220 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2221 GLint x = static_cast<GLint>(c.x);
2222 GLint y = static_cast<GLint>(c.y);
2223 GLsizei width = static_cast<GLsizei>(c.width);
2224 GLsizei height = static_cast<GLsizei>(c.height);
2225 if (attachments == NULL) {
2226 return error::kOutOfBounds;
2228 glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height);
2229 return error::kNoError;
2232 error::Error GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size,
2233 const void* cmd_data) {
2234 const gles2::cmds::IsBuffer& c =
2235 *static_cast<const gles2::cmds::IsBuffer*>(cmd_data);
2236 (void)c;
2237 GLuint buffer = c.buffer;
2238 typedef cmds::IsBuffer::Result Result;
2239 Result* result_dst = GetSharedMemoryAs<Result*>(
2240 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2241 if (!result_dst) {
2242 return error::kOutOfBounds;
2244 *result_dst = DoIsBuffer(buffer);
2245 return error::kNoError;
2248 error::Error GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size,
2249 const void* cmd_data) {
2250 const gles2::cmds::IsEnabled& c =
2251 *static_cast<const gles2::cmds::IsEnabled*>(cmd_data);
2252 (void)c;
2253 GLenum cap = static_cast<GLenum>(c.cap);
2254 typedef cmds::IsEnabled::Result Result;
2255 Result* result_dst = GetSharedMemoryAs<Result*>(
2256 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2257 if (!result_dst) {
2258 return error::kOutOfBounds;
2260 if (!validators_->capability.IsValid(cap)) {
2261 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap, "cap");
2262 return error::kNoError;
2264 *result_dst = DoIsEnabled(cap);
2265 return error::kNoError;
2268 error::Error GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size,
2269 const void* cmd_data) {
2270 const gles2::cmds::IsFramebuffer& c =
2271 *static_cast<const gles2::cmds::IsFramebuffer*>(cmd_data);
2272 (void)c;
2273 GLuint framebuffer = c.framebuffer;
2274 typedef cmds::IsFramebuffer::Result Result;
2275 Result* result_dst = GetSharedMemoryAs<Result*>(
2276 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2277 if (!result_dst) {
2278 return error::kOutOfBounds;
2280 *result_dst = DoIsFramebuffer(framebuffer);
2281 return error::kNoError;
2284 error::Error GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size,
2285 const void* cmd_data) {
2286 const gles2::cmds::IsProgram& c =
2287 *static_cast<const gles2::cmds::IsProgram*>(cmd_data);
2288 (void)c;
2289 GLuint program = c.program;
2290 typedef cmds::IsProgram::Result Result;
2291 Result* result_dst = GetSharedMemoryAs<Result*>(
2292 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2293 if (!result_dst) {
2294 return error::kOutOfBounds;
2296 *result_dst = DoIsProgram(program);
2297 return error::kNoError;
2300 error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
2301 uint32_t immediate_data_size,
2302 const void* cmd_data) {
2303 const gles2::cmds::IsRenderbuffer& c =
2304 *static_cast<const gles2::cmds::IsRenderbuffer*>(cmd_data);
2305 (void)c;
2306 GLuint renderbuffer = c.renderbuffer;
2307 typedef cmds::IsRenderbuffer::Result Result;
2308 Result* result_dst = GetSharedMemoryAs<Result*>(
2309 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2310 if (!result_dst) {
2311 return error::kOutOfBounds;
2313 *result_dst = DoIsRenderbuffer(renderbuffer);
2314 return error::kNoError;
2317 error::Error GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size,
2318 const void* cmd_data) {
2319 if (!unsafe_es3_apis_enabled())
2320 return error::kUnknownCommand;
2321 const gles2::cmds::IsSampler& c =
2322 *static_cast<const gles2::cmds::IsSampler*>(cmd_data);
2323 (void)c;
2324 GLuint sampler = c.sampler;
2325 typedef cmds::IsSampler::Result Result;
2326 Result* result_dst = GetSharedMemoryAs<Result*>(
2327 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2328 if (!result_dst) {
2329 return error::kOutOfBounds;
2331 GLuint service_sampler = 0;
2332 *result_dst = group_->GetSamplerServiceId(sampler, &service_sampler);
2333 return error::kNoError;
2336 error::Error GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size,
2337 const void* cmd_data) {
2338 const gles2::cmds::IsShader& c =
2339 *static_cast<const gles2::cmds::IsShader*>(cmd_data);
2340 (void)c;
2341 GLuint shader = c.shader;
2342 typedef cmds::IsShader::Result Result;
2343 Result* result_dst = GetSharedMemoryAs<Result*>(
2344 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2345 if (!result_dst) {
2346 return error::kOutOfBounds;
2348 *result_dst = DoIsShader(shader);
2349 return error::kNoError;
2352 error::Error GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size,
2353 const void* cmd_data) {
2354 if (!unsafe_es3_apis_enabled())
2355 return error::kUnknownCommand;
2356 const gles2::cmds::IsSync& c =
2357 *static_cast<const gles2::cmds::IsSync*>(cmd_data);
2358 (void)c;
2359 GLuint sync = c.sync;
2360 typedef cmds::IsSync::Result Result;
2361 Result* result_dst = GetSharedMemoryAs<Result*>(
2362 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2363 if (!result_dst) {
2364 return error::kOutOfBounds;
2366 GLsync service_sync = 0;
2367 *result_dst = group_->GetSyncServiceId(sync, &service_sync);
2368 return error::kNoError;
2371 error::Error GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size,
2372 const void* cmd_data) {
2373 const gles2::cmds::IsTexture& c =
2374 *static_cast<const gles2::cmds::IsTexture*>(cmd_data);
2375 (void)c;
2376 GLuint texture = c.texture;
2377 typedef cmds::IsTexture::Result Result;
2378 Result* result_dst = GetSharedMemoryAs<Result*>(
2379 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2380 if (!result_dst) {
2381 return error::kOutOfBounds;
2383 *result_dst = DoIsTexture(texture);
2384 return error::kNoError;
2387 error::Error GLES2DecoderImpl::HandleIsTransformFeedback(
2388 uint32_t immediate_data_size,
2389 const void* cmd_data) {
2390 if (!unsafe_es3_apis_enabled())
2391 return error::kUnknownCommand;
2392 const gles2::cmds::IsTransformFeedback& c =
2393 *static_cast<const gles2::cmds::IsTransformFeedback*>(cmd_data);
2394 (void)c;
2395 GLuint transformfeedback = c.transformfeedback;
2396 typedef cmds::IsTransformFeedback::Result Result;
2397 Result* result_dst = GetSharedMemoryAs<Result*>(
2398 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2399 if (!result_dst) {
2400 return error::kOutOfBounds;
2402 GLuint service_transformfeedback = 0;
2403 *result_dst = group_->GetTransformFeedbackServiceId(
2404 transformfeedback, &service_transformfeedback);
2405 return error::kNoError;
2408 error::Error GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size,
2409 const void* cmd_data) {
2410 const gles2::cmds::LineWidth& c =
2411 *static_cast<const gles2::cmds::LineWidth*>(cmd_data);
2412 (void)c;
2413 GLfloat width = static_cast<GLfloat>(c.width);
2414 if (width <= 0.0f || std::isnan(width)) {
2415 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "LineWidth", "width out of range");
2416 return error::kNoError;
2418 if (state_.line_width != width) {
2419 state_.line_width = width;
2420 glLineWidth(width);
2422 return error::kNoError;
2425 error::Error GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size,
2426 const void* cmd_data) {
2427 const gles2::cmds::LinkProgram& c =
2428 *static_cast<const gles2::cmds::LinkProgram*>(cmd_data);
2429 (void)c;
2430 GLuint program = c.program;
2431 DoLinkProgram(program);
2432 return error::kNoError;
2435 error::Error GLES2DecoderImpl::HandlePauseTransformFeedback(
2436 uint32_t immediate_data_size,
2437 const void* cmd_data) {
2438 if (!unsafe_es3_apis_enabled())
2439 return error::kUnknownCommand;
2440 const gles2::cmds::PauseTransformFeedback& c =
2441 *static_cast<const gles2::cmds::PauseTransformFeedback*>(cmd_data);
2442 (void)c;
2443 glPauseTransformFeedback();
2444 return error::kNoError;
2447 error::Error GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size,
2448 const void* cmd_data) {
2449 const gles2::cmds::PolygonOffset& c =
2450 *static_cast<const gles2::cmds::PolygonOffset*>(cmd_data);
2451 (void)c;
2452 GLfloat factor = static_cast<GLfloat>(c.factor);
2453 GLfloat units = static_cast<GLfloat>(c.units);
2454 if (state_.polygon_offset_factor != factor ||
2455 state_.polygon_offset_units != units) {
2456 state_.polygon_offset_factor = factor;
2457 state_.polygon_offset_units = units;
2458 glPolygonOffset(factor, units);
2460 return error::kNoError;
2463 error::Error GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size,
2464 const void* cmd_data) {
2465 if (!unsafe_es3_apis_enabled())
2466 return error::kUnknownCommand;
2467 const gles2::cmds::ReadBuffer& c =
2468 *static_cast<const gles2::cmds::ReadBuffer*>(cmd_data);
2469 (void)c;
2470 GLenum src = static_cast<GLenum>(c.src);
2471 glReadBuffer(src);
2472 return error::kNoError;
2475 error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler(
2476 uint32_t immediate_data_size,
2477 const void* cmd_data) {
2478 const gles2::cmds::ReleaseShaderCompiler& c =
2479 *static_cast<const gles2::cmds::ReleaseShaderCompiler*>(cmd_data);
2480 (void)c;
2481 DoReleaseShaderCompiler();
2482 return error::kNoError;
2485 error::Error GLES2DecoderImpl::HandleRenderbufferStorage(
2486 uint32_t immediate_data_size,
2487 const void* cmd_data) {
2488 const gles2::cmds::RenderbufferStorage& c =
2489 *static_cast<const gles2::cmds::RenderbufferStorage*>(cmd_data);
2490 (void)c;
2491 GLenum target = static_cast<GLenum>(c.target);
2492 GLenum internalformat = static_cast<GLenum>(c.internalformat);
2493 GLsizei width = static_cast<GLsizei>(c.width);
2494 GLsizei height = static_cast<GLsizei>(c.height);
2495 if (!validators_->render_buffer_target.IsValid(target)) {
2496 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target, "target");
2497 return error::kNoError;
2499 if (!validators_->render_buffer_format.IsValid(internalformat)) {
2500 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat,
2501 "internalformat");
2502 return error::kNoError;
2504 if (width < 0) {
2505 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
2506 return error::kNoError;
2508 if (height < 0) {
2509 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
2510 return error::kNoError;
2512 DoRenderbufferStorage(target, internalformat, width, height);
2513 return error::kNoError;
2516 error::Error GLES2DecoderImpl::HandleResumeTransformFeedback(
2517 uint32_t immediate_data_size,
2518 const void* cmd_data) {
2519 if (!unsafe_es3_apis_enabled())
2520 return error::kUnknownCommand;
2521 const gles2::cmds::ResumeTransformFeedback& c =
2522 *static_cast<const gles2::cmds::ResumeTransformFeedback*>(cmd_data);
2523 (void)c;
2524 glResumeTransformFeedback();
2525 return error::kNoError;
2528 error::Error GLES2DecoderImpl::HandleSampleCoverage(
2529 uint32_t immediate_data_size,
2530 const void* cmd_data) {
2531 const gles2::cmds::SampleCoverage& c =
2532 *static_cast<const gles2::cmds::SampleCoverage*>(cmd_data);
2533 (void)c;
2534 GLclampf value = static_cast<GLclampf>(c.value);
2535 GLboolean invert = static_cast<GLboolean>(c.invert);
2536 DoSampleCoverage(value, invert);
2537 return error::kNoError;
2540 error::Error GLES2DecoderImpl::HandleSamplerParameterf(
2541 uint32_t immediate_data_size,
2542 const void* cmd_data) {
2543 if (!unsafe_es3_apis_enabled())
2544 return error::kUnknownCommand;
2545 const gles2::cmds::SamplerParameterf& c =
2546 *static_cast<const gles2::cmds::SamplerParameterf*>(cmd_data);
2547 (void)c;
2548 GLuint sampler = c.sampler;
2549 GLenum pname = static_cast<GLenum>(c.pname);
2550 GLfloat param = static_cast<GLfloat>(c.param);
2551 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2552 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameterf",
2553 "invalid sampler id");
2554 return error::kNoError;
2556 glSamplerParameterf(sampler, pname, param);
2557 return error::kNoError;
2560 error::Error GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2561 uint32_t immediate_data_size,
2562 const void* cmd_data) {
2563 if (!unsafe_es3_apis_enabled())
2564 return error::kUnknownCommand;
2565 const gles2::cmds::SamplerParameterfvImmediate& c =
2566 *static_cast<const gles2::cmds::SamplerParameterfvImmediate*>(cmd_data);
2567 (void)c;
2568 GLuint sampler = c.sampler;
2569 GLenum pname = static_cast<GLenum>(c.pname);
2570 uint32_t data_size;
2571 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2572 return error::kOutOfBounds;
2574 if (data_size > immediate_data_size) {
2575 return error::kOutOfBounds;
2577 const GLfloat* params =
2578 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2579 if (params == NULL) {
2580 return error::kOutOfBounds;
2582 group_->GetSamplerServiceId(sampler, &sampler);
2583 DoSamplerParameterfv(sampler, pname, params);
2584 return error::kNoError;
2587 error::Error GLES2DecoderImpl::HandleSamplerParameteri(
2588 uint32_t immediate_data_size,
2589 const void* cmd_data) {
2590 if (!unsafe_es3_apis_enabled())
2591 return error::kUnknownCommand;
2592 const gles2::cmds::SamplerParameteri& c =
2593 *static_cast<const gles2::cmds::SamplerParameteri*>(cmd_data);
2594 (void)c;
2595 GLuint sampler = c.sampler;
2596 GLenum pname = static_cast<GLenum>(c.pname);
2597 GLint param = static_cast<GLint>(c.param);
2598 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2599 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameteri",
2600 "invalid sampler id");
2601 return error::kNoError;
2603 glSamplerParameteri(sampler, pname, param);
2604 return error::kNoError;
2607 error::Error GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2608 uint32_t immediate_data_size,
2609 const void* cmd_data) {
2610 if (!unsafe_es3_apis_enabled())
2611 return error::kUnknownCommand;
2612 const gles2::cmds::SamplerParameterivImmediate& c =
2613 *static_cast<const gles2::cmds::SamplerParameterivImmediate*>(cmd_data);
2614 (void)c;
2615 GLuint sampler = c.sampler;
2616 GLenum pname = static_cast<GLenum>(c.pname);
2617 uint32_t data_size;
2618 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2619 return error::kOutOfBounds;
2621 if (data_size > immediate_data_size) {
2622 return error::kOutOfBounds;
2624 const GLint* params =
2625 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2626 if (params == NULL) {
2627 return error::kOutOfBounds;
2629 DoSamplerParameteriv(sampler, pname, params);
2630 return error::kNoError;
2633 error::Error GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size,
2634 const void* cmd_data) {
2635 const gles2::cmds::Scissor& c =
2636 *static_cast<const gles2::cmds::Scissor*>(cmd_data);
2637 (void)c;
2638 GLint x = static_cast<GLint>(c.x);
2639 GLint y = static_cast<GLint>(c.y);
2640 GLsizei width = static_cast<GLsizei>(c.width);
2641 GLsizei height = static_cast<GLsizei>(c.height);
2642 if (width < 0) {
2643 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "width < 0");
2644 return error::kNoError;
2646 if (height < 0) {
2647 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "height < 0");
2648 return error::kNoError;
2650 if (state_.scissor_x != x || state_.scissor_y != y ||
2651 state_.scissor_width != width || state_.scissor_height != height) {
2652 state_.scissor_x = x;
2653 state_.scissor_y = y;
2654 state_.scissor_width = width;
2655 state_.scissor_height = height;
2656 glScissor(x, y, width, height);
2658 return error::kNoError;
2661 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2662 uint32_t immediate_data_size,
2663 const void* cmd_data) {
2664 const gles2::cmds::ShaderSourceBucket& c =
2665 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data);
2666 (void)c;
2667 GLuint shader = static_cast<GLuint>(c.shader);
2669 Bucket* bucket = GetBucket(c.str_bucket_id);
2670 if (!bucket) {
2671 return error::kInvalidArguments;
2673 GLsizei count = 0;
2674 std::vector<char*> strs;
2675 std::vector<GLint> len;
2676 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2677 return error::kInvalidArguments;
2679 const char** str =
2680 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2681 const GLint* length =
2682 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2683 (void)length;
2684 DoShaderSource(shader, count, str, length);
2685 return error::kNoError;
2688 error::Error GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size,
2689 const void* cmd_data) {
2690 const gles2::cmds::StencilFunc& c =
2691 *static_cast<const gles2::cmds::StencilFunc*>(cmd_data);
2692 (void)c;
2693 GLenum func = static_cast<GLenum>(c.func);
2694 GLint ref = static_cast<GLint>(c.ref);
2695 GLuint mask = static_cast<GLuint>(c.mask);
2696 if (!validators_->cmp_function.IsValid(func)) {
2697 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func, "func");
2698 return error::kNoError;
2700 if (state_.stencil_front_func != func || state_.stencil_front_ref != ref ||
2701 state_.stencil_front_mask != mask || state_.stencil_back_func != func ||
2702 state_.stencil_back_ref != ref || state_.stencil_back_mask != mask) {
2703 state_.stencil_front_func = func;
2704 state_.stencil_front_ref = ref;
2705 state_.stencil_front_mask = mask;
2706 state_.stencil_back_func = func;
2707 state_.stencil_back_ref = ref;
2708 state_.stencil_back_mask = mask;
2709 glStencilFunc(func, ref, mask);
2711 return error::kNoError;
2714 error::Error GLES2DecoderImpl::HandleStencilFuncSeparate(
2715 uint32_t immediate_data_size,
2716 const void* cmd_data) {
2717 const gles2::cmds::StencilFuncSeparate& c =
2718 *static_cast<const gles2::cmds::StencilFuncSeparate*>(cmd_data);
2719 (void)c;
2720 GLenum face = static_cast<GLenum>(c.face);
2721 GLenum func = static_cast<GLenum>(c.func);
2722 GLint ref = static_cast<GLint>(c.ref);
2723 GLuint mask = static_cast<GLuint>(c.mask);
2724 if (!validators_->face_type.IsValid(face)) {
2725 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face, "face");
2726 return error::kNoError;
2728 if (!validators_->cmp_function.IsValid(func)) {
2729 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func, "func");
2730 return error::kNoError;
2732 bool changed = false;
2733 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2734 changed |= state_.stencil_front_func != func ||
2735 state_.stencil_front_ref != ref ||
2736 state_.stencil_front_mask != mask;
2738 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2739 changed |= state_.stencil_back_func != func ||
2740 state_.stencil_back_ref != ref ||
2741 state_.stencil_back_mask != mask;
2743 if (changed) {
2744 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2745 state_.stencil_front_func = func;
2746 state_.stencil_front_ref = ref;
2747 state_.stencil_front_mask = mask;
2749 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2750 state_.stencil_back_func = func;
2751 state_.stencil_back_ref = ref;
2752 state_.stencil_back_mask = mask;
2754 glStencilFuncSeparate(face, func, ref, mask);
2756 return error::kNoError;
2759 error::Error GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size,
2760 const void* cmd_data) {
2761 const gles2::cmds::StencilMask& c =
2762 *static_cast<const gles2::cmds::StencilMask*>(cmd_data);
2763 (void)c;
2764 GLuint mask = static_cast<GLuint>(c.mask);
2765 if (state_.stencil_front_writemask != mask ||
2766 state_.stencil_back_writemask != mask) {
2767 state_.stencil_front_writemask = mask;
2768 state_.stencil_back_writemask = mask;
2769 framebuffer_state_.clear_state_dirty = true;
2771 return error::kNoError;
2774 error::Error GLES2DecoderImpl::HandleStencilMaskSeparate(
2775 uint32_t immediate_data_size,
2776 const void* cmd_data) {
2777 const gles2::cmds::StencilMaskSeparate& c =
2778 *static_cast<const gles2::cmds::StencilMaskSeparate*>(cmd_data);
2779 (void)c;
2780 GLenum face = static_cast<GLenum>(c.face);
2781 GLuint mask = static_cast<GLuint>(c.mask);
2782 if (!validators_->face_type.IsValid(face)) {
2783 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face, "face");
2784 return error::kNoError;
2786 bool changed = false;
2787 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2788 changed |= state_.stencil_front_writemask != mask;
2790 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2791 changed |= state_.stencil_back_writemask != mask;
2793 if (changed) {
2794 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2795 state_.stencil_front_writemask = mask;
2797 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2798 state_.stencil_back_writemask = mask;
2800 framebuffer_state_.clear_state_dirty = true;
2802 return error::kNoError;
2805 error::Error GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size,
2806 const void* cmd_data) {
2807 const gles2::cmds::StencilOp& c =
2808 *static_cast<const gles2::cmds::StencilOp*>(cmd_data);
2809 (void)c;
2810 GLenum fail = static_cast<GLenum>(c.fail);
2811 GLenum zfail = static_cast<GLenum>(c.zfail);
2812 GLenum zpass = static_cast<GLenum>(c.zpass);
2813 if (!validators_->stencil_op.IsValid(fail)) {
2814 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail, "fail");
2815 return error::kNoError;
2817 if (!validators_->stencil_op.IsValid(zfail)) {
2818 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail, "zfail");
2819 return error::kNoError;
2821 if (!validators_->stencil_op.IsValid(zpass)) {
2822 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass, "zpass");
2823 return error::kNoError;
2825 if (state_.stencil_front_fail_op != fail ||
2826 state_.stencil_front_z_fail_op != zfail ||
2827 state_.stencil_front_z_pass_op != zpass ||
2828 state_.stencil_back_fail_op != fail ||
2829 state_.stencil_back_z_fail_op != zfail ||
2830 state_.stencil_back_z_pass_op != zpass) {
2831 state_.stencil_front_fail_op = fail;
2832 state_.stencil_front_z_fail_op = zfail;
2833 state_.stencil_front_z_pass_op = zpass;
2834 state_.stencil_back_fail_op = fail;
2835 state_.stencil_back_z_fail_op = zfail;
2836 state_.stencil_back_z_pass_op = zpass;
2837 glStencilOp(fail, zfail, zpass);
2839 return error::kNoError;
2842 error::Error GLES2DecoderImpl::HandleStencilOpSeparate(
2843 uint32_t immediate_data_size,
2844 const void* cmd_data) {
2845 const gles2::cmds::StencilOpSeparate& c =
2846 *static_cast<const gles2::cmds::StencilOpSeparate*>(cmd_data);
2847 (void)c;
2848 GLenum face = static_cast<GLenum>(c.face);
2849 GLenum fail = static_cast<GLenum>(c.fail);
2850 GLenum zfail = static_cast<GLenum>(c.zfail);
2851 GLenum zpass = static_cast<GLenum>(c.zpass);
2852 if (!validators_->face_type.IsValid(face)) {
2853 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face, "face");
2854 return error::kNoError;
2856 if (!validators_->stencil_op.IsValid(fail)) {
2857 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail, "fail");
2858 return error::kNoError;
2860 if (!validators_->stencil_op.IsValid(zfail)) {
2861 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail, "zfail");
2862 return error::kNoError;
2864 if (!validators_->stencil_op.IsValid(zpass)) {
2865 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass, "zpass");
2866 return error::kNoError;
2868 bool changed = false;
2869 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2870 changed |= state_.stencil_front_fail_op != fail ||
2871 state_.stencil_front_z_fail_op != zfail ||
2872 state_.stencil_front_z_pass_op != zpass;
2874 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2875 changed |= state_.stencil_back_fail_op != fail ||
2876 state_.stencil_back_z_fail_op != zfail ||
2877 state_.stencil_back_z_pass_op != zpass;
2879 if (changed) {
2880 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2881 state_.stencil_front_fail_op = fail;
2882 state_.stencil_front_z_fail_op = zfail;
2883 state_.stencil_front_z_pass_op = zpass;
2885 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2886 state_.stencil_back_fail_op = fail;
2887 state_.stencil_back_z_fail_op = zfail;
2888 state_.stencil_back_z_pass_op = zpass;
2890 glStencilOpSeparate(face, fail, zfail, zpass);
2892 return error::kNoError;
2895 error::Error GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size,
2896 const void* cmd_data) {
2897 const gles2::cmds::TexParameterf& c =
2898 *static_cast<const gles2::cmds::TexParameterf*>(cmd_data);
2899 (void)c;
2900 GLenum target = static_cast<GLenum>(c.target);
2901 GLenum pname = static_cast<GLenum>(c.pname);
2902 GLfloat param = static_cast<GLfloat>(c.param);
2903 if (!validators_->texture_bind_target.IsValid(target)) {
2904 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target, "target");
2905 return error::kNoError;
2907 if (!validators_->texture_parameter.IsValid(pname)) {
2908 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname, "pname");
2909 return error::kNoError;
2911 DoTexParameterf(target, pname, param);
2912 return error::kNoError;
2915 error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
2916 uint32_t immediate_data_size,
2917 const void* cmd_data) {
2918 const gles2::cmds::TexParameterfvImmediate& c =
2919 *static_cast<const gles2::cmds::TexParameterfvImmediate*>(cmd_data);
2920 (void)c;
2921 GLenum target = static_cast<GLenum>(c.target);
2922 GLenum pname = static_cast<GLenum>(c.pname);
2923 uint32_t data_size;
2924 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2925 return error::kOutOfBounds;
2927 if (data_size > immediate_data_size) {
2928 return error::kOutOfBounds;
2930 const GLfloat* params =
2931 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2932 if (!validators_->texture_bind_target.IsValid(target)) {
2933 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target, "target");
2934 return error::kNoError;
2936 if (!validators_->texture_parameter.IsValid(pname)) {
2937 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname, "pname");
2938 return error::kNoError;
2940 if (params == NULL) {
2941 return error::kOutOfBounds;
2943 DoTexParameterfv(target, pname, params);
2944 return error::kNoError;
2947 error::Error GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size,
2948 const void* cmd_data) {
2949 const gles2::cmds::TexParameteri& c =
2950 *static_cast<const gles2::cmds::TexParameteri*>(cmd_data);
2951 (void)c;
2952 GLenum target = static_cast<GLenum>(c.target);
2953 GLenum pname = static_cast<GLenum>(c.pname);
2954 GLint param = static_cast<GLint>(c.param);
2955 if (!validators_->texture_bind_target.IsValid(target)) {
2956 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target, "target");
2957 return error::kNoError;
2959 if (!validators_->texture_parameter.IsValid(pname)) {
2960 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname, "pname");
2961 return error::kNoError;
2963 DoTexParameteri(target, pname, param);
2964 return error::kNoError;
2967 error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
2968 uint32_t immediate_data_size,
2969 const void* cmd_data) {
2970 const gles2::cmds::TexParameterivImmediate& c =
2971 *static_cast<const gles2::cmds::TexParameterivImmediate*>(cmd_data);
2972 (void)c;
2973 GLenum target = static_cast<GLenum>(c.target);
2974 GLenum pname = static_cast<GLenum>(c.pname);
2975 uint32_t data_size;
2976 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2977 return error::kOutOfBounds;
2979 if (data_size > immediate_data_size) {
2980 return error::kOutOfBounds;
2982 const GLint* params =
2983 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2984 if (!validators_->texture_bind_target.IsValid(target)) {
2985 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target, "target");
2986 return error::kNoError;
2988 if (!validators_->texture_parameter.IsValid(pname)) {
2989 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname, "pname");
2990 return error::kNoError;
2992 if (params == NULL) {
2993 return error::kOutOfBounds;
2995 DoTexParameteriv(target, pname, params);
2996 return error::kNoError;
2999 error::Error GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size,
3000 const void* cmd_data) {
3001 if (!unsafe_es3_apis_enabled())
3002 return error::kUnknownCommand;
3003 const gles2::cmds::TexStorage3D& c =
3004 *static_cast<const gles2::cmds::TexStorage3D*>(cmd_data);
3005 (void)c;
3006 GLenum target = static_cast<GLenum>(c.target);
3007 GLsizei levels = static_cast<GLsizei>(c.levels);
3008 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
3009 GLsizei width = static_cast<GLsizei>(c.width);
3010 GLsizei height = static_cast<GLsizei>(c.height);
3011 GLsizei depth = static_cast<GLsizei>(c.depth);
3012 glTexStorage3D(target, levels, internalFormat, width, height, depth);
3013 return error::kNoError;
3016 error::Error GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
3017 uint32_t immediate_data_size,
3018 const void* cmd_data) {
3019 if (!unsafe_es3_apis_enabled())
3020 return error::kUnknownCommand;
3021 const gles2::cmds::TransformFeedbackVaryingsBucket& c =
3022 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket*>(
3023 cmd_data);
3024 (void)c;
3025 GLuint program = static_cast<GLuint>(c.program);
3027 Bucket* bucket = GetBucket(c.varyings_bucket_id);
3028 if (!bucket) {
3029 return error::kInvalidArguments;
3031 GLsizei count = 0;
3032 std::vector<char*> strs;
3033 std::vector<GLint> len;
3034 if (!bucket->GetAsStrings(&count, &strs, &len)) {
3035 return error::kInvalidArguments;
3037 const char** varyings =
3038 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
3039 const GLint* length =
3040 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
3041 (void)length;
3042 GLenum buffermode = static_cast<GLenum>(c.buffermode);
3043 DoTransformFeedbackVaryings(program, count, varyings, buffermode);
3044 return error::kNoError;
3047 error::Error GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size,
3048 const void* cmd_data) {
3049 const gles2::cmds::Uniform1f& c =
3050 *static_cast<const gles2::cmds::Uniform1f*>(cmd_data);
3051 (void)c;
3052 GLint location = static_cast<GLint>(c.location);
3053 GLfloat x = static_cast<GLfloat>(c.x);
3054 GLfloat temp[1] = {
3057 DoUniform1fv(location, 1, &temp[0]);
3058 return error::kNoError;
3061 error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
3062 uint32_t immediate_data_size,
3063 const void* cmd_data) {
3064 const gles2::cmds::Uniform1fvImmediate& c =
3065 *static_cast<const gles2::cmds::Uniform1fvImmediate*>(cmd_data);
3066 (void)c;
3067 GLint location = static_cast<GLint>(c.location);
3068 GLsizei count = static_cast<GLsizei>(c.count);
3069 uint32_t data_size;
3070 if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
3071 return error::kOutOfBounds;
3073 if (data_size > immediate_data_size) {
3074 return error::kOutOfBounds;
3076 const GLfloat* v =
3077 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3078 if (v == NULL) {
3079 return error::kOutOfBounds;
3081 DoUniform1fv(location, count, v);
3082 return error::kNoError;
3085 error::Error GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size,
3086 const void* cmd_data) {
3087 const gles2::cmds::Uniform1i& c =
3088 *static_cast<const gles2::cmds::Uniform1i*>(cmd_data);
3089 (void)c;
3090 GLint location = static_cast<GLint>(c.location);
3091 GLint x = static_cast<GLint>(c.x);
3092 DoUniform1i(location, x);
3093 return error::kNoError;
3096 error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
3097 uint32_t immediate_data_size,
3098 const void* cmd_data) {
3099 const gles2::cmds::Uniform1ivImmediate& c =
3100 *static_cast<const gles2::cmds::Uniform1ivImmediate*>(cmd_data);
3101 (void)c;
3102 GLint location = static_cast<GLint>(c.location);
3103 GLsizei count = static_cast<GLsizei>(c.count);
3104 uint32_t data_size;
3105 if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
3106 return error::kOutOfBounds;
3108 if (data_size > immediate_data_size) {
3109 return error::kOutOfBounds;
3111 const GLint* v =
3112 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3113 if (v == NULL) {
3114 return error::kOutOfBounds;
3116 DoUniform1iv(location, count, v);
3117 return error::kNoError;
3120 error::Error GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size,
3121 const void* cmd_data) {
3122 if (!unsafe_es3_apis_enabled())
3123 return error::kUnknownCommand;
3124 const gles2::cmds::Uniform1ui& c =
3125 *static_cast<const gles2::cmds::Uniform1ui*>(cmd_data);
3126 (void)c;
3127 GLint location = static_cast<GLint>(c.location);
3128 GLuint x = static_cast<GLuint>(c.x);
3129 GLuint temp[1] = {
3132 glUniform1uiv(location, 1, &temp[0]);
3133 return error::kNoError;
3136 error::Error GLES2DecoderImpl::HandleUniform1uivImmediate(
3137 uint32_t immediate_data_size,
3138 const void* cmd_data) {
3139 if (!unsafe_es3_apis_enabled())
3140 return error::kUnknownCommand;
3141 const gles2::cmds::Uniform1uivImmediate& c =
3142 *static_cast<const gles2::cmds::Uniform1uivImmediate*>(cmd_data);
3143 (void)c;
3144 GLint location = static_cast<GLint>(c.location);
3145 GLsizei count = static_cast<GLsizei>(c.count);
3146 uint32_t data_size;
3147 if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) {
3148 return error::kOutOfBounds;
3150 if (data_size > immediate_data_size) {
3151 return error::kOutOfBounds;
3153 const GLuint* v =
3154 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3155 if (v == NULL) {
3156 return error::kOutOfBounds;
3158 glUniform1uiv(location, count, v);
3159 return error::kNoError;
3162 error::Error GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size,
3163 const void* cmd_data) {
3164 const gles2::cmds::Uniform2f& c =
3165 *static_cast<const gles2::cmds::Uniform2f*>(cmd_data);
3166 (void)c;
3167 GLint location = static_cast<GLint>(c.location);
3168 GLfloat x = static_cast<GLfloat>(c.x);
3169 GLfloat y = static_cast<GLfloat>(c.y);
3170 GLfloat temp[2] = {
3171 x, y,
3173 DoUniform2fv(location, 1, &temp[0]);
3174 return error::kNoError;
3177 error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
3178 uint32_t immediate_data_size,
3179 const void* cmd_data) {
3180 const gles2::cmds::Uniform2fvImmediate& c =
3181 *static_cast<const gles2::cmds::Uniform2fvImmediate*>(cmd_data);
3182 (void)c;
3183 GLint location = static_cast<GLint>(c.location);
3184 GLsizei count = static_cast<GLsizei>(c.count);
3185 uint32_t data_size;
3186 if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
3187 return error::kOutOfBounds;
3189 if (data_size > immediate_data_size) {
3190 return error::kOutOfBounds;
3192 const GLfloat* v =
3193 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3194 if (v == NULL) {
3195 return error::kOutOfBounds;
3197 DoUniform2fv(location, count, v);
3198 return error::kNoError;
3201 error::Error GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size,
3202 const void* cmd_data) {
3203 const gles2::cmds::Uniform2i& c =
3204 *static_cast<const gles2::cmds::Uniform2i*>(cmd_data);
3205 (void)c;
3206 GLint location = static_cast<GLint>(c.location);
3207 GLint x = static_cast<GLint>(c.x);
3208 GLint y = static_cast<GLint>(c.y);
3209 GLint temp[2] = {
3210 x, y,
3212 DoUniform2iv(location, 1, &temp[0]);
3213 return error::kNoError;
3216 error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
3217 uint32_t immediate_data_size,
3218 const void* cmd_data) {
3219 const gles2::cmds::Uniform2ivImmediate& c =
3220 *static_cast<const gles2::cmds::Uniform2ivImmediate*>(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(GLint), 2, &data_size)) {
3226 return error::kOutOfBounds;
3228 if (data_size > immediate_data_size) {
3229 return error::kOutOfBounds;
3231 const GLint* v =
3232 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3233 if (v == NULL) {
3234 return error::kOutOfBounds;
3236 DoUniform2iv(location, count, v);
3237 return error::kNoError;
3240 error::Error GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size,
3241 const void* cmd_data) {
3242 if (!unsafe_es3_apis_enabled())
3243 return error::kUnknownCommand;
3244 const gles2::cmds::Uniform2ui& c =
3245 *static_cast<const gles2::cmds::Uniform2ui*>(cmd_data);
3246 (void)c;
3247 GLint location = static_cast<GLint>(c.location);
3248 GLuint x = static_cast<GLuint>(c.x);
3249 GLuint y = static_cast<GLuint>(c.y);
3250 GLuint temp[2] = {
3251 x, y,
3253 glUniform2uiv(location, 1, &temp[0]);
3254 return error::kNoError;
3257 error::Error GLES2DecoderImpl::HandleUniform2uivImmediate(
3258 uint32_t immediate_data_size,
3259 const void* cmd_data) {
3260 if (!unsafe_es3_apis_enabled())
3261 return error::kUnknownCommand;
3262 const gles2::cmds::Uniform2uivImmediate& c =
3263 *static_cast<const gles2::cmds::Uniform2uivImmediate*>(cmd_data);
3264 (void)c;
3265 GLint location = static_cast<GLint>(c.location);
3266 GLsizei count = static_cast<GLsizei>(c.count);
3267 uint32_t data_size;
3268 if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) {
3269 return error::kOutOfBounds;
3271 if (data_size > immediate_data_size) {
3272 return error::kOutOfBounds;
3274 const GLuint* v =
3275 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3276 if (v == NULL) {
3277 return error::kOutOfBounds;
3279 glUniform2uiv(location, count, v);
3280 return error::kNoError;
3283 error::Error GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size,
3284 const void* cmd_data) {
3285 const gles2::cmds::Uniform3f& c =
3286 *static_cast<const gles2::cmds::Uniform3f*>(cmd_data);
3287 (void)c;
3288 GLint location = static_cast<GLint>(c.location);
3289 GLfloat x = static_cast<GLfloat>(c.x);
3290 GLfloat y = static_cast<GLfloat>(c.y);
3291 GLfloat z = static_cast<GLfloat>(c.z);
3292 GLfloat temp[3] = {
3293 x, y, z,
3295 DoUniform3fv(location, 1, &temp[0]);
3296 return error::kNoError;
3299 error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
3300 uint32_t immediate_data_size,
3301 const void* cmd_data) {
3302 const gles2::cmds::Uniform3fvImmediate& c =
3303 *static_cast<const gles2::cmds::Uniform3fvImmediate*>(cmd_data);
3304 (void)c;
3305 GLint location = static_cast<GLint>(c.location);
3306 GLsizei count = static_cast<GLsizei>(c.count);
3307 uint32_t data_size;
3308 if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
3309 return error::kOutOfBounds;
3311 if (data_size > immediate_data_size) {
3312 return error::kOutOfBounds;
3314 const GLfloat* v =
3315 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3316 if (v == NULL) {
3317 return error::kOutOfBounds;
3319 DoUniform3fv(location, count, v);
3320 return error::kNoError;
3323 error::Error GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size,
3324 const void* cmd_data) {
3325 const gles2::cmds::Uniform3i& c =
3326 *static_cast<const gles2::cmds::Uniform3i*>(cmd_data);
3327 (void)c;
3328 GLint location = static_cast<GLint>(c.location);
3329 GLint x = static_cast<GLint>(c.x);
3330 GLint y = static_cast<GLint>(c.y);
3331 GLint z = static_cast<GLint>(c.z);
3332 GLint temp[3] = {
3333 x, y, z,
3335 DoUniform3iv(location, 1, &temp[0]);
3336 return error::kNoError;
3339 error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
3340 uint32_t immediate_data_size,
3341 const void* cmd_data) {
3342 const gles2::cmds::Uniform3ivImmediate& c =
3343 *static_cast<const gles2::cmds::Uniform3ivImmediate*>(cmd_data);
3344 (void)c;
3345 GLint location = static_cast<GLint>(c.location);
3346 GLsizei count = static_cast<GLsizei>(c.count);
3347 uint32_t data_size;
3348 if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
3349 return error::kOutOfBounds;
3351 if (data_size > immediate_data_size) {
3352 return error::kOutOfBounds;
3354 const GLint* v =
3355 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3356 if (v == NULL) {
3357 return error::kOutOfBounds;
3359 DoUniform3iv(location, count, v);
3360 return error::kNoError;
3363 error::Error GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size,
3364 const void* cmd_data) {
3365 if (!unsafe_es3_apis_enabled())
3366 return error::kUnknownCommand;
3367 const gles2::cmds::Uniform3ui& c =
3368 *static_cast<const gles2::cmds::Uniform3ui*>(cmd_data);
3369 (void)c;
3370 GLint location = static_cast<GLint>(c.location);
3371 GLuint x = static_cast<GLuint>(c.x);
3372 GLuint y = static_cast<GLuint>(c.y);
3373 GLuint z = static_cast<GLuint>(c.z);
3374 GLuint temp[3] = {
3375 x, y, z,
3377 glUniform3uiv(location, 1, &temp[0]);
3378 return error::kNoError;
3381 error::Error GLES2DecoderImpl::HandleUniform3uivImmediate(
3382 uint32_t immediate_data_size,
3383 const void* cmd_data) {
3384 if (!unsafe_es3_apis_enabled())
3385 return error::kUnknownCommand;
3386 const gles2::cmds::Uniform3uivImmediate& c =
3387 *static_cast<const gles2::cmds::Uniform3uivImmediate*>(cmd_data);
3388 (void)c;
3389 GLint location = static_cast<GLint>(c.location);
3390 GLsizei count = static_cast<GLsizei>(c.count);
3391 uint32_t data_size;
3392 if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) {
3393 return error::kOutOfBounds;
3395 if (data_size > immediate_data_size) {
3396 return error::kOutOfBounds;
3398 const GLuint* v =
3399 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3400 if (v == NULL) {
3401 return error::kOutOfBounds;
3403 glUniform3uiv(location, count, v);
3404 return error::kNoError;
3407 error::Error GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size,
3408 const void* cmd_data) {
3409 const gles2::cmds::Uniform4f& c =
3410 *static_cast<const gles2::cmds::Uniform4f*>(cmd_data);
3411 (void)c;
3412 GLint location = static_cast<GLint>(c.location);
3413 GLfloat x = static_cast<GLfloat>(c.x);
3414 GLfloat y = static_cast<GLfloat>(c.y);
3415 GLfloat z = static_cast<GLfloat>(c.z);
3416 GLfloat w = static_cast<GLfloat>(c.w);
3417 GLfloat temp[4] = {
3418 x, y, z, w,
3420 DoUniform4fv(location, 1, &temp[0]);
3421 return error::kNoError;
3424 error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
3425 uint32_t immediate_data_size,
3426 const void* cmd_data) {
3427 const gles2::cmds::Uniform4fvImmediate& c =
3428 *static_cast<const gles2::cmds::Uniform4fvImmediate*>(cmd_data);
3429 (void)c;
3430 GLint location = static_cast<GLint>(c.location);
3431 GLsizei count = static_cast<GLsizei>(c.count);
3432 uint32_t data_size;
3433 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3434 return error::kOutOfBounds;
3436 if (data_size > immediate_data_size) {
3437 return error::kOutOfBounds;
3439 const GLfloat* v =
3440 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3441 if (v == NULL) {
3442 return error::kOutOfBounds;
3444 DoUniform4fv(location, count, v);
3445 return error::kNoError;
3448 error::Error GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size,
3449 const void* cmd_data) {
3450 const gles2::cmds::Uniform4i& c =
3451 *static_cast<const gles2::cmds::Uniform4i*>(cmd_data);
3452 (void)c;
3453 GLint location = static_cast<GLint>(c.location);
3454 GLint x = static_cast<GLint>(c.x);
3455 GLint y = static_cast<GLint>(c.y);
3456 GLint z = static_cast<GLint>(c.z);
3457 GLint w = static_cast<GLint>(c.w);
3458 GLint temp[4] = {
3459 x, y, z, w,
3461 DoUniform4iv(location, 1, &temp[0]);
3462 return error::kNoError;
3465 error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
3466 uint32_t immediate_data_size,
3467 const void* cmd_data) {
3468 const gles2::cmds::Uniform4ivImmediate& c =
3469 *static_cast<const gles2::cmds::Uniform4ivImmediate*>(cmd_data);
3470 (void)c;
3471 GLint location = static_cast<GLint>(c.location);
3472 GLsizei count = static_cast<GLsizei>(c.count);
3473 uint32_t data_size;
3474 if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
3475 return error::kOutOfBounds;
3477 if (data_size > immediate_data_size) {
3478 return error::kOutOfBounds;
3480 const GLint* v =
3481 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3482 if (v == NULL) {
3483 return error::kOutOfBounds;
3485 DoUniform4iv(location, count, v);
3486 return error::kNoError;
3489 error::Error GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size,
3490 const void* cmd_data) {
3491 if (!unsafe_es3_apis_enabled())
3492 return error::kUnknownCommand;
3493 const gles2::cmds::Uniform4ui& c =
3494 *static_cast<const gles2::cmds::Uniform4ui*>(cmd_data);
3495 (void)c;
3496 GLint location = static_cast<GLint>(c.location);
3497 GLuint x = static_cast<GLuint>(c.x);
3498 GLuint y = static_cast<GLuint>(c.y);
3499 GLuint z = static_cast<GLuint>(c.z);
3500 GLuint w = static_cast<GLuint>(c.w);
3501 GLuint temp[4] = {
3502 x, y, z, w,
3504 glUniform4uiv(location, 1, &temp[0]);
3505 return error::kNoError;
3508 error::Error GLES2DecoderImpl::HandleUniform4uivImmediate(
3509 uint32_t immediate_data_size,
3510 const void* cmd_data) {
3511 if (!unsafe_es3_apis_enabled())
3512 return error::kUnknownCommand;
3513 const gles2::cmds::Uniform4uivImmediate& c =
3514 *static_cast<const gles2::cmds::Uniform4uivImmediate*>(cmd_data);
3515 (void)c;
3516 GLint location = static_cast<GLint>(c.location);
3517 GLsizei count = static_cast<GLsizei>(c.count);
3518 uint32_t data_size;
3519 if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) {
3520 return error::kOutOfBounds;
3522 if (data_size > immediate_data_size) {
3523 return error::kOutOfBounds;
3525 const GLuint* v =
3526 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3527 if (v == NULL) {
3528 return error::kOutOfBounds;
3530 glUniform4uiv(location, count, v);
3531 return error::kNoError;
3534 error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3535 uint32_t immediate_data_size,
3536 const void* cmd_data) {
3537 const gles2::cmds::UniformMatrix2fvImmediate& c =
3538 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate*>(cmd_data);
3539 (void)c;
3540 GLint location = static_cast<GLint>(c.location);
3541 GLsizei count = static_cast<GLsizei>(c.count);
3542 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3543 uint32_t data_size;
3544 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3545 return error::kOutOfBounds;
3547 if (data_size > immediate_data_size) {
3548 return error::kOutOfBounds;
3550 const GLfloat* value =
3551 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3552 if (value == NULL) {
3553 return error::kOutOfBounds;
3555 DoUniformMatrix2fv(location, count, transpose, value);
3556 return error::kNoError;
3559 error::Error GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3560 uint32_t immediate_data_size,
3561 const void* cmd_data) {
3562 if (!unsafe_es3_apis_enabled())
3563 return error::kUnknownCommand;
3564 const gles2::cmds::UniformMatrix2x3fvImmediate& c =
3565 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate*>(cmd_data);
3566 (void)c;
3567 GLint location = static_cast<GLint>(c.location);
3568 GLsizei count = static_cast<GLsizei>(c.count);
3569 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3570 uint32_t data_size;
3571 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3572 return error::kOutOfBounds;
3574 if (data_size > immediate_data_size) {
3575 return error::kOutOfBounds;
3577 const GLfloat* value =
3578 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3579 if (value == NULL) {
3580 return error::kOutOfBounds;
3582 glUniformMatrix2x3fv(location, count, transpose, value);
3583 return error::kNoError;
3586 error::Error GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3587 uint32_t immediate_data_size,
3588 const void* cmd_data) {
3589 if (!unsafe_es3_apis_enabled())
3590 return error::kUnknownCommand;
3591 const gles2::cmds::UniformMatrix2x4fvImmediate& c =
3592 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate*>(cmd_data);
3593 (void)c;
3594 GLint location = static_cast<GLint>(c.location);
3595 GLsizei count = static_cast<GLsizei>(c.count);
3596 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3597 uint32_t data_size;
3598 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3599 return error::kOutOfBounds;
3601 if (data_size > immediate_data_size) {
3602 return error::kOutOfBounds;
3604 const GLfloat* value =
3605 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3606 if (value == NULL) {
3607 return error::kOutOfBounds;
3609 glUniformMatrix2x4fv(location, count, transpose, value);
3610 return error::kNoError;
3613 error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3614 uint32_t immediate_data_size,
3615 const void* cmd_data) {
3616 const gles2::cmds::UniformMatrix3fvImmediate& c =
3617 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate*>(cmd_data);
3618 (void)c;
3619 GLint location = static_cast<GLint>(c.location);
3620 GLsizei count = static_cast<GLsizei>(c.count);
3621 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3622 uint32_t data_size;
3623 if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
3624 return error::kOutOfBounds;
3626 if (data_size > immediate_data_size) {
3627 return error::kOutOfBounds;
3629 const GLfloat* value =
3630 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3631 if (value == NULL) {
3632 return error::kOutOfBounds;
3634 DoUniformMatrix3fv(location, count, transpose, value);
3635 return error::kNoError;
3638 error::Error GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3639 uint32_t immediate_data_size,
3640 const void* cmd_data) {
3641 if (!unsafe_es3_apis_enabled())
3642 return error::kUnknownCommand;
3643 const gles2::cmds::UniformMatrix3x2fvImmediate& c =
3644 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate*>(cmd_data);
3645 (void)c;
3646 GLint location = static_cast<GLint>(c.location);
3647 GLsizei count = static_cast<GLsizei>(c.count);
3648 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3649 uint32_t data_size;
3650 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3651 return error::kOutOfBounds;
3653 if (data_size > immediate_data_size) {
3654 return error::kOutOfBounds;
3656 const GLfloat* value =
3657 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3658 if (value == NULL) {
3659 return error::kOutOfBounds;
3661 glUniformMatrix3x2fv(location, count, transpose, value);
3662 return error::kNoError;
3665 error::Error GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3666 uint32_t immediate_data_size,
3667 const void* cmd_data) {
3668 if (!unsafe_es3_apis_enabled())
3669 return error::kUnknownCommand;
3670 const gles2::cmds::UniformMatrix3x4fvImmediate& c =
3671 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate*>(cmd_data);
3672 (void)c;
3673 GLint location = static_cast<GLint>(c.location);
3674 GLsizei count = static_cast<GLsizei>(c.count);
3675 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3676 uint32_t data_size;
3677 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3678 return error::kOutOfBounds;
3680 if (data_size > immediate_data_size) {
3681 return error::kOutOfBounds;
3683 const GLfloat* value =
3684 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3685 if (value == NULL) {
3686 return error::kOutOfBounds;
3688 glUniformMatrix3x4fv(location, count, transpose, value);
3689 return error::kNoError;
3692 error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3693 uint32_t immediate_data_size,
3694 const void* cmd_data) {
3695 const gles2::cmds::UniformMatrix4fvImmediate& c =
3696 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate*>(cmd_data);
3697 (void)c;
3698 GLint location = static_cast<GLint>(c.location);
3699 GLsizei count = static_cast<GLsizei>(c.count);
3700 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3701 uint32_t data_size;
3702 if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
3703 return error::kOutOfBounds;
3705 if (data_size > immediate_data_size) {
3706 return error::kOutOfBounds;
3708 const GLfloat* value =
3709 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3710 if (value == NULL) {
3711 return error::kOutOfBounds;
3713 DoUniformMatrix4fv(location, count, transpose, value);
3714 return error::kNoError;
3717 error::Error GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3718 uint32_t immediate_data_size,
3719 const void* cmd_data) {
3720 if (!unsafe_es3_apis_enabled())
3721 return error::kUnknownCommand;
3722 const gles2::cmds::UniformMatrix4x2fvImmediate& c =
3723 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate*>(cmd_data);
3724 (void)c;
3725 GLint location = static_cast<GLint>(c.location);
3726 GLsizei count = static_cast<GLsizei>(c.count);
3727 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3728 uint32_t data_size;
3729 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3730 return error::kOutOfBounds;
3732 if (data_size > immediate_data_size) {
3733 return error::kOutOfBounds;
3735 const GLfloat* value =
3736 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3737 if (value == NULL) {
3738 return error::kOutOfBounds;
3740 glUniformMatrix4x2fv(location, count, transpose, value);
3741 return error::kNoError;
3744 error::Error GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3745 uint32_t immediate_data_size,
3746 const void* cmd_data) {
3747 if (!unsafe_es3_apis_enabled())
3748 return error::kUnknownCommand;
3749 const gles2::cmds::UniformMatrix4x3fvImmediate& c =
3750 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate*>(cmd_data);
3751 (void)c;
3752 GLint location = static_cast<GLint>(c.location);
3753 GLsizei count = static_cast<GLsizei>(c.count);
3754 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3755 uint32_t data_size;
3756 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3757 return error::kOutOfBounds;
3759 if (data_size > immediate_data_size) {
3760 return error::kOutOfBounds;
3762 const GLfloat* value =
3763 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3764 if (value == NULL) {
3765 return error::kOutOfBounds;
3767 glUniformMatrix4x3fv(location, count, transpose, value);
3768 return error::kNoError;
3771 error::Error GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size,
3772 const void* cmd_data) {
3773 const gles2::cmds::UseProgram& c =
3774 *static_cast<const gles2::cmds::UseProgram*>(cmd_data);
3775 (void)c;
3776 GLuint program = c.program;
3777 DoUseProgram(program);
3778 return error::kNoError;
3781 error::Error GLES2DecoderImpl::HandleValidateProgram(
3782 uint32_t immediate_data_size,
3783 const void* cmd_data) {
3784 const gles2::cmds::ValidateProgram& c =
3785 *static_cast<const gles2::cmds::ValidateProgram*>(cmd_data);
3786 (void)c;
3787 GLuint program = c.program;
3788 DoValidateProgram(program);
3789 return error::kNoError;
3792 error::Error GLES2DecoderImpl::HandleVertexAttrib1f(
3793 uint32_t immediate_data_size,
3794 const void* cmd_data) {
3795 const gles2::cmds::VertexAttrib1f& c =
3796 *static_cast<const gles2::cmds::VertexAttrib1f*>(cmd_data);
3797 (void)c;
3798 GLuint indx = static_cast<GLuint>(c.indx);
3799 GLfloat x = static_cast<GLfloat>(c.x);
3800 DoVertexAttrib1f(indx, x);
3801 return error::kNoError;
3804 error::Error GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3805 uint32_t immediate_data_size,
3806 const void* cmd_data) {
3807 const gles2::cmds::VertexAttrib1fvImmediate& c =
3808 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate*>(cmd_data);
3809 (void)c;
3810 GLuint indx = static_cast<GLuint>(c.indx);
3811 uint32_t data_size;
3812 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
3813 return error::kOutOfBounds;
3815 if (data_size > immediate_data_size) {
3816 return error::kOutOfBounds;
3818 const GLfloat* values =
3819 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3820 if (values == NULL) {
3821 return error::kOutOfBounds;
3823 DoVertexAttrib1fv(indx, values);
3824 return error::kNoError;
3827 error::Error GLES2DecoderImpl::HandleVertexAttrib2f(
3828 uint32_t immediate_data_size,
3829 const void* cmd_data) {
3830 const gles2::cmds::VertexAttrib2f& c =
3831 *static_cast<const gles2::cmds::VertexAttrib2f*>(cmd_data);
3832 (void)c;
3833 GLuint indx = static_cast<GLuint>(c.indx);
3834 GLfloat x = static_cast<GLfloat>(c.x);
3835 GLfloat y = static_cast<GLfloat>(c.y);
3836 DoVertexAttrib2f(indx, x, y);
3837 return error::kNoError;
3840 error::Error GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3841 uint32_t immediate_data_size,
3842 const void* cmd_data) {
3843 const gles2::cmds::VertexAttrib2fvImmediate& c =
3844 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate*>(cmd_data);
3845 (void)c;
3846 GLuint indx = static_cast<GLuint>(c.indx);
3847 uint32_t data_size;
3848 if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
3849 return error::kOutOfBounds;
3851 if (data_size > immediate_data_size) {
3852 return error::kOutOfBounds;
3854 const GLfloat* values =
3855 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3856 if (values == NULL) {
3857 return error::kOutOfBounds;
3859 DoVertexAttrib2fv(indx, values);
3860 return error::kNoError;
3863 error::Error GLES2DecoderImpl::HandleVertexAttrib3f(
3864 uint32_t immediate_data_size,
3865 const void* cmd_data) {
3866 const gles2::cmds::VertexAttrib3f& c =
3867 *static_cast<const gles2::cmds::VertexAttrib3f*>(cmd_data);
3868 (void)c;
3869 GLuint indx = static_cast<GLuint>(c.indx);
3870 GLfloat x = static_cast<GLfloat>(c.x);
3871 GLfloat y = static_cast<GLfloat>(c.y);
3872 GLfloat z = static_cast<GLfloat>(c.z);
3873 DoVertexAttrib3f(indx, x, y, z);
3874 return error::kNoError;
3877 error::Error GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3878 uint32_t immediate_data_size,
3879 const void* cmd_data) {
3880 const gles2::cmds::VertexAttrib3fvImmediate& c =
3881 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate*>(cmd_data);
3882 (void)c;
3883 GLuint indx = static_cast<GLuint>(c.indx);
3884 uint32_t data_size;
3885 if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
3886 return error::kOutOfBounds;
3888 if (data_size > immediate_data_size) {
3889 return error::kOutOfBounds;
3891 const GLfloat* values =
3892 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3893 if (values == NULL) {
3894 return error::kOutOfBounds;
3896 DoVertexAttrib3fv(indx, values);
3897 return error::kNoError;
3900 error::Error GLES2DecoderImpl::HandleVertexAttrib4f(
3901 uint32_t immediate_data_size,
3902 const void* cmd_data) {
3903 const gles2::cmds::VertexAttrib4f& c =
3904 *static_cast<const gles2::cmds::VertexAttrib4f*>(cmd_data);
3905 (void)c;
3906 GLuint indx = static_cast<GLuint>(c.indx);
3907 GLfloat x = static_cast<GLfloat>(c.x);
3908 GLfloat y = static_cast<GLfloat>(c.y);
3909 GLfloat z = static_cast<GLfloat>(c.z);
3910 GLfloat w = static_cast<GLfloat>(c.w);
3911 DoVertexAttrib4f(indx, x, y, z, w);
3912 return error::kNoError;
3915 error::Error GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3916 uint32_t immediate_data_size,
3917 const void* cmd_data) {
3918 const gles2::cmds::VertexAttrib4fvImmediate& c =
3919 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate*>(cmd_data);
3920 (void)c;
3921 GLuint indx = static_cast<GLuint>(c.indx);
3922 uint32_t data_size;
3923 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
3924 return error::kOutOfBounds;
3926 if (data_size > immediate_data_size) {
3927 return error::kOutOfBounds;
3929 const GLfloat* values =
3930 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3931 if (values == NULL) {
3932 return error::kOutOfBounds;
3934 DoVertexAttrib4fv(indx, values);
3935 return error::kNoError;
3938 error::Error GLES2DecoderImpl::HandleVertexAttribI4i(
3939 uint32_t immediate_data_size,
3940 const void* cmd_data) {
3941 if (!unsafe_es3_apis_enabled())
3942 return error::kUnknownCommand;
3943 const gles2::cmds::VertexAttribI4i& c =
3944 *static_cast<const gles2::cmds::VertexAttribI4i*>(cmd_data);
3945 (void)c;
3946 GLuint indx = static_cast<GLuint>(c.indx);
3947 GLint x = static_cast<GLint>(c.x);
3948 GLint y = static_cast<GLint>(c.y);
3949 GLint z = static_cast<GLint>(c.z);
3950 GLint w = static_cast<GLint>(c.w);
3951 DoVertexAttribI4i(indx, x, y, z, w);
3952 return error::kNoError;
3955 error::Error GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3956 uint32_t immediate_data_size,
3957 const void* cmd_data) {
3958 if (!unsafe_es3_apis_enabled())
3959 return error::kUnknownCommand;
3960 const gles2::cmds::VertexAttribI4ivImmediate& c =
3961 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate*>(cmd_data);
3962 (void)c;
3963 GLuint indx = static_cast<GLuint>(c.indx);
3964 uint32_t data_size;
3965 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
3966 return error::kOutOfBounds;
3968 if (data_size > immediate_data_size) {
3969 return error::kOutOfBounds;
3971 const GLint* values =
3972 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3973 if (values == NULL) {
3974 return error::kOutOfBounds;
3976 DoVertexAttribI4iv(indx, values);
3977 return error::kNoError;
3980 error::Error GLES2DecoderImpl::HandleVertexAttribI4ui(
3981 uint32_t immediate_data_size,
3982 const void* cmd_data) {
3983 if (!unsafe_es3_apis_enabled())
3984 return error::kUnknownCommand;
3985 const gles2::cmds::VertexAttribI4ui& c =
3986 *static_cast<const gles2::cmds::VertexAttribI4ui*>(cmd_data);
3987 (void)c;
3988 GLuint indx = static_cast<GLuint>(c.indx);
3989 GLuint x = static_cast<GLuint>(c.x);
3990 GLuint y = static_cast<GLuint>(c.y);
3991 GLuint z = static_cast<GLuint>(c.z);
3992 GLuint w = static_cast<GLuint>(c.w);
3993 DoVertexAttribI4ui(indx, x, y, z, w);
3994 return error::kNoError;
3997 error::Error GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3998 uint32_t immediate_data_size,
3999 const void* cmd_data) {
4000 if (!unsafe_es3_apis_enabled())
4001 return error::kUnknownCommand;
4002 const gles2::cmds::VertexAttribI4uivImmediate& c =
4003 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate*>(cmd_data);
4004 (void)c;
4005 GLuint indx = static_cast<GLuint>(c.indx);
4006 uint32_t data_size;
4007 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
4008 return error::kOutOfBounds;
4010 if (data_size > immediate_data_size) {
4011 return error::kOutOfBounds;
4013 const GLuint* values =
4014 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4015 if (values == NULL) {
4016 return error::kOutOfBounds;
4018 DoVertexAttribI4uiv(indx, values);
4019 return error::kNoError;
4022 error::Error GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size,
4023 const void* cmd_data) {
4024 const gles2::cmds::Viewport& c =
4025 *static_cast<const gles2::cmds::Viewport*>(cmd_data);
4026 (void)c;
4027 GLint x = static_cast<GLint>(c.x);
4028 GLint y = static_cast<GLint>(c.y);
4029 GLsizei width = static_cast<GLsizei>(c.width);
4030 GLsizei height = static_cast<GLsizei>(c.height);
4031 if (width < 0) {
4032 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "width < 0");
4033 return error::kNoError;
4035 if (height < 0) {
4036 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "height < 0");
4037 return error::kNoError;
4039 DoViewport(x, y, width, height);
4040 return error::kNoError;
4043 error::Error GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
4044 uint32_t immediate_data_size,
4045 const void* cmd_data) {
4046 const gles2::cmds::BlitFramebufferCHROMIUM& c =
4047 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM*>(cmd_data);
4048 (void)c;
4049 if (!features().chromium_framebuffer_multisample) {
4050 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlitFramebufferCHROMIUM",
4051 "function not available");
4052 return error::kNoError;
4055 error::Error error;
4056 error = WillAccessBoundFramebufferForDraw();
4057 if (error != error::kNoError)
4058 return error;
4059 error = WillAccessBoundFramebufferForRead();
4060 if (error != error::kNoError)
4061 return error;
4062 GLint srcX0 = static_cast<GLint>(c.srcX0);
4063 GLint srcY0 = static_cast<GLint>(c.srcY0);
4064 GLint srcX1 = static_cast<GLint>(c.srcX1);
4065 GLint srcY1 = static_cast<GLint>(c.srcY1);
4066 GLint dstX0 = static_cast<GLint>(c.dstX0);
4067 GLint dstY0 = static_cast<GLint>(c.dstY0);
4068 GLint dstX1 = static_cast<GLint>(c.dstX1);
4069 GLint dstY1 = static_cast<GLint>(c.dstY1);
4070 GLbitfield mask = static_cast<GLbitfield>(c.mask);
4071 GLenum filter = static_cast<GLenum>(c.filter);
4072 if (!validators_->blit_filter.IsValid(filter)) {
4073 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter,
4074 "filter");
4075 return error::kNoError;
4077 DoBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
4078 dstY1, mask, filter);
4079 return error::kNoError;
4082 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
4083 uint32_t immediate_data_size,
4084 const void* cmd_data) {
4085 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM& c =
4086 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM*>(
4087 cmd_data);
4088 (void)c;
4089 if (!features().chromium_framebuffer_multisample) {
4090 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4091 "glRenderbufferStorageMultisampleCHROMIUM",
4092 "function not available");
4093 return error::kNoError;
4096 GLenum target = static_cast<GLenum>(c.target);
4097 GLsizei samples = static_cast<GLsizei>(c.samples);
4098 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4099 GLsizei width = static_cast<GLsizei>(c.width);
4100 GLsizei height = static_cast<GLsizei>(c.height);
4101 if (!validators_->render_buffer_target.IsValid(target)) {
4102 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4103 target, "target");
4104 return error::kNoError;
4106 if (samples < 0) {
4107 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4108 "glRenderbufferStorageMultisampleCHROMIUM",
4109 "samples < 0");
4110 return error::kNoError;
4112 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4113 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4114 internalformat, "internalformat");
4115 return error::kNoError;
4117 if (width < 0) {
4118 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4119 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
4120 return error::kNoError;
4122 if (height < 0) {
4123 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4124 "glRenderbufferStorageMultisampleCHROMIUM",
4125 "height < 0");
4126 return error::kNoError;
4128 DoRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
4129 width, height);
4130 return error::kNoError;
4133 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
4134 uint32_t immediate_data_size,
4135 const void* cmd_data) {
4136 const gles2::cmds::RenderbufferStorageMultisampleEXT& c =
4137 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT*>(
4138 cmd_data);
4139 (void)c;
4140 if (!features().multisampled_render_to_texture) {
4141 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4142 "glRenderbufferStorageMultisampleEXT",
4143 "function not available");
4144 return error::kNoError;
4147 GLenum target = static_cast<GLenum>(c.target);
4148 GLsizei samples = static_cast<GLsizei>(c.samples);
4149 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4150 GLsizei width = static_cast<GLsizei>(c.width);
4151 GLsizei height = static_cast<GLsizei>(c.height);
4152 if (!validators_->render_buffer_target.IsValid(target)) {
4153 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4154 target, "target");
4155 return error::kNoError;
4157 if (samples < 0) {
4158 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4159 "samples < 0");
4160 return error::kNoError;
4162 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4163 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4164 internalformat, "internalformat");
4165 return error::kNoError;
4167 if (width < 0) {
4168 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4169 "width < 0");
4170 return error::kNoError;
4172 if (height < 0) {
4173 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4174 "height < 0");
4175 return error::kNoError;
4177 DoRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
4178 height);
4179 return error::kNoError;
4182 error::Error GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
4183 uint32_t immediate_data_size,
4184 const void* cmd_data) {
4185 const gles2::cmds::FramebufferTexture2DMultisampleEXT& c =
4186 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT*>(
4187 cmd_data);
4188 (void)c;
4189 if (!features().multisampled_render_to_texture) {
4190 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4191 "glFramebufferTexture2DMultisampleEXT",
4192 "function not available");
4193 return error::kNoError;
4196 GLenum target = static_cast<GLenum>(c.target);
4197 GLenum attachment = static_cast<GLenum>(c.attachment);
4198 GLenum textarget = static_cast<GLenum>(c.textarget);
4199 GLuint texture = c.texture;
4200 GLint level = static_cast<GLint>(c.level);
4201 GLsizei samples = static_cast<GLsizei>(c.samples);
4202 if (!validators_->frame_buffer_target.IsValid(target)) {
4203 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4204 target, "target");
4205 return error::kNoError;
4207 if (!validators_->attachment.IsValid(attachment)) {
4208 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4209 attachment, "attachment");
4210 return error::kNoError;
4212 if (!validators_->texture_target.IsValid(textarget)) {
4213 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4214 textarget, "textarget");
4215 return error::kNoError;
4217 if (samples < 0) {
4218 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glFramebufferTexture2DMultisampleEXT",
4219 "samples < 0");
4220 return error::kNoError;
4222 DoFramebufferTexture2DMultisample(target, attachment, textarget, texture,
4223 level, samples);
4224 return error::kNoError;
4227 error::Error GLES2DecoderImpl::HandleTexStorage2DEXT(
4228 uint32_t immediate_data_size,
4229 const void* cmd_data) {
4230 const gles2::cmds::TexStorage2DEXT& c =
4231 *static_cast<const gles2::cmds::TexStorage2DEXT*>(cmd_data);
4232 (void)c;
4233 GLenum target = static_cast<GLenum>(c.target);
4234 GLsizei levels = static_cast<GLsizei>(c.levels);
4235 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
4236 GLsizei width = static_cast<GLsizei>(c.width);
4237 GLsizei height = static_cast<GLsizei>(c.height);
4238 if (!validators_->texture_bind_target.IsValid(target)) {
4239 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target, "target");
4240 return error::kNoError;
4242 if (levels < 0) {
4243 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
4244 return error::kNoError;
4246 if (!validators_->texture_internal_format_storage.IsValid(internalFormat)) {
4247 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat,
4248 "internalFormat");
4249 return error::kNoError;
4251 if (width < 0) {
4252 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
4253 return error::kNoError;
4255 if (height < 0) {
4256 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
4257 return error::kNoError;
4259 DoTexStorage2DEXT(target, levels, internalFormat, width, height);
4260 return error::kNoError;
4263 error::Error GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4264 uint32_t immediate_data_size,
4265 const void* cmd_data) {
4266 const gles2::cmds::GenQueriesEXTImmediate& c =
4267 *static_cast<const gles2::cmds::GenQueriesEXTImmediate*>(cmd_data);
4268 (void)c;
4269 GLsizei n = static_cast<GLsizei>(c.n);
4270 uint32_t data_size;
4271 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4272 return error::kOutOfBounds;
4274 GLuint* queries =
4275 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4276 if (queries == NULL) {
4277 return error::kOutOfBounds;
4279 if (!GenQueriesEXTHelper(n, queries)) {
4280 return error::kInvalidArguments;
4282 return error::kNoError;
4285 error::Error GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4286 uint32_t immediate_data_size,
4287 const void* cmd_data) {
4288 const gles2::cmds::DeleteQueriesEXTImmediate& c =
4289 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate*>(cmd_data);
4290 (void)c;
4291 GLsizei n = static_cast<GLsizei>(c.n);
4292 uint32_t data_size;
4293 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4294 return error::kOutOfBounds;
4296 const GLuint* queries =
4297 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4298 if (queries == NULL) {
4299 return error::kOutOfBounds;
4301 DeleteQueriesEXTHelper(n, queries);
4302 return error::kNoError;
4305 error::Error GLES2DecoderImpl::HandleBeginTransformFeedback(
4306 uint32_t immediate_data_size,
4307 const void* cmd_data) {
4308 if (!unsafe_es3_apis_enabled())
4309 return error::kUnknownCommand;
4310 const gles2::cmds::BeginTransformFeedback& c =
4311 *static_cast<const gles2::cmds::BeginTransformFeedback*>(cmd_data);
4312 (void)c;
4313 GLenum primitivemode = static_cast<GLenum>(c.primitivemode);
4314 glBeginTransformFeedback(primitivemode);
4315 return error::kNoError;
4318 error::Error GLES2DecoderImpl::HandleEndTransformFeedback(
4319 uint32_t immediate_data_size,
4320 const void* cmd_data) {
4321 if (!unsafe_es3_apis_enabled())
4322 return error::kUnknownCommand;
4323 const gles2::cmds::EndTransformFeedback& c =
4324 *static_cast<const gles2::cmds::EndTransformFeedback*>(cmd_data);
4325 (void)c;
4326 glEndTransformFeedback();
4327 return error::kNoError;
4330 error::Error GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4331 uint32_t immediate_data_size,
4332 const void* cmd_data) {
4333 const gles2::cmds::InsertEventMarkerEXT& c =
4334 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data);
4335 (void)c;
4337 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4338 Bucket* bucket = GetBucket(bucket_id);
4339 if (!bucket || bucket->size() == 0) {
4340 return error::kInvalidArguments;
4342 std::string str;
4343 if (!bucket->GetAsString(&str)) {
4344 return error::kInvalidArguments;
4346 DoInsertEventMarkerEXT(0, str.c_str());
4347 return error::kNoError;
4350 error::Error GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4351 uint32_t immediate_data_size,
4352 const void* cmd_data) {
4353 const gles2::cmds::PushGroupMarkerEXT& c =
4354 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data);
4355 (void)c;
4357 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4358 Bucket* bucket = GetBucket(bucket_id);
4359 if (!bucket || bucket->size() == 0) {
4360 return error::kInvalidArguments;
4362 std::string str;
4363 if (!bucket->GetAsString(&str)) {
4364 return error::kInvalidArguments;
4366 DoPushGroupMarkerEXT(0, str.c_str());
4367 return error::kNoError;
4370 error::Error GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4371 uint32_t immediate_data_size,
4372 const void* cmd_data) {
4373 const gles2::cmds::PopGroupMarkerEXT& c =
4374 *static_cast<const gles2::cmds::PopGroupMarkerEXT*>(cmd_data);
4375 (void)c;
4376 DoPopGroupMarkerEXT();
4377 return error::kNoError;
4380 error::Error GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4381 uint32_t immediate_data_size,
4382 const void* cmd_data) {
4383 const gles2::cmds::GenVertexArraysOESImmediate& c =
4384 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate*>(cmd_data);
4385 (void)c;
4386 GLsizei n = static_cast<GLsizei>(c.n);
4387 uint32_t data_size;
4388 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4389 return error::kOutOfBounds;
4391 GLuint* arrays =
4392 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4393 if (arrays == NULL) {
4394 return error::kOutOfBounds;
4396 if (!GenVertexArraysOESHelper(n, arrays)) {
4397 return error::kInvalidArguments;
4399 return error::kNoError;
4402 error::Error GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4403 uint32_t immediate_data_size,
4404 const void* cmd_data) {
4405 const gles2::cmds::DeleteVertexArraysOESImmediate& c =
4406 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate*>(
4407 cmd_data);
4408 (void)c;
4409 GLsizei n = static_cast<GLsizei>(c.n);
4410 uint32_t data_size;
4411 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4412 return error::kOutOfBounds;
4414 const GLuint* arrays =
4415 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4416 if (arrays == NULL) {
4417 return error::kOutOfBounds;
4419 DeleteVertexArraysOESHelper(n, arrays);
4420 return error::kNoError;
4423 error::Error GLES2DecoderImpl::HandleIsVertexArrayOES(
4424 uint32_t immediate_data_size,
4425 const void* cmd_data) {
4426 const gles2::cmds::IsVertexArrayOES& c =
4427 *static_cast<const gles2::cmds::IsVertexArrayOES*>(cmd_data);
4428 (void)c;
4429 GLuint array = c.array;
4430 typedef cmds::IsVertexArrayOES::Result Result;
4431 Result* result_dst = GetSharedMemoryAs<Result*>(
4432 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4433 if (!result_dst) {
4434 return error::kOutOfBounds;
4436 *result_dst = DoIsVertexArrayOES(array);
4437 return error::kNoError;
4440 error::Error GLES2DecoderImpl::HandleBindVertexArrayOES(
4441 uint32_t immediate_data_size,
4442 const void* cmd_data) {
4443 const gles2::cmds::BindVertexArrayOES& c =
4444 *static_cast<const gles2::cmds::BindVertexArrayOES*>(cmd_data);
4445 (void)c;
4446 GLuint array = c.array;
4447 DoBindVertexArrayOES(array);
4448 return error::kNoError;
4451 error::Error GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size,
4452 const void* cmd_data) {
4453 const gles2::cmds::SwapBuffers& c =
4454 *static_cast<const gles2::cmds::SwapBuffers*>(cmd_data);
4455 (void)c;
4456 DoSwapBuffers();
4457 return error::kNoError;
4460 error::Error GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4461 uint32_t immediate_data_size,
4462 const void* cmd_data) {
4463 const gles2::cmds::GetMaxValueInBufferCHROMIUM& c =
4464 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM*>(cmd_data);
4465 (void)c;
4466 GLuint buffer_id = c.buffer_id;
4467 GLsizei count = static_cast<GLsizei>(c.count);
4468 GLenum type = static_cast<GLenum>(c.type);
4469 GLuint offset = static_cast<GLuint>(c.offset);
4470 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result;
4471 Result* result_dst = GetSharedMemoryAs<Result*>(
4472 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4473 if (!result_dst) {
4474 return error::kOutOfBounds;
4476 if (count < 0) {
4477 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetMaxValueInBufferCHROMIUM",
4478 "count < 0");
4479 return error::kNoError;
4481 if (!validators_->get_max_index_type.IsValid(type)) {
4482 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type,
4483 "type");
4484 return error::kNoError;
4486 *result_dst = DoGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
4487 return error::kNoError;
4490 error::Error GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4491 uint32_t immediate_data_size,
4492 const void* cmd_data) {
4493 const gles2::cmds::TexImageIOSurface2DCHROMIUM& c =
4494 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM*>(cmd_data);
4495 (void)c;
4496 GLenum target = static_cast<GLenum>(c.target);
4497 GLsizei width = static_cast<GLsizei>(c.width);
4498 GLsizei height = static_cast<GLsizei>(c.height);
4499 GLuint ioSurfaceId = static_cast<GLuint>(c.ioSurfaceId);
4500 GLuint plane = static_cast<GLuint>(c.plane);
4501 if (!validators_->texture_bind_target.IsValid(target)) {
4502 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target,
4503 "target");
4504 return error::kNoError;
4506 if (width < 0) {
4507 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4508 "width < 0");
4509 return error::kNoError;
4511 if (height < 0) {
4512 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4513 "height < 0");
4514 return error::kNoError;
4516 DoTexImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
4517 return error::kNoError;
4520 error::Error GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4521 uint32_t immediate_data_size,
4522 const void* cmd_data) {
4523 const gles2::cmds::CopyTextureCHROMIUM& c =
4524 *static_cast<const gles2::cmds::CopyTextureCHROMIUM*>(cmd_data);
4525 (void)c;
4526 GLenum target = static_cast<GLenum>(c.target);
4527 GLenum source_id = static_cast<GLenum>(c.source_id);
4528 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4529 GLint internalformat = static_cast<GLint>(c.internalformat);
4530 GLenum dest_type = static_cast<GLenum>(c.dest_type);
4531 if (!validators_->texture_internal_format.IsValid(internalformat)) {
4532 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM",
4533 "internalformat GL_INVALID_VALUE");
4534 return error::kNoError;
4536 if (!validators_->pixel_type.IsValid(dest_type)) {
4537 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type,
4538 "dest_type");
4539 return error::kNoError;
4541 DoCopyTextureCHROMIUM(target, source_id, dest_id, internalformat, dest_type);
4542 return error::kNoError;
4545 error::Error GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4546 uint32_t immediate_data_size,
4547 const void* cmd_data) {
4548 const gles2::cmds::CopySubTextureCHROMIUM& c =
4549 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM*>(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 GLint xoffset = static_cast<GLint>(c.xoffset);
4555 GLint yoffset = static_cast<GLint>(c.yoffset);
4556 GLint x = static_cast<GLint>(c.x);
4557 GLint y = static_cast<GLint>(c.y);
4558 GLsizei width = static_cast<GLsizei>(c.width);
4559 GLsizei height = static_cast<GLsizei>(c.height);
4560 if (width < 0) {
4561 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4562 "width < 0");
4563 return error::kNoError;
4565 if (height < 0) {
4566 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4567 "height < 0");
4568 return error::kNoError;
4570 DoCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset, yoffset, x, y,
4571 width, height);
4572 return error::kNoError;
4575 error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4576 uint32_t immediate_data_size,
4577 const void* cmd_data) {
4578 const gles2::cmds::ProduceTextureCHROMIUMImmediate& c =
4579 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate*>(
4580 cmd_data);
4581 (void)c;
4582 GLenum target = static_cast<GLenum>(c.target);
4583 uint32_t data_size;
4584 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4585 return error::kOutOfBounds;
4587 if (data_size > immediate_data_size) {
4588 return error::kOutOfBounds;
4590 const GLbyte* mailbox =
4591 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4592 if (!validators_->texture_bind_target.IsValid(target)) {
4593 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target,
4594 "target");
4595 return error::kNoError;
4597 if (mailbox == NULL) {
4598 return error::kOutOfBounds;
4600 DoProduceTextureCHROMIUM(target, mailbox);
4601 return error::kNoError;
4604 error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4605 uint32_t immediate_data_size,
4606 const void* cmd_data) {
4607 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c =
4608 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>(
4609 cmd_data);
4610 (void)c;
4611 GLuint texture = c.texture;
4612 GLenum target = static_cast<GLenum>(c.target);
4613 uint32_t data_size;
4614 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4615 return error::kOutOfBounds;
4617 if (data_size > immediate_data_size) {
4618 return error::kOutOfBounds;
4620 const GLbyte* mailbox =
4621 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4622 if (!validators_->texture_bind_target.IsValid(target)) {
4623 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target,
4624 "target");
4625 return error::kNoError;
4627 if (mailbox == NULL) {
4628 return error::kOutOfBounds;
4630 DoProduceTextureDirectCHROMIUM(texture, target, mailbox);
4631 return error::kNoError;
4634 error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4635 uint32_t immediate_data_size,
4636 const void* cmd_data) {
4637 const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c =
4638 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate*>(
4639 cmd_data);
4640 (void)c;
4641 GLenum target = static_cast<GLenum>(c.target);
4642 uint32_t data_size;
4643 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4644 return error::kOutOfBounds;
4646 if (data_size > immediate_data_size) {
4647 return error::kOutOfBounds;
4649 const GLbyte* mailbox =
4650 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4651 if (!validators_->texture_bind_target.IsValid(target)) {
4652 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target,
4653 "target");
4654 return error::kNoError;
4656 if (mailbox == NULL) {
4657 return error::kOutOfBounds;
4659 DoConsumeTextureCHROMIUM(target, mailbox);
4660 return error::kNoError;
4663 error::Error GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4664 uint32_t immediate_data_size,
4665 const void* cmd_data) {
4666 const gles2::cmds::GenValuebuffersCHROMIUMImmediate& c =
4667 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate*>(
4668 cmd_data);
4669 (void)c;
4670 GLsizei n = static_cast<GLsizei>(c.n);
4671 uint32_t data_size;
4672 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4673 return error::kOutOfBounds;
4675 GLuint* buffers =
4676 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4677 if (buffers == NULL) {
4678 return error::kOutOfBounds;
4680 if (!GenValuebuffersCHROMIUMHelper(n, buffers)) {
4681 return error::kInvalidArguments;
4683 return error::kNoError;
4686 error::Error GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4687 uint32_t immediate_data_size,
4688 const void* cmd_data) {
4689 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate& c =
4690 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate*>(
4691 cmd_data);
4692 (void)c;
4693 GLsizei n = static_cast<GLsizei>(c.n);
4694 uint32_t data_size;
4695 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4696 return error::kOutOfBounds;
4698 const GLuint* valuebuffers =
4699 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4700 if (valuebuffers == NULL) {
4701 return error::kOutOfBounds;
4703 DeleteValuebuffersCHROMIUMHelper(n, valuebuffers);
4704 return error::kNoError;
4707 error::Error GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4708 uint32_t immediate_data_size,
4709 const void* cmd_data) {
4710 const gles2::cmds::IsValuebufferCHROMIUM& c =
4711 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM*>(cmd_data);
4712 (void)c;
4713 GLuint valuebuffer = c.valuebuffer;
4714 typedef cmds::IsValuebufferCHROMIUM::Result Result;
4715 Result* result_dst = GetSharedMemoryAs<Result*>(
4716 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4717 if (!result_dst) {
4718 return error::kOutOfBounds;
4720 *result_dst = DoIsValuebufferCHROMIUM(valuebuffer);
4721 return error::kNoError;
4724 error::Error GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4725 uint32_t immediate_data_size,
4726 const void* cmd_data) {
4727 const gles2::cmds::BindValuebufferCHROMIUM& c =
4728 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM*>(cmd_data);
4729 (void)c;
4730 GLenum target = static_cast<GLenum>(c.target);
4731 GLuint valuebuffer = c.valuebuffer;
4732 if (!validators_->value_buffer_target.IsValid(target)) {
4733 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target,
4734 "target");
4735 return error::kNoError;
4737 DoBindValueBufferCHROMIUM(target, valuebuffer);
4738 return error::kNoError;
4741 error::Error GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4742 uint32_t immediate_data_size,
4743 const void* cmd_data) {
4744 const gles2::cmds::SubscribeValueCHROMIUM& c =
4745 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM*>(cmd_data);
4746 (void)c;
4747 GLenum target = static_cast<GLenum>(c.target);
4748 GLenum subscription = static_cast<GLenum>(c.subscription);
4749 if (!validators_->value_buffer_target.IsValid(target)) {
4750 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target,
4751 "target");
4752 return error::kNoError;
4754 if (!validators_->subscription_target.IsValid(subscription)) {
4755 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription,
4756 "subscription");
4757 return error::kNoError;
4759 DoSubscribeValueCHROMIUM(target, subscription);
4760 return error::kNoError;
4763 error::Error GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4764 uint32_t immediate_data_size,
4765 const void* cmd_data) {
4766 const gles2::cmds::PopulateSubscribedValuesCHROMIUM& c =
4767 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM*>(
4768 cmd_data);
4769 (void)c;
4770 GLenum target = static_cast<GLenum>(c.target);
4771 if (!validators_->value_buffer_target.IsValid(target)) {
4772 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4773 target, "target");
4774 return error::kNoError;
4776 DoPopulateSubscribedValuesCHROMIUM(target);
4777 return error::kNoError;
4780 error::Error GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4781 uint32_t immediate_data_size,
4782 const void* cmd_data) {
4783 const gles2::cmds::UniformValuebufferCHROMIUM& c =
4784 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM*>(cmd_data);
4785 (void)c;
4786 GLint location = static_cast<GLint>(c.location);
4787 GLenum target = static_cast<GLenum>(c.target);
4788 GLenum subscription = static_cast<GLenum>(c.subscription);
4789 if (!validators_->value_buffer_target.IsValid(target)) {
4790 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target,
4791 "target");
4792 return error::kNoError;
4794 if (!validators_->subscription_target.IsValid(subscription)) {
4795 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4796 subscription, "subscription");
4797 return error::kNoError;
4799 DoUniformValueBufferCHROMIUM(location, target, subscription);
4800 return error::kNoError;
4803 error::Error GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4804 uint32_t immediate_data_size,
4805 const void* cmd_data) {
4806 const gles2::cmds::BindTexImage2DCHROMIUM& c =
4807 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM*>(cmd_data);
4808 (void)c;
4809 GLenum target = static_cast<GLenum>(c.target);
4810 GLint imageId = static_cast<GLint>(c.imageId);
4811 if (!validators_->texture_bind_target.IsValid(target)) {
4812 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target,
4813 "target");
4814 return error::kNoError;
4816 DoBindTexImage2DCHROMIUM(target, imageId);
4817 return error::kNoError;
4820 error::Error GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4821 uint32_t immediate_data_size,
4822 const void* cmd_data) {
4823 const gles2::cmds::ReleaseTexImage2DCHROMIUM& c =
4824 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM*>(cmd_data);
4825 (void)c;
4826 GLenum target = static_cast<GLenum>(c.target);
4827 GLint imageId = static_cast<GLint>(c.imageId);
4828 if (!validators_->texture_bind_target.IsValid(target)) {
4829 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target,
4830 "target");
4831 return error::kNoError;
4833 DoReleaseTexImage2DCHROMIUM(target, imageId);
4834 return error::kNoError;
4837 error::Error GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4838 uint32_t immediate_data_size,
4839 const void* cmd_data) {
4840 const gles2::cmds::TraceEndCHROMIUM& c =
4841 *static_cast<const gles2::cmds::TraceEndCHROMIUM*>(cmd_data);
4842 (void)c;
4843 DoTraceEndCHROMIUM();
4844 return error::kNoError;
4847 error::Error GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4848 uint32_t immediate_data_size,
4849 const void* cmd_data) {
4850 const gles2::cmds::DiscardFramebufferEXTImmediate& c =
4851 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate*>(
4852 cmd_data);
4853 (void)c;
4854 if (!features().ext_discard_framebuffer) {
4855 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDiscardFramebufferEXT",
4856 "function not available");
4857 return error::kNoError;
4860 GLenum target = static_cast<GLenum>(c.target);
4861 GLsizei count = static_cast<GLsizei>(c.count);
4862 uint32_t data_size;
4863 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4864 return error::kOutOfBounds;
4866 if (data_size > immediate_data_size) {
4867 return error::kOutOfBounds;
4869 const GLenum* attachments =
4870 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4871 if (count < 0) {
4872 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDiscardFramebufferEXT",
4873 "count < 0");
4874 return error::kNoError;
4876 if (attachments == NULL) {
4877 return error::kOutOfBounds;
4879 DoDiscardFramebufferEXT(target, count, attachments);
4880 return error::kNoError;
4883 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4884 uint32_t immediate_data_size,
4885 const void* cmd_data) {
4886 const gles2::cmds::LoseContextCHROMIUM& c =
4887 *static_cast<const gles2::cmds::LoseContextCHROMIUM*>(cmd_data);
4888 (void)c;
4889 GLenum current = static_cast<GLenum>(c.current);
4890 GLenum other = static_cast<GLenum>(c.other);
4891 if (!validators_->reset_status.IsValid(current)) {
4892 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
4893 "current");
4894 return error::kNoError;
4896 if (!validators_->reset_status.IsValid(other)) {
4897 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
4898 return error::kNoError;
4900 DoLoseContextCHROMIUM(current, other);
4901 return error::kNoError;
4904 error::Error GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4905 uint32_t immediate_data_size,
4906 const void* cmd_data) {
4907 const gles2::cmds::DrawBuffersEXTImmediate& c =
4908 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate*>(cmd_data);
4909 (void)c;
4910 GLsizei count = static_cast<GLsizei>(c.count);
4911 uint32_t data_size;
4912 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4913 return error::kOutOfBounds;
4915 if (data_size > immediate_data_size) {
4916 return error::kOutOfBounds;
4918 const GLenum* bufs =
4919 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4920 if (count < 0) {
4921 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
4922 return error::kNoError;
4924 if (bufs == NULL) {
4925 return error::kOutOfBounds;
4927 DoDrawBuffersEXT(count, bufs);
4928 return error::kNoError;
4931 error::Error GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size,
4932 const void* cmd_data) {
4933 const gles2::cmds::SwapInterval& c =
4934 *static_cast<const gles2::cmds::SwapInterval*>(cmd_data);
4935 (void)c;
4936 GLint interval = static_cast<GLint>(c.interval);
4937 DoSwapInterval(interval);
4938 return error::kNoError;
4941 error::Error GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4942 uint32_t immediate_data_size,
4943 const void* cmd_data) {
4944 const gles2::cmds::MatrixLoadfCHROMIUMImmediate& c =
4945 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate*>(cmd_data);
4946 (void)c;
4947 if (!features().chromium_path_rendering) {
4948 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadfCHROMIUM",
4949 "function not available");
4950 return error::kNoError;
4953 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4954 uint32_t data_size;
4955 if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
4956 return error::kOutOfBounds;
4958 if (data_size > immediate_data_size) {
4959 return error::kOutOfBounds;
4961 const GLfloat* m =
4962 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
4963 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4964 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode,
4965 "matrixMode");
4966 return error::kNoError;
4968 if (m == NULL) {
4969 return error::kOutOfBounds;
4971 DoMatrixLoadfCHROMIUM(matrixMode, m);
4972 return error::kNoError;
4975 error::Error GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
4976 uint32_t immediate_data_size,
4977 const void* cmd_data) {
4978 const gles2::cmds::MatrixLoadIdentityCHROMIUM& c =
4979 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM*>(cmd_data);
4980 (void)c;
4981 if (!features().chromium_path_rendering) {
4982 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadIdentityCHROMIUM",
4983 "function not available");
4984 return error::kNoError;
4987 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4988 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4989 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode,
4990 "matrixMode");
4991 return error::kNoError;
4993 DoMatrixLoadIdentityCHROMIUM(matrixMode);
4994 return error::kNoError;
4997 error::Error GLES2DecoderImpl::HandleBlendBarrierKHR(
4998 uint32_t immediate_data_size,
4999 const void* cmd_data) {
5000 const gles2::cmds::BlendBarrierKHR& c =
5001 *static_cast<const gles2::cmds::BlendBarrierKHR*>(cmd_data);
5002 (void)c;
5003 if (!features().blend_equation_advanced) {
5004 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlendBarrierKHR",
5005 "function not available");
5006 return error::kNoError;
5009 glBlendBarrierKHR();
5010 return error::kNoError;
5013 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
5014 switch (cap) {
5015 case GL_BLEND:
5016 state_.enable_flags.blend = enabled;
5017 if (state_.enable_flags.cached_blend != enabled ||
5018 state_.ignore_cached_state) {
5019 state_.enable_flags.cached_blend = enabled;
5020 return true;
5022 return false;
5023 case GL_CULL_FACE:
5024 state_.enable_flags.cull_face = enabled;
5025 if (state_.enable_flags.cached_cull_face != enabled ||
5026 state_.ignore_cached_state) {
5027 state_.enable_flags.cached_cull_face = enabled;
5028 return true;
5030 return false;
5031 case GL_DEPTH_TEST:
5032 state_.enable_flags.depth_test = enabled;
5033 if (state_.enable_flags.cached_depth_test != enabled ||
5034 state_.ignore_cached_state) {
5035 framebuffer_state_.clear_state_dirty = true;
5037 return false;
5038 case GL_DITHER:
5039 state_.enable_flags.dither = enabled;
5040 if (state_.enable_flags.cached_dither != enabled ||
5041 state_.ignore_cached_state) {
5042 state_.enable_flags.cached_dither = enabled;
5043 return true;
5045 return false;
5046 case GL_POLYGON_OFFSET_FILL:
5047 state_.enable_flags.polygon_offset_fill = enabled;
5048 if (state_.enable_flags.cached_polygon_offset_fill != enabled ||
5049 state_.ignore_cached_state) {
5050 state_.enable_flags.cached_polygon_offset_fill = enabled;
5051 return true;
5053 return false;
5054 case GL_SAMPLE_ALPHA_TO_COVERAGE:
5055 state_.enable_flags.sample_alpha_to_coverage = enabled;
5056 if (state_.enable_flags.cached_sample_alpha_to_coverage != enabled ||
5057 state_.ignore_cached_state) {
5058 state_.enable_flags.cached_sample_alpha_to_coverage = enabled;
5059 return true;
5061 return false;
5062 case GL_SAMPLE_COVERAGE:
5063 state_.enable_flags.sample_coverage = enabled;
5064 if (state_.enable_flags.cached_sample_coverage != enabled ||
5065 state_.ignore_cached_state) {
5066 state_.enable_flags.cached_sample_coverage = enabled;
5067 return true;
5069 return false;
5070 case GL_SCISSOR_TEST:
5071 state_.enable_flags.scissor_test = enabled;
5072 if (state_.enable_flags.cached_scissor_test != enabled ||
5073 state_.ignore_cached_state) {
5074 state_.enable_flags.cached_scissor_test = enabled;
5075 return true;
5077 return false;
5078 case GL_STENCIL_TEST:
5079 state_.enable_flags.stencil_test = enabled;
5080 if (state_.enable_flags.cached_stencil_test != enabled ||
5081 state_.ignore_cached_state) {
5082 framebuffer_state_.clear_state_dirty = true;
5084 return false;
5085 case GL_RASTERIZER_DISCARD:
5086 state_.enable_flags.rasterizer_discard = enabled;
5087 if (state_.enable_flags.cached_rasterizer_discard != enabled ||
5088 state_.ignore_cached_state) {
5089 state_.enable_flags.cached_rasterizer_discard = enabled;
5090 return true;
5092 return false;
5093 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
5094 state_.enable_flags.primitive_restart_fixed_index = enabled;
5095 if (state_.enable_flags.cached_primitive_restart_fixed_index != enabled ||
5096 state_.ignore_cached_state) {
5097 state_.enable_flags.cached_primitive_restart_fixed_index = enabled;
5098 return true;
5100 return false;
5101 default:
5102 NOTREACHED();
5103 return false;
5106 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_