Handle account removal correctly on all platforms.
[chromium-blink-merge.git] / gpu / command_buffer / service / context_state_impl_autogen.h
blob1b1e5fe43015499a315fd3f16efb6294f66f4b78
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
9 // DO NOT EDIT!
11 // It is included by context_state.cc
12 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_
13 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_
15 ContextState::EnableFlags::EnableFlags()
16 : blend(false),
17 cached_blend(false),
18 cull_face(false),
19 cached_cull_face(false),
20 depth_test(false),
21 cached_depth_test(false),
22 dither(true),
23 cached_dither(true),
24 polygon_offset_fill(false),
25 cached_polygon_offset_fill(false),
26 sample_alpha_to_coverage(false),
27 cached_sample_alpha_to_coverage(false),
28 sample_coverage(false),
29 cached_sample_coverage(false),
30 scissor_test(false),
31 cached_scissor_test(false),
32 stencil_test(false),
33 cached_stencil_test(false) {
36 void ContextState::Initialize() {
37 blend_color_red = 0.0f;
38 blend_color_green = 0.0f;
39 blend_color_blue = 0.0f;
40 blend_color_alpha = 0.0f;
41 blend_equation_rgb = GL_FUNC_ADD;
42 blend_equation_alpha = GL_FUNC_ADD;
43 blend_source_rgb = GL_ONE;
44 blend_dest_rgb = GL_ZERO;
45 blend_source_alpha = GL_ONE;
46 blend_dest_alpha = GL_ZERO;
47 color_clear_red = 0.0f;
48 color_clear_green = 0.0f;
49 color_clear_blue = 0.0f;
50 color_clear_alpha = 0.0f;
51 depth_clear = 1.0f;
52 stencil_clear = 0;
53 color_mask_red = true;
54 cached_color_mask_red = true;
55 color_mask_green = true;
56 cached_color_mask_green = true;
57 color_mask_blue = true;
58 cached_color_mask_blue = true;
59 color_mask_alpha = true;
60 cached_color_mask_alpha = true;
61 cull_mode = GL_BACK;
62 depth_func = GL_LESS;
63 depth_mask = true;
64 cached_depth_mask = true;
65 z_near = 0.0f;
66 z_far = 1.0f;
67 front_face = GL_CCW;
68 hint_generate_mipmap = GL_DONT_CARE;
69 hint_fragment_shader_derivative = GL_DONT_CARE;
70 line_width = 1.0f;
71 modelview_matrix[0] = 1.0f;
72 modelview_matrix[1] = 0.0f;
73 modelview_matrix[2] = 0.0f;
74 modelview_matrix[3] = 0.0f;
75 modelview_matrix[4] = 0.0f;
76 modelview_matrix[5] = 1.0f;
77 modelview_matrix[6] = 0.0f;
78 modelview_matrix[7] = 0.0f;
79 modelview_matrix[8] = 0.0f;
80 modelview_matrix[9] = 0.0f;
81 modelview_matrix[10] = 1.0f;
82 modelview_matrix[11] = 0.0f;
83 modelview_matrix[12] = 0.0f;
84 modelview_matrix[13] = 0.0f;
85 modelview_matrix[14] = 0.0f;
86 modelview_matrix[15] = 1.0f;
87 projection_matrix[0] = 1.0f;
88 projection_matrix[1] = 0.0f;
89 projection_matrix[2] = 0.0f;
90 projection_matrix[3] = 0.0f;
91 projection_matrix[4] = 0.0f;
92 projection_matrix[5] = 1.0f;
93 projection_matrix[6] = 0.0f;
94 projection_matrix[7] = 0.0f;
95 projection_matrix[8] = 0.0f;
96 projection_matrix[9] = 0.0f;
97 projection_matrix[10] = 1.0f;
98 projection_matrix[11] = 0.0f;
99 projection_matrix[12] = 0.0f;
100 projection_matrix[13] = 0.0f;
101 projection_matrix[14] = 0.0f;
102 projection_matrix[15] = 1.0f;
103 pack_alignment = 4;
104 unpack_alignment = 4;
105 polygon_offset_factor = 0.0f;
106 polygon_offset_units = 0.0f;
107 sample_coverage_value = 1.0f;
108 sample_coverage_invert = false;
109 scissor_x = 0;
110 scissor_y = 0;
111 scissor_width = 1;
112 scissor_height = 1;
113 stencil_front_func = GL_ALWAYS;
114 stencil_front_ref = 0;
115 stencil_front_mask = 0xFFFFFFFFU;
116 stencil_back_func = GL_ALWAYS;
117 stencil_back_ref = 0;
118 stencil_back_mask = 0xFFFFFFFFU;
119 stencil_front_writemask = 0xFFFFFFFFU;
120 cached_stencil_front_writemask = 0xFFFFFFFFU;
121 stencil_back_writemask = 0xFFFFFFFFU;
122 cached_stencil_back_writemask = 0xFFFFFFFFU;
123 stencil_front_fail_op = GL_KEEP;
124 stencil_front_z_fail_op = GL_KEEP;
125 stencil_front_z_pass_op = GL_KEEP;
126 stencil_back_fail_op = GL_KEEP;
127 stencil_back_z_fail_op = GL_KEEP;
128 stencil_back_z_pass_op = GL_KEEP;
129 viewport_x = 0;
130 viewport_y = 0;
131 viewport_width = 1;
132 viewport_height = 1;
135 void ContextState::InitCapabilities(const ContextState* prev_state) const {
136 if (prev_state) {
137 if (prev_state->enable_flags.cached_blend != enable_flags.cached_blend)
138 EnableDisable(GL_BLEND, enable_flags.cached_blend);
139 if (prev_state->enable_flags.cached_cull_face !=
140 enable_flags.cached_cull_face)
141 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
142 if (prev_state->enable_flags.cached_depth_test !=
143 enable_flags.cached_depth_test)
144 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
145 if (prev_state->enable_flags.cached_dither != enable_flags.cached_dither)
146 EnableDisable(GL_DITHER, enable_flags.cached_dither);
147 if (prev_state->enable_flags.cached_polygon_offset_fill !=
148 enable_flags.cached_polygon_offset_fill)
149 EnableDisable(GL_POLYGON_OFFSET_FILL,
150 enable_flags.cached_polygon_offset_fill);
151 if (prev_state->enable_flags.cached_sample_alpha_to_coverage !=
152 enable_flags.cached_sample_alpha_to_coverage)
153 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
154 enable_flags.cached_sample_alpha_to_coverage);
155 if (prev_state->enable_flags.cached_sample_coverage !=
156 enable_flags.cached_sample_coverage)
157 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
158 if (prev_state->enable_flags.cached_scissor_test !=
159 enable_flags.cached_scissor_test)
160 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
161 if (prev_state->enable_flags.cached_stencil_test !=
162 enable_flags.cached_stencil_test)
163 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
164 } else {
165 EnableDisable(GL_BLEND, enable_flags.cached_blend);
166 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
167 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
168 EnableDisable(GL_DITHER, enable_flags.cached_dither);
169 EnableDisable(GL_POLYGON_OFFSET_FILL,
170 enable_flags.cached_polygon_offset_fill);
171 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
172 enable_flags.cached_sample_alpha_to_coverage);
173 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
174 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
175 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
179 void ContextState::InitState(const ContextState* prev_state) const {
180 if (prev_state) {
181 if ((blend_color_red != prev_state->blend_color_red) ||
182 (blend_color_green != prev_state->blend_color_green) ||
183 (blend_color_blue != prev_state->blend_color_blue) ||
184 (blend_color_alpha != prev_state->blend_color_alpha))
185 glBlendColor(blend_color_red,
186 blend_color_green,
187 blend_color_blue,
188 blend_color_alpha);
189 if ((blend_equation_rgb != prev_state->blend_equation_rgb) ||
190 (blend_equation_alpha != prev_state->blend_equation_alpha))
191 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
192 if ((blend_source_rgb != prev_state->blend_source_rgb) ||
193 (blend_dest_rgb != prev_state->blend_dest_rgb) ||
194 (blend_source_alpha != prev_state->blend_source_alpha) ||
195 (blend_dest_alpha != prev_state->blend_dest_alpha))
196 glBlendFuncSeparate(blend_source_rgb,
197 blend_dest_rgb,
198 blend_source_alpha,
199 blend_dest_alpha);
200 if ((color_clear_red != prev_state->color_clear_red) ||
201 (color_clear_green != prev_state->color_clear_green) ||
202 (color_clear_blue != prev_state->color_clear_blue) ||
203 (color_clear_alpha != prev_state->color_clear_alpha))
204 glClearColor(color_clear_red,
205 color_clear_green,
206 color_clear_blue,
207 color_clear_alpha);
208 if ((depth_clear != prev_state->depth_clear))
209 glClearDepth(depth_clear);
210 if ((stencil_clear != prev_state->stencil_clear))
211 glClearStencil(stencil_clear);
212 if ((cached_color_mask_red != prev_state->cached_color_mask_red) ||
213 (cached_color_mask_green != prev_state->cached_color_mask_green) ||
214 (cached_color_mask_blue != prev_state->cached_color_mask_blue) ||
215 (cached_color_mask_alpha != prev_state->cached_color_mask_alpha))
216 glColorMask(cached_color_mask_red,
217 cached_color_mask_green,
218 cached_color_mask_blue,
219 cached_color_mask_alpha);
220 if ((cull_mode != prev_state->cull_mode))
221 glCullFace(cull_mode);
222 if ((depth_func != prev_state->depth_func))
223 glDepthFunc(depth_func);
224 if ((cached_depth_mask != prev_state->cached_depth_mask))
225 glDepthMask(cached_depth_mask);
226 if ((z_near != prev_state->z_near) || (z_far != prev_state->z_far))
227 glDepthRange(z_near, z_far);
228 if ((front_face != prev_state->front_face))
229 glFrontFace(front_face);
230 if (prev_state->hint_generate_mipmap != hint_generate_mipmap) {
231 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
233 if (feature_info_->feature_flags().oes_standard_derivatives) {
234 if (prev_state->hint_fragment_shader_derivative !=
235 hint_fragment_shader_derivative) {
236 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
237 hint_fragment_shader_derivative);
240 if ((line_width != prev_state->line_width))
241 glLineWidth(line_width);
242 if (feature_info_->feature_flags().chromium_path_rendering) {
243 if (memcmp(prev_state->modelview_matrix,
244 modelview_matrix,
245 sizeof(GLfloat) * 16)) {
246 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
249 if (feature_info_->feature_flags().chromium_path_rendering) {
250 if (memcmp(prev_state->projection_matrix,
251 projection_matrix,
252 sizeof(GLfloat) * 16)) {
253 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
256 if (prev_state->pack_alignment != pack_alignment) {
257 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
259 if (prev_state->unpack_alignment != unpack_alignment) {
260 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
262 if ((polygon_offset_factor != prev_state->polygon_offset_factor) ||
263 (polygon_offset_units != prev_state->polygon_offset_units))
264 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
265 if ((sample_coverage_value != prev_state->sample_coverage_value) ||
266 (sample_coverage_invert != prev_state->sample_coverage_invert))
267 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
268 if ((scissor_x != prev_state->scissor_x) ||
269 (scissor_y != prev_state->scissor_y) ||
270 (scissor_width != prev_state->scissor_width) ||
271 (scissor_height != prev_state->scissor_height))
272 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
273 if ((stencil_front_func != prev_state->stencil_front_func) ||
274 (stencil_front_ref != prev_state->stencil_front_ref) ||
275 (stencil_front_mask != prev_state->stencil_front_mask))
276 glStencilFuncSeparate(
277 GL_FRONT, stencil_front_func, stencil_front_ref, stencil_front_mask);
278 if ((stencil_back_func != prev_state->stencil_back_func) ||
279 (stencil_back_ref != prev_state->stencil_back_ref) ||
280 (stencil_back_mask != prev_state->stencil_back_mask))
281 glStencilFuncSeparate(
282 GL_BACK, stencil_back_func, stencil_back_ref, stencil_back_mask);
283 if ((cached_stencil_front_writemask !=
284 prev_state->cached_stencil_front_writemask))
285 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
286 if ((cached_stencil_back_writemask !=
287 prev_state->cached_stencil_back_writemask))
288 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
289 if ((stencil_front_fail_op != prev_state->stencil_front_fail_op) ||
290 (stencil_front_z_fail_op != prev_state->stencil_front_z_fail_op) ||
291 (stencil_front_z_pass_op != prev_state->stencil_front_z_pass_op))
292 glStencilOpSeparate(GL_FRONT,
293 stencil_front_fail_op,
294 stencil_front_z_fail_op,
295 stencil_front_z_pass_op);
296 if ((stencil_back_fail_op != prev_state->stencil_back_fail_op) ||
297 (stencil_back_z_fail_op != prev_state->stencil_back_z_fail_op) ||
298 (stencil_back_z_pass_op != prev_state->stencil_back_z_pass_op))
299 glStencilOpSeparate(GL_BACK,
300 stencil_back_fail_op,
301 stencil_back_z_fail_op,
302 stencil_back_z_pass_op);
303 if ((viewport_x != prev_state->viewport_x) ||
304 (viewport_y != prev_state->viewport_y) ||
305 (viewport_width != prev_state->viewport_width) ||
306 (viewport_height != prev_state->viewport_height))
307 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
308 } else {
309 glBlendColor(blend_color_red,
310 blend_color_green,
311 blend_color_blue,
312 blend_color_alpha);
313 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
314 glBlendFuncSeparate(
315 blend_source_rgb, blend_dest_rgb, blend_source_alpha, blend_dest_alpha);
316 glClearColor(color_clear_red,
317 color_clear_green,
318 color_clear_blue,
319 color_clear_alpha);
320 glClearDepth(depth_clear);
321 glClearStencil(stencil_clear);
322 glColorMask(cached_color_mask_red,
323 cached_color_mask_green,
324 cached_color_mask_blue,
325 cached_color_mask_alpha);
326 glCullFace(cull_mode);
327 glDepthFunc(depth_func);
328 glDepthMask(cached_depth_mask);
329 glDepthRange(z_near, z_far);
330 glFrontFace(front_face);
331 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
332 if (feature_info_->feature_flags().oes_standard_derivatives) {
333 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
334 hint_fragment_shader_derivative);
336 glLineWidth(line_width);
337 if (feature_info_->feature_flags().chromium_path_rendering) {
338 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
340 if (feature_info_->feature_flags().chromium_path_rendering) {
341 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
343 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
344 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
345 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
346 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
347 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
348 glStencilFuncSeparate(
349 GL_FRONT, stencil_front_func, stencil_front_ref, stencil_front_mask);
350 glStencilFuncSeparate(
351 GL_BACK, stencil_back_func, stencil_back_ref, stencil_back_mask);
352 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
353 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
354 glStencilOpSeparate(GL_FRONT,
355 stencil_front_fail_op,
356 stencil_front_z_fail_op,
357 stencil_front_z_pass_op);
358 glStencilOpSeparate(GL_BACK,
359 stencil_back_fail_op,
360 stencil_back_z_fail_op,
361 stencil_back_z_pass_op);
362 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
365 bool ContextState::GetEnabled(GLenum cap) const {
366 switch (cap) {
367 case GL_BLEND:
368 return enable_flags.blend;
369 case GL_CULL_FACE:
370 return enable_flags.cull_face;
371 case GL_DEPTH_TEST:
372 return enable_flags.depth_test;
373 case GL_DITHER:
374 return enable_flags.dither;
375 case GL_POLYGON_OFFSET_FILL:
376 return enable_flags.polygon_offset_fill;
377 case GL_SAMPLE_ALPHA_TO_COVERAGE:
378 return enable_flags.sample_alpha_to_coverage;
379 case GL_SAMPLE_COVERAGE:
380 return enable_flags.sample_coverage;
381 case GL_SCISSOR_TEST:
382 return enable_flags.scissor_test;
383 case GL_STENCIL_TEST:
384 return enable_flags.stencil_test;
385 default:
386 NOTREACHED();
387 return false;
391 bool ContextState::GetStateAsGLint(GLenum pname,
392 GLint* params,
393 GLsizei* num_written) const {
394 switch (pname) {
395 case GL_BLEND_COLOR:
396 *num_written = 4;
397 if (params) {
398 params[0] = static_cast<GLint>(blend_color_red);
399 params[1] = static_cast<GLint>(blend_color_green);
400 params[2] = static_cast<GLint>(blend_color_blue);
401 params[3] = static_cast<GLint>(blend_color_alpha);
403 return true;
404 case GL_BLEND_EQUATION_RGB:
405 *num_written = 1;
406 if (params) {
407 params[0] = static_cast<GLint>(blend_equation_rgb);
409 return true;
410 case GL_BLEND_EQUATION_ALPHA:
411 *num_written = 1;
412 if (params) {
413 params[0] = static_cast<GLint>(blend_equation_alpha);
415 return true;
416 case GL_BLEND_SRC_RGB:
417 *num_written = 1;
418 if (params) {
419 params[0] = static_cast<GLint>(blend_source_rgb);
421 return true;
422 case GL_BLEND_DST_RGB:
423 *num_written = 1;
424 if (params) {
425 params[0] = static_cast<GLint>(blend_dest_rgb);
427 return true;
428 case GL_BLEND_SRC_ALPHA:
429 *num_written = 1;
430 if (params) {
431 params[0] = static_cast<GLint>(blend_source_alpha);
433 return true;
434 case GL_BLEND_DST_ALPHA:
435 *num_written = 1;
436 if (params) {
437 params[0] = static_cast<GLint>(blend_dest_alpha);
439 return true;
440 case GL_COLOR_CLEAR_VALUE:
441 *num_written = 4;
442 if (params) {
443 params[0] = static_cast<GLint>(color_clear_red);
444 params[1] = static_cast<GLint>(color_clear_green);
445 params[2] = static_cast<GLint>(color_clear_blue);
446 params[3] = static_cast<GLint>(color_clear_alpha);
448 return true;
449 case GL_DEPTH_CLEAR_VALUE:
450 *num_written = 1;
451 if (params) {
452 params[0] = static_cast<GLint>(depth_clear);
454 return true;
455 case GL_STENCIL_CLEAR_VALUE:
456 *num_written = 1;
457 if (params) {
458 params[0] = static_cast<GLint>(stencil_clear);
460 return true;
461 case GL_COLOR_WRITEMASK:
462 *num_written = 4;
463 if (params) {
464 params[0] = static_cast<GLint>(color_mask_red);
465 params[1] = static_cast<GLint>(color_mask_green);
466 params[2] = static_cast<GLint>(color_mask_blue);
467 params[3] = static_cast<GLint>(color_mask_alpha);
469 return true;
470 case GL_CULL_FACE_MODE:
471 *num_written = 1;
472 if (params) {
473 params[0] = static_cast<GLint>(cull_mode);
475 return true;
476 case GL_DEPTH_FUNC:
477 *num_written = 1;
478 if (params) {
479 params[0] = static_cast<GLint>(depth_func);
481 return true;
482 case GL_DEPTH_WRITEMASK:
483 *num_written = 1;
484 if (params) {
485 params[0] = static_cast<GLint>(depth_mask);
487 return true;
488 case GL_DEPTH_RANGE:
489 *num_written = 2;
490 if (params) {
491 params[0] = static_cast<GLint>(z_near);
492 params[1] = static_cast<GLint>(z_far);
494 return true;
495 case GL_FRONT_FACE:
496 *num_written = 1;
497 if (params) {
498 params[0] = static_cast<GLint>(front_face);
500 return true;
501 case GL_GENERATE_MIPMAP_HINT:
502 *num_written = 1;
503 if (params) {
504 params[0] = static_cast<GLint>(hint_generate_mipmap);
506 return true;
507 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
508 *num_written = 1;
509 if (params) {
510 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
512 return true;
513 case GL_LINE_WIDTH:
514 *num_written = 1;
515 if (params) {
516 params[0] = static_cast<GLint>(line_width);
518 return true;
519 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
520 *num_written = 16;
521 if (params) {
522 for (size_t i = 0; i < 16; ++i) {
523 params[i] = static_cast<GLint>(round(modelview_matrix[i]));
526 return true;
527 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
528 *num_written = 16;
529 if (params) {
530 for (size_t i = 0; i < 16; ++i) {
531 params[i] = static_cast<GLint>(round(projection_matrix[i]));
534 return true;
535 case GL_PACK_ALIGNMENT:
536 *num_written = 1;
537 if (params) {
538 params[0] = static_cast<GLint>(pack_alignment);
540 return true;
541 case GL_UNPACK_ALIGNMENT:
542 *num_written = 1;
543 if (params) {
544 params[0] = static_cast<GLint>(unpack_alignment);
546 return true;
547 case GL_POLYGON_OFFSET_FACTOR:
548 *num_written = 1;
549 if (params) {
550 params[0] = static_cast<GLint>(round(polygon_offset_factor));
552 return true;
553 case GL_POLYGON_OFFSET_UNITS:
554 *num_written = 1;
555 if (params) {
556 params[0] = static_cast<GLint>(round(polygon_offset_units));
558 return true;
559 case GL_SAMPLE_COVERAGE_VALUE:
560 *num_written = 1;
561 if (params) {
562 params[0] = static_cast<GLint>(sample_coverage_value);
564 return true;
565 case GL_SAMPLE_COVERAGE_INVERT:
566 *num_written = 1;
567 if (params) {
568 params[0] = static_cast<GLint>(sample_coverage_invert);
570 return true;
571 case GL_SCISSOR_BOX:
572 *num_written = 4;
573 if (params) {
574 params[0] = static_cast<GLint>(scissor_x);
575 params[1] = static_cast<GLint>(scissor_y);
576 params[2] = static_cast<GLint>(scissor_width);
577 params[3] = static_cast<GLint>(scissor_height);
579 return true;
580 case GL_STENCIL_FUNC:
581 *num_written = 1;
582 if (params) {
583 params[0] = static_cast<GLint>(stencil_front_func);
585 return true;
586 case GL_STENCIL_REF:
587 *num_written = 1;
588 if (params) {
589 params[0] = static_cast<GLint>(stencil_front_ref);
591 return true;
592 case GL_STENCIL_VALUE_MASK:
593 *num_written = 1;
594 if (params) {
595 params[0] = static_cast<GLint>(stencil_front_mask);
597 return true;
598 case GL_STENCIL_BACK_FUNC:
599 *num_written = 1;
600 if (params) {
601 params[0] = static_cast<GLint>(stencil_back_func);
603 return true;
604 case GL_STENCIL_BACK_REF:
605 *num_written = 1;
606 if (params) {
607 params[0] = static_cast<GLint>(stencil_back_ref);
609 return true;
610 case GL_STENCIL_BACK_VALUE_MASK:
611 *num_written = 1;
612 if (params) {
613 params[0] = static_cast<GLint>(stencil_back_mask);
615 return true;
616 case GL_STENCIL_WRITEMASK:
617 *num_written = 1;
618 if (params) {
619 params[0] = static_cast<GLint>(stencil_front_writemask);
621 return true;
622 case GL_STENCIL_BACK_WRITEMASK:
623 *num_written = 1;
624 if (params) {
625 params[0] = static_cast<GLint>(stencil_back_writemask);
627 return true;
628 case GL_STENCIL_FAIL:
629 *num_written = 1;
630 if (params) {
631 params[0] = static_cast<GLint>(stencil_front_fail_op);
633 return true;
634 case GL_STENCIL_PASS_DEPTH_FAIL:
635 *num_written = 1;
636 if (params) {
637 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
639 return true;
640 case GL_STENCIL_PASS_DEPTH_PASS:
641 *num_written = 1;
642 if (params) {
643 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
645 return true;
646 case GL_STENCIL_BACK_FAIL:
647 *num_written = 1;
648 if (params) {
649 params[0] = static_cast<GLint>(stencil_back_fail_op);
651 return true;
652 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
653 *num_written = 1;
654 if (params) {
655 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
657 return true;
658 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
659 *num_written = 1;
660 if (params) {
661 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
663 return true;
664 case GL_VIEWPORT:
665 *num_written = 4;
666 if (params) {
667 params[0] = static_cast<GLint>(viewport_x);
668 params[1] = static_cast<GLint>(viewport_y);
669 params[2] = static_cast<GLint>(viewport_width);
670 params[3] = static_cast<GLint>(viewport_height);
672 return true;
673 case GL_BLEND:
674 *num_written = 1;
675 if (params) {
676 params[0] = static_cast<GLint>(enable_flags.blend);
678 return true;
679 case GL_CULL_FACE:
680 *num_written = 1;
681 if (params) {
682 params[0] = static_cast<GLint>(enable_flags.cull_face);
684 return true;
685 case GL_DEPTH_TEST:
686 *num_written = 1;
687 if (params) {
688 params[0] = static_cast<GLint>(enable_flags.depth_test);
690 return true;
691 case GL_DITHER:
692 *num_written = 1;
693 if (params) {
694 params[0] = static_cast<GLint>(enable_flags.dither);
696 return true;
697 case GL_POLYGON_OFFSET_FILL:
698 *num_written = 1;
699 if (params) {
700 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
702 return true;
703 case GL_SAMPLE_ALPHA_TO_COVERAGE:
704 *num_written = 1;
705 if (params) {
706 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
708 return true;
709 case GL_SAMPLE_COVERAGE:
710 *num_written = 1;
711 if (params) {
712 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
714 return true;
715 case GL_SCISSOR_TEST:
716 *num_written = 1;
717 if (params) {
718 params[0] = static_cast<GLint>(enable_flags.scissor_test);
720 return true;
721 case GL_STENCIL_TEST:
722 *num_written = 1;
723 if (params) {
724 params[0] = static_cast<GLint>(enable_flags.stencil_test);
726 return true;
727 default:
728 return false;
732 bool ContextState::GetStateAsGLfloat(GLenum pname,
733 GLfloat* params,
734 GLsizei* num_written) const {
735 switch (pname) {
736 case GL_BLEND_COLOR:
737 *num_written = 4;
738 if (params) {
739 params[0] = static_cast<GLfloat>(blend_color_red);
740 params[1] = static_cast<GLfloat>(blend_color_green);
741 params[2] = static_cast<GLfloat>(blend_color_blue);
742 params[3] = static_cast<GLfloat>(blend_color_alpha);
744 return true;
745 case GL_BLEND_EQUATION_RGB:
746 *num_written = 1;
747 if (params) {
748 params[0] = static_cast<GLfloat>(blend_equation_rgb);
750 return true;
751 case GL_BLEND_EQUATION_ALPHA:
752 *num_written = 1;
753 if (params) {
754 params[0] = static_cast<GLfloat>(blend_equation_alpha);
756 return true;
757 case GL_BLEND_SRC_RGB:
758 *num_written = 1;
759 if (params) {
760 params[0] = static_cast<GLfloat>(blend_source_rgb);
762 return true;
763 case GL_BLEND_DST_RGB:
764 *num_written = 1;
765 if (params) {
766 params[0] = static_cast<GLfloat>(blend_dest_rgb);
768 return true;
769 case GL_BLEND_SRC_ALPHA:
770 *num_written = 1;
771 if (params) {
772 params[0] = static_cast<GLfloat>(blend_source_alpha);
774 return true;
775 case GL_BLEND_DST_ALPHA:
776 *num_written = 1;
777 if (params) {
778 params[0] = static_cast<GLfloat>(blend_dest_alpha);
780 return true;
781 case GL_COLOR_CLEAR_VALUE:
782 *num_written = 4;
783 if (params) {
784 params[0] = static_cast<GLfloat>(color_clear_red);
785 params[1] = static_cast<GLfloat>(color_clear_green);
786 params[2] = static_cast<GLfloat>(color_clear_blue);
787 params[3] = static_cast<GLfloat>(color_clear_alpha);
789 return true;
790 case GL_DEPTH_CLEAR_VALUE:
791 *num_written = 1;
792 if (params) {
793 params[0] = static_cast<GLfloat>(depth_clear);
795 return true;
796 case GL_STENCIL_CLEAR_VALUE:
797 *num_written = 1;
798 if (params) {
799 params[0] = static_cast<GLfloat>(stencil_clear);
801 return true;
802 case GL_COLOR_WRITEMASK:
803 *num_written = 4;
804 if (params) {
805 params[0] = static_cast<GLfloat>(color_mask_red);
806 params[1] = static_cast<GLfloat>(color_mask_green);
807 params[2] = static_cast<GLfloat>(color_mask_blue);
808 params[3] = static_cast<GLfloat>(color_mask_alpha);
810 return true;
811 case GL_CULL_FACE_MODE:
812 *num_written = 1;
813 if (params) {
814 params[0] = static_cast<GLfloat>(cull_mode);
816 return true;
817 case GL_DEPTH_FUNC:
818 *num_written = 1;
819 if (params) {
820 params[0] = static_cast<GLfloat>(depth_func);
822 return true;
823 case GL_DEPTH_WRITEMASK:
824 *num_written = 1;
825 if (params) {
826 params[0] = static_cast<GLfloat>(depth_mask);
828 return true;
829 case GL_DEPTH_RANGE:
830 *num_written = 2;
831 if (params) {
832 params[0] = static_cast<GLfloat>(z_near);
833 params[1] = static_cast<GLfloat>(z_far);
835 return true;
836 case GL_FRONT_FACE:
837 *num_written = 1;
838 if (params) {
839 params[0] = static_cast<GLfloat>(front_face);
841 return true;
842 case GL_GENERATE_MIPMAP_HINT:
843 *num_written = 1;
844 if (params) {
845 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
847 return true;
848 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
849 *num_written = 1;
850 if (params) {
851 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
853 return true;
854 case GL_LINE_WIDTH:
855 *num_written = 1;
856 if (params) {
857 params[0] = static_cast<GLfloat>(line_width);
859 return true;
860 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
861 *num_written = 16;
862 if (params) {
863 memcpy(params, modelview_matrix, sizeof(GLfloat) * 16);
865 return true;
866 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
867 *num_written = 16;
868 if (params) {
869 memcpy(params, projection_matrix, sizeof(GLfloat) * 16);
871 return true;
872 case GL_PACK_ALIGNMENT:
873 *num_written = 1;
874 if (params) {
875 params[0] = static_cast<GLfloat>(pack_alignment);
877 return true;
878 case GL_UNPACK_ALIGNMENT:
879 *num_written = 1;
880 if (params) {
881 params[0] = static_cast<GLfloat>(unpack_alignment);
883 return true;
884 case GL_POLYGON_OFFSET_FACTOR:
885 *num_written = 1;
886 if (params) {
887 params[0] = static_cast<GLfloat>(polygon_offset_factor);
889 return true;
890 case GL_POLYGON_OFFSET_UNITS:
891 *num_written = 1;
892 if (params) {
893 params[0] = static_cast<GLfloat>(polygon_offset_units);
895 return true;
896 case GL_SAMPLE_COVERAGE_VALUE:
897 *num_written = 1;
898 if (params) {
899 params[0] = static_cast<GLfloat>(sample_coverage_value);
901 return true;
902 case GL_SAMPLE_COVERAGE_INVERT:
903 *num_written = 1;
904 if (params) {
905 params[0] = static_cast<GLfloat>(sample_coverage_invert);
907 return true;
908 case GL_SCISSOR_BOX:
909 *num_written = 4;
910 if (params) {
911 params[0] = static_cast<GLfloat>(scissor_x);
912 params[1] = static_cast<GLfloat>(scissor_y);
913 params[2] = static_cast<GLfloat>(scissor_width);
914 params[3] = static_cast<GLfloat>(scissor_height);
916 return true;
917 case GL_STENCIL_FUNC:
918 *num_written = 1;
919 if (params) {
920 params[0] = static_cast<GLfloat>(stencil_front_func);
922 return true;
923 case GL_STENCIL_REF:
924 *num_written = 1;
925 if (params) {
926 params[0] = static_cast<GLfloat>(stencil_front_ref);
928 return true;
929 case GL_STENCIL_VALUE_MASK:
930 *num_written = 1;
931 if (params) {
932 params[0] = static_cast<GLfloat>(stencil_front_mask);
934 return true;
935 case GL_STENCIL_BACK_FUNC:
936 *num_written = 1;
937 if (params) {
938 params[0] = static_cast<GLfloat>(stencil_back_func);
940 return true;
941 case GL_STENCIL_BACK_REF:
942 *num_written = 1;
943 if (params) {
944 params[0] = static_cast<GLfloat>(stencil_back_ref);
946 return true;
947 case GL_STENCIL_BACK_VALUE_MASK:
948 *num_written = 1;
949 if (params) {
950 params[0] = static_cast<GLfloat>(stencil_back_mask);
952 return true;
953 case GL_STENCIL_WRITEMASK:
954 *num_written = 1;
955 if (params) {
956 params[0] = static_cast<GLfloat>(stencil_front_writemask);
958 return true;
959 case GL_STENCIL_BACK_WRITEMASK:
960 *num_written = 1;
961 if (params) {
962 params[0] = static_cast<GLfloat>(stencil_back_writemask);
964 return true;
965 case GL_STENCIL_FAIL:
966 *num_written = 1;
967 if (params) {
968 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
970 return true;
971 case GL_STENCIL_PASS_DEPTH_FAIL:
972 *num_written = 1;
973 if (params) {
974 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
976 return true;
977 case GL_STENCIL_PASS_DEPTH_PASS:
978 *num_written = 1;
979 if (params) {
980 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
982 return true;
983 case GL_STENCIL_BACK_FAIL:
984 *num_written = 1;
985 if (params) {
986 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
988 return true;
989 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
990 *num_written = 1;
991 if (params) {
992 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
994 return true;
995 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
996 *num_written = 1;
997 if (params) {
998 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
1000 return true;
1001 case GL_VIEWPORT:
1002 *num_written = 4;
1003 if (params) {
1004 params[0] = static_cast<GLfloat>(viewport_x);
1005 params[1] = static_cast<GLfloat>(viewport_y);
1006 params[2] = static_cast<GLfloat>(viewport_width);
1007 params[3] = static_cast<GLfloat>(viewport_height);
1009 return true;
1010 case GL_BLEND:
1011 *num_written = 1;
1012 if (params) {
1013 params[0] = static_cast<GLfloat>(enable_flags.blend);
1015 return true;
1016 case GL_CULL_FACE:
1017 *num_written = 1;
1018 if (params) {
1019 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
1021 return true;
1022 case GL_DEPTH_TEST:
1023 *num_written = 1;
1024 if (params) {
1025 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
1027 return true;
1028 case GL_DITHER:
1029 *num_written = 1;
1030 if (params) {
1031 params[0] = static_cast<GLfloat>(enable_flags.dither);
1033 return true;
1034 case GL_POLYGON_OFFSET_FILL:
1035 *num_written = 1;
1036 if (params) {
1037 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
1039 return true;
1040 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1041 *num_written = 1;
1042 if (params) {
1043 params[0] = static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
1045 return true;
1046 case GL_SAMPLE_COVERAGE:
1047 *num_written = 1;
1048 if (params) {
1049 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
1051 return true;
1052 case GL_SCISSOR_TEST:
1053 *num_written = 1;
1054 if (params) {
1055 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
1057 return true;
1058 case GL_STENCIL_TEST:
1059 *num_written = 1;
1060 if (params) {
1061 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
1063 return true;
1064 default:
1065 return false;
1068 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_