Elim cr-checkbox
[chromium-blink-merge.git] / gpu / command_buffer / service / context_state_impl_autogen.h
blob450f0e295e0619cf85f2c7cd1ccda67c08a54378
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),
34 rasterizer_discard(false),
35 cached_rasterizer_discard(false),
36 primitive_restart_fixed_index(false),
37 cached_primitive_restart_fixed_index(false) {}
39 void ContextState::Initialize() {
40 blend_color_red = 0.0f;
41 blend_color_green = 0.0f;
42 blend_color_blue = 0.0f;
43 blend_color_alpha = 0.0f;
44 blend_equation_rgb = GL_FUNC_ADD;
45 blend_equation_alpha = GL_FUNC_ADD;
46 blend_source_rgb = GL_ONE;
47 blend_dest_rgb = GL_ZERO;
48 blend_source_alpha = GL_ONE;
49 blend_dest_alpha = GL_ZERO;
50 color_clear_red = 0.0f;
51 color_clear_green = 0.0f;
52 color_clear_blue = 0.0f;
53 color_clear_alpha = 0.0f;
54 depth_clear = 1.0f;
55 stencil_clear = 0;
56 color_mask_red = true;
57 cached_color_mask_red = true;
58 color_mask_green = true;
59 cached_color_mask_green = true;
60 color_mask_blue = true;
61 cached_color_mask_blue = true;
62 color_mask_alpha = true;
63 cached_color_mask_alpha = true;
64 cull_mode = GL_BACK;
65 depth_func = GL_LESS;
66 depth_mask = true;
67 cached_depth_mask = true;
68 z_near = 0.0f;
69 z_far = 1.0f;
70 front_face = GL_CCW;
71 hint_generate_mipmap = GL_DONT_CARE;
72 hint_fragment_shader_derivative = GL_DONT_CARE;
73 line_width = 1.0f;
74 modelview_matrix[0] = 1.0f;
75 modelview_matrix[1] = 0.0f;
76 modelview_matrix[2] = 0.0f;
77 modelview_matrix[3] = 0.0f;
78 modelview_matrix[4] = 0.0f;
79 modelview_matrix[5] = 1.0f;
80 modelview_matrix[6] = 0.0f;
81 modelview_matrix[7] = 0.0f;
82 modelview_matrix[8] = 0.0f;
83 modelview_matrix[9] = 0.0f;
84 modelview_matrix[10] = 1.0f;
85 modelview_matrix[11] = 0.0f;
86 modelview_matrix[12] = 0.0f;
87 modelview_matrix[13] = 0.0f;
88 modelview_matrix[14] = 0.0f;
89 modelview_matrix[15] = 1.0f;
90 projection_matrix[0] = 1.0f;
91 projection_matrix[1] = 0.0f;
92 projection_matrix[2] = 0.0f;
93 projection_matrix[3] = 0.0f;
94 projection_matrix[4] = 0.0f;
95 projection_matrix[5] = 1.0f;
96 projection_matrix[6] = 0.0f;
97 projection_matrix[7] = 0.0f;
98 projection_matrix[8] = 0.0f;
99 projection_matrix[9] = 0.0f;
100 projection_matrix[10] = 1.0f;
101 projection_matrix[11] = 0.0f;
102 projection_matrix[12] = 0.0f;
103 projection_matrix[13] = 0.0f;
104 projection_matrix[14] = 0.0f;
105 projection_matrix[15] = 1.0f;
106 stencil_path_func = GL_ALWAYS;
107 stencil_path_ref = 0;
108 stencil_path_mask = 0xFFFFFFFFU;
109 pack_alignment = 4;
110 unpack_alignment = 4;
111 polygon_offset_factor = 0.0f;
112 polygon_offset_units = 0.0f;
113 sample_coverage_value = 1.0f;
114 sample_coverage_invert = false;
115 scissor_x = 0;
116 scissor_y = 0;
117 scissor_width = 1;
118 scissor_height = 1;
119 stencil_front_func = GL_ALWAYS;
120 stencil_front_ref = 0;
121 stencil_front_mask = 0xFFFFFFFFU;
122 stencil_back_func = GL_ALWAYS;
123 stencil_back_ref = 0;
124 stencil_back_mask = 0xFFFFFFFFU;
125 stencil_front_writemask = 0xFFFFFFFFU;
126 cached_stencil_front_writemask = 0xFFFFFFFFU;
127 stencil_back_writemask = 0xFFFFFFFFU;
128 cached_stencil_back_writemask = 0xFFFFFFFFU;
129 stencil_front_fail_op = GL_KEEP;
130 stencil_front_z_fail_op = GL_KEEP;
131 stencil_front_z_pass_op = GL_KEEP;
132 stencil_back_fail_op = GL_KEEP;
133 stencil_back_z_fail_op = GL_KEEP;
134 stencil_back_z_pass_op = GL_KEEP;
135 viewport_x = 0;
136 viewport_y = 0;
137 viewport_width = 1;
138 viewport_height = 1;
141 void ContextState::InitCapabilities(const ContextState* prev_state) const {
142 if (prev_state) {
143 if (prev_state->enable_flags.cached_blend != enable_flags.cached_blend) {
144 EnableDisable(GL_BLEND, enable_flags.cached_blend);
146 if (prev_state->enable_flags.cached_cull_face !=
147 enable_flags.cached_cull_face) {
148 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
150 if (prev_state->enable_flags.cached_depth_test !=
151 enable_flags.cached_depth_test) {
152 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
154 if (prev_state->enable_flags.cached_dither != enable_flags.cached_dither) {
155 EnableDisable(GL_DITHER, enable_flags.cached_dither);
157 if (prev_state->enable_flags.cached_polygon_offset_fill !=
158 enable_flags.cached_polygon_offset_fill) {
159 EnableDisable(GL_POLYGON_OFFSET_FILL,
160 enable_flags.cached_polygon_offset_fill);
162 if (prev_state->enable_flags.cached_sample_alpha_to_coverage !=
163 enable_flags.cached_sample_alpha_to_coverage) {
164 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
165 enable_flags.cached_sample_alpha_to_coverage);
167 if (prev_state->enable_flags.cached_sample_coverage !=
168 enable_flags.cached_sample_coverage) {
169 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
171 if (prev_state->enable_flags.cached_scissor_test !=
172 enable_flags.cached_scissor_test) {
173 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
175 if (prev_state->enable_flags.cached_stencil_test !=
176 enable_flags.cached_stencil_test) {
177 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
179 if (feature_info_->IsES3Capable()) {
180 if (prev_state->enable_flags.cached_rasterizer_discard !=
181 enable_flags.cached_rasterizer_discard) {
182 EnableDisable(GL_RASTERIZER_DISCARD,
183 enable_flags.cached_rasterizer_discard);
185 if (prev_state->enable_flags.cached_primitive_restart_fixed_index !=
186 enable_flags.cached_primitive_restart_fixed_index) {
187 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
188 enable_flags.cached_primitive_restart_fixed_index);
191 } else {
192 EnableDisable(GL_BLEND, enable_flags.cached_blend);
193 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
194 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
195 EnableDisable(GL_DITHER, enable_flags.cached_dither);
196 EnableDisable(GL_POLYGON_OFFSET_FILL,
197 enable_flags.cached_polygon_offset_fill);
198 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
199 enable_flags.cached_sample_alpha_to_coverage);
200 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
201 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
202 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
203 if (feature_info_->IsES3Capable()) {
204 EnableDisable(GL_RASTERIZER_DISCARD,
205 enable_flags.cached_rasterizer_discard);
206 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
207 enable_flags.cached_primitive_restart_fixed_index);
212 void ContextState::InitState(const ContextState* prev_state) const {
213 if (prev_state) {
214 if ((blend_color_red != prev_state->blend_color_red) ||
215 (blend_color_green != prev_state->blend_color_green) ||
216 (blend_color_blue != prev_state->blend_color_blue) ||
217 (blend_color_alpha != prev_state->blend_color_alpha))
218 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
219 blend_color_alpha);
220 if ((blend_equation_rgb != prev_state->blend_equation_rgb) ||
221 (blend_equation_alpha != prev_state->blend_equation_alpha))
222 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
223 if ((blend_source_rgb != prev_state->blend_source_rgb) ||
224 (blend_dest_rgb != prev_state->blend_dest_rgb) ||
225 (blend_source_alpha != prev_state->blend_source_alpha) ||
226 (blend_dest_alpha != prev_state->blend_dest_alpha))
227 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
228 blend_dest_alpha);
229 if ((color_clear_red != prev_state->color_clear_red) ||
230 (color_clear_green != prev_state->color_clear_green) ||
231 (color_clear_blue != prev_state->color_clear_blue) ||
232 (color_clear_alpha != prev_state->color_clear_alpha))
233 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
234 color_clear_alpha);
235 if ((depth_clear != prev_state->depth_clear))
236 glClearDepth(depth_clear);
237 if ((stencil_clear != prev_state->stencil_clear))
238 glClearStencil(stencil_clear);
239 if ((cached_color_mask_red != prev_state->cached_color_mask_red) ||
240 (cached_color_mask_green != prev_state->cached_color_mask_green) ||
241 (cached_color_mask_blue != prev_state->cached_color_mask_blue) ||
242 (cached_color_mask_alpha != prev_state->cached_color_mask_alpha))
243 glColorMask(cached_color_mask_red, cached_color_mask_green,
244 cached_color_mask_blue, cached_color_mask_alpha);
245 if ((cull_mode != prev_state->cull_mode))
246 glCullFace(cull_mode);
247 if ((depth_func != prev_state->depth_func))
248 glDepthFunc(depth_func);
249 if ((cached_depth_mask != prev_state->cached_depth_mask))
250 glDepthMask(cached_depth_mask);
251 if ((z_near != prev_state->z_near) || (z_far != prev_state->z_far))
252 glDepthRange(z_near, z_far);
253 if ((front_face != prev_state->front_face))
254 glFrontFace(front_face);
255 if (prev_state->hint_generate_mipmap != hint_generate_mipmap) {
256 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
257 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
260 if (feature_info_->feature_flags().oes_standard_derivatives) {
261 if (prev_state->hint_fragment_shader_derivative !=
262 hint_fragment_shader_derivative) {
263 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
264 hint_fragment_shader_derivative);
267 if ((line_width != prev_state->line_width))
268 glLineWidth(line_width);
269 if (feature_info_->feature_flags().chromium_path_rendering) {
270 if (memcmp(prev_state->modelview_matrix, modelview_matrix,
271 sizeof(GLfloat) * 16)) {
272 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
275 if (feature_info_->feature_flags().chromium_path_rendering) {
276 if (memcmp(prev_state->projection_matrix, projection_matrix,
277 sizeof(GLfloat) * 16)) {
278 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
281 if (feature_info_->feature_flags().chromium_path_rendering)
282 if ((stencil_path_func != prev_state->stencil_path_func) ||
283 (stencil_path_ref != prev_state->stencil_path_ref) ||
284 (stencil_path_mask != prev_state->stencil_path_mask))
285 glPathStencilFuncNV(stencil_path_func, stencil_path_ref,
286 stencil_path_mask);
287 if (prev_state->pack_alignment != pack_alignment) {
288 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
290 if (prev_state->unpack_alignment != unpack_alignment) {
291 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
293 if ((polygon_offset_factor != prev_state->polygon_offset_factor) ||
294 (polygon_offset_units != prev_state->polygon_offset_units))
295 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
296 if ((sample_coverage_value != prev_state->sample_coverage_value) ||
297 (sample_coverage_invert != prev_state->sample_coverage_invert))
298 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
299 if ((scissor_x != prev_state->scissor_x) ||
300 (scissor_y != prev_state->scissor_y) ||
301 (scissor_width != prev_state->scissor_width) ||
302 (scissor_height != prev_state->scissor_height))
303 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
304 if ((stencil_front_func != prev_state->stencil_front_func) ||
305 (stencil_front_ref != prev_state->stencil_front_ref) ||
306 (stencil_front_mask != prev_state->stencil_front_mask))
307 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
308 stencil_front_mask);
309 if ((stencil_back_func != prev_state->stencil_back_func) ||
310 (stencil_back_ref != prev_state->stencil_back_ref) ||
311 (stencil_back_mask != prev_state->stencil_back_mask))
312 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
313 stencil_back_mask);
314 if ((cached_stencil_front_writemask !=
315 prev_state->cached_stencil_front_writemask))
316 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
317 if ((cached_stencil_back_writemask !=
318 prev_state->cached_stencil_back_writemask))
319 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
320 if ((stencil_front_fail_op != prev_state->stencil_front_fail_op) ||
321 (stencil_front_z_fail_op != prev_state->stencil_front_z_fail_op) ||
322 (stencil_front_z_pass_op != prev_state->stencil_front_z_pass_op))
323 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
324 stencil_front_z_fail_op, stencil_front_z_pass_op);
325 if ((stencil_back_fail_op != prev_state->stencil_back_fail_op) ||
326 (stencil_back_z_fail_op != prev_state->stencil_back_z_fail_op) ||
327 (stencil_back_z_pass_op != prev_state->stencil_back_z_pass_op))
328 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
329 stencil_back_z_pass_op);
330 if ((viewport_x != prev_state->viewport_x) ||
331 (viewport_y != prev_state->viewport_y) ||
332 (viewport_width != prev_state->viewport_width) ||
333 (viewport_height != prev_state->viewport_height))
334 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
335 } else {
336 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
337 blend_color_alpha);
338 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
339 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
340 blend_dest_alpha);
341 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
342 color_clear_alpha);
343 glClearDepth(depth_clear);
344 glClearStencil(stencil_clear);
345 glColorMask(cached_color_mask_red, cached_color_mask_green,
346 cached_color_mask_blue, cached_color_mask_alpha);
347 glCullFace(cull_mode);
348 glDepthFunc(depth_func);
349 glDepthMask(cached_depth_mask);
350 glDepthRange(z_near, z_far);
351 glFrontFace(front_face);
352 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
353 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
355 if (feature_info_->feature_flags().oes_standard_derivatives) {
356 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
357 hint_fragment_shader_derivative);
359 glLineWidth(line_width);
360 if (feature_info_->feature_flags().chromium_path_rendering) {
361 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
363 if (feature_info_->feature_flags().chromium_path_rendering) {
364 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
366 if (feature_info_->feature_flags().chromium_path_rendering)
367 glPathStencilFuncNV(stencil_path_func, stencil_path_ref,
368 stencil_path_mask);
369 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
370 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
371 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
372 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
373 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
374 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
375 stencil_front_mask);
376 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
377 stencil_back_mask);
378 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
379 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
380 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
381 stencil_front_z_fail_op, stencil_front_z_pass_op);
382 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
383 stencil_back_z_pass_op);
384 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
387 bool ContextState::GetEnabled(GLenum cap) const {
388 switch (cap) {
389 case GL_BLEND:
390 return enable_flags.blend;
391 case GL_CULL_FACE:
392 return enable_flags.cull_face;
393 case GL_DEPTH_TEST:
394 return enable_flags.depth_test;
395 case GL_DITHER:
396 return enable_flags.dither;
397 case GL_POLYGON_OFFSET_FILL:
398 return enable_flags.polygon_offset_fill;
399 case GL_SAMPLE_ALPHA_TO_COVERAGE:
400 return enable_flags.sample_alpha_to_coverage;
401 case GL_SAMPLE_COVERAGE:
402 return enable_flags.sample_coverage;
403 case GL_SCISSOR_TEST:
404 return enable_flags.scissor_test;
405 case GL_STENCIL_TEST:
406 return enable_flags.stencil_test;
407 case GL_RASTERIZER_DISCARD:
408 return enable_flags.rasterizer_discard;
409 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
410 return enable_flags.primitive_restart_fixed_index;
411 default:
412 NOTREACHED();
413 return false;
417 bool ContextState::GetStateAsGLint(GLenum pname,
418 GLint* params,
419 GLsizei* num_written) const {
420 switch (pname) {
421 case GL_BLEND_COLOR:
422 *num_written = 4;
423 if (params) {
424 params[0] = static_cast<GLint>(blend_color_red);
425 params[1] = static_cast<GLint>(blend_color_green);
426 params[2] = static_cast<GLint>(blend_color_blue);
427 params[3] = static_cast<GLint>(blend_color_alpha);
429 return true;
430 case GL_BLEND_EQUATION_RGB:
431 *num_written = 1;
432 if (params) {
433 params[0] = static_cast<GLint>(blend_equation_rgb);
435 return true;
436 case GL_BLEND_EQUATION_ALPHA:
437 *num_written = 1;
438 if (params) {
439 params[0] = static_cast<GLint>(blend_equation_alpha);
441 return true;
442 case GL_BLEND_SRC_RGB:
443 *num_written = 1;
444 if (params) {
445 params[0] = static_cast<GLint>(blend_source_rgb);
447 return true;
448 case GL_BLEND_DST_RGB:
449 *num_written = 1;
450 if (params) {
451 params[0] = static_cast<GLint>(blend_dest_rgb);
453 return true;
454 case GL_BLEND_SRC_ALPHA:
455 *num_written = 1;
456 if (params) {
457 params[0] = static_cast<GLint>(blend_source_alpha);
459 return true;
460 case GL_BLEND_DST_ALPHA:
461 *num_written = 1;
462 if (params) {
463 params[0] = static_cast<GLint>(blend_dest_alpha);
465 return true;
466 case GL_COLOR_CLEAR_VALUE:
467 *num_written = 4;
468 if (params) {
469 params[0] = static_cast<GLint>(color_clear_red);
470 params[1] = static_cast<GLint>(color_clear_green);
471 params[2] = static_cast<GLint>(color_clear_blue);
472 params[3] = static_cast<GLint>(color_clear_alpha);
474 return true;
475 case GL_DEPTH_CLEAR_VALUE:
476 *num_written = 1;
477 if (params) {
478 params[0] = static_cast<GLint>(depth_clear);
480 return true;
481 case GL_STENCIL_CLEAR_VALUE:
482 *num_written = 1;
483 if (params) {
484 params[0] = static_cast<GLint>(stencil_clear);
486 return true;
487 case GL_COLOR_WRITEMASK:
488 *num_written = 4;
489 if (params) {
490 params[0] = static_cast<GLint>(color_mask_red);
491 params[1] = static_cast<GLint>(color_mask_green);
492 params[2] = static_cast<GLint>(color_mask_blue);
493 params[3] = static_cast<GLint>(color_mask_alpha);
495 return true;
496 case GL_CULL_FACE_MODE:
497 *num_written = 1;
498 if (params) {
499 params[0] = static_cast<GLint>(cull_mode);
501 return true;
502 case GL_DEPTH_FUNC:
503 *num_written = 1;
504 if (params) {
505 params[0] = static_cast<GLint>(depth_func);
507 return true;
508 case GL_DEPTH_WRITEMASK:
509 *num_written = 1;
510 if (params) {
511 params[0] = static_cast<GLint>(depth_mask);
513 return true;
514 case GL_DEPTH_RANGE:
515 *num_written = 2;
516 if (params) {
517 params[0] = static_cast<GLint>(z_near);
518 params[1] = static_cast<GLint>(z_far);
520 return true;
521 case GL_FRONT_FACE:
522 *num_written = 1;
523 if (params) {
524 params[0] = static_cast<GLint>(front_face);
526 return true;
527 case GL_GENERATE_MIPMAP_HINT:
528 *num_written = 1;
529 if (params) {
530 params[0] = static_cast<GLint>(hint_generate_mipmap);
532 return true;
533 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
534 *num_written = 1;
535 if (params) {
536 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
538 return true;
539 case GL_LINE_WIDTH:
540 *num_written = 1;
541 if (params) {
542 params[0] = static_cast<GLint>(line_width);
544 return true;
545 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
546 *num_written = 16;
547 if (params) {
548 for (size_t i = 0; i < 16; ++i) {
549 params[i] = static_cast<GLint>(round(modelview_matrix[i]));
552 return true;
553 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
554 *num_written = 16;
555 if (params) {
556 for (size_t i = 0; i < 16; ++i) {
557 params[i] = static_cast<GLint>(round(projection_matrix[i]));
560 return true;
561 case GL_PATH_STENCIL_FUNC_CHROMIUM:
562 *num_written = 1;
563 if (params) {
564 params[0] = static_cast<GLint>(stencil_path_func);
566 return true;
567 case GL_PATH_STENCIL_REF_CHROMIUM:
568 *num_written = 1;
569 if (params) {
570 params[0] = static_cast<GLint>(stencil_path_ref);
572 return true;
573 case GL_PATH_STENCIL_VALUE_MASK_CHROMIUM:
574 *num_written = 1;
575 if (params) {
576 params[0] = static_cast<GLint>(stencil_path_mask);
578 return true;
579 case GL_PACK_ALIGNMENT:
580 *num_written = 1;
581 if (params) {
582 params[0] = static_cast<GLint>(pack_alignment);
584 return true;
585 case GL_UNPACK_ALIGNMENT:
586 *num_written = 1;
587 if (params) {
588 params[0] = static_cast<GLint>(unpack_alignment);
590 return true;
591 case GL_POLYGON_OFFSET_FACTOR:
592 *num_written = 1;
593 if (params) {
594 params[0] = static_cast<GLint>(round(polygon_offset_factor));
596 return true;
597 case GL_POLYGON_OFFSET_UNITS:
598 *num_written = 1;
599 if (params) {
600 params[0] = static_cast<GLint>(round(polygon_offset_units));
602 return true;
603 case GL_SAMPLE_COVERAGE_VALUE:
604 *num_written = 1;
605 if (params) {
606 params[0] = static_cast<GLint>(sample_coverage_value);
608 return true;
609 case GL_SAMPLE_COVERAGE_INVERT:
610 *num_written = 1;
611 if (params) {
612 params[0] = static_cast<GLint>(sample_coverage_invert);
614 return true;
615 case GL_SCISSOR_BOX:
616 *num_written = 4;
617 if (params) {
618 params[0] = static_cast<GLint>(scissor_x);
619 params[1] = static_cast<GLint>(scissor_y);
620 params[2] = static_cast<GLint>(scissor_width);
621 params[3] = static_cast<GLint>(scissor_height);
623 return true;
624 case GL_STENCIL_FUNC:
625 *num_written = 1;
626 if (params) {
627 params[0] = static_cast<GLint>(stencil_front_func);
629 return true;
630 case GL_STENCIL_REF:
631 *num_written = 1;
632 if (params) {
633 params[0] = static_cast<GLint>(stencil_front_ref);
635 return true;
636 case GL_STENCIL_VALUE_MASK:
637 *num_written = 1;
638 if (params) {
639 params[0] = static_cast<GLint>(stencil_front_mask);
641 return true;
642 case GL_STENCIL_BACK_FUNC:
643 *num_written = 1;
644 if (params) {
645 params[0] = static_cast<GLint>(stencil_back_func);
647 return true;
648 case GL_STENCIL_BACK_REF:
649 *num_written = 1;
650 if (params) {
651 params[0] = static_cast<GLint>(stencil_back_ref);
653 return true;
654 case GL_STENCIL_BACK_VALUE_MASK:
655 *num_written = 1;
656 if (params) {
657 params[0] = static_cast<GLint>(stencil_back_mask);
659 return true;
660 case GL_STENCIL_WRITEMASK:
661 *num_written = 1;
662 if (params) {
663 params[0] = static_cast<GLint>(stencil_front_writemask);
665 return true;
666 case GL_STENCIL_BACK_WRITEMASK:
667 *num_written = 1;
668 if (params) {
669 params[0] = static_cast<GLint>(stencil_back_writemask);
671 return true;
672 case GL_STENCIL_FAIL:
673 *num_written = 1;
674 if (params) {
675 params[0] = static_cast<GLint>(stencil_front_fail_op);
677 return true;
678 case GL_STENCIL_PASS_DEPTH_FAIL:
679 *num_written = 1;
680 if (params) {
681 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
683 return true;
684 case GL_STENCIL_PASS_DEPTH_PASS:
685 *num_written = 1;
686 if (params) {
687 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
689 return true;
690 case GL_STENCIL_BACK_FAIL:
691 *num_written = 1;
692 if (params) {
693 params[0] = static_cast<GLint>(stencil_back_fail_op);
695 return true;
696 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
697 *num_written = 1;
698 if (params) {
699 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
701 return true;
702 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
703 *num_written = 1;
704 if (params) {
705 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
707 return true;
708 case GL_VIEWPORT:
709 *num_written = 4;
710 if (params) {
711 params[0] = static_cast<GLint>(viewport_x);
712 params[1] = static_cast<GLint>(viewport_y);
713 params[2] = static_cast<GLint>(viewport_width);
714 params[3] = static_cast<GLint>(viewport_height);
716 return true;
717 case GL_BLEND:
718 *num_written = 1;
719 if (params) {
720 params[0] = static_cast<GLint>(enable_flags.blend);
722 return true;
723 case GL_CULL_FACE:
724 *num_written = 1;
725 if (params) {
726 params[0] = static_cast<GLint>(enable_flags.cull_face);
728 return true;
729 case GL_DEPTH_TEST:
730 *num_written = 1;
731 if (params) {
732 params[0] = static_cast<GLint>(enable_flags.depth_test);
734 return true;
735 case GL_DITHER:
736 *num_written = 1;
737 if (params) {
738 params[0] = static_cast<GLint>(enable_flags.dither);
740 return true;
741 case GL_POLYGON_OFFSET_FILL:
742 *num_written = 1;
743 if (params) {
744 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
746 return true;
747 case GL_SAMPLE_ALPHA_TO_COVERAGE:
748 *num_written = 1;
749 if (params) {
750 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
752 return true;
753 case GL_SAMPLE_COVERAGE:
754 *num_written = 1;
755 if (params) {
756 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
758 return true;
759 case GL_SCISSOR_TEST:
760 *num_written = 1;
761 if (params) {
762 params[0] = static_cast<GLint>(enable_flags.scissor_test);
764 return true;
765 case GL_STENCIL_TEST:
766 *num_written = 1;
767 if (params) {
768 params[0] = static_cast<GLint>(enable_flags.stencil_test);
770 return true;
771 case GL_RASTERIZER_DISCARD:
772 *num_written = 1;
773 if (params) {
774 params[0] = static_cast<GLint>(enable_flags.rasterizer_discard);
776 return true;
777 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
778 *num_written = 1;
779 if (params) {
780 params[0] =
781 static_cast<GLint>(enable_flags.primitive_restart_fixed_index);
783 return true;
784 default:
785 return false;
789 bool ContextState::GetStateAsGLfloat(GLenum pname,
790 GLfloat* params,
791 GLsizei* num_written) const {
792 switch (pname) {
793 case GL_BLEND_COLOR:
794 *num_written = 4;
795 if (params) {
796 params[0] = static_cast<GLfloat>(blend_color_red);
797 params[1] = static_cast<GLfloat>(blend_color_green);
798 params[2] = static_cast<GLfloat>(blend_color_blue);
799 params[3] = static_cast<GLfloat>(blend_color_alpha);
801 return true;
802 case GL_BLEND_EQUATION_RGB:
803 *num_written = 1;
804 if (params) {
805 params[0] = static_cast<GLfloat>(blend_equation_rgb);
807 return true;
808 case GL_BLEND_EQUATION_ALPHA:
809 *num_written = 1;
810 if (params) {
811 params[0] = static_cast<GLfloat>(blend_equation_alpha);
813 return true;
814 case GL_BLEND_SRC_RGB:
815 *num_written = 1;
816 if (params) {
817 params[0] = static_cast<GLfloat>(blend_source_rgb);
819 return true;
820 case GL_BLEND_DST_RGB:
821 *num_written = 1;
822 if (params) {
823 params[0] = static_cast<GLfloat>(blend_dest_rgb);
825 return true;
826 case GL_BLEND_SRC_ALPHA:
827 *num_written = 1;
828 if (params) {
829 params[0] = static_cast<GLfloat>(blend_source_alpha);
831 return true;
832 case GL_BLEND_DST_ALPHA:
833 *num_written = 1;
834 if (params) {
835 params[0] = static_cast<GLfloat>(blend_dest_alpha);
837 return true;
838 case GL_COLOR_CLEAR_VALUE:
839 *num_written = 4;
840 if (params) {
841 params[0] = static_cast<GLfloat>(color_clear_red);
842 params[1] = static_cast<GLfloat>(color_clear_green);
843 params[2] = static_cast<GLfloat>(color_clear_blue);
844 params[3] = static_cast<GLfloat>(color_clear_alpha);
846 return true;
847 case GL_DEPTH_CLEAR_VALUE:
848 *num_written = 1;
849 if (params) {
850 params[0] = static_cast<GLfloat>(depth_clear);
852 return true;
853 case GL_STENCIL_CLEAR_VALUE:
854 *num_written = 1;
855 if (params) {
856 params[0] = static_cast<GLfloat>(stencil_clear);
858 return true;
859 case GL_COLOR_WRITEMASK:
860 *num_written = 4;
861 if (params) {
862 params[0] = static_cast<GLfloat>(color_mask_red);
863 params[1] = static_cast<GLfloat>(color_mask_green);
864 params[2] = static_cast<GLfloat>(color_mask_blue);
865 params[3] = static_cast<GLfloat>(color_mask_alpha);
867 return true;
868 case GL_CULL_FACE_MODE:
869 *num_written = 1;
870 if (params) {
871 params[0] = static_cast<GLfloat>(cull_mode);
873 return true;
874 case GL_DEPTH_FUNC:
875 *num_written = 1;
876 if (params) {
877 params[0] = static_cast<GLfloat>(depth_func);
879 return true;
880 case GL_DEPTH_WRITEMASK:
881 *num_written = 1;
882 if (params) {
883 params[0] = static_cast<GLfloat>(depth_mask);
885 return true;
886 case GL_DEPTH_RANGE:
887 *num_written = 2;
888 if (params) {
889 params[0] = static_cast<GLfloat>(z_near);
890 params[1] = static_cast<GLfloat>(z_far);
892 return true;
893 case GL_FRONT_FACE:
894 *num_written = 1;
895 if (params) {
896 params[0] = static_cast<GLfloat>(front_face);
898 return true;
899 case GL_GENERATE_MIPMAP_HINT:
900 *num_written = 1;
901 if (params) {
902 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
904 return true;
905 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
906 *num_written = 1;
907 if (params) {
908 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
910 return true;
911 case GL_LINE_WIDTH:
912 *num_written = 1;
913 if (params) {
914 params[0] = static_cast<GLfloat>(line_width);
916 return true;
917 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
918 *num_written = 16;
919 if (params) {
920 memcpy(params, modelview_matrix, sizeof(GLfloat) * 16);
922 return true;
923 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
924 *num_written = 16;
925 if (params) {
926 memcpy(params, projection_matrix, sizeof(GLfloat) * 16);
928 return true;
929 case GL_PATH_STENCIL_FUNC_CHROMIUM:
930 *num_written = 1;
931 if (params) {
932 params[0] = static_cast<GLfloat>(stencil_path_func);
934 return true;
935 case GL_PATH_STENCIL_REF_CHROMIUM:
936 *num_written = 1;
937 if (params) {
938 params[0] = static_cast<GLfloat>(stencil_path_ref);
940 return true;
941 case GL_PATH_STENCIL_VALUE_MASK_CHROMIUM:
942 *num_written = 1;
943 if (params) {
944 params[0] = static_cast<GLfloat>(stencil_path_mask);
946 return true;
947 case GL_PACK_ALIGNMENT:
948 *num_written = 1;
949 if (params) {
950 params[0] = static_cast<GLfloat>(pack_alignment);
952 return true;
953 case GL_UNPACK_ALIGNMENT:
954 *num_written = 1;
955 if (params) {
956 params[0] = static_cast<GLfloat>(unpack_alignment);
958 return true;
959 case GL_POLYGON_OFFSET_FACTOR:
960 *num_written = 1;
961 if (params) {
962 params[0] = static_cast<GLfloat>(polygon_offset_factor);
964 return true;
965 case GL_POLYGON_OFFSET_UNITS:
966 *num_written = 1;
967 if (params) {
968 params[0] = static_cast<GLfloat>(polygon_offset_units);
970 return true;
971 case GL_SAMPLE_COVERAGE_VALUE:
972 *num_written = 1;
973 if (params) {
974 params[0] = static_cast<GLfloat>(sample_coverage_value);
976 return true;
977 case GL_SAMPLE_COVERAGE_INVERT:
978 *num_written = 1;
979 if (params) {
980 params[0] = static_cast<GLfloat>(sample_coverage_invert);
982 return true;
983 case GL_SCISSOR_BOX:
984 *num_written = 4;
985 if (params) {
986 params[0] = static_cast<GLfloat>(scissor_x);
987 params[1] = static_cast<GLfloat>(scissor_y);
988 params[2] = static_cast<GLfloat>(scissor_width);
989 params[3] = static_cast<GLfloat>(scissor_height);
991 return true;
992 case GL_STENCIL_FUNC:
993 *num_written = 1;
994 if (params) {
995 params[0] = static_cast<GLfloat>(stencil_front_func);
997 return true;
998 case GL_STENCIL_REF:
999 *num_written = 1;
1000 if (params) {
1001 params[0] = static_cast<GLfloat>(stencil_front_ref);
1003 return true;
1004 case GL_STENCIL_VALUE_MASK:
1005 *num_written = 1;
1006 if (params) {
1007 params[0] = static_cast<GLfloat>(stencil_front_mask);
1009 return true;
1010 case GL_STENCIL_BACK_FUNC:
1011 *num_written = 1;
1012 if (params) {
1013 params[0] = static_cast<GLfloat>(stencil_back_func);
1015 return true;
1016 case GL_STENCIL_BACK_REF:
1017 *num_written = 1;
1018 if (params) {
1019 params[0] = static_cast<GLfloat>(stencil_back_ref);
1021 return true;
1022 case GL_STENCIL_BACK_VALUE_MASK:
1023 *num_written = 1;
1024 if (params) {
1025 params[0] = static_cast<GLfloat>(stencil_back_mask);
1027 return true;
1028 case GL_STENCIL_WRITEMASK:
1029 *num_written = 1;
1030 if (params) {
1031 params[0] = static_cast<GLfloat>(stencil_front_writemask);
1033 return true;
1034 case GL_STENCIL_BACK_WRITEMASK:
1035 *num_written = 1;
1036 if (params) {
1037 params[0] = static_cast<GLfloat>(stencil_back_writemask);
1039 return true;
1040 case GL_STENCIL_FAIL:
1041 *num_written = 1;
1042 if (params) {
1043 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
1045 return true;
1046 case GL_STENCIL_PASS_DEPTH_FAIL:
1047 *num_written = 1;
1048 if (params) {
1049 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
1051 return true;
1052 case GL_STENCIL_PASS_DEPTH_PASS:
1053 *num_written = 1;
1054 if (params) {
1055 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
1057 return true;
1058 case GL_STENCIL_BACK_FAIL:
1059 *num_written = 1;
1060 if (params) {
1061 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
1063 return true;
1064 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1065 *num_written = 1;
1066 if (params) {
1067 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
1069 return true;
1070 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1071 *num_written = 1;
1072 if (params) {
1073 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
1075 return true;
1076 case GL_VIEWPORT:
1077 *num_written = 4;
1078 if (params) {
1079 params[0] = static_cast<GLfloat>(viewport_x);
1080 params[1] = static_cast<GLfloat>(viewport_y);
1081 params[2] = static_cast<GLfloat>(viewport_width);
1082 params[3] = static_cast<GLfloat>(viewport_height);
1084 return true;
1085 case GL_BLEND:
1086 *num_written = 1;
1087 if (params) {
1088 params[0] = static_cast<GLfloat>(enable_flags.blend);
1090 return true;
1091 case GL_CULL_FACE:
1092 *num_written = 1;
1093 if (params) {
1094 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
1096 return true;
1097 case GL_DEPTH_TEST:
1098 *num_written = 1;
1099 if (params) {
1100 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
1102 return true;
1103 case GL_DITHER:
1104 *num_written = 1;
1105 if (params) {
1106 params[0] = static_cast<GLfloat>(enable_flags.dither);
1108 return true;
1109 case GL_POLYGON_OFFSET_FILL:
1110 *num_written = 1;
1111 if (params) {
1112 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
1114 return true;
1115 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1116 *num_written = 1;
1117 if (params) {
1118 params[0] = static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
1120 return true;
1121 case GL_SAMPLE_COVERAGE:
1122 *num_written = 1;
1123 if (params) {
1124 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
1126 return true;
1127 case GL_SCISSOR_TEST:
1128 *num_written = 1;
1129 if (params) {
1130 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
1132 return true;
1133 case GL_STENCIL_TEST:
1134 *num_written = 1;
1135 if (params) {
1136 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
1138 return true;
1139 case GL_RASTERIZER_DISCARD:
1140 *num_written = 1;
1141 if (params) {
1142 params[0] = static_cast<GLfloat>(enable_flags.rasterizer_discard);
1144 return true;
1145 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
1146 *num_written = 1;
1147 if (params) {
1148 params[0] =
1149 static_cast<GLfloat>(enable_flags.primitive_restart_fixed_index);
1151 return true;
1152 default:
1153 return false;
1156 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_