Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_autogen.h
blobe97591026f585d41ec8dda0965974e29ec84ac28
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 = LOCAL_PEEK_GL_ERROR("GetBooleanv");
1385 if (error == GL_NO_ERROR) {
1386 result->SetNumResults(num_values);
1388 return error::kNoError;
1391 error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
1392 uint32_t immediate_data_size,
1393 const void* cmd_data) {
1394 const gles2::cmds::GetBufferParameteriv& c =
1395 *static_cast<const gles2::cmds::GetBufferParameteriv*>(cmd_data);
1396 (void)c;
1397 GLenum target = static_cast<GLenum>(c.target);
1398 GLenum pname = static_cast<GLenum>(c.pname);
1399 typedef cmds::GetBufferParameteriv::Result Result;
1400 GLsizei num_values = 0;
1401 GetNumValuesReturnedForGLGet(pname, &num_values);
1402 Result* result = GetSharedMemoryAs<Result*>(
1403 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1404 GLint* params = result ? result->GetData() : NULL;
1405 if (!validators_->buffer_target.IsValid(target)) {
1406 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
1407 return error::kNoError;
1409 if (!validators_->buffer_parameter.IsValid(pname)) {
1410 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
1411 return error::kNoError;
1413 if (params == NULL) {
1414 return error::kOutOfBounds;
1416 // Check that the client initialized the result.
1417 if (result->size != 0) {
1418 return error::kInvalidArguments;
1420 DoGetBufferParameteriv(target, pname, params);
1421 result->SetNumResults(num_values);
1422 return error::kNoError;
1424 error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
1425 const void* cmd_data) {
1426 const gles2::cmds::GetError& c =
1427 *static_cast<const gles2::cmds::GetError*>(cmd_data);
1428 (void)c;
1429 typedef cmds::GetError::Result Result;
1430 Result* result_dst = GetSharedMemoryAs<Result*>(
1431 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1432 if (!result_dst) {
1433 return error::kOutOfBounds;
1435 *result_dst = GetErrorState()->GetGLError();
1436 return error::kNoError;
1439 error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
1440 const void* cmd_data) {
1441 const gles2::cmds::GetFloatv& c =
1442 *static_cast<const gles2::cmds::GetFloatv*>(cmd_data);
1443 (void)c;
1444 GLenum pname = static_cast<GLenum>(c.pname);
1445 typedef cmds::GetFloatv::Result Result;
1446 GLsizei num_values = 0;
1447 GetNumValuesReturnedForGLGet(pname, &num_values);
1448 Result* result = GetSharedMemoryAs<Result*>(
1449 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1450 GLfloat* params = result ? result->GetData() : NULL;
1451 if (!validators_->g_l_state.IsValid(pname)) {
1452 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
1453 return error::kNoError;
1455 if (params == NULL) {
1456 return error::kOutOfBounds;
1458 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1459 // Check that the client initialized the result.
1460 if (result->size != 0) {
1461 return error::kInvalidArguments;
1463 DoGetFloatv(pname, params);
1464 GLenum error = LOCAL_PEEK_GL_ERROR("GetFloatv");
1465 if (error == GL_NO_ERROR) {
1466 result->SetNumResults(num_values);
1468 return error::kNoError;
1471 error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1472 uint32_t immediate_data_size,
1473 const void* cmd_data) {
1474 const gles2::cmds::GetFramebufferAttachmentParameteriv& c =
1475 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv*>(
1476 cmd_data);
1477 (void)c;
1478 GLenum target = static_cast<GLenum>(c.target);
1479 GLenum attachment = static_cast<GLenum>(c.attachment);
1480 GLenum pname = static_cast<GLenum>(c.pname);
1481 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
1482 GLsizei num_values = 0;
1483 GetNumValuesReturnedForGLGet(pname, &num_values);
1484 Result* result = GetSharedMemoryAs<Result*>(
1485 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1486 GLint* params = result ? result->GetData() : NULL;
1487 if (!validators_->frame_buffer_target.IsValid(target)) {
1488 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1489 target, "target");
1490 return error::kNoError;
1492 if (!validators_->attachment.IsValid(attachment)) {
1493 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1494 attachment, "attachment");
1495 return error::kNoError;
1497 if (!validators_->frame_buffer_parameter.IsValid(pname)) {
1498 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1499 pname, "pname");
1500 return error::kNoError;
1502 if (params == NULL) {
1503 return error::kOutOfBounds;
1505 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1506 // Check that the client initialized the result.
1507 if (result->size != 0) {
1508 return error::kInvalidArguments;
1510 DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1511 GLenum error = LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv");
1512 if (error == GL_NO_ERROR) {
1513 result->SetNumResults(num_values);
1515 return error::kNoError;
1518 error::Error GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size,
1519 const void* cmd_data) {
1520 if (!unsafe_es3_apis_enabled())
1521 return error::kUnknownCommand;
1522 const gles2::cmds::GetInteger64v& c =
1523 *static_cast<const gles2::cmds::GetInteger64v*>(cmd_data);
1524 (void)c;
1525 GLenum pname = static_cast<GLenum>(c.pname);
1526 typedef cmds::GetInteger64v::Result Result;
1527 GLsizei num_values = 0;
1528 GetNumValuesReturnedForGLGet(pname, &num_values);
1529 Result* result = GetSharedMemoryAs<Result*>(
1530 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1531 GLint64* params = result ? result->GetData() : NULL;
1532 if (params == NULL) {
1533 return error::kOutOfBounds;
1535 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
1536 // Check that the client initialized the result.
1537 if (result->size != 0) {
1538 return error::kInvalidArguments;
1540 DoGetInteger64v(pname, params);
1541 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64v");
1542 if (error == GL_NO_ERROR) {
1543 result->SetNumResults(num_values);
1545 return error::kNoError;
1548 error::Error GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size,
1549 const void* cmd_data) {
1550 if (!unsafe_es3_apis_enabled())
1551 return error::kUnknownCommand;
1552 const gles2::cmds::GetIntegeri_v& c =
1553 *static_cast<const gles2::cmds::GetIntegeri_v*>(cmd_data);
1554 (void)c;
1555 GLenum pname = static_cast<GLenum>(c.pname);
1556 GLuint index = static_cast<GLuint>(c.index);
1557 typedef cmds::GetIntegeri_v::Result Result;
1558 GLsizei num_values = 0;
1559 GetNumValuesReturnedForGLGet(pname, &num_values);
1560 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1561 Result::ComputeSize(num_values));
1562 GLint* data = result ? result->GetData() : NULL;
1563 if (data == NULL) {
1564 return error::kOutOfBounds;
1566 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegeri_v");
1567 // Check that the client initialized the result.
1568 if (result->size != 0) {
1569 return error::kInvalidArguments;
1571 glGetIntegeri_v(pname, index, data);
1572 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegeri_v");
1573 if (error == GL_NO_ERROR) {
1574 result->SetNumResults(num_values);
1576 return error::kNoError;
1579 error::Error GLES2DecoderImpl::HandleGetInteger64i_v(
1580 uint32_t immediate_data_size,
1581 const void* cmd_data) {
1582 if (!unsafe_es3_apis_enabled())
1583 return error::kUnknownCommand;
1584 const gles2::cmds::GetInteger64i_v& c =
1585 *static_cast<const gles2::cmds::GetInteger64i_v*>(cmd_data);
1586 (void)c;
1587 GLenum pname = static_cast<GLenum>(c.pname);
1588 GLuint index = static_cast<GLuint>(c.index);
1589 typedef cmds::GetInteger64i_v::Result Result;
1590 GLsizei num_values = 0;
1591 GetNumValuesReturnedForGLGet(pname, &num_values);
1592 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1593 Result::ComputeSize(num_values));
1594 GLint64* data = result ? result->GetData() : NULL;
1595 if (data == NULL) {
1596 return error::kOutOfBounds;
1598 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64i_v");
1599 // Check that the client initialized the result.
1600 if (result->size != 0) {
1601 return error::kInvalidArguments;
1603 glGetInteger64i_v(pname, index, data);
1604 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64i_v");
1605 if (error == GL_NO_ERROR) {
1606 result->SetNumResults(num_values);
1608 return error::kNoError;
1611 error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size,
1612 const void* cmd_data) {
1613 const gles2::cmds::GetIntegerv& c =
1614 *static_cast<const gles2::cmds::GetIntegerv*>(cmd_data);
1615 (void)c;
1616 GLenum pname = static_cast<GLenum>(c.pname);
1617 typedef cmds::GetIntegerv::Result Result;
1618 GLsizei num_values = 0;
1619 GetNumValuesReturnedForGLGet(pname, &num_values);
1620 Result* result = GetSharedMemoryAs<Result*>(
1621 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1622 GLint* params = result ? result->GetData() : NULL;
1623 if (!validators_->g_l_state.IsValid(pname)) {
1624 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
1625 return error::kNoError;
1627 if (params == NULL) {
1628 return error::kOutOfBounds;
1630 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1631 // Check that the client initialized the result.
1632 if (result->size != 0) {
1633 return error::kInvalidArguments;
1635 DoGetIntegerv(pname, params);
1636 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegerv");
1637 if (error == GL_NO_ERROR) {
1638 result->SetNumResults(num_values);
1640 return error::kNoError;
1643 error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size,
1644 const void* cmd_data) {
1645 const gles2::cmds::GetProgramiv& c =
1646 *static_cast<const gles2::cmds::GetProgramiv*>(cmd_data);
1647 (void)c;
1648 GLuint program = c.program;
1649 GLenum pname = static_cast<GLenum>(c.pname);
1650 typedef cmds::GetProgramiv::Result Result;
1651 GLsizei num_values = 0;
1652 GetNumValuesReturnedForGLGet(pname, &num_values);
1653 Result* result = GetSharedMemoryAs<Result*>(
1654 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1655 GLint* params = result ? result->GetData() : NULL;
1656 if (!validators_->program_parameter.IsValid(pname)) {
1657 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
1658 return error::kNoError;
1660 if (params == NULL) {
1661 return error::kOutOfBounds;
1663 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1664 // Check that the client initialized the result.
1665 if (result->size != 0) {
1666 return error::kInvalidArguments;
1668 DoGetProgramiv(program, pname, params);
1669 GLenum error = LOCAL_PEEK_GL_ERROR("GetProgramiv");
1670 if (error == GL_NO_ERROR) {
1671 result->SetNumResults(num_values);
1673 return error::kNoError;
1676 error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1677 uint32_t immediate_data_size,
1678 const void* cmd_data) {
1679 const gles2::cmds::GetRenderbufferParameteriv& c =
1680 *static_cast<const gles2::cmds::GetRenderbufferParameteriv*>(cmd_data);
1681 (void)c;
1682 GLenum target = static_cast<GLenum>(c.target);
1683 GLenum pname = static_cast<GLenum>(c.pname);
1684 typedef cmds::GetRenderbufferParameteriv::Result Result;
1685 GLsizei num_values = 0;
1686 GetNumValuesReturnedForGLGet(pname, &num_values);
1687 Result* result = GetSharedMemoryAs<Result*>(
1688 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1689 GLint* params = result ? result->GetData() : NULL;
1690 if (!validators_->render_buffer_target.IsValid(target)) {
1691 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
1692 "target");
1693 return error::kNoError;
1695 if (!validators_->render_buffer_parameter.IsValid(pname)) {
1696 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
1697 "pname");
1698 return error::kNoError;
1700 if (params == NULL) {
1701 return error::kOutOfBounds;
1703 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1704 // Check that the client initialized the result.
1705 if (result->size != 0) {
1706 return error::kInvalidArguments;
1708 DoGetRenderbufferParameteriv(target, pname, params);
1709 GLenum error = LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv");
1710 if (error == GL_NO_ERROR) {
1711 result->SetNumResults(num_values);
1713 return error::kNoError;
1716 error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
1717 uint32_t immediate_data_size,
1718 const void* cmd_data) {
1719 if (!unsafe_es3_apis_enabled())
1720 return error::kUnknownCommand;
1721 const gles2::cmds::GetSamplerParameterfv& c =
1722 *static_cast<const gles2::cmds::GetSamplerParameterfv*>(cmd_data);
1723 (void)c;
1724 GLuint sampler = c.sampler;
1725 GLenum pname = static_cast<GLenum>(c.pname);
1726 typedef cmds::GetSamplerParameterfv::Result Result;
1727 GLsizei num_values = 0;
1728 GetNumValuesReturnedForGLGet(pname, &num_values);
1729 Result* result = GetSharedMemoryAs<Result*>(
1730 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1731 GLfloat* params = result ? result->GetData() : NULL;
1732 if (params == NULL) {
1733 return error::kOutOfBounds;
1735 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1736 // Check that the client initialized the result.
1737 if (result->size != 0) {
1738 return error::kInvalidArguments;
1740 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1741 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameterfv",
1742 "invalid sampler id");
1743 return error::kNoError;
1745 glGetSamplerParameterfv(sampler, pname, params);
1746 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv");
1747 if (error == GL_NO_ERROR) {
1748 result->SetNumResults(num_values);
1750 return error::kNoError;
1753 error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
1754 uint32_t immediate_data_size,
1755 const void* cmd_data) {
1756 if (!unsafe_es3_apis_enabled())
1757 return error::kUnknownCommand;
1758 const gles2::cmds::GetSamplerParameteriv& c =
1759 *static_cast<const gles2::cmds::GetSamplerParameteriv*>(cmd_data);
1760 (void)c;
1761 GLuint sampler = c.sampler;
1762 GLenum pname = static_cast<GLenum>(c.pname);
1763 typedef cmds::GetSamplerParameteriv::Result Result;
1764 GLsizei num_values = 0;
1765 GetNumValuesReturnedForGLGet(pname, &num_values);
1766 Result* result = GetSharedMemoryAs<Result*>(
1767 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1768 GLint* params = result ? result->GetData() : NULL;
1769 if (params == NULL) {
1770 return error::kOutOfBounds;
1772 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1773 // Check that the client initialized the result.
1774 if (result->size != 0) {
1775 return error::kInvalidArguments;
1777 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1778 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameteriv",
1779 "invalid sampler id");
1780 return error::kNoError;
1782 glGetSamplerParameteriv(sampler, pname, params);
1783 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv");
1784 if (error == GL_NO_ERROR) {
1785 result->SetNumResults(num_values);
1787 return error::kNoError;
1790 error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size,
1791 const void* cmd_data) {
1792 const gles2::cmds::GetShaderiv& c =
1793 *static_cast<const gles2::cmds::GetShaderiv*>(cmd_data);
1794 (void)c;
1795 GLuint shader = c.shader;
1796 GLenum pname = static_cast<GLenum>(c.pname);
1797 typedef cmds::GetShaderiv::Result Result;
1798 GLsizei num_values = 0;
1799 GetNumValuesReturnedForGLGet(pname, &num_values);
1800 Result* result = GetSharedMemoryAs<Result*>(
1801 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1802 GLint* params = result ? result->GetData() : NULL;
1803 if (!validators_->shader_parameter.IsValid(pname)) {
1804 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
1805 return error::kNoError;
1807 if (params == NULL) {
1808 return error::kOutOfBounds;
1810 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1811 // Check that the client initialized the result.
1812 if (result->size != 0) {
1813 return error::kInvalidArguments;
1815 DoGetShaderiv(shader, pname, params);
1816 GLenum error = LOCAL_PEEK_GL_ERROR("GetShaderiv");
1817 if (error == GL_NO_ERROR) {
1818 result->SetNumResults(num_values);
1820 return error::kNoError;
1823 error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
1824 const void* cmd_data) {
1825 if (!unsafe_es3_apis_enabled())
1826 return error::kUnknownCommand;
1827 const gles2::cmds::GetSynciv& c =
1828 *static_cast<const gles2::cmds::GetSynciv*>(cmd_data);
1829 (void)c;
1830 GLuint sync = static_cast<GLuint>(c.sync);
1831 GLenum pname = static_cast<GLenum>(c.pname);
1832 typedef cmds::GetSynciv::Result Result;
1833 GLsizei num_values = 0;
1834 GetNumValuesReturnedForGLGet(pname, &num_values);
1835 Result* result = GetSharedMemoryAs<Result*>(
1836 c.values_shm_id, c.values_shm_offset, Result::ComputeSize(num_values));
1837 GLint* values = result ? result->GetData() : NULL;
1838 if (values == NULL) {
1839 return error::kOutOfBounds;
1841 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1842 // Check that the client initialized the result.
1843 if (result->size != 0) {
1844 return error::kInvalidArguments;
1846 GLsync service_sync = 0;
1847 if (!group_->GetSyncServiceId(sync, &service_sync)) {
1848 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSynciv", "invalid sync id");
1849 return error::kNoError;
1851 glGetSynciv(service_sync, pname, num_values, nullptr, values);
1852 GLenum error = LOCAL_PEEK_GL_ERROR("GetSynciv");
1853 if (error == GL_NO_ERROR) {
1854 result->SetNumResults(num_values);
1856 return error::kNoError;
1859 error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
1860 uint32_t immediate_data_size,
1861 const void* cmd_data) {
1862 const gles2::cmds::GetTexParameterfv& c =
1863 *static_cast<const gles2::cmds::GetTexParameterfv*>(cmd_data);
1864 (void)c;
1865 GLenum target = static_cast<GLenum>(c.target);
1866 GLenum pname = static_cast<GLenum>(c.pname);
1867 typedef cmds::GetTexParameterfv::Result Result;
1868 GLsizei num_values = 0;
1869 GetNumValuesReturnedForGLGet(pname, &num_values);
1870 Result* result = GetSharedMemoryAs<Result*>(
1871 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1872 GLfloat* params = result ? result->GetData() : NULL;
1873 if (!validators_->get_tex_param_target.IsValid(target)) {
1874 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
1875 return error::kNoError;
1877 if (!validators_->texture_parameter.IsValid(pname)) {
1878 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
1879 return error::kNoError;
1881 if (params == NULL) {
1882 return error::kOutOfBounds;
1884 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1885 // Check that the client initialized the result.
1886 if (result->size != 0) {
1887 return error::kInvalidArguments;
1889 DoGetTexParameterfv(target, pname, params);
1890 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameterfv");
1891 if (error == GL_NO_ERROR) {
1892 result->SetNumResults(num_values);
1894 return error::kNoError;
1897 error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
1898 uint32_t immediate_data_size,
1899 const void* cmd_data) {
1900 const gles2::cmds::GetTexParameteriv& c =
1901 *static_cast<const gles2::cmds::GetTexParameteriv*>(cmd_data);
1902 (void)c;
1903 GLenum target = static_cast<GLenum>(c.target);
1904 GLenum pname = static_cast<GLenum>(c.pname);
1905 typedef cmds::GetTexParameteriv::Result Result;
1906 GLsizei num_values = 0;
1907 GetNumValuesReturnedForGLGet(pname, &num_values);
1908 Result* result = GetSharedMemoryAs<Result*>(
1909 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1910 GLint* params = result ? result->GetData() : NULL;
1911 if (!validators_->get_tex_param_target.IsValid(target)) {
1912 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
1913 return error::kNoError;
1915 if (!validators_->texture_parameter.IsValid(pname)) {
1916 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
1917 return error::kNoError;
1919 if (params == NULL) {
1920 return error::kOutOfBounds;
1922 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1923 // Check that the client initialized the result.
1924 if (result->size != 0) {
1925 return error::kInvalidArguments;
1927 DoGetTexParameteriv(target, pname, params);
1928 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameteriv");
1929 if (error == GL_NO_ERROR) {
1930 result->SetNumResults(num_values);
1932 return error::kNoError;
1935 error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
1936 uint32_t immediate_data_size,
1937 const void* cmd_data) {
1938 const gles2::cmds::GetVertexAttribfv& c =
1939 *static_cast<const gles2::cmds::GetVertexAttribfv*>(cmd_data);
1940 (void)c;
1941 GLuint index = static_cast<GLuint>(c.index);
1942 GLenum pname = static_cast<GLenum>(c.pname);
1943 typedef cmds::GetVertexAttribfv::Result Result;
1944 GLsizei num_values = 0;
1945 GetNumValuesReturnedForGLGet(pname, &num_values);
1946 Result* result = GetSharedMemoryAs<Result*>(
1947 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1948 GLfloat* params = result ? result->GetData() : NULL;
1949 if (!validators_->vertex_attribute.IsValid(pname)) {
1950 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
1951 return error::kNoError;
1953 if (params == NULL) {
1954 return error::kOutOfBounds;
1956 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1957 // Check that the client initialized the result.
1958 if (result->size != 0) {
1959 return error::kInvalidArguments;
1961 DoGetVertexAttribfv(index, pname, params);
1962 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribfv");
1963 if (error == GL_NO_ERROR) {
1964 result->SetNumResults(num_values);
1966 return error::kNoError;
1969 error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
1970 uint32_t immediate_data_size,
1971 const void* cmd_data) {
1972 const gles2::cmds::GetVertexAttribiv& c =
1973 *static_cast<const gles2::cmds::GetVertexAttribiv*>(cmd_data);
1974 (void)c;
1975 GLuint index = static_cast<GLuint>(c.index);
1976 GLenum pname = static_cast<GLenum>(c.pname);
1977 typedef cmds::GetVertexAttribiv::Result Result;
1978 GLsizei num_values = 0;
1979 GetNumValuesReturnedForGLGet(pname, &num_values);
1980 Result* result = GetSharedMemoryAs<Result*>(
1981 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1982 GLint* params = result ? result->GetData() : NULL;
1983 if (!validators_->vertex_attribute.IsValid(pname)) {
1984 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
1985 return error::kNoError;
1987 if (params == NULL) {
1988 return error::kOutOfBounds;
1990 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
1991 // Check that the client initialized the result.
1992 if (result->size != 0) {
1993 return error::kInvalidArguments;
1995 DoGetVertexAttribiv(index, pname, params);
1996 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribiv");
1997 if (error == GL_NO_ERROR) {
1998 result->SetNumResults(num_values);
2000 return error::kNoError;
2003 error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv(
2004 uint32_t immediate_data_size,
2005 const void* cmd_data) {
2006 if (!unsafe_es3_apis_enabled())
2007 return error::kUnknownCommand;
2008 const gles2::cmds::GetVertexAttribIiv& c =
2009 *static_cast<const gles2::cmds::GetVertexAttribIiv*>(cmd_data);
2010 (void)c;
2011 GLuint index = static_cast<GLuint>(c.index);
2012 GLenum pname = static_cast<GLenum>(c.pname);
2013 typedef cmds::GetVertexAttribIiv::Result Result;
2014 GLsizei num_values = 0;
2015 GetNumValuesReturnedForGLGet(pname, &num_values);
2016 Result* result = GetSharedMemoryAs<Result*>(
2017 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2018 GLint* params = result ? result->GetData() : NULL;
2019 if (params == NULL) {
2020 return error::kOutOfBounds;
2022 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
2023 // Check that the client initialized the result.
2024 if (result->size != 0) {
2025 return error::kInvalidArguments;
2027 DoGetVertexAttribIiv(index, pname, params);
2028 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv");
2029 if (error == GL_NO_ERROR) {
2030 result->SetNumResults(num_values);
2032 return error::kNoError;
2035 error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv(
2036 uint32_t immediate_data_size,
2037 const void* cmd_data) {
2038 if (!unsafe_es3_apis_enabled())
2039 return error::kUnknownCommand;
2040 const gles2::cmds::GetVertexAttribIuiv& c =
2041 *static_cast<const gles2::cmds::GetVertexAttribIuiv*>(cmd_data);
2042 (void)c;
2043 GLuint index = static_cast<GLuint>(c.index);
2044 GLenum pname = static_cast<GLenum>(c.pname);
2045 typedef cmds::GetVertexAttribIuiv::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 GLuint* params = result ? result->GetData() : NULL;
2051 if (params == NULL) {
2052 return error::kOutOfBounds;
2054 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
2055 // Check that the client initialized the result.
2056 if (result->size != 0) {
2057 return error::kInvalidArguments;
2059 DoGetVertexAttribIuiv(index, pname, params);
2060 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv");
2061 if (error == GL_NO_ERROR) {
2062 result->SetNumResults(num_values);
2064 return error::kNoError;
2067 error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
2068 const void* cmd_data) {
2069 const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data);
2070 (void)c;
2071 GLenum target = static_cast<GLenum>(c.target);
2072 GLenum mode = static_cast<GLenum>(c.mode);
2073 if (!validators_->hint_target.IsValid(target)) {
2074 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
2075 return error::kNoError;
2077 if (!validators_->hint_mode.IsValid(mode)) {
2078 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
2079 return error::kNoError;
2081 switch (target) {
2082 case GL_GENERATE_MIPMAP_HINT:
2083 if (state_.hint_generate_mipmap != mode) {
2084 state_.hint_generate_mipmap = mode;
2085 glHint(target, mode);
2087 break;
2088 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
2089 if (state_.hint_fragment_shader_derivative != mode) {
2090 state_.hint_fragment_shader_derivative = mode;
2091 glHint(target, mode);
2093 break;
2094 default:
2095 NOTREACHED();
2097 return error::kNoError;
2100 error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
2101 uint32_t immediate_data_size,
2102 const void* cmd_data) {
2103 if (!unsafe_es3_apis_enabled())
2104 return error::kUnknownCommand;
2105 const gles2::cmds::InvalidateFramebufferImmediate& c =
2106 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate*>(
2107 cmd_data);
2108 (void)c;
2109 GLenum target = static_cast<GLenum>(c.target);
2110 GLsizei count = static_cast<GLsizei>(c.count);
2111 uint32_t data_size;
2112 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2113 return error::kOutOfBounds;
2115 if (data_size > immediate_data_size) {
2116 return error::kOutOfBounds;
2118 const GLenum* attachments =
2119 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2120 if (attachments == NULL) {
2121 return error::kOutOfBounds;
2123 glInvalidateFramebuffer(target, count, attachments);
2124 return error::kNoError;
2127 error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2128 uint32_t immediate_data_size,
2129 const void* cmd_data) {
2130 if (!unsafe_es3_apis_enabled())
2131 return error::kUnknownCommand;
2132 const gles2::cmds::InvalidateSubFramebufferImmediate& c =
2133 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate*>(
2134 cmd_data);
2135 (void)c;
2136 GLenum target = static_cast<GLenum>(c.target);
2137 GLsizei count = static_cast<GLsizei>(c.count);
2138 uint32_t data_size;
2139 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2140 return error::kOutOfBounds;
2142 if (data_size > immediate_data_size) {
2143 return error::kOutOfBounds;
2145 const GLenum* attachments =
2146 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2147 GLint x = static_cast<GLint>(c.x);
2148 GLint y = static_cast<GLint>(c.y);
2149 GLsizei width = static_cast<GLsizei>(c.width);
2150 GLsizei height = static_cast<GLsizei>(c.height);
2151 if (attachments == NULL) {
2152 return error::kOutOfBounds;
2154 glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height);
2155 return error::kNoError;
2158 error::Error GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size,
2159 const void* cmd_data) {
2160 const gles2::cmds::IsBuffer& c =
2161 *static_cast<const gles2::cmds::IsBuffer*>(cmd_data);
2162 (void)c;
2163 GLuint buffer = c.buffer;
2164 typedef cmds::IsBuffer::Result Result;
2165 Result* result_dst = GetSharedMemoryAs<Result*>(
2166 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2167 if (!result_dst) {
2168 return error::kOutOfBounds;
2170 *result_dst = DoIsBuffer(buffer);
2171 return error::kNoError;
2174 error::Error GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size,
2175 const void* cmd_data) {
2176 const gles2::cmds::IsEnabled& c =
2177 *static_cast<const gles2::cmds::IsEnabled*>(cmd_data);
2178 (void)c;
2179 GLenum cap = static_cast<GLenum>(c.cap);
2180 typedef cmds::IsEnabled::Result Result;
2181 Result* result_dst = GetSharedMemoryAs<Result*>(
2182 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2183 if (!result_dst) {
2184 return error::kOutOfBounds;
2186 if (!validators_->capability.IsValid(cap)) {
2187 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap, "cap");
2188 return error::kNoError;
2190 *result_dst = DoIsEnabled(cap);
2191 return error::kNoError;
2194 error::Error GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size,
2195 const void* cmd_data) {
2196 const gles2::cmds::IsFramebuffer& c =
2197 *static_cast<const gles2::cmds::IsFramebuffer*>(cmd_data);
2198 (void)c;
2199 GLuint framebuffer = c.framebuffer;
2200 typedef cmds::IsFramebuffer::Result Result;
2201 Result* result_dst = GetSharedMemoryAs<Result*>(
2202 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2203 if (!result_dst) {
2204 return error::kOutOfBounds;
2206 *result_dst = DoIsFramebuffer(framebuffer);
2207 return error::kNoError;
2210 error::Error GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size,
2211 const void* cmd_data) {
2212 const gles2::cmds::IsProgram& c =
2213 *static_cast<const gles2::cmds::IsProgram*>(cmd_data);
2214 (void)c;
2215 GLuint program = c.program;
2216 typedef cmds::IsProgram::Result Result;
2217 Result* result_dst = GetSharedMemoryAs<Result*>(
2218 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2219 if (!result_dst) {
2220 return error::kOutOfBounds;
2222 *result_dst = DoIsProgram(program);
2223 return error::kNoError;
2226 error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
2227 uint32_t immediate_data_size,
2228 const void* cmd_data) {
2229 const gles2::cmds::IsRenderbuffer& c =
2230 *static_cast<const gles2::cmds::IsRenderbuffer*>(cmd_data);
2231 (void)c;
2232 GLuint renderbuffer = c.renderbuffer;
2233 typedef cmds::IsRenderbuffer::Result Result;
2234 Result* result_dst = GetSharedMemoryAs<Result*>(
2235 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2236 if (!result_dst) {
2237 return error::kOutOfBounds;
2239 *result_dst = DoIsRenderbuffer(renderbuffer);
2240 return error::kNoError;
2243 error::Error GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size,
2244 const void* cmd_data) {
2245 if (!unsafe_es3_apis_enabled())
2246 return error::kUnknownCommand;
2247 const gles2::cmds::IsSampler& c =
2248 *static_cast<const gles2::cmds::IsSampler*>(cmd_data);
2249 (void)c;
2250 GLuint sampler = c.sampler;
2251 typedef cmds::IsSampler::Result Result;
2252 Result* result_dst = GetSharedMemoryAs<Result*>(
2253 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2254 if (!result_dst) {
2255 return error::kOutOfBounds;
2257 GLuint service_sampler = 0;
2258 *result_dst = group_->GetSamplerServiceId(sampler, &service_sampler);
2259 return error::kNoError;
2262 error::Error GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size,
2263 const void* cmd_data) {
2264 const gles2::cmds::IsShader& c =
2265 *static_cast<const gles2::cmds::IsShader*>(cmd_data);
2266 (void)c;
2267 GLuint shader = c.shader;
2268 typedef cmds::IsShader::Result Result;
2269 Result* result_dst = GetSharedMemoryAs<Result*>(
2270 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2271 if (!result_dst) {
2272 return error::kOutOfBounds;
2274 *result_dst = DoIsShader(shader);
2275 return error::kNoError;
2278 error::Error GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size,
2279 const void* cmd_data) {
2280 if (!unsafe_es3_apis_enabled())
2281 return error::kUnknownCommand;
2282 const gles2::cmds::IsSync& c =
2283 *static_cast<const gles2::cmds::IsSync*>(cmd_data);
2284 (void)c;
2285 GLuint sync = c.sync;
2286 typedef cmds::IsSync::Result Result;
2287 Result* result_dst = GetSharedMemoryAs<Result*>(
2288 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2289 if (!result_dst) {
2290 return error::kOutOfBounds;
2292 GLsync service_sync = 0;
2293 *result_dst = group_->GetSyncServiceId(sync, &service_sync);
2294 return error::kNoError;
2297 error::Error GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size,
2298 const void* cmd_data) {
2299 const gles2::cmds::IsTexture& c =
2300 *static_cast<const gles2::cmds::IsTexture*>(cmd_data);
2301 (void)c;
2302 GLuint texture = c.texture;
2303 typedef cmds::IsTexture::Result Result;
2304 Result* result_dst = GetSharedMemoryAs<Result*>(
2305 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2306 if (!result_dst) {
2307 return error::kOutOfBounds;
2309 *result_dst = DoIsTexture(texture);
2310 return error::kNoError;
2313 error::Error GLES2DecoderImpl::HandleIsTransformFeedback(
2314 uint32_t immediate_data_size,
2315 const void* cmd_data) {
2316 if (!unsafe_es3_apis_enabled())
2317 return error::kUnknownCommand;
2318 const gles2::cmds::IsTransformFeedback& c =
2319 *static_cast<const gles2::cmds::IsTransformFeedback*>(cmd_data);
2320 (void)c;
2321 GLuint transformfeedback = c.transformfeedback;
2322 typedef cmds::IsTransformFeedback::Result Result;
2323 Result* result_dst = GetSharedMemoryAs<Result*>(
2324 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2325 if (!result_dst) {
2326 return error::kOutOfBounds;
2328 GLuint service_transformfeedback = 0;
2329 *result_dst = group_->GetTransformFeedbackServiceId(
2330 transformfeedback, &service_transformfeedback);
2331 return error::kNoError;
2334 error::Error GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size,
2335 const void* cmd_data) {
2336 const gles2::cmds::LineWidth& c =
2337 *static_cast<const gles2::cmds::LineWidth*>(cmd_data);
2338 (void)c;
2339 GLfloat width = static_cast<GLfloat>(c.width);
2340 if (width <= 0.0f || std::isnan(width)) {
2341 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "LineWidth", "width out of range");
2342 return error::kNoError;
2344 if (state_.line_width != width) {
2345 state_.line_width = width;
2346 glLineWidth(width);
2348 return error::kNoError;
2351 error::Error GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size,
2352 const void* cmd_data) {
2353 const gles2::cmds::LinkProgram& c =
2354 *static_cast<const gles2::cmds::LinkProgram*>(cmd_data);
2355 (void)c;
2356 GLuint program = c.program;
2357 DoLinkProgram(program);
2358 return error::kNoError;
2361 error::Error GLES2DecoderImpl::HandlePauseTransformFeedback(
2362 uint32_t immediate_data_size,
2363 const void* cmd_data) {
2364 if (!unsafe_es3_apis_enabled())
2365 return error::kUnknownCommand;
2366 const gles2::cmds::PauseTransformFeedback& c =
2367 *static_cast<const gles2::cmds::PauseTransformFeedback*>(cmd_data);
2368 (void)c;
2369 glPauseTransformFeedback();
2370 return error::kNoError;
2373 error::Error GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size,
2374 const void* cmd_data) {
2375 const gles2::cmds::PolygonOffset& c =
2376 *static_cast<const gles2::cmds::PolygonOffset*>(cmd_data);
2377 (void)c;
2378 GLfloat factor = static_cast<GLfloat>(c.factor);
2379 GLfloat units = static_cast<GLfloat>(c.units);
2380 if (state_.polygon_offset_factor != factor ||
2381 state_.polygon_offset_units != units) {
2382 state_.polygon_offset_factor = factor;
2383 state_.polygon_offset_units = units;
2384 glPolygonOffset(factor, units);
2386 return error::kNoError;
2389 error::Error GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size,
2390 const void* cmd_data) {
2391 if (!unsafe_es3_apis_enabled())
2392 return error::kUnknownCommand;
2393 const gles2::cmds::ReadBuffer& c =
2394 *static_cast<const gles2::cmds::ReadBuffer*>(cmd_data);
2395 (void)c;
2396 GLenum src = static_cast<GLenum>(c.src);
2397 glReadBuffer(src);
2398 return error::kNoError;
2401 error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler(
2402 uint32_t immediate_data_size,
2403 const void* cmd_data) {
2404 const gles2::cmds::ReleaseShaderCompiler& c =
2405 *static_cast<const gles2::cmds::ReleaseShaderCompiler*>(cmd_data);
2406 (void)c;
2407 DoReleaseShaderCompiler();
2408 return error::kNoError;
2411 error::Error GLES2DecoderImpl::HandleRenderbufferStorage(
2412 uint32_t immediate_data_size,
2413 const void* cmd_data) {
2414 const gles2::cmds::RenderbufferStorage& c =
2415 *static_cast<const gles2::cmds::RenderbufferStorage*>(cmd_data);
2416 (void)c;
2417 GLenum target = static_cast<GLenum>(c.target);
2418 GLenum internalformat = static_cast<GLenum>(c.internalformat);
2419 GLsizei width = static_cast<GLsizei>(c.width);
2420 GLsizei height = static_cast<GLsizei>(c.height);
2421 if (!validators_->render_buffer_target.IsValid(target)) {
2422 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target, "target");
2423 return error::kNoError;
2425 if (!validators_->render_buffer_format.IsValid(internalformat)) {
2426 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat,
2427 "internalformat");
2428 return error::kNoError;
2430 if (width < 0) {
2431 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
2432 return error::kNoError;
2434 if (height < 0) {
2435 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
2436 return error::kNoError;
2438 DoRenderbufferStorage(target, internalformat, width, height);
2439 return error::kNoError;
2442 error::Error GLES2DecoderImpl::HandleResumeTransformFeedback(
2443 uint32_t immediate_data_size,
2444 const void* cmd_data) {
2445 if (!unsafe_es3_apis_enabled())
2446 return error::kUnknownCommand;
2447 const gles2::cmds::ResumeTransformFeedback& c =
2448 *static_cast<const gles2::cmds::ResumeTransformFeedback*>(cmd_data);
2449 (void)c;
2450 glResumeTransformFeedback();
2451 return error::kNoError;
2454 error::Error GLES2DecoderImpl::HandleSampleCoverage(
2455 uint32_t immediate_data_size,
2456 const void* cmd_data) {
2457 const gles2::cmds::SampleCoverage& c =
2458 *static_cast<const gles2::cmds::SampleCoverage*>(cmd_data);
2459 (void)c;
2460 GLclampf value = static_cast<GLclampf>(c.value);
2461 GLboolean invert = static_cast<GLboolean>(c.invert);
2462 DoSampleCoverage(value, invert);
2463 return error::kNoError;
2466 error::Error GLES2DecoderImpl::HandleSamplerParameterf(
2467 uint32_t immediate_data_size,
2468 const void* cmd_data) {
2469 if (!unsafe_es3_apis_enabled())
2470 return error::kUnknownCommand;
2471 const gles2::cmds::SamplerParameterf& c =
2472 *static_cast<const gles2::cmds::SamplerParameterf*>(cmd_data);
2473 (void)c;
2474 GLuint sampler = c.sampler;
2475 GLenum pname = static_cast<GLenum>(c.pname);
2476 GLfloat param = static_cast<GLfloat>(c.param);
2477 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2478 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameterf",
2479 "invalid sampler id");
2480 return error::kNoError;
2482 glSamplerParameterf(sampler, pname, param);
2483 return error::kNoError;
2486 error::Error GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2487 uint32_t immediate_data_size,
2488 const void* cmd_data) {
2489 if (!unsafe_es3_apis_enabled())
2490 return error::kUnknownCommand;
2491 const gles2::cmds::SamplerParameterfvImmediate& c =
2492 *static_cast<const gles2::cmds::SamplerParameterfvImmediate*>(cmd_data);
2493 (void)c;
2494 GLuint sampler = c.sampler;
2495 GLenum pname = static_cast<GLenum>(c.pname);
2496 uint32_t data_size;
2497 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2498 return error::kOutOfBounds;
2500 if (data_size > immediate_data_size) {
2501 return error::kOutOfBounds;
2503 const GLfloat* params =
2504 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2505 if (params == NULL) {
2506 return error::kOutOfBounds;
2508 group_->GetSamplerServiceId(sampler, &sampler);
2509 DoSamplerParameterfv(sampler, pname, params);
2510 return error::kNoError;
2513 error::Error GLES2DecoderImpl::HandleSamplerParameteri(
2514 uint32_t immediate_data_size,
2515 const void* cmd_data) {
2516 if (!unsafe_es3_apis_enabled())
2517 return error::kUnknownCommand;
2518 const gles2::cmds::SamplerParameteri& c =
2519 *static_cast<const gles2::cmds::SamplerParameteri*>(cmd_data);
2520 (void)c;
2521 GLuint sampler = c.sampler;
2522 GLenum pname = static_cast<GLenum>(c.pname);
2523 GLint param = static_cast<GLint>(c.param);
2524 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2525 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameteri",
2526 "invalid sampler id");
2527 return error::kNoError;
2529 glSamplerParameteri(sampler, pname, param);
2530 return error::kNoError;
2533 error::Error GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2534 uint32_t immediate_data_size,
2535 const void* cmd_data) {
2536 if (!unsafe_es3_apis_enabled())
2537 return error::kUnknownCommand;
2538 const gles2::cmds::SamplerParameterivImmediate& c =
2539 *static_cast<const gles2::cmds::SamplerParameterivImmediate*>(cmd_data);
2540 (void)c;
2541 GLuint sampler = c.sampler;
2542 GLenum pname = static_cast<GLenum>(c.pname);
2543 uint32_t data_size;
2544 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2545 return error::kOutOfBounds;
2547 if (data_size > immediate_data_size) {
2548 return error::kOutOfBounds;
2550 const GLint* params =
2551 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2552 if (params == NULL) {
2553 return error::kOutOfBounds;
2555 DoSamplerParameteriv(sampler, pname, params);
2556 return error::kNoError;
2559 error::Error GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size,
2560 const void* cmd_data) {
2561 const gles2::cmds::Scissor& c =
2562 *static_cast<const gles2::cmds::Scissor*>(cmd_data);
2563 (void)c;
2564 GLint x = static_cast<GLint>(c.x);
2565 GLint y = static_cast<GLint>(c.y);
2566 GLsizei width = static_cast<GLsizei>(c.width);
2567 GLsizei height = static_cast<GLsizei>(c.height);
2568 if (width < 0) {
2569 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "width < 0");
2570 return error::kNoError;
2572 if (height < 0) {
2573 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "height < 0");
2574 return error::kNoError;
2576 if (state_.scissor_x != x || state_.scissor_y != y ||
2577 state_.scissor_width != width || state_.scissor_height != height) {
2578 state_.scissor_x = x;
2579 state_.scissor_y = y;
2580 state_.scissor_width = width;
2581 state_.scissor_height = height;
2582 glScissor(x, y, width, height);
2584 return error::kNoError;
2587 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2588 uint32_t immediate_data_size,
2589 const void* cmd_data) {
2590 const gles2::cmds::ShaderSourceBucket& c =
2591 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data);
2592 (void)c;
2593 GLuint shader = static_cast<GLuint>(c.shader);
2595 Bucket* bucket = GetBucket(c.str_bucket_id);
2596 if (!bucket) {
2597 return error::kInvalidArguments;
2599 GLsizei count = 0;
2600 std::vector<char*> strs;
2601 std::vector<GLint> len;
2602 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2603 return error::kInvalidArguments;
2605 const char** str =
2606 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2607 const GLint* length =
2608 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2609 (void)length;
2610 DoShaderSource(shader, count, str, length);
2611 return error::kNoError;
2614 error::Error GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size,
2615 const void* cmd_data) {
2616 const gles2::cmds::StencilFunc& c =
2617 *static_cast<const gles2::cmds::StencilFunc*>(cmd_data);
2618 (void)c;
2619 GLenum func = static_cast<GLenum>(c.func);
2620 GLint ref = static_cast<GLint>(c.ref);
2621 GLuint mask = static_cast<GLuint>(c.mask);
2622 if (!validators_->cmp_function.IsValid(func)) {
2623 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func, "func");
2624 return error::kNoError;
2626 if (state_.stencil_front_func != func || state_.stencil_front_ref != ref ||
2627 state_.stencil_front_mask != mask || state_.stencil_back_func != func ||
2628 state_.stencil_back_ref != ref || state_.stencil_back_mask != mask) {
2629 state_.stencil_front_func = func;
2630 state_.stencil_front_ref = ref;
2631 state_.stencil_front_mask = mask;
2632 state_.stencil_back_func = func;
2633 state_.stencil_back_ref = ref;
2634 state_.stencil_back_mask = mask;
2635 glStencilFunc(func, ref, mask);
2637 return error::kNoError;
2640 error::Error GLES2DecoderImpl::HandleStencilFuncSeparate(
2641 uint32_t immediate_data_size,
2642 const void* cmd_data) {
2643 const gles2::cmds::StencilFuncSeparate& c =
2644 *static_cast<const gles2::cmds::StencilFuncSeparate*>(cmd_data);
2645 (void)c;
2646 GLenum face = static_cast<GLenum>(c.face);
2647 GLenum func = static_cast<GLenum>(c.func);
2648 GLint ref = static_cast<GLint>(c.ref);
2649 GLuint mask = static_cast<GLuint>(c.mask);
2650 if (!validators_->face_type.IsValid(face)) {
2651 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face, "face");
2652 return error::kNoError;
2654 if (!validators_->cmp_function.IsValid(func)) {
2655 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func, "func");
2656 return error::kNoError;
2658 bool changed = false;
2659 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2660 changed |= state_.stencil_front_func != func ||
2661 state_.stencil_front_ref != ref ||
2662 state_.stencil_front_mask != mask;
2664 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2665 changed |= state_.stencil_back_func != func ||
2666 state_.stencil_back_ref != ref ||
2667 state_.stencil_back_mask != mask;
2669 if (changed) {
2670 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2671 state_.stencil_front_func = func;
2672 state_.stencil_front_ref = ref;
2673 state_.stencil_front_mask = mask;
2675 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2676 state_.stencil_back_func = func;
2677 state_.stencil_back_ref = ref;
2678 state_.stencil_back_mask = mask;
2680 glStencilFuncSeparate(face, func, ref, mask);
2682 return error::kNoError;
2685 error::Error GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size,
2686 const void* cmd_data) {
2687 const gles2::cmds::StencilMask& c =
2688 *static_cast<const gles2::cmds::StencilMask*>(cmd_data);
2689 (void)c;
2690 GLuint mask = static_cast<GLuint>(c.mask);
2691 if (state_.stencil_front_writemask != mask ||
2692 state_.stencil_back_writemask != mask) {
2693 state_.stencil_front_writemask = mask;
2694 state_.stencil_back_writemask = mask;
2695 framebuffer_state_.clear_state_dirty = true;
2697 return error::kNoError;
2700 error::Error GLES2DecoderImpl::HandleStencilMaskSeparate(
2701 uint32_t immediate_data_size,
2702 const void* cmd_data) {
2703 const gles2::cmds::StencilMaskSeparate& c =
2704 *static_cast<const gles2::cmds::StencilMaskSeparate*>(cmd_data);
2705 (void)c;
2706 GLenum face = static_cast<GLenum>(c.face);
2707 GLuint mask = static_cast<GLuint>(c.mask);
2708 if (!validators_->face_type.IsValid(face)) {
2709 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face, "face");
2710 return error::kNoError;
2712 bool changed = false;
2713 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2714 changed |= state_.stencil_front_writemask != mask;
2716 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2717 changed |= state_.stencil_back_writemask != mask;
2719 if (changed) {
2720 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2721 state_.stencil_front_writemask = mask;
2723 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2724 state_.stencil_back_writemask = mask;
2726 framebuffer_state_.clear_state_dirty = true;
2728 return error::kNoError;
2731 error::Error GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size,
2732 const void* cmd_data) {
2733 const gles2::cmds::StencilOp& c =
2734 *static_cast<const gles2::cmds::StencilOp*>(cmd_data);
2735 (void)c;
2736 GLenum fail = static_cast<GLenum>(c.fail);
2737 GLenum zfail = static_cast<GLenum>(c.zfail);
2738 GLenum zpass = static_cast<GLenum>(c.zpass);
2739 if (!validators_->stencil_op.IsValid(fail)) {
2740 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail, "fail");
2741 return error::kNoError;
2743 if (!validators_->stencil_op.IsValid(zfail)) {
2744 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail, "zfail");
2745 return error::kNoError;
2747 if (!validators_->stencil_op.IsValid(zpass)) {
2748 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass, "zpass");
2749 return error::kNoError;
2751 if (state_.stencil_front_fail_op != fail ||
2752 state_.stencil_front_z_fail_op != zfail ||
2753 state_.stencil_front_z_pass_op != zpass ||
2754 state_.stencil_back_fail_op != fail ||
2755 state_.stencil_back_z_fail_op != zfail ||
2756 state_.stencil_back_z_pass_op != zpass) {
2757 state_.stencil_front_fail_op = fail;
2758 state_.stencil_front_z_fail_op = zfail;
2759 state_.stencil_front_z_pass_op = zpass;
2760 state_.stencil_back_fail_op = fail;
2761 state_.stencil_back_z_fail_op = zfail;
2762 state_.stencil_back_z_pass_op = zpass;
2763 glStencilOp(fail, zfail, zpass);
2765 return error::kNoError;
2768 error::Error GLES2DecoderImpl::HandleStencilOpSeparate(
2769 uint32_t immediate_data_size,
2770 const void* cmd_data) {
2771 const gles2::cmds::StencilOpSeparate& c =
2772 *static_cast<const gles2::cmds::StencilOpSeparate*>(cmd_data);
2773 (void)c;
2774 GLenum face = static_cast<GLenum>(c.face);
2775 GLenum fail = static_cast<GLenum>(c.fail);
2776 GLenum zfail = static_cast<GLenum>(c.zfail);
2777 GLenum zpass = static_cast<GLenum>(c.zpass);
2778 if (!validators_->face_type.IsValid(face)) {
2779 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face, "face");
2780 return error::kNoError;
2782 if (!validators_->stencil_op.IsValid(fail)) {
2783 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail, "fail");
2784 return error::kNoError;
2786 if (!validators_->stencil_op.IsValid(zfail)) {
2787 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail, "zfail");
2788 return error::kNoError;
2790 if (!validators_->stencil_op.IsValid(zpass)) {
2791 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass, "zpass");
2792 return error::kNoError;
2794 bool changed = false;
2795 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2796 changed |= state_.stencil_front_fail_op != fail ||
2797 state_.stencil_front_z_fail_op != zfail ||
2798 state_.stencil_front_z_pass_op != zpass;
2800 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2801 changed |= state_.stencil_back_fail_op != fail ||
2802 state_.stencil_back_z_fail_op != zfail ||
2803 state_.stencil_back_z_pass_op != zpass;
2805 if (changed) {
2806 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2807 state_.stencil_front_fail_op = fail;
2808 state_.stencil_front_z_fail_op = zfail;
2809 state_.stencil_front_z_pass_op = zpass;
2811 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2812 state_.stencil_back_fail_op = fail;
2813 state_.stencil_back_z_fail_op = zfail;
2814 state_.stencil_back_z_pass_op = zpass;
2816 glStencilOpSeparate(face, fail, zfail, zpass);
2818 return error::kNoError;
2821 error::Error GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size,
2822 const void* cmd_data) {
2823 const gles2::cmds::TexParameterf& c =
2824 *static_cast<const gles2::cmds::TexParameterf*>(cmd_data);
2825 (void)c;
2826 GLenum target = static_cast<GLenum>(c.target);
2827 GLenum pname = static_cast<GLenum>(c.pname);
2828 GLfloat param = static_cast<GLfloat>(c.param);
2829 if (!validators_->texture_bind_target.IsValid(target)) {
2830 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target, "target");
2831 return error::kNoError;
2833 if (!validators_->texture_parameter.IsValid(pname)) {
2834 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname, "pname");
2835 return error::kNoError;
2837 DoTexParameterf(target, pname, param);
2838 return error::kNoError;
2841 error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
2842 uint32_t immediate_data_size,
2843 const void* cmd_data) {
2844 const gles2::cmds::TexParameterfvImmediate& c =
2845 *static_cast<const gles2::cmds::TexParameterfvImmediate*>(cmd_data);
2846 (void)c;
2847 GLenum target = static_cast<GLenum>(c.target);
2848 GLenum pname = static_cast<GLenum>(c.pname);
2849 uint32_t data_size;
2850 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2851 return error::kOutOfBounds;
2853 if (data_size > immediate_data_size) {
2854 return error::kOutOfBounds;
2856 const GLfloat* params =
2857 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2858 if (!validators_->texture_bind_target.IsValid(target)) {
2859 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target, "target");
2860 return error::kNoError;
2862 if (!validators_->texture_parameter.IsValid(pname)) {
2863 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname, "pname");
2864 return error::kNoError;
2866 if (params == NULL) {
2867 return error::kOutOfBounds;
2869 DoTexParameterfv(target, pname, params);
2870 return error::kNoError;
2873 error::Error GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size,
2874 const void* cmd_data) {
2875 const gles2::cmds::TexParameteri& c =
2876 *static_cast<const gles2::cmds::TexParameteri*>(cmd_data);
2877 (void)c;
2878 GLenum target = static_cast<GLenum>(c.target);
2879 GLenum pname = static_cast<GLenum>(c.pname);
2880 GLint param = static_cast<GLint>(c.param);
2881 if (!validators_->texture_bind_target.IsValid(target)) {
2882 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target, "target");
2883 return error::kNoError;
2885 if (!validators_->texture_parameter.IsValid(pname)) {
2886 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname, "pname");
2887 return error::kNoError;
2889 DoTexParameteri(target, pname, param);
2890 return error::kNoError;
2893 error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
2894 uint32_t immediate_data_size,
2895 const void* cmd_data) {
2896 const gles2::cmds::TexParameterivImmediate& c =
2897 *static_cast<const gles2::cmds::TexParameterivImmediate*>(cmd_data);
2898 (void)c;
2899 GLenum target = static_cast<GLenum>(c.target);
2900 GLenum pname = static_cast<GLenum>(c.pname);
2901 uint32_t data_size;
2902 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2903 return error::kOutOfBounds;
2905 if (data_size > immediate_data_size) {
2906 return error::kOutOfBounds;
2908 const GLint* params =
2909 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2910 if (!validators_->texture_bind_target.IsValid(target)) {
2911 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target, "target");
2912 return error::kNoError;
2914 if (!validators_->texture_parameter.IsValid(pname)) {
2915 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname, "pname");
2916 return error::kNoError;
2918 if (params == NULL) {
2919 return error::kOutOfBounds;
2921 DoTexParameteriv(target, pname, params);
2922 return error::kNoError;
2925 error::Error GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size,
2926 const void* cmd_data) {
2927 if (!unsafe_es3_apis_enabled())
2928 return error::kUnknownCommand;
2929 const gles2::cmds::TexStorage3D& c =
2930 *static_cast<const gles2::cmds::TexStorage3D*>(cmd_data);
2931 (void)c;
2932 GLenum target = static_cast<GLenum>(c.target);
2933 GLsizei levels = static_cast<GLsizei>(c.levels);
2934 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
2935 GLsizei width = static_cast<GLsizei>(c.width);
2936 GLsizei height = static_cast<GLsizei>(c.height);
2937 GLsizei depth = static_cast<GLsizei>(c.depth);
2938 glTexStorage3D(target, levels, internalFormat, width, height, depth);
2939 return error::kNoError;
2942 error::Error GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
2943 uint32_t immediate_data_size,
2944 const void* cmd_data) {
2945 if (!unsafe_es3_apis_enabled())
2946 return error::kUnknownCommand;
2947 const gles2::cmds::TransformFeedbackVaryingsBucket& c =
2948 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket*>(
2949 cmd_data);
2950 (void)c;
2951 GLuint program = static_cast<GLuint>(c.program);
2953 Bucket* bucket = GetBucket(c.varyings_bucket_id);
2954 if (!bucket) {
2955 return error::kInvalidArguments;
2957 GLsizei count = 0;
2958 std::vector<char*> strs;
2959 std::vector<GLint> len;
2960 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2961 return error::kInvalidArguments;
2963 const char** varyings =
2964 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2965 const GLint* length =
2966 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2967 (void)length;
2968 GLenum buffermode = static_cast<GLenum>(c.buffermode);
2969 DoTransformFeedbackVaryings(program, count, varyings, buffermode);
2970 return error::kNoError;
2973 error::Error GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size,
2974 const void* cmd_data) {
2975 const gles2::cmds::Uniform1f& c =
2976 *static_cast<const gles2::cmds::Uniform1f*>(cmd_data);
2977 (void)c;
2978 GLint location = static_cast<GLint>(c.location);
2979 GLfloat x = static_cast<GLfloat>(c.x);
2980 GLfloat temp[1] = {
2983 DoUniform1fv(location, 1, &temp[0]);
2984 return error::kNoError;
2987 error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
2988 uint32_t immediate_data_size,
2989 const void* cmd_data) {
2990 const gles2::cmds::Uniform1fvImmediate& c =
2991 *static_cast<const gles2::cmds::Uniform1fvImmediate*>(cmd_data);
2992 (void)c;
2993 GLint location = static_cast<GLint>(c.location);
2994 GLsizei count = static_cast<GLsizei>(c.count);
2995 uint32_t data_size;
2996 if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
2997 return error::kOutOfBounds;
2999 if (data_size > immediate_data_size) {
3000 return error::kOutOfBounds;
3002 const GLfloat* v =
3003 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3004 if (v == NULL) {
3005 return error::kOutOfBounds;
3007 DoUniform1fv(location, count, v);
3008 return error::kNoError;
3011 error::Error GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size,
3012 const void* cmd_data) {
3013 const gles2::cmds::Uniform1i& c =
3014 *static_cast<const gles2::cmds::Uniform1i*>(cmd_data);
3015 (void)c;
3016 GLint location = static_cast<GLint>(c.location);
3017 GLint x = static_cast<GLint>(c.x);
3018 DoUniform1i(location, x);
3019 return error::kNoError;
3022 error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
3023 uint32_t immediate_data_size,
3024 const void* cmd_data) {
3025 const gles2::cmds::Uniform1ivImmediate& c =
3026 *static_cast<const gles2::cmds::Uniform1ivImmediate*>(cmd_data);
3027 (void)c;
3028 GLint location = static_cast<GLint>(c.location);
3029 GLsizei count = static_cast<GLsizei>(c.count);
3030 uint32_t data_size;
3031 if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
3032 return error::kOutOfBounds;
3034 if (data_size > immediate_data_size) {
3035 return error::kOutOfBounds;
3037 const GLint* v =
3038 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3039 if (v == NULL) {
3040 return error::kOutOfBounds;
3042 DoUniform1iv(location, count, v);
3043 return error::kNoError;
3046 error::Error GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size,
3047 const void* cmd_data) {
3048 if (!unsafe_es3_apis_enabled())
3049 return error::kUnknownCommand;
3050 const gles2::cmds::Uniform1ui& c =
3051 *static_cast<const gles2::cmds::Uniform1ui*>(cmd_data);
3052 (void)c;
3053 GLint location = static_cast<GLint>(c.location);
3054 GLuint x = static_cast<GLuint>(c.x);
3055 GLuint temp[1] = {
3058 glUniform1uiv(location, 1, &temp[0]);
3059 return error::kNoError;
3062 error::Error GLES2DecoderImpl::HandleUniform1uivImmediate(
3063 uint32_t immediate_data_size,
3064 const void* cmd_data) {
3065 if (!unsafe_es3_apis_enabled())
3066 return error::kUnknownCommand;
3067 const gles2::cmds::Uniform1uivImmediate& c =
3068 *static_cast<const gles2::cmds::Uniform1uivImmediate*>(cmd_data);
3069 (void)c;
3070 GLint location = static_cast<GLint>(c.location);
3071 GLsizei count = static_cast<GLsizei>(c.count);
3072 uint32_t data_size;
3073 if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) {
3074 return error::kOutOfBounds;
3076 if (data_size > immediate_data_size) {
3077 return error::kOutOfBounds;
3079 const GLuint* v =
3080 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3081 if (v == NULL) {
3082 return error::kOutOfBounds;
3084 glUniform1uiv(location, count, v);
3085 return error::kNoError;
3088 error::Error GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size,
3089 const void* cmd_data) {
3090 const gles2::cmds::Uniform2f& c =
3091 *static_cast<const gles2::cmds::Uniform2f*>(cmd_data);
3092 (void)c;
3093 GLint location = static_cast<GLint>(c.location);
3094 GLfloat x = static_cast<GLfloat>(c.x);
3095 GLfloat y = static_cast<GLfloat>(c.y);
3096 GLfloat temp[2] = {
3097 x, y,
3099 DoUniform2fv(location, 1, &temp[0]);
3100 return error::kNoError;
3103 error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
3104 uint32_t immediate_data_size,
3105 const void* cmd_data) {
3106 const gles2::cmds::Uniform2fvImmediate& c =
3107 *static_cast<const gles2::cmds::Uniform2fvImmediate*>(cmd_data);
3108 (void)c;
3109 GLint location = static_cast<GLint>(c.location);
3110 GLsizei count = static_cast<GLsizei>(c.count);
3111 uint32_t data_size;
3112 if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
3113 return error::kOutOfBounds;
3115 if (data_size > immediate_data_size) {
3116 return error::kOutOfBounds;
3118 const GLfloat* v =
3119 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3120 if (v == NULL) {
3121 return error::kOutOfBounds;
3123 DoUniform2fv(location, count, v);
3124 return error::kNoError;
3127 error::Error GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size,
3128 const void* cmd_data) {
3129 const gles2::cmds::Uniform2i& c =
3130 *static_cast<const gles2::cmds::Uniform2i*>(cmd_data);
3131 (void)c;
3132 GLint location = static_cast<GLint>(c.location);
3133 GLint x = static_cast<GLint>(c.x);
3134 GLint y = static_cast<GLint>(c.y);
3135 GLint temp[2] = {
3136 x, y,
3138 DoUniform2iv(location, 1, &temp[0]);
3139 return error::kNoError;
3142 error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
3143 uint32_t immediate_data_size,
3144 const void* cmd_data) {
3145 const gles2::cmds::Uniform2ivImmediate& c =
3146 *static_cast<const gles2::cmds::Uniform2ivImmediate*>(cmd_data);
3147 (void)c;
3148 GLint location = static_cast<GLint>(c.location);
3149 GLsizei count = static_cast<GLsizei>(c.count);
3150 uint32_t data_size;
3151 if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
3152 return error::kOutOfBounds;
3154 if (data_size > immediate_data_size) {
3155 return error::kOutOfBounds;
3157 const GLint* v =
3158 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3159 if (v == NULL) {
3160 return error::kOutOfBounds;
3162 DoUniform2iv(location, count, v);
3163 return error::kNoError;
3166 error::Error GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size,
3167 const void* cmd_data) {
3168 if (!unsafe_es3_apis_enabled())
3169 return error::kUnknownCommand;
3170 const gles2::cmds::Uniform2ui& c =
3171 *static_cast<const gles2::cmds::Uniform2ui*>(cmd_data);
3172 (void)c;
3173 GLint location = static_cast<GLint>(c.location);
3174 GLuint x = static_cast<GLuint>(c.x);
3175 GLuint y = static_cast<GLuint>(c.y);
3176 GLuint temp[2] = {
3177 x, y,
3179 glUniform2uiv(location, 1, &temp[0]);
3180 return error::kNoError;
3183 error::Error GLES2DecoderImpl::HandleUniform2uivImmediate(
3184 uint32_t immediate_data_size,
3185 const void* cmd_data) {
3186 if (!unsafe_es3_apis_enabled())
3187 return error::kUnknownCommand;
3188 const gles2::cmds::Uniform2uivImmediate& c =
3189 *static_cast<const gles2::cmds::Uniform2uivImmediate*>(cmd_data);
3190 (void)c;
3191 GLint location = static_cast<GLint>(c.location);
3192 GLsizei count = static_cast<GLsizei>(c.count);
3193 uint32_t data_size;
3194 if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) {
3195 return error::kOutOfBounds;
3197 if (data_size > immediate_data_size) {
3198 return error::kOutOfBounds;
3200 const GLuint* v =
3201 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3202 if (v == NULL) {
3203 return error::kOutOfBounds;
3205 glUniform2uiv(location, count, v);
3206 return error::kNoError;
3209 error::Error GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size,
3210 const void* cmd_data) {
3211 const gles2::cmds::Uniform3f& c =
3212 *static_cast<const gles2::cmds::Uniform3f*>(cmd_data);
3213 (void)c;
3214 GLint location = static_cast<GLint>(c.location);
3215 GLfloat x = static_cast<GLfloat>(c.x);
3216 GLfloat y = static_cast<GLfloat>(c.y);
3217 GLfloat z = static_cast<GLfloat>(c.z);
3218 GLfloat temp[3] = {
3219 x, y, z,
3221 DoUniform3fv(location, 1, &temp[0]);
3222 return error::kNoError;
3225 error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
3226 uint32_t immediate_data_size,
3227 const void* cmd_data) {
3228 const gles2::cmds::Uniform3fvImmediate& c =
3229 *static_cast<const gles2::cmds::Uniform3fvImmediate*>(cmd_data);
3230 (void)c;
3231 GLint location = static_cast<GLint>(c.location);
3232 GLsizei count = static_cast<GLsizei>(c.count);
3233 uint32_t data_size;
3234 if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
3235 return error::kOutOfBounds;
3237 if (data_size > immediate_data_size) {
3238 return error::kOutOfBounds;
3240 const GLfloat* v =
3241 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3242 if (v == NULL) {
3243 return error::kOutOfBounds;
3245 DoUniform3fv(location, count, v);
3246 return error::kNoError;
3249 error::Error GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size,
3250 const void* cmd_data) {
3251 const gles2::cmds::Uniform3i& c =
3252 *static_cast<const gles2::cmds::Uniform3i*>(cmd_data);
3253 (void)c;
3254 GLint location = static_cast<GLint>(c.location);
3255 GLint x = static_cast<GLint>(c.x);
3256 GLint y = static_cast<GLint>(c.y);
3257 GLint z = static_cast<GLint>(c.z);
3258 GLint temp[3] = {
3259 x, y, z,
3261 DoUniform3iv(location, 1, &temp[0]);
3262 return error::kNoError;
3265 error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
3266 uint32_t immediate_data_size,
3267 const void* cmd_data) {
3268 const gles2::cmds::Uniform3ivImmediate& c =
3269 *static_cast<const gles2::cmds::Uniform3ivImmediate*>(cmd_data);
3270 (void)c;
3271 GLint location = static_cast<GLint>(c.location);
3272 GLsizei count = static_cast<GLsizei>(c.count);
3273 uint32_t data_size;
3274 if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
3275 return error::kOutOfBounds;
3277 if (data_size > immediate_data_size) {
3278 return error::kOutOfBounds;
3280 const GLint* v =
3281 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3282 if (v == NULL) {
3283 return error::kOutOfBounds;
3285 DoUniform3iv(location, count, v);
3286 return error::kNoError;
3289 error::Error GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size,
3290 const void* cmd_data) {
3291 if (!unsafe_es3_apis_enabled())
3292 return error::kUnknownCommand;
3293 const gles2::cmds::Uniform3ui& c =
3294 *static_cast<const gles2::cmds::Uniform3ui*>(cmd_data);
3295 (void)c;
3296 GLint location = static_cast<GLint>(c.location);
3297 GLuint x = static_cast<GLuint>(c.x);
3298 GLuint y = static_cast<GLuint>(c.y);
3299 GLuint z = static_cast<GLuint>(c.z);
3300 GLuint temp[3] = {
3301 x, y, z,
3303 glUniform3uiv(location, 1, &temp[0]);
3304 return error::kNoError;
3307 error::Error GLES2DecoderImpl::HandleUniform3uivImmediate(
3308 uint32_t immediate_data_size,
3309 const void* cmd_data) {
3310 if (!unsafe_es3_apis_enabled())
3311 return error::kUnknownCommand;
3312 const gles2::cmds::Uniform3uivImmediate& c =
3313 *static_cast<const gles2::cmds::Uniform3uivImmediate*>(cmd_data);
3314 (void)c;
3315 GLint location = static_cast<GLint>(c.location);
3316 GLsizei count = static_cast<GLsizei>(c.count);
3317 uint32_t data_size;
3318 if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) {
3319 return error::kOutOfBounds;
3321 if (data_size > immediate_data_size) {
3322 return error::kOutOfBounds;
3324 const GLuint* v =
3325 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3326 if (v == NULL) {
3327 return error::kOutOfBounds;
3329 glUniform3uiv(location, count, v);
3330 return error::kNoError;
3333 error::Error GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size,
3334 const void* cmd_data) {
3335 const gles2::cmds::Uniform4f& c =
3336 *static_cast<const gles2::cmds::Uniform4f*>(cmd_data);
3337 (void)c;
3338 GLint location = static_cast<GLint>(c.location);
3339 GLfloat x = static_cast<GLfloat>(c.x);
3340 GLfloat y = static_cast<GLfloat>(c.y);
3341 GLfloat z = static_cast<GLfloat>(c.z);
3342 GLfloat w = static_cast<GLfloat>(c.w);
3343 GLfloat temp[4] = {
3344 x, y, z, w,
3346 DoUniform4fv(location, 1, &temp[0]);
3347 return error::kNoError;
3350 error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
3351 uint32_t immediate_data_size,
3352 const void* cmd_data) {
3353 const gles2::cmds::Uniform4fvImmediate& c =
3354 *static_cast<const gles2::cmds::Uniform4fvImmediate*>(cmd_data);
3355 (void)c;
3356 GLint location = static_cast<GLint>(c.location);
3357 GLsizei count = static_cast<GLsizei>(c.count);
3358 uint32_t data_size;
3359 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3360 return error::kOutOfBounds;
3362 if (data_size > immediate_data_size) {
3363 return error::kOutOfBounds;
3365 const GLfloat* v =
3366 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3367 if (v == NULL) {
3368 return error::kOutOfBounds;
3370 DoUniform4fv(location, count, v);
3371 return error::kNoError;
3374 error::Error GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size,
3375 const void* cmd_data) {
3376 const gles2::cmds::Uniform4i& c =
3377 *static_cast<const gles2::cmds::Uniform4i*>(cmd_data);
3378 (void)c;
3379 GLint location = static_cast<GLint>(c.location);
3380 GLint x = static_cast<GLint>(c.x);
3381 GLint y = static_cast<GLint>(c.y);
3382 GLint z = static_cast<GLint>(c.z);
3383 GLint w = static_cast<GLint>(c.w);
3384 GLint temp[4] = {
3385 x, y, z, w,
3387 DoUniform4iv(location, 1, &temp[0]);
3388 return error::kNoError;
3391 error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
3392 uint32_t immediate_data_size,
3393 const void* cmd_data) {
3394 const gles2::cmds::Uniform4ivImmediate& c =
3395 *static_cast<const gles2::cmds::Uniform4ivImmediate*>(cmd_data);
3396 (void)c;
3397 GLint location = static_cast<GLint>(c.location);
3398 GLsizei count = static_cast<GLsizei>(c.count);
3399 uint32_t data_size;
3400 if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
3401 return error::kOutOfBounds;
3403 if (data_size > immediate_data_size) {
3404 return error::kOutOfBounds;
3406 const GLint* v =
3407 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3408 if (v == NULL) {
3409 return error::kOutOfBounds;
3411 DoUniform4iv(location, count, v);
3412 return error::kNoError;
3415 error::Error GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size,
3416 const void* cmd_data) {
3417 if (!unsafe_es3_apis_enabled())
3418 return error::kUnknownCommand;
3419 const gles2::cmds::Uniform4ui& c =
3420 *static_cast<const gles2::cmds::Uniform4ui*>(cmd_data);
3421 (void)c;
3422 GLint location = static_cast<GLint>(c.location);
3423 GLuint x = static_cast<GLuint>(c.x);
3424 GLuint y = static_cast<GLuint>(c.y);
3425 GLuint z = static_cast<GLuint>(c.z);
3426 GLuint w = static_cast<GLuint>(c.w);
3427 GLuint temp[4] = {
3428 x, y, z, w,
3430 glUniform4uiv(location, 1, &temp[0]);
3431 return error::kNoError;
3434 error::Error GLES2DecoderImpl::HandleUniform4uivImmediate(
3435 uint32_t immediate_data_size,
3436 const void* cmd_data) {
3437 if (!unsafe_es3_apis_enabled())
3438 return error::kUnknownCommand;
3439 const gles2::cmds::Uniform4uivImmediate& c =
3440 *static_cast<const gles2::cmds::Uniform4uivImmediate*>(cmd_data);
3441 (void)c;
3442 GLint location = static_cast<GLint>(c.location);
3443 GLsizei count = static_cast<GLsizei>(c.count);
3444 uint32_t data_size;
3445 if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) {
3446 return error::kOutOfBounds;
3448 if (data_size > immediate_data_size) {
3449 return error::kOutOfBounds;
3451 const GLuint* v =
3452 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3453 if (v == NULL) {
3454 return error::kOutOfBounds;
3456 glUniform4uiv(location, count, v);
3457 return error::kNoError;
3460 error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3461 uint32_t immediate_data_size,
3462 const void* cmd_data) {
3463 const gles2::cmds::UniformMatrix2fvImmediate& c =
3464 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate*>(cmd_data);
3465 (void)c;
3466 GLint location = static_cast<GLint>(c.location);
3467 GLsizei count = static_cast<GLsizei>(c.count);
3468 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3469 uint32_t data_size;
3470 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3471 return error::kOutOfBounds;
3473 if (data_size > immediate_data_size) {
3474 return error::kOutOfBounds;
3476 const GLfloat* value =
3477 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3478 if (value == NULL) {
3479 return error::kOutOfBounds;
3481 DoUniformMatrix2fv(location, count, transpose, value);
3482 return error::kNoError;
3485 error::Error GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3486 uint32_t immediate_data_size,
3487 const void* cmd_data) {
3488 if (!unsafe_es3_apis_enabled())
3489 return error::kUnknownCommand;
3490 const gles2::cmds::UniformMatrix2x3fvImmediate& c =
3491 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate*>(cmd_data);
3492 (void)c;
3493 GLint location = static_cast<GLint>(c.location);
3494 GLsizei count = static_cast<GLsizei>(c.count);
3495 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3496 uint32_t data_size;
3497 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3498 return error::kOutOfBounds;
3500 if (data_size > immediate_data_size) {
3501 return error::kOutOfBounds;
3503 const GLfloat* value =
3504 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3505 if (value == NULL) {
3506 return error::kOutOfBounds;
3508 glUniformMatrix2x3fv(location, count, transpose, value);
3509 return error::kNoError;
3512 error::Error GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3513 uint32_t immediate_data_size,
3514 const void* cmd_data) {
3515 if (!unsafe_es3_apis_enabled())
3516 return error::kUnknownCommand;
3517 const gles2::cmds::UniformMatrix2x4fvImmediate& c =
3518 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate*>(cmd_data);
3519 (void)c;
3520 GLint location = static_cast<GLint>(c.location);
3521 GLsizei count = static_cast<GLsizei>(c.count);
3522 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3523 uint32_t data_size;
3524 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3525 return error::kOutOfBounds;
3527 if (data_size > immediate_data_size) {
3528 return error::kOutOfBounds;
3530 const GLfloat* value =
3531 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3532 if (value == NULL) {
3533 return error::kOutOfBounds;
3535 glUniformMatrix2x4fv(location, count, transpose, value);
3536 return error::kNoError;
3539 error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3540 uint32_t immediate_data_size,
3541 const void* cmd_data) {
3542 const gles2::cmds::UniformMatrix3fvImmediate& c =
3543 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate*>(cmd_data);
3544 (void)c;
3545 GLint location = static_cast<GLint>(c.location);
3546 GLsizei count = static_cast<GLsizei>(c.count);
3547 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3548 uint32_t data_size;
3549 if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
3550 return error::kOutOfBounds;
3552 if (data_size > immediate_data_size) {
3553 return error::kOutOfBounds;
3555 const GLfloat* value =
3556 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3557 if (value == NULL) {
3558 return error::kOutOfBounds;
3560 DoUniformMatrix3fv(location, count, transpose, value);
3561 return error::kNoError;
3564 error::Error GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3565 uint32_t immediate_data_size,
3566 const void* cmd_data) {
3567 if (!unsafe_es3_apis_enabled())
3568 return error::kUnknownCommand;
3569 const gles2::cmds::UniformMatrix3x2fvImmediate& c =
3570 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate*>(cmd_data);
3571 (void)c;
3572 GLint location = static_cast<GLint>(c.location);
3573 GLsizei count = static_cast<GLsizei>(c.count);
3574 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3575 uint32_t data_size;
3576 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3577 return error::kOutOfBounds;
3579 if (data_size > immediate_data_size) {
3580 return error::kOutOfBounds;
3582 const GLfloat* value =
3583 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3584 if (value == NULL) {
3585 return error::kOutOfBounds;
3587 glUniformMatrix3x2fv(location, count, transpose, value);
3588 return error::kNoError;
3591 error::Error GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3592 uint32_t immediate_data_size,
3593 const void* cmd_data) {
3594 if (!unsafe_es3_apis_enabled())
3595 return error::kUnknownCommand;
3596 const gles2::cmds::UniformMatrix3x4fvImmediate& c =
3597 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate*>(cmd_data);
3598 (void)c;
3599 GLint location = static_cast<GLint>(c.location);
3600 GLsizei count = static_cast<GLsizei>(c.count);
3601 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3602 uint32_t data_size;
3603 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3604 return error::kOutOfBounds;
3606 if (data_size > immediate_data_size) {
3607 return error::kOutOfBounds;
3609 const GLfloat* value =
3610 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3611 if (value == NULL) {
3612 return error::kOutOfBounds;
3614 glUniformMatrix3x4fv(location, count, transpose, value);
3615 return error::kNoError;
3618 error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3619 uint32_t immediate_data_size,
3620 const void* cmd_data) {
3621 const gles2::cmds::UniformMatrix4fvImmediate& c =
3622 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate*>(cmd_data);
3623 (void)c;
3624 GLint location = static_cast<GLint>(c.location);
3625 GLsizei count = static_cast<GLsizei>(c.count);
3626 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3627 uint32_t data_size;
3628 if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
3629 return error::kOutOfBounds;
3631 if (data_size > immediate_data_size) {
3632 return error::kOutOfBounds;
3634 const GLfloat* value =
3635 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3636 if (value == NULL) {
3637 return error::kOutOfBounds;
3639 DoUniformMatrix4fv(location, count, transpose, value);
3640 return error::kNoError;
3643 error::Error GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3644 uint32_t immediate_data_size,
3645 const void* cmd_data) {
3646 if (!unsafe_es3_apis_enabled())
3647 return error::kUnknownCommand;
3648 const gles2::cmds::UniformMatrix4x2fvImmediate& c =
3649 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate*>(cmd_data);
3650 (void)c;
3651 GLint location = static_cast<GLint>(c.location);
3652 GLsizei count = static_cast<GLsizei>(c.count);
3653 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3654 uint32_t data_size;
3655 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3656 return error::kOutOfBounds;
3658 if (data_size > immediate_data_size) {
3659 return error::kOutOfBounds;
3661 const GLfloat* value =
3662 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3663 if (value == NULL) {
3664 return error::kOutOfBounds;
3666 glUniformMatrix4x2fv(location, count, transpose, value);
3667 return error::kNoError;
3670 error::Error GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3671 uint32_t immediate_data_size,
3672 const void* cmd_data) {
3673 if (!unsafe_es3_apis_enabled())
3674 return error::kUnknownCommand;
3675 const gles2::cmds::UniformMatrix4x3fvImmediate& c =
3676 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate*>(cmd_data);
3677 (void)c;
3678 GLint location = static_cast<GLint>(c.location);
3679 GLsizei count = static_cast<GLsizei>(c.count);
3680 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3681 uint32_t data_size;
3682 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3683 return error::kOutOfBounds;
3685 if (data_size > immediate_data_size) {
3686 return error::kOutOfBounds;
3688 const GLfloat* value =
3689 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3690 if (value == NULL) {
3691 return error::kOutOfBounds;
3693 glUniformMatrix4x3fv(location, count, transpose, value);
3694 return error::kNoError;
3697 error::Error GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size,
3698 const void* cmd_data) {
3699 const gles2::cmds::UseProgram& c =
3700 *static_cast<const gles2::cmds::UseProgram*>(cmd_data);
3701 (void)c;
3702 GLuint program = c.program;
3703 DoUseProgram(program);
3704 return error::kNoError;
3707 error::Error GLES2DecoderImpl::HandleValidateProgram(
3708 uint32_t immediate_data_size,
3709 const void* cmd_data) {
3710 const gles2::cmds::ValidateProgram& c =
3711 *static_cast<const gles2::cmds::ValidateProgram*>(cmd_data);
3712 (void)c;
3713 GLuint program = c.program;
3714 DoValidateProgram(program);
3715 return error::kNoError;
3718 error::Error GLES2DecoderImpl::HandleVertexAttrib1f(
3719 uint32_t immediate_data_size,
3720 const void* cmd_data) {
3721 const gles2::cmds::VertexAttrib1f& c =
3722 *static_cast<const gles2::cmds::VertexAttrib1f*>(cmd_data);
3723 (void)c;
3724 GLuint indx = static_cast<GLuint>(c.indx);
3725 GLfloat x = static_cast<GLfloat>(c.x);
3726 DoVertexAttrib1f(indx, x);
3727 return error::kNoError;
3730 error::Error GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3731 uint32_t immediate_data_size,
3732 const void* cmd_data) {
3733 const gles2::cmds::VertexAttrib1fvImmediate& c =
3734 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate*>(cmd_data);
3735 (void)c;
3736 GLuint indx = static_cast<GLuint>(c.indx);
3737 uint32_t data_size;
3738 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
3739 return error::kOutOfBounds;
3741 if (data_size > immediate_data_size) {
3742 return error::kOutOfBounds;
3744 const GLfloat* values =
3745 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3746 if (values == NULL) {
3747 return error::kOutOfBounds;
3749 DoVertexAttrib1fv(indx, values);
3750 return error::kNoError;
3753 error::Error GLES2DecoderImpl::HandleVertexAttrib2f(
3754 uint32_t immediate_data_size,
3755 const void* cmd_data) {
3756 const gles2::cmds::VertexAttrib2f& c =
3757 *static_cast<const gles2::cmds::VertexAttrib2f*>(cmd_data);
3758 (void)c;
3759 GLuint indx = static_cast<GLuint>(c.indx);
3760 GLfloat x = static_cast<GLfloat>(c.x);
3761 GLfloat y = static_cast<GLfloat>(c.y);
3762 DoVertexAttrib2f(indx, x, y);
3763 return error::kNoError;
3766 error::Error GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3767 uint32_t immediate_data_size,
3768 const void* cmd_data) {
3769 const gles2::cmds::VertexAttrib2fvImmediate& c =
3770 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate*>(cmd_data);
3771 (void)c;
3772 GLuint indx = static_cast<GLuint>(c.indx);
3773 uint32_t data_size;
3774 if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
3775 return error::kOutOfBounds;
3777 if (data_size > immediate_data_size) {
3778 return error::kOutOfBounds;
3780 const GLfloat* values =
3781 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3782 if (values == NULL) {
3783 return error::kOutOfBounds;
3785 DoVertexAttrib2fv(indx, values);
3786 return error::kNoError;
3789 error::Error GLES2DecoderImpl::HandleVertexAttrib3f(
3790 uint32_t immediate_data_size,
3791 const void* cmd_data) {
3792 const gles2::cmds::VertexAttrib3f& c =
3793 *static_cast<const gles2::cmds::VertexAttrib3f*>(cmd_data);
3794 (void)c;
3795 GLuint indx = static_cast<GLuint>(c.indx);
3796 GLfloat x = static_cast<GLfloat>(c.x);
3797 GLfloat y = static_cast<GLfloat>(c.y);
3798 GLfloat z = static_cast<GLfloat>(c.z);
3799 DoVertexAttrib3f(indx, x, y, z);
3800 return error::kNoError;
3803 error::Error GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3804 uint32_t immediate_data_size,
3805 const void* cmd_data) {
3806 const gles2::cmds::VertexAttrib3fvImmediate& c =
3807 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate*>(cmd_data);
3808 (void)c;
3809 GLuint indx = static_cast<GLuint>(c.indx);
3810 uint32_t data_size;
3811 if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
3812 return error::kOutOfBounds;
3814 if (data_size > immediate_data_size) {
3815 return error::kOutOfBounds;
3817 const GLfloat* values =
3818 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3819 if (values == NULL) {
3820 return error::kOutOfBounds;
3822 DoVertexAttrib3fv(indx, values);
3823 return error::kNoError;
3826 error::Error GLES2DecoderImpl::HandleVertexAttrib4f(
3827 uint32_t immediate_data_size,
3828 const void* cmd_data) {
3829 const gles2::cmds::VertexAttrib4f& c =
3830 *static_cast<const gles2::cmds::VertexAttrib4f*>(cmd_data);
3831 (void)c;
3832 GLuint indx = static_cast<GLuint>(c.indx);
3833 GLfloat x = static_cast<GLfloat>(c.x);
3834 GLfloat y = static_cast<GLfloat>(c.y);
3835 GLfloat z = static_cast<GLfloat>(c.z);
3836 GLfloat w = static_cast<GLfloat>(c.w);
3837 DoVertexAttrib4f(indx, x, y, z, w);
3838 return error::kNoError;
3841 error::Error GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3842 uint32_t immediate_data_size,
3843 const void* cmd_data) {
3844 const gles2::cmds::VertexAttrib4fvImmediate& c =
3845 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate*>(cmd_data);
3846 (void)c;
3847 GLuint indx = static_cast<GLuint>(c.indx);
3848 uint32_t data_size;
3849 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
3850 return error::kOutOfBounds;
3852 if (data_size > immediate_data_size) {
3853 return error::kOutOfBounds;
3855 const GLfloat* values =
3856 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3857 if (values == NULL) {
3858 return error::kOutOfBounds;
3860 DoVertexAttrib4fv(indx, values);
3861 return error::kNoError;
3864 error::Error GLES2DecoderImpl::HandleVertexAttribI4i(
3865 uint32_t immediate_data_size,
3866 const void* cmd_data) {
3867 if (!unsafe_es3_apis_enabled())
3868 return error::kUnknownCommand;
3869 const gles2::cmds::VertexAttribI4i& c =
3870 *static_cast<const gles2::cmds::VertexAttribI4i*>(cmd_data);
3871 (void)c;
3872 GLuint indx = static_cast<GLuint>(c.indx);
3873 GLint x = static_cast<GLint>(c.x);
3874 GLint y = static_cast<GLint>(c.y);
3875 GLint z = static_cast<GLint>(c.z);
3876 GLint w = static_cast<GLint>(c.w);
3877 DoVertexAttribI4i(indx, x, y, z, w);
3878 return error::kNoError;
3881 error::Error GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3882 uint32_t immediate_data_size,
3883 const void* cmd_data) {
3884 if (!unsafe_es3_apis_enabled())
3885 return error::kUnknownCommand;
3886 const gles2::cmds::VertexAttribI4ivImmediate& c =
3887 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate*>(cmd_data);
3888 (void)c;
3889 GLuint indx = static_cast<GLuint>(c.indx);
3890 uint32_t data_size;
3891 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
3892 return error::kOutOfBounds;
3894 if (data_size > immediate_data_size) {
3895 return error::kOutOfBounds;
3897 const GLint* values =
3898 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3899 if (values == NULL) {
3900 return error::kOutOfBounds;
3902 DoVertexAttribI4iv(indx, values);
3903 return error::kNoError;
3906 error::Error GLES2DecoderImpl::HandleVertexAttribI4ui(
3907 uint32_t immediate_data_size,
3908 const void* cmd_data) {
3909 if (!unsafe_es3_apis_enabled())
3910 return error::kUnknownCommand;
3911 const gles2::cmds::VertexAttribI4ui& c =
3912 *static_cast<const gles2::cmds::VertexAttribI4ui*>(cmd_data);
3913 (void)c;
3914 GLuint indx = static_cast<GLuint>(c.indx);
3915 GLuint x = static_cast<GLuint>(c.x);
3916 GLuint y = static_cast<GLuint>(c.y);
3917 GLuint z = static_cast<GLuint>(c.z);
3918 GLuint w = static_cast<GLuint>(c.w);
3919 DoVertexAttribI4ui(indx, x, y, z, w);
3920 return error::kNoError;
3923 error::Error GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3924 uint32_t immediate_data_size,
3925 const void* cmd_data) {
3926 if (!unsafe_es3_apis_enabled())
3927 return error::kUnknownCommand;
3928 const gles2::cmds::VertexAttribI4uivImmediate& c =
3929 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate*>(cmd_data);
3930 (void)c;
3931 GLuint indx = static_cast<GLuint>(c.indx);
3932 uint32_t data_size;
3933 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
3934 return error::kOutOfBounds;
3936 if (data_size > immediate_data_size) {
3937 return error::kOutOfBounds;
3939 const GLuint* values =
3940 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3941 if (values == NULL) {
3942 return error::kOutOfBounds;
3944 DoVertexAttribI4uiv(indx, values);
3945 return error::kNoError;
3948 error::Error GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size,
3949 const void* cmd_data) {
3950 const gles2::cmds::Viewport& c =
3951 *static_cast<const gles2::cmds::Viewport*>(cmd_data);
3952 (void)c;
3953 GLint x = static_cast<GLint>(c.x);
3954 GLint y = static_cast<GLint>(c.y);
3955 GLsizei width = static_cast<GLsizei>(c.width);
3956 GLsizei height = static_cast<GLsizei>(c.height);
3957 if (width < 0) {
3958 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "width < 0");
3959 return error::kNoError;
3961 if (height < 0) {
3962 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "height < 0");
3963 return error::kNoError;
3965 DoViewport(x, y, width, height);
3966 return error::kNoError;
3969 error::Error GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
3970 uint32_t immediate_data_size,
3971 const void* cmd_data) {
3972 const gles2::cmds::BlitFramebufferCHROMIUM& c =
3973 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM*>(cmd_data);
3974 (void)c;
3975 if (!features().chromium_framebuffer_multisample) {
3976 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlitFramebufferCHROMIUM",
3977 "function not available");
3978 return error::kNoError;
3981 error::Error error;
3982 error = WillAccessBoundFramebufferForDraw();
3983 if (error != error::kNoError)
3984 return error;
3985 error = WillAccessBoundFramebufferForRead();
3986 if (error != error::kNoError)
3987 return error;
3988 GLint srcX0 = static_cast<GLint>(c.srcX0);
3989 GLint srcY0 = static_cast<GLint>(c.srcY0);
3990 GLint srcX1 = static_cast<GLint>(c.srcX1);
3991 GLint srcY1 = static_cast<GLint>(c.srcY1);
3992 GLint dstX0 = static_cast<GLint>(c.dstX0);
3993 GLint dstY0 = static_cast<GLint>(c.dstY0);
3994 GLint dstX1 = static_cast<GLint>(c.dstX1);
3995 GLint dstY1 = static_cast<GLint>(c.dstY1);
3996 GLbitfield mask = static_cast<GLbitfield>(c.mask);
3997 GLenum filter = static_cast<GLenum>(c.filter);
3998 if (!validators_->blit_filter.IsValid(filter)) {
3999 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter,
4000 "filter");
4001 return error::kNoError;
4003 DoBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
4004 dstY1, mask, filter);
4005 return error::kNoError;
4008 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
4009 uint32_t immediate_data_size,
4010 const void* cmd_data) {
4011 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM& c =
4012 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM*>(
4013 cmd_data);
4014 (void)c;
4015 if (!features().chromium_framebuffer_multisample) {
4016 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4017 "glRenderbufferStorageMultisampleCHROMIUM",
4018 "function not available");
4019 return error::kNoError;
4022 GLenum target = static_cast<GLenum>(c.target);
4023 GLsizei samples = static_cast<GLsizei>(c.samples);
4024 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4025 GLsizei width = static_cast<GLsizei>(c.width);
4026 GLsizei height = static_cast<GLsizei>(c.height);
4027 if (!validators_->render_buffer_target.IsValid(target)) {
4028 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4029 target, "target");
4030 return error::kNoError;
4032 if (samples < 0) {
4033 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4034 "glRenderbufferStorageMultisampleCHROMIUM",
4035 "samples < 0");
4036 return error::kNoError;
4038 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4039 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4040 internalformat, "internalformat");
4041 return error::kNoError;
4043 if (width < 0) {
4044 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4045 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
4046 return error::kNoError;
4048 if (height < 0) {
4049 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4050 "glRenderbufferStorageMultisampleCHROMIUM",
4051 "height < 0");
4052 return error::kNoError;
4054 DoRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
4055 width, height);
4056 return error::kNoError;
4059 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
4060 uint32_t immediate_data_size,
4061 const void* cmd_data) {
4062 const gles2::cmds::RenderbufferStorageMultisampleEXT& c =
4063 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT*>(
4064 cmd_data);
4065 (void)c;
4066 if (!features().multisampled_render_to_texture) {
4067 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4068 "glRenderbufferStorageMultisampleEXT",
4069 "function not available");
4070 return error::kNoError;
4073 GLenum target = static_cast<GLenum>(c.target);
4074 GLsizei samples = static_cast<GLsizei>(c.samples);
4075 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4076 GLsizei width = static_cast<GLsizei>(c.width);
4077 GLsizei height = static_cast<GLsizei>(c.height);
4078 if (!validators_->render_buffer_target.IsValid(target)) {
4079 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4080 target, "target");
4081 return error::kNoError;
4083 if (samples < 0) {
4084 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4085 "samples < 0");
4086 return error::kNoError;
4088 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4089 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4090 internalformat, "internalformat");
4091 return error::kNoError;
4093 if (width < 0) {
4094 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4095 "width < 0");
4096 return error::kNoError;
4098 if (height < 0) {
4099 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4100 "height < 0");
4101 return error::kNoError;
4103 DoRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
4104 height);
4105 return error::kNoError;
4108 error::Error GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
4109 uint32_t immediate_data_size,
4110 const void* cmd_data) {
4111 const gles2::cmds::FramebufferTexture2DMultisampleEXT& c =
4112 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT*>(
4113 cmd_data);
4114 (void)c;
4115 if (!features().multisampled_render_to_texture) {
4116 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4117 "glFramebufferTexture2DMultisampleEXT",
4118 "function not available");
4119 return error::kNoError;
4122 GLenum target = static_cast<GLenum>(c.target);
4123 GLenum attachment = static_cast<GLenum>(c.attachment);
4124 GLenum textarget = static_cast<GLenum>(c.textarget);
4125 GLuint texture = c.texture;
4126 GLint level = static_cast<GLint>(c.level);
4127 GLsizei samples = static_cast<GLsizei>(c.samples);
4128 if (!validators_->frame_buffer_target.IsValid(target)) {
4129 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4130 target, "target");
4131 return error::kNoError;
4133 if (!validators_->attachment.IsValid(attachment)) {
4134 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4135 attachment, "attachment");
4136 return error::kNoError;
4138 if (!validators_->texture_target.IsValid(textarget)) {
4139 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4140 textarget, "textarget");
4141 return error::kNoError;
4143 if (samples < 0) {
4144 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glFramebufferTexture2DMultisampleEXT",
4145 "samples < 0");
4146 return error::kNoError;
4148 DoFramebufferTexture2DMultisample(target, attachment, textarget, texture,
4149 level, samples);
4150 return error::kNoError;
4153 error::Error GLES2DecoderImpl::HandleTexStorage2DEXT(
4154 uint32_t immediate_data_size,
4155 const void* cmd_data) {
4156 const gles2::cmds::TexStorage2DEXT& c =
4157 *static_cast<const gles2::cmds::TexStorage2DEXT*>(cmd_data);
4158 (void)c;
4159 GLenum target = static_cast<GLenum>(c.target);
4160 GLsizei levels = static_cast<GLsizei>(c.levels);
4161 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
4162 GLsizei width = static_cast<GLsizei>(c.width);
4163 GLsizei height = static_cast<GLsizei>(c.height);
4164 if (!validators_->texture_bind_target.IsValid(target)) {
4165 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target, "target");
4166 return error::kNoError;
4168 if (levels < 0) {
4169 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
4170 return error::kNoError;
4172 if (!validators_->texture_internal_format_storage.IsValid(internalFormat)) {
4173 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat,
4174 "internalFormat");
4175 return error::kNoError;
4177 if (width < 0) {
4178 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
4179 return error::kNoError;
4181 if (height < 0) {
4182 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
4183 return error::kNoError;
4185 DoTexStorage2DEXT(target, levels, internalFormat, width, height);
4186 return error::kNoError;
4189 error::Error GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4190 uint32_t immediate_data_size,
4191 const void* cmd_data) {
4192 const gles2::cmds::GenQueriesEXTImmediate& c =
4193 *static_cast<const gles2::cmds::GenQueriesEXTImmediate*>(cmd_data);
4194 (void)c;
4195 GLsizei n = static_cast<GLsizei>(c.n);
4196 uint32_t data_size;
4197 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4198 return error::kOutOfBounds;
4200 GLuint* queries =
4201 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4202 if (queries == NULL) {
4203 return error::kOutOfBounds;
4205 if (!GenQueriesEXTHelper(n, queries)) {
4206 return error::kInvalidArguments;
4208 return error::kNoError;
4211 error::Error GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4212 uint32_t immediate_data_size,
4213 const void* cmd_data) {
4214 const gles2::cmds::DeleteQueriesEXTImmediate& c =
4215 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate*>(cmd_data);
4216 (void)c;
4217 GLsizei n = static_cast<GLsizei>(c.n);
4218 uint32_t data_size;
4219 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4220 return error::kOutOfBounds;
4222 const GLuint* queries =
4223 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4224 if (queries == NULL) {
4225 return error::kOutOfBounds;
4227 DeleteQueriesEXTHelper(n, queries);
4228 return error::kNoError;
4231 error::Error GLES2DecoderImpl::HandleBeginTransformFeedback(
4232 uint32_t immediate_data_size,
4233 const void* cmd_data) {
4234 if (!unsafe_es3_apis_enabled())
4235 return error::kUnknownCommand;
4236 const gles2::cmds::BeginTransformFeedback& c =
4237 *static_cast<const gles2::cmds::BeginTransformFeedback*>(cmd_data);
4238 (void)c;
4239 GLenum primitivemode = static_cast<GLenum>(c.primitivemode);
4240 glBeginTransformFeedback(primitivemode);
4241 return error::kNoError;
4244 error::Error GLES2DecoderImpl::HandleEndTransformFeedback(
4245 uint32_t immediate_data_size,
4246 const void* cmd_data) {
4247 if (!unsafe_es3_apis_enabled())
4248 return error::kUnknownCommand;
4249 const gles2::cmds::EndTransformFeedback& c =
4250 *static_cast<const gles2::cmds::EndTransformFeedback*>(cmd_data);
4251 (void)c;
4252 glEndTransformFeedback();
4253 return error::kNoError;
4256 error::Error GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4257 uint32_t immediate_data_size,
4258 const void* cmd_data) {
4259 const gles2::cmds::InsertEventMarkerEXT& c =
4260 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data);
4261 (void)c;
4263 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4264 Bucket* bucket = GetBucket(bucket_id);
4265 if (!bucket || bucket->size() == 0) {
4266 return error::kInvalidArguments;
4268 std::string str;
4269 if (!bucket->GetAsString(&str)) {
4270 return error::kInvalidArguments;
4272 DoInsertEventMarkerEXT(0, str.c_str());
4273 return error::kNoError;
4276 error::Error GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4277 uint32_t immediate_data_size,
4278 const void* cmd_data) {
4279 const gles2::cmds::PushGroupMarkerEXT& c =
4280 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data);
4281 (void)c;
4283 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4284 Bucket* bucket = GetBucket(bucket_id);
4285 if (!bucket || bucket->size() == 0) {
4286 return error::kInvalidArguments;
4288 std::string str;
4289 if (!bucket->GetAsString(&str)) {
4290 return error::kInvalidArguments;
4292 DoPushGroupMarkerEXT(0, str.c_str());
4293 return error::kNoError;
4296 error::Error GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4297 uint32_t immediate_data_size,
4298 const void* cmd_data) {
4299 const gles2::cmds::PopGroupMarkerEXT& c =
4300 *static_cast<const gles2::cmds::PopGroupMarkerEXT*>(cmd_data);
4301 (void)c;
4302 DoPopGroupMarkerEXT();
4303 return error::kNoError;
4306 error::Error GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4307 uint32_t immediate_data_size,
4308 const void* cmd_data) {
4309 const gles2::cmds::GenVertexArraysOESImmediate& c =
4310 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate*>(cmd_data);
4311 (void)c;
4312 GLsizei n = static_cast<GLsizei>(c.n);
4313 uint32_t data_size;
4314 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4315 return error::kOutOfBounds;
4317 GLuint* arrays =
4318 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4319 if (arrays == NULL) {
4320 return error::kOutOfBounds;
4322 if (!GenVertexArraysOESHelper(n, arrays)) {
4323 return error::kInvalidArguments;
4325 return error::kNoError;
4328 error::Error GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4329 uint32_t immediate_data_size,
4330 const void* cmd_data) {
4331 const gles2::cmds::DeleteVertexArraysOESImmediate& c =
4332 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate*>(
4333 cmd_data);
4334 (void)c;
4335 GLsizei n = static_cast<GLsizei>(c.n);
4336 uint32_t data_size;
4337 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4338 return error::kOutOfBounds;
4340 const GLuint* arrays =
4341 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4342 if (arrays == NULL) {
4343 return error::kOutOfBounds;
4345 DeleteVertexArraysOESHelper(n, arrays);
4346 return error::kNoError;
4349 error::Error GLES2DecoderImpl::HandleIsVertexArrayOES(
4350 uint32_t immediate_data_size,
4351 const void* cmd_data) {
4352 const gles2::cmds::IsVertexArrayOES& c =
4353 *static_cast<const gles2::cmds::IsVertexArrayOES*>(cmd_data);
4354 (void)c;
4355 GLuint array = c.array;
4356 typedef cmds::IsVertexArrayOES::Result Result;
4357 Result* result_dst = GetSharedMemoryAs<Result*>(
4358 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4359 if (!result_dst) {
4360 return error::kOutOfBounds;
4362 *result_dst = DoIsVertexArrayOES(array);
4363 return error::kNoError;
4366 error::Error GLES2DecoderImpl::HandleBindVertexArrayOES(
4367 uint32_t immediate_data_size,
4368 const void* cmd_data) {
4369 const gles2::cmds::BindVertexArrayOES& c =
4370 *static_cast<const gles2::cmds::BindVertexArrayOES*>(cmd_data);
4371 (void)c;
4372 GLuint array = c.array;
4373 DoBindVertexArrayOES(array);
4374 return error::kNoError;
4377 error::Error GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size,
4378 const void* cmd_data) {
4379 const gles2::cmds::SwapBuffers& c =
4380 *static_cast<const gles2::cmds::SwapBuffers*>(cmd_data);
4381 (void)c;
4382 DoSwapBuffers();
4383 return error::kNoError;
4386 error::Error GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4387 uint32_t immediate_data_size,
4388 const void* cmd_data) {
4389 const gles2::cmds::GetMaxValueInBufferCHROMIUM& c =
4390 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM*>(cmd_data);
4391 (void)c;
4392 GLuint buffer_id = c.buffer_id;
4393 GLsizei count = static_cast<GLsizei>(c.count);
4394 GLenum type = static_cast<GLenum>(c.type);
4395 GLuint offset = static_cast<GLuint>(c.offset);
4396 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result;
4397 Result* result_dst = GetSharedMemoryAs<Result*>(
4398 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4399 if (!result_dst) {
4400 return error::kOutOfBounds;
4402 if (count < 0) {
4403 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetMaxValueInBufferCHROMIUM",
4404 "count < 0");
4405 return error::kNoError;
4407 if (!validators_->get_max_index_type.IsValid(type)) {
4408 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type,
4409 "type");
4410 return error::kNoError;
4412 *result_dst = DoGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
4413 return error::kNoError;
4416 error::Error GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4417 uint32_t immediate_data_size,
4418 const void* cmd_data) {
4419 const gles2::cmds::TexImageIOSurface2DCHROMIUM& c =
4420 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM*>(cmd_data);
4421 (void)c;
4422 GLenum target = static_cast<GLenum>(c.target);
4423 GLsizei width = static_cast<GLsizei>(c.width);
4424 GLsizei height = static_cast<GLsizei>(c.height);
4425 GLuint ioSurfaceId = static_cast<GLuint>(c.ioSurfaceId);
4426 GLuint plane = static_cast<GLuint>(c.plane);
4427 if (!validators_->texture_bind_target.IsValid(target)) {
4428 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target,
4429 "target");
4430 return error::kNoError;
4432 if (width < 0) {
4433 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4434 "width < 0");
4435 return error::kNoError;
4437 if (height < 0) {
4438 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4439 "height < 0");
4440 return error::kNoError;
4442 DoTexImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
4443 return error::kNoError;
4446 error::Error GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4447 uint32_t immediate_data_size,
4448 const void* cmd_data) {
4449 const gles2::cmds::CopyTextureCHROMIUM& c =
4450 *static_cast<const gles2::cmds::CopyTextureCHROMIUM*>(cmd_data);
4451 (void)c;
4452 GLenum target = static_cast<GLenum>(c.target);
4453 GLenum source_id = static_cast<GLenum>(c.source_id);
4454 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4455 GLint internalformat = static_cast<GLint>(c.internalformat);
4456 GLenum dest_type = static_cast<GLenum>(c.dest_type);
4457 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4458 GLboolean unpack_premultiply_alpha =
4459 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4460 GLboolean unpack_unmultiply_alpha =
4461 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4462 if (!validators_->texture_internal_format.IsValid(internalformat)) {
4463 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM",
4464 "internalformat GL_INVALID_VALUE");
4465 return error::kNoError;
4467 if (!validators_->pixel_type.IsValid(dest_type)) {
4468 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type,
4469 "dest_type");
4470 return error::kNoError;
4472 DoCopyTextureCHROMIUM(target, source_id, dest_id, internalformat, dest_type,
4473 unpack_flip_y, unpack_premultiply_alpha,
4474 unpack_unmultiply_alpha);
4475 return error::kNoError;
4478 error::Error GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4479 uint32_t immediate_data_size,
4480 const void* cmd_data) {
4481 const gles2::cmds::CopySubTextureCHROMIUM& c =
4482 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM*>(cmd_data);
4483 (void)c;
4484 GLenum target = static_cast<GLenum>(c.target);
4485 GLenum source_id = static_cast<GLenum>(c.source_id);
4486 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4487 GLint xoffset = static_cast<GLint>(c.xoffset);
4488 GLint yoffset = static_cast<GLint>(c.yoffset);
4489 GLint x = static_cast<GLint>(c.x);
4490 GLint y = static_cast<GLint>(c.y);
4491 GLsizei width = static_cast<GLsizei>(c.width);
4492 GLsizei height = static_cast<GLsizei>(c.height);
4493 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4494 GLboolean unpack_premultiply_alpha =
4495 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4496 GLboolean unpack_unmultiply_alpha =
4497 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4498 if (width < 0) {
4499 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4500 "width < 0");
4501 return error::kNoError;
4503 if (height < 0) {
4504 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4505 "height < 0");
4506 return error::kNoError;
4508 DoCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset, yoffset, x, y,
4509 width, height, unpack_flip_y,
4510 unpack_premultiply_alpha, unpack_unmultiply_alpha);
4511 return error::kNoError;
4514 error::Error GLES2DecoderImpl::HandleCompressedCopyTextureCHROMIUM(
4515 uint32_t immediate_data_size,
4516 const void* cmd_data) {
4517 const gles2::cmds::CompressedCopyTextureCHROMIUM& c =
4518 *static_cast<const gles2::cmds::CompressedCopyTextureCHROMIUM*>(cmd_data);
4519 (void)c;
4520 GLenum target = static_cast<GLenum>(c.target);
4521 GLenum source_id = static_cast<GLenum>(c.source_id);
4522 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4523 DoCompressedCopyTextureCHROMIUM(target, source_id, dest_id);
4524 return error::kNoError;
4527 error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4528 uint32_t immediate_data_size,
4529 const void* cmd_data) {
4530 const gles2::cmds::ProduceTextureCHROMIUMImmediate& c =
4531 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate*>(
4532 cmd_data);
4533 (void)c;
4534 GLenum target = static_cast<GLenum>(c.target);
4535 uint32_t data_size;
4536 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4537 return error::kOutOfBounds;
4539 if (data_size > immediate_data_size) {
4540 return error::kOutOfBounds;
4542 const GLbyte* mailbox =
4543 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4544 if (!validators_->texture_bind_target.IsValid(target)) {
4545 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target,
4546 "target");
4547 return error::kNoError;
4549 if (mailbox == NULL) {
4550 return error::kOutOfBounds;
4552 DoProduceTextureCHROMIUM(target, mailbox);
4553 return error::kNoError;
4556 error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4557 uint32_t immediate_data_size,
4558 const void* cmd_data) {
4559 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c =
4560 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>(
4561 cmd_data);
4562 (void)c;
4563 GLuint texture = c.texture;
4564 GLenum target = static_cast<GLenum>(c.target);
4565 uint32_t data_size;
4566 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4567 return error::kOutOfBounds;
4569 if (data_size > immediate_data_size) {
4570 return error::kOutOfBounds;
4572 const GLbyte* mailbox =
4573 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4574 if (!validators_->texture_bind_target.IsValid(target)) {
4575 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target,
4576 "target");
4577 return error::kNoError;
4579 if (mailbox == NULL) {
4580 return error::kOutOfBounds;
4582 DoProduceTextureDirectCHROMIUM(texture, target, mailbox);
4583 return error::kNoError;
4586 error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4587 uint32_t immediate_data_size,
4588 const void* cmd_data) {
4589 const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c =
4590 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate*>(
4591 cmd_data);
4592 (void)c;
4593 GLenum target = static_cast<GLenum>(c.target);
4594 uint32_t data_size;
4595 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4596 return error::kOutOfBounds;
4598 if (data_size > immediate_data_size) {
4599 return error::kOutOfBounds;
4601 const GLbyte* mailbox =
4602 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4603 if (!validators_->texture_bind_target.IsValid(target)) {
4604 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target,
4605 "target");
4606 return error::kNoError;
4608 if (mailbox == NULL) {
4609 return error::kOutOfBounds;
4611 DoConsumeTextureCHROMIUM(target, mailbox);
4612 return error::kNoError;
4615 error::Error GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4616 uint32_t immediate_data_size,
4617 const void* cmd_data) {
4618 const gles2::cmds::GenValuebuffersCHROMIUMImmediate& c =
4619 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate*>(
4620 cmd_data);
4621 (void)c;
4622 GLsizei n = static_cast<GLsizei>(c.n);
4623 uint32_t data_size;
4624 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4625 return error::kOutOfBounds;
4627 GLuint* buffers =
4628 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4629 if (buffers == NULL) {
4630 return error::kOutOfBounds;
4632 if (!GenValuebuffersCHROMIUMHelper(n, buffers)) {
4633 return error::kInvalidArguments;
4635 return error::kNoError;
4638 error::Error GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4639 uint32_t immediate_data_size,
4640 const void* cmd_data) {
4641 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate& c =
4642 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate*>(
4643 cmd_data);
4644 (void)c;
4645 GLsizei n = static_cast<GLsizei>(c.n);
4646 uint32_t data_size;
4647 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4648 return error::kOutOfBounds;
4650 const GLuint* valuebuffers =
4651 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4652 if (valuebuffers == NULL) {
4653 return error::kOutOfBounds;
4655 DeleteValuebuffersCHROMIUMHelper(n, valuebuffers);
4656 return error::kNoError;
4659 error::Error GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4660 uint32_t immediate_data_size,
4661 const void* cmd_data) {
4662 const gles2::cmds::IsValuebufferCHROMIUM& c =
4663 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM*>(cmd_data);
4664 (void)c;
4665 GLuint valuebuffer = c.valuebuffer;
4666 typedef cmds::IsValuebufferCHROMIUM::Result Result;
4667 Result* result_dst = GetSharedMemoryAs<Result*>(
4668 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4669 if (!result_dst) {
4670 return error::kOutOfBounds;
4672 *result_dst = DoIsValuebufferCHROMIUM(valuebuffer);
4673 return error::kNoError;
4676 error::Error GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4677 uint32_t immediate_data_size,
4678 const void* cmd_data) {
4679 const gles2::cmds::BindValuebufferCHROMIUM& c =
4680 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM*>(cmd_data);
4681 (void)c;
4682 GLenum target = static_cast<GLenum>(c.target);
4683 GLuint valuebuffer = c.valuebuffer;
4684 if (!validators_->value_buffer_target.IsValid(target)) {
4685 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target,
4686 "target");
4687 return error::kNoError;
4689 DoBindValueBufferCHROMIUM(target, valuebuffer);
4690 return error::kNoError;
4693 error::Error GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4694 uint32_t immediate_data_size,
4695 const void* cmd_data) {
4696 const gles2::cmds::SubscribeValueCHROMIUM& c =
4697 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM*>(cmd_data);
4698 (void)c;
4699 GLenum target = static_cast<GLenum>(c.target);
4700 GLenum subscription = static_cast<GLenum>(c.subscription);
4701 if (!validators_->value_buffer_target.IsValid(target)) {
4702 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target,
4703 "target");
4704 return error::kNoError;
4706 if (!validators_->subscription_target.IsValid(subscription)) {
4707 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription,
4708 "subscription");
4709 return error::kNoError;
4711 DoSubscribeValueCHROMIUM(target, subscription);
4712 return error::kNoError;
4715 error::Error GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4716 uint32_t immediate_data_size,
4717 const void* cmd_data) {
4718 const gles2::cmds::PopulateSubscribedValuesCHROMIUM& c =
4719 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM*>(
4720 cmd_data);
4721 (void)c;
4722 GLenum target = static_cast<GLenum>(c.target);
4723 if (!validators_->value_buffer_target.IsValid(target)) {
4724 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4725 target, "target");
4726 return error::kNoError;
4728 DoPopulateSubscribedValuesCHROMIUM(target);
4729 return error::kNoError;
4732 error::Error GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4733 uint32_t immediate_data_size,
4734 const void* cmd_data) {
4735 const gles2::cmds::UniformValuebufferCHROMIUM& c =
4736 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM*>(cmd_data);
4737 (void)c;
4738 GLint location = static_cast<GLint>(c.location);
4739 GLenum target = static_cast<GLenum>(c.target);
4740 GLenum subscription = static_cast<GLenum>(c.subscription);
4741 if (!validators_->value_buffer_target.IsValid(target)) {
4742 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target,
4743 "target");
4744 return error::kNoError;
4746 if (!validators_->subscription_target.IsValid(subscription)) {
4747 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4748 subscription, "subscription");
4749 return error::kNoError;
4751 DoUniformValueBufferCHROMIUM(location, target, subscription);
4752 return error::kNoError;
4755 error::Error GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4756 uint32_t immediate_data_size,
4757 const void* cmd_data) {
4758 const gles2::cmds::BindTexImage2DCHROMIUM& c =
4759 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM*>(cmd_data);
4760 (void)c;
4761 GLenum target = static_cast<GLenum>(c.target);
4762 GLint imageId = static_cast<GLint>(c.imageId);
4763 if (!validators_->texture_bind_target.IsValid(target)) {
4764 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target,
4765 "target");
4766 return error::kNoError;
4768 DoBindTexImage2DCHROMIUM(target, imageId);
4769 return error::kNoError;
4772 error::Error GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4773 uint32_t immediate_data_size,
4774 const void* cmd_data) {
4775 const gles2::cmds::ReleaseTexImage2DCHROMIUM& c =
4776 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM*>(cmd_data);
4777 (void)c;
4778 GLenum target = static_cast<GLenum>(c.target);
4779 GLint imageId = static_cast<GLint>(c.imageId);
4780 if (!validators_->texture_bind_target.IsValid(target)) {
4781 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target,
4782 "target");
4783 return error::kNoError;
4785 DoReleaseTexImage2DCHROMIUM(target, imageId);
4786 return error::kNoError;
4789 error::Error GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4790 uint32_t immediate_data_size,
4791 const void* cmd_data) {
4792 const gles2::cmds::TraceEndCHROMIUM& c =
4793 *static_cast<const gles2::cmds::TraceEndCHROMIUM*>(cmd_data);
4794 (void)c;
4795 DoTraceEndCHROMIUM();
4796 return error::kNoError;
4799 error::Error GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4800 uint32_t immediate_data_size,
4801 const void* cmd_data) {
4802 const gles2::cmds::DiscardFramebufferEXTImmediate& c =
4803 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate*>(
4804 cmd_data);
4805 (void)c;
4806 if (!features().ext_discard_framebuffer) {
4807 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDiscardFramebufferEXT",
4808 "function not available");
4809 return error::kNoError;
4812 GLenum target = static_cast<GLenum>(c.target);
4813 GLsizei count = static_cast<GLsizei>(c.count);
4814 uint32_t data_size;
4815 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4816 return error::kOutOfBounds;
4818 if (data_size > immediate_data_size) {
4819 return error::kOutOfBounds;
4821 const GLenum* attachments =
4822 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4823 if (count < 0) {
4824 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDiscardFramebufferEXT",
4825 "count < 0");
4826 return error::kNoError;
4828 if (attachments == NULL) {
4829 return error::kOutOfBounds;
4831 DoDiscardFramebufferEXT(target, count, attachments);
4832 return error::kNoError;
4835 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4836 uint32_t immediate_data_size,
4837 const void* cmd_data) {
4838 const gles2::cmds::LoseContextCHROMIUM& c =
4839 *static_cast<const gles2::cmds::LoseContextCHROMIUM*>(cmd_data);
4840 (void)c;
4841 GLenum current = static_cast<GLenum>(c.current);
4842 GLenum other = static_cast<GLenum>(c.other);
4843 if (!validators_->reset_status.IsValid(current)) {
4844 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
4845 "current");
4846 return error::kNoError;
4848 if (!validators_->reset_status.IsValid(other)) {
4849 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
4850 return error::kNoError;
4852 DoLoseContextCHROMIUM(current, other);
4853 return error::kNoError;
4856 error::Error GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4857 uint32_t immediate_data_size,
4858 const void* cmd_data) {
4859 const gles2::cmds::DrawBuffersEXTImmediate& c =
4860 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate*>(cmd_data);
4861 (void)c;
4862 GLsizei count = static_cast<GLsizei>(c.count);
4863 uint32_t data_size;
4864 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4865 return error::kOutOfBounds;
4867 if (data_size > immediate_data_size) {
4868 return error::kOutOfBounds;
4870 const GLenum* bufs =
4871 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4872 if (count < 0) {
4873 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
4874 return error::kNoError;
4876 if (bufs == NULL) {
4877 return error::kOutOfBounds;
4879 DoDrawBuffersEXT(count, bufs);
4880 return error::kNoError;
4883 error::Error GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size,
4884 const void* cmd_data) {
4885 const gles2::cmds::SwapInterval& c =
4886 *static_cast<const gles2::cmds::SwapInterval*>(cmd_data);
4887 (void)c;
4888 GLint interval = static_cast<GLint>(c.interval);
4889 DoSwapInterval(interval);
4890 return error::kNoError;
4893 error::Error GLES2DecoderImpl::HandleFlushDriverCachesCHROMIUM(
4894 uint32_t immediate_data_size,
4895 const void* cmd_data) {
4896 const gles2::cmds::FlushDriverCachesCHROMIUM& c =
4897 *static_cast<const gles2::cmds::FlushDriverCachesCHROMIUM*>(cmd_data);
4898 (void)c;
4899 DoFlushDriverCachesCHROMIUM();
4900 return error::kNoError;
4903 error::Error GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4904 uint32_t immediate_data_size,
4905 const void* cmd_data) {
4906 const gles2::cmds::MatrixLoadfCHROMIUMImmediate& c =
4907 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate*>(cmd_data);
4908 (void)c;
4909 if (!features().chromium_path_rendering) {
4910 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadfCHROMIUM",
4911 "function not available");
4912 return error::kNoError;
4915 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4916 uint32_t data_size;
4917 if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
4918 return error::kOutOfBounds;
4920 if (data_size > immediate_data_size) {
4921 return error::kOutOfBounds;
4923 const GLfloat* m =
4924 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
4925 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4926 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode,
4927 "matrixMode");
4928 return error::kNoError;
4930 if (m == NULL) {
4931 return error::kOutOfBounds;
4933 DoMatrixLoadfCHROMIUM(matrixMode, m);
4934 return error::kNoError;
4937 error::Error GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
4938 uint32_t immediate_data_size,
4939 const void* cmd_data) {
4940 const gles2::cmds::MatrixLoadIdentityCHROMIUM& c =
4941 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM*>(cmd_data);
4942 (void)c;
4943 if (!features().chromium_path_rendering) {
4944 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadIdentityCHROMIUM",
4945 "function not available");
4946 return error::kNoError;
4949 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4950 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4951 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode,
4952 "matrixMode");
4953 return error::kNoError;
4955 DoMatrixLoadIdentityCHROMIUM(matrixMode);
4956 return error::kNoError;
4959 error::Error GLES2DecoderImpl::HandleIsPathCHROMIUM(
4960 uint32_t immediate_data_size,
4961 const void* cmd_data) {
4962 const gles2::cmds::IsPathCHROMIUM& c =
4963 *static_cast<const gles2::cmds::IsPathCHROMIUM*>(cmd_data);
4964 (void)c;
4965 if (!features().chromium_path_rendering) {
4966 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glIsPathCHROMIUM",
4967 "function not available");
4968 return error::kNoError;
4971 GLuint path = c.path;
4972 typedef cmds::IsPathCHROMIUM::Result Result;
4973 Result* result_dst = GetSharedMemoryAs<Result*>(
4974 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4975 if (!result_dst) {
4976 return error::kOutOfBounds;
4978 *result_dst = DoIsPathCHROMIUM(path);
4979 return error::kNoError;
4982 error::Error GLES2DecoderImpl::HandlePathStencilFuncCHROMIUM(
4983 uint32_t immediate_data_size,
4984 const void* cmd_data) {
4985 const gles2::cmds::PathStencilFuncCHROMIUM& c =
4986 *static_cast<const gles2::cmds::PathStencilFuncCHROMIUM*>(cmd_data);
4987 (void)c;
4988 if (!features().chromium_path_rendering) {
4989 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glPathStencilFuncCHROMIUM",
4990 "function not available");
4991 return error::kNoError;
4994 GLenum func = static_cast<GLenum>(c.func);
4995 GLint ref = static_cast<GLint>(c.ref);
4996 GLuint mask = static_cast<GLuint>(c.mask);
4997 if (!validators_->cmp_function.IsValid(func)) {
4998 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPathStencilFuncCHROMIUM", func, "func");
4999 return error::kNoError;
5001 if (state_.stencil_path_func != func || state_.stencil_path_ref != ref ||
5002 state_.stencil_path_mask != mask) {
5003 state_.stencil_path_func = func;
5004 state_.stencil_path_ref = ref;
5005 state_.stencil_path_mask = mask;
5006 glPathStencilFuncNV(func, ref, mask);
5008 return error::kNoError;
5011 error::Error GLES2DecoderImpl::HandleBlendBarrierKHR(
5012 uint32_t immediate_data_size,
5013 const void* cmd_data) {
5014 const gles2::cmds::BlendBarrierKHR& c =
5015 *static_cast<const gles2::cmds::BlendBarrierKHR*>(cmd_data);
5016 (void)c;
5017 if (!features().blend_equation_advanced) {
5018 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlendBarrierKHR",
5019 "function not available");
5020 return error::kNoError;
5023 glBlendBarrierKHR();
5024 return error::kNoError;
5027 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
5028 switch (cap) {
5029 case GL_BLEND:
5030 state_.enable_flags.blend = enabled;
5031 if (state_.enable_flags.cached_blend != enabled ||
5032 state_.ignore_cached_state) {
5033 state_.enable_flags.cached_blend = enabled;
5034 return true;
5036 return false;
5037 case GL_CULL_FACE:
5038 state_.enable_flags.cull_face = enabled;
5039 if (state_.enable_flags.cached_cull_face != enabled ||
5040 state_.ignore_cached_state) {
5041 state_.enable_flags.cached_cull_face = enabled;
5042 return true;
5044 return false;
5045 case GL_DEPTH_TEST:
5046 state_.enable_flags.depth_test = enabled;
5047 if (state_.enable_flags.cached_depth_test != enabled ||
5048 state_.ignore_cached_state) {
5049 framebuffer_state_.clear_state_dirty = true;
5051 return false;
5052 case GL_DITHER:
5053 state_.enable_flags.dither = enabled;
5054 if (state_.enable_flags.cached_dither != enabled ||
5055 state_.ignore_cached_state) {
5056 state_.enable_flags.cached_dither = enabled;
5057 return true;
5059 return false;
5060 case GL_POLYGON_OFFSET_FILL:
5061 state_.enable_flags.polygon_offset_fill = enabled;
5062 if (state_.enable_flags.cached_polygon_offset_fill != enabled ||
5063 state_.ignore_cached_state) {
5064 state_.enable_flags.cached_polygon_offset_fill = enabled;
5065 return true;
5067 return false;
5068 case GL_SAMPLE_ALPHA_TO_COVERAGE:
5069 state_.enable_flags.sample_alpha_to_coverage = enabled;
5070 if (state_.enable_flags.cached_sample_alpha_to_coverage != enabled ||
5071 state_.ignore_cached_state) {
5072 state_.enable_flags.cached_sample_alpha_to_coverage = enabled;
5073 return true;
5075 return false;
5076 case GL_SAMPLE_COVERAGE:
5077 state_.enable_flags.sample_coverage = enabled;
5078 if (state_.enable_flags.cached_sample_coverage != enabled ||
5079 state_.ignore_cached_state) {
5080 state_.enable_flags.cached_sample_coverage = enabled;
5081 return true;
5083 return false;
5084 case GL_SCISSOR_TEST:
5085 state_.enable_flags.scissor_test = enabled;
5086 if (state_.enable_flags.cached_scissor_test != enabled ||
5087 state_.ignore_cached_state) {
5088 state_.enable_flags.cached_scissor_test = enabled;
5089 return true;
5091 return false;
5092 case GL_STENCIL_TEST:
5093 state_.enable_flags.stencil_test = enabled;
5094 if (state_.enable_flags.cached_stencil_test != enabled ||
5095 state_.ignore_cached_state) {
5096 framebuffer_state_.clear_state_dirty = true;
5098 return false;
5099 case GL_RASTERIZER_DISCARD:
5100 state_.enable_flags.rasterizer_discard = enabled;
5101 if (state_.enable_flags.cached_rasterizer_discard != enabled ||
5102 state_.ignore_cached_state) {
5103 state_.enable_flags.cached_rasterizer_discard = enabled;
5104 return true;
5106 return false;
5107 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
5108 state_.enable_flags.primitive_restart_fixed_index = enabled;
5109 if (state_.enable_flags.cached_primitive_restart_fixed_index != enabled ||
5110 state_.ignore_cached_state) {
5111 state_.enable_flags.cached_primitive_restart_fixed_index = enabled;
5112 return true;
5114 return false;
5115 default:
5116 NOTREACHED();
5117 return false;
5120 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_