Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / command_buffer / service / context_state_impl_autogen.h
blob2dde5304e4348031f28a5ca979c6b34acf0400b8
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) {
40 void ContextState::Initialize() {
41 blend_color_red = 0.0f;
42 blend_color_green = 0.0f;
43 blend_color_blue = 0.0f;
44 blend_color_alpha = 0.0f;
45 blend_equation_rgb = GL_FUNC_ADD;
46 blend_equation_alpha = GL_FUNC_ADD;
47 blend_source_rgb = GL_ONE;
48 blend_dest_rgb = GL_ZERO;
49 blend_source_alpha = GL_ONE;
50 blend_dest_alpha = GL_ZERO;
51 color_clear_red = 0.0f;
52 color_clear_green = 0.0f;
53 color_clear_blue = 0.0f;
54 color_clear_alpha = 0.0f;
55 depth_clear = 1.0f;
56 stencil_clear = 0;
57 color_mask_red = true;
58 cached_color_mask_red = true;
59 color_mask_green = true;
60 cached_color_mask_green = true;
61 color_mask_blue = true;
62 cached_color_mask_blue = true;
63 color_mask_alpha = true;
64 cached_color_mask_alpha = true;
65 cull_mode = GL_BACK;
66 depth_func = GL_LESS;
67 depth_mask = true;
68 cached_depth_mask = true;
69 z_near = 0.0f;
70 z_far = 1.0f;
71 front_face = GL_CCW;
72 hint_generate_mipmap = GL_DONT_CARE;
73 hint_fragment_shader_derivative = GL_DONT_CARE;
74 line_width = 1.0f;
75 modelview_matrix[0] = 1.0f;
76 modelview_matrix[1] = 0.0f;
77 modelview_matrix[2] = 0.0f;
78 modelview_matrix[3] = 0.0f;
79 modelview_matrix[4] = 0.0f;
80 modelview_matrix[5] = 1.0f;
81 modelview_matrix[6] = 0.0f;
82 modelview_matrix[7] = 0.0f;
83 modelview_matrix[8] = 0.0f;
84 modelview_matrix[9] = 0.0f;
85 modelview_matrix[10] = 1.0f;
86 modelview_matrix[11] = 0.0f;
87 modelview_matrix[12] = 0.0f;
88 modelview_matrix[13] = 0.0f;
89 modelview_matrix[14] = 0.0f;
90 modelview_matrix[15] = 1.0f;
91 projection_matrix[0] = 1.0f;
92 projection_matrix[1] = 0.0f;
93 projection_matrix[2] = 0.0f;
94 projection_matrix[3] = 0.0f;
95 projection_matrix[4] = 0.0f;
96 projection_matrix[5] = 1.0f;
97 projection_matrix[6] = 0.0f;
98 projection_matrix[7] = 0.0f;
99 projection_matrix[8] = 0.0f;
100 projection_matrix[9] = 0.0f;
101 projection_matrix[10] = 1.0f;
102 projection_matrix[11] = 0.0f;
103 projection_matrix[12] = 0.0f;
104 projection_matrix[13] = 0.0f;
105 projection_matrix[14] = 0.0f;
106 projection_matrix[15] = 1.0f;
107 stencil_path_func = GL_ALWAYS;
108 stencil_path_ref = 0;
109 stencil_path_mask = 0xFFFFFFFFU;
110 pack_alignment = 4;
111 unpack_alignment = 4;
112 polygon_offset_factor = 0.0f;
113 polygon_offset_units = 0.0f;
114 sample_coverage_value = 1.0f;
115 sample_coverage_invert = false;
116 scissor_x = 0;
117 scissor_y = 0;
118 scissor_width = 1;
119 scissor_height = 1;
120 stencil_front_func = GL_ALWAYS;
121 stencil_front_ref = 0;
122 stencil_front_mask = 0xFFFFFFFFU;
123 stencil_back_func = GL_ALWAYS;
124 stencil_back_ref = 0;
125 stencil_back_mask = 0xFFFFFFFFU;
126 stencil_front_writemask = 0xFFFFFFFFU;
127 cached_stencil_front_writemask = 0xFFFFFFFFU;
128 stencil_back_writemask = 0xFFFFFFFFU;
129 cached_stencil_back_writemask = 0xFFFFFFFFU;
130 stencil_front_fail_op = GL_KEEP;
131 stencil_front_z_fail_op = GL_KEEP;
132 stencil_front_z_pass_op = GL_KEEP;
133 stencil_back_fail_op = GL_KEEP;
134 stencil_back_z_fail_op = GL_KEEP;
135 stencil_back_z_pass_op = GL_KEEP;
136 viewport_x = 0;
137 viewport_y = 0;
138 viewport_width = 1;
139 viewport_height = 1;
142 void ContextState::InitCapabilities(const ContextState* prev_state) const {
143 if (prev_state) {
144 if (prev_state->enable_flags.cached_blend != enable_flags.cached_blend) {
145 EnableDisable(GL_BLEND, enable_flags.cached_blend);
147 if (prev_state->enable_flags.cached_cull_face !=
148 enable_flags.cached_cull_face) {
149 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
151 if (prev_state->enable_flags.cached_depth_test !=
152 enable_flags.cached_depth_test) {
153 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
155 if (prev_state->enable_flags.cached_dither != enable_flags.cached_dither) {
156 EnableDisable(GL_DITHER, enable_flags.cached_dither);
158 if (prev_state->enable_flags.cached_polygon_offset_fill !=
159 enable_flags.cached_polygon_offset_fill) {
160 EnableDisable(GL_POLYGON_OFFSET_FILL,
161 enable_flags.cached_polygon_offset_fill);
163 if (prev_state->enable_flags.cached_sample_alpha_to_coverage !=
164 enable_flags.cached_sample_alpha_to_coverage) {
165 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
166 enable_flags.cached_sample_alpha_to_coverage);
168 if (prev_state->enable_flags.cached_sample_coverage !=
169 enable_flags.cached_sample_coverage) {
170 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
172 if (prev_state->enable_flags.cached_scissor_test !=
173 enable_flags.cached_scissor_test) {
174 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
176 if (prev_state->enable_flags.cached_stencil_test !=
177 enable_flags.cached_stencil_test) {
178 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
180 if (feature_info_->IsES3Capable()) {
181 if (prev_state->enable_flags.cached_rasterizer_discard !=
182 enable_flags.cached_rasterizer_discard) {
183 EnableDisable(GL_RASTERIZER_DISCARD,
184 enable_flags.cached_rasterizer_discard);
186 if (prev_state->enable_flags.cached_primitive_restart_fixed_index !=
187 enable_flags.cached_primitive_restart_fixed_index) {
188 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
189 enable_flags.cached_primitive_restart_fixed_index);
192 } else {
193 EnableDisable(GL_BLEND, enable_flags.cached_blend);
194 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
195 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
196 EnableDisable(GL_DITHER, enable_flags.cached_dither);
197 EnableDisable(GL_POLYGON_OFFSET_FILL,
198 enable_flags.cached_polygon_offset_fill);
199 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
200 enable_flags.cached_sample_alpha_to_coverage);
201 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
202 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
203 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
204 if (feature_info_->IsES3Capable()) {
205 EnableDisable(GL_RASTERIZER_DISCARD,
206 enable_flags.cached_rasterizer_discard);
207 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
208 enable_flags.cached_primitive_restart_fixed_index);
213 void ContextState::InitState(const ContextState* prev_state) const {
214 if (prev_state) {
215 if ((blend_color_red != prev_state->blend_color_red) ||
216 (blend_color_green != prev_state->blend_color_green) ||
217 (blend_color_blue != prev_state->blend_color_blue) ||
218 (blend_color_alpha != prev_state->blend_color_alpha))
219 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
220 blend_color_alpha);
221 if ((blend_equation_rgb != prev_state->blend_equation_rgb) ||
222 (blend_equation_alpha != prev_state->blend_equation_alpha))
223 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
224 if ((blend_source_rgb != prev_state->blend_source_rgb) ||
225 (blend_dest_rgb != prev_state->blend_dest_rgb) ||
226 (blend_source_alpha != prev_state->blend_source_alpha) ||
227 (blend_dest_alpha != prev_state->blend_dest_alpha))
228 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
229 blend_dest_alpha);
230 if ((color_clear_red != prev_state->color_clear_red) ||
231 (color_clear_green != prev_state->color_clear_green) ||
232 (color_clear_blue != prev_state->color_clear_blue) ||
233 (color_clear_alpha != prev_state->color_clear_alpha))
234 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
235 color_clear_alpha);
236 if ((depth_clear != prev_state->depth_clear))
237 glClearDepth(depth_clear);
238 if ((stencil_clear != prev_state->stencil_clear))
239 glClearStencil(stencil_clear);
240 if ((cached_color_mask_red != prev_state->cached_color_mask_red) ||
241 (cached_color_mask_green != prev_state->cached_color_mask_green) ||
242 (cached_color_mask_blue != prev_state->cached_color_mask_blue) ||
243 (cached_color_mask_alpha != prev_state->cached_color_mask_alpha))
244 glColorMask(cached_color_mask_red, cached_color_mask_green,
245 cached_color_mask_blue, cached_color_mask_alpha);
246 if ((cull_mode != prev_state->cull_mode))
247 glCullFace(cull_mode);
248 if ((depth_func != prev_state->depth_func))
249 glDepthFunc(depth_func);
250 if ((cached_depth_mask != prev_state->cached_depth_mask))
251 glDepthMask(cached_depth_mask);
252 if ((z_near != prev_state->z_near) || (z_far != prev_state->z_far))
253 glDepthRange(z_near, z_far);
254 if ((front_face != prev_state->front_face))
255 glFrontFace(front_face);
256 if (prev_state->hint_generate_mipmap != hint_generate_mipmap) {
257 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
258 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
261 if (feature_info_->feature_flags().oes_standard_derivatives) {
262 if (prev_state->hint_fragment_shader_derivative !=
263 hint_fragment_shader_derivative) {
264 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
265 hint_fragment_shader_derivative);
268 if ((line_width != prev_state->line_width))
269 glLineWidth(line_width);
270 if (feature_info_->feature_flags().chromium_path_rendering) {
271 if (memcmp(prev_state->modelview_matrix, modelview_matrix,
272 sizeof(GLfloat) * 16)) {
273 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
276 if (feature_info_->feature_flags().chromium_path_rendering) {
277 if (memcmp(prev_state->projection_matrix, projection_matrix,
278 sizeof(GLfloat) * 16)) {
279 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
282 if (feature_info_->feature_flags().chromium_path_rendering)
283 if ((stencil_path_func != prev_state->stencil_path_func) ||
284 (stencil_path_ref != prev_state->stencil_path_ref) ||
285 (stencil_path_mask != prev_state->stencil_path_mask))
286 glPathStencilFuncNV(stencil_path_func, stencil_path_ref,
287 stencil_path_mask);
288 if (prev_state->pack_alignment != pack_alignment) {
289 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
291 if (prev_state->unpack_alignment != unpack_alignment) {
292 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
294 if ((polygon_offset_factor != prev_state->polygon_offset_factor) ||
295 (polygon_offset_units != prev_state->polygon_offset_units))
296 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
297 if ((sample_coverage_value != prev_state->sample_coverage_value) ||
298 (sample_coverage_invert != prev_state->sample_coverage_invert))
299 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
300 if ((scissor_x != prev_state->scissor_x) ||
301 (scissor_y != prev_state->scissor_y) ||
302 (scissor_width != prev_state->scissor_width) ||
303 (scissor_height != prev_state->scissor_height))
304 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
305 if ((stencil_front_func != prev_state->stencil_front_func) ||
306 (stencil_front_ref != prev_state->stencil_front_ref) ||
307 (stencil_front_mask != prev_state->stencil_front_mask))
308 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
309 stencil_front_mask);
310 if ((stencil_back_func != prev_state->stencil_back_func) ||
311 (stencil_back_ref != prev_state->stencil_back_ref) ||
312 (stencil_back_mask != prev_state->stencil_back_mask))
313 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
314 stencil_back_mask);
315 if ((cached_stencil_front_writemask !=
316 prev_state->cached_stencil_front_writemask))
317 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
318 if ((cached_stencil_back_writemask !=
319 prev_state->cached_stencil_back_writemask))
320 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
321 if ((stencil_front_fail_op != prev_state->stencil_front_fail_op) ||
322 (stencil_front_z_fail_op != prev_state->stencil_front_z_fail_op) ||
323 (stencil_front_z_pass_op != prev_state->stencil_front_z_pass_op))
324 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
325 stencil_front_z_fail_op, stencil_front_z_pass_op);
326 if ((stencil_back_fail_op != prev_state->stencil_back_fail_op) ||
327 (stencil_back_z_fail_op != prev_state->stencil_back_z_fail_op) ||
328 (stencil_back_z_pass_op != prev_state->stencil_back_z_pass_op))
329 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
330 stencil_back_z_pass_op);
331 if ((viewport_x != prev_state->viewport_x) ||
332 (viewport_y != prev_state->viewport_y) ||
333 (viewport_width != prev_state->viewport_width) ||
334 (viewport_height != prev_state->viewport_height))
335 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
336 } else {
337 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
338 blend_color_alpha);
339 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
340 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
341 blend_dest_alpha);
342 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
343 color_clear_alpha);
344 glClearDepth(depth_clear);
345 glClearStencil(stencil_clear);
346 glColorMask(cached_color_mask_red, cached_color_mask_green,
347 cached_color_mask_blue, cached_color_mask_alpha);
348 glCullFace(cull_mode);
349 glDepthFunc(depth_func);
350 glDepthMask(cached_depth_mask);
351 glDepthRange(z_near, z_far);
352 glFrontFace(front_face);
353 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
354 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
356 if (feature_info_->feature_flags().oes_standard_derivatives) {
357 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
358 hint_fragment_shader_derivative);
360 glLineWidth(line_width);
361 if (feature_info_->feature_flags().chromium_path_rendering) {
362 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
364 if (feature_info_->feature_flags().chromium_path_rendering) {
365 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
367 if (feature_info_->feature_flags().chromium_path_rendering)
368 glPathStencilFuncNV(stencil_path_func, stencil_path_ref,
369 stencil_path_mask);
370 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
371 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
372 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
373 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
374 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
375 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
376 stencil_front_mask);
377 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
378 stencil_back_mask);
379 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
380 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
381 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
382 stencil_front_z_fail_op, stencil_front_z_pass_op);
383 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
384 stencil_back_z_pass_op);
385 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
388 bool ContextState::GetEnabled(GLenum cap) const {
389 switch (cap) {
390 case GL_BLEND:
391 return enable_flags.blend;
392 case GL_CULL_FACE:
393 return enable_flags.cull_face;
394 case GL_DEPTH_TEST:
395 return enable_flags.depth_test;
396 case GL_DITHER:
397 return enable_flags.dither;
398 case GL_POLYGON_OFFSET_FILL:
399 return enable_flags.polygon_offset_fill;
400 case GL_SAMPLE_ALPHA_TO_COVERAGE:
401 return enable_flags.sample_alpha_to_coverage;
402 case GL_SAMPLE_COVERAGE:
403 return enable_flags.sample_coverage;
404 case GL_SCISSOR_TEST:
405 return enable_flags.scissor_test;
406 case GL_STENCIL_TEST:
407 return enable_flags.stencil_test;
408 case GL_RASTERIZER_DISCARD:
409 return enable_flags.rasterizer_discard;
410 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
411 return enable_flags.primitive_restart_fixed_index;
412 default:
413 NOTREACHED();
414 return false;
418 bool ContextState::GetStateAsGLint(GLenum pname,
419 GLint* params,
420 GLsizei* num_written) const {
421 switch (pname) {
422 case GL_BLEND_COLOR:
423 *num_written = 4;
424 if (params) {
425 params[0] = static_cast<GLint>(blend_color_red);
426 params[1] = static_cast<GLint>(blend_color_green);
427 params[2] = static_cast<GLint>(blend_color_blue);
428 params[3] = static_cast<GLint>(blend_color_alpha);
430 return true;
431 case GL_BLEND_EQUATION_RGB:
432 *num_written = 1;
433 if (params) {
434 params[0] = static_cast<GLint>(blend_equation_rgb);
436 return true;
437 case GL_BLEND_EQUATION_ALPHA:
438 *num_written = 1;
439 if (params) {
440 params[0] = static_cast<GLint>(blend_equation_alpha);
442 return true;
443 case GL_BLEND_SRC_RGB:
444 *num_written = 1;
445 if (params) {
446 params[0] = static_cast<GLint>(blend_source_rgb);
448 return true;
449 case GL_BLEND_DST_RGB:
450 *num_written = 1;
451 if (params) {
452 params[0] = static_cast<GLint>(blend_dest_rgb);
454 return true;
455 case GL_BLEND_SRC_ALPHA:
456 *num_written = 1;
457 if (params) {
458 params[0] = static_cast<GLint>(blend_source_alpha);
460 return true;
461 case GL_BLEND_DST_ALPHA:
462 *num_written = 1;
463 if (params) {
464 params[0] = static_cast<GLint>(blend_dest_alpha);
466 return true;
467 case GL_COLOR_CLEAR_VALUE:
468 *num_written = 4;
469 if (params) {
470 params[0] = static_cast<GLint>(color_clear_red);
471 params[1] = static_cast<GLint>(color_clear_green);
472 params[2] = static_cast<GLint>(color_clear_blue);
473 params[3] = static_cast<GLint>(color_clear_alpha);
475 return true;
476 case GL_DEPTH_CLEAR_VALUE:
477 *num_written = 1;
478 if (params) {
479 params[0] = static_cast<GLint>(depth_clear);
481 return true;
482 case GL_STENCIL_CLEAR_VALUE:
483 *num_written = 1;
484 if (params) {
485 params[0] = static_cast<GLint>(stencil_clear);
487 return true;
488 case GL_COLOR_WRITEMASK:
489 *num_written = 4;
490 if (params) {
491 params[0] = static_cast<GLint>(color_mask_red);
492 params[1] = static_cast<GLint>(color_mask_green);
493 params[2] = static_cast<GLint>(color_mask_blue);
494 params[3] = static_cast<GLint>(color_mask_alpha);
496 return true;
497 case GL_CULL_FACE_MODE:
498 *num_written = 1;
499 if (params) {
500 params[0] = static_cast<GLint>(cull_mode);
502 return true;
503 case GL_DEPTH_FUNC:
504 *num_written = 1;
505 if (params) {
506 params[0] = static_cast<GLint>(depth_func);
508 return true;
509 case GL_DEPTH_WRITEMASK:
510 *num_written = 1;
511 if (params) {
512 params[0] = static_cast<GLint>(depth_mask);
514 return true;
515 case GL_DEPTH_RANGE:
516 *num_written = 2;
517 if (params) {
518 params[0] = static_cast<GLint>(z_near);
519 params[1] = static_cast<GLint>(z_far);
521 return true;
522 case GL_FRONT_FACE:
523 *num_written = 1;
524 if (params) {
525 params[0] = static_cast<GLint>(front_face);
527 return true;
528 case GL_GENERATE_MIPMAP_HINT:
529 *num_written = 1;
530 if (params) {
531 params[0] = static_cast<GLint>(hint_generate_mipmap);
533 return true;
534 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
535 *num_written = 1;
536 if (params) {
537 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
539 return true;
540 case GL_LINE_WIDTH:
541 *num_written = 1;
542 if (params) {
543 params[0] = static_cast<GLint>(line_width);
545 return true;
546 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
547 *num_written = 16;
548 if (params) {
549 for (size_t i = 0; i < 16; ++i) {
550 params[i] = static_cast<GLint>(round(modelview_matrix[i]));
553 return true;
554 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
555 *num_written = 16;
556 if (params) {
557 for (size_t i = 0; i < 16; ++i) {
558 params[i] = static_cast<GLint>(round(projection_matrix[i]));
561 return true;
562 case GL_PATH_STENCIL_FUNC_CHROMIUM:
563 *num_written = 1;
564 if (params) {
565 params[0] = static_cast<GLint>(stencil_path_func);
567 return true;
568 case GL_PATH_STENCIL_REF_CHROMIUM:
569 *num_written = 1;
570 if (params) {
571 params[0] = static_cast<GLint>(stencil_path_ref);
573 return true;
574 case GL_PATH_STENCIL_VALUE_MASK_CHROMIUM:
575 *num_written = 1;
576 if (params) {
577 params[0] = static_cast<GLint>(stencil_path_mask);
579 return true;
580 case GL_PACK_ALIGNMENT:
581 *num_written = 1;
582 if (params) {
583 params[0] = static_cast<GLint>(pack_alignment);
585 return true;
586 case GL_UNPACK_ALIGNMENT:
587 *num_written = 1;
588 if (params) {
589 params[0] = static_cast<GLint>(unpack_alignment);
591 return true;
592 case GL_POLYGON_OFFSET_FACTOR:
593 *num_written = 1;
594 if (params) {
595 params[0] = static_cast<GLint>(round(polygon_offset_factor));
597 return true;
598 case GL_POLYGON_OFFSET_UNITS:
599 *num_written = 1;
600 if (params) {
601 params[0] = static_cast<GLint>(round(polygon_offset_units));
603 return true;
604 case GL_SAMPLE_COVERAGE_VALUE:
605 *num_written = 1;
606 if (params) {
607 params[0] = static_cast<GLint>(sample_coverage_value);
609 return true;
610 case GL_SAMPLE_COVERAGE_INVERT:
611 *num_written = 1;
612 if (params) {
613 params[0] = static_cast<GLint>(sample_coverage_invert);
615 return true;
616 case GL_SCISSOR_BOX:
617 *num_written = 4;
618 if (params) {
619 params[0] = static_cast<GLint>(scissor_x);
620 params[1] = static_cast<GLint>(scissor_y);
621 params[2] = static_cast<GLint>(scissor_width);
622 params[3] = static_cast<GLint>(scissor_height);
624 return true;
625 case GL_STENCIL_FUNC:
626 *num_written = 1;
627 if (params) {
628 params[0] = static_cast<GLint>(stencil_front_func);
630 return true;
631 case GL_STENCIL_REF:
632 *num_written = 1;
633 if (params) {
634 params[0] = static_cast<GLint>(stencil_front_ref);
636 return true;
637 case GL_STENCIL_VALUE_MASK:
638 *num_written = 1;
639 if (params) {
640 params[0] = static_cast<GLint>(stencil_front_mask);
642 return true;
643 case GL_STENCIL_BACK_FUNC:
644 *num_written = 1;
645 if (params) {
646 params[0] = static_cast<GLint>(stencil_back_func);
648 return true;
649 case GL_STENCIL_BACK_REF:
650 *num_written = 1;
651 if (params) {
652 params[0] = static_cast<GLint>(stencil_back_ref);
654 return true;
655 case GL_STENCIL_BACK_VALUE_MASK:
656 *num_written = 1;
657 if (params) {
658 params[0] = static_cast<GLint>(stencil_back_mask);
660 return true;
661 case GL_STENCIL_WRITEMASK:
662 *num_written = 1;
663 if (params) {
664 params[0] = static_cast<GLint>(stencil_front_writemask);
666 return true;
667 case GL_STENCIL_BACK_WRITEMASK:
668 *num_written = 1;
669 if (params) {
670 params[0] = static_cast<GLint>(stencil_back_writemask);
672 return true;
673 case GL_STENCIL_FAIL:
674 *num_written = 1;
675 if (params) {
676 params[0] = static_cast<GLint>(stencil_front_fail_op);
678 return true;
679 case GL_STENCIL_PASS_DEPTH_FAIL:
680 *num_written = 1;
681 if (params) {
682 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
684 return true;
685 case GL_STENCIL_PASS_DEPTH_PASS:
686 *num_written = 1;
687 if (params) {
688 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
690 return true;
691 case GL_STENCIL_BACK_FAIL:
692 *num_written = 1;
693 if (params) {
694 params[0] = static_cast<GLint>(stencil_back_fail_op);
696 return true;
697 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
698 *num_written = 1;
699 if (params) {
700 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
702 return true;
703 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
704 *num_written = 1;
705 if (params) {
706 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
708 return true;
709 case GL_VIEWPORT:
710 *num_written = 4;
711 if (params) {
712 params[0] = static_cast<GLint>(viewport_x);
713 params[1] = static_cast<GLint>(viewport_y);
714 params[2] = static_cast<GLint>(viewport_width);
715 params[3] = static_cast<GLint>(viewport_height);
717 return true;
718 case GL_BLEND:
719 *num_written = 1;
720 if (params) {
721 params[0] = static_cast<GLint>(enable_flags.blend);
723 return true;
724 case GL_CULL_FACE:
725 *num_written = 1;
726 if (params) {
727 params[0] = static_cast<GLint>(enable_flags.cull_face);
729 return true;
730 case GL_DEPTH_TEST:
731 *num_written = 1;
732 if (params) {
733 params[0] = static_cast<GLint>(enable_flags.depth_test);
735 return true;
736 case GL_DITHER:
737 *num_written = 1;
738 if (params) {
739 params[0] = static_cast<GLint>(enable_flags.dither);
741 return true;
742 case GL_POLYGON_OFFSET_FILL:
743 *num_written = 1;
744 if (params) {
745 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
747 return true;
748 case GL_SAMPLE_ALPHA_TO_COVERAGE:
749 *num_written = 1;
750 if (params) {
751 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
753 return true;
754 case GL_SAMPLE_COVERAGE:
755 *num_written = 1;
756 if (params) {
757 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
759 return true;
760 case GL_SCISSOR_TEST:
761 *num_written = 1;
762 if (params) {
763 params[0] = static_cast<GLint>(enable_flags.scissor_test);
765 return true;
766 case GL_STENCIL_TEST:
767 *num_written = 1;
768 if (params) {
769 params[0] = static_cast<GLint>(enable_flags.stencil_test);
771 return true;
772 case GL_RASTERIZER_DISCARD:
773 *num_written = 1;
774 if (params) {
775 params[0] = static_cast<GLint>(enable_flags.rasterizer_discard);
777 return true;
778 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
779 *num_written = 1;
780 if (params) {
781 params[0] =
782 static_cast<GLint>(enable_flags.primitive_restart_fixed_index);
784 return true;
785 default:
786 return false;
790 bool ContextState::GetStateAsGLfloat(GLenum pname,
791 GLfloat* params,
792 GLsizei* num_written) const {
793 switch (pname) {
794 case GL_BLEND_COLOR:
795 *num_written = 4;
796 if (params) {
797 params[0] = static_cast<GLfloat>(blend_color_red);
798 params[1] = static_cast<GLfloat>(blend_color_green);
799 params[2] = static_cast<GLfloat>(blend_color_blue);
800 params[3] = static_cast<GLfloat>(blend_color_alpha);
802 return true;
803 case GL_BLEND_EQUATION_RGB:
804 *num_written = 1;
805 if (params) {
806 params[0] = static_cast<GLfloat>(blend_equation_rgb);
808 return true;
809 case GL_BLEND_EQUATION_ALPHA:
810 *num_written = 1;
811 if (params) {
812 params[0] = static_cast<GLfloat>(blend_equation_alpha);
814 return true;
815 case GL_BLEND_SRC_RGB:
816 *num_written = 1;
817 if (params) {
818 params[0] = static_cast<GLfloat>(blend_source_rgb);
820 return true;
821 case GL_BLEND_DST_RGB:
822 *num_written = 1;
823 if (params) {
824 params[0] = static_cast<GLfloat>(blend_dest_rgb);
826 return true;
827 case GL_BLEND_SRC_ALPHA:
828 *num_written = 1;
829 if (params) {
830 params[0] = static_cast<GLfloat>(blend_source_alpha);
832 return true;
833 case GL_BLEND_DST_ALPHA:
834 *num_written = 1;
835 if (params) {
836 params[0] = static_cast<GLfloat>(blend_dest_alpha);
838 return true;
839 case GL_COLOR_CLEAR_VALUE:
840 *num_written = 4;
841 if (params) {
842 params[0] = static_cast<GLfloat>(color_clear_red);
843 params[1] = static_cast<GLfloat>(color_clear_green);
844 params[2] = static_cast<GLfloat>(color_clear_blue);
845 params[3] = static_cast<GLfloat>(color_clear_alpha);
847 return true;
848 case GL_DEPTH_CLEAR_VALUE:
849 *num_written = 1;
850 if (params) {
851 params[0] = static_cast<GLfloat>(depth_clear);
853 return true;
854 case GL_STENCIL_CLEAR_VALUE:
855 *num_written = 1;
856 if (params) {
857 params[0] = static_cast<GLfloat>(stencil_clear);
859 return true;
860 case GL_COLOR_WRITEMASK:
861 *num_written = 4;
862 if (params) {
863 params[0] = static_cast<GLfloat>(color_mask_red);
864 params[1] = static_cast<GLfloat>(color_mask_green);
865 params[2] = static_cast<GLfloat>(color_mask_blue);
866 params[3] = static_cast<GLfloat>(color_mask_alpha);
868 return true;
869 case GL_CULL_FACE_MODE:
870 *num_written = 1;
871 if (params) {
872 params[0] = static_cast<GLfloat>(cull_mode);
874 return true;
875 case GL_DEPTH_FUNC:
876 *num_written = 1;
877 if (params) {
878 params[0] = static_cast<GLfloat>(depth_func);
880 return true;
881 case GL_DEPTH_WRITEMASK:
882 *num_written = 1;
883 if (params) {
884 params[0] = static_cast<GLfloat>(depth_mask);
886 return true;
887 case GL_DEPTH_RANGE:
888 *num_written = 2;
889 if (params) {
890 params[0] = static_cast<GLfloat>(z_near);
891 params[1] = static_cast<GLfloat>(z_far);
893 return true;
894 case GL_FRONT_FACE:
895 *num_written = 1;
896 if (params) {
897 params[0] = static_cast<GLfloat>(front_face);
899 return true;
900 case GL_GENERATE_MIPMAP_HINT:
901 *num_written = 1;
902 if (params) {
903 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
905 return true;
906 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
907 *num_written = 1;
908 if (params) {
909 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
911 return true;
912 case GL_LINE_WIDTH:
913 *num_written = 1;
914 if (params) {
915 params[0] = static_cast<GLfloat>(line_width);
917 return true;
918 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
919 *num_written = 16;
920 if (params) {
921 memcpy(params, modelview_matrix, sizeof(GLfloat) * 16);
923 return true;
924 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
925 *num_written = 16;
926 if (params) {
927 memcpy(params, projection_matrix, sizeof(GLfloat) * 16);
929 return true;
930 case GL_PATH_STENCIL_FUNC_CHROMIUM:
931 *num_written = 1;
932 if (params) {
933 params[0] = static_cast<GLfloat>(stencil_path_func);
935 return true;
936 case GL_PATH_STENCIL_REF_CHROMIUM:
937 *num_written = 1;
938 if (params) {
939 params[0] = static_cast<GLfloat>(stencil_path_ref);
941 return true;
942 case GL_PATH_STENCIL_VALUE_MASK_CHROMIUM:
943 *num_written = 1;
944 if (params) {
945 params[0] = static_cast<GLfloat>(stencil_path_mask);
947 return true;
948 case GL_PACK_ALIGNMENT:
949 *num_written = 1;
950 if (params) {
951 params[0] = static_cast<GLfloat>(pack_alignment);
953 return true;
954 case GL_UNPACK_ALIGNMENT:
955 *num_written = 1;
956 if (params) {
957 params[0] = static_cast<GLfloat>(unpack_alignment);
959 return true;
960 case GL_POLYGON_OFFSET_FACTOR:
961 *num_written = 1;
962 if (params) {
963 params[0] = static_cast<GLfloat>(polygon_offset_factor);
965 return true;
966 case GL_POLYGON_OFFSET_UNITS:
967 *num_written = 1;
968 if (params) {
969 params[0] = static_cast<GLfloat>(polygon_offset_units);
971 return true;
972 case GL_SAMPLE_COVERAGE_VALUE:
973 *num_written = 1;
974 if (params) {
975 params[0] = static_cast<GLfloat>(sample_coverage_value);
977 return true;
978 case GL_SAMPLE_COVERAGE_INVERT:
979 *num_written = 1;
980 if (params) {
981 params[0] = static_cast<GLfloat>(sample_coverage_invert);
983 return true;
984 case GL_SCISSOR_BOX:
985 *num_written = 4;
986 if (params) {
987 params[0] = static_cast<GLfloat>(scissor_x);
988 params[1] = static_cast<GLfloat>(scissor_y);
989 params[2] = static_cast<GLfloat>(scissor_width);
990 params[3] = static_cast<GLfloat>(scissor_height);
992 return true;
993 case GL_STENCIL_FUNC:
994 *num_written = 1;
995 if (params) {
996 params[0] = static_cast<GLfloat>(stencil_front_func);
998 return true;
999 case GL_STENCIL_REF:
1000 *num_written = 1;
1001 if (params) {
1002 params[0] = static_cast<GLfloat>(stencil_front_ref);
1004 return true;
1005 case GL_STENCIL_VALUE_MASK:
1006 *num_written = 1;
1007 if (params) {
1008 params[0] = static_cast<GLfloat>(stencil_front_mask);
1010 return true;
1011 case GL_STENCIL_BACK_FUNC:
1012 *num_written = 1;
1013 if (params) {
1014 params[0] = static_cast<GLfloat>(stencil_back_func);
1016 return true;
1017 case GL_STENCIL_BACK_REF:
1018 *num_written = 1;
1019 if (params) {
1020 params[0] = static_cast<GLfloat>(stencil_back_ref);
1022 return true;
1023 case GL_STENCIL_BACK_VALUE_MASK:
1024 *num_written = 1;
1025 if (params) {
1026 params[0] = static_cast<GLfloat>(stencil_back_mask);
1028 return true;
1029 case GL_STENCIL_WRITEMASK:
1030 *num_written = 1;
1031 if (params) {
1032 params[0] = static_cast<GLfloat>(stencil_front_writemask);
1034 return true;
1035 case GL_STENCIL_BACK_WRITEMASK:
1036 *num_written = 1;
1037 if (params) {
1038 params[0] = static_cast<GLfloat>(stencil_back_writemask);
1040 return true;
1041 case GL_STENCIL_FAIL:
1042 *num_written = 1;
1043 if (params) {
1044 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
1046 return true;
1047 case GL_STENCIL_PASS_DEPTH_FAIL:
1048 *num_written = 1;
1049 if (params) {
1050 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
1052 return true;
1053 case GL_STENCIL_PASS_DEPTH_PASS:
1054 *num_written = 1;
1055 if (params) {
1056 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
1058 return true;
1059 case GL_STENCIL_BACK_FAIL:
1060 *num_written = 1;
1061 if (params) {
1062 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
1064 return true;
1065 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1066 *num_written = 1;
1067 if (params) {
1068 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
1070 return true;
1071 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1072 *num_written = 1;
1073 if (params) {
1074 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
1076 return true;
1077 case GL_VIEWPORT:
1078 *num_written = 4;
1079 if (params) {
1080 params[0] = static_cast<GLfloat>(viewport_x);
1081 params[1] = static_cast<GLfloat>(viewport_y);
1082 params[2] = static_cast<GLfloat>(viewport_width);
1083 params[3] = static_cast<GLfloat>(viewport_height);
1085 return true;
1086 case GL_BLEND:
1087 *num_written = 1;
1088 if (params) {
1089 params[0] = static_cast<GLfloat>(enable_flags.blend);
1091 return true;
1092 case GL_CULL_FACE:
1093 *num_written = 1;
1094 if (params) {
1095 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
1097 return true;
1098 case GL_DEPTH_TEST:
1099 *num_written = 1;
1100 if (params) {
1101 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
1103 return true;
1104 case GL_DITHER:
1105 *num_written = 1;
1106 if (params) {
1107 params[0] = static_cast<GLfloat>(enable_flags.dither);
1109 return true;
1110 case GL_POLYGON_OFFSET_FILL:
1111 *num_written = 1;
1112 if (params) {
1113 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
1115 return true;
1116 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1117 *num_written = 1;
1118 if (params) {
1119 params[0] = static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
1121 return true;
1122 case GL_SAMPLE_COVERAGE:
1123 *num_written = 1;
1124 if (params) {
1125 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
1127 return true;
1128 case GL_SCISSOR_TEST:
1129 *num_written = 1;
1130 if (params) {
1131 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
1133 return true;
1134 case GL_STENCIL_TEST:
1135 *num_written = 1;
1136 if (params) {
1137 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
1139 return true;
1140 case GL_RASTERIZER_DISCARD:
1141 *num_written = 1;
1142 if (params) {
1143 params[0] = static_cast<GLfloat>(enable_flags.rasterizer_discard);
1145 return true;
1146 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
1147 *num_written = 1;
1148 if (params) {
1149 params[0] =
1150 static_cast<GLfloat>(enable_flags.primitive_restart_fixed_index);
1152 return true;
1153 default:
1154 return false;
1157 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_