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
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(
16 uint32_t immediate_data_size
,
17 const gles2::cmds::ActiveTexture
& c
) {
18 GLenum texture
= static_cast<GLenum
>(c
.texture
);
19 DoActiveTexture(texture
);
20 return error::kNoError
;
23 error::Error
GLES2DecoderImpl::HandleAttachShader(
24 uint32_t immediate_data_size
,
25 const gles2::cmds::AttachShader
& c
) {
26 GLuint program
= c
.program
;
27 GLuint shader
= c
.shader
;
28 DoAttachShader(program
, shader
);
29 return error::kNoError
;
32 error::Error
GLES2DecoderImpl::HandleBindBuffer(
33 uint32_t immediate_data_size
,
34 const gles2::cmds::BindBuffer
& c
) {
35 GLenum target
= static_cast<GLenum
>(c
.target
);
36 GLuint buffer
= c
.buffer
;
37 if (!validators_
->buffer_target
.IsValid(target
)) {
38 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBuffer", target
, "target");
39 return error::kNoError
;
41 DoBindBuffer(target
, buffer
);
42 return error::kNoError
;
45 error::Error
GLES2DecoderImpl::HandleBindFramebuffer(
46 uint32_t immediate_data_size
,
47 const gles2::cmds::BindFramebuffer
& c
) {
48 GLenum target
= static_cast<GLenum
>(c
.target
);
49 GLuint framebuffer
= c
.framebuffer
;
50 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
51 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target
, "target");
52 return error::kNoError
;
54 DoBindFramebuffer(target
, framebuffer
);
55 return error::kNoError
;
58 error::Error
GLES2DecoderImpl::HandleBindRenderbuffer(
59 uint32_t immediate_data_size
,
60 const gles2::cmds::BindRenderbuffer
& c
) {
61 GLenum target
= static_cast<GLenum
>(c
.target
);
62 GLuint renderbuffer
= c
.renderbuffer
;
63 if (!validators_
->render_buffer_target
.IsValid(target
)) {
64 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target
, "target");
65 return error::kNoError
;
67 DoBindRenderbuffer(target
, renderbuffer
);
68 return error::kNoError
;
71 error::Error
GLES2DecoderImpl::HandleBindTexture(
72 uint32_t immediate_data_size
,
73 const gles2::cmds::BindTexture
& c
) {
74 GLenum target
= static_cast<GLenum
>(c
.target
);
75 GLuint texture
= c
.texture
;
76 if (!validators_
->texture_bind_target
.IsValid(target
)) {
77 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target
, "target");
78 return error::kNoError
;
80 DoBindTexture(target
, texture
);
81 return error::kNoError
;
84 error::Error
GLES2DecoderImpl::HandleBlendColor(
85 uint32_t immediate_data_size
,
86 const gles2::cmds::BlendColor
& c
) {
87 GLclampf red
= static_cast<GLclampf
>(c
.red
);
88 GLclampf green
= static_cast<GLclampf
>(c
.green
);
89 GLclampf blue
= static_cast<GLclampf
>(c
.blue
);
90 GLclampf alpha
= static_cast<GLclampf
>(c
.alpha
);
91 if (state_
.blend_color_red
!= red
|| state_
.blend_color_green
!= green
||
92 state_
.blend_color_blue
!= blue
|| state_
.blend_color_alpha
!= alpha
) {
93 state_
.blend_color_red
= red
;
94 state_
.blend_color_green
= green
;
95 state_
.blend_color_blue
= blue
;
96 state_
.blend_color_alpha
= alpha
;
97 glBlendColor(red
, green
, blue
, alpha
);
99 return error::kNoError
;
102 error::Error
GLES2DecoderImpl::HandleBlendEquation(
103 uint32_t immediate_data_size
,
104 const gles2::cmds::BlendEquation
& c
) {
105 GLenum mode
= static_cast<GLenum
>(c
.mode
);
106 if (!validators_
->equation
.IsValid(mode
)) {
107 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode
, "mode");
108 return error::kNoError
;
110 if (state_
.blend_equation_rgb
!= mode
||
111 state_
.blend_equation_alpha
!= mode
) {
112 state_
.blend_equation_rgb
= mode
;
113 state_
.blend_equation_alpha
= mode
;
114 glBlendEquation(mode
);
116 return error::kNoError
;
119 error::Error
GLES2DecoderImpl::HandleBlendEquationSeparate(
120 uint32_t immediate_data_size
,
121 const gles2::cmds::BlendEquationSeparate
& c
) {
122 GLenum modeRGB
= static_cast<GLenum
>(c
.modeRGB
);
123 GLenum modeAlpha
= static_cast<GLenum
>(c
.modeAlpha
);
124 if (!validators_
->equation
.IsValid(modeRGB
)) {
125 LOCAL_SET_GL_ERROR_INVALID_ENUM(
126 "glBlendEquationSeparate", modeRGB
, "modeRGB");
127 return error::kNoError
;
129 if (!validators_
->equation
.IsValid(modeAlpha
)) {
130 LOCAL_SET_GL_ERROR_INVALID_ENUM(
131 "glBlendEquationSeparate", modeAlpha
, "modeAlpha");
132 return error::kNoError
;
134 if (state_
.blend_equation_rgb
!= modeRGB
||
135 state_
.blend_equation_alpha
!= modeAlpha
) {
136 state_
.blend_equation_rgb
= modeRGB
;
137 state_
.blend_equation_alpha
= modeAlpha
;
138 glBlendEquationSeparate(modeRGB
, modeAlpha
);
140 return error::kNoError
;
143 error::Error
GLES2DecoderImpl::HandleBlendFunc(
144 uint32_t immediate_data_size
,
145 const gles2::cmds::BlendFunc
& c
) {
146 GLenum sfactor
= static_cast<GLenum
>(c
.sfactor
);
147 GLenum dfactor
= static_cast<GLenum
>(c
.dfactor
);
148 if (!validators_
->src_blend_factor
.IsValid(sfactor
)) {
149 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor
, "sfactor");
150 return error::kNoError
;
152 if (!validators_
->dst_blend_factor
.IsValid(dfactor
)) {
153 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor
, "dfactor");
154 return error::kNoError
;
156 if (state_
.blend_source_rgb
!= sfactor
|| state_
.blend_dest_rgb
!= dfactor
||
157 state_
.blend_source_alpha
!= sfactor
||
158 state_
.blend_dest_alpha
!= dfactor
) {
159 state_
.blend_source_rgb
= sfactor
;
160 state_
.blend_dest_rgb
= dfactor
;
161 state_
.blend_source_alpha
= sfactor
;
162 state_
.blend_dest_alpha
= dfactor
;
163 glBlendFunc(sfactor
, dfactor
);
165 return error::kNoError
;
168 error::Error
GLES2DecoderImpl::HandleBlendFuncSeparate(
169 uint32_t immediate_data_size
,
170 const gles2::cmds::BlendFuncSeparate
& c
) {
171 GLenum srcRGB
= static_cast<GLenum
>(c
.srcRGB
);
172 GLenum dstRGB
= static_cast<GLenum
>(c
.dstRGB
);
173 GLenum srcAlpha
= static_cast<GLenum
>(c
.srcAlpha
);
174 GLenum dstAlpha
= static_cast<GLenum
>(c
.dstAlpha
);
175 if (!validators_
->src_blend_factor
.IsValid(srcRGB
)) {
176 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB
, "srcRGB");
177 return error::kNoError
;
179 if (!validators_
->dst_blend_factor
.IsValid(dstRGB
)) {
180 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB
, "dstRGB");
181 return error::kNoError
;
183 if (!validators_
->src_blend_factor
.IsValid(srcAlpha
)) {
184 LOCAL_SET_GL_ERROR_INVALID_ENUM(
185 "glBlendFuncSeparate", srcAlpha
, "srcAlpha");
186 return error::kNoError
;
188 if (!validators_
->dst_blend_factor
.IsValid(dstAlpha
)) {
189 LOCAL_SET_GL_ERROR_INVALID_ENUM(
190 "glBlendFuncSeparate", dstAlpha
, "dstAlpha");
191 return error::kNoError
;
193 if (state_
.blend_source_rgb
!= srcRGB
|| state_
.blend_dest_rgb
!= dstRGB
||
194 state_
.blend_source_alpha
!= srcAlpha
||
195 state_
.blend_dest_alpha
!= dstAlpha
) {
196 state_
.blend_source_rgb
= srcRGB
;
197 state_
.blend_dest_rgb
= dstRGB
;
198 state_
.blend_source_alpha
= srcAlpha
;
199 state_
.blend_dest_alpha
= dstAlpha
;
200 glBlendFuncSeparate(srcRGB
, dstRGB
, srcAlpha
, dstAlpha
);
202 return error::kNoError
;
205 error::Error
GLES2DecoderImpl::HandleBufferSubData(
206 uint32_t immediate_data_size
,
207 const gles2::cmds::BufferSubData
& c
) {
208 GLenum target
= static_cast<GLenum
>(c
.target
);
209 GLintptr offset
= static_cast<GLintptr
>(c
.offset
);
210 GLsizeiptr size
= static_cast<GLsizeiptr
>(c
.size
);
211 uint32_t data_size
= size
;
212 const void* data
= GetSharedMemoryAs
<const void*>(
213 c
.data_shm_id
, c
.data_shm_offset
, data_size
);
214 if (!validators_
->buffer_target
.IsValid(target
)) {
215 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target
, "target");
216 return error::kNoError
;
219 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glBufferSubData", "size < 0");
220 return error::kNoError
;
223 return error::kOutOfBounds
;
225 DoBufferSubData(target
, offset
, size
, data
);
226 return error::kNoError
;
229 error::Error
GLES2DecoderImpl::HandleCheckFramebufferStatus(
230 uint32_t immediate_data_size
,
231 const gles2::cmds::CheckFramebufferStatus
& c
) {
232 GLenum target
= static_cast<GLenum
>(c
.target
);
233 typedef cmds::CheckFramebufferStatus::Result Result
;
234 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
235 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
237 return error::kOutOfBounds
;
239 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
240 LOCAL_SET_GL_ERROR_INVALID_ENUM(
241 "glCheckFramebufferStatus", target
, "target");
242 return error::kNoError
;
244 *result_dst
= DoCheckFramebufferStatus(target
);
245 return error::kNoError
;
248 error::Error
GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size
,
249 const gles2::cmds::Clear
& c
) {
251 error
= WillAccessBoundFramebufferForDraw();
252 if (error
!= error::kNoError
)
254 GLbitfield mask
= static_cast<GLbitfield
>(c
.mask
);
256 return error::kNoError
;
259 error::Error
GLES2DecoderImpl::HandleClearColor(
260 uint32_t immediate_data_size
,
261 const gles2::cmds::ClearColor
& c
) {
262 GLclampf red
= static_cast<GLclampf
>(c
.red
);
263 GLclampf green
= static_cast<GLclampf
>(c
.green
);
264 GLclampf blue
= static_cast<GLclampf
>(c
.blue
);
265 GLclampf alpha
= static_cast<GLclampf
>(c
.alpha
);
266 if (state_
.color_clear_red
!= red
|| state_
.color_clear_green
!= green
||
267 state_
.color_clear_blue
!= blue
|| state_
.color_clear_alpha
!= alpha
) {
268 state_
.color_clear_red
= red
;
269 state_
.color_clear_green
= green
;
270 state_
.color_clear_blue
= blue
;
271 state_
.color_clear_alpha
= alpha
;
272 glClearColor(red
, green
, blue
, alpha
);
274 return error::kNoError
;
277 error::Error
GLES2DecoderImpl::HandleClearDepthf(
278 uint32_t immediate_data_size
,
279 const gles2::cmds::ClearDepthf
& c
) {
280 GLclampf depth
= static_cast<GLclampf
>(c
.depth
);
281 if (state_
.depth_clear
!= depth
) {
282 state_
.depth_clear
= depth
;
285 return error::kNoError
;
288 error::Error
GLES2DecoderImpl::HandleClearStencil(
289 uint32_t immediate_data_size
,
290 const gles2::cmds::ClearStencil
& c
) {
291 GLint s
= static_cast<GLint
>(c
.s
);
292 if (state_
.stencil_clear
!= s
) {
293 state_
.stencil_clear
= s
;
296 return error::kNoError
;
299 error::Error
GLES2DecoderImpl::HandleColorMask(
300 uint32_t immediate_data_size
,
301 const gles2::cmds::ColorMask
& c
) {
302 GLboolean red
= static_cast<GLboolean
>(c
.red
);
303 GLboolean green
= static_cast<GLboolean
>(c
.green
);
304 GLboolean blue
= static_cast<GLboolean
>(c
.blue
);
305 GLboolean alpha
= static_cast<GLboolean
>(c
.alpha
);
306 if (state_
.color_mask_red
!= red
|| state_
.color_mask_green
!= green
||
307 state_
.color_mask_blue
!= blue
|| state_
.color_mask_alpha
!= alpha
) {
308 state_
.color_mask_red
= red
;
309 state_
.color_mask_green
= green
;
310 state_
.color_mask_blue
= blue
;
311 state_
.color_mask_alpha
= alpha
;
312 framebuffer_state_
.clear_state_dirty
= true;
314 return error::kNoError
;
317 error::Error
GLES2DecoderImpl::HandleCompileShader(
318 uint32_t immediate_data_size
,
319 const gles2::cmds::CompileShader
& c
) {
320 GLuint shader
= c
.shader
;
321 DoCompileShader(shader
);
322 return error::kNoError
;
325 error::Error
GLES2DecoderImpl::HandleCompressedTexSubImage2D(
326 uint32_t immediate_data_size
,
327 const gles2::cmds::CompressedTexSubImage2D
& c
) {
328 GLenum target
= static_cast<GLenum
>(c
.target
);
329 GLint level
= static_cast<GLint
>(c
.level
);
330 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
331 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
332 GLsizei width
= static_cast<GLsizei
>(c
.width
);
333 GLsizei height
= static_cast<GLsizei
>(c
.height
);
334 GLenum format
= static_cast<GLenum
>(c
.format
);
335 GLsizei imageSize
= static_cast<GLsizei
>(c
.imageSize
);
336 uint32_t data_size
= imageSize
;
337 const void* data
= GetSharedMemoryAs
<const void*>(
338 c
.data_shm_id
, c
.data_shm_offset
, data_size
);
339 if (!validators_
->texture_target
.IsValid(target
)) {
340 LOCAL_SET_GL_ERROR_INVALID_ENUM(
341 "glCompressedTexSubImage2D", target
, "target");
342 return error::kNoError
;
346 GL_INVALID_VALUE
, "glCompressedTexSubImage2D", "width < 0");
347 return error::kNoError
;
351 GL_INVALID_VALUE
, "glCompressedTexSubImage2D", "height < 0");
352 return error::kNoError
;
354 if (!validators_
->compressed_texture_format
.IsValid(format
)) {
355 LOCAL_SET_GL_ERROR_INVALID_ENUM(
356 "glCompressedTexSubImage2D", format
, "format");
357 return error::kNoError
;
361 GL_INVALID_VALUE
, "glCompressedTexSubImage2D", "imageSize < 0");
362 return error::kNoError
;
365 return error::kOutOfBounds
;
367 DoCompressedTexSubImage2D(
368 target
, level
, xoffset
, yoffset
, width
, height
, format
, imageSize
, data
);
369 return error::kNoError
;
372 error::Error
GLES2DecoderImpl::HandleCopyTexImage2D(
373 uint32_t immediate_data_size
,
374 const gles2::cmds::CopyTexImage2D
& c
) {
376 error
= WillAccessBoundFramebufferForRead();
377 if (error
!= error::kNoError
)
379 GLenum target
= static_cast<GLenum
>(c
.target
);
380 GLint level
= static_cast<GLint
>(c
.level
);
381 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
382 GLint x
= static_cast<GLint
>(c
.x
);
383 GLint y
= static_cast<GLint
>(c
.y
);
384 GLsizei width
= static_cast<GLsizei
>(c
.width
);
385 GLsizei height
= static_cast<GLsizei
>(c
.height
);
386 GLint border
= static_cast<GLint
>(c
.border
);
387 if (!validators_
->texture_target
.IsValid(target
)) {
388 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target
, "target");
389 return error::kNoError
;
391 if (!validators_
->texture_internal_format
.IsValid(internalformat
)) {
392 LOCAL_SET_GL_ERROR_INVALID_ENUM(
393 "glCopyTexImage2D", internalformat
, "internalformat");
394 return error::kNoError
;
397 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexImage2D", "width < 0");
398 return error::kNoError
;
401 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexImage2D", "height < 0");
402 return error::kNoError
;
404 DoCopyTexImage2D(target
, level
, internalformat
, x
, y
, width
, height
, border
);
405 return error::kNoError
;
408 error::Error
GLES2DecoderImpl::HandleCopyTexSubImage2D(
409 uint32_t immediate_data_size
,
410 const gles2::cmds::CopyTexSubImage2D
& c
) {
412 error
= WillAccessBoundFramebufferForRead();
413 if (error
!= error::kNoError
)
415 GLenum target
= static_cast<GLenum
>(c
.target
);
416 GLint level
= static_cast<GLint
>(c
.level
);
417 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
418 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
419 GLint x
= static_cast<GLint
>(c
.x
);
420 GLint y
= static_cast<GLint
>(c
.y
);
421 GLsizei width
= static_cast<GLsizei
>(c
.width
);
422 GLsizei height
= static_cast<GLsizei
>(c
.height
);
423 if (!validators_
->texture_target
.IsValid(target
)) {
424 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target
, "target");
425 return error::kNoError
;
428 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexSubImage2D", "width < 0");
429 return error::kNoError
;
432 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexSubImage2D", "height < 0");
433 return error::kNoError
;
435 DoCopyTexSubImage2D(target
, level
, xoffset
, yoffset
, x
, y
, width
, height
);
436 return error::kNoError
;
439 error::Error
GLES2DecoderImpl::HandleCreateProgram(
440 uint32_t immediate_data_size
,
441 const gles2::cmds::CreateProgram
& c
) {
442 uint32_t client_id
= c
.client_id
;
443 if (!CreateProgramHelper(client_id
)) {
444 return error::kInvalidArguments
;
446 return error::kNoError
;
449 error::Error
GLES2DecoderImpl::HandleCreateShader(
450 uint32_t immediate_data_size
,
451 const gles2::cmds::CreateShader
& c
) {
452 GLenum type
= static_cast<GLenum
>(c
.type
);
453 if (!validators_
->shader_type
.IsValid(type
)) {
454 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type
, "type");
455 return error::kNoError
;
457 uint32_t client_id
= c
.client_id
;
458 if (!CreateShaderHelper(type
, client_id
)) {
459 return error::kInvalidArguments
;
461 return error::kNoError
;
464 error::Error
GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size
,
465 const gles2::cmds::CullFace
& c
) {
466 GLenum mode
= static_cast<GLenum
>(c
.mode
);
467 if (!validators_
->face_type
.IsValid(mode
)) {
468 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode
, "mode");
469 return error::kNoError
;
471 if (state_
.cull_mode
!= mode
) {
472 state_
.cull_mode
= mode
;
475 return error::kNoError
;
478 error::Error
GLES2DecoderImpl::HandleDeleteBuffersImmediate(
479 uint32_t immediate_data_size
,
480 const gles2::cmds::DeleteBuffersImmediate
& c
) {
481 GLsizei n
= static_cast<GLsizei
>(c
.n
);
483 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
484 return error::kOutOfBounds
;
486 const GLuint
* buffers
=
487 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
488 if (buffers
== NULL
) {
489 return error::kOutOfBounds
;
491 DeleteBuffersHelper(n
, buffers
);
492 return error::kNoError
;
495 error::Error
GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
496 uint32_t immediate_data_size
,
497 const gles2::cmds::DeleteFramebuffersImmediate
& c
) {
498 GLsizei n
= static_cast<GLsizei
>(c
.n
);
500 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
501 return error::kOutOfBounds
;
503 const GLuint
* framebuffers
=
504 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
505 if (framebuffers
== NULL
) {
506 return error::kOutOfBounds
;
508 DeleteFramebuffersHelper(n
, framebuffers
);
509 return error::kNoError
;
512 error::Error
GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
513 uint32_t immediate_data_size
,
514 const gles2::cmds::DeleteRenderbuffersImmediate
& c
) {
515 GLsizei n
= static_cast<GLsizei
>(c
.n
);
517 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
518 return error::kOutOfBounds
;
520 const GLuint
* renderbuffers
=
521 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
522 if (renderbuffers
== NULL
) {
523 return error::kOutOfBounds
;
525 DeleteRenderbuffersHelper(n
, renderbuffers
);
526 return error::kNoError
;
529 error::Error
GLES2DecoderImpl::HandleDeleteTexturesImmediate(
530 uint32_t immediate_data_size
,
531 const gles2::cmds::DeleteTexturesImmediate
& c
) {
532 GLsizei n
= static_cast<GLsizei
>(c
.n
);
534 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
535 return error::kOutOfBounds
;
537 const GLuint
* textures
=
538 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
539 if (textures
== NULL
) {
540 return error::kOutOfBounds
;
542 DeleteTexturesHelper(n
, textures
);
543 return error::kNoError
;
546 error::Error
GLES2DecoderImpl::HandleDepthFunc(
547 uint32_t immediate_data_size
,
548 const gles2::cmds::DepthFunc
& c
) {
549 GLenum func
= static_cast<GLenum
>(c
.func
);
550 if (!validators_
->cmp_function
.IsValid(func
)) {
551 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func
, "func");
552 return error::kNoError
;
554 if (state_
.depth_func
!= func
) {
555 state_
.depth_func
= func
;
558 return error::kNoError
;
561 error::Error
GLES2DecoderImpl::HandleDepthMask(
562 uint32_t immediate_data_size
,
563 const gles2::cmds::DepthMask
& c
) {
564 GLboolean flag
= static_cast<GLboolean
>(c
.flag
);
565 if (state_
.depth_mask
!= flag
) {
566 state_
.depth_mask
= flag
;
567 framebuffer_state_
.clear_state_dirty
= true;
569 return error::kNoError
;
572 error::Error
GLES2DecoderImpl::HandleDepthRangef(
573 uint32_t immediate_data_size
,
574 const gles2::cmds::DepthRangef
& c
) {
575 GLclampf zNear
= static_cast<GLclampf
>(c
.zNear
);
576 GLclampf zFar
= static_cast<GLclampf
>(c
.zFar
);
577 DoDepthRangef(zNear
, zFar
);
578 return error::kNoError
;
581 error::Error
GLES2DecoderImpl::HandleDetachShader(
582 uint32_t immediate_data_size
,
583 const gles2::cmds::DetachShader
& c
) {
584 GLuint program
= c
.program
;
585 GLuint shader
= c
.shader
;
586 DoDetachShader(program
, shader
);
587 return error::kNoError
;
590 error::Error
GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size
,
591 const gles2::cmds::Disable
& c
) {
592 GLenum cap
= static_cast<GLenum
>(c
.cap
);
593 if (!validators_
->capability
.IsValid(cap
)) {
594 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap
, "cap");
595 return error::kNoError
;
598 return error::kNoError
;
601 error::Error
GLES2DecoderImpl::HandleDisableVertexAttribArray(
602 uint32_t immediate_data_size
,
603 const gles2::cmds::DisableVertexAttribArray
& c
) {
604 GLuint index
= static_cast<GLuint
>(c
.index
);
605 DoDisableVertexAttribArray(index
);
606 return error::kNoError
;
609 error::Error
GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size
,
610 const gles2::cmds::Enable
& c
) {
611 GLenum cap
= static_cast<GLenum
>(c
.cap
);
612 if (!validators_
->capability
.IsValid(cap
)) {
613 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap
, "cap");
614 return error::kNoError
;
617 return error::kNoError
;
620 error::Error
GLES2DecoderImpl::HandleEnableVertexAttribArray(
621 uint32_t immediate_data_size
,
622 const gles2::cmds::EnableVertexAttribArray
& c
) {
623 GLuint index
= static_cast<GLuint
>(c
.index
);
624 DoEnableVertexAttribArray(index
);
625 return error::kNoError
;
628 error::Error
GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size
,
629 const gles2::cmds::Finish
& c
) {
631 error
= WillAccessBoundFramebufferForRead();
632 if (error
!= error::kNoError
)
635 return error::kNoError
;
638 error::Error
GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size
,
639 const gles2::cmds::Flush
& c
) {
641 return error::kNoError
;
644 error::Error
GLES2DecoderImpl::HandleFramebufferRenderbuffer(
645 uint32_t immediate_data_size
,
646 const gles2::cmds::FramebufferRenderbuffer
& c
) {
647 GLenum target
= static_cast<GLenum
>(c
.target
);
648 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
649 GLenum renderbuffertarget
= static_cast<GLenum
>(c
.renderbuffertarget
);
650 GLuint renderbuffer
= c
.renderbuffer
;
651 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
652 LOCAL_SET_GL_ERROR_INVALID_ENUM(
653 "glFramebufferRenderbuffer", target
, "target");
654 return error::kNoError
;
656 if (!validators_
->attachment
.IsValid(attachment
)) {
657 LOCAL_SET_GL_ERROR_INVALID_ENUM(
658 "glFramebufferRenderbuffer", attachment
, "attachment");
659 return error::kNoError
;
661 if (!validators_
->render_buffer_target
.IsValid(renderbuffertarget
)) {
662 LOCAL_SET_GL_ERROR_INVALID_ENUM(
663 "glFramebufferRenderbuffer", renderbuffertarget
, "renderbuffertarget");
664 return error::kNoError
;
666 DoFramebufferRenderbuffer(
667 target
, attachment
, renderbuffertarget
, renderbuffer
);
668 return error::kNoError
;
671 error::Error
GLES2DecoderImpl::HandleFramebufferTexture2D(
672 uint32_t immediate_data_size
,
673 const gles2::cmds::FramebufferTexture2D
& c
) {
674 GLenum target
= static_cast<GLenum
>(c
.target
);
675 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
676 GLenum textarget
= static_cast<GLenum
>(c
.textarget
);
677 GLuint texture
= c
.texture
;
678 GLint level
= static_cast<GLint
>(c
.level
);
679 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
680 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target
, "target");
681 return error::kNoError
;
683 if (!validators_
->attachment
.IsValid(attachment
)) {
684 LOCAL_SET_GL_ERROR_INVALID_ENUM(
685 "glFramebufferTexture2D", attachment
, "attachment");
686 return error::kNoError
;
688 if (!validators_
->texture_target
.IsValid(textarget
)) {
689 LOCAL_SET_GL_ERROR_INVALID_ENUM(
690 "glFramebufferTexture2D", textarget
, "textarget");
691 return error::kNoError
;
693 DoFramebufferTexture2D(target
, attachment
, textarget
, texture
, level
);
694 return error::kNoError
;
697 error::Error
GLES2DecoderImpl::HandleFrontFace(
698 uint32_t immediate_data_size
,
699 const gles2::cmds::FrontFace
& c
) {
700 GLenum mode
= static_cast<GLenum
>(c
.mode
);
701 if (!validators_
->face_mode
.IsValid(mode
)) {
702 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode
, "mode");
703 return error::kNoError
;
705 if (state_
.front_face
!= mode
) {
706 state_
.front_face
= mode
;
709 return error::kNoError
;
712 error::Error
GLES2DecoderImpl::HandleGenBuffersImmediate(
713 uint32_t immediate_data_size
,
714 const gles2::cmds::GenBuffersImmediate
& c
) {
715 GLsizei n
= static_cast<GLsizei
>(c
.n
);
717 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
718 return error::kOutOfBounds
;
721 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
722 if (buffers
== NULL
) {
723 return error::kOutOfBounds
;
725 if (!GenBuffersHelper(n
, buffers
)) {
726 return error::kInvalidArguments
;
728 return error::kNoError
;
731 error::Error
GLES2DecoderImpl::HandleGenerateMipmap(
732 uint32_t immediate_data_size
,
733 const gles2::cmds::GenerateMipmap
& c
) {
734 GLenum target
= static_cast<GLenum
>(c
.target
);
735 if (!validators_
->texture_bind_target
.IsValid(target
)) {
736 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target
, "target");
737 return error::kNoError
;
739 DoGenerateMipmap(target
);
740 return error::kNoError
;
743 error::Error
GLES2DecoderImpl::HandleGenFramebuffersImmediate(
744 uint32_t immediate_data_size
,
745 const gles2::cmds::GenFramebuffersImmediate
& c
) {
746 GLsizei n
= static_cast<GLsizei
>(c
.n
);
748 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
749 return error::kOutOfBounds
;
751 GLuint
* framebuffers
=
752 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
753 if (framebuffers
== NULL
) {
754 return error::kOutOfBounds
;
756 if (!GenFramebuffersHelper(n
, framebuffers
)) {
757 return error::kInvalidArguments
;
759 return error::kNoError
;
762 error::Error
GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
763 uint32_t immediate_data_size
,
764 const gles2::cmds::GenRenderbuffersImmediate
& c
) {
765 GLsizei n
= static_cast<GLsizei
>(c
.n
);
767 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
768 return error::kOutOfBounds
;
770 GLuint
* renderbuffers
=
771 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
772 if (renderbuffers
== NULL
) {
773 return error::kOutOfBounds
;
775 if (!GenRenderbuffersHelper(n
, renderbuffers
)) {
776 return error::kInvalidArguments
;
778 return error::kNoError
;
781 error::Error
GLES2DecoderImpl::HandleGenTexturesImmediate(
782 uint32_t immediate_data_size
,
783 const gles2::cmds::GenTexturesImmediate
& c
) {
784 GLsizei n
= static_cast<GLsizei
>(c
.n
);
786 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
787 return error::kOutOfBounds
;
790 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
791 if (textures
== NULL
) {
792 return error::kOutOfBounds
;
794 if (!GenTexturesHelper(n
, textures
)) {
795 return error::kInvalidArguments
;
797 return error::kNoError
;
800 error::Error
GLES2DecoderImpl::HandleGetBooleanv(
801 uint32_t immediate_data_size
,
802 const gles2::cmds::GetBooleanv
& c
) {
803 GLenum pname
= static_cast<GLenum
>(c
.pname
);
804 typedef cmds::GetBooleanv::Result Result
;
805 GLsizei num_values
= 0;
806 GetNumValuesReturnedForGLGet(pname
, &num_values
);
807 Result
* result
= GetSharedMemoryAs
<Result
*>(
808 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
809 GLboolean
* params
= result
? result
->GetData() : NULL
;
810 if (!validators_
->g_l_state
.IsValid(pname
)) {
811 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname
, "pname");
812 return error::kNoError
;
814 if (params
== NULL
) {
815 return error::kOutOfBounds
;
817 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
818 // Check that the client initialized the result.
819 if (result
->size
!= 0) {
820 return error::kInvalidArguments
;
822 DoGetBooleanv(pname
, params
);
823 GLenum error
= glGetError();
824 if (error
== GL_NO_ERROR
) {
825 result
->SetNumResults(num_values
);
827 LOCAL_SET_GL_ERROR(error
, "GetBooleanv", "");
829 return error::kNoError
;
832 error::Error
GLES2DecoderImpl::HandleGetBufferParameteriv(
833 uint32_t immediate_data_size
,
834 const gles2::cmds::GetBufferParameteriv
& c
) {
835 GLenum target
= static_cast<GLenum
>(c
.target
);
836 GLenum pname
= static_cast<GLenum
>(c
.pname
);
837 typedef cmds::GetBufferParameteriv::Result Result
;
838 GLsizei num_values
= 0;
839 GetNumValuesReturnedForGLGet(pname
, &num_values
);
840 Result
* result
= GetSharedMemoryAs
<Result
*>(
841 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
842 GLint
* params
= result
? result
->GetData() : NULL
;
843 if (!validators_
->buffer_target
.IsValid(target
)) {
844 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target
, "target");
845 return error::kNoError
;
847 if (!validators_
->buffer_parameter
.IsValid(pname
)) {
848 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname
, "pname");
849 return error::kNoError
;
851 if (params
== NULL
) {
852 return error::kOutOfBounds
;
854 // Check that the client initialized the result.
855 if (result
->size
!= 0) {
856 return error::kInvalidArguments
;
858 DoGetBufferParameteriv(target
, pname
, params
);
859 result
->SetNumResults(num_values
);
860 return error::kNoError
;
862 error::Error
GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size
,
863 const gles2::cmds::GetError
& c
) {
864 typedef cmds::GetError::Result Result
;
865 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
866 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
868 return error::kOutOfBounds
;
870 *result_dst
= GetErrorState()->GetGLError();
871 return error::kNoError
;
874 error::Error
GLES2DecoderImpl::HandleGetFloatv(
875 uint32_t immediate_data_size
,
876 const gles2::cmds::GetFloatv
& c
) {
877 GLenum pname
= static_cast<GLenum
>(c
.pname
);
878 typedef cmds::GetFloatv::Result Result
;
879 GLsizei num_values
= 0;
880 GetNumValuesReturnedForGLGet(pname
, &num_values
);
881 Result
* result
= GetSharedMemoryAs
<Result
*>(
882 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
883 GLfloat
* params
= result
? result
->GetData() : NULL
;
884 if (!validators_
->g_l_state
.IsValid(pname
)) {
885 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname
, "pname");
886 return error::kNoError
;
888 if (params
== NULL
) {
889 return error::kOutOfBounds
;
891 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
892 // Check that the client initialized the result.
893 if (result
->size
!= 0) {
894 return error::kInvalidArguments
;
896 DoGetFloatv(pname
, params
);
897 GLenum error
= glGetError();
898 if (error
== GL_NO_ERROR
) {
899 result
->SetNumResults(num_values
);
901 LOCAL_SET_GL_ERROR(error
, "GetFloatv", "");
903 return error::kNoError
;
906 error::Error
GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
907 uint32_t immediate_data_size
,
908 const gles2::cmds::GetFramebufferAttachmentParameteriv
& c
) {
909 GLenum target
= static_cast<GLenum
>(c
.target
);
910 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
911 GLenum pname
= static_cast<GLenum
>(c
.pname
);
912 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result
;
913 GLsizei num_values
= 0;
914 GetNumValuesReturnedForGLGet(pname
, &num_values
);
915 Result
* result
= GetSharedMemoryAs
<Result
*>(
916 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
917 GLint
* params
= result
? result
->GetData() : NULL
;
918 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
919 LOCAL_SET_GL_ERROR_INVALID_ENUM(
920 "glGetFramebufferAttachmentParameteriv", target
, "target");
921 return error::kNoError
;
923 if (!validators_
->attachment
.IsValid(attachment
)) {
924 LOCAL_SET_GL_ERROR_INVALID_ENUM(
925 "glGetFramebufferAttachmentParameteriv", attachment
, "attachment");
926 return error::kNoError
;
928 if (!validators_
->frame_buffer_parameter
.IsValid(pname
)) {
929 LOCAL_SET_GL_ERROR_INVALID_ENUM(
930 "glGetFramebufferAttachmentParameteriv", pname
, "pname");
931 return error::kNoError
;
933 if (params
== NULL
) {
934 return error::kOutOfBounds
;
936 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
937 // Check that the client initialized the result.
938 if (result
->size
!= 0) {
939 return error::kInvalidArguments
;
941 DoGetFramebufferAttachmentParameteriv(target
, attachment
, pname
, params
);
942 GLenum error
= glGetError();
943 if (error
== GL_NO_ERROR
) {
944 result
->SetNumResults(num_values
);
946 LOCAL_SET_GL_ERROR(error
, "GetFramebufferAttachmentParameteriv", "");
948 return error::kNoError
;
951 error::Error
GLES2DecoderImpl::HandleGetIntegerv(
952 uint32_t immediate_data_size
,
953 const gles2::cmds::GetIntegerv
& c
) {
954 GLenum pname
= static_cast<GLenum
>(c
.pname
);
955 typedef cmds::GetIntegerv::Result Result
;
956 GLsizei num_values
= 0;
957 GetNumValuesReturnedForGLGet(pname
, &num_values
);
958 Result
* result
= GetSharedMemoryAs
<Result
*>(
959 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
960 GLint
* params
= result
? result
->GetData() : NULL
;
961 if (!validators_
->g_l_state
.IsValid(pname
)) {
962 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname
, "pname");
963 return error::kNoError
;
965 if (params
== NULL
) {
966 return error::kOutOfBounds
;
968 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
969 // Check that the client initialized the result.
970 if (result
->size
!= 0) {
971 return error::kInvalidArguments
;
973 DoGetIntegerv(pname
, params
);
974 GLenum error
= glGetError();
975 if (error
== GL_NO_ERROR
) {
976 result
->SetNumResults(num_values
);
978 LOCAL_SET_GL_ERROR(error
, "GetIntegerv", "");
980 return error::kNoError
;
983 error::Error
GLES2DecoderImpl::HandleGetProgramiv(
984 uint32_t immediate_data_size
,
985 const gles2::cmds::GetProgramiv
& c
) {
986 GLuint program
= c
.program
;
987 GLenum pname
= static_cast<GLenum
>(c
.pname
);
988 typedef cmds::GetProgramiv::Result Result
;
989 GLsizei num_values
= 0;
990 GetNumValuesReturnedForGLGet(pname
, &num_values
);
991 Result
* result
= GetSharedMemoryAs
<Result
*>(
992 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
993 GLint
* params
= result
? result
->GetData() : NULL
;
994 if (!validators_
->program_parameter
.IsValid(pname
)) {
995 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname
, "pname");
996 return error::kNoError
;
998 if (params
== NULL
) {
999 return error::kOutOfBounds
;
1001 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1002 // Check that the client initialized the result.
1003 if (result
->size
!= 0) {
1004 return error::kInvalidArguments
;
1006 DoGetProgramiv(program
, pname
, params
);
1007 GLenum error
= glGetError();
1008 if (error
== GL_NO_ERROR
) {
1009 result
->SetNumResults(num_values
);
1011 LOCAL_SET_GL_ERROR(error
, "GetProgramiv", "");
1013 return error::kNoError
;
1016 error::Error
GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1017 uint32_t immediate_data_size
,
1018 const gles2::cmds::GetRenderbufferParameteriv
& c
) {
1019 GLenum target
= static_cast<GLenum
>(c
.target
);
1020 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1021 typedef cmds::GetRenderbufferParameteriv::Result Result
;
1022 GLsizei num_values
= 0;
1023 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1024 Result
* result
= GetSharedMemoryAs
<Result
*>(
1025 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1026 GLint
* params
= result
? result
->GetData() : NULL
;
1027 if (!validators_
->render_buffer_target
.IsValid(target
)) {
1028 LOCAL_SET_GL_ERROR_INVALID_ENUM(
1029 "glGetRenderbufferParameteriv", target
, "target");
1030 return error::kNoError
;
1032 if (!validators_
->render_buffer_parameter
.IsValid(pname
)) {
1033 LOCAL_SET_GL_ERROR_INVALID_ENUM(
1034 "glGetRenderbufferParameteriv", pname
, "pname");
1035 return error::kNoError
;
1037 if (params
== NULL
) {
1038 return error::kOutOfBounds
;
1040 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1041 // Check that the client initialized the result.
1042 if (result
->size
!= 0) {
1043 return error::kInvalidArguments
;
1045 DoGetRenderbufferParameteriv(target
, pname
, params
);
1046 GLenum error
= glGetError();
1047 if (error
== GL_NO_ERROR
) {
1048 result
->SetNumResults(num_values
);
1050 LOCAL_SET_GL_ERROR(error
, "GetRenderbufferParameteriv", "");
1052 return error::kNoError
;
1055 error::Error
GLES2DecoderImpl::HandleGetShaderiv(
1056 uint32_t immediate_data_size
,
1057 const gles2::cmds::GetShaderiv
& c
) {
1058 GLuint shader
= c
.shader
;
1059 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1060 typedef cmds::GetShaderiv::Result Result
;
1061 GLsizei num_values
= 0;
1062 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1063 Result
* result
= GetSharedMemoryAs
<Result
*>(
1064 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1065 GLint
* params
= result
? result
->GetData() : NULL
;
1066 if (!validators_
->shader_parameter
.IsValid(pname
)) {
1067 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname
, "pname");
1068 return error::kNoError
;
1070 if (params
== NULL
) {
1071 return error::kOutOfBounds
;
1073 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1074 // Check that the client initialized the result.
1075 if (result
->size
!= 0) {
1076 return error::kInvalidArguments
;
1078 DoGetShaderiv(shader
, pname
, params
);
1079 GLenum error
= glGetError();
1080 if (error
== GL_NO_ERROR
) {
1081 result
->SetNumResults(num_values
);
1083 LOCAL_SET_GL_ERROR(error
, "GetShaderiv", "");
1085 return error::kNoError
;
1088 error::Error
GLES2DecoderImpl::HandleGetTexParameterfv(
1089 uint32_t immediate_data_size
,
1090 const gles2::cmds::GetTexParameterfv
& c
) {
1091 GLenum target
= static_cast<GLenum
>(c
.target
);
1092 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1093 typedef cmds::GetTexParameterfv::Result Result
;
1094 GLsizei num_values
= 0;
1095 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1096 Result
* result
= GetSharedMemoryAs
<Result
*>(
1097 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1098 GLfloat
* params
= result
? result
->GetData() : NULL
;
1099 if (!validators_
->get_tex_param_target
.IsValid(target
)) {
1100 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target
, "target");
1101 return error::kNoError
;
1103 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1104 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname
, "pname");
1105 return error::kNoError
;
1107 if (params
== NULL
) {
1108 return error::kOutOfBounds
;
1110 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1111 // Check that the client initialized the result.
1112 if (result
->size
!= 0) {
1113 return error::kInvalidArguments
;
1115 DoGetTexParameterfv(target
, pname
, params
);
1116 GLenum error
= glGetError();
1117 if (error
== GL_NO_ERROR
) {
1118 result
->SetNumResults(num_values
);
1120 LOCAL_SET_GL_ERROR(error
, "GetTexParameterfv", "");
1122 return error::kNoError
;
1125 error::Error
GLES2DecoderImpl::HandleGetTexParameteriv(
1126 uint32_t immediate_data_size
,
1127 const gles2::cmds::GetTexParameteriv
& c
) {
1128 GLenum target
= static_cast<GLenum
>(c
.target
);
1129 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1130 typedef cmds::GetTexParameteriv::Result Result
;
1131 GLsizei num_values
= 0;
1132 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1133 Result
* result
= GetSharedMemoryAs
<Result
*>(
1134 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1135 GLint
* params
= result
? result
->GetData() : NULL
;
1136 if (!validators_
->get_tex_param_target
.IsValid(target
)) {
1137 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target
, "target");
1138 return error::kNoError
;
1140 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1141 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname
, "pname");
1142 return error::kNoError
;
1144 if (params
== NULL
) {
1145 return error::kOutOfBounds
;
1147 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1148 // Check that the client initialized the result.
1149 if (result
->size
!= 0) {
1150 return error::kInvalidArguments
;
1152 DoGetTexParameteriv(target
, pname
, params
);
1153 GLenum error
= glGetError();
1154 if (error
== GL_NO_ERROR
) {
1155 result
->SetNumResults(num_values
);
1157 LOCAL_SET_GL_ERROR(error
, "GetTexParameteriv", "");
1159 return error::kNoError
;
1162 error::Error
GLES2DecoderImpl::HandleGetVertexAttribfv(
1163 uint32_t immediate_data_size
,
1164 const gles2::cmds::GetVertexAttribfv
& c
) {
1165 GLuint index
= static_cast<GLuint
>(c
.index
);
1166 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1167 typedef cmds::GetVertexAttribfv::Result Result
;
1168 GLsizei num_values
= 0;
1169 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1170 Result
* result
= GetSharedMemoryAs
<Result
*>(
1171 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1172 GLfloat
* params
= result
? result
->GetData() : NULL
;
1173 if (!validators_
->vertex_attribute
.IsValid(pname
)) {
1174 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname
, "pname");
1175 return error::kNoError
;
1177 if (params
== NULL
) {
1178 return error::kOutOfBounds
;
1180 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1181 // Check that the client initialized the result.
1182 if (result
->size
!= 0) {
1183 return error::kInvalidArguments
;
1185 DoGetVertexAttribfv(index
, pname
, params
);
1186 GLenum error
= glGetError();
1187 if (error
== GL_NO_ERROR
) {
1188 result
->SetNumResults(num_values
);
1190 LOCAL_SET_GL_ERROR(error
, "GetVertexAttribfv", "");
1192 return error::kNoError
;
1195 error::Error
GLES2DecoderImpl::HandleGetVertexAttribiv(
1196 uint32_t immediate_data_size
,
1197 const gles2::cmds::GetVertexAttribiv
& c
) {
1198 GLuint index
= static_cast<GLuint
>(c
.index
);
1199 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1200 typedef cmds::GetVertexAttribiv::Result Result
;
1201 GLsizei num_values
= 0;
1202 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1203 Result
* result
= GetSharedMemoryAs
<Result
*>(
1204 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1205 GLint
* params
= result
? result
->GetData() : NULL
;
1206 if (!validators_
->vertex_attribute
.IsValid(pname
)) {
1207 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname
, "pname");
1208 return error::kNoError
;
1210 if (params
== NULL
) {
1211 return error::kOutOfBounds
;
1213 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
1214 // Check that the client initialized the result.
1215 if (result
->size
!= 0) {
1216 return error::kInvalidArguments
;
1218 DoGetVertexAttribiv(index
, pname
, params
);
1219 GLenum error
= glGetError();
1220 if (error
== GL_NO_ERROR
) {
1221 result
->SetNumResults(num_values
);
1223 LOCAL_SET_GL_ERROR(error
, "GetVertexAttribiv", "");
1225 return error::kNoError
;
1228 error::Error
GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size
,
1229 const gles2::cmds::Hint
& c
) {
1230 GLenum target
= static_cast<GLenum
>(c
.target
);
1231 GLenum mode
= static_cast<GLenum
>(c
.mode
);
1232 if (!validators_
->hint_target
.IsValid(target
)) {
1233 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target
, "target");
1234 return error::kNoError
;
1236 if (!validators_
->hint_mode
.IsValid(mode
)) {
1237 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode
, "mode");
1238 return error::kNoError
;
1241 case GL_GENERATE_MIPMAP_HINT
:
1242 if (state_
.hint_generate_mipmap
!= mode
) {
1243 state_
.hint_generate_mipmap
= mode
;
1244 glHint(target
, mode
);
1247 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
:
1248 if (state_
.hint_fragment_shader_derivative
!= mode
) {
1249 state_
.hint_fragment_shader_derivative
= mode
;
1250 glHint(target
, mode
);
1256 return error::kNoError
;
1259 error::Error
GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size
,
1260 const gles2::cmds::IsBuffer
& c
) {
1261 GLuint buffer
= c
.buffer
;
1262 typedef cmds::IsBuffer::Result Result
;
1263 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1264 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1266 return error::kOutOfBounds
;
1268 *result_dst
= DoIsBuffer(buffer
);
1269 return error::kNoError
;
1272 error::Error
GLES2DecoderImpl::HandleIsEnabled(
1273 uint32_t immediate_data_size
,
1274 const gles2::cmds::IsEnabled
& c
) {
1275 GLenum cap
= static_cast<GLenum
>(c
.cap
);
1276 typedef cmds::IsEnabled::Result Result
;
1277 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1278 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1280 return error::kOutOfBounds
;
1282 if (!validators_
->capability
.IsValid(cap
)) {
1283 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap
, "cap");
1284 return error::kNoError
;
1286 *result_dst
= DoIsEnabled(cap
);
1287 return error::kNoError
;
1290 error::Error
GLES2DecoderImpl::HandleIsFramebuffer(
1291 uint32_t immediate_data_size
,
1292 const gles2::cmds::IsFramebuffer
& c
) {
1293 GLuint framebuffer
= c
.framebuffer
;
1294 typedef cmds::IsFramebuffer::Result Result
;
1295 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1296 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1298 return error::kOutOfBounds
;
1300 *result_dst
= DoIsFramebuffer(framebuffer
);
1301 return error::kNoError
;
1304 error::Error
GLES2DecoderImpl::HandleIsProgram(
1305 uint32_t immediate_data_size
,
1306 const gles2::cmds::IsProgram
& c
) {
1307 GLuint program
= c
.program
;
1308 typedef cmds::IsProgram::Result Result
;
1309 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1310 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1312 return error::kOutOfBounds
;
1314 *result_dst
= DoIsProgram(program
);
1315 return error::kNoError
;
1318 error::Error
GLES2DecoderImpl::HandleIsRenderbuffer(
1319 uint32_t immediate_data_size
,
1320 const gles2::cmds::IsRenderbuffer
& c
) {
1321 GLuint renderbuffer
= c
.renderbuffer
;
1322 typedef cmds::IsRenderbuffer::Result Result
;
1323 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1324 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1326 return error::kOutOfBounds
;
1328 *result_dst
= DoIsRenderbuffer(renderbuffer
);
1329 return error::kNoError
;
1332 error::Error
GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size
,
1333 const gles2::cmds::IsShader
& c
) {
1334 GLuint shader
= c
.shader
;
1335 typedef cmds::IsShader::Result Result
;
1336 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1337 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1339 return error::kOutOfBounds
;
1341 *result_dst
= DoIsShader(shader
);
1342 return error::kNoError
;
1345 error::Error
GLES2DecoderImpl::HandleIsTexture(
1346 uint32_t immediate_data_size
,
1347 const gles2::cmds::IsTexture
& c
) {
1348 GLuint texture
= c
.texture
;
1349 typedef cmds::IsTexture::Result Result
;
1350 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1351 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1353 return error::kOutOfBounds
;
1355 *result_dst
= DoIsTexture(texture
);
1356 return error::kNoError
;
1359 error::Error
GLES2DecoderImpl::HandleLineWidth(
1360 uint32_t immediate_data_size
,
1361 const gles2::cmds::LineWidth
& c
) {
1362 GLfloat width
= static_cast<GLfloat
>(c
.width
);
1363 if (width
<= 0.0f
|| base::IsNaN(width
)) {
1364 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "LineWidth", "width out of range");
1365 return error::kNoError
;
1367 if (state_
.line_width
!= width
) {
1368 state_
.line_width
= width
;
1371 return error::kNoError
;
1374 error::Error
GLES2DecoderImpl::HandleLinkProgram(
1375 uint32_t immediate_data_size
,
1376 const gles2::cmds::LinkProgram
& c
) {
1377 GLuint program
= c
.program
;
1378 DoLinkProgram(program
);
1379 return error::kNoError
;
1382 error::Error
GLES2DecoderImpl::HandlePolygonOffset(
1383 uint32_t immediate_data_size
,
1384 const gles2::cmds::PolygonOffset
& c
) {
1385 GLfloat factor
= static_cast<GLfloat
>(c
.factor
);
1386 GLfloat units
= static_cast<GLfloat
>(c
.units
);
1387 if (state_
.polygon_offset_factor
!= factor
||
1388 state_
.polygon_offset_units
!= units
) {
1389 state_
.polygon_offset_factor
= factor
;
1390 state_
.polygon_offset_units
= units
;
1391 glPolygonOffset(factor
, units
);
1393 return error::kNoError
;
1396 error::Error
GLES2DecoderImpl::HandleReleaseShaderCompiler(
1397 uint32_t immediate_data_size
,
1398 const gles2::cmds::ReleaseShaderCompiler
& c
) {
1399 DoReleaseShaderCompiler();
1400 return error::kNoError
;
1403 error::Error
GLES2DecoderImpl::HandleRenderbufferStorage(
1404 uint32_t immediate_data_size
,
1405 const gles2::cmds::RenderbufferStorage
& c
) {
1406 GLenum target
= static_cast<GLenum
>(c
.target
);
1407 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
1408 GLsizei width
= static_cast<GLsizei
>(c
.width
);
1409 GLsizei height
= static_cast<GLsizei
>(c
.height
);
1410 if (!validators_
->render_buffer_target
.IsValid(target
)) {
1411 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target
, "target");
1412 return error::kNoError
;
1414 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
1415 LOCAL_SET_GL_ERROR_INVALID_ENUM(
1416 "glRenderbufferStorage", internalformat
, "internalformat");
1417 return error::kNoError
;
1420 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorage", "width < 0");
1421 return error::kNoError
;
1424 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorage", "height < 0");
1425 return error::kNoError
;
1427 DoRenderbufferStorage(target
, internalformat
, width
, height
);
1428 return error::kNoError
;
1431 error::Error
GLES2DecoderImpl::HandleSampleCoverage(
1432 uint32_t immediate_data_size
,
1433 const gles2::cmds::SampleCoverage
& c
) {
1434 GLclampf value
= static_cast<GLclampf
>(c
.value
);
1435 GLboolean invert
= static_cast<GLboolean
>(c
.invert
);
1436 DoSampleCoverage(value
, invert
);
1437 return error::kNoError
;
1440 error::Error
GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size
,
1441 const gles2::cmds::Scissor
& c
) {
1442 GLint x
= static_cast<GLint
>(c
.x
);
1443 GLint y
= static_cast<GLint
>(c
.y
);
1444 GLsizei width
= static_cast<GLsizei
>(c
.width
);
1445 GLsizei height
= static_cast<GLsizei
>(c
.height
);
1447 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glScissor", "width < 0");
1448 return error::kNoError
;
1451 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glScissor", "height < 0");
1452 return error::kNoError
;
1454 if (state_
.scissor_x
!= x
|| state_
.scissor_y
!= y
||
1455 state_
.scissor_width
!= width
|| state_
.scissor_height
!= height
) {
1456 state_
.scissor_x
= x
;
1457 state_
.scissor_y
= y
;
1458 state_
.scissor_width
= width
;
1459 state_
.scissor_height
= height
;
1460 glScissor(x
, y
, width
, height
);
1462 return error::kNoError
;
1465 error::Error
GLES2DecoderImpl::HandleStencilFunc(
1466 uint32_t immediate_data_size
,
1467 const gles2::cmds::StencilFunc
& c
) {
1468 GLenum func
= static_cast<GLenum
>(c
.func
);
1469 GLint ref
= static_cast<GLint
>(c
.ref
);
1470 GLuint mask
= static_cast<GLuint
>(c
.mask
);
1471 if (!validators_
->cmp_function
.IsValid(func
)) {
1472 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func
, "func");
1473 return error::kNoError
;
1475 if (state_
.stencil_front_func
!= func
|| state_
.stencil_front_ref
!= ref
||
1476 state_
.stencil_front_mask
!= mask
|| state_
.stencil_back_func
!= func
||
1477 state_
.stencil_back_ref
!= ref
|| state_
.stencil_back_mask
!= mask
) {
1478 state_
.stencil_front_func
= func
;
1479 state_
.stencil_front_ref
= ref
;
1480 state_
.stencil_front_mask
= mask
;
1481 state_
.stencil_back_func
= func
;
1482 state_
.stencil_back_ref
= ref
;
1483 state_
.stencil_back_mask
= mask
;
1484 glStencilFunc(func
, ref
, mask
);
1486 return error::kNoError
;
1489 error::Error
GLES2DecoderImpl::HandleStencilFuncSeparate(
1490 uint32_t immediate_data_size
,
1491 const gles2::cmds::StencilFuncSeparate
& c
) {
1492 GLenum face
= static_cast<GLenum
>(c
.face
);
1493 GLenum func
= static_cast<GLenum
>(c
.func
);
1494 GLint ref
= static_cast<GLint
>(c
.ref
);
1495 GLuint mask
= static_cast<GLuint
>(c
.mask
);
1496 if (!validators_
->face_type
.IsValid(face
)) {
1497 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face
, "face");
1498 return error::kNoError
;
1500 if (!validators_
->cmp_function
.IsValid(func
)) {
1501 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func
, "func");
1502 return error::kNoError
;
1504 bool changed
= false;
1505 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1506 changed
|= state_
.stencil_front_func
!= func
||
1507 state_
.stencil_front_ref
!= ref
||
1508 state_
.stencil_front_mask
!= mask
;
1510 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1511 changed
|= state_
.stencil_back_func
!= func
||
1512 state_
.stencil_back_ref
!= ref
||
1513 state_
.stencil_back_mask
!= mask
;
1516 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1517 state_
.stencil_front_func
= func
;
1518 state_
.stencil_front_ref
= ref
;
1519 state_
.stencil_front_mask
= mask
;
1521 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1522 state_
.stencil_back_func
= func
;
1523 state_
.stencil_back_ref
= ref
;
1524 state_
.stencil_back_mask
= mask
;
1526 glStencilFuncSeparate(face
, func
, ref
, mask
);
1528 return error::kNoError
;
1531 error::Error
GLES2DecoderImpl::HandleStencilMask(
1532 uint32_t immediate_data_size
,
1533 const gles2::cmds::StencilMask
& c
) {
1534 GLuint mask
= static_cast<GLuint
>(c
.mask
);
1535 if (state_
.stencil_front_writemask
!= mask
||
1536 state_
.stencil_back_writemask
!= mask
) {
1537 state_
.stencil_front_writemask
= mask
;
1538 state_
.stencil_back_writemask
= mask
;
1539 framebuffer_state_
.clear_state_dirty
= true;
1541 return error::kNoError
;
1544 error::Error
GLES2DecoderImpl::HandleStencilMaskSeparate(
1545 uint32_t immediate_data_size
,
1546 const gles2::cmds::StencilMaskSeparate
& c
) {
1547 GLenum face
= static_cast<GLenum
>(c
.face
);
1548 GLuint mask
= static_cast<GLuint
>(c
.mask
);
1549 if (!validators_
->face_type
.IsValid(face
)) {
1550 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face
, "face");
1551 return error::kNoError
;
1553 bool changed
= false;
1554 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1555 changed
|= state_
.stencil_front_writemask
!= mask
;
1557 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1558 changed
|= state_
.stencil_back_writemask
!= mask
;
1561 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1562 state_
.stencil_front_writemask
= mask
;
1564 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1565 state_
.stencil_back_writemask
= mask
;
1567 framebuffer_state_
.clear_state_dirty
= true;
1569 return error::kNoError
;
1572 error::Error
GLES2DecoderImpl::HandleStencilOp(
1573 uint32_t immediate_data_size
,
1574 const gles2::cmds::StencilOp
& c
) {
1575 GLenum fail
= static_cast<GLenum
>(c
.fail
);
1576 GLenum zfail
= static_cast<GLenum
>(c
.zfail
);
1577 GLenum zpass
= static_cast<GLenum
>(c
.zpass
);
1578 if (!validators_
->stencil_op
.IsValid(fail
)) {
1579 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail
, "fail");
1580 return error::kNoError
;
1582 if (!validators_
->stencil_op
.IsValid(zfail
)) {
1583 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail
, "zfail");
1584 return error::kNoError
;
1586 if (!validators_
->stencil_op
.IsValid(zpass
)) {
1587 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass
, "zpass");
1588 return error::kNoError
;
1590 if (state_
.stencil_front_fail_op
!= fail
||
1591 state_
.stencil_front_z_fail_op
!= zfail
||
1592 state_
.stencil_front_z_pass_op
!= zpass
||
1593 state_
.stencil_back_fail_op
!= fail
||
1594 state_
.stencil_back_z_fail_op
!= zfail
||
1595 state_
.stencil_back_z_pass_op
!= zpass
) {
1596 state_
.stencil_front_fail_op
= fail
;
1597 state_
.stencil_front_z_fail_op
= zfail
;
1598 state_
.stencil_front_z_pass_op
= zpass
;
1599 state_
.stencil_back_fail_op
= fail
;
1600 state_
.stencil_back_z_fail_op
= zfail
;
1601 state_
.stencil_back_z_pass_op
= zpass
;
1602 glStencilOp(fail
, zfail
, zpass
);
1604 return error::kNoError
;
1607 error::Error
GLES2DecoderImpl::HandleStencilOpSeparate(
1608 uint32_t immediate_data_size
,
1609 const gles2::cmds::StencilOpSeparate
& c
) {
1610 GLenum face
= static_cast<GLenum
>(c
.face
);
1611 GLenum fail
= static_cast<GLenum
>(c
.fail
);
1612 GLenum zfail
= static_cast<GLenum
>(c
.zfail
);
1613 GLenum zpass
= static_cast<GLenum
>(c
.zpass
);
1614 if (!validators_
->face_type
.IsValid(face
)) {
1615 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face
, "face");
1616 return error::kNoError
;
1618 if (!validators_
->stencil_op
.IsValid(fail
)) {
1619 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail
, "fail");
1620 return error::kNoError
;
1622 if (!validators_
->stencil_op
.IsValid(zfail
)) {
1623 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail
, "zfail");
1624 return error::kNoError
;
1626 if (!validators_
->stencil_op
.IsValid(zpass
)) {
1627 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass
, "zpass");
1628 return error::kNoError
;
1630 bool changed
= false;
1631 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1632 changed
|= state_
.stencil_front_fail_op
!= fail
||
1633 state_
.stencil_front_z_fail_op
!= zfail
||
1634 state_
.stencil_front_z_pass_op
!= zpass
;
1636 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1637 changed
|= state_
.stencil_back_fail_op
!= fail
||
1638 state_
.stencil_back_z_fail_op
!= zfail
||
1639 state_
.stencil_back_z_pass_op
!= zpass
;
1642 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
1643 state_
.stencil_front_fail_op
= fail
;
1644 state_
.stencil_front_z_fail_op
= zfail
;
1645 state_
.stencil_front_z_pass_op
= zpass
;
1647 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
1648 state_
.stencil_back_fail_op
= fail
;
1649 state_
.stencil_back_z_fail_op
= zfail
;
1650 state_
.stencil_back_z_pass_op
= zpass
;
1652 glStencilOpSeparate(face
, fail
, zfail
, zpass
);
1654 return error::kNoError
;
1657 error::Error
GLES2DecoderImpl::HandleTexParameterf(
1658 uint32_t immediate_data_size
,
1659 const gles2::cmds::TexParameterf
& c
) {
1660 GLenum target
= static_cast<GLenum
>(c
.target
);
1661 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1662 GLfloat param
= static_cast<GLfloat
>(c
.param
);
1663 if (!validators_
->texture_bind_target
.IsValid(target
)) {
1664 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target
, "target");
1665 return error::kNoError
;
1667 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1668 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname
, "pname");
1669 return error::kNoError
;
1671 DoTexParameterf(target
, pname
, param
);
1672 return error::kNoError
;
1675 error::Error
GLES2DecoderImpl::HandleTexParameterfvImmediate(
1676 uint32_t immediate_data_size
,
1677 const gles2::cmds::TexParameterfvImmediate
& c
) {
1678 GLenum target
= static_cast<GLenum
>(c
.target
);
1679 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1681 if (!ComputeDataSize(1, sizeof(GLfloat
), 1, &data_size
)) {
1682 return error::kOutOfBounds
;
1684 if (data_size
> immediate_data_size
) {
1685 return error::kOutOfBounds
;
1687 const GLfloat
* params
=
1688 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
1689 if (!validators_
->texture_bind_target
.IsValid(target
)) {
1690 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target
, "target");
1691 return error::kNoError
;
1693 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1694 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname
, "pname");
1695 return error::kNoError
;
1697 if (params
== NULL
) {
1698 return error::kOutOfBounds
;
1700 DoTexParameterfv(target
, pname
, params
);
1701 return error::kNoError
;
1704 error::Error
GLES2DecoderImpl::HandleTexParameteri(
1705 uint32_t immediate_data_size
,
1706 const gles2::cmds::TexParameteri
& c
) {
1707 GLenum target
= static_cast<GLenum
>(c
.target
);
1708 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1709 GLint param
= static_cast<GLint
>(c
.param
);
1710 if (!validators_
->texture_bind_target
.IsValid(target
)) {
1711 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target
, "target");
1712 return error::kNoError
;
1714 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1715 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname
, "pname");
1716 return error::kNoError
;
1718 DoTexParameteri(target
, pname
, param
);
1719 return error::kNoError
;
1722 error::Error
GLES2DecoderImpl::HandleTexParameterivImmediate(
1723 uint32_t immediate_data_size
,
1724 const gles2::cmds::TexParameterivImmediate
& c
) {
1725 GLenum target
= static_cast<GLenum
>(c
.target
);
1726 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1728 if (!ComputeDataSize(1, sizeof(GLint
), 1, &data_size
)) {
1729 return error::kOutOfBounds
;
1731 if (data_size
> immediate_data_size
) {
1732 return error::kOutOfBounds
;
1734 const GLint
* params
=
1735 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
1736 if (!validators_
->texture_bind_target
.IsValid(target
)) {
1737 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target
, "target");
1738 return error::kNoError
;
1740 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1741 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname
, "pname");
1742 return error::kNoError
;
1744 if (params
== NULL
) {
1745 return error::kOutOfBounds
;
1747 DoTexParameteriv(target
, pname
, params
);
1748 return error::kNoError
;
1751 error::Error
GLES2DecoderImpl::HandleUniform1f(
1752 uint32_t immediate_data_size
,
1753 const gles2::cmds::Uniform1f
& c
) {
1754 GLint location
= static_cast<GLint
>(c
.location
);
1755 GLfloat x
= static_cast<GLfloat
>(c
.x
);
1759 DoUniform1fv(location
, 1, &temp
[0]);
1760 return error::kNoError
;
1763 error::Error
GLES2DecoderImpl::HandleUniform1fvImmediate(
1764 uint32_t immediate_data_size
,
1765 const gles2::cmds::Uniform1fvImmediate
& c
) {
1766 GLint location
= static_cast<GLint
>(c
.location
);
1767 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1769 if (!ComputeDataSize(count
, sizeof(GLfloat
), 1, &data_size
)) {
1770 return error::kOutOfBounds
;
1772 if (data_size
> immediate_data_size
) {
1773 return error::kOutOfBounds
;
1776 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
1778 return error::kOutOfBounds
;
1780 DoUniform1fv(location
, count
, v
);
1781 return error::kNoError
;
1784 error::Error
GLES2DecoderImpl::HandleUniform1i(
1785 uint32_t immediate_data_size
,
1786 const gles2::cmds::Uniform1i
& c
) {
1787 GLint location
= static_cast<GLint
>(c
.location
);
1788 GLint x
= static_cast<GLint
>(c
.x
);
1789 DoUniform1i(location
, x
);
1790 return error::kNoError
;
1793 error::Error
GLES2DecoderImpl::HandleUniform1ivImmediate(
1794 uint32_t immediate_data_size
,
1795 const gles2::cmds::Uniform1ivImmediate
& c
) {
1796 GLint location
= static_cast<GLint
>(c
.location
);
1797 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1799 if (!ComputeDataSize(count
, sizeof(GLint
), 1, &data_size
)) {
1800 return error::kOutOfBounds
;
1802 if (data_size
> immediate_data_size
) {
1803 return error::kOutOfBounds
;
1806 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
1808 return error::kOutOfBounds
;
1810 DoUniform1iv(location
, count
, v
);
1811 return error::kNoError
;
1814 error::Error
GLES2DecoderImpl::HandleUniform2f(
1815 uint32_t immediate_data_size
,
1816 const gles2::cmds::Uniform2f
& c
) {
1817 GLint location
= static_cast<GLint
>(c
.location
);
1818 GLfloat x
= static_cast<GLfloat
>(c
.x
);
1819 GLfloat y
= static_cast<GLfloat
>(c
.y
);
1823 DoUniform2fv(location
, 1, &temp
[0]);
1824 return error::kNoError
;
1827 error::Error
GLES2DecoderImpl::HandleUniform2fvImmediate(
1828 uint32_t immediate_data_size
,
1829 const gles2::cmds::Uniform2fvImmediate
& c
) {
1830 GLint location
= static_cast<GLint
>(c
.location
);
1831 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1833 if (!ComputeDataSize(count
, sizeof(GLfloat
), 2, &data_size
)) {
1834 return error::kOutOfBounds
;
1836 if (data_size
> immediate_data_size
) {
1837 return error::kOutOfBounds
;
1840 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
1842 return error::kOutOfBounds
;
1844 DoUniform2fv(location
, count
, v
);
1845 return error::kNoError
;
1848 error::Error
GLES2DecoderImpl::HandleUniform2i(
1849 uint32_t immediate_data_size
,
1850 const gles2::cmds::Uniform2i
& c
) {
1851 GLint location
= static_cast<GLint
>(c
.location
);
1852 GLint x
= static_cast<GLint
>(c
.x
);
1853 GLint y
= static_cast<GLint
>(c
.y
);
1857 DoUniform2iv(location
, 1, &temp
[0]);
1858 return error::kNoError
;
1861 error::Error
GLES2DecoderImpl::HandleUniform2ivImmediate(
1862 uint32_t immediate_data_size
,
1863 const gles2::cmds::Uniform2ivImmediate
& c
) {
1864 GLint location
= static_cast<GLint
>(c
.location
);
1865 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1867 if (!ComputeDataSize(count
, sizeof(GLint
), 2, &data_size
)) {
1868 return error::kOutOfBounds
;
1870 if (data_size
> immediate_data_size
) {
1871 return error::kOutOfBounds
;
1874 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
1876 return error::kOutOfBounds
;
1878 DoUniform2iv(location
, count
, v
);
1879 return error::kNoError
;
1882 error::Error
GLES2DecoderImpl::HandleUniform3f(
1883 uint32_t immediate_data_size
,
1884 const gles2::cmds::Uniform3f
& c
) {
1885 GLint location
= static_cast<GLint
>(c
.location
);
1886 GLfloat x
= static_cast<GLfloat
>(c
.x
);
1887 GLfloat y
= static_cast<GLfloat
>(c
.y
);
1888 GLfloat z
= static_cast<GLfloat
>(c
.z
);
1892 DoUniform3fv(location
, 1, &temp
[0]);
1893 return error::kNoError
;
1896 error::Error
GLES2DecoderImpl::HandleUniform3fvImmediate(
1897 uint32_t immediate_data_size
,
1898 const gles2::cmds::Uniform3fvImmediate
& c
) {
1899 GLint location
= static_cast<GLint
>(c
.location
);
1900 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1902 if (!ComputeDataSize(count
, sizeof(GLfloat
), 3, &data_size
)) {
1903 return error::kOutOfBounds
;
1905 if (data_size
> immediate_data_size
) {
1906 return error::kOutOfBounds
;
1909 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
1911 return error::kOutOfBounds
;
1913 DoUniform3fv(location
, count
, v
);
1914 return error::kNoError
;
1917 error::Error
GLES2DecoderImpl::HandleUniform3i(
1918 uint32_t immediate_data_size
,
1919 const gles2::cmds::Uniform3i
& c
) {
1920 GLint location
= static_cast<GLint
>(c
.location
);
1921 GLint x
= static_cast<GLint
>(c
.x
);
1922 GLint y
= static_cast<GLint
>(c
.y
);
1923 GLint z
= static_cast<GLint
>(c
.z
);
1927 DoUniform3iv(location
, 1, &temp
[0]);
1928 return error::kNoError
;
1931 error::Error
GLES2DecoderImpl::HandleUniform3ivImmediate(
1932 uint32_t immediate_data_size
,
1933 const gles2::cmds::Uniform3ivImmediate
& c
) {
1934 GLint location
= static_cast<GLint
>(c
.location
);
1935 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1937 if (!ComputeDataSize(count
, sizeof(GLint
), 3, &data_size
)) {
1938 return error::kOutOfBounds
;
1940 if (data_size
> immediate_data_size
) {
1941 return error::kOutOfBounds
;
1944 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
1946 return error::kOutOfBounds
;
1948 DoUniform3iv(location
, count
, v
);
1949 return error::kNoError
;
1952 error::Error
GLES2DecoderImpl::HandleUniform4f(
1953 uint32_t immediate_data_size
,
1954 const gles2::cmds::Uniform4f
& c
) {
1955 GLint location
= static_cast<GLint
>(c
.location
);
1956 GLfloat x
= static_cast<GLfloat
>(c
.x
);
1957 GLfloat y
= static_cast<GLfloat
>(c
.y
);
1958 GLfloat z
= static_cast<GLfloat
>(c
.z
);
1959 GLfloat w
= static_cast<GLfloat
>(c
.w
);
1963 DoUniform4fv(location
, 1, &temp
[0]);
1964 return error::kNoError
;
1967 error::Error
GLES2DecoderImpl::HandleUniform4fvImmediate(
1968 uint32_t immediate_data_size
,
1969 const gles2::cmds::Uniform4fvImmediate
& c
) {
1970 GLint location
= static_cast<GLint
>(c
.location
);
1971 GLsizei count
= static_cast<GLsizei
>(c
.count
);
1973 if (!ComputeDataSize(count
, sizeof(GLfloat
), 4, &data_size
)) {
1974 return error::kOutOfBounds
;
1976 if (data_size
> immediate_data_size
) {
1977 return error::kOutOfBounds
;
1980 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
1982 return error::kOutOfBounds
;
1984 DoUniform4fv(location
, count
, v
);
1985 return error::kNoError
;
1988 error::Error
GLES2DecoderImpl::HandleUniform4i(
1989 uint32_t immediate_data_size
,
1990 const gles2::cmds::Uniform4i
& c
) {
1991 GLint location
= static_cast<GLint
>(c
.location
);
1992 GLint x
= static_cast<GLint
>(c
.x
);
1993 GLint y
= static_cast<GLint
>(c
.y
);
1994 GLint z
= static_cast<GLint
>(c
.z
);
1995 GLint w
= static_cast<GLint
>(c
.w
);
1999 DoUniform4iv(location
, 1, &temp
[0]);
2000 return error::kNoError
;
2003 error::Error
GLES2DecoderImpl::HandleUniform4ivImmediate(
2004 uint32_t immediate_data_size
,
2005 const gles2::cmds::Uniform4ivImmediate
& c
) {
2006 GLint location
= static_cast<GLint
>(c
.location
);
2007 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2009 if (!ComputeDataSize(count
, sizeof(GLint
), 4, &data_size
)) {
2010 return error::kOutOfBounds
;
2012 if (data_size
> immediate_data_size
) {
2013 return error::kOutOfBounds
;
2016 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
2018 return error::kOutOfBounds
;
2020 DoUniform4iv(location
, count
, v
);
2021 return error::kNoError
;
2024 error::Error
GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
2025 uint32_t immediate_data_size
,
2026 const gles2::cmds::UniformMatrix2fvImmediate
& c
) {
2027 GLint location
= static_cast<GLint
>(c
.location
);
2028 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2029 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
2031 if (!ComputeDataSize(count
, sizeof(GLfloat
), 4, &data_size
)) {
2032 return error::kOutOfBounds
;
2034 if (data_size
> immediate_data_size
) {
2035 return error::kOutOfBounds
;
2037 const GLfloat
* value
=
2038 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2039 if (value
== NULL
) {
2040 return error::kOutOfBounds
;
2042 DoUniformMatrix2fv(location
, count
, transpose
, value
);
2043 return error::kNoError
;
2046 error::Error
GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
2047 uint32_t immediate_data_size
,
2048 const gles2::cmds::UniformMatrix3fvImmediate
& c
) {
2049 GLint location
= static_cast<GLint
>(c
.location
);
2050 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2051 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
2053 if (!ComputeDataSize(count
, sizeof(GLfloat
), 9, &data_size
)) {
2054 return error::kOutOfBounds
;
2056 if (data_size
> immediate_data_size
) {
2057 return error::kOutOfBounds
;
2059 const GLfloat
* value
=
2060 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2061 if (value
== NULL
) {
2062 return error::kOutOfBounds
;
2064 DoUniformMatrix3fv(location
, count
, transpose
, value
);
2065 return error::kNoError
;
2068 error::Error
GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
2069 uint32_t immediate_data_size
,
2070 const gles2::cmds::UniformMatrix4fvImmediate
& c
) {
2071 GLint location
= static_cast<GLint
>(c
.location
);
2072 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2073 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
2075 if (!ComputeDataSize(count
, sizeof(GLfloat
), 16, &data_size
)) {
2076 return error::kOutOfBounds
;
2078 if (data_size
> immediate_data_size
) {
2079 return error::kOutOfBounds
;
2081 const GLfloat
* value
=
2082 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2083 if (value
== NULL
) {
2084 return error::kOutOfBounds
;
2086 DoUniformMatrix4fv(location
, count
, transpose
, value
);
2087 return error::kNoError
;
2090 error::Error
GLES2DecoderImpl::HandleUseProgram(
2091 uint32_t immediate_data_size
,
2092 const gles2::cmds::UseProgram
& c
) {
2093 GLuint program
= c
.program
;
2094 DoUseProgram(program
);
2095 return error::kNoError
;
2098 error::Error
GLES2DecoderImpl::HandleValidateProgram(
2099 uint32_t immediate_data_size
,
2100 const gles2::cmds::ValidateProgram
& c
) {
2101 GLuint program
= c
.program
;
2102 DoValidateProgram(program
);
2103 return error::kNoError
;
2106 error::Error
GLES2DecoderImpl::HandleVertexAttrib1f(
2107 uint32_t immediate_data_size
,
2108 const gles2::cmds::VertexAttrib1f
& c
) {
2109 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2110 GLfloat x
= static_cast<GLfloat
>(c
.x
);
2111 DoVertexAttrib1f(indx
, x
);
2112 return error::kNoError
;
2115 error::Error
GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
2116 uint32_t immediate_data_size
,
2117 const gles2::cmds::VertexAttrib1fvImmediate
& c
) {
2118 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2120 if (!ComputeDataSize(1, sizeof(GLfloat
), 1, &data_size
)) {
2121 return error::kOutOfBounds
;
2123 if (data_size
> immediate_data_size
) {
2124 return error::kOutOfBounds
;
2126 const GLfloat
* values
=
2127 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2128 if (values
== NULL
) {
2129 return error::kOutOfBounds
;
2131 DoVertexAttrib1fv(indx
, values
);
2132 return error::kNoError
;
2135 error::Error
GLES2DecoderImpl::HandleVertexAttrib2f(
2136 uint32_t immediate_data_size
,
2137 const gles2::cmds::VertexAttrib2f
& c
) {
2138 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2139 GLfloat x
= static_cast<GLfloat
>(c
.x
);
2140 GLfloat y
= static_cast<GLfloat
>(c
.y
);
2141 DoVertexAttrib2f(indx
, x
, y
);
2142 return error::kNoError
;
2145 error::Error
GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
2146 uint32_t immediate_data_size
,
2147 const gles2::cmds::VertexAttrib2fvImmediate
& c
) {
2148 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2150 if (!ComputeDataSize(1, sizeof(GLfloat
), 2, &data_size
)) {
2151 return error::kOutOfBounds
;
2153 if (data_size
> immediate_data_size
) {
2154 return error::kOutOfBounds
;
2156 const GLfloat
* values
=
2157 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2158 if (values
== NULL
) {
2159 return error::kOutOfBounds
;
2161 DoVertexAttrib2fv(indx
, values
);
2162 return error::kNoError
;
2165 error::Error
GLES2DecoderImpl::HandleVertexAttrib3f(
2166 uint32_t immediate_data_size
,
2167 const gles2::cmds::VertexAttrib3f
& c
) {
2168 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2169 GLfloat x
= static_cast<GLfloat
>(c
.x
);
2170 GLfloat y
= static_cast<GLfloat
>(c
.y
);
2171 GLfloat z
= static_cast<GLfloat
>(c
.z
);
2172 DoVertexAttrib3f(indx
, x
, y
, z
);
2173 return error::kNoError
;
2176 error::Error
GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
2177 uint32_t immediate_data_size
,
2178 const gles2::cmds::VertexAttrib3fvImmediate
& c
) {
2179 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2181 if (!ComputeDataSize(1, sizeof(GLfloat
), 3, &data_size
)) {
2182 return error::kOutOfBounds
;
2184 if (data_size
> immediate_data_size
) {
2185 return error::kOutOfBounds
;
2187 const GLfloat
* values
=
2188 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2189 if (values
== NULL
) {
2190 return error::kOutOfBounds
;
2192 DoVertexAttrib3fv(indx
, values
);
2193 return error::kNoError
;
2196 error::Error
GLES2DecoderImpl::HandleVertexAttrib4f(
2197 uint32_t immediate_data_size
,
2198 const gles2::cmds::VertexAttrib4f
& c
) {
2199 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2200 GLfloat x
= static_cast<GLfloat
>(c
.x
);
2201 GLfloat y
= static_cast<GLfloat
>(c
.y
);
2202 GLfloat z
= static_cast<GLfloat
>(c
.z
);
2203 GLfloat w
= static_cast<GLfloat
>(c
.w
);
2204 DoVertexAttrib4f(indx
, x
, y
, z
, w
);
2205 return error::kNoError
;
2208 error::Error
GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
2209 uint32_t immediate_data_size
,
2210 const gles2::cmds::VertexAttrib4fvImmediate
& c
) {
2211 GLuint indx
= static_cast<GLuint
>(c
.indx
);
2213 if (!ComputeDataSize(1, sizeof(GLfloat
), 4, &data_size
)) {
2214 return error::kOutOfBounds
;
2216 if (data_size
> immediate_data_size
) {
2217 return error::kOutOfBounds
;
2219 const GLfloat
* values
=
2220 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2221 if (values
== NULL
) {
2222 return error::kOutOfBounds
;
2224 DoVertexAttrib4fv(indx
, values
);
2225 return error::kNoError
;
2228 error::Error
GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size
,
2229 const gles2::cmds::Viewport
& c
) {
2230 GLint x
= static_cast<GLint
>(c
.x
);
2231 GLint y
= static_cast<GLint
>(c
.y
);
2232 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2233 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2235 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glViewport", "width < 0");
2236 return error::kNoError
;
2239 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glViewport", "height < 0");
2240 return error::kNoError
;
2242 DoViewport(x
, y
, width
, height
);
2243 return error::kNoError
;
2246 error::Error
GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
2247 uint32_t immediate_data_size
,
2248 const gles2::cmds::BlitFramebufferCHROMIUM
& c
) {
2249 if (!features().chromium_framebuffer_multisample
) {
2250 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2251 "glBlitFramebufferCHROMIUM",
2252 "function not available");
2253 return error::kNoError
;
2257 error
= WillAccessBoundFramebufferForDraw();
2258 if (error
!= error::kNoError
)
2260 error
= WillAccessBoundFramebufferForRead();
2261 if (error
!= error::kNoError
)
2263 GLint srcX0
= static_cast<GLint
>(c
.srcX0
);
2264 GLint srcY0
= static_cast<GLint
>(c
.srcY0
);
2265 GLint srcX1
= static_cast<GLint
>(c
.srcX1
);
2266 GLint srcY1
= static_cast<GLint
>(c
.srcY1
);
2267 GLint dstX0
= static_cast<GLint
>(c
.dstX0
);
2268 GLint dstY0
= static_cast<GLint
>(c
.dstY0
);
2269 GLint dstX1
= static_cast<GLint
>(c
.dstX1
);
2270 GLint dstY1
= static_cast<GLint
>(c
.dstY1
);
2271 GLbitfield mask
= static_cast<GLbitfield
>(c
.mask
);
2272 GLenum filter
= static_cast<GLenum
>(c
.filter
);
2273 if (!validators_
->blit_filter
.IsValid(filter
)) {
2274 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2275 "glBlitFramebufferCHROMIUM", filter
, "filter");
2276 return error::kNoError
;
2278 DoBlitFramebufferCHROMIUM(
2279 srcX0
, srcY0
, srcX1
, srcY1
, dstX0
, dstY0
, dstX1
, dstY1
, mask
, filter
);
2280 return error::kNoError
;
2283 error::Error
GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
2284 uint32_t immediate_data_size
,
2285 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM
& c
) {
2286 if (!features().chromium_framebuffer_multisample
) {
2287 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2288 "glRenderbufferStorageMultisampleCHROMIUM",
2289 "function not available");
2290 return error::kNoError
;
2293 GLenum target
= static_cast<GLenum
>(c
.target
);
2294 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
2295 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
2296 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2297 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2298 if (!validators_
->render_buffer_target
.IsValid(target
)) {
2299 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2300 "glRenderbufferStorageMultisampleCHROMIUM", target
, "target");
2301 return error::kNoError
;
2304 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
2305 "glRenderbufferStorageMultisampleCHROMIUM",
2307 return error::kNoError
;
2309 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
2310 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
2313 return error::kNoError
;
2316 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
2317 "glRenderbufferStorageMultisampleCHROMIUM",
2319 return error::kNoError
;
2322 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
2323 "glRenderbufferStorageMultisampleCHROMIUM",
2325 return error::kNoError
;
2327 DoRenderbufferStorageMultisampleCHROMIUM(
2328 target
, samples
, internalformat
, width
, height
);
2329 return error::kNoError
;
2332 error::Error
GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
2333 uint32_t immediate_data_size
,
2334 const gles2::cmds::RenderbufferStorageMultisampleEXT
& c
) {
2335 if (!features().multisampled_render_to_texture
) {
2336 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2337 "glRenderbufferStorageMultisampleEXT",
2338 "function not available");
2339 return error::kNoError
;
2342 GLenum target
= static_cast<GLenum
>(c
.target
);
2343 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
2344 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
2345 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2346 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2347 if (!validators_
->render_buffer_target
.IsValid(target
)) {
2348 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2349 "glRenderbufferStorageMultisampleEXT", target
, "target");
2350 return error::kNoError
;
2354 GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT", "samples < 0");
2355 return error::kNoError
;
2357 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
2358 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
2361 return error::kNoError
;
2365 GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT", "width < 0");
2366 return error::kNoError
;
2370 GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT", "height < 0");
2371 return error::kNoError
;
2373 DoRenderbufferStorageMultisampleEXT(
2374 target
, samples
, internalformat
, width
, height
);
2375 return error::kNoError
;
2378 error::Error
GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
2379 uint32_t immediate_data_size
,
2380 const gles2::cmds::FramebufferTexture2DMultisampleEXT
& c
) {
2381 if (!features().multisampled_render_to_texture
) {
2382 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2383 "glFramebufferTexture2DMultisampleEXT",
2384 "function not available");
2385 return error::kNoError
;
2388 GLenum target
= static_cast<GLenum
>(c
.target
);
2389 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
2390 GLenum textarget
= static_cast<GLenum
>(c
.textarget
);
2391 GLuint texture
= c
.texture
;
2392 GLint level
= static_cast<GLint
>(c
.level
);
2393 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
2394 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
2395 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2396 "glFramebufferTexture2DMultisampleEXT", target
, "target");
2397 return error::kNoError
;
2399 if (!validators_
->attachment
.IsValid(attachment
)) {
2400 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2401 "glFramebufferTexture2DMultisampleEXT", attachment
, "attachment");
2402 return error::kNoError
;
2404 if (!validators_
->texture_target
.IsValid(textarget
)) {
2405 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2406 "glFramebufferTexture2DMultisampleEXT", textarget
, "textarget");
2407 return error::kNoError
;
2410 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
2411 "glFramebufferTexture2DMultisampleEXT",
2413 return error::kNoError
;
2415 DoFramebufferTexture2DMultisample(
2416 target
, attachment
, textarget
, texture
, level
, samples
);
2417 return error::kNoError
;
2420 error::Error
GLES2DecoderImpl::HandleTexStorage2DEXT(
2421 uint32_t immediate_data_size
,
2422 const gles2::cmds::TexStorage2DEXT
& c
) {
2423 GLenum target
= static_cast<GLenum
>(c
.target
);
2424 GLsizei levels
= static_cast<GLsizei
>(c
.levels
);
2425 GLenum internalFormat
= static_cast<GLenum
>(c
.internalFormat
);
2426 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2427 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2428 if (!validators_
->texture_target
.IsValid(target
)) {
2429 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target
, "target");
2430 return error::kNoError
;
2433 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "levels < 0");
2434 return error::kNoError
;
2436 if (!validators_
->texture_internal_format_storage
.IsValid(internalFormat
)) {
2437 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2438 "glTexStorage2DEXT", internalFormat
, "internalFormat");
2439 return error::kNoError
;
2442 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "width < 0");
2443 return error::kNoError
;
2446 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "height < 0");
2447 return error::kNoError
;
2449 DoTexStorage2DEXT(target
, levels
, internalFormat
, width
, height
);
2450 return error::kNoError
;
2453 error::Error
GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
2454 uint32_t immediate_data_size
,
2455 const gles2::cmds::GenQueriesEXTImmediate
& c
) {
2456 GLsizei n
= static_cast<GLsizei
>(c
.n
);
2458 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
2459 return error::kOutOfBounds
;
2462 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
2463 if (queries
== NULL
) {
2464 return error::kOutOfBounds
;
2466 if (!GenQueriesEXTHelper(n
, queries
)) {
2467 return error::kInvalidArguments
;
2469 return error::kNoError
;
2472 error::Error
GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
2473 uint32_t immediate_data_size
,
2474 const gles2::cmds::DeleteQueriesEXTImmediate
& c
) {
2475 GLsizei n
= static_cast<GLsizei
>(c
.n
);
2477 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
2478 return error::kOutOfBounds
;
2480 const GLuint
* queries
=
2481 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
2482 if (queries
== NULL
) {
2483 return error::kOutOfBounds
;
2485 DeleteQueriesEXTHelper(n
, queries
);
2486 return error::kNoError
;
2489 error::Error
GLES2DecoderImpl::HandleInsertEventMarkerEXT(
2490 uint32_t immediate_data_size
,
2491 const gles2::cmds::InsertEventMarkerEXT
& c
) {
2492 GLuint bucket_id
= static_cast<GLuint
>(c
.bucket_id
);
2493 Bucket
* bucket
= GetBucket(bucket_id
);
2494 if (!bucket
|| bucket
->size() == 0) {
2495 return error::kInvalidArguments
;
2498 if (!bucket
->GetAsString(&str
)) {
2499 return error::kInvalidArguments
;
2501 DoInsertEventMarkerEXT(0, str
.c_str());
2502 return error::kNoError
;
2505 error::Error
GLES2DecoderImpl::HandlePushGroupMarkerEXT(
2506 uint32_t immediate_data_size
,
2507 const gles2::cmds::PushGroupMarkerEXT
& c
) {
2508 GLuint bucket_id
= static_cast<GLuint
>(c
.bucket_id
);
2509 Bucket
* bucket
= GetBucket(bucket_id
);
2510 if (!bucket
|| bucket
->size() == 0) {
2511 return error::kInvalidArguments
;
2514 if (!bucket
->GetAsString(&str
)) {
2515 return error::kInvalidArguments
;
2517 DoPushGroupMarkerEXT(0, str
.c_str());
2518 return error::kNoError
;
2521 error::Error
GLES2DecoderImpl::HandlePopGroupMarkerEXT(
2522 uint32_t immediate_data_size
,
2523 const gles2::cmds::PopGroupMarkerEXT
& c
) {
2524 DoPopGroupMarkerEXT();
2525 return error::kNoError
;
2528 error::Error
GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
2529 uint32_t immediate_data_size
,
2530 const gles2::cmds::GenVertexArraysOESImmediate
& c
) {
2531 GLsizei n
= static_cast<GLsizei
>(c
.n
);
2533 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
2534 return error::kOutOfBounds
;
2537 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
2538 if (arrays
== NULL
) {
2539 return error::kOutOfBounds
;
2541 if (!GenVertexArraysOESHelper(n
, arrays
)) {
2542 return error::kInvalidArguments
;
2544 return error::kNoError
;
2547 error::Error
GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
2548 uint32_t immediate_data_size
,
2549 const gles2::cmds::DeleteVertexArraysOESImmediate
& c
) {
2550 GLsizei n
= static_cast<GLsizei
>(c
.n
);
2552 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
2553 return error::kOutOfBounds
;
2555 const GLuint
* arrays
=
2556 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
2557 if (arrays
== NULL
) {
2558 return error::kOutOfBounds
;
2560 DeleteVertexArraysOESHelper(n
, arrays
);
2561 return error::kNoError
;
2564 error::Error
GLES2DecoderImpl::HandleIsVertexArrayOES(
2565 uint32_t immediate_data_size
,
2566 const gles2::cmds::IsVertexArrayOES
& c
) {
2567 GLuint array
= c
.array
;
2568 typedef cmds::IsVertexArrayOES::Result Result
;
2569 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2570 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2572 return error::kOutOfBounds
;
2574 *result_dst
= DoIsVertexArrayOES(array
);
2575 return error::kNoError
;
2578 error::Error
GLES2DecoderImpl::HandleBindVertexArrayOES(
2579 uint32_t immediate_data_size
,
2580 const gles2::cmds::BindVertexArrayOES
& c
) {
2581 GLuint array
= c
.array
;
2582 DoBindVertexArrayOES(array
);
2583 return error::kNoError
;
2586 error::Error
GLES2DecoderImpl::HandleSwapBuffers(
2587 uint32_t immediate_data_size
,
2588 const gles2::cmds::SwapBuffers
& c
) {
2590 return error::kNoError
;
2593 error::Error
GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
2594 uint32_t immediate_data_size
,
2595 const gles2::cmds::GetMaxValueInBufferCHROMIUM
& c
) {
2596 GLuint buffer_id
= c
.buffer_id
;
2597 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2598 GLenum type
= static_cast<GLenum
>(c
.type
);
2599 GLuint offset
= static_cast<GLuint
>(c
.offset
);
2600 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result
;
2601 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2602 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2604 return error::kOutOfBounds
;
2608 GL_INVALID_VALUE
, "glGetMaxValueInBufferCHROMIUM", "count < 0");
2609 return error::kNoError
;
2611 if (!validators_
->get_max_index_type
.IsValid(type
)) {
2612 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2613 "glGetMaxValueInBufferCHROMIUM", type
, "type");
2614 return error::kNoError
;
2616 *result_dst
= DoGetMaxValueInBufferCHROMIUM(buffer_id
, count
, type
, offset
);
2617 return error::kNoError
;
2620 error::Error
GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
2621 uint32_t immediate_data_size
,
2622 const gles2::cmds::TexImageIOSurface2DCHROMIUM
& c
) {
2623 GLenum target
= static_cast<GLenum
>(c
.target
);
2624 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2625 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2626 GLuint ioSurfaceId
= static_cast<GLuint
>(c
.ioSurfaceId
);
2627 GLuint plane
= static_cast<GLuint
>(c
.plane
);
2628 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2629 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2630 "glTexImageIOSurface2DCHROMIUM", target
, "target");
2631 return error::kNoError
;
2635 GL_INVALID_VALUE
, "glTexImageIOSurface2DCHROMIUM", "width < 0");
2636 return error::kNoError
;
2640 GL_INVALID_VALUE
, "glTexImageIOSurface2DCHROMIUM", "height < 0");
2641 return error::kNoError
;
2643 DoTexImageIOSurface2DCHROMIUM(target
, width
, height
, ioSurfaceId
, plane
);
2644 return error::kNoError
;
2647 error::Error
GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
2648 uint32_t immediate_data_size
,
2649 const gles2::cmds::CopyTextureCHROMIUM
& c
) {
2650 GLenum target
= static_cast<GLenum
>(c
.target
);
2651 GLenum source_id
= static_cast<GLenum
>(c
.source_id
);
2652 GLenum dest_id
= static_cast<GLenum
>(c
.dest_id
);
2653 GLint level
= static_cast<GLint
>(c
.level
);
2654 GLint internalformat
= static_cast<GLint
>(c
.internalformat
);
2655 GLenum dest_type
= static_cast<GLenum
>(c
.dest_type
);
2656 if (!validators_
->texture_internal_format
.IsValid(internalformat
)) {
2657 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
2658 "glCopyTextureCHROMIUM",
2659 "internalformat GL_INVALID_VALUE");
2660 return error::kNoError
;
2662 if (!validators_
->pixel_type
.IsValid(dest_type
)) {
2663 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2664 "glCopyTextureCHROMIUM", dest_type
, "dest_type");
2665 return error::kNoError
;
2667 DoCopyTextureCHROMIUM(
2668 target
, source_id
, dest_id
, level
, internalformat
, dest_type
);
2669 return error::kNoError
;
2672 error::Error
GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
2673 uint32_t immediate_data_size
,
2674 const gles2::cmds::ProduceTextureCHROMIUMImmediate
& c
) {
2675 GLenum target
= static_cast<GLenum
>(c
.target
);
2677 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
2678 return error::kOutOfBounds
;
2680 if (data_size
> immediate_data_size
) {
2681 return error::kOutOfBounds
;
2683 const GLbyte
* mailbox
=
2684 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
2685 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2686 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2687 "glProduceTextureCHROMIUM", target
, "target");
2688 return error::kNoError
;
2690 if (mailbox
== NULL
) {
2691 return error::kOutOfBounds
;
2693 DoProduceTextureCHROMIUM(target
, mailbox
);
2694 return error::kNoError
;
2697 error::Error
GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
2698 uint32_t immediate_data_size
,
2699 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate
& c
) {
2700 GLuint texture
= c
.texture
;
2701 GLenum target
= static_cast<GLenum
>(c
.target
);
2703 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
2704 return error::kOutOfBounds
;
2706 if (data_size
> immediate_data_size
) {
2707 return error::kOutOfBounds
;
2709 const GLbyte
* mailbox
=
2710 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
2711 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2712 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2713 "glProduceTextureDirectCHROMIUM", target
, "target");
2714 return error::kNoError
;
2716 if (mailbox
== NULL
) {
2717 return error::kOutOfBounds
;
2719 DoProduceTextureDirectCHROMIUM(texture
, target
, mailbox
);
2720 return error::kNoError
;
2723 error::Error
GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
2724 uint32_t immediate_data_size
,
2725 const gles2::cmds::ConsumeTextureCHROMIUMImmediate
& c
) {
2726 GLenum target
= static_cast<GLenum
>(c
.target
);
2728 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
2729 return error::kOutOfBounds
;
2731 if (data_size
> immediate_data_size
) {
2732 return error::kOutOfBounds
;
2734 const GLbyte
* mailbox
=
2735 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
2736 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2737 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2738 "glConsumeTextureCHROMIUM", target
, "target");
2739 return error::kNoError
;
2741 if (mailbox
== NULL
) {
2742 return error::kOutOfBounds
;
2744 DoConsumeTextureCHROMIUM(target
, mailbox
);
2745 return error::kNoError
;
2748 error::Error
GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
2749 uint32_t immediate_data_size
,
2750 const gles2::cmds::BindTexImage2DCHROMIUM
& c
) {
2751 GLenum target
= static_cast<GLenum
>(c
.target
);
2752 GLint imageId
= static_cast<GLint
>(c
.imageId
);
2753 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2754 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2755 "glBindTexImage2DCHROMIUM", target
, "target");
2756 return error::kNoError
;
2758 DoBindTexImage2DCHROMIUM(target
, imageId
);
2759 return error::kNoError
;
2762 error::Error
GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
2763 uint32_t immediate_data_size
,
2764 const gles2::cmds::ReleaseTexImage2DCHROMIUM
& c
) {
2765 GLenum target
= static_cast<GLenum
>(c
.target
);
2766 GLint imageId
= static_cast<GLint
>(c
.imageId
);
2767 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2768 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2769 "glReleaseTexImage2DCHROMIUM", target
, "target");
2770 return error::kNoError
;
2772 DoReleaseTexImage2DCHROMIUM(target
, imageId
);
2773 return error::kNoError
;
2776 error::Error
GLES2DecoderImpl::HandleTraceEndCHROMIUM(
2777 uint32_t immediate_data_size
,
2778 const gles2::cmds::TraceEndCHROMIUM
& c
) {
2779 DoTraceEndCHROMIUM();
2780 return error::kNoError
;
2783 error::Error
GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
2784 uint32_t immediate_data_size
,
2785 const gles2::cmds::DiscardFramebufferEXTImmediate
& c
) {
2786 if (!features().ext_discard_framebuffer
) {
2787 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2788 "glDiscardFramebufferEXT",
2789 "function not available");
2790 return error::kNoError
;
2793 GLenum target
= static_cast<GLenum
>(c
.target
);
2794 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2796 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
2797 return error::kOutOfBounds
;
2799 if (data_size
> immediate_data_size
) {
2800 return error::kOutOfBounds
;
2802 const GLenum
* attachments
=
2803 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
2806 GL_INVALID_VALUE
, "glDiscardFramebufferEXT", "count < 0");
2807 return error::kNoError
;
2809 if (attachments
== NULL
) {
2810 return error::kOutOfBounds
;
2812 DoDiscardFramebufferEXT(target
, count
, attachments
);
2813 return error::kNoError
;
2816 error::Error
GLES2DecoderImpl::HandleLoseContextCHROMIUM(
2817 uint32_t immediate_data_size
,
2818 const gles2::cmds::LoseContextCHROMIUM
& c
) {
2819 GLenum current
= static_cast<GLenum
>(c
.current
);
2820 GLenum other
= static_cast<GLenum
>(c
.other
);
2821 if (!validators_
->reset_status
.IsValid(current
)) {
2822 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2823 "glLoseContextCHROMIUM", current
, "current");
2824 return error::kNoError
;
2826 if (!validators_
->reset_status
.IsValid(other
)) {
2827 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other
, "other");
2828 return error::kNoError
;
2830 DoLoseContextCHROMIUM(current
, other
);
2831 return error::kNoError
;
2834 error::Error
GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
2835 uint32_t immediate_data_size
,
2836 const gles2::cmds::DrawBuffersEXTImmediate
& c
) {
2837 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2839 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
2840 return error::kOutOfBounds
;
2842 if (data_size
> immediate_data_size
) {
2843 return error::kOutOfBounds
;
2845 const GLenum
* bufs
=
2846 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
2848 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glDrawBuffersEXT", "count < 0");
2849 return error::kNoError
;
2852 return error::kOutOfBounds
;
2854 DoDrawBuffersEXT(count
, bufs
);
2855 return error::kNoError
;
2858 error::Error
GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
2859 uint32_t immediate_data_size
,
2860 const gles2::cmds::MatrixLoadfCHROMIUMImmediate
& c
) {
2861 if (!features().chromium_path_rendering
) {
2862 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2863 "glMatrixLoadfCHROMIUM",
2864 "function not available");
2865 return error::kNoError
;
2868 GLenum matrixMode
= static_cast<GLenum
>(c
.matrixMode
);
2870 if (!ComputeDataSize(1, sizeof(GLfloat
), 16, &data_size
)) {
2871 return error::kOutOfBounds
;
2873 if (data_size
> immediate_data_size
) {
2874 return error::kOutOfBounds
;
2877 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2878 if (!validators_
->matrix_mode
.IsValid(matrixMode
)) {
2879 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2880 "glMatrixLoadfCHROMIUM", matrixMode
, "matrixMode");
2881 return error::kNoError
;
2884 return error::kOutOfBounds
;
2886 DoMatrixLoadfCHROMIUM(matrixMode
, m
);
2887 return error::kNoError
;
2890 error::Error
GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
2891 uint32_t immediate_data_size
,
2892 const gles2::cmds::MatrixLoadIdentityCHROMIUM
& c
) {
2893 if (!features().chromium_path_rendering
) {
2894 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
2895 "glMatrixLoadIdentityCHROMIUM",
2896 "function not available");
2897 return error::kNoError
;
2900 GLenum matrixMode
= static_cast<GLenum
>(c
.matrixMode
);
2901 if (!validators_
->matrix_mode
.IsValid(matrixMode
)) {
2902 LOCAL_SET_GL_ERROR_INVALID_ENUM(
2903 "glMatrixLoadIdentityCHROMIUM", matrixMode
, "matrixMode");
2904 return error::kNoError
;
2906 DoMatrixLoadIdentityCHROMIUM(matrixMode
);
2907 return error::kNoError
;
2910 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap
, bool enabled
) {
2913 state_
.enable_flags
.blend
= enabled
;
2914 if (state_
.enable_flags
.cached_blend
!= enabled
||
2915 state_
.ignore_cached_state
) {
2916 state_
.enable_flags
.cached_blend
= enabled
;
2921 state_
.enable_flags
.cull_face
= enabled
;
2922 if (state_
.enable_flags
.cached_cull_face
!= enabled
||
2923 state_
.ignore_cached_state
) {
2924 state_
.enable_flags
.cached_cull_face
= enabled
;
2929 state_
.enable_flags
.depth_test
= enabled
;
2930 if (state_
.enable_flags
.cached_depth_test
!= enabled
||
2931 state_
.ignore_cached_state
) {
2932 framebuffer_state_
.clear_state_dirty
= true;
2936 state_
.enable_flags
.dither
= enabled
;
2937 if (state_
.enable_flags
.cached_dither
!= enabled
||
2938 state_
.ignore_cached_state
) {
2939 state_
.enable_flags
.cached_dither
= enabled
;
2943 case GL_POLYGON_OFFSET_FILL
:
2944 state_
.enable_flags
.polygon_offset_fill
= enabled
;
2945 if (state_
.enable_flags
.cached_polygon_offset_fill
!= enabled
||
2946 state_
.ignore_cached_state
) {
2947 state_
.enable_flags
.cached_polygon_offset_fill
= enabled
;
2951 case GL_SAMPLE_ALPHA_TO_COVERAGE
:
2952 state_
.enable_flags
.sample_alpha_to_coverage
= enabled
;
2953 if (state_
.enable_flags
.cached_sample_alpha_to_coverage
!= enabled
||
2954 state_
.ignore_cached_state
) {
2955 state_
.enable_flags
.cached_sample_alpha_to_coverage
= enabled
;
2959 case GL_SAMPLE_COVERAGE
:
2960 state_
.enable_flags
.sample_coverage
= enabled
;
2961 if (state_
.enable_flags
.cached_sample_coverage
!= enabled
||
2962 state_
.ignore_cached_state
) {
2963 state_
.enable_flags
.cached_sample_coverage
= enabled
;
2967 case GL_SCISSOR_TEST
:
2968 state_
.enable_flags
.scissor_test
= enabled
;
2969 if (state_
.enable_flags
.cached_scissor_test
!= enabled
||
2970 state_
.ignore_cached_state
) {
2971 state_
.enable_flags
.cached_scissor_test
= enabled
;
2975 case GL_STENCIL_TEST
:
2976 state_
.enable_flags
.stencil_test
= enabled
;
2977 if (state_
.enable_flags
.cached_stencil_test
!= enabled
||
2978 state_
.ignore_cached_state
) {
2979 framebuffer_state_
.clear_state_dirty
= true;
2987 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_