Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_autogen.h
blob303b7021c5c2301dd25830221e1455b928678166
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 DoBindBufferBase(target, index, buffer);
63 return error::kNoError;
66 error::Error GLES2DecoderImpl::HandleBindBufferRange(
67 uint32_t immediate_data_size,
68 const void* cmd_data) {
69 if (!unsafe_es3_apis_enabled())
70 return error::kUnknownCommand;
71 const gles2::cmds::BindBufferRange& c =
72 *static_cast<const gles2::cmds::BindBufferRange*>(cmd_data);
73 (void)c;
74 GLenum target = static_cast<GLenum>(c.target);
75 GLuint index = static_cast<GLuint>(c.index);
76 GLuint buffer = c.buffer;
77 GLintptr offset = static_cast<GLintptr>(c.offset);
78 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
79 DoBindBufferRange(target, index, buffer, offset, size);
80 return error::kNoError;
83 error::Error GLES2DecoderImpl::HandleBindFramebuffer(
84 uint32_t immediate_data_size,
85 const void* cmd_data) {
86 const gles2::cmds::BindFramebuffer& c =
87 *static_cast<const gles2::cmds::BindFramebuffer*>(cmd_data);
88 (void)c;
89 GLenum target = static_cast<GLenum>(c.target);
90 GLuint framebuffer = c.framebuffer;
91 if (!validators_->frame_buffer_target.IsValid(target)) {
92 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target, "target");
93 return error::kNoError;
95 DoBindFramebuffer(target, framebuffer);
96 return error::kNoError;
99 error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
100 uint32_t immediate_data_size,
101 const void* cmd_data) {
102 const gles2::cmds::BindRenderbuffer& c =
103 *static_cast<const gles2::cmds::BindRenderbuffer*>(cmd_data);
104 (void)c;
105 GLenum target = static_cast<GLenum>(c.target);
106 GLuint renderbuffer = c.renderbuffer;
107 if (!validators_->render_buffer_target.IsValid(target)) {
108 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target, "target");
109 return error::kNoError;
111 DoBindRenderbuffer(target, renderbuffer);
112 return error::kNoError;
115 error::Error GLES2DecoderImpl::HandleBindSampler(uint32_t immediate_data_size,
116 const void* cmd_data) {
117 if (!unsafe_es3_apis_enabled())
118 return error::kUnknownCommand;
119 const gles2::cmds::BindSampler& c =
120 *static_cast<const gles2::cmds::BindSampler*>(cmd_data);
121 (void)c;
122 GLuint unit = static_cast<GLuint>(c.unit);
123 GLuint sampler = c.sampler;
124 if (sampler == 0) {
125 glBindSampler(unit, sampler);
126 return error::kNoError;
128 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
129 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindSampler",
130 "invalid sampler id");
131 return error::kNoError;
133 glBindSampler(unit, sampler);
134 return error::kNoError;
137 error::Error GLES2DecoderImpl::HandleBindTexture(uint32_t immediate_data_size,
138 const void* cmd_data) {
139 const gles2::cmds::BindTexture& c =
140 *static_cast<const gles2::cmds::BindTexture*>(cmd_data);
141 (void)c;
142 GLenum target = static_cast<GLenum>(c.target);
143 GLuint texture = c.texture;
144 if (!validators_->texture_bind_target.IsValid(target)) {
145 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target, "target");
146 return error::kNoError;
148 DoBindTexture(target, texture);
149 return error::kNoError;
152 error::Error GLES2DecoderImpl::HandleBindTransformFeedback(
153 uint32_t immediate_data_size,
154 const void* cmd_data) {
155 if (!unsafe_es3_apis_enabled())
156 return error::kUnknownCommand;
157 const gles2::cmds::BindTransformFeedback& c =
158 *static_cast<const gles2::cmds::BindTransformFeedback*>(cmd_data);
159 (void)c;
160 GLenum target = static_cast<GLenum>(c.target);
161 GLuint transformfeedback = c.transformfeedback;
162 if (!group_->GetTransformFeedbackServiceId(transformfeedback,
163 &transformfeedback)) {
164 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindTransformFeedback",
165 "invalid transformfeedback id");
166 return error::kNoError;
168 glBindTransformFeedback(target, transformfeedback);
169 return error::kNoError;
172 error::Error GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size,
173 const void* cmd_data) {
174 const gles2::cmds::BlendColor& c =
175 *static_cast<const gles2::cmds::BlendColor*>(cmd_data);
176 (void)c;
177 GLclampf red = static_cast<GLclampf>(c.red);
178 GLclampf green = static_cast<GLclampf>(c.green);
179 GLclampf blue = static_cast<GLclampf>(c.blue);
180 GLclampf alpha = static_cast<GLclampf>(c.alpha);
181 if (state_.blend_color_red != red || state_.blend_color_green != green ||
182 state_.blend_color_blue != blue || state_.blend_color_alpha != alpha) {
183 state_.blend_color_red = red;
184 state_.blend_color_green = green;
185 state_.blend_color_blue = blue;
186 state_.blend_color_alpha = alpha;
187 glBlendColor(red, green, blue, alpha);
189 return error::kNoError;
192 error::Error GLES2DecoderImpl::HandleBlendEquation(uint32_t immediate_data_size,
193 const void* cmd_data) {
194 const gles2::cmds::BlendEquation& c =
195 *static_cast<const gles2::cmds::BlendEquation*>(cmd_data);
196 (void)c;
197 GLenum mode = static_cast<GLenum>(c.mode);
198 if (!validators_->equation.IsValid(mode)) {
199 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode, "mode");
200 return error::kNoError;
202 if (state_.blend_equation_rgb != mode ||
203 state_.blend_equation_alpha != mode) {
204 state_.blend_equation_rgb = mode;
205 state_.blend_equation_alpha = mode;
206 glBlendEquation(mode);
208 return error::kNoError;
211 error::Error GLES2DecoderImpl::HandleBlendEquationSeparate(
212 uint32_t immediate_data_size,
213 const void* cmd_data) {
214 const gles2::cmds::BlendEquationSeparate& c =
215 *static_cast<const gles2::cmds::BlendEquationSeparate*>(cmd_data);
216 (void)c;
217 GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
218 GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
219 if (!validators_->equation.IsValid(modeRGB)) {
220 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB,
221 "modeRGB");
222 return error::kNoError;
224 if (!validators_->equation.IsValid(modeAlpha)) {
225 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha,
226 "modeAlpha");
227 return error::kNoError;
229 if (state_.blend_equation_rgb != modeRGB ||
230 state_.blend_equation_alpha != modeAlpha) {
231 state_.blend_equation_rgb = modeRGB;
232 state_.blend_equation_alpha = modeAlpha;
233 glBlendEquationSeparate(modeRGB, modeAlpha);
235 return error::kNoError;
238 error::Error GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size,
239 const void* cmd_data) {
240 const gles2::cmds::BlendFunc& c =
241 *static_cast<const gles2::cmds::BlendFunc*>(cmd_data);
242 (void)c;
243 GLenum sfactor = static_cast<GLenum>(c.sfactor);
244 GLenum dfactor = static_cast<GLenum>(c.dfactor);
245 if (!validators_->src_blend_factor.IsValid(sfactor)) {
246 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor, "sfactor");
247 return error::kNoError;
249 if (!validators_->dst_blend_factor.IsValid(dfactor)) {
250 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor, "dfactor");
251 return error::kNoError;
253 if (state_.blend_source_rgb != sfactor || state_.blend_dest_rgb != dfactor ||
254 state_.blend_source_alpha != sfactor ||
255 state_.blend_dest_alpha != dfactor) {
256 state_.blend_source_rgb = sfactor;
257 state_.blend_dest_rgb = dfactor;
258 state_.blend_source_alpha = sfactor;
259 state_.blend_dest_alpha = dfactor;
260 glBlendFunc(sfactor, dfactor);
262 return error::kNoError;
265 error::Error GLES2DecoderImpl::HandleBlendFuncSeparate(
266 uint32_t immediate_data_size,
267 const void* cmd_data) {
268 const gles2::cmds::BlendFuncSeparate& c =
269 *static_cast<const gles2::cmds::BlendFuncSeparate*>(cmd_data);
270 (void)c;
271 GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
272 GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
273 GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
274 GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
275 if (!validators_->src_blend_factor.IsValid(srcRGB)) {
276 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB, "srcRGB");
277 return error::kNoError;
279 if (!validators_->dst_blend_factor.IsValid(dstRGB)) {
280 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB, "dstRGB");
281 return error::kNoError;
283 if (!validators_->src_blend_factor.IsValid(srcAlpha)) {
284 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha,
285 "srcAlpha");
286 return error::kNoError;
288 if (!validators_->dst_blend_factor.IsValid(dstAlpha)) {
289 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha,
290 "dstAlpha");
291 return error::kNoError;
293 if (state_.blend_source_rgb != srcRGB || state_.blend_dest_rgb != dstRGB ||
294 state_.blend_source_alpha != srcAlpha ||
295 state_.blend_dest_alpha != dstAlpha) {
296 state_.blend_source_rgb = srcRGB;
297 state_.blend_dest_rgb = dstRGB;
298 state_.blend_source_alpha = srcAlpha;
299 state_.blend_dest_alpha = dstAlpha;
300 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
302 return error::kNoError;
305 error::Error GLES2DecoderImpl::HandleBufferSubData(uint32_t immediate_data_size,
306 const void* cmd_data) {
307 const gles2::cmds::BufferSubData& c =
308 *static_cast<const gles2::cmds::BufferSubData*>(cmd_data);
309 (void)c;
310 GLenum target = static_cast<GLenum>(c.target);
311 GLintptr offset = static_cast<GLintptr>(c.offset);
312 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
313 uint32_t data_size = size;
314 const void* data = GetSharedMemoryAs<const void*>(
315 c.data_shm_id, c.data_shm_offset, data_size);
316 if (!validators_->buffer_target.IsValid(target)) {
317 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target, "target");
318 return error::kNoError;
320 if (size < 0) {
321 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
322 return error::kNoError;
324 if (data == NULL) {
325 return error::kOutOfBounds;
327 DoBufferSubData(target, offset, size, data);
328 return error::kNoError;
331 error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus(
332 uint32_t immediate_data_size,
333 const void* cmd_data) {
334 const gles2::cmds::CheckFramebufferStatus& c =
335 *static_cast<const gles2::cmds::CheckFramebufferStatus*>(cmd_data);
336 (void)c;
337 GLenum target = static_cast<GLenum>(c.target);
338 typedef cmds::CheckFramebufferStatus::Result Result;
339 Result* result_dst = GetSharedMemoryAs<Result*>(
340 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
341 if (!result_dst) {
342 return error::kOutOfBounds;
344 if (!validators_->frame_buffer_target.IsValid(target)) {
345 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target,
346 "target");
347 return error::kNoError;
349 *result_dst = DoCheckFramebufferStatus(target);
350 return error::kNoError;
353 error::Error GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size,
354 const void* cmd_data) {
355 const gles2::cmds::Clear& c =
356 *static_cast<const gles2::cmds::Clear*>(cmd_data);
357 (void)c;
358 error::Error error;
359 error = WillAccessBoundFramebufferForDraw();
360 if (error != error::kNoError)
361 return error;
362 GLbitfield mask = static_cast<GLbitfield>(c.mask);
363 DoClear(mask);
364 return error::kNoError;
367 error::Error GLES2DecoderImpl::HandleClearBufferfi(uint32_t immediate_data_size,
368 const void* cmd_data) {
369 if (!unsafe_es3_apis_enabled())
370 return error::kUnknownCommand;
371 const gles2::cmds::ClearBufferfi& c =
372 *static_cast<const gles2::cmds::ClearBufferfi*>(cmd_data);
373 (void)c;
374 GLenum buffer = static_cast<GLenum>(c.buffer);
375 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
376 GLfloat depth = static_cast<GLfloat>(c.depth);
377 GLint stencil = static_cast<GLint>(c.stencil);
378 DoClearBufferfi(buffer, drawbuffers, depth, stencil);
379 return error::kNoError;
382 error::Error GLES2DecoderImpl::HandleClearBufferfvImmediate(
383 uint32_t immediate_data_size,
384 const void* cmd_data) {
385 if (!unsafe_es3_apis_enabled())
386 return error::kUnknownCommand;
387 const gles2::cmds::ClearBufferfvImmediate& c =
388 *static_cast<const gles2::cmds::ClearBufferfvImmediate*>(cmd_data);
389 (void)c;
390 GLenum buffer = static_cast<GLenum>(c.buffer);
391 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
392 uint32_t data_size;
393 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
394 return error::kOutOfBounds;
396 if (data_size > immediate_data_size) {
397 return error::kOutOfBounds;
399 const GLfloat* value =
400 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
401 if (value == NULL) {
402 return error::kOutOfBounds;
404 DoClearBufferfv(buffer, drawbuffers, value);
405 return error::kNoError;
408 error::Error GLES2DecoderImpl::HandleClearBufferivImmediate(
409 uint32_t immediate_data_size,
410 const void* cmd_data) {
411 if (!unsafe_es3_apis_enabled())
412 return error::kUnknownCommand;
413 const gles2::cmds::ClearBufferivImmediate& c =
414 *static_cast<const gles2::cmds::ClearBufferivImmediate*>(cmd_data);
415 (void)c;
416 GLenum buffer = static_cast<GLenum>(c.buffer);
417 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
418 uint32_t data_size;
419 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
420 return error::kOutOfBounds;
422 if (data_size > immediate_data_size) {
423 return error::kOutOfBounds;
425 const GLint* value =
426 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
427 if (value == NULL) {
428 return error::kOutOfBounds;
430 DoClearBufferiv(buffer, drawbuffers, value);
431 return error::kNoError;
434 error::Error GLES2DecoderImpl::HandleClearBufferuivImmediate(
435 uint32_t immediate_data_size,
436 const void* cmd_data) {
437 if (!unsafe_es3_apis_enabled())
438 return error::kUnknownCommand;
439 const gles2::cmds::ClearBufferuivImmediate& c =
440 *static_cast<const gles2::cmds::ClearBufferuivImmediate*>(cmd_data);
441 (void)c;
442 GLenum buffer = static_cast<GLenum>(c.buffer);
443 GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
444 uint32_t data_size;
445 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
446 return error::kOutOfBounds;
448 if (data_size > immediate_data_size) {
449 return error::kOutOfBounds;
451 const GLuint* value =
452 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
453 if (value == NULL) {
454 return error::kOutOfBounds;
456 DoClearBufferuiv(buffer, drawbuffers, value);
457 return error::kNoError;
460 error::Error GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size,
461 const void* cmd_data) {
462 const gles2::cmds::ClearColor& c =
463 *static_cast<const gles2::cmds::ClearColor*>(cmd_data);
464 (void)c;
465 GLclampf red = static_cast<GLclampf>(c.red);
466 GLclampf green = static_cast<GLclampf>(c.green);
467 GLclampf blue = static_cast<GLclampf>(c.blue);
468 GLclampf alpha = static_cast<GLclampf>(c.alpha);
469 if (state_.color_clear_red != red || state_.color_clear_green != green ||
470 state_.color_clear_blue != blue || state_.color_clear_alpha != alpha) {
471 state_.color_clear_red = red;
472 state_.color_clear_green = green;
473 state_.color_clear_blue = blue;
474 state_.color_clear_alpha = alpha;
475 glClearColor(red, green, blue, alpha);
477 return error::kNoError;
480 error::Error GLES2DecoderImpl::HandleClearDepthf(uint32_t immediate_data_size,
481 const void* cmd_data) {
482 const gles2::cmds::ClearDepthf& c =
483 *static_cast<const gles2::cmds::ClearDepthf*>(cmd_data);
484 (void)c;
485 GLclampf depth = static_cast<GLclampf>(c.depth);
486 if (state_.depth_clear != depth) {
487 state_.depth_clear = depth;
488 glClearDepth(depth);
490 return error::kNoError;
493 error::Error GLES2DecoderImpl::HandleClearStencil(uint32_t immediate_data_size,
494 const void* cmd_data) {
495 const gles2::cmds::ClearStencil& c =
496 *static_cast<const gles2::cmds::ClearStencil*>(cmd_data);
497 (void)c;
498 GLint s = static_cast<GLint>(c.s);
499 if (state_.stencil_clear != s) {
500 state_.stencil_clear = s;
501 glClearStencil(s);
503 return error::kNoError;
506 error::Error GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size,
507 const void* cmd_data) {
508 const gles2::cmds::ColorMask& c =
509 *static_cast<const gles2::cmds::ColorMask*>(cmd_data);
510 (void)c;
511 GLboolean red = static_cast<GLboolean>(c.red);
512 GLboolean green = static_cast<GLboolean>(c.green);
513 GLboolean blue = static_cast<GLboolean>(c.blue);
514 GLboolean alpha = static_cast<GLboolean>(c.alpha);
515 if (state_.color_mask_red != red || state_.color_mask_green != green ||
516 state_.color_mask_blue != blue || state_.color_mask_alpha != alpha) {
517 state_.color_mask_red = red;
518 state_.color_mask_green = green;
519 state_.color_mask_blue = blue;
520 state_.color_mask_alpha = alpha;
521 framebuffer_state_.clear_state_dirty = true;
523 return error::kNoError;
526 error::Error GLES2DecoderImpl::HandleCompileShader(uint32_t immediate_data_size,
527 const void* cmd_data) {
528 const gles2::cmds::CompileShader& c =
529 *static_cast<const gles2::cmds::CompileShader*>(cmd_data);
530 (void)c;
531 GLuint shader = c.shader;
532 DoCompileShader(shader);
533 return error::kNoError;
536 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2D(
537 uint32_t immediate_data_size,
538 const void* cmd_data) {
539 const gles2::cmds::CompressedTexSubImage2D& c =
540 *static_cast<const gles2::cmds::CompressedTexSubImage2D*>(cmd_data);
541 (void)c;
542 GLenum target = static_cast<GLenum>(c.target);
543 GLint level = static_cast<GLint>(c.level);
544 GLint xoffset = static_cast<GLint>(c.xoffset);
545 GLint yoffset = static_cast<GLint>(c.yoffset);
546 GLsizei width = static_cast<GLsizei>(c.width);
547 GLsizei height = static_cast<GLsizei>(c.height);
548 GLenum format = static_cast<GLenum>(c.format);
549 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
550 uint32_t data_size = imageSize;
551 const void* data = GetSharedMemoryAs<const void*>(
552 c.data_shm_id, c.data_shm_offset, data_size);
553 if (!validators_->texture_target.IsValid(target)) {
554 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", target,
555 "target");
556 return error::kNoError;
558 if (width < 0) {
559 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
560 "width < 0");
561 return error::kNoError;
563 if (height < 0) {
564 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
565 "height < 0");
566 return error::kNoError;
568 if (!validators_->compressed_texture_format.IsValid(format)) {
569 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", format,
570 "format");
571 return error::kNoError;
573 if (imageSize < 0) {
574 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
575 "imageSize < 0");
576 return error::kNoError;
578 if (data == NULL) {
579 return error::kOutOfBounds;
581 DoCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height,
582 format, imageSize, data);
583 return error::kNoError;
586 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage3D(
587 uint32_t immediate_data_size,
588 const void* cmd_data) {
589 if (!unsafe_es3_apis_enabled())
590 return error::kUnknownCommand;
591 const gles2::cmds::CompressedTexSubImage3D& c =
592 *static_cast<const gles2::cmds::CompressedTexSubImage3D*>(cmd_data);
593 (void)c;
594 GLenum target = static_cast<GLenum>(c.target);
595 GLint level = static_cast<GLint>(c.level);
596 GLint xoffset = static_cast<GLint>(c.xoffset);
597 GLint yoffset = static_cast<GLint>(c.yoffset);
598 GLint zoffset = static_cast<GLint>(c.zoffset);
599 GLsizei width = static_cast<GLsizei>(c.width);
600 GLsizei height = static_cast<GLsizei>(c.height);
601 GLsizei depth = static_cast<GLsizei>(c.depth);
602 GLenum format = static_cast<GLenum>(c.format);
603 GLsizei imageSize = static_cast<GLsizei>(c.imageSize);
604 uint32_t data_size = imageSize;
605 const void* data = GetSharedMemoryAs<const void*>(
606 c.data_shm_id, c.data_shm_offset, data_size);
607 if (data == NULL) {
608 return error::kOutOfBounds;
610 DoCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width,
611 height, depth, format, imageSize, data);
612 return error::kNoError;
615 error::Error GLES2DecoderImpl::HandleCopyBufferSubData(
616 uint32_t immediate_data_size,
617 const void* cmd_data) {
618 if (!unsafe_es3_apis_enabled())
619 return error::kUnknownCommand;
620 const gles2::cmds::CopyBufferSubData& c =
621 *static_cast<const gles2::cmds::CopyBufferSubData*>(cmd_data);
622 (void)c;
623 GLenum readtarget = static_cast<GLenum>(c.readtarget);
624 GLenum writetarget = static_cast<GLenum>(c.writetarget);
625 GLintptr readoffset = static_cast<GLintptr>(c.readoffset);
626 GLintptr writeoffset = static_cast<GLintptr>(c.writeoffset);
627 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
628 glCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
629 return error::kNoError;
632 error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
633 uint32_t immediate_data_size,
634 const void* cmd_data) {
635 const gles2::cmds::CopyTexImage2D& c =
636 *static_cast<const gles2::cmds::CopyTexImage2D*>(cmd_data);
637 (void)c;
638 error::Error error;
639 error = WillAccessBoundFramebufferForRead();
640 if (error != error::kNoError)
641 return error;
642 GLenum target = static_cast<GLenum>(c.target);
643 GLint level = static_cast<GLint>(c.level);
644 GLenum internalformat = static_cast<GLenum>(c.internalformat);
645 GLint x = static_cast<GLint>(c.x);
646 GLint y = static_cast<GLint>(c.y);
647 GLsizei width = static_cast<GLsizei>(c.width);
648 GLsizei height = static_cast<GLsizei>(c.height);
649 GLint border = static_cast<GLint>(c.border);
650 if (!validators_->texture_target.IsValid(target)) {
651 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target, "target");
652 return error::kNoError;
654 if (!validators_->texture_internal_format.IsValid(internalformat)) {
655 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat,
656 "internalformat");
657 return error::kNoError;
659 if (width < 0) {
660 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
661 return error::kNoError;
663 if (height < 0) {
664 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
665 return error::kNoError;
667 DoCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
668 return error::kNoError;
671 error::Error GLES2DecoderImpl::HandleCopyTexSubImage2D(
672 uint32_t immediate_data_size,
673 const void* cmd_data) {
674 const gles2::cmds::CopyTexSubImage2D& c =
675 *static_cast<const gles2::cmds::CopyTexSubImage2D*>(cmd_data);
676 (void)c;
677 error::Error error;
678 error = WillAccessBoundFramebufferForRead();
679 if (error != error::kNoError)
680 return error;
681 GLenum target = static_cast<GLenum>(c.target);
682 GLint level = static_cast<GLint>(c.level);
683 GLint xoffset = static_cast<GLint>(c.xoffset);
684 GLint yoffset = static_cast<GLint>(c.yoffset);
685 GLint x = static_cast<GLint>(c.x);
686 GLint y = static_cast<GLint>(c.y);
687 GLsizei width = static_cast<GLsizei>(c.width);
688 GLsizei height = static_cast<GLsizei>(c.height);
689 if (!validators_->texture_target.IsValid(target)) {
690 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target, "target");
691 return error::kNoError;
693 if (width < 0) {
694 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
695 return error::kNoError;
697 if (height < 0) {
698 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
699 return error::kNoError;
701 DoCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
702 return error::kNoError;
705 error::Error GLES2DecoderImpl::HandleCopyTexSubImage3D(
706 uint32_t immediate_data_size,
707 const void* cmd_data) {
708 if (!unsafe_es3_apis_enabled())
709 return error::kUnknownCommand;
710 const gles2::cmds::CopyTexSubImage3D& c =
711 *static_cast<const gles2::cmds::CopyTexSubImage3D*>(cmd_data);
712 (void)c;
713 error::Error error;
714 error = WillAccessBoundFramebufferForRead();
715 if (error != error::kNoError)
716 return error;
717 GLenum target = static_cast<GLenum>(c.target);
718 GLint level = static_cast<GLint>(c.level);
719 GLint xoffset = static_cast<GLint>(c.xoffset);
720 GLint yoffset = static_cast<GLint>(c.yoffset);
721 GLint zoffset = static_cast<GLint>(c.zoffset);
722 GLint x = static_cast<GLint>(c.x);
723 GLint y = static_cast<GLint>(c.y);
724 GLsizei width = static_cast<GLsizei>(c.width);
725 GLsizei height = static_cast<GLsizei>(c.height);
726 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
727 height);
728 return error::kNoError;
731 error::Error GLES2DecoderImpl::HandleCreateProgram(uint32_t immediate_data_size,
732 const void* cmd_data) {
733 const gles2::cmds::CreateProgram& c =
734 *static_cast<const gles2::cmds::CreateProgram*>(cmd_data);
735 (void)c;
736 uint32_t client_id = c.client_id;
737 if (GetProgram(client_id)) {
738 return error::kInvalidArguments;
740 GLuint service_id = glCreateProgram();
741 if (service_id) {
742 CreateProgram(client_id, service_id);
744 return error::kNoError;
747 error::Error GLES2DecoderImpl::HandleCreateShader(uint32_t immediate_data_size,
748 const void* cmd_data) {
749 const gles2::cmds::CreateShader& c =
750 *static_cast<const gles2::cmds::CreateShader*>(cmd_data);
751 (void)c;
752 GLenum type = static_cast<GLenum>(c.type);
753 if (!validators_->shader_type.IsValid(type)) {
754 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type, "type");
755 return error::kNoError;
757 uint32_t client_id = c.client_id;
758 if (GetShader(client_id)) {
759 return error::kInvalidArguments;
761 GLuint service_id = glCreateShader(type);
762 if (service_id) {
763 CreateShader(client_id, service_id, type);
765 return error::kNoError;
768 error::Error GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size,
769 const void* cmd_data) {
770 const gles2::cmds::CullFace& c =
771 *static_cast<const gles2::cmds::CullFace*>(cmd_data);
772 (void)c;
773 GLenum mode = static_cast<GLenum>(c.mode);
774 if (!validators_->face_type.IsValid(mode)) {
775 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode, "mode");
776 return error::kNoError;
778 if (state_.cull_mode != mode) {
779 state_.cull_mode = mode;
780 glCullFace(mode);
782 return error::kNoError;
785 error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
786 uint32_t immediate_data_size,
787 const void* cmd_data) {
788 const gles2::cmds::DeleteBuffersImmediate& c =
789 *static_cast<const gles2::cmds::DeleteBuffersImmediate*>(cmd_data);
790 (void)c;
791 GLsizei n = static_cast<GLsizei>(c.n);
792 uint32_t data_size;
793 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
794 return error::kOutOfBounds;
796 const GLuint* buffers =
797 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
798 if (buffers == NULL) {
799 return error::kOutOfBounds;
801 DeleteBuffersHelper(n, buffers);
802 return error::kNoError;
805 error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
806 uint32_t immediate_data_size,
807 const void* cmd_data) {
808 const gles2::cmds::DeleteFramebuffersImmediate& c =
809 *static_cast<const gles2::cmds::DeleteFramebuffersImmediate*>(cmd_data);
810 (void)c;
811 GLsizei n = static_cast<GLsizei>(c.n);
812 uint32_t data_size;
813 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
814 return error::kOutOfBounds;
816 const GLuint* framebuffers =
817 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
818 if (framebuffers == NULL) {
819 return error::kOutOfBounds;
821 DeleteFramebuffersHelper(n, framebuffers);
822 return error::kNoError;
825 error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
826 uint32_t immediate_data_size,
827 const void* cmd_data) {
828 const gles2::cmds::DeleteRenderbuffersImmediate& c =
829 *static_cast<const gles2::cmds::DeleteRenderbuffersImmediate*>(cmd_data);
830 (void)c;
831 GLsizei n = static_cast<GLsizei>(c.n);
832 uint32_t data_size;
833 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
834 return error::kOutOfBounds;
836 const GLuint* renderbuffers =
837 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
838 if (renderbuffers == NULL) {
839 return error::kOutOfBounds;
841 DeleteRenderbuffersHelper(n, renderbuffers);
842 return error::kNoError;
845 error::Error GLES2DecoderImpl::HandleDeleteSamplersImmediate(
846 uint32_t immediate_data_size,
847 const void* cmd_data) {
848 if (!unsafe_es3_apis_enabled())
849 return error::kUnknownCommand;
850 const gles2::cmds::DeleteSamplersImmediate& c =
851 *static_cast<const gles2::cmds::DeleteSamplersImmediate*>(cmd_data);
852 (void)c;
853 GLsizei n = static_cast<GLsizei>(c.n);
854 uint32_t data_size;
855 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
856 return error::kOutOfBounds;
858 const GLuint* samplers =
859 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
860 if (samplers == NULL) {
861 return error::kOutOfBounds;
863 for (GLsizei ii = 0; ii < n; ++ii) {
864 GLuint service_id = 0;
865 if (group_->GetSamplerServiceId(samplers[ii], &service_id)) {
866 glDeleteSamplers(1, &service_id);
867 group_->RemoveSamplerId(samplers[ii]);
870 return error::kNoError;
873 error::Error GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size,
874 const void* cmd_data) {
875 if (!unsafe_es3_apis_enabled())
876 return error::kUnknownCommand;
877 const gles2::cmds::DeleteSync& c =
878 *static_cast<const gles2::cmds::DeleteSync*>(cmd_data);
879 (void)c;
880 GLuint sync = c.sync;
881 GLsync service_id = 0;
882 if (group_->GetSyncServiceId(sync, &service_id)) {
883 glDeleteSync(service_id);
884 group_->RemoveSyncId(sync);
885 } else {
886 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDeleteSync", "unknown sync");
888 return error::kNoError;
891 error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
892 uint32_t immediate_data_size,
893 const void* cmd_data) {
894 const gles2::cmds::DeleteTexturesImmediate& c =
895 *static_cast<const gles2::cmds::DeleteTexturesImmediate*>(cmd_data);
896 (void)c;
897 GLsizei n = static_cast<GLsizei>(c.n);
898 uint32_t data_size;
899 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
900 return error::kOutOfBounds;
902 const GLuint* textures =
903 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
904 if (textures == NULL) {
905 return error::kOutOfBounds;
907 DeleteTexturesHelper(n, textures);
908 return error::kNoError;
911 error::Error GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
912 uint32_t immediate_data_size,
913 const void* cmd_data) {
914 if (!unsafe_es3_apis_enabled())
915 return error::kUnknownCommand;
916 const gles2::cmds::DeleteTransformFeedbacksImmediate& c =
917 *static_cast<const gles2::cmds::DeleteTransformFeedbacksImmediate*>(
918 cmd_data);
919 (void)c;
920 GLsizei n = static_cast<GLsizei>(c.n);
921 uint32_t data_size;
922 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
923 return error::kOutOfBounds;
925 const GLuint* ids =
926 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
927 if (ids == NULL) {
928 return error::kOutOfBounds;
930 for (GLsizei ii = 0; ii < n; ++ii) {
931 GLuint service_id = 0;
932 if (group_->GetTransformFeedbackServiceId(ids[ii], &service_id)) {
933 glDeleteTransformFeedbacks(1, &service_id);
934 group_->RemoveTransformFeedbackId(ids[ii]);
937 return error::kNoError;
940 error::Error GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size,
941 const void* cmd_data) {
942 const gles2::cmds::DepthFunc& c =
943 *static_cast<const gles2::cmds::DepthFunc*>(cmd_data);
944 (void)c;
945 GLenum func = static_cast<GLenum>(c.func);
946 if (!validators_->cmp_function.IsValid(func)) {
947 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func, "func");
948 return error::kNoError;
950 if (state_.depth_func != func) {
951 state_.depth_func = func;
952 glDepthFunc(func);
954 return error::kNoError;
957 error::Error GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size,
958 const void* cmd_data) {
959 const gles2::cmds::DepthMask& c =
960 *static_cast<const gles2::cmds::DepthMask*>(cmd_data);
961 (void)c;
962 GLboolean flag = static_cast<GLboolean>(c.flag);
963 if (state_.depth_mask != flag) {
964 state_.depth_mask = flag;
965 framebuffer_state_.clear_state_dirty = true;
967 return error::kNoError;
970 error::Error GLES2DecoderImpl::HandleDepthRangef(uint32_t immediate_data_size,
971 const void* cmd_data) {
972 const gles2::cmds::DepthRangef& c =
973 *static_cast<const gles2::cmds::DepthRangef*>(cmd_data);
974 (void)c;
975 GLclampf zNear = static_cast<GLclampf>(c.zNear);
976 GLclampf zFar = static_cast<GLclampf>(c.zFar);
977 DoDepthRangef(zNear, zFar);
978 return error::kNoError;
981 error::Error GLES2DecoderImpl::HandleDetachShader(uint32_t immediate_data_size,
982 const void* cmd_data) {
983 const gles2::cmds::DetachShader& c =
984 *static_cast<const gles2::cmds::DetachShader*>(cmd_data);
985 (void)c;
986 GLuint program = c.program;
987 GLuint shader = c.shader;
988 DoDetachShader(program, shader);
989 return error::kNoError;
992 error::Error GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size,
993 const void* cmd_data) {
994 const gles2::cmds::Disable& c =
995 *static_cast<const gles2::cmds::Disable*>(cmd_data);
996 (void)c;
997 GLenum cap = static_cast<GLenum>(c.cap);
998 if (!validators_->capability.IsValid(cap)) {
999 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap, "cap");
1000 return error::kNoError;
1002 DoDisable(cap);
1003 return error::kNoError;
1006 error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
1007 uint32_t immediate_data_size,
1008 const void* cmd_data) {
1009 const gles2::cmds::DisableVertexAttribArray& c =
1010 *static_cast<const gles2::cmds::DisableVertexAttribArray*>(cmd_data);
1011 (void)c;
1012 GLuint index = static_cast<GLuint>(c.index);
1013 DoDisableVertexAttribArray(index);
1014 return error::kNoError;
1017 error::Error GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size,
1018 const void* cmd_data) {
1019 const gles2::cmds::Enable& c =
1020 *static_cast<const gles2::cmds::Enable*>(cmd_data);
1021 (void)c;
1022 GLenum cap = static_cast<GLenum>(c.cap);
1023 if (!validators_->capability.IsValid(cap)) {
1024 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap, "cap");
1025 return error::kNoError;
1027 DoEnable(cap);
1028 return error::kNoError;
1031 error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
1032 uint32_t immediate_data_size,
1033 const void* cmd_data) {
1034 const gles2::cmds::EnableVertexAttribArray& c =
1035 *static_cast<const gles2::cmds::EnableVertexAttribArray*>(cmd_data);
1036 (void)c;
1037 GLuint index = static_cast<GLuint>(c.index);
1038 DoEnableVertexAttribArray(index);
1039 return error::kNoError;
1042 error::Error GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size,
1043 const void* cmd_data) {
1044 if (!unsafe_es3_apis_enabled())
1045 return error::kUnknownCommand;
1046 const gles2::cmds::FenceSync& c =
1047 *static_cast<const gles2::cmds::FenceSync*>(cmd_data);
1048 (void)c;
1049 GLenum condition = static_cast<GLenum>(c.condition);
1050 GLbitfield flags = static_cast<GLbitfield>(c.flags);
1051 uint32_t client_id = c.client_id;
1052 GLsync service_id = 0;
1053 if (group_->GetSyncServiceId(client_id, &service_id)) {
1054 return error::kInvalidArguments;
1056 service_id = glFenceSync(condition, flags);
1057 if (service_id) {
1058 group_->AddSyncId(client_id, service_id);
1060 return error::kNoError;
1063 error::Error GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size,
1064 const void* cmd_data) {
1065 const gles2::cmds::Finish& c =
1066 *static_cast<const gles2::cmds::Finish*>(cmd_data);
1067 (void)c;
1068 error::Error error;
1069 error = WillAccessBoundFramebufferForRead();
1070 if (error != error::kNoError)
1071 return error;
1072 DoFinish();
1073 return error::kNoError;
1076 error::Error GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size,
1077 const void* cmd_data) {
1078 const gles2::cmds::Flush& c =
1079 *static_cast<const gles2::cmds::Flush*>(cmd_data);
1080 (void)c;
1081 DoFlush();
1082 return error::kNoError;
1085 error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
1086 uint32_t immediate_data_size,
1087 const void* cmd_data) {
1088 const gles2::cmds::FramebufferRenderbuffer& c =
1089 *static_cast<const gles2::cmds::FramebufferRenderbuffer*>(cmd_data);
1090 (void)c;
1091 GLenum target = static_cast<GLenum>(c.target);
1092 GLenum attachment = static_cast<GLenum>(c.attachment);
1093 GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
1094 GLuint renderbuffer = c.renderbuffer;
1095 if (!validators_->frame_buffer_target.IsValid(target)) {
1096 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target,
1097 "target");
1098 return error::kNoError;
1100 if (!validators_->attachment.IsValid(attachment)) {
1101 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment,
1102 "attachment");
1103 return error::kNoError;
1105 if (!validators_->render_buffer_target.IsValid(renderbuffertarget)) {
1106 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
1107 renderbuffertarget, "renderbuffertarget");
1108 return error::kNoError;
1110 DoFramebufferRenderbuffer(target, attachment, renderbuffertarget,
1111 renderbuffer);
1112 return error::kNoError;
1115 error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
1116 uint32_t immediate_data_size,
1117 const void* cmd_data) {
1118 const gles2::cmds::FramebufferTexture2D& c =
1119 *static_cast<const gles2::cmds::FramebufferTexture2D*>(cmd_data);
1120 (void)c;
1121 GLenum target = static_cast<GLenum>(c.target);
1122 GLenum attachment = static_cast<GLenum>(c.attachment);
1123 GLenum textarget = static_cast<GLenum>(c.textarget);
1124 GLuint texture = c.texture;
1125 GLint level = static_cast<GLint>(c.level);
1126 if (!validators_->frame_buffer_target.IsValid(target)) {
1127 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target, "target");
1128 return error::kNoError;
1130 if (!validators_->attachment.IsValid(attachment)) {
1131 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment,
1132 "attachment");
1133 return error::kNoError;
1135 if (!validators_->texture_target.IsValid(textarget)) {
1136 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget,
1137 "textarget");
1138 return error::kNoError;
1140 DoFramebufferTexture2D(target, attachment, textarget, texture, level);
1141 return error::kNoError;
1144 error::Error GLES2DecoderImpl::HandleFramebufferTextureLayer(
1145 uint32_t immediate_data_size,
1146 const void* cmd_data) {
1147 if (!unsafe_es3_apis_enabled())
1148 return error::kUnknownCommand;
1149 const gles2::cmds::FramebufferTextureLayer& c =
1150 *static_cast<const gles2::cmds::FramebufferTextureLayer*>(cmd_data);
1151 (void)c;
1152 GLenum target = static_cast<GLenum>(c.target);
1153 GLenum attachment = static_cast<GLenum>(c.attachment);
1154 GLuint texture = c.texture;
1155 GLint level = static_cast<GLint>(c.level);
1156 GLint layer = static_cast<GLint>(c.layer);
1157 DoFramebufferTextureLayer(target, attachment, texture, level, layer);
1158 return error::kNoError;
1161 error::Error GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size,
1162 const void* cmd_data) {
1163 const gles2::cmds::FrontFace& c =
1164 *static_cast<const gles2::cmds::FrontFace*>(cmd_data);
1165 (void)c;
1166 GLenum mode = static_cast<GLenum>(c.mode);
1167 if (!validators_->face_mode.IsValid(mode)) {
1168 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode, "mode");
1169 return error::kNoError;
1171 if (state_.front_face != mode) {
1172 state_.front_face = mode;
1173 glFrontFace(mode);
1175 return error::kNoError;
1178 error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
1179 uint32_t immediate_data_size,
1180 const void* cmd_data) {
1181 const gles2::cmds::GenBuffersImmediate& c =
1182 *static_cast<const gles2::cmds::GenBuffersImmediate*>(cmd_data);
1183 (void)c;
1184 GLsizei n = static_cast<GLsizei>(c.n);
1185 uint32_t data_size;
1186 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1187 return error::kOutOfBounds;
1189 GLuint* buffers =
1190 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1191 if (buffers == NULL) {
1192 return error::kOutOfBounds;
1194 if (!GenBuffersHelper(n, buffers)) {
1195 return error::kInvalidArguments;
1197 return error::kNoError;
1200 error::Error GLES2DecoderImpl::HandleGenerateMipmap(
1201 uint32_t immediate_data_size,
1202 const void* cmd_data) {
1203 const gles2::cmds::GenerateMipmap& c =
1204 *static_cast<const gles2::cmds::GenerateMipmap*>(cmd_data);
1205 (void)c;
1206 GLenum target = static_cast<GLenum>(c.target);
1207 if (!validators_->texture_bind_target.IsValid(target)) {
1208 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target, "target");
1209 return error::kNoError;
1211 DoGenerateMipmap(target);
1212 return error::kNoError;
1215 error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
1216 uint32_t immediate_data_size,
1217 const void* cmd_data) {
1218 const gles2::cmds::GenFramebuffersImmediate& c =
1219 *static_cast<const gles2::cmds::GenFramebuffersImmediate*>(cmd_data);
1220 (void)c;
1221 GLsizei n = static_cast<GLsizei>(c.n);
1222 uint32_t data_size;
1223 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1224 return error::kOutOfBounds;
1226 GLuint* framebuffers =
1227 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1228 if (framebuffers == NULL) {
1229 return error::kOutOfBounds;
1231 if (!GenFramebuffersHelper(n, framebuffers)) {
1232 return error::kInvalidArguments;
1234 return error::kNoError;
1237 error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
1238 uint32_t immediate_data_size,
1239 const void* cmd_data) {
1240 const gles2::cmds::GenRenderbuffersImmediate& c =
1241 *static_cast<const gles2::cmds::GenRenderbuffersImmediate*>(cmd_data);
1242 (void)c;
1243 GLsizei n = static_cast<GLsizei>(c.n);
1244 uint32_t data_size;
1245 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1246 return error::kOutOfBounds;
1248 GLuint* renderbuffers =
1249 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1250 if (renderbuffers == NULL) {
1251 return error::kOutOfBounds;
1253 if (!GenRenderbuffersHelper(n, renderbuffers)) {
1254 return error::kInvalidArguments;
1256 return error::kNoError;
1259 error::Error GLES2DecoderImpl::HandleGenSamplersImmediate(
1260 uint32_t immediate_data_size,
1261 const void* cmd_data) {
1262 if (!unsafe_es3_apis_enabled())
1263 return error::kUnknownCommand;
1264 const gles2::cmds::GenSamplersImmediate& c =
1265 *static_cast<const gles2::cmds::GenSamplersImmediate*>(cmd_data);
1266 (void)c;
1267 GLsizei n = static_cast<GLsizei>(c.n);
1268 uint32_t data_size;
1269 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1270 return error::kOutOfBounds;
1272 GLuint* samplers =
1273 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1274 if (samplers == NULL) {
1275 return error::kOutOfBounds;
1277 for (GLsizei ii = 0; ii < n; ++ii) {
1278 if (group_->GetSamplerServiceId(samplers[ii], NULL)) {
1279 return error::kInvalidArguments;
1282 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1283 glGenSamplers(n, service_ids.get());
1284 for (GLsizei ii = 0; ii < n; ++ii) {
1285 group_->AddSamplerId(samplers[ii], service_ids[ii]);
1287 return error::kNoError;
1290 error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
1291 uint32_t immediate_data_size,
1292 const void* cmd_data) {
1293 const gles2::cmds::GenTexturesImmediate& c =
1294 *static_cast<const gles2::cmds::GenTexturesImmediate*>(cmd_data);
1295 (void)c;
1296 GLsizei n = static_cast<GLsizei>(c.n);
1297 uint32_t data_size;
1298 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1299 return error::kOutOfBounds;
1301 GLuint* textures =
1302 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1303 if (textures == NULL) {
1304 return error::kOutOfBounds;
1306 if (!GenTexturesHelper(n, textures)) {
1307 return error::kInvalidArguments;
1309 return error::kNoError;
1312 error::Error GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
1313 uint32_t immediate_data_size,
1314 const void* cmd_data) {
1315 if (!unsafe_es3_apis_enabled())
1316 return error::kUnknownCommand;
1317 const gles2::cmds::GenTransformFeedbacksImmediate& c =
1318 *static_cast<const gles2::cmds::GenTransformFeedbacksImmediate*>(
1319 cmd_data);
1320 (void)c;
1321 GLsizei n = static_cast<GLsizei>(c.n);
1322 uint32_t data_size;
1323 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
1324 return error::kOutOfBounds;
1326 GLuint* ids = GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
1327 if (ids == NULL) {
1328 return error::kOutOfBounds;
1330 for (GLsizei ii = 0; ii < n; ++ii) {
1331 if (group_->GetTransformFeedbackServiceId(ids[ii], NULL)) {
1332 return error::kInvalidArguments;
1335 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
1336 glGenTransformFeedbacks(n, service_ids.get());
1337 for (GLsizei ii = 0; ii < n; ++ii) {
1338 group_->AddTransformFeedbackId(ids[ii], service_ids[ii]);
1340 return error::kNoError;
1343 error::Error GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size,
1344 const void* cmd_data) {
1345 const gles2::cmds::GetBooleanv& c =
1346 *static_cast<const gles2::cmds::GetBooleanv*>(cmd_data);
1347 (void)c;
1348 GLenum pname = static_cast<GLenum>(c.pname);
1349 typedef cmds::GetBooleanv::Result Result;
1350 GLsizei num_values = 0;
1351 GetNumValuesReturnedForGLGet(pname, &num_values);
1352 Result* result = GetSharedMemoryAs<Result*>(
1353 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1354 GLboolean* params = result ? result->GetData() : NULL;
1355 if (!validators_->g_l_state.IsValid(pname)) {
1356 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname, "pname");
1357 return error::kNoError;
1359 if (params == NULL) {
1360 return error::kOutOfBounds;
1362 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
1363 // Check that the client initialized the result.
1364 if (result->size != 0) {
1365 return error::kInvalidArguments;
1367 DoGetBooleanv(pname, params);
1368 GLenum error = LOCAL_PEEK_GL_ERROR("GetBooleanv");
1369 if (error == GL_NO_ERROR) {
1370 result->SetNumResults(num_values);
1372 return error::kNoError;
1375 error::Error GLES2DecoderImpl::HandleGetBufferParameteri64v(
1376 uint32_t immediate_data_size,
1377 const void* cmd_data) {
1378 if (!unsafe_es3_apis_enabled())
1379 return error::kUnknownCommand;
1380 const gles2::cmds::GetBufferParameteri64v& c =
1381 *static_cast<const gles2::cmds::GetBufferParameteri64v*>(cmd_data);
1382 (void)c;
1383 GLenum target = static_cast<GLenum>(c.target);
1384 GLenum pname = static_cast<GLenum>(c.pname);
1385 typedef cmds::GetBufferParameteri64v::Result Result;
1386 GLsizei num_values = 0;
1387 GetNumValuesReturnedForGLGet(pname, &num_values);
1388 Result* result = GetSharedMemoryAs<Result*>(
1389 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1390 GLint64* params = result ? result->GetData() : NULL;
1391 if (params == NULL) {
1392 return error::kOutOfBounds;
1394 // Check that the client initialized the result.
1395 if (result->size != 0) {
1396 return error::kInvalidArguments;
1398 DoGetBufferParameteri64v(target, pname, params);
1399 result->SetNumResults(num_values);
1400 return error::kNoError;
1402 error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
1403 uint32_t immediate_data_size,
1404 const void* cmd_data) {
1405 const gles2::cmds::GetBufferParameteriv& c =
1406 *static_cast<const gles2::cmds::GetBufferParameteriv*>(cmd_data);
1407 (void)c;
1408 GLenum target = static_cast<GLenum>(c.target);
1409 GLenum pname = static_cast<GLenum>(c.pname);
1410 typedef cmds::GetBufferParameteriv::Result Result;
1411 GLsizei num_values = 0;
1412 GetNumValuesReturnedForGLGet(pname, &num_values);
1413 Result* result = GetSharedMemoryAs<Result*>(
1414 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1415 GLint* params = result ? result->GetData() : NULL;
1416 if (!validators_->buffer_target.IsValid(target)) {
1417 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
1418 return error::kNoError;
1420 if (!validators_->buffer_parameter.IsValid(pname)) {
1421 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
1422 return error::kNoError;
1424 if (params == NULL) {
1425 return error::kOutOfBounds;
1427 // Check that the client initialized the result.
1428 if (result->size != 0) {
1429 return error::kInvalidArguments;
1431 DoGetBufferParameteriv(target, pname, params);
1432 result->SetNumResults(num_values);
1433 return error::kNoError;
1435 error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
1436 const void* cmd_data) {
1437 const gles2::cmds::GetError& c =
1438 *static_cast<const gles2::cmds::GetError*>(cmd_data);
1439 (void)c;
1440 typedef cmds::GetError::Result Result;
1441 Result* result_dst = GetSharedMemoryAs<Result*>(
1442 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
1443 if (!result_dst) {
1444 return error::kOutOfBounds;
1446 *result_dst = GetErrorState()->GetGLError();
1447 return error::kNoError;
1450 error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
1451 const void* cmd_data) {
1452 const gles2::cmds::GetFloatv& c =
1453 *static_cast<const gles2::cmds::GetFloatv*>(cmd_data);
1454 (void)c;
1455 GLenum pname = static_cast<GLenum>(c.pname);
1456 typedef cmds::GetFloatv::Result Result;
1457 GLsizei num_values = 0;
1458 GetNumValuesReturnedForGLGet(pname, &num_values);
1459 Result* result = GetSharedMemoryAs<Result*>(
1460 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1461 GLfloat* params = result ? result->GetData() : NULL;
1462 if (!validators_->g_l_state.IsValid(pname)) {
1463 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
1464 return error::kNoError;
1466 if (params == NULL) {
1467 return error::kOutOfBounds;
1469 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1470 // Check that the client initialized the result.
1471 if (result->size != 0) {
1472 return error::kInvalidArguments;
1474 DoGetFloatv(pname, params);
1475 GLenum error = LOCAL_PEEK_GL_ERROR("GetFloatv");
1476 if (error == GL_NO_ERROR) {
1477 result->SetNumResults(num_values);
1479 return error::kNoError;
1482 error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1483 uint32_t immediate_data_size,
1484 const void* cmd_data) {
1485 const gles2::cmds::GetFramebufferAttachmentParameteriv& c =
1486 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv*>(
1487 cmd_data);
1488 (void)c;
1489 GLenum target = static_cast<GLenum>(c.target);
1490 GLenum attachment = static_cast<GLenum>(c.attachment);
1491 GLenum pname = static_cast<GLenum>(c.pname);
1492 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
1493 GLsizei num_values = 0;
1494 GetNumValuesReturnedForGLGet(pname, &num_values);
1495 Result* result = GetSharedMemoryAs<Result*>(
1496 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1497 GLint* params = result ? result->GetData() : NULL;
1498 if (!validators_->frame_buffer_target.IsValid(target)) {
1499 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1500 target, "target");
1501 return error::kNoError;
1503 if (!validators_->attachment.IsValid(attachment)) {
1504 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1505 attachment, "attachment");
1506 return error::kNoError;
1508 if (!validators_->frame_buffer_parameter.IsValid(pname)) {
1509 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1510 pname, "pname");
1511 return error::kNoError;
1513 if (params == NULL) {
1514 return error::kOutOfBounds;
1516 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1517 // Check that the client initialized the result.
1518 if (result->size != 0) {
1519 return error::kInvalidArguments;
1521 DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1522 GLenum error = LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv");
1523 if (error == GL_NO_ERROR) {
1524 result->SetNumResults(num_values);
1526 return error::kNoError;
1529 error::Error GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size,
1530 const void* cmd_data) {
1531 if (!unsafe_es3_apis_enabled())
1532 return error::kUnknownCommand;
1533 const gles2::cmds::GetInteger64v& c =
1534 *static_cast<const gles2::cmds::GetInteger64v*>(cmd_data);
1535 (void)c;
1536 GLenum pname = static_cast<GLenum>(c.pname);
1537 typedef cmds::GetInteger64v::Result Result;
1538 GLsizei num_values = 0;
1539 GetNumValuesReturnedForGLGet(pname, &num_values);
1540 Result* result = GetSharedMemoryAs<Result*>(
1541 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1542 GLint64* params = result ? result->GetData() : NULL;
1543 if (params == NULL) {
1544 return error::kOutOfBounds;
1546 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
1547 // Check that the client initialized the result.
1548 if (result->size != 0) {
1549 return error::kInvalidArguments;
1551 DoGetInteger64v(pname, params);
1552 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64v");
1553 if (error == GL_NO_ERROR) {
1554 result->SetNumResults(num_values);
1556 return error::kNoError;
1559 error::Error GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size,
1560 const void* cmd_data) {
1561 if (!unsafe_es3_apis_enabled())
1562 return error::kUnknownCommand;
1563 const gles2::cmds::GetIntegeri_v& c =
1564 *static_cast<const gles2::cmds::GetIntegeri_v*>(cmd_data);
1565 (void)c;
1566 GLenum pname = static_cast<GLenum>(c.pname);
1567 GLuint index = static_cast<GLuint>(c.index);
1568 typedef cmds::GetIntegeri_v::Result Result;
1569 GLsizei num_values = 0;
1570 GetNumValuesReturnedForGLGet(pname, &num_values);
1571 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1572 Result::ComputeSize(num_values));
1573 GLint* data = result ? result->GetData() : NULL;
1574 if (data == NULL) {
1575 return error::kOutOfBounds;
1577 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegeri_v");
1578 // Check that the client initialized the result.
1579 if (result->size != 0) {
1580 return error::kInvalidArguments;
1582 glGetIntegeri_v(pname, index, data);
1583 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegeri_v");
1584 if (error == GL_NO_ERROR) {
1585 result->SetNumResults(num_values);
1587 return error::kNoError;
1590 error::Error GLES2DecoderImpl::HandleGetInteger64i_v(
1591 uint32_t immediate_data_size,
1592 const void* cmd_data) {
1593 if (!unsafe_es3_apis_enabled())
1594 return error::kUnknownCommand;
1595 const gles2::cmds::GetInteger64i_v& c =
1596 *static_cast<const gles2::cmds::GetInteger64i_v*>(cmd_data);
1597 (void)c;
1598 GLenum pname = static_cast<GLenum>(c.pname);
1599 GLuint index = static_cast<GLuint>(c.index);
1600 typedef cmds::GetInteger64i_v::Result Result;
1601 GLsizei num_values = 0;
1602 GetNumValuesReturnedForGLGet(pname, &num_values);
1603 Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
1604 Result::ComputeSize(num_values));
1605 GLint64* data = result ? result->GetData() : NULL;
1606 if (data == NULL) {
1607 return error::kOutOfBounds;
1609 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64i_v");
1610 // Check that the client initialized the result.
1611 if (result->size != 0) {
1612 return error::kInvalidArguments;
1614 glGetInteger64i_v(pname, index, data);
1615 GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64i_v");
1616 if (error == GL_NO_ERROR) {
1617 result->SetNumResults(num_values);
1619 return error::kNoError;
1622 error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size,
1623 const void* cmd_data) {
1624 const gles2::cmds::GetIntegerv& c =
1625 *static_cast<const gles2::cmds::GetIntegerv*>(cmd_data);
1626 (void)c;
1627 GLenum pname = static_cast<GLenum>(c.pname);
1628 typedef cmds::GetIntegerv::Result Result;
1629 GLsizei num_values = 0;
1630 GetNumValuesReturnedForGLGet(pname, &num_values);
1631 Result* result = GetSharedMemoryAs<Result*>(
1632 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1633 GLint* params = result ? result->GetData() : NULL;
1634 if (!validators_->g_l_state.IsValid(pname)) {
1635 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
1636 return error::kNoError;
1638 if (params == NULL) {
1639 return error::kOutOfBounds;
1641 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1642 // Check that the client initialized the result.
1643 if (result->size != 0) {
1644 return error::kInvalidArguments;
1646 DoGetIntegerv(pname, params);
1647 GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegerv");
1648 if (error == GL_NO_ERROR) {
1649 result->SetNumResults(num_values);
1651 return error::kNoError;
1654 error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size,
1655 const void* cmd_data) {
1656 const gles2::cmds::GetProgramiv& c =
1657 *static_cast<const gles2::cmds::GetProgramiv*>(cmd_data);
1658 (void)c;
1659 GLuint program = c.program;
1660 GLenum pname = static_cast<GLenum>(c.pname);
1661 typedef cmds::GetProgramiv::Result Result;
1662 GLsizei num_values = 0;
1663 GetNumValuesReturnedForGLGet(pname, &num_values);
1664 Result* result = GetSharedMemoryAs<Result*>(
1665 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1666 GLint* params = result ? result->GetData() : NULL;
1667 if (!validators_->program_parameter.IsValid(pname)) {
1668 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
1669 return error::kNoError;
1671 if (params == NULL) {
1672 return error::kOutOfBounds;
1674 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1675 // Check that the client initialized the result.
1676 if (result->size != 0) {
1677 return error::kInvalidArguments;
1679 DoGetProgramiv(program, pname, params);
1680 GLenum error = LOCAL_PEEK_GL_ERROR("GetProgramiv");
1681 if (error == GL_NO_ERROR) {
1682 result->SetNumResults(num_values);
1684 return error::kNoError;
1687 error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1688 uint32_t immediate_data_size,
1689 const void* cmd_data) {
1690 const gles2::cmds::GetRenderbufferParameteriv& c =
1691 *static_cast<const gles2::cmds::GetRenderbufferParameteriv*>(cmd_data);
1692 (void)c;
1693 GLenum target = static_cast<GLenum>(c.target);
1694 GLenum pname = static_cast<GLenum>(c.pname);
1695 typedef cmds::GetRenderbufferParameteriv::Result Result;
1696 GLsizei num_values = 0;
1697 GetNumValuesReturnedForGLGet(pname, &num_values);
1698 Result* result = GetSharedMemoryAs<Result*>(
1699 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1700 GLint* params = result ? result->GetData() : NULL;
1701 if (!validators_->render_buffer_target.IsValid(target)) {
1702 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
1703 "target");
1704 return error::kNoError;
1706 if (!validators_->render_buffer_parameter.IsValid(pname)) {
1707 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
1708 "pname");
1709 return error::kNoError;
1711 if (params == NULL) {
1712 return error::kOutOfBounds;
1714 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1715 // Check that the client initialized the result.
1716 if (result->size != 0) {
1717 return error::kInvalidArguments;
1719 DoGetRenderbufferParameteriv(target, pname, params);
1720 GLenum error = LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv");
1721 if (error == GL_NO_ERROR) {
1722 result->SetNumResults(num_values);
1724 return error::kNoError;
1727 error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
1728 uint32_t immediate_data_size,
1729 const void* cmd_data) {
1730 if (!unsafe_es3_apis_enabled())
1731 return error::kUnknownCommand;
1732 const gles2::cmds::GetSamplerParameterfv& c =
1733 *static_cast<const gles2::cmds::GetSamplerParameterfv*>(cmd_data);
1734 (void)c;
1735 GLuint sampler = c.sampler;
1736 GLenum pname = static_cast<GLenum>(c.pname);
1737 typedef cmds::GetSamplerParameterfv::Result Result;
1738 GLsizei num_values = 0;
1739 GetNumValuesReturnedForGLGet(pname, &num_values);
1740 Result* result = GetSharedMemoryAs<Result*>(
1741 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1742 GLfloat* params = result ? result->GetData() : NULL;
1743 if (params == NULL) {
1744 return error::kOutOfBounds;
1746 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1747 // Check that the client initialized the result.
1748 if (result->size != 0) {
1749 return error::kInvalidArguments;
1751 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1752 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameterfv",
1753 "invalid sampler id");
1754 return error::kNoError;
1756 glGetSamplerParameterfv(sampler, pname, params);
1757 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv");
1758 if (error == GL_NO_ERROR) {
1759 result->SetNumResults(num_values);
1761 return error::kNoError;
1764 error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
1765 uint32_t immediate_data_size,
1766 const void* cmd_data) {
1767 if (!unsafe_es3_apis_enabled())
1768 return error::kUnknownCommand;
1769 const gles2::cmds::GetSamplerParameteriv& c =
1770 *static_cast<const gles2::cmds::GetSamplerParameteriv*>(cmd_data);
1771 (void)c;
1772 GLuint sampler = c.sampler;
1773 GLenum pname = static_cast<GLenum>(c.pname);
1774 typedef cmds::GetSamplerParameteriv::Result Result;
1775 GLsizei num_values = 0;
1776 GetNumValuesReturnedForGLGet(pname, &num_values);
1777 Result* result = GetSharedMemoryAs<Result*>(
1778 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1779 GLint* params = result ? result->GetData() : NULL;
1780 if (params == NULL) {
1781 return error::kOutOfBounds;
1783 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1784 // Check that the client initialized the result.
1785 if (result->size != 0) {
1786 return error::kInvalidArguments;
1788 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
1789 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSamplerParameteriv",
1790 "invalid sampler id");
1791 return error::kNoError;
1793 glGetSamplerParameteriv(sampler, pname, params);
1794 GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv");
1795 if (error == GL_NO_ERROR) {
1796 result->SetNumResults(num_values);
1798 return error::kNoError;
1801 error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size,
1802 const void* cmd_data) {
1803 const gles2::cmds::GetShaderiv& c =
1804 *static_cast<const gles2::cmds::GetShaderiv*>(cmd_data);
1805 (void)c;
1806 GLuint shader = c.shader;
1807 GLenum pname = static_cast<GLenum>(c.pname);
1808 typedef cmds::GetShaderiv::Result Result;
1809 GLsizei num_values = 0;
1810 GetNumValuesReturnedForGLGet(pname, &num_values);
1811 Result* result = GetSharedMemoryAs<Result*>(
1812 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1813 GLint* params = result ? result->GetData() : NULL;
1814 if (!validators_->shader_parameter.IsValid(pname)) {
1815 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
1816 return error::kNoError;
1818 if (params == NULL) {
1819 return error::kOutOfBounds;
1821 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1822 // Check that the client initialized the result.
1823 if (result->size != 0) {
1824 return error::kInvalidArguments;
1826 DoGetShaderiv(shader, pname, params);
1827 GLenum error = LOCAL_PEEK_GL_ERROR("GetShaderiv");
1828 if (error == GL_NO_ERROR) {
1829 result->SetNumResults(num_values);
1831 return error::kNoError;
1834 error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
1835 const void* cmd_data) {
1836 if (!unsafe_es3_apis_enabled())
1837 return error::kUnknownCommand;
1838 const gles2::cmds::GetSynciv& c =
1839 *static_cast<const gles2::cmds::GetSynciv*>(cmd_data);
1840 (void)c;
1841 GLuint sync = static_cast<GLuint>(c.sync);
1842 GLenum pname = static_cast<GLenum>(c.pname);
1843 typedef cmds::GetSynciv::Result Result;
1844 GLsizei num_values = 0;
1845 GetNumValuesReturnedForGLGet(pname, &num_values);
1846 Result* result = GetSharedMemoryAs<Result*>(
1847 c.values_shm_id, c.values_shm_offset, Result::ComputeSize(num_values));
1848 GLint* values = result ? result->GetData() : NULL;
1849 if (values == NULL) {
1850 return error::kOutOfBounds;
1852 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1853 // Check that the client initialized the result.
1854 if (result->size != 0) {
1855 return error::kInvalidArguments;
1857 GLsync service_sync = 0;
1858 if (!group_->GetSyncServiceId(sync, &service_sync)) {
1859 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetSynciv", "invalid sync id");
1860 return error::kNoError;
1862 glGetSynciv(service_sync, pname, num_values, nullptr, values);
1863 GLenum error = LOCAL_PEEK_GL_ERROR("GetSynciv");
1864 if (error == GL_NO_ERROR) {
1865 result->SetNumResults(num_values);
1867 return error::kNoError;
1870 error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
1871 uint32_t immediate_data_size,
1872 const void* cmd_data) {
1873 const gles2::cmds::GetTexParameterfv& c =
1874 *static_cast<const gles2::cmds::GetTexParameterfv*>(cmd_data);
1875 (void)c;
1876 GLenum target = static_cast<GLenum>(c.target);
1877 GLenum pname = static_cast<GLenum>(c.pname);
1878 typedef cmds::GetTexParameterfv::Result Result;
1879 GLsizei num_values = 0;
1880 GetNumValuesReturnedForGLGet(pname, &num_values);
1881 Result* result = GetSharedMemoryAs<Result*>(
1882 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1883 GLfloat* params = result ? result->GetData() : NULL;
1884 if (!validators_->get_tex_param_target.IsValid(target)) {
1885 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
1886 return error::kNoError;
1888 if (!validators_->texture_parameter.IsValid(pname)) {
1889 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
1890 return error::kNoError;
1892 if (params == NULL) {
1893 return error::kOutOfBounds;
1895 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1896 // Check that the client initialized the result.
1897 if (result->size != 0) {
1898 return error::kInvalidArguments;
1900 DoGetTexParameterfv(target, pname, params);
1901 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameterfv");
1902 if (error == GL_NO_ERROR) {
1903 result->SetNumResults(num_values);
1905 return error::kNoError;
1908 error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
1909 uint32_t immediate_data_size,
1910 const void* cmd_data) {
1911 const gles2::cmds::GetTexParameteriv& c =
1912 *static_cast<const gles2::cmds::GetTexParameteriv*>(cmd_data);
1913 (void)c;
1914 GLenum target = static_cast<GLenum>(c.target);
1915 GLenum pname = static_cast<GLenum>(c.pname);
1916 typedef cmds::GetTexParameteriv::Result Result;
1917 GLsizei num_values = 0;
1918 GetNumValuesReturnedForGLGet(pname, &num_values);
1919 Result* result = GetSharedMemoryAs<Result*>(
1920 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1921 GLint* params = result ? result->GetData() : NULL;
1922 if (!validators_->get_tex_param_target.IsValid(target)) {
1923 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
1924 return error::kNoError;
1926 if (!validators_->texture_parameter.IsValid(pname)) {
1927 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
1928 return error::kNoError;
1930 if (params == NULL) {
1931 return error::kOutOfBounds;
1933 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1934 // Check that the client initialized the result.
1935 if (result->size != 0) {
1936 return error::kInvalidArguments;
1938 DoGetTexParameteriv(target, pname, params);
1939 GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameteriv");
1940 if (error == GL_NO_ERROR) {
1941 result->SetNumResults(num_values);
1943 return error::kNoError;
1946 error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
1947 uint32_t immediate_data_size,
1948 const void* cmd_data) {
1949 const gles2::cmds::GetVertexAttribfv& c =
1950 *static_cast<const gles2::cmds::GetVertexAttribfv*>(cmd_data);
1951 (void)c;
1952 GLuint index = static_cast<GLuint>(c.index);
1953 GLenum pname = static_cast<GLenum>(c.pname);
1954 typedef cmds::GetVertexAttribfv::Result Result;
1955 GLsizei num_values = 0;
1956 GetNumValuesReturnedForGLGet(pname, &num_values);
1957 Result* result = GetSharedMemoryAs<Result*>(
1958 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1959 GLfloat* params = result ? result->GetData() : NULL;
1960 if (!validators_->vertex_attribute.IsValid(pname)) {
1961 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
1962 return error::kNoError;
1964 if (params == NULL) {
1965 return error::kOutOfBounds;
1967 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1968 // Check that the client initialized the result.
1969 if (result->size != 0) {
1970 return error::kInvalidArguments;
1972 DoGetVertexAttribfv(index, pname, params);
1973 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribfv");
1974 if (error == GL_NO_ERROR) {
1975 result->SetNumResults(num_values);
1977 return error::kNoError;
1980 error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
1981 uint32_t immediate_data_size,
1982 const void* cmd_data) {
1983 const gles2::cmds::GetVertexAttribiv& c =
1984 *static_cast<const gles2::cmds::GetVertexAttribiv*>(cmd_data);
1985 (void)c;
1986 GLuint index = static_cast<GLuint>(c.index);
1987 GLenum pname = static_cast<GLenum>(c.pname);
1988 typedef cmds::GetVertexAttribiv::Result Result;
1989 GLsizei num_values = 0;
1990 GetNumValuesReturnedForGLGet(pname, &num_values);
1991 Result* result = GetSharedMemoryAs<Result*>(
1992 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
1993 GLint* params = result ? result->GetData() : NULL;
1994 if (!validators_->vertex_attribute.IsValid(pname)) {
1995 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
1996 return error::kNoError;
1998 if (params == NULL) {
1999 return error::kOutOfBounds;
2001 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
2002 // Check that the client initialized the result.
2003 if (result->size != 0) {
2004 return error::kInvalidArguments;
2006 DoGetVertexAttribiv(index, pname, params);
2007 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribiv");
2008 if (error == GL_NO_ERROR) {
2009 result->SetNumResults(num_values);
2011 return error::kNoError;
2014 error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv(
2015 uint32_t immediate_data_size,
2016 const void* cmd_data) {
2017 if (!unsafe_es3_apis_enabled())
2018 return error::kUnknownCommand;
2019 const gles2::cmds::GetVertexAttribIiv& c =
2020 *static_cast<const gles2::cmds::GetVertexAttribIiv*>(cmd_data);
2021 (void)c;
2022 GLuint index = static_cast<GLuint>(c.index);
2023 GLenum pname = static_cast<GLenum>(c.pname);
2024 typedef cmds::GetVertexAttribIiv::Result Result;
2025 GLsizei num_values = 0;
2026 GetNumValuesReturnedForGLGet(pname, &num_values);
2027 Result* result = GetSharedMemoryAs<Result*>(
2028 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2029 GLint* params = result ? result->GetData() : NULL;
2030 if (params == NULL) {
2031 return error::kOutOfBounds;
2033 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
2034 // Check that the client initialized the result.
2035 if (result->size != 0) {
2036 return error::kInvalidArguments;
2038 DoGetVertexAttribIiv(index, pname, params);
2039 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv");
2040 if (error == GL_NO_ERROR) {
2041 result->SetNumResults(num_values);
2043 return error::kNoError;
2046 error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv(
2047 uint32_t immediate_data_size,
2048 const void* cmd_data) {
2049 if (!unsafe_es3_apis_enabled())
2050 return error::kUnknownCommand;
2051 const gles2::cmds::GetVertexAttribIuiv& c =
2052 *static_cast<const gles2::cmds::GetVertexAttribIuiv*>(cmd_data);
2053 (void)c;
2054 GLuint index = static_cast<GLuint>(c.index);
2055 GLenum pname = static_cast<GLenum>(c.pname);
2056 typedef cmds::GetVertexAttribIuiv::Result Result;
2057 GLsizei num_values = 0;
2058 GetNumValuesReturnedForGLGet(pname, &num_values);
2059 Result* result = GetSharedMemoryAs<Result*>(
2060 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values));
2061 GLuint* params = result ? result->GetData() : NULL;
2062 if (params == NULL) {
2063 return error::kOutOfBounds;
2065 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
2066 // Check that the client initialized the result.
2067 if (result->size != 0) {
2068 return error::kInvalidArguments;
2070 DoGetVertexAttribIuiv(index, pname, params);
2071 GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv");
2072 if (error == GL_NO_ERROR) {
2073 result->SetNumResults(num_values);
2075 return error::kNoError;
2078 error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
2079 const void* cmd_data) {
2080 const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data);
2081 (void)c;
2082 GLenum target = static_cast<GLenum>(c.target);
2083 GLenum mode = static_cast<GLenum>(c.mode);
2084 if (!validators_->hint_target.IsValid(target)) {
2085 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
2086 return error::kNoError;
2088 if (!validators_->hint_mode.IsValid(mode)) {
2089 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
2090 return error::kNoError;
2092 switch (target) {
2093 case GL_GENERATE_MIPMAP_HINT:
2094 if (state_.hint_generate_mipmap != mode) {
2095 state_.hint_generate_mipmap = mode;
2096 glHint(target, mode);
2098 break;
2099 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
2100 if (state_.hint_fragment_shader_derivative != mode) {
2101 state_.hint_fragment_shader_derivative = mode;
2102 glHint(target, mode);
2104 break;
2105 default:
2106 NOTREACHED();
2108 return error::kNoError;
2111 error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
2112 uint32_t immediate_data_size,
2113 const void* cmd_data) {
2114 if (!unsafe_es3_apis_enabled())
2115 return error::kUnknownCommand;
2116 const gles2::cmds::InvalidateFramebufferImmediate& c =
2117 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate*>(
2118 cmd_data);
2119 (void)c;
2120 GLenum target = static_cast<GLenum>(c.target);
2121 GLsizei count = static_cast<GLsizei>(c.count);
2122 uint32_t data_size;
2123 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2124 return error::kOutOfBounds;
2126 if (data_size > immediate_data_size) {
2127 return error::kOutOfBounds;
2129 const GLenum* attachments =
2130 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2131 if (attachments == NULL) {
2132 return error::kOutOfBounds;
2134 glInvalidateFramebuffer(target, count, attachments);
2135 return error::kNoError;
2138 error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2139 uint32_t immediate_data_size,
2140 const void* cmd_data) {
2141 if (!unsafe_es3_apis_enabled())
2142 return error::kUnknownCommand;
2143 const gles2::cmds::InvalidateSubFramebufferImmediate& c =
2144 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate*>(
2145 cmd_data);
2146 (void)c;
2147 GLenum target = static_cast<GLenum>(c.target);
2148 GLsizei count = static_cast<GLsizei>(c.count);
2149 uint32_t data_size;
2150 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
2151 return error::kOutOfBounds;
2153 if (data_size > immediate_data_size) {
2154 return error::kOutOfBounds;
2156 const GLenum* attachments =
2157 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
2158 GLint x = static_cast<GLint>(c.x);
2159 GLint y = static_cast<GLint>(c.y);
2160 GLsizei width = static_cast<GLsizei>(c.width);
2161 GLsizei height = static_cast<GLsizei>(c.height);
2162 if (attachments == NULL) {
2163 return error::kOutOfBounds;
2165 glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height);
2166 return error::kNoError;
2169 error::Error GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size,
2170 const void* cmd_data) {
2171 const gles2::cmds::IsBuffer& c =
2172 *static_cast<const gles2::cmds::IsBuffer*>(cmd_data);
2173 (void)c;
2174 GLuint buffer = c.buffer;
2175 typedef cmds::IsBuffer::Result Result;
2176 Result* result_dst = GetSharedMemoryAs<Result*>(
2177 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2178 if (!result_dst) {
2179 return error::kOutOfBounds;
2181 *result_dst = DoIsBuffer(buffer);
2182 return error::kNoError;
2185 error::Error GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size,
2186 const void* cmd_data) {
2187 const gles2::cmds::IsEnabled& c =
2188 *static_cast<const gles2::cmds::IsEnabled*>(cmd_data);
2189 (void)c;
2190 GLenum cap = static_cast<GLenum>(c.cap);
2191 typedef cmds::IsEnabled::Result Result;
2192 Result* result_dst = GetSharedMemoryAs<Result*>(
2193 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2194 if (!result_dst) {
2195 return error::kOutOfBounds;
2197 if (!validators_->capability.IsValid(cap)) {
2198 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap, "cap");
2199 return error::kNoError;
2201 *result_dst = DoIsEnabled(cap);
2202 return error::kNoError;
2205 error::Error GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size,
2206 const void* cmd_data) {
2207 const gles2::cmds::IsFramebuffer& c =
2208 *static_cast<const gles2::cmds::IsFramebuffer*>(cmd_data);
2209 (void)c;
2210 GLuint framebuffer = c.framebuffer;
2211 typedef cmds::IsFramebuffer::Result Result;
2212 Result* result_dst = GetSharedMemoryAs<Result*>(
2213 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2214 if (!result_dst) {
2215 return error::kOutOfBounds;
2217 *result_dst = DoIsFramebuffer(framebuffer);
2218 return error::kNoError;
2221 error::Error GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size,
2222 const void* cmd_data) {
2223 const gles2::cmds::IsProgram& c =
2224 *static_cast<const gles2::cmds::IsProgram*>(cmd_data);
2225 (void)c;
2226 GLuint program = c.program;
2227 typedef cmds::IsProgram::Result Result;
2228 Result* result_dst = GetSharedMemoryAs<Result*>(
2229 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2230 if (!result_dst) {
2231 return error::kOutOfBounds;
2233 *result_dst = DoIsProgram(program);
2234 return error::kNoError;
2237 error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
2238 uint32_t immediate_data_size,
2239 const void* cmd_data) {
2240 const gles2::cmds::IsRenderbuffer& c =
2241 *static_cast<const gles2::cmds::IsRenderbuffer*>(cmd_data);
2242 (void)c;
2243 GLuint renderbuffer = c.renderbuffer;
2244 typedef cmds::IsRenderbuffer::Result Result;
2245 Result* result_dst = GetSharedMemoryAs<Result*>(
2246 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2247 if (!result_dst) {
2248 return error::kOutOfBounds;
2250 *result_dst = DoIsRenderbuffer(renderbuffer);
2251 return error::kNoError;
2254 error::Error GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size,
2255 const void* cmd_data) {
2256 if (!unsafe_es3_apis_enabled())
2257 return error::kUnknownCommand;
2258 const gles2::cmds::IsSampler& c =
2259 *static_cast<const gles2::cmds::IsSampler*>(cmd_data);
2260 (void)c;
2261 GLuint sampler = c.sampler;
2262 typedef cmds::IsSampler::Result Result;
2263 Result* result_dst = GetSharedMemoryAs<Result*>(
2264 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2265 if (!result_dst) {
2266 return error::kOutOfBounds;
2268 GLuint service_sampler = 0;
2269 *result_dst = group_->GetSamplerServiceId(sampler, &service_sampler);
2270 return error::kNoError;
2273 error::Error GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size,
2274 const void* cmd_data) {
2275 const gles2::cmds::IsShader& c =
2276 *static_cast<const gles2::cmds::IsShader*>(cmd_data);
2277 (void)c;
2278 GLuint shader = c.shader;
2279 typedef cmds::IsShader::Result Result;
2280 Result* result_dst = GetSharedMemoryAs<Result*>(
2281 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2282 if (!result_dst) {
2283 return error::kOutOfBounds;
2285 *result_dst = DoIsShader(shader);
2286 return error::kNoError;
2289 error::Error GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size,
2290 const void* cmd_data) {
2291 if (!unsafe_es3_apis_enabled())
2292 return error::kUnknownCommand;
2293 const gles2::cmds::IsSync& c =
2294 *static_cast<const gles2::cmds::IsSync*>(cmd_data);
2295 (void)c;
2296 GLuint sync = c.sync;
2297 typedef cmds::IsSync::Result Result;
2298 Result* result_dst = GetSharedMemoryAs<Result*>(
2299 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2300 if (!result_dst) {
2301 return error::kOutOfBounds;
2303 GLsync service_sync = 0;
2304 *result_dst = group_->GetSyncServiceId(sync, &service_sync);
2305 return error::kNoError;
2308 error::Error GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size,
2309 const void* cmd_data) {
2310 const gles2::cmds::IsTexture& c =
2311 *static_cast<const gles2::cmds::IsTexture*>(cmd_data);
2312 (void)c;
2313 GLuint texture = c.texture;
2314 typedef cmds::IsTexture::Result Result;
2315 Result* result_dst = GetSharedMemoryAs<Result*>(
2316 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2317 if (!result_dst) {
2318 return error::kOutOfBounds;
2320 *result_dst = DoIsTexture(texture);
2321 return error::kNoError;
2324 error::Error GLES2DecoderImpl::HandleIsTransformFeedback(
2325 uint32_t immediate_data_size,
2326 const void* cmd_data) {
2327 if (!unsafe_es3_apis_enabled())
2328 return error::kUnknownCommand;
2329 const gles2::cmds::IsTransformFeedback& c =
2330 *static_cast<const gles2::cmds::IsTransformFeedback*>(cmd_data);
2331 (void)c;
2332 GLuint transformfeedback = c.transformfeedback;
2333 typedef cmds::IsTransformFeedback::Result Result;
2334 Result* result_dst = GetSharedMemoryAs<Result*>(
2335 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
2336 if (!result_dst) {
2337 return error::kOutOfBounds;
2339 GLuint service_transformfeedback = 0;
2340 *result_dst = group_->GetTransformFeedbackServiceId(
2341 transformfeedback, &service_transformfeedback);
2342 return error::kNoError;
2345 error::Error GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size,
2346 const void* cmd_data) {
2347 const gles2::cmds::LineWidth& c =
2348 *static_cast<const gles2::cmds::LineWidth*>(cmd_data);
2349 (void)c;
2350 GLfloat width = static_cast<GLfloat>(c.width);
2351 if (width <= 0.0f || std::isnan(width)) {
2352 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "LineWidth", "width out of range");
2353 return error::kNoError;
2355 if (state_.line_width != width) {
2356 state_.line_width = width;
2357 glLineWidth(width);
2359 return error::kNoError;
2362 error::Error GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size,
2363 const void* cmd_data) {
2364 const gles2::cmds::LinkProgram& c =
2365 *static_cast<const gles2::cmds::LinkProgram*>(cmd_data);
2366 (void)c;
2367 GLuint program = c.program;
2368 DoLinkProgram(program);
2369 return error::kNoError;
2372 error::Error GLES2DecoderImpl::HandlePauseTransformFeedback(
2373 uint32_t immediate_data_size,
2374 const void* cmd_data) {
2375 if (!unsafe_es3_apis_enabled())
2376 return error::kUnknownCommand;
2377 const gles2::cmds::PauseTransformFeedback& c =
2378 *static_cast<const gles2::cmds::PauseTransformFeedback*>(cmd_data);
2379 (void)c;
2380 glPauseTransformFeedback();
2381 return error::kNoError;
2384 error::Error GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size,
2385 const void* cmd_data) {
2386 const gles2::cmds::PolygonOffset& c =
2387 *static_cast<const gles2::cmds::PolygonOffset*>(cmd_data);
2388 (void)c;
2389 GLfloat factor = static_cast<GLfloat>(c.factor);
2390 GLfloat units = static_cast<GLfloat>(c.units);
2391 if (state_.polygon_offset_factor != factor ||
2392 state_.polygon_offset_units != units) {
2393 state_.polygon_offset_factor = factor;
2394 state_.polygon_offset_units = units;
2395 glPolygonOffset(factor, units);
2397 return error::kNoError;
2400 error::Error GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size,
2401 const void* cmd_data) {
2402 if (!unsafe_es3_apis_enabled())
2403 return error::kUnknownCommand;
2404 const gles2::cmds::ReadBuffer& c =
2405 *static_cast<const gles2::cmds::ReadBuffer*>(cmd_data);
2406 (void)c;
2407 GLenum src = static_cast<GLenum>(c.src);
2408 DoReadBuffer(src);
2409 return error::kNoError;
2412 error::Error GLES2DecoderImpl::HandleReleaseShaderCompiler(
2413 uint32_t immediate_data_size,
2414 const void* cmd_data) {
2415 const gles2::cmds::ReleaseShaderCompiler& c =
2416 *static_cast<const gles2::cmds::ReleaseShaderCompiler*>(cmd_data);
2417 (void)c;
2418 DoReleaseShaderCompiler();
2419 return error::kNoError;
2422 error::Error GLES2DecoderImpl::HandleRenderbufferStorage(
2423 uint32_t immediate_data_size,
2424 const void* cmd_data) {
2425 const gles2::cmds::RenderbufferStorage& c =
2426 *static_cast<const gles2::cmds::RenderbufferStorage*>(cmd_data);
2427 (void)c;
2428 GLenum target = static_cast<GLenum>(c.target);
2429 GLenum internalformat = static_cast<GLenum>(c.internalformat);
2430 GLsizei width = static_cast<GLsizei>(c.width);
2431 GLsizei height = static_cast<GLsizei>(c.height);
2432 if (!validators_->render_buffer_target.IsValid(target)) {
2433 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target, "target");
2434 return error::kNoError;
2436 if (!validators_->render_buffer_format.IsValid(internalformat)) {
2437 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat,
2438 "internalformat");
2439 return error::kNoError;
2441 if (width < 0) {
2442 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
2443 return error::kNoError;
2445 if (height < 0) {
2446 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
2447 return error::kNoError;
2449 DoRenderbufferStorage(target, internalformat, width, height);
2450 return error::kNoError;
2453 error::Error GLES2DecoderImpl::HandleResumeTransformFeedback(
2454 uint32_t immediate_data_size,
2455 const void* cmd_data) {
2456 if (!unsafe_es3_apis_enabled())
2457 return error::kUnknownCommand;
2458 const gles2::cmds::ResumeTransformFeedback& c =
2459 *static_cast<const gles2::cmds::ResumeTransformFeedback*>(cmd_data);
2460 (void)c;
2461 glResumeTransformFeedback();
2462 return error::kNoError;
2465 error::Error GLES2DecoderImpl::HandleSampleCoverage(
2466 uint32_t immediate_data_size,
2467 const void* cmd_data) {
2468 const gles2::cmds::SampleCoverage& c =
2469 *static_cast<const gles2::cmds::SampleCoverage*>(cmd_data);
2470 (void)c;
2471 GLclampf value = static_cast<GLclampf>(c.value);
2472 GLboolean invert = static_cast<GLboolean>(c.invert);
2473 DoSampleCoverage(value, invert);
2474 return error::kNoError;
2477 error::Error GLES2DecoderImpl::HandleSamplerParameterf(
2478 uint32_t immediate_data_size,
2479 const void* cmd_data) {
2480 if (!unsafe_es3_apis_enabled())
2481 return error::kUnknownCommand;
2482 const gles2::cmds::SamplerParameterf& c =
2483 *static_cast<const gles2::cmds::SamplerParameterf*>(cmd_data);
2484 (void)c;
2485 GLuint sampler = c.sampler;
2486 GLenum pname = static_cast<GLenum>(c.pname);
2487 GLfloat param = static_cast<GLfloat>(c.param);
2488 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2489 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameterf",
2490 "invalid sampler id");
2491 return error::kNoError;
2493 glSamplerParameterf(sampler, pname, param);
2494 return error::kNoError;
2497 error::Error GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2498 uint32_t immediate_data_size,
2499 const void* cmd_data) {
2500 if (!unsafe_es3_apis_enabled())
2501 return error::kUnknownCommand;
2502 const gles2::cmds::SamplerParameterfvImmediate& c =
2503 *static_cast<const gles2::cmds::SamplerParameterfvImmediate*>(cmd_data);
2504 (void)c;
2505 GLuint sampler = c.sampler;
2506 GLenum pname = static_cast<GLenum>(c.pname);
2507 uint32_t data_size;
2508 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2509 return error::kOutOfBounds;
2511 if (data_size > immediate_data_size) {
2512 return error::kOutOfBounds;
2514 const GLfloat* params =
2515 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2516 if (params == NULL) {
2517 return error::kOutOfBounds;
2519 group_->GetSamplerServiceId(sampler, &sampler);
2520 DoSamplerParameterfv(sampler, pname, params);
2521 return error::kNoError;
2524 error::Error GLES2DecoderImpl::HandleSamplerParameteri(
2525 uint32_t immediate_data_size,
2526 const void* cmd_data) {
2527 if (!unsafe_es3_apis_enabled())
2528 return error::kUnknownCommand;
2529 const gles2::cmds::SamplerParameteri& c =
2530 *static_cast<const gles2::cmds::SamplerParameteri*>(cmd_data);
2531 (void)c;
2532 GLuint sampler = c.sampler;
2533 GLenum pname = static_cast<GLenum>(c.pname);
2534 GLint param = static_cast<GLint>(c.param);
2535 if (!group_->GetSamplerServiceId(sampler, &sampler)) {
2536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSamplerParameteri",
2537 "invalid sampler id");
2538 return error::kNoError;
2540 glSamplerParameteri(sampler, pname, param);
2541 return error::kNoError;
2544 error::Error GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2545 uint32_t immediate_data_size,
2546 const void* cmd_data) {
2547 if (!unsafe_es3_apis_enabled())
2548 return error::kUnknownCommand;
2549 const gles2::cmds::SamplerParameterivImmediate& c =
2550 *static_cast<const gles2::cmds::SamplerParameterivImmediate*>(cmd_data);
2551 (void)c;
2552 GLuint sampler = c.sampler;
2553 GLenum pname = static_cast<GLenum>(c.pname);
2554 uint32_t data_size;
2555 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2556 return error::kOutOfBounds;
2558 if (data_size > immediate_data_size) {
2559 return error::kOutOfBounds;
2561 const GLint* params =
2562 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2563 if (params == NULL) {
2564 return error::kOutOfBounds;
2566 DoSamplerParameteriv(sampler, pname, params);
2567 return error::kNoError;
2570 error::Error GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size,
2571 const void* cmd_data) {
2572 const gles2::cmds::Scissor& c =
2573 *static_cast<const gles2::cmds::Scissor*>(cmd_data);
2574 (void)c;
2575 GLint x = static_cast<GLint>(c.x);
2576 GLint y = static_cast<GLint>(c.y);
2577 GLsizei width = static_cast<GLsizei>(c.width);
2578 GLsizei height = static_cast<GLsizei>(c.height);
2579 if (width < 0) {
2580 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "width < 0");
2581 return error::kNoError;
2583 if (height < 0) {
2584 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScissor", "height < 0");
2585 return error::kNoError;
2587 if (state_.scissor_x != x || state_.scissor_y != y ||
2588 state_.scissor_width != width || state_.scissor_height != height) {
2589 state_.scissor_x = x;
2590 state_.scissor_y = y;
2591 state_.scissor_width = width;
2592 state_.scissor_height = height;
2593 glScissor(x, y, width, height);
2595 return error::kNoError;
2598 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2599 uint32_t immediate_data_size,
2600 const void* cmd_data) {
2601 const gles2::cmds::ShaderSourceBucket& c =
2602 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data);
2603 (void)c;
2604 GLuint shader = static_cast<GLuint>(c.shader);
2606 Bucket* bucket = GetBucket(c.str_bucket_id);
2607 if (!bucket) {
2608 return error::kInvalidArguments;
2610 GLsizei count = 0;
2611 std::vector<char*> strs;
2612 std::vector<GLint> len;
2613 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2614 return error::kInvalidArguments;
2616 const char** str =
2617 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2618 const GLint* length =
2619 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2620 (void)length;
2621 DoShaderSource(shader, count, str, length);
2622 return error::kNoError;
2625 error::Error GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size,
2626 const void* cmd_data) {
2627 const gles2::cmds::StencilFunc& c =
2628 *static_cast<const gles2::cmds::StencilFunc*>(cmd_data);
2629 (void)c;
2630 GLenum func = static_cast<GLenum>(c.func);
2631 GLint ref = static_cast<GLint>(c.ref);
2632 GLuint mask = static_cast<GLuint>(c.mask);
2633 if (!validators_->cmp_function.IsValid(func)) {
2634 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func, "func");
2635 return error::kNoError;
2637 if (state_.stencil_front_func != func || state_.stencil_front_ref != ref ||
2638 state_.stencil_front_mask != mask || state_.stencil_back_func != func ||
2639 state_.stencil_back_ref != ref || state_.stencil_back_mask != mask) {
2640 state_.stencil_front_func = func;
2641 state_.stencil_front_ref = ref;
2642 state_.stencil_front_mask = mask;
2643 state_.stencil_back_func = func;
2644 state_.stencil_back_ref = ref;
2645 state_.stencil_back_mask = mask;
2646 glStencilFunc(func, ref, mask);
2648 return error::kNoError;
2651 error::Error GLES2DecoderImpl::HandleStencilFuncSeparate(
2652 uint32_t immediate_data_size,
2653 const void* cmd_data) {
2654 const gles2::cmds::StencilFuncSeparate& c =
2655 *static_cast<const gles2::cmds::StencilFuncSeparate*>(cmd_data);
2656 (void)c;
2657 GLenum face = static_cast<GLenum>(c.face);
2658 GLenum func = static_cast<GLenum>(c.func);
2659 GLint ref = static_cast<GLint>(c.ref);
2660 GLuint mask = static_cast<GLuint>(c.mask);
2661 if (!validators_->face_type.IsValid(face)) {
2662 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face, "face");
2663 return error::kNoError;
2665 if (!validators_->cmp_function.IsValid(func)) {
2666 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func, "func");
2667 return error::kNoError;
2669 bool changed = false;
2670 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2671 changed |= 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 changed |= state_.stencil_back_func != func ||
2677 state_.stencil_back_ref != ref ||
2678 state_.stencil_back_mask != mask;
2680 if (changed) {
2681 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2682 state_.stencil_front_func = func;
2683 state_.stencil_front_ref = ref;
2684 state_.stencil_front_mask = mask;
2686 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2687 state_.stencil_back_func = func;
2688 state_.stencil_back_ref = ref;
2689 state_.stencil_back_mask = mask;
2691 glStencilFuncSeparate(face, func, ref, mask);
2693 return error::kNoError;
2696 error::Error GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size,
2697 const void* cmd_data) {
2698 const gles2::cmds::StencilMask& c =
2699 *static_cast<const gles2::cmds::StencilMask*>(cmd_data);
2700 (void)c;
2701 GLuint mask = static_cast<GLuint>(c.mask);
2702 if (state_.stencil_front_writemask != mask ||
2703 state_.stencil_back_writemask != mask) {
2704 state_.stencil_front_writemask = mask;
2705 state_.stencil_back_writemask = mask;
2706 framebuffer_state_.clear_state_dirty = true;
2708 return error::kNoError;
2711 error::Error GLES2DecoderImpl::HandleStencilMaskSeparate(
2712 uint32_t immediate_data_size,
2713 const void* cmd_data) {
2714 const gles2::cmds::StencilMaskSeparate& c =
2715 *static_cast<const gles2::cmds::StencilMaskSeparate*>(cmd_data);
2716 (void)c;
2717 GLenum face = static_cast<GLenum>(c.face);
2718 GLuint mask = static_cast<GLuint>(c.mask);
2719 if (!validators_->face_type.IsValid(face)) {
2720 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face, "face");
2721 return error::kNoError;
2723 bool changed = false;
2724 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2725 changed |= state_.stencil_front_writemask != mask;
2727 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2728 changed |= state_.stencil_back_writemask != mask;
2730 if (changed) {
2731 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2732 state_.stencil_front_writemask = mask;
2734 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2735 state_.stencil_back_writemask = mask;
2737 framebuffer_state_.clear_state_dirty = true;
2739 return error::kNoError;
2742 error::Error GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size,
2743 const void* cmd_data) {
2744 const gles2::cmds::StencilOp& c =
2745 *static_cast<const gles2::cmds::StencilOp*>(cmd_data);
2746 (void)c;
2747 GLenum fail = static_cast<GLenum>(c.fail);
2748 GLenum zfail = static_cast<GLenum>(c.zfail);
2749 GLenum zpass = static_cast<GLenum>(c.zpass);
2750 if (!validators_->stencil_op.IsValid(fail)) {
2751 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail, "fail");
2752 return error::kNoError;
2754 if (!validators_->stencil_op.IsValid(zfail)) {
2755 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail, "zfail");
2756 return error::kNoError;
2758 if (!validators_->stencil_op.IsValid(zpass)) {
2759 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass, "zpass");
2760 return error::kNoError;
2762 if (state_.stencil_front_fail_op != fail ||
2763 state_.stencil_front_z_fail_op != zfail ||
2764 state_.stencil_front_z_pass_op != zpass ||
2765 state_.stencil_back_fail_op != fail ||
2766 state_.stencil_back_z_fail_op != zfail ||
2767 state_.stencil_back_z_pass_op != zpass) {
2768 state_.stencil_front_fail_op = fail;
2769 state_.stencil_front_z_fail_op = zfail;
2770 state_.stencil_front_z_pass_op = zpass;
2771 state_.stencil_back_fail_op = fail;
2772 state_.stencil_back_z_fail_op = zfail;
2773 state_.stencil_back_z_pass_op = zpass;
2774 glStencilOp(fail, zfail, zpass);
2776 return error::kNoError;
2779 error::Error GLES2DecoderImpl::HandleStencilOpSeparate(
2780 uint32_t immediate_data_size,
2781 const void* cmd_data) {
2782 const gles2::cmds::StencilOpSeparate& c =
2783 *static_cast<const gles2::cmds::StencilOpSeparate*>(cmd_data);
2784 (void)c;
2785 GLenum face = static_cast<GLenum>(c.face);
2786 GLenum fail = static_cast<GLenum>(c.fail);
2787 GLenum zfail = static_cast<GLenum>(c.zfail);
2788 GLenum zpass = static_cast<GLenum>(c.zpass);
2789 if (!validators_->face_type.IsValid(face)) {
2790 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face, "face");
2791 return error::kNoError;
2793 if (!validators_->stencil_op.IsValid(fail)) {
2794 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail, "fail");
2795 return error::kNoError;
2797 if (!validators_->stencil_op.IsValid(zfail)) {
2798 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail, "zfail");
2799 return error::kNoError;
2801 if (!validators_->stencil_op.IsValid(zpass)) {
2802 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass, "zpass");
2803 return error::kNoError;
2805 bool changed = false;
2806 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2807 changed |= 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 changed |= state_.stencil_back_fail_op != fail ||
2813 state_.stencil_back_z_fail_op != zfail ||
2814 state_.stencil_back_z_pass_op != zpass;
2816 if (changed) {
2817 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
2818 state_.stencil_front_fail_op = fail;
2819 state_.stencil_front_z_fail_op = zfail;
2820 state_.stencil_front_z_pass_op = zpass;
2822 if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
2823 state_.stencil_back_fail_op = fail;
2824 state_.stencil_back_z_fail_op = zfail;
2825 state_.stencil_back_z_pass_op = zpass;
2827 glStencilOpSeparate(face, fail, zfail, zpass);
2829 return error::kNoError;
2832 error::Error GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size,
2833 const void* cmd_data) {
2834 const gles2::cmds::TexParameterf& c =
2835 *static_cast<const gles2::cmds::TexParameterf*>(cmd_data);
2836 (void)c;
2837 GLenum target = static_cast<GLenum>(c.target);
2838 GLenum pname = static_cast<GLenum>(c.pname);
2839 GLfloat param = static_cast<GLfloat>(c.param);
2840 if (!validators_->texture_bind_target.IsValid(target)) {
2841 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target, "target");
2842 return error::kNoError;
2844 if (!validators_->texture_parameter.IsValid(pname)) {
2845 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname, "pname");
2846 return error::kNoError;
2848 DoTexParameterf(target, pname, param);
2849 return error::kNoError;
2852 error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
2853 uint32_t immediate_data_size,
2854 const void* cmd_data) {
2855 const gles2::cmds::TexParameterfvImmediate& c =
2856 *static_cast<const gles2::cmds::TexParameterfvImmediate*>(cmd_data);
2857 (void)c;
2858 GLenum target = static_cast<GLenum>(c.target);
2859 GLenum pname = static_cast<GLenum>(c.pname);
2860 uint32_t data_size;
2861 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
2862 return error::kOutOfBounds;
2864 if (data_size > immediate_data_size) {
2865 return error::kOutOfBounds;
2867 const GLfloat* params =
2868 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
2869 if (!validators_->texture_bind_target.IsValid(target)) {
2870 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target, "target");
2871 return error::kNoError;
2873 if (!validators_->texture_parameter.IsValid(pname)) {
2874 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname, "pname");
2875 return error::kNoError;
2877 if (params == NULL) {
2878 return error::kOutOfBounds;
2880 DoTexParameterfv(target, pname, params);
2881 return error::kNoError;
2884 error::Error GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size,
2885 const void* cmd_data) {
2886 const gles2::cmds::TexParameteri& c =
2887 *static_cast<const gles2::cmds::TexParameteri*>(cmd_data);
2888 (void)c;
2889 GLenum target = static_cast<GLenum>(c.target);
2890 GLenum pname = static_cast<GLenum>(c.pname);
2891 GLint param = static_cast<GLint>(c.param);
2892 if (!validators_->texture_bind_target.IsValid(target)) {
2893 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target, "target");
2894 return error::kNoError;
2896 if (!validators_->texture_parameter.IsValid(pname)) {
2897 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname, "pname");
2898 return error::kNoError;
2900 DoTexParameteri(target, pname, param);
2901 return error::kNoError;
2904 error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
2905 uint32_t immediate_data_size,
2906 const void* cmd_data) {
2907 const gles2::cmds::TexParameterivImmediate& c =
2908 *static_cast<const gles2::cmds::TexParameterivImmediate*>(cmd_data);
2909 (void)c;
2910 GLenum target = static_cast<GLenum>(c.target);
2911 GLenum pname = static_cast<GLenum>(c.pname);
2912 uint32_t data_size;
2913 if (!ComputeDataSize(1, sizeof(GLint), 1, &data_size)) {
2914 return error::kOutOfBounds;
2916 if (data_size > immediate_data_size) {
2917 return error::kOutOfBounds;
2919 const GLint* params =
2920 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
2921 if (!validators_->texture_bind_target.IsValid(target)) {
2922 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target, "target");
2923 return error::kNoError;
2925 if (!validators_->texture_parameter.IsValid(pname)) {
2926 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname, "pname");
2927 return error::kNoError;
2929 if (params == NULL) {
2930 return error::kOutOfBounds;
2932 DoTexParameteriv(target, pname, params);
2933 return error::kNoError;
2936 error::Error GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size,
2937 const void* cmd_data) {
2938 if (!unsafe_es3_apis_enabled())
2939 return error::kUnknownCommand;
2940 const gles2::cmds::TexStorage3D& c =
2941 *static_cast<const gles2::cmds::TexStorage3D*>(cmd_data);
2942 (void)c;
2943 GLenum target = static_cast<GLenum>(c.target);
2944 GLsizei levels = static_cast<GLsizei>(c.levels);
2945 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
2946 GLsizei width = static_cast<GLsizei>(c.width);
2947 GLsizei height = static_cast<GLsizei>(c.height);
2948 GLsizei depth = static_cast<GLsizei>(c.depth);
2949 glTexStorage3D(target, levels, internalFormat, width, height, depth);
2950 return error::kNoError;
2953 error::Error GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
2954 uint32_t immediate_data_size,
2955 const void* cmd_data) {
2956 if (!unsafe_es3_apis_enabled())
2957 return error::kUnknownCommand;
2958 const gles2::cmds::TransformFeedbackVaryingsBucket& c =
2959 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket*>(
2960 cmd_data);
2961 (void)c;
2962 GLuint program = static_cast<GLuint>(c.program);
2964 Bucket* bucket = GetBucket(c.varyings_bucket_id);
2965 if (!bucket) {
2966 return error::kInvalidArguments;
2968 GLsizei count = 0;
2969 std::vector<char*> strs;
2970 std::vector<GLint> len;
2971 if (!bucket->GetAsStrings(&count, &strs, &len)) {
2972 return error::kInvalidArguments;
2974 const char** varyings =
2975 strs.size() > 0 ? const_cast<const char**>(&strs[0]) : NULL;
2976 const GLint* length =
2977 len.size() > 0 ? const_cast<const GLint*>(&len[0]) : NULL;
2978 (void)length;
2979 GLenum buffermode = static_cast<GLenum>(c.buffermode);
2980 DoTransformFeedbackVaryings(program, count, varyings, buffermode);
2981 return error::kNoError;
2984 error::Error GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size,
2985 const void* cmd_data) {
2986 const gles2::cmds::Uniform1f& c =
2987 *static_cast<const gles2::cmds::Uniform1f*>(cmd_data);
2988 (void)c;
2989 GLint location = static_cast<GLint>(c.location);
2990 GLfloat x = static_cast<GLfloat>(c.x);
2991 GLfloat temp[1] = {
2994 DoUniform1fv(location, 1, &temp[0]);
2995 return error::kNoError;
2998 error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
2999 uint32_t immediate_data_size,
3000 const void* cmd_data) {
3001 const gles2::cmds::Uniform1fvImmediate& c =
3002 *static_cast<const gles2::cmds::Uniform1fvImmediate*>(cmd_data);
3003 (void)c;
3004 GLint location = static_cast<GLint>(c.location);
3005 GLsizei count = static_cast<GLsizei>(c.count);
3006 uint32_t data_size;
3007 if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) {
3008 return error::kOutOfBounds;
3010 if (data_size > immediate_data_size) {
3011 return error::kOutOfBounds;
3013 const GLfloat* v =
3014 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3015 if (v == NULL) {
3016 return error::kOutOfBounds;
3018 DoUniform1fv(location, count, v);
3019 return error::kNoError;
3022 error::Error GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size,
3023 const void* cmd_data) {
3024 const gles2::cmds::Uniform1i& c =
3025 *static_cast<const gles2::cmds::Uniform1i*>(cmd_data);
3026 (void)c;
3027 GLint location = static_cast<GLint>(c.location);
3028 GLint x = static_cast<GLint>(c.x);
3029 DoUniform1i(location, x);
3030 return error::kNoError;
3033 error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
3034 uint32_t immediate_data_size,
3035 const void* cmd_data) {
3036 const gles2::cmds::Uniform1ivImmediate& c =
3037 *static_cast<const gles2::cmds::Uniform1ivImmediate*>(cmd_data);
3038 (void)c;
3039 GLint location = static_cast<GLint>(c.location);
3040 GLsizei count = static_cast<GLsizei>(c.count);
3041 uint32_t data_size;
3042 if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) {
3043 return error::kOutOfBounds;
3045 if (data_size > immediate_data_size) {
3046 return error::kOutOfBounds;
3048 const GLint* v =
3049 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3050 if (v == NULL) {
3051 return error::kOutOfBounds;
3053 DoUniform1iv(location, count, v);
3054 return error::kNoError;
3057 error::Error GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size,
3058 const void* cmd_data) {
3059 if (!unsafe_es3_apis_enabled())
3060 return error::kUnknownCommand;
3061 const gles2::cmds::Uniform1ui& c =
3062 *static_cast<const gles2::cmds::Uniform1ui*>(cmd_data);
3063 (void)c;
3064 GLint location = static_cast<GLint>(c.location);
3065 GLuint x = static_cast<GLuint>(c.x);
3066 GLuint temp[1] = {
3069 DoUniform1uiv(location, 1, &temp[0]);
3070 return error::kNoError;
3073 error::Error GLES2DecoderImpl::HandleUniform1uivImmediate(
3074 uint32_t immediate_data_size,
3075 const void* cmd_data) {
3076 if (!unsafe_es3_apis_enabled())
3077 return error::kUnknownCommand;
3078 const gles2::cmds::Uniform1uivImmediate& c =
3079 *static_cast<const gles2::cmds::Uniform1uivImmediate*>(cmd_data);
3080 (void)c;
3081 GLint location = static_cast<GLint>(c.location);
3082 GLsizei count = static_cast<GLsizei>(c.count);
3083 uint32_t data_size;
3084 if (!ComputeDataSize(count, sizeof(GLuint), 1, &data_size)) {
3085 return error::kOutOfBounds;
3087 if (data_size > immediate_data_size) {
3088 return error::kOutOfBounds;
3090 const GLuint* v =
3091 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3092 if (v == NULL) {
3093 return error::kOutOfBounds;
3095 DoUniform1uiv(location, count, v);
3096 return error::kNoError;
3099 error::Error GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size,
3100 const void* cmd_data) {
3101 const gles2::cmds::Uniform2f& c =
3102 *static_cast<const gles2::cmds::Uniform2f*>(cmd_data);
3103 (void)c;
3104 GLint location = static_cast<GLint>(c.location);
3105 GLfloat x = static_cast<GLfloat>(c.x);
3106 GLfloat y = static_cast<GLfloat>(c.y);
3107 GLfloat temp[2] = {
3108 x, y,
3110 DoUniform2fv(location, 1, &temp[0]);
3111 return error::kNoError;
3114 error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
3115 uint32_t immediate_data_size,
3116 const void* cmd_data) {
3117 const gles2::cmds::Uniform2fvImmediate& c =
3118 *static_cast<const gles2::cmds::Uniform2fvImmediate*>(cmd_data);
3119 (void)c;
3120 GLint location = static_cast<GLint>(c.location);
3121 GLsizei count = static_cast<GLsizei>(c.count);
3122 uint32_t data_size;
3123 if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) {
3124 return error::kOutOfBounds;
3126 if (data_size > immediate_data_size) {
3127 return error::kOutOfBounds;
3129 const GLfloat* v =
3130 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3131 if (v == NULL) {
3132 return error::kOutOfBounds;
3134 DoUniform2fv(location, count, v);
3135 return error::kNoError;
3138 error::Error GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size,
3139 const void* cmd_data) {
3140 const gles2::cmds::Uniform2i& c =
3141 *static_cast<const gles2::cmds::Uniform2i*>(cmd_data);
3142 (void)c;
3143 GLint location = static_cast<GLint>(c.location);
3144 GLint x = static_cast<GLint>(c.x);
3145 GLint y = static_cast<GLint>(c.y);
3146 GLint temp[2] = {
3147 x, y,
3149 DoUniform2iv(location, 1, &temp[0]);
3150 return error::kNoError;
3153 error::Error GLES2DecoderImpl::HandleUniform2ivImmediate(
3154 uint32_t immediate_data_size,
3155 const void* cmd_data) {
3156 const gles2::cmds::Uniform2ivImmediate& c =
3157 *static_cast<const gles2::cmds::Uniform2ivImmediate*>(cmd_data);
3158 (void)c;
3159 GLint location = static_cast<GLint>(c.location);
3160 GLsizei count = static_cast<GLsizei>(c.count);
3161 uint32_t data_size;
3162 if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) {
3163 return error::kOutOfBounds;
3165 if (data_size > immediate_data_size) {
3166 return error::kOutOfBounds;
3168 const GLint* v =
3169 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3170 if (v == NULL) {
3171 return error::kOutOfBounds;
3173 DoUniform2iv(location, count, v);
3174 return error::kNoError;
3177 error::Error GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size,
3178 const void* cmd_data) {
3179 if (!unsafe_es3_apis_enabled())
3180 return error::kUnknownCommand;
3181 const gles2::cmds::Uniform2ui& c =
3182 *static_cast<const gles2::cmds::Uniform2ui*>(cmd_data);
3183 (void)c;
3184 GLint location = static_cast<GLint>(c.location);
3185 GLuint x = static_cast<GLuint>(c.x);
3186 GLuint y = static_cast<GLuint>(c.y);
3187 GLuint temp[2] = {
3188 x, y,
3190 DoUniform2uiv(location, 1, &temp[0]);
3191 return error::kNoError;
3194 error::Error GLES2DecoderImpl::HandleUniform2uivImmediate(
3195 uint32_t immediate_data_size,
3196 const void* cmd_data) {
3197 if (!unsafe_es3_apis_enabled())
3198 return error::kUnknownCommand;
3199 const gles2::cmds::Uniform2uivImmediate& c =
3200 *static_cast<const gles2::cmds::Uniform2uivImmediate*>(cmd_data);
3201 (void)c;
3202 GLint location = static_cast<GLint>(c.location);
3203 GLsizei count = static_cast<GLsizei>(c.count);
3204 uint32_t data_size;
3205 if (!ComputeDataSize(count, sizeof(GLuint), 2, &data_size)) {
3206 return error::kOutOfBounds;
3208 if (data_size > immediate_data_size) {
3209 return error::kOutOfBounds;
3211 const GLuint* v =
3212 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3213 if (v == NULL) {
3214 return error::kOutOfBounds;
3216 DoUniform2uiv(location, count, v);
3217 return error::kNoError;
3220 error::Error GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size,
3221 const void* cmd_data) {
3222 const gles2::cmds::Uniform3f& c =
3223 *static_cast<const gles2::cmds::Uniform3f*>(cmd_data);
3224 (void)c;
3225 GLint location = static_cast<GLint>(c.location);
3226 GLfloat x = static_cast<GLfloat>(c.x);
3227 GLfloat y = static_cast<GLfloat>(c.y);
3228 GLfloat z = static_cast<GLfloat>(c.z);
3229 GLfloat temp[3] = {
3230 x, y, z,
3232 DoUniform3fv(location, 1, &temp[0]);
3233 return error::kNoError;
3236 error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
3237 uint32_t immediate_data_size,
3238 const void* cmd_data) {
3239 const gles2::cmds::Uniform3fvImmediate& c =
3240 *static_cast<const gles2::cmds::Uniform3fvImmediate*>(cmd_data);
3241 (void)c;
3242 GLint location = static_cast<GLint>(c.location);
3243 GLsizei count = static_cast<GLsizei>(c.count);
3244 uint32_t data_size;
3245 if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) {
3246 return error::kOutOfBounds;
3248 if (data_size > immediate_data_size) {
3249 return error::kOutOfBounds;
3251 const GLfloat* v =
3252 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3253 if (v == NULL) {
3254 return error::kOutOfBounds;
3256 DoUniform3fv(location, count, v);
3257 return error::kNoError;
3260 error::Error GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size,
3261 const void* cmd_data) {
3262 const gles2::cmds::Uniform3i& c =
3263 *static_cast<const gles2::cmds::Uniform3i*>(cmd_data);
3264 (void)c;
3265 GLint location = static_cast<GLint>(c.location);
3266 GLint x = static_cast<GLint>(c.x);
3267 GLint y = static_cast<GLint>(c.y);
3268 GLint z = static_cast<GLint>(c.z);
3269 GLint temp[3] = {
3270 x, y, z,
3272 DoUniform3iv(location, 1, &temp[0]);
3273 return error::kNoError;
3276 error::Error GLES2DecoderImpl::HandleUniform3ivImmediate(
3277 uint32_t immediate_data_size,
3278 const void* cmd_data) {
3279 const gles2::cmds::Uniform3ivImmediate& c =
3280 *static_cast<const gles2::cmds::Uniform3ivImmediate*>(cmd_data);
3281 (void)c;
3282 GLint location = static_cast<GLint>(c.location);
3283 GLsizei count = static_cast<GLsizei>(c.count);
3284 uint32_t data_size;
3285 if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) {
3286 return error::kOutOfBounds;
3288 if (data_size > immediate_data_size) {
3289 return error::kOutOfBounds;
3291 const GLint* v =
3292 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3293 if (v == NULL) {
3294 return error::kOutOfBounds;
3296 DoUniform3iv(location, count, v);
3297 return error::kNoError;
3300 error::Error GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size,
3301 const void* cmd_data) {
3302 if (!unsafe_es3_apis_enabled())
3303 return error::kUnknownCommand;
3304 const gles2::cmds::Uniform3ui& c =
3305 *static_cast<const gles2::cmds::Uniform3ui*>(cmd_data);
3306 (void)c;
3307 GLint location = static_cast<GLint>(c.location);
3308 GLuint x = static_cast<GLuint>(c.x);
3309 GLuint y = static_cast<GLuint>(c.y);
3310 GLuint z = static_cast<GLuint>(c.z);
3311 GLuint temp[3] = {
3312 x, y, z,
3314 DoUniform3uiv(location, 1, &temp[0]);
3315 return error::kNoError;
3318 error::Error GLES2DecoderImpl::HandleUniform3uivImmediate(
3319 uint32_t immediate_data_size,
3320 const void* cmd_data) {
3321 if (!unsafe_es3_apis_enabled())
3322 return error::kUnknownCommand;
3323 const gles2::cmds::Uniform3uivImmediate& c =
3324 *static_cast<const gles2::cmds::Uniform3uivImmediate*>(cmd_data);
3325 (void)c;
3326 GLint location = static_cast<GLint>(c.location);
3327 GLsizei count = static_cast<GLsizei>(c.count);
3328 uint32_t data_size;
3329 if (!ComputeDataSize(count, sizeof(GLuint), 3, &data_size)) {
3330 return error::kOutOfBounds;
3332 if (data_size > immediate_data_size) {
3333 return error::kOutOfBounds;
3335 const GLuint* v =
3336 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3337 if (v == NULL) {
3338 return error::kOutOfBounds;
3340 DoUniform3uiv(location, count, v);
3341 return error::kNoError;
3344 error::Error GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size,
3345 const void* cmd_data) {
3346 const gles2::cmds::Uniform4f& c =
3347 *static_cast<const gles2::cmds::Uniform4f*>(cmd_data);
3348 (void)c;
3349 GLint location = static_cast<GLint>(c.location);
3350 GLfloat x = static_cast<GLfloat>(c.x);
3351 GLfloat y = static_cast<GLfloat>(c.y);
3352 GLfloat z = static_cast<GLfloat>(c.z);
3353 GLfloat w = static_cast<GLfloat>(c.w);
3354 GLfloat temp[4] = {
3355 x, y, z, w,
3357 DoUniform4fv(location, 1, &temp[0]);
3358 return error::kNoError;
3361 error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
3362 uint32_t immediate_data_size,
3363 const void* cmd_data) {
3364 const gles2::cmds::Uniform4fvImmediate& c =
3365 *static_cast<const gles2::cmds::Uniform4fvImmediate*>(cmd_data);
3366 (void)c;
3367 GLint location = static_cast<GLint>(c.location);
3368 GLsizei count = static_cast<GLsizei>(c.count);
3369 uint32_t data_size;
3370 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3371 return error::kOutOfBounds;
3373 if (data_size > immediate_data_size) {
3374 return error::kOutOfBounds;
3376 const GLfloat* v =
3377 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3378 if (v == NULL) {
3379 return error::kOutOfBounds;
3381 DoUniform4fv(location, count, v);
3382 return error::kNoError;
3385 error::Error GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size,
3386 const void* cmd_data) {
3387 const gles2::cmds::Uniform4i& c =
3388 *static_cast<const gles2::cmds::Uniform4i*>(cmd_data);
3389 (void)c;
3390 GLint location = static_cast<GLint>(c.location);
3391 GLint x = static_cast<GLint>(c.x);
3392 GLint y = static_cast<GLint>(c.y);
3393 GLint z = static_cast<GLint>(c.z);
3394 GLint w = static_cast<GLint>(c.w);
3395 GLint temp[4] = {
3396 x, y, z, w,
3398 DoUniform4iv(location, 1, &temp[0]);
3399 return error::kNoError;
3402 error::Error GLES2DecoderImpl::HandleUniform4ivImmediate(
3403 uint32_t immediate_data_size,
3404 const void* cmd_data) {
3405 const gles2::cmds::Uniform4ivImmediate& c =
3406 *static_cast<const gles2::cmds::Uniform4ivImmediate*>(cmd_data);
3407 (void)c;
3408 GLint location = static_cast<GLint>(c.location);
3409 GLsizei count = static_cast<GLsizei>(c.count);
3410 uint32_t data_size;
3411 if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) {
3412 return error::kOutOfBounds;
3414 if (data_size > immediate_data_size) {
3415 return error::kOutOfBounds;
3417 const GLint* v =
3418 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3419 if (v == NULL) {
3420 return error::kOutOfBounds;
3422 DoUniform4iv(location, count, v);
3423 return error::kNoError;
3426 error::Error GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size,
3427 const void* cmd_data) {
3428 if (!unsafe_es3_apis_enabled())
3429 return error::kUnknownCommand;
3430 const gles2::cmds::Uniform4ui& c =
3431 *static_cast<const gles2::cmds::Uniform4ui*>(cmd_data);
3432 (void)c;
3433 GLint location = static_cast<GLint>(c.location);
3434 GLuint x = static_cast<GLuint>(c.x);
3435 GLuint y = static_cast<GLuint>(c.y);
3436 GLuint z = static_cast<GLuint>(c.z);
3437 GLuint w = static_cast<GLuint>(c.w);
3438 GLuint temp[4] = {
3439 x, y, z, w,
3441 DoUniform4uiv(location, 1, &temp[0]);
3442 return error::kNoError;
3445 error::Error GLES2DecoderImpl::HandleUniform4uivImmediate(
3446 uint32_t immediate_data_size,
3447 const void* cmd_data) {
3448 if (!unsafe_es3_apis_enabled())
3449 return error::kUnknownCommand;
3450 const gles2::cmds::Uniform4uivImmediate& c =
3451 *static_cast<const gles2::cmds::Uniform4uivImmediate*>(cmd_data);
3452 (void)c;
3453 GLint location = static_cast<GLint>(c.location);
3454 GLsizei count = static_cast<GLsizei>(c.count);
3455 uint32_t data_size;
3456 if (!ComputeDataSize(count, sizeof(GLuint), 4, &data_size)) {
3457 return error::kOutOfBounds;
3459 if (data_size > immediate_data_size) {
3460 return error::kOutOfBounds;
3462 const GLuint* v =
3463 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3464 if (v == NULL) {
3465 return error::kOutOfBounds;
3467 DoUniform4uiv(location, count, v);
3468 return error::kNoError;
3471 error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3472 uint32_t immediate_data_size,
3473 const void* cmd_data) {
3474 const gles2::cmds::UniformMatrix2fvImmediate& c =
3475 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate*>(cmd_data);
3476 (void)c;
3477 GLint location = static_cast<GLint>(c.location);
3478 GLsizei count = static_cast<GLsizei>(c.count);
3479 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3480 uint32_t data_size;
3481 if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) {
3482 return error::kOutOfBounds;
3484 if (data_size > immediate_data_size) {
3485 return error::kOutOfBounds;
3487 const GLfloat* value =
3488 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3489 if (value == NULL) {
3490 return error::kOutOfBounds;
3492 DoUniformMatrix2fv(location, count, transpose, value);
3493 return error::kNoError;
3496 error::Error GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3497 uint32_t immediate_data_size,
3498 const void* cmd_data) {
3499 if (!unsafe_es3_apis_enabled())
3500 return error::kUnknownCommand;
3501 const gles2::cmds::UniformMatrix2x3fvImmediate& c =
3502 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate*>(cmd_data);
3503 (void)c;
3504 GLint location = static_cast<GLint>(c.location);
3505 GLsizei count = static_cast<GLsizei>(c.count);
3506 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3507 uint32_t data_size;
3508 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3509 return error::kOutOfBounds;
3511 if (data_size > immediate_data_size) {
3512 return error::kOutOfBounds;
3514 const GLfloat* value =
3515 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3516 if (value == NULL) {
3517 return error::kOutOfBounds;
3519 DoUniformMatrix2x3fv(location, count, transpose, value);
3520 return error::kNoError;
3523 error::Error GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3524 uint32_t immediate_data_size,
3525 const void* cmd_data) {
3526 if (!unsafe_es3_apis_enabled())
3527 return error::kUnknownCommand;
3528 const gles2::cmds::UniformMatrix2x4fvImmediate& c =
3529 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate*>(cmd_data);
3530 (void)c;
3531 GLint location = static_cast<GLint>(c.location);
3532 GLsizei count = static_cast<GLsizei>(c.count);
3533 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3534 uint32_t data_size;
3535 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3536 return error::kOutOfBounds;
3538 if (data_size > immediate_data_size) {
3539 return error::kOutOfBounds;
3541 const GLfloat* value =
3542 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3543 if (value == NULL) {
3544 return error::kOutOfBounds;
3546 DoUniformMatrix2x4fv(location, count, transpose, value);
3547 return error::kNoError;
3550 error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3551 uint32_t immediate_data_size,
3552 const void* cmd_data) {
3553 const gles2::cmds::UniformMatrix3fvImmediate& c =
3554 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate*>(cmd_data);
3555 (void)c;
3556 GLint location = static_cast<GLint>(c.location);
3557 GLsizei count = static_cast<GLsizei>(c.count);
3558 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3559 uint32_t data_size;
3560 if (!ComputeDataSize(count, sizeof(GLfloat), 9, &data_size)) {
3561 return error::kOutOfBounds;
3563 if (data_size > immediate_data_size) {
3564 return error::kOutOfBounds;
3566 const GLfloat* value =
3567 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3568 if (value == NULL) {
3569 return error::kOutOfBounds;
3571 DoUniformMatrix3fv(location, count, transpose, value);
3572 return error::kNoError;
3575 error::Error GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3576 uint32_t immediate_data_size,
3577 const void* cmd_data) {
3578 if (!unsafe_es3_apis_enabled())
3579 return error::kUnknownCommand;
3580 const gles2::cmds::UniformMatrix3x2fvImmediate& c =
3581 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate*>(cmd_data);
3582 (void)c;
3583 GLint location = static_cast<GLint>(c.location);
3584 GLsizei count = static_cast<GLsizei>(c.count);
3585 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3586 uint32_t data_size;
3587 if (!ComputeDataSize(count, sizeof(GLfloat), 6, &data_size)) {
3588 return error::kOutOfBounds;
3590 if (data_size > immediate_data_size) {
3591 return error::kOutOfBounds;
3593 const GLfloat* value =
3594 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3595 if (value == NULL) {
3596 return error::kOutOfBounds;
3598 DoUniformMatrix3x2fv(location, count, transpose, value);
3599 return error::kNoError;
3602 error::Error GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3603 uint32_t immediate_data_size,
3604 const void* cmd_data) {
3605 if (!unsafe_es3_apis_enabled())
3606 return error::kUnknownCommand;
3607 const gles2::cmds::UniformMatrix3x4fvImmediate& c =
3608 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate*>(cmd_data);
3609 (void)c;
3610 GLint location = static_cast<GLint>(c.location);
3611 GLsizei count = static_cast<GLsizei>(c.count);
3612 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3613 uint32_t data_size;
3614 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3615 return error::kOutOfBounds;
3617 if (data_size > immediate_data_size) {
3618 return error::kOutOfBounds;
3620 const GLfloat* value =
3621 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3622 if (value == NULL) {
3623 return error::kOutOfBounds;
3625 DoUniformMatrix3x4fv(location, count, transpose, value);
3626 return error::kNoError;
3629 error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3630 uint32_t immediate_data_size,
3631 const void* cmd_data) {
3632 const gles2::cmds::UniformMatrix4fvImmediate& c =
3633 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate*>(cmd_data);
3634 (void)c;
3635 GLint location = static_cast<GLint>(c.location);
3636 GLsizei count = static_cast<GLsizei>(c.count);
3637 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3638 uint32_t data_size;
3639 if (!ComputeDataSize(count, sizeof(GLfloat), 16, &data_size)) {
3640 return error::kOutOfBounds;
3642 if (data_size > immediate_data_size) {
3643 return error::kOutOfBounds;
3645 const GLfloat* value =
3646 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3647 if (value == NULL) {
3648 return error::kOutOfBounds;
3650 DoUniformMatrix4fv(location, count, transpose, value);
3651 return error::kNoError;
3654 error::Error GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3655 uint32_t immediate_data_size,
3656 const void* cmd_data) {
3657 if (!unsafe_es3_apis_enabled())
3658 return error::kUnknownCommand;
3659 const gles2::cmds::UniformMatrix4x2fvImmediate& c =
3660 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate*>(cmd_data);
3661 (void)c;
3662 GLint location = static_cast<GLint>(c.location);
3663 GLsizei count = static_cast<GLsizei>(c.count);
3664 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3665 uint32_t data_size;
3666 if (!ComputeDataSize(count, sizeof(GLfloat), 8, &data_size)) {
3667 return error::kOutOfBounds;
3669 if (data_size > immediate_data_size) {
3670 return error::kOutOfBounds;
3672 const GLfloat* value =
3673 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3674 if (value == NULL) {
3675 return error::kOutOfBounds;
3677 DoUniformMatrix4x2fv(location, count, transpose, value);
3678 return error::kNoError;
3681 error::Error GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3682 uint32_t immediate_data_size,
3683 const void* cmd_data) {
3684 if (!unsafe_es3_apis_enabled())
3685 return error::kUnknownCommand;
3686 const gles2::cmds::UniformMatrix4x3fvImmediate& c =
3687 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate*>(cmd_data);
3688 (void)c;
3689 GLint location = static_cast<GLint>(c.location);
3690 GLsizei count = static_cast<GLsizei>(c.count);
3691 GLboolean transpose = static_cast<GLboolean>(c.transpose);
3692 uint32_t data_size;
3693 if (!ComputeDataSize(count, sizeof(GLfloat), 12, &data_size)) {
3694 return error::kOutOfBounds;
3696 if (data_size > immediate_data_size) {
3697 return error::kOutOfBounds;
3699 const GLfloat* value =
3700 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3701 if (value == NULL) {
3702 return error::kOutOfBounds;
3704 DoUniformMatrix4x3fv(location, count, transpose, value);
3705 return error::kNoError;
3708 error::Error GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size,
3709 const void* cmd_data) {
3710 const gles2::cmds::UseProgram& c =
3711 *static_cast<const gles2::cmds::UseProgram*>(cmd_data);
3712 (void)c;
3713 GLuint program = c.program;
3714 DoUseProgram(program);
3715 return error::kNoError;
3718 error::Error GLES2DecoderImpl::HandleValidateProgram(
3719 uint32_t immediate_data_size,
3720 const void* cmd_data) {
3721 const gles2::cmds::ValidateProgram& c =
3722 *static_cast<const gles2::cmds::ValidateProgram*>(cmd_data);
3723 (void)c;
3724 GLuint program = c.program;
3725 DoValidateProgram(program);
3726 return error::kNoError;
3729 error::Error GLES2DecoderImpl::HandleVertexAttrib1f(
3730 uint32_t immediate_data_size,
3731 const void* cmd_data) {
3732 const gles2::cmds::VertexAttrib1f& c =
3733 *static_cast<const gles2::cmds::VertexAttrib1f*>(cmd_data);
3734 (void)c;
3735 GLuint indx = static_cast<GLuint>(c.indx);
3736 GLfloat x = static_cast<GLfloat>(c.x);
3737 DoVertexAttrib1f(indx, x);
3738 return error::kNoError;
3741 error::Error GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3742 uint32_t immediate_data_size,
3743 const void* cmd_data) {
3744 const gles2::cmds::VertexAttrib1fvImmediate& c =
3745 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate*>(cmd_data);
3746 (void)c;
3747 GLuint indx = static_cast<GLuint>(c.indx);
3748 uint32_t data_size;
3749 if (!ComputeDataSize(1, sizeof(GLfloat), 1, &data_size)) {
3750 return error::kOutOfBounds;
3752 if (data_size > immediate_data_size) {
3753 return error::kOutOfBounds;
3755 const GLfloat* values =
3756 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3757 if (values == NULL) {
3758 return error::kOutOfBounds;
3760 DoVertexAttrib1fv(indx, values);
3761 return error::kNoError;
3764 error::Error GLES2DecoderImpl::HandleVertexAttrib2f(
3765 uint32_t immediate_data_size,
3766 const void* cmd_data) {
3767 const gles2::cmds::VertexAttrib2f& c =
3768 *static_cast<const gles2::cmds::VertexAttrib2f*>(cmd_data);
3769 (void)c;
3770 GLuint indx = static_cast<GLuint>(c.indx);
3771 GLfloat x = static_cast<GLfloat>(c.x);
3772 GLfloat y = static_cast<GLfloat>(c.y);
3773 DoVertexAttrib2f(indx, x, y);
3774 return error::kNoError;
3777 error::Error GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3778 uint32_t immediate_data_size,
3779 const void* cmd_data) {
3780 const gles2::cmds::VertexAttrib2fvImmediate& c =
3781 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate*>(cmd_data);
3782 (void)c;
3783 GLuint indx = static_cast<GLuint>(c.indx);
3784 uint32_t data_size;
3785 if (!ComputeDataSize(1, sizeof(GLfloat), 2, &data_size)) {
3786 return error::kOutOfBounds;
3788 if (data_size > immediate_data_size) {
3789 return error::kOutOfBounds;
3791 const GLfloat* values =
3792 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3793 if (values == NULL) {
3794 return error::kOutOfBounds;
3796 DoVertexAttrib2fv(indx, values);
3797 return error::kNoError;
3800 error::Error GLES2DecoderImpl::HandleVertexAttrib3f(
3801 uint32_t immediate_data_size,
3802 const void* cmd_data) {
3803 const gles2::cmds::VertexAttrib3f& c =
3804 *static_cast<const gles2::cmds::VertexAttrib3f*>(cmd_data);
3805 (void)c;
3806 GLuint indx = static_cast<GLuint>(c.indx);
3807 GLfloat x = static_cast<GLfloat>(c.x);
3808 GLfloat y = static_cast<GLfloat>(c.y);
3809 GLfloat z = static_cast<GLfloat>(c.z);
3810 DoVertexAttrib3f(indx, x, y, z);
3811 return error::kNoError;
3814 error::Error GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3815 uint32_t immediate_data_size,
3816 const void* cmd_data) {
3817 const gles2::cmds::VertexAttrib3fvImmediate& c =
3818 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate*>(cmd_data);
3819 (void)c;
3820 GLuint indx = static_cast<GLuint>(c.indx);
3821 uint32_t data_size;
3822 if (!ComputeDataSize(1, sizeof(GLfloat), 3, &data_size)) {
3823 return error::kOutOfBounds;
3825 if (data_size > immediate_data_size) {
3826 return error::kOutOfBounds;
3828 const GLfloat* values =
3829 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3830 if (values == NULL) {
3831 return error::kOutOfBounds;
3833 DoVertexAttrib3fv(indx, values);
3834 return error::kNoError;
3837 error::Error GLES2DecoderImpl::HandleVertexAttrib4f(
3838 uint32_t immediate_data_size,
3839 const void* cmd_data) {
3840 const gles2::cmds::VertexAttrib4f& c =
3841 *static_cast<const gles2::cmds::VertexAttrib4f*>(cmd_data);
3842 (void)c;
3843 GLuint indx = static_cast<GLuint>(c.indx);
3844 GLfloat x = static_cast<GLfloat>(c.x);
3845 GLfloat y = static_cast<GLfloat>(c.y);
3846 GLfloat z = static_cast<GLfloat>(c.z);
3847 GLfloat w = static_cast<GLfloat>(c.w);
3848 DoVertexAttrib4f(indx, x, y, z, w);
3849 return error::kNoError;
3852 error::Error GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3853 uint32_t immediate_data_size,
3854 const void* cmd_data) {
3855 const gles2::cmds::VertexAttrib4fvImmediate& c =
3856 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate*>(cmd_data);
3857 (void)c;
3858 GLuint indx = static_cast<GLuint>(c.indx);
3859 uint32_t data_size;
3860 if (!ComputeDataSize(1, sizeof(GLfloat), 4, &data_size)) {
3861 return error::kOutOfBounds;
3863 if (data_size > immediate_data_size) {
3864 return error::kOutOfBounds;
3866 const GLfloat* values =
3867 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
3868 if (values == NULL) {
3869 return error::kOutOfBounds;
3871 DoVertexAttrib4fv(indx, values);
3872 return error::kNoError;
3875 error::Error GLES2DecoderImpl::HandleVertexAttribI4i(
3876 uint32_t immediate_data_size,
3877 const void* cmd_data) {
3878 if (!unsafe_es3_apis_enabled())
3879 return error::kUnknownCommand;
3880 const gles2::cmds::VertexAttribI4i& c =
3881 *static_cast<const gles2::cmds::VertexAttribI4i*>(cmd_data);
3882 (void)c;
3883 GLuint indx = static_cast<GLuint>(c.indx);
3884 GLint x = static_cast<GLint>(c.x);
3885 GLint y = static_cast<GLint>(c.y);
3886 GLint z = static_cast<GLint>(c.z);
3887 GLint w = static_cast<GLint>(c.w);
3888 DoVertexAttribI4i(indx, x, y, z, w);
3889 return error::kNoError;
3892 error::Error GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3893 uint32_t immediate_data_size,
3894 const void* cmd_data) {
3895 if (!unsafe_es3_apis_enabled())
3896 return error::kUnknownCommand;
3897 const gles2::cmds::VertexAttribI4ivImmediate& c =
3898 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate*>(cmd_data);
3899 (void)c;
3900 GLuint indx = static_cast<GLuint>(c.indx);
3901 uint32_t data_size;
3902 if (!ComputeDataSize(1, sizeof(GLint), 4, &data_size)) {
3903 return error::kOutOfBounds;
3905 if (data_size > immediate_data_size) {
3906 return error::kOutOfBounds;
3908 const GLint* values =
3909 GetImmediateDataAs<const GLint*>(c, data_size, immediate_data_size);
3910 if (values == NULL) {
3911 return error::kOutOfBounds;
3913 DoVertexAttribI4iv(indx, values);
3914 return error::kNoError;
3917 error::Error GLES2DecoderImpl::HandleVertexAttribI4ui(
3918 uint32_t immediate_data_size,
3919 const void* cmd_data) {
3920 if (!unsafe_es3_apis_enabled())
3921 return error::kUnknownCommand;
3922 const gles2::cmds::VertexAttribI4ui& c =
3923 *static_cast<const gles2::cmds::VertexAttribI4ui*>(cmd_data);
3924 (void)c;
3925 GLuint indx = static_cast<GLuint>(c.indx);
3926 GLuint x = static_cast<GLuint>(c.x);
3927 GLuint y = static_cast<GLuint>(c.y);
3928 GLuint z = static_cast<GLuint>(c.z);
3929 GLuint w = static_cast<GLuint>(c.w);
3930 DoVertexAttribI4ui(indx, x, y, z, w);
3931 return error::kNoError;
3934 error::Error GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3935 uint32_t immediate_data_size,
3936 const void* cmd_data) {
3937 if (!unsafe_es3_apis_enabled())
3938 return error::kUnknownCommand;
3939 const gles2::cmds::VertexAttribI4uivImmediate& c =
3940 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate*>(cmd_data);
3941 (void)c;
3942 GLuint indx = static_cast<GLuint>(c.indx);
3943 uint32_t data_size;
3944 if (!ComputeDataSize(1, sizeof(GLuint), 4, &data_size)) {
3945 return error::kOutOfBounds;
3947 if (data_size > immediate_data_size) {
3948 return error::kOutOfBounds;
3950 const GLuint* values =
3951 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
3952 if (values == NULL) {
3953 return error::kOutOfBounds;
3955 DoVertexAttribI4uiv(indx, values);
3956 return error::kNoError;
3959 error::Error GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size,
3960 const void* cmd_data) {
3961 const gles2::cmds::Viewport& c =
3962 *static_cast<const gles2::cmds::Viewport*>(cmd_data);
3963 (void)c;
3964 GLint x = static_cast<GLint>(c.x);
3965 GLint y = static_cast<GLint>(c.y);
3966 GLsizei width = static_cast<GLsizei>(c.width);
3967 GLsizei height = static_cast<GLsizei>(c.height);
3968 if (width < 0) {
3969 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "width < 0");
3970 return error::kNoError;
3972 if (height < 0) {
3973 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glViewport", "height < 0");
3974 return error::kNoError;
3976 DoViewport(x, y, width, height);
3977 return error::kNoError;
3980 error::Error GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
3981 uint32_t immediate_data_size,
3982 const void* cmd_data) {
3983 const gles2::cmds::BlitFramebufferCHROMIUM& c =
3984 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM*>(cmd_data);
3985 (void)c;
3986 if (!features().chromium_framebuffer_multisample) {
3987 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlitFramebufferCHROMIUM",
3988 "function not available");
3989 return error::kNoError;
3992 error::Error error;
3993 error = WillAccessBoundFramebufferForDraw();
3994 if (error != error::kNoError)
3995 return error;
3996 error = WillAccessBoundFramebufferForRead();
3997 if (error != error::kNoError)
3998 return error;
3999 GLint srcX0 = static_cast<GLint>(c.srcX0);
4000 GLint srcY0 = static_cast<GLint>(c.srcY0);
4001 GLint srcX1 = static_cast<GLint>(c.srcX1);
4002 GLint srcY1 = static_cast<GLint>(c.srcY1);
4003 GLint dstX0 = static_cast<GLint>(c.dstX0);
4004 GLint dstY0 = static_cast<GLint>(c.dstY0);
4005 GLint dstX1 = static_cast<GLint>(c.dstX1);
4006 GLint dstY1 = static_cast<GLint>(c.dstY1);
4007 GLbitfield mask = static_cast<GLbitfield>(c.mask);
4008 GLenum filter = static_cast<GLenum>(c.filter);
4009 if (!validators_->blit_filter.IsValid(filter)) {
4010 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter,
4011 "filter");
4012 return error::kNoError;
4014 DoBlitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1,
4015 dstY1, mask, filter);
4016 return error::kNoError;
4019 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
4020 uint32_t immediate_data_size,
4021 const void* cmd_data) {
4022 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM& c =
4023 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM*>(
4024 cmd_data);
4025 (void)c;
4026 if (!features().chromium_framebuffer_multisample) {
4027 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4028 "glRenderbufferStorageMultisampleCHROMIUM",
4029 "function not available");
4030 return error::kNoError;
4033 GLenum target = static_cast<GLenum>(c.target);
4034 GLsizei samples = static_cast<GLsizei>(c.samples);
4035 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4036 GLsizei width = static_cast<GLsizei>(c.width);
4037 GLsizei height = static_cast<GLsizei>(c.height);
4038 if (!validators_->render_buffer_target.IsValid(target)) {
4039 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4040 target, "target");
4041 return error::kNoError;
4043 if (samples < 0) {
4044 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4045 "glRenderbufferStorageMultisampleCHROMIUM",
4046 "samples < 0");
4047 return error::kNoError;
4049 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4050 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4051 internalformat, "internalformat");
4052 return error::kNoError;
4054 if (width < 0) {
4055 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4056 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
4057 return error::kNoError;
4059 if (height < 0) {
4060 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
4061 "glRenderbufferStorageMultisampleCHROMIUM",
4062 "height < 0");
4063 return error::kNoError;
4065 DoRenderbufferStorageMultisampleCHROMIUM(target, samples, internalformat,
4066 width, height);
4067 return error::kNoError;
4070 error::Error GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
4071 uint32_t immediate_data_size,
4072 const void* cmd_data) {
4073 const gles2::cmds::RenderbufferStorageMultisampleEXT& c =
4074 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT*>(
4075 cmd_data);
4076 (void)c;
4077 if (!features().multisampled_render_to_texture) {
4078 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4079 "glRenderbufferStorageMultisampleEXT",
4080 "function not available");
4081 return error::kNoError;
4084 GLenum target = static_cast<GLenum>(c.target);
4085 GLsizei samples = static_cast<GLsizei>(c.samples);
4086 GLenum internalformat = static_cast<GLenum>(c.internalformat);
4087 GLsizei width = static_cast<GLsizei>(c.width);
4088 GLsizei height = static_cast<GLsizei>(c.height);
4089 if (!validators_->render_buffer_target.IsValid(target)) {
4090 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4091 target, "target");
4092 return error::kNoError;
4094 if (samples < 0) {
4095 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4096 "samples < 0");
4097 return error::kNoError;
4099 if (!validators_->render_buffer_format.IsValid(internalformat)) {
4100 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4101 internalformat, "internalformat");
4102 return error::kNoError;
4104 if (width < 0) {
4105 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4106 "width < 0");
4107 return error::kNoError;
4109 if (height < 0) {
4110 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT",
4111 "height < 0");
4112 return error::kNoError;
4114 DoRenderbufferStorageMultisampleEXT(target, samples, internalformat, width,
4115 height);
4116 return error::kNoError;
4119 error::Error GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
4120 uint32_t immediate_data_size,
4121 const void* cmd_data) {
4122 const gles2::cmds::FramebufferTexture2DMultisampleEXT& c =
4123 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT*>(
4124 cmd_data);
4125 (void)c;
4126 if (!features().multisampled_render_to_texture) {
4127 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
4128 "glFramebufferTexture2DMultisampleEXT",
4129 "function not available");
4130 return error::kNoError;
4133 GLenum target = static_cast<GLenum>(c.target);
4134 GLenum attachment = static_cast<GLenum>(c.attachment);
4135 GLenum textarget = static_cast<GLenum>(c.textarget);
4136 GLuint texture = c.texture;
4137 GLint level = static_cast<GLint>(c.level);
4138 GLsizei samples = static_cast<GLsizei>(c.samples);
4139 if (!validators_->frame_buffer_target.IsValid(target)) {
4140 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4141 target, "target");
4142 return error::kNoError;
4144 if (!validators_->attachment.IsValid(attachment)) {
4145 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4146 attachment, "attachment");
4147 return error::kNoError;
4149 if (!validators_->texture_target.IsValid(textarget)) {
4150 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4151 textarget, "textarget");
4152 return error::kNoError;
4154 if (samples < 0) {
4155 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glFramebufferTexture2DMultisampleEXT",
4156 "samples < 0");
4157 return error::kNoError;
4159 DoFramebufferTexture2DMultisample(target, attachment, textarget, texture,
4160 level, samples);
4161 return error::kNoError;
4164 error::Error GLES2DecoderImpl::HandleTexStorage2DEXT(
4165 uint32_t immediate_data_size,
4166 const void* cmd_data) {
4167 const gles2::cmds::TexStorage2DEXT& c =
4168 *static_cast<const gles2::cmds::TexStorage2DEXT*>(cmd_data);
4169 (void)c;
4170 GLenum target = static_cast<GLenum>(c.target);
4171 GLsizei levels = static_cast<GLsizei>(c.levels);
4172 GLenum internalFormat = static_cast<GLenum>(c.internalFormat);
4173 GLsizei width = static_cast<GLsizei>(c.width);
4174 GLsizei height = static_cast<GLsizei>(c.height);
4175 if (!validators_->texture_bind_target.IsValid(target)) {
4176 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target, "target");
4177 return error::kNoError;
4179 if (levels < 0) {
4180 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
4181 return error::kNoError;
4183 if (!validators_->texture_internal_format_storage.IsValid(internalFormat)) {
4184 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat,
4185 "internalFormat");
4186 return error::kNoError;
4188 if (width < 0) {
4189 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
4190 return error::kNoError;
4192 if (height < 0) {
4193 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
4194 return error::kNoError;
4196 DoTexStorage2DEXT(target, levels, internalFormat, width, height);
4197 return error::kNoError;
4200 error::Error GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4201 uint32_t immediate_data_size,
4202 const void* cmd_data) {
4203 const gles2::cmds::GenQueriesEXTImmediate& c =
4204 *static_cast<const gles2::cmds::GenQueriesEXTImmediate*>(cmd_data);
4205 (void)c;
4206 GLsizei n = static_cast<GLsizei>(c.n);
4207 uint32_t data_size;
4208 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4209 return error::kOutOfBounds;
4211 GLuint* queries =
4212 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4213 if (queries == NULL) {
4214 return error::kOutOfBounds;
4216 if (!GenQueriesEXTHelper(n, queries)) {
4217 return error::kInvalidArguments;
4219 return error::kNoError;
4222 error::Error GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4223 uint32_t immediate_data_size,
4224 const void* cmd_data) {
4225 const gles2::cmds::DeleteQueriesEXTImmediate& c =
4226 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate*>(cmd_data);
4227 (void)c;
4228 GLsizei n = static_cast<GLsizei>(c.n);
4229 uint32_t data_size;
4230 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4231 return error::kOutOfBounds;
4233 const GLuint* queries =
4234 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4235 if (queries == NULL) {
4236 return error::kOutOfBounds;
4238 DeleteQueriesEXTHelper(n, queries);
4239 return error::kNoError;
4242 error::Error GLES2DecoderImpl::HandleBeginTransformFeedback(
4243 uint32_t immediate_data_size,
4244 const void* cmd_data) {
4245 if (!unsafe_es3_apis_enabled())
4246 return error::kUnknownCommand;
4247 const gles2::cmds::BeginTransformFeedback& c =
4248 *static_cast<const gles2::cmds::BeginTransformFeedback*>(cmd_data);
4249 (void)c;
4250 GLenum primitivemode = static_cast<GLenum>(c.primitivemode);
4251 glBeginTransformFeedback(primitivemode);
4252 return error::kNoError;
4255 error::Error GLES2DecoderImpl::HandleEndTransformFeedback(
4256 uint32_t immediate_data_size,
4257 const void* cmd_data) {
4258 if (!unsafe_es3_apis_enabled())
4259 return error::kUnknownCommand;
4260 const gles2::cmds::EndTransformFeedback& c =
4261 *static_cast<const gles2::cmds::EndTransformFeedback*>(cmd_data);
4262 (void)c;
4263 glEndTransformFeedback();
4264 return error::kNoError;
4267 error::Error GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4268 uint32_t immediate_data_size,
4269 const void* cmd_data) {
4270 const gles2::cmds::InsertEventMarkerEXT& c =
4271 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data);
4272 (void)c;
4274 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4275 Bucket* bucket = GetBucket(bucket_id);
4276 if (!bucket || bucket->size() == 0) {
4277 return error::kInvalidArguments;
4279 std::string str;
4280 if (!bucket->GetAsString(&str)) {
4281 return error::kInvalidArguments;
4283 DoInsertEventMarkerEXT(0, str.c_str());
4284 return error::kNoError;
4287 error::Error GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4288 uint32_t immediate_data_size,
4289 const void* cmd_data) {
4290 const gles2::cmds::PushGroupMarkerEXT& c =
4291 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data);
4292 (void)c;
4294 GLuint bucket_id = static_cast<GLuint>(c.bucket_id);
4295 Bucket* bucket = GetBucket(bucket_id);
4296 if (!bucket || bucket->size() == 0) {
4297 return error::kInvalidArguments;
4299 std::string str;
4300 if (!bucket->GetAsString(&str)) {
4301 return error::kInvalidArguments;
4303 DoPushGroupMarkerEXT(0, str.c_str());
4304 return error::kNoError;
4307 error::Error GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4308 uint32_t immediate_data_size,
4309 const void* cmd_data) {
4310 const gles2::cmds::PopGroupMarkerEXT& c =
4311 *static_cast<const gles2::cmds::PopGroupMarkerEXT*>(cmd_data);
4312 (void)c;
4313 DoPopGroupMarkerEXT();
4314 return error::kNoError;
4317 error::Error GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4318 uint32_t immediate_data_size,
4319 const void* cmd_data) {
4320 const gles2::cmds::GenVertexArraysOESImmediate& c =
4321 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate*>(cmd_data);
4322 (void)c;
4323 GLsizei n = static_cast<GLsizei>(c.n);
4324 uint32_t data_size;
4325 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4326 return error::kOutOfBounds;
4328 GLuint* arrays =
4329 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4330 if (arrays == NULL) {
4331 return error::kOutOfBounds;
4333 if (!GenVertexArraysOESHelper(n, arrays)) {
4334 return error::kInvalidArguments;
4336 return error::kNoError;
4339 error::Error GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4340 uint32_t immediate_data_size,
4341 const void* cmd_data) {
4342 const gles2::cmds::DeleteVertexArraysOESImmediate& c =
4343 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate*>(
4344 cmd_data);
4345 (void)c;
4346 GLsizei n = static_cast<GLsizei>(c.n);
4347 uint32_t data_size;
4348 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4349 return error::kOutOfBounds;
4351 const GLuint* arrays =
4352 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4353 if (arrays == NULL) {
4354 return error::kOutOfBounds;
4356 DeleteVertexArraysOESHelper(n, arrays);
4357 return error::kNoError;
4360 error::Error GLES2DecoderImpl::HandleIsVertexArrayOES(
4361 uint32_t immediate_data_size,
4362 const void* cmd_data) {
4363 const gles2::cmds::IsVertexArrayOES& c =
4364 *static_cast<const gles2::cmds::IsVertexArrayOES*>(cmd_data);
4365 (void)c;
4366 GLuint array = c.array;
4367 typedef cmds::IsVertexArrayOES::Result Result;
4368 Result* result_dst = GetSharedMemoryAs<Result*>(
4369 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4370 if (!result_dst) {
4371 return error::kOutOfBounds;
4373 *result_dst = DoIsVertexArrayOES(array);
4374 return error::kNoError;
4377 error::Error GLES2DecoderImpl::HandleBindVertexArrayOES(
4378 uint32_t immediate_data_size,
4379 const void* cmd_data) {
4380 const gles2::cmds::BindVertexArrayOES& c =
4381 *static_cast<const gles2::cmds::BindVertexArrayOES*>(cmd_data);
4382 (void)c;
4383 GLuint array = c.array;
4384 DoBindVertexArrayOES(array);
4385 return error::kNoError;
4388 error::Error GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size,
4389 const void* cmd_data) {
4390 const gles2::cmds::SwapBuffers& c =
4391 *static_cast<const gles2::cmds::SwapBuffers*>(cmd_data);
4392 (void)c;
4393 DoSwapBuffers();
4394 return error::kNoError;
4397 error::Error GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4398 uint32_t immediate_data_size,
4399 const void* cmd_data) {
4400 const gles2::cmds::GetMaxValueInBufferCHROMIUM& c =
4401 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM*>(cmd_data);
4402 (void)c;
4403 GLuint buffer_id = c.buffer_id;
4404 GLsizei count = static_cast<GLsizei>(c.count);
4405 GLenum type = static_cast<GLenum>(c.type);
4406 GLuint offset = static_cast<GLuint>(c.offset);
4407 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result;
4408 Result* result_dst = GetSharedMemoryAs<Result*>(
4409 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4410 if (!result_dst) {
4411 return error::kOutOfBounds;
4413 if (count < 0) {
4414 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetMaxValueInBufferCHROMIUM",
4415 "count < 0");
4416 return error::kNoError;
4418 if (!validators_->get_max_index_type.IsValid(type)) {
4419 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type,
4420 "type");
4421 return error::kNoError;
4423 *result_dst = DoGetMaxValueInBufferCHROMIUM(buffer_id, count, type, offset);
4424 return error::kNoError;
4427 error::Error GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4428 uint32_t immediate_data_size,
4429 const void* cmd_data) {
4430 const gles2::cmds::TexImageIOSurface2DCHROMIUM& c =
4431 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM*>(cmd_data);
4432 (void)c;
4433 GLenum target = static_cast<GLenum>(c.target);
4434 GLsizei width = static_cast<GLsizei>(c.width);
4435 GLsizei height = static_cast<GLsizei>(c.height);
4436 GLuint ioSurfaceId = static_cast<GLuint>(c.ioSurfaceId);
4437 GLuint plane = static_cast<GLuint>(c.plane);
4438 if (!validators_->texture_bind_target.IsValid(target)) {
4439 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target,
4440 "target");
4441 return error::kNoError;
4443 if (width < 0) {
4444 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4445 "width < 0");
4446 return error::kNoError;
4448 if (height < 0) {
4449 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM",
4450 "height < 0");
4451 return error::kNoError;
4453 DoTexImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
4454 return error::kNoError;
4457 error::Error GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4458 uint32_t immediate_data_size,
4459 const void* cmd_data) {
4460 const gles2::cmds::CopyTextureCHROMIUM& c =
4461 *static_cast<const gles2::cmds::CopyTextureCHROMIUM*>(cmd_data);
4462 (void)c;
4463 GLenum target = static_cast<GLenum>(c.target);
4464 GLenum source_id = static_cast<GLenum>(c.source_id);
4465 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4466 GLint internalformat = static_cast<GLint>(c.internalformat);
4467 GLenum dest_type = static_cast<GLenum>(c.dest_type);
4468 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4469 GLboolean unpack_premultiply_alpha =
4470 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4471 GLboolean unpack_unmultiply_alpha =
4472 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4473 if (!validators_->texture_internal_format.IsValid(internalformat)) {
4474 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTextureCHROMIUM",
4475 "internalformat GL_INVALID_VALUE");
4476 return error::kNoError;
4478 if (!validators_->pixel_type.IsValid(dest_type)) {
4479 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type,
4480 "dest_type");
4481 return error::kNoError;
4483 DoCopyTextureCHROMIUM(target, source_id, dest_id, internalformat, dest_type,
4484 unpack_flip_y, unpack_premultiply_alpha,
4485 unpack_unmultiply_alpha);
4486 return error::kNoError;
4489 error::Error GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4490 uint32_t immediate_data_size,
4491 const void* cmd_data) {
4492 const gles2::cmds::CopySubTextureCHROMIUM& c =
4493 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM*>(cmd_data);
4494 (void)c;
4495 GLenum target = static_cast<GLenum>(c.target);
4496 GLenum source_id = static_cast<GLenum>(c.source_id);
4497 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4498 GLint xoffset = static_cast<GLint>(c.xoffset);
4499 GLint yoffset = static_cast<GLint>(c.yoffset);
4500 GLint x = static_cast<GLint>(c.x);
4501 GLint y = static_cast<GLint>(c.y);
4502 GLsizei width = static_cast<GLsizei>(c.width);
4503 GLsizei height = static_cast<GLsizei>(c.height);
4504 GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
4505 GLboolean unpack_premultiply_alpha =
4506 static_cast<GLboolean>(c.unpack_premultiply_alpha);
4507 GLboolean unpack_unmultiply_alpha =
4508 static_cast<GLboolean>(c.unpack_unmultiply_alpha);
4509 if (width < 0) {
4510 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4511 "width < 0");
4512 return error::kNoError;
4514 if (height < 0) {
4515 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
4516 "height < 0");
4517 return error::kNoError;
4519 DoCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset, yoffset, x, y,
4520 width, height, unpack_flip_y,
4521 unpack_premultiply_alpha, unpack_unmultiply_alpha);
4522 return error::kNoError;
4525 error::Error GLES2DecoderImpl::HandleCompressedCopyTextureCHROMIUM(
4526 uint32_t immediate_data_size,
4527 const void* cmd_data) {
4528 const gles2::cmds::CompressedCopyTextureCHROMIUM& c =
4529 *static_cast<const gles2::cmds::CompressedCopyTextureCHROMIUM*>(cmd_data);
4530 (void)c;
4531 GLenum target = static_cast<GLenum>(c.target);
4532 GLenum source_id = static_cast<GLenum>(c.source_id);
4533 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4534 DoCompressedCopyTextureCHROMIUM(target, source_id, dest_id);
4535 return error::kNoError;
4538 error::Error GLES2DecoderImpl::HandleCompressedCopySubTextureCHROMIUM(
4539 uint32_t immediate_data_size,
4540 const void* cmd_data) {
4541 const gles2::cmds::CompressedCopySubTextureCHROMIUM& c =
4542 *static_cast<const gles2::cmds::CompressedCopySubTextureCHROMIUM*>(
4543 cmd_data);
4544 (void)c;
4545 GLenum target = static_cast<GLenum>(c.target);
4546 GLenum source_id = static_cast<GLenum>(c.source_id);
4547 GLenum dest_id = static_cast<GLenum>(c.dest_id);
4548 GLint xoffset = static_cast<GLint>(c.xoffset);
4549 GLint yoffset = static_cast<GLint>(c.yoffset);
4550 GLint x = static_cast<GLint>(c.x);
4551 GLint y = static_cast<GLint>(c.y);
4552 GLsizei width = static_cast<GLsizei>(c.width);
4553 GLsizei height = static_cast<GLsizei>(c.height);
4554 if (width < 0) {
4555 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
4556 "width < 0");
4557 return error::kNoError;
4559 if (height < 0) {
4560 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
4561 "height < 0");
4562 return error::kNoError;
4564 DoCompressedCopySubTextureCHROMIUM(target, source_id, dest_id, xoffset,
4565 yoffset, x, y, width, height);
4566 return error::kNoError;
4569 error::Error GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4570 uint32_t immediate_data_size,
4571 const void* cmd_data) {
4572 const gles2::cmds::ProduceTextureCHROMIUMImmediate& c =
4573 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate*>(
4574 cmd_data);
4575 (void)c;
4576 GLenum target = static_cast<GLenum>(c.target);
4577 uint32_t data_size;
4578 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4579 return error::kOutOfBounds;
4581 if (data_size > immediate_data_size) {
4582 return error::kOutOfBounds;
4584 const GLbyte* mailbox =
4585 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4586 if (!validators_->texture_bind_target.IsValid(target)) {
4587 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target,
4588 "target");
4589 return error::kNoError;
4591 if (mailbox == NULL) {
4592 return error::kOutOfBounds;
4594 DoProduceTextureCHROMIUM(target, mailbox);
4595 return error::kNoError;
4598 error::Error GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4599 uint32_t immediate_data_size,
4600 const void* cmd_data) {
4601 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate& c =
4602 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate*>(
4603 cmd_data);
4604 (void)c;
4605 GLuint texture = c.texture;
4606 GLenum target = static_cast<GLenum>(c.target);
4607 uint32_t data_size;
4608 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4609 return error::kOutOfBounds;
4611 if (data_size > immediate_data_size) {
4612 return error::kOutOfBounds;
4614 const GLbyte* mailbox =
4615 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4616 if (!validators_->texture_bind_target.IsValid(target)) {
4617 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target,
4618 "target");
4619 return error::kNoError;
4621 if (mailbox == NULL) {
4622 return error::kOutOfBounds;
4624 DoProduceTextureDirectCHROMIUM(texture, target, mailbox);
4625 return error::kNoError;
4628 error::Error GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4629 uint32_t immediate_data_size,
4630 const void* cmd_data) {
4631 const gles2::cmds::ConsumeTextureCHROMIUMImmediate& c =
4632 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate*>(
4633 cmd_data);
4634 (void)c;
4635 GLenum target = static_cast<GLenum>(c.target);
4636 uint32_t data_size;
4637 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
4638 return error::kOutOfBounds;
4640 if (data_size > immediate_data_size) {
4641 return error::kOutOfBounds;
4643 const GLbyte* mailbox =
4644 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
4645 if (!validators_->texture_bind_target.IsValid(target)) {
4646 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target,
4647 "target");
4648 return error::kNoError;
4650 if (mailbox == NULL) {
4651 return error::kOutOfBounds;
4653 DoConsumeTextureCHROMIUM(target, mailbox);
4654 return error::kNoError;
4657 error::Error GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4658 uint32_t immediate_data_size,
4659 const void* cmd_data) {
4660 const gles2::cmds::GenValuebuffersCHROMIUMImmediate& c =
4661 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate*>(
4662 cmd_data);
4663 (void)c;
4664 GLsizei n = static_cast<GLsizei>(c.n);
4665 uint32_t data_size;
4666 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4667 return error::kOutOfBounds;
4669 GLuint* buffers =
4670 GetImmediateDataAs<GLuint*>(c, data_size, immediate_data_size);
4671 if (buffers == NULL) {
4672 return error::kOutOfBounds;
4674 if (!GenValuebuffersCHROMIUMHelper(n, buffers)) {
4675 return error::kInvalidArguments;
4677 return error::kNoError;
4680 error::Error GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4681 uint32_t immediate_data_size,
4682 const void* cmd_data) {
4683 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate& c =
4684 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate*>(
4685 cmd_data);
4686 (void)c;
4687 GLsizei n = static_cast<GLsizei>(c.n);
4688 uint32_t data_size;
4689 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4690 return error::kOutOfBounds;
4692 const GLuint* valuebuffers =
4693 GetImmediateDataAs<const GLuint*>(c, data_size, immediate_data_size);
4694 if (valuebuffers == NULL) {
4695 return error::kOutOfBounds;
4697 DeleteValuebuffersCHROMIUMHelper(n, valuebuffers);
4698 return error::kNoError;
4701 error::Error GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4702 uint32_t immediate_data_size,
4703 const void* cmd_data) {
4704 const gles2::cmds::IsValuebufferCHROMIUM& c =
4705 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM*>(cmd_data);
4706 (void)c;
4707 GLuint valuebuffer = c.valuebuffer;
4708 typedef cmds::IsValuebufferCHROMIUM::Result Result;
4709 Result* result_dst = GetSharedMemoryAs<Result*>(
4710 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
4711 if (!result_dst) {
4712 return error::kOutOfBounds;
4714 *result_dst = DoIsValuebufferCHROMIUM(valuebuffer);
4715 return error::kNoError;
4718 error::Error GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4719 uint32_t immediate_data_size,
4720 const void* cmd_data) {
4721 const gles2::cmds::BindValuebufferCHROMIUM& c =
4722 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM*>(cmd_data);
4723 (void)c;
4724 GLenum target = static_cast<GLenum>(c.target);
4725 GLuint valuebuffer = c.valuebuffer;
4726 if (!validators_->value_buffer_target.IsValid(target)) {
4727 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target,
4728 "target");
4729 return error::kNoError;
4731 DoBindValueBufferCHROMIUM(target, valuebuffer);
4732 return error::kNoError;
4735 error::Error GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4736 uint32_t immediate_data_size,
4737 const void* cmd_data) {
4738 const gles2::cmds::SubscribeValueCHROMIUM& c =
4739 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM*>(cmd_data);
4740 (void)c;
4741 GLenum target = static_cast<GLenum>(c.target);
4742 GLenum subscription = static_cast<GLenum>(c.subscription);
4743 if (!validators_->value_buffer_target.IsValid(target)) {
4744 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target,
4745 "target");
4746 return error::kNoError;
4748 if (!validators_->subscription_target.IsValid(subscription)) {
4749 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription,
4750 "subscription");
4751 return error::kNoError;
4753 DoSubscribeValueCHROMIUM(target, subscription);
4754 return error::kNoError;
4757 error::Error GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4758 uint32_t immediate_data_size,
4759 const void* cmd_data) {
4760 const gles2::cmds::PopulateSubscribedValuesCHROMIUM& c =
4761 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM*>(
4762 cmd_data);
4763 (void)c;
4764 GLenum target = static_cast<GLenum>(c.target);
4765 if (!validators_->value_buffer_target.IsValid(target)) {
4766 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4767 target, "target");
4768 return error::kNoError;
4770 DoPopulateSubscribedValuesCHROMIUM(target);
4771 return error::kNoError;
4774 error::Error GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4775 uint32_t immediate_data_size,
4776 const void* cmd_data) {
4777 const gles2::cmds::UniformValuebufferCHROMIUM& c =
4778 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM*>(cmd_data);
4779 (void)c;
4780 GLint location = static_cast<GLint>(c.location);
4781 GLenum target = static_cast<GLenum>(c.target);
4782 GLenum subscription = static_cast<GLenum>(c.subscription);
4783 if (!validators_->value_buffer_target.IsValid(target)) {
4784 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target,
4785 "target");
4786 return error::kNoError;
4788 if (!validators_->subscription_target.IsValid(subscription)) {
4789 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4790 subscription, "subscription");
4791 return error::kNoError;
4793 DoUniformValueBufferCHROMIUM(location, target, subscription);
4794 return error::kNoError;
4797 error::Error GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4798 uint32_t immediate_data_size,
4799 const void* cmd_data) {
4800 const gles2::cmds::BindTexImage2DCHROMIUM& c =
4801 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM*>(cmd_data);
4802 (void)c;
4803 GLenum target = static_cast<GLenum>(c.target);
4804 GLint imageId = static_cast<GLint>(c.imageId);
4805 if (!validators_->texture_bind_target.IsValid(target)) {
4806 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target,
4807 "target");
4808 return error::kNoError;
4810 DoBindTexImage2DCHROMIUM(target, imageId);
4811 return error::kNoError;
4814 error::Error GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4815 uint32_t immediate_data_size,
4816 const void* cmd_data) {
4817 const gles2::cmds::ReleaseTexImage2DCHROMIUM& c =
4818 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM*>(cmd_data);
4819 (void)c;
4820 GLenum target = static_cast<GLenum>(c.target);
4821 GLint imageId = static_cast<GLint>(c.imageId);
4822 if (!validators_->texture_bind_target.IsValid(target)) {
4823 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target,
4824 "target");
4825 return error::kNoError;
4827 DoReleaseTexImage2DCHROMIUM(target, imageId);
4828 return error::kNoError;
4831 error::Error GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4832 uint32_t immediate_data_size,
4833 const void* cmd_data) {
4834 const gles2::cmds::TraceEndCHROMIUM& c =
4835 *static_cast<const gles2::cmds::TraceEndCHROMIUM*>(cmd_data);
4836 (void)c;
4837 DoTraceEndCHROMIUM();
4838 return error::kNoError;
4841 error::Error GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4842 uint32_t immediate_data_size,
4843 const void* cmd_data) {
4844 const gles2::cmds::DiscardFramebufferEXTImmediate& c =
4845 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate*>(
4846 cmd_data);
4847 (void)c;
4848 if (!features().ext_discard_framebuffer) {
4849 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDiscardFramebufferEXT",
4850 "function not available");
4851 return error::kNoError;
4854 GLenum target = static_cast<GLenum>(c.target);
4855 GLsizei count = static_cast<GLsizei>(c.count);
4856 uint32_t data_size;
4857 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4858 return error::kOutOfBounds;
4860 if (data_size > immediate_data_size) {
4861 return error::kOutOfBounds;
4863 const GLenum* attachments =
4864 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4865 if (count < 0) {
4866 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDiscardFramebufferEXT",
4867 "count < 0");
4868 return error::kNoError;
4870 if (attachments == NULL) {
4871 return error::kOutOfBounds;
4873 DoDiscardFramebufferEXT(target, count, attachments);
4874 return error::kNoError;
4877 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4878 uint32_t immediate_data_size,
4879 const void* cmd_data) {
4880 const gles2::cmds::LoseContextCHROMIUM& c =
4881 *static_cast<const gles2::cmds::LoseContextCHROMIUM*>(cmd_data);
4882 (void)c;
4883 GLenum current = static_cast<GLenum>(c.current);
4884 GLenum other = static_cast<GLenum>(c.other);
4885 if (!validators_->reset_status.IsValid(current)) {
4886 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
4887 "current");
4888 return error::kNoError;
4890 if (!validators_->reset_status.IsValid(other)) {
4891 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
4892 return error::kNoError;
4894 DoLoseContextCHROMIUM(current, other);
4895 return error::kNoError;
4898 error::Error GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4899 uint32_t immediate_data_size,
4900 const void* cmd_data) {
4901 const gles2::cmds::DrawBuffersEXTImmediate& c =
4902 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate*>(cmd_data);
4903 (void)c;
4904 GLsizei count = static_cast<GLsizei>(c.count);
4905 uint32_t data_size;
4906 if (!ComputeDataSize(count, sizeof(GLenum), 1, &data_size)) {
4907 return error::kOutOfBounds;
4909 if (data_size > immediate_data_size) {
4910 return error::kOutOfBounds;
4912 const GLenum* bufs =
4913 GetImmediateDataAs<const GLenum*>(c, data_size, immediate_data_size);
4914 if (count < 0) {
4915 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
4916 return error::kNoError;
4918 if (bufs == NULL) {
4919 return error::kOutOfBounds;
4921 DoDrawBuffersEXT(count, bufs);
4922 return error::kNoError;
4925 error::Error GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size,
4926 const void* cmd_data) {
4927 const gles2::cmds::SwapInterval& c =
4928 *static_cast<const gles2::cmds::SwapInterval*>(cmd_data);
4929 (void)c;
4930 GLint interval = static_cast<GLint>(c.interval);
4931 DoSwapInterval(interval);
4932 return error::kNoError;
4935 error::Error GLES2DecoderImpl::HandleFlushDriverCachesCHROMIUM(
4936 uint32_t immediate_data_size,
4937 const void* cmd_data) {
4938 const gles2::cmds::FlushDriverCachesCHROMIUM& c =
4939 *static_cast<const gles2::cmds::FlushDriverCachesCHROMIUM*>(cmd_data);
4940 (void)c;
4941 DoFlushDriverCachesCHROMIUM();
4942 return error::kNoError;
4945 error::Error GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4946 uint32_t immediate_data_size,
4947 const void* cmd_data) {
4948 const gles2::cmds::MatrixLoadfCHROMIUMImmediate& c =
4949 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate*>(cmd_data);
4950 (void)c;
4951 if (!features().chromium_path_rendering) {
4952 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadfCHROMIUM",
4953 "function not available");
4954 return error::kNoError;
4957 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4958 uint32_t data_size;
4959 if (!ComputeDataSize(1, sizeof(GLfloat), 16, &data_size)) {
4960 return error::kOutOfBounds;
4962 if (data_size > immediate_data_size) {
4963 return error::kOutOfBounds;
4965 const GLfloat* m =
4966 GetImmediateDataAs<const GLfloat*>(c, data_size, immediate_data_size);
4967 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4968 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode,
4969 "matrixMode");
4970 return error::kNoError;
4972 if (m == NULL) {
4973 return error::kOutOfBounds;
4975 DoMatrixLoadfCHROMIUM(matrixMode, m);
4976 return error::kNoError;
4979 error::Error GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
4980 uint32_t immediate_data_size,
4981 const void* cmd_data) {
4982 const gles2::cmds::MatrixLoadIdentityCHROMIUM& c =
4983 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM*>(cmd_data);
4984 (void)c;
4985 if (!features().chromium_path_rendering) {
4986 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glMatrixLoadIdentityCHROMIUM",
4987 "function not available");
4988 return error::kNoError;
4991 GLenum matrixMode = static_cast<GLenum>(c.matrixMode);
4992 if (!validators_->matrix_mode.IsValid(matrixMode)) {
4993 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode,
4994 "matrixMode");
4995 return error::kNoError;
4997 DoMatrixLoadIdentityCHROMIUM(matrixMode);
4998 return error::kNoError;
5001 error::Error GLES2DecoderImpl::HandleIsPathCHROMIUM(
5002 uint32_t immediate_data_size,
5003 const void* cmd_data) {
5004 const gles2::cmds::IsPathCHROMIUM& c =
5005 *static_cast<const gles2::cmds::IsPathCHROMIUM*>(cmd_data);
5006 (void)c;
5007 if (!features().chromium_path_rendering) {
5008 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glIsPathCHROMIUM",
5009 "function not available");
5010 return error::kNoError;
5013 GLuint path = c.path;
5014 typedef cmds::IsPathCHROMIUM::Result Result;
5015 Result* result_dst = GetSharedMemoryAs<Result*>(
5016 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
5017 if (!result_dst) {
5018 return error::kOutOfBounds;
5020 *result_dst = DoIsPathCHROMIUM(path);
5021 return error::kNoError;
5024 error::Error GLES2DecoderImpl::HandlePathStencilFuncCHROMIUM(
5025 uint32_t immediate_data_size,
5026 const void* cmd_data) {
5027 const gles2::cmds::PathStencilFuncCHROMIUM& c =
5028 *static_cast<const gles2::cmds::PathStencilFuncCHROMIUM*>(cmd_data);
5029 (void)c;
5030 if (!features().chromium_path_rendering) {
5031 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glPathStencilFuncCHROMIUM",
5032 "function not available");
5033 return error::kNoError;
5036 GLenum func = static_cast<GLenum>(c.func);
5037 GLint ref = static_cast<GLint>(c.ref);
5038 GLuint mask = static_cast<GLuint>(c.mask);
5039 if (!validators_->cmp_function.IsValid(func)) {
5040 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPathStencilFuncCHROMIUM", func, "func");
5041 return error::kNoError;
5043 if (state_.stencil_path_func != func || state_.stencil_path_ref != ref ||
5044 state_.stencil_path_mask != mask) {
5045 state_.stencil_path_func = func;
5046 state_.stencil_path_ref = ref;
5047 state_.stencil_path_mask = mask;
5048 glPathStencilFuncNV(func, ref, mask);
5050 return error::kNoError;
5053 error::Error GLES2DecoderImpl::HandleBlendBarrierKHR(
5054 uint32_t immediate_data_size,
5055 const void* cmd_data) {
5056 const gles2::cmds::BlendBarrierKHR& c =
5057 *static_cast<const gles2::cmds::BlendBarrierKHR*>(cmd_data);
5058 (void)c;
5059 if (!features().blend_equation_advanced) {
5060 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBlendBarrierKHR",
5061 "function not available");
5062 return error::kNoError;
5065 glBlendBarrierKHR();
5066 return error::kNoError;
5069 error::Error GLES2DecoderImpl::HandleApplyScreenSpaceAntialiasingCHROMIUM(
5070 uint32_t immediate_data_size,
5071 const void* cmd_data) {
5072 const gles2::cmds::ApplyScreenSpaceAntialiasingCHROMIUM& c =
5073 *static_cast<const gles2::cmds::ApplyScreenSpaceAntialiasingCHROMIUM*>(
5074 cmd_data);
5075 (void)c;
5076 if (!features().chromium_screen_space_antialiasing) {
5077 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
5078 "glApplyScreenSpaceAntialiasingCHROMIUM",
5079 "function not available");
5080 return error::kNoError;
5083 DoApplyScreenSpaceAntialiasingCHROMIUM();
5084 return error::kNoError;
5087 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
5088 switch (cap) {
5089 case GL_BLEND:
5090 state_.enable_flags.blend = enabled;
5091 if (state_.enable_flags.cached_blend != enabled ||
5092 state_.ignore_cached_state) {
5093 state_.enable_flags.cached_blend = enabled;
5094 return true;
5096 return false;
5097 case GL_CULL_FACE:
5098 state_.enable_flags.cull_face = enabled;
5099 if (state_.enable_flags.cached_cull_face != enabled ||
5100 state_.ignore_cached_state) {
5101 state_.enable_flags.cached_cull_face = enabled;
5102 return true;
5104 return false;
5105 case GL_DEPTH_TEST:
5106 state_.enable_flags.depth_test = enabled;
5107 if (state_.enable_flags.cached_depth_test != enabled ||
5108 state_.ignore_cached_state) {
5109 framebuffer_state_.clear_state_dirty = true;
5111 return false;
5112 case GL_DITHER:
5113 state_.enable_flags.dither = enabled;
5114 if (state_.enable_flags.cached_dither != enabled ||
5115 state_.ignore_cached_state) {
5116 state_.enable_flags.cached_dither = enabled;
5117 return true;
5119 return false;
5120 case GL_POLYGON_OFFSET_FILL:
5121 state_.enable_flags.polygon_offset_fill = enabled;
5122 if (state_.enable_flags.cached_polygon_offset_fill != enabled ||
5123 state_.ignore_cached_state) {
5124 state_.enable_flags.cached_polygon_offset_fill = enabled;
5125 return true;
5127 return false;
5128 case GL_SAMPLE_ALPHA_TO_COVERAGE:
5129 state_.enable_flags.sample_alpha_to_coverage = enabled;
5130 if (state_.enable_flags.cached_sample_alpha_to_coverage != enabled ||
5131 state_.ignore_cached_state) {
5132 state_.enable_flags.cached_sample_alpha_to_coverage = enabled;
5133 return true;
5135 return false;
5136 case GL_SAMPLE_COVERAGE:
5137 state_.enable_flags.sample_coverage = enabled;
5138 if (state_.enable_flags.cached_sample_coverage != enabled ||
5139 state_.ignore_cached_state) {
5140 state_.enable_flags.cached_sample_coverage = enabled;
5141 return true;
5143 return false;
5144 case GL_SCISSOR_TEST:
5145 state_.enable_flags.scissor_test = enabled;
5146 if (state_.enable_flags.cached_scissor_test != enabled ||
5147 state_.ignore_cached_state) {
5148 state_.enable_flags.cached_scissor_test = enabled;
5149 return true;
5151 return false;
5152 case GL_STENCIL_TEST:
5153 state_.enable_flags.stencil_test = enabled;
5154 if (state_.enable_flags.cached_stencil_test != enabled ||
5155 state_.ignore_cached_state) {
5156 framebuffer_state_.clear_state_dirty = true;
5158 return false;
5159 case GL_RASTERIZER_DISCARD:
5160 state_.enable_flags.rasterizer_discard = enabled;
5161 if (state_.enable_flags.cached_rasterizer_discard != enabled ||
5162 state_.ignore_cached_state) {
5163 state_.enable_flags.cached_rasterizer_discard = enabled;
5164 return true;
5166 return false;
5167 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
5168 state_.enable_flags.primitive_restart_fixed_index = enabled;
5169 if (state_.enable_flags.cached_primitive_restart_fixed_index != enabled ||
5170 state_.ignore_cached_state) {
5171 state_.enable_flags.cached_primitive_restart_fixed_index = enabled;
5172 return true;
5174 return false;
5175 default:
5176 NOTREACHED();
5177 return false;
5180 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_