Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / context_state_impl_autogen.h
blobfa5462f0460bce9655b2576e3ac31a61afa6fcb4
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 pack_alignment = 4;
108 unpack_alignment = 4;
109 polygon_offset_factor = 0.0f;
110 polygon_offset_units = 0.0f;
111 sample_coverage_value = 1.0f;
112 sample_coverage_invert = false;
113 scissor_x = 0;
114 scissor_y = 0;
115 scissor_width = 1;
116 scissor_height = 1;
117 stencil_front_func = GL_ALWAYS;
118 stencil_front_ref = 0;
119 stencil_front_mask = 0xFFFFFFFFU;
120 stencil_back_func = GL_ALWAYS;
121 stencil_back_ref = 0;
122 stencil_back_mask = 0xFFFFFFFFU;
123 stencil_front_writemask = 0xFFFFFFFFU;
124 cached_stencil_front_writemask = 0xFFFFFFFFU;
125 stencil_back_writemask = 0xFFFFFFFFU;
126 cached_stencil_back_writemask = 0xFFFFFFFFU;
127 stencil_front_fail_op = GL_KEEP;
128 stencil_front_z_fail_op = GL_KEEP;
129 stencil_front_z_pass_op = GL_KEEP;
130 stencil_back_fail_op = GL_KEEP;
131 stencil_back_z_fail_op = GL_KEEP;
132 stencil_back_z_pass_op = GL_KEEP;
133 viewport_x = 0;
134 viewport_y = 0;
135 viewport_width = 1;
136 viewport_height = 1;
139 void ContextState::InitCapabilities(const ContextState* prev_state) const {
140 if (prev_state) {
141 if (prev_state->enable_flags.cached_blend != enable_flags.cached_blend) {
142 EnableDisable(GL_BLEND, enable_flags.cached_blend);
144 if (prev_state->enable_flags.cached_cull_face !=
145 enable_flags.cached_cull_face) {
146 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
148 if (prev_state->enable_flags.cached_depth_test !=
149 enable_flags.cached_depth_test) {
150 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
152 if (prev_state->enable_flags.cached_dither != enable_flags.cached_dither) {
153 EnableDisable(GL_DITHER, enable_flags.cached_dither);
155 if (prev_state->enable_flags.cached_polygon_offset_fill !=
156 enable_flags.cached_polygon_offset_fill) {
157 EnableDisable(GL_POLYGON_OFFSET_FILL,
158 enable_flags.cached_polygon_offset_fill);
160 if (prev_state->enable_flags.cached_sample_alpha_to_coverage !=
161 enable_flags.cached_sample_alpha_to_coverage) {
162 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
163 enable_flags.cached_sample_alpha_to_coverage);
165 if (prev_state->enable_flags.cached_sample_coverage !=
166 enable_flags.cached_sample_coverage) {
167 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
169 if (prev_state->enable_flags.cached_scissor_test !=
170 enable_flags.cached_scissor_test) {
171 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
173 if (prev_state->enable_flags.cached_stencil_test !=
174 enable_flags.cached_stencil_test) {
175 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
177 if (feature_info_->IsES3Capable()) {
178 if (prev_state->enable_flags.cached_rasterizer_discard !=
179 enable_flags.cached_rasterizer_discard) {
180 EnableDisable(GL_RASTERIZER_DISCARD,
181 enable_flags.cached_rasterizer_discard);
183 if (prev_state->enable_flags.cached_primitive_restart_fixed_index !=
184 enable_flags.cached_primitive_restart_fixed_index) {
185 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
186 enable_flags.cached_primitive_restart_fixed_index);
189 } else {
190 EnableDisable(GL_BLEND, enable_flags.cached_blend);
191 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
192 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
193 EnableDisable(GL_DITHER, enable_flags.cached_dither);
194 EnableDisable(GL_POLYGON_OFFSET_FILL,
195 enable_flags.cached_polygon_offset_fill);
196 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
197 enable_flags.cached_sample_alpha_to_coverage);
198 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
199 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
200 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
201 if (feature_info_->IsES3Capable()) {
202 EnableDisable(GL_RASTERIZER_DISCARD,
203 enable_flags.cached_rasterizer_discard);
204 EnableDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX,
205 enable_flags.cached_primitive_restart_fixed_index);
210 void ContextState::InitState(const ContextState* prev_state) const {
211 if (prev_state) {
212 if ((blend_color_red != prev_state->blend_color_red) ||
213 (blend_color_green != prev_state->blend_color_green) ||
214 (blend_color_blue != prev_state->blend_color_blue) ||
215 (blend_color_alpha != prev_state->blend_color_alpha))
216 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
217 blend_color_alpha);
218 if ((blend_equation_rgb != prev_state->blend_equation_rgb) ||
219 (blend_equation_alpha != prev_state->blend_equation_alpha))
220 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
221 if ((blend_source_rgb != prev_state->blend_source_rgb) ||
222 (blend_dest_rgb != prev_state->blend_dest_rgb) ||
223 (blend_source_alpha != prev_state->blend_source_alpha) ||
224 (blend_dest_alpha != prev_state->blend_dest_alpha))
225 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
226 blend_dest_alpha);
227 if ((color_clear_red != prev_state->color_clear_red) ||
228 (color_clear_green != prev_state->color_clear_green) ||
229 (color_clear_blue != prev_state->color_clear_blue) ||
230 (color_clear_alpha != prev_state->color_clear_alpha))
231 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
232 color_clear_alpha);
233 if ((depth_clear != prev_state->depth_clear))
234 glClearDepth(depth_clear);
235 if ((stencil_clear != prev_state->stencil_clear))
236 glClearStencil(stencil_clear);
237 if ((cached_color_mask_red != prev_state->cached_color_mask_red) ||
238 (cached_color_mask_green != prev_state->cached_color_mask_green) ||
239 (cached_color_mask_blue != prev_state->cached_color_mask_blue) ||
240 (cached_color_mask_alpha != prev_state->cached_color_mask_alpha))
241 glColorMask(cached_color_mask_red, cached_color_mask_green,
242 cached_color_mask_blue, cached_color_mask_alpha);
243 if ((cull_mode != prev_state->cull_mode))
244 glCullFace(cull_mode);
245 if ((depth_func != prev_state->depth_func))
246 glDepthFunc(depth_func);
247 if ((cached_depth_mask != prev_state->cached_depth_mask))
248 glDepthMask(cached_depth_mask);
249 if ((z_near != prev_state->z_near) || (z_far != prev_state->z_far))
250 glDepthRange(z_near, z_far);
251 if ((front_face != prev_state->front_face))
252 glFrontFace(front_face);
253 if (prev_state->hint_generate_mipmap != hint_generate_mipmap) {
254 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
255 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
258 if (feature_info_->feature_flags().oes_standard_derivatives) {
259 if (prev_state->hint_fragment_shader_derivative !=
260 hint_fragment_shader_derivative) {
261 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
262 hint_fragment_shader_derivative);
265 if ((line_width != prev_state->line_width))
266 glLineWidth(line_width);
267 if (feature_info_->feature_flags().chromium_path_rendering) {
268 if (memcmp(prev_state->modelview_matrix, modelview_matrix,
269 sizeof(GLfloat) * 16)) {
270 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
273 if (feature_info_->feature_flags().chromium_path_rendering) {
274 if (memcmp(prev_state->projection_matrix, projection_matrix,
275 sizeof(GLfloat) * 16)) {
276 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
279 if (prev_state->pack_alignment != pack_alignment) {
280 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
282 if (prev_state->unpack_alignment != unpack_alignment) {
283 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
285 if ((polygon_offset_factor != prev_state->polygon_offset_factor) ||
286 (polygon_offset_units != prev_state->polygon_offset_units))
287 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
288 if ((sample_coverage_value != prev_state->sample_coverage_value) ||
289 (sample_coverage_invert != prev_state->sample_coverage_invert))
290 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
291 if ((scissor_x != prev_state->scissor_x) ||
292 (scissor_y != prev_state->scissor_y) ||
293 (scissor_width != prev_state->scissor_width) ||
294 (scissor_height != prev_state->scissor_height))
295 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
296 if ((stencil_front_func != prev_state->stencil_front_func) ||
297 (stencil_front_ref != prev_state->stencil_front_ref) ||
298 (stencil_front_mask != prev_state->stencil_front_mask))
299 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
300 stencil_front_mask);
301 if ((stencil_back_func != prev_state->stencil_back_func) ||
302 (stencil_back_ref != prev_state->stencil_back_ref) ||
303 (stencil_back_mask != prev_state->stencil_back_mask))
304 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
305 stencil_back_mask);
306 if ((cached_stencil_front_writemask !=
307 prev_state->cached_stencil_front_writemask))
308 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
309 if ((cached_stencil_back_writemask !=
310 prev_state->cached_stencil_back_writemask))
311 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
312 if ((stencil_front_fail_op != prev_state->stencil_front_fail_op) ||
313 (stencil_front_z_fail_op != prev_state->stencil_front_z_fail_op) ||
314 (stencil_front_z_pass_op != prev_state->stencil_front_z_pass_op))
315 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
316 stencil_front_z_fail_op, stencil_front_z_pass_op);
317 if ((stencil_back_fail_op != prev_state->stencil_back_fail_op) ||
318 (stencil_back_z_fail_op != prev_state->stencil_back_z_fail_op) ||
319 (stencil_back_z_pass_op != prev_state->stencil_back_z_pass_op))
320 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
321 stencil_back_z_pass_op);
322 if ((viewport_x != prev_state->viewport_x) ||
323 (viewport_y != prev_state->viewport_y) ||
324 (viewport_width != prev_state->viewport_width) ||
325 (viewport_height != prev_state->viewport_height))
326 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
327 } else {
328 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
329 blend_color_alpha);
330 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
331 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
332 blend_dest_alpha);
333 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
334 color_clear_alpha);
335 glClearDepth(depth_clear);
336 glClearStencil(stencil_clear);
337 glColorMask(cached_color_mask_red, cached_color_mask_green,
338 cached_color_mask_blue, cached_color_mask_alpha);
339 glCullFace(cull_mode);
340 glDepthFunc(depth_func);
341 glDepthMask(cached_depth_mask);
342 glDepthRange(z_near, z_far);
343 glFrontFace(front_face);
344 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
345 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
347 if (feature_info_->feature_flags().oes_standard_derivatives) {
348 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
349 hint_fragment_shader_derivative);
351 glLineWidth(line_width);
352 if (feature_info_->feature_flags().chromium_path_rendering) {
353 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
355 if (feature_info_->feature_flags().chromium_path_rendering) {
356 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
358 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
359 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
360 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
361 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
362 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
363 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
364 stencil_front_mask);
365 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
366 stencil_back_mask);
367 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
368 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
369 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
370 stencil_front_z_fail_op, stencil_front_z_pass_op);
371 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
372 stencil_back_z_pass_op);
373 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
376 bool ContextState::GetEnabled(GLenum cap) const {
377 switch (cap) {
378 case GL_BLEND:
379 return enable_flags.blend;
380 case GL_CULL_FACE:
381 return enable_flags.cull_face;
382 case GL_DEPTH_TEST:
383 return enable_flags.depth_test;
384 case GL_DITHER:
385 return enable_flags.dither;
386 case GL_POLYGON_OFFSET_FILL:
387 return enable_flags.polygon_offset_fill;
388 case GL_SAMPLE_ALPHA_TO_COVERAGE:
389 return enable_flags.sample_alpha_to_coverage;
390 case GL_SAMPLE_COVERAGE:
391 return enable_flags.sample_coverage;
392 case GL_SCISSOR_TEST:
393 return enable_flags.scissor_test;
394 case GL_STENCIL_TEST:
395 return enable_flags.stencil_test;
396 case GL_RASTERIZER_DISCARD:
397 return enable_flags.rasterizer_discard;
398 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
399 return enable_flags.primitive_restart_fixed_index;
400 default:
401 NOTREACHED();
402 return false;
406 bool ContextState::GetStateAsGLint(GLenum pname,
407 GLint* params,
408 GLsizei* num_written) const {
409 switch (pname) {
410 case GL_BLEND_COLOR:
411 *num_written = 4;
412 if (params) {
413 params[0] = static_cast<GLint>(blend_color_red);
414 params[1] = static_cast<GLint>(blend_color_green);
415 params[2] = static_cast<GLint>(blend_color_blue);
416 params[3] = static_cast<GLint>(blend_color_alpha);
418 return true;
419 case GL_BLEND_EQUATION_RGB:
420 *num_written = 1;
421 if (params) {
422 params[0] = static_cast<GLint>(blend_equation_rgb);
424 return true;
425 case GL_BLEND_EQUATION_ALPHA:
426 *num_written = 1;
427 if (params) {
428 params[0] = static_cast<GLint>(blend_equation_alpha);
430 return true;
431 case GL_BLEND_SRC_RGB:
432 *num_written = 1;
433 if (params) {
434 params[0] = static_cast<GLint>(blend_source_rgb);
436 return true;
437 case GL_BLEND_DST_RGB:
438 *num_written = 1;
439 if (params) {
440 params[0] = static_cast<GLint>(blend_dest_rgb);
442 return true;
443 case GL_BLEND_SRC_ALPHA:
444 *num_written = 1;
445 if (params) {
446 params[0] = static_cast<GLint>(blend_source_alpha);
448 return true;
449 case GL_BLEND_DST_ALPHA:
450 *num_written = 1;
451 if (params) {
452 params[0] = static_cast<GLint>(blend_dest_alpha);
454 return true;
455 case GL_COLOR_CLEAR_VALUE:
456 *num_written = 4;
457 if (params) {
458 params[0] = static_cast<GLint>(color_clear_red);
459 params[1] = static_cast<GLint>(color_clear_green);
460 params[2] = static_cast<GLint>(color_clear_blue);
461 params[3] = static_cast<GLint>(color_clear_alpha);
463 return true;
464 case GL_DEPTH_CLEAR_VALUE:
465 *num_written = 1;
466 if (params) {
467 params[0] = static_cast<GLint>(depth_clear);
469 return true;
470 case GL_STENCIL_CLEAR_VALUE:
471 *num_written = 1;
472 if (params) {
473 params[0] = static_cast<GLint>(stencil_clear);
475 return true;
476 case GL_COLOR_WRITEMASK:
477 *num_written = 4;
478 if (params) {
479 params[0] = static_cast<GLint>(color_mask_red);
480 params[1] = static_cast<GLint>(color_mask_green);
481 params[2] = static_cast<GLint>(color_mask_blue);
482 params[3] = static_cast<GLint>(color_mask_alpha);
484 return true;
485 case GL_CULL_FACE_MODE:
486 *num_written = 1;
487 if (params) {
488 params[0] = static_cast<GLint>(cull_mode);
490 return true;
491 case GL_DEPTH_FUNC:
492 *num_written = 1;
493 if (params) {
494 params[0] = static_cast<GLint>(depth_func);
496 return true;
497 case GL_DEPTH_WRITEMASK:
498 *num_written = 1;
499 if (params) {
500 params[0] = static_cast<GLint>(depth_mask);
502 return true;
503 case GL_DEPTH_RANGE:
504 *num_written = 2;
505 if (params) {
506 params[0] = static_cast<GLint>(z_near);
507 params[1] = static_cast<GLint>(z_far);
509 return true;
510 case GL_FRONT_FACE:
511 *num_written = 1;
512 if (params) {
513 params[0] = static_cast<GLint>(front_face);
515 return true;
516 case GL_GENERATE_MIPMAP_HINT:
517 *num_written = 1;
518 if (params) {
519 params[0] = static_cast<GLint>(hint_generate_mipmap);
521 return true;
522 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
523 *num_written = 1;
524 if (params) {
525 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
527 return true;
528 case GL_LINE_WIDTH:
529 *num_written = 1;
530 if (params) {
531 params[0] = static_cast<GLint>(line_width);
533 return true;
534 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
535 *num_written = 16;
536 if (params) {
537 for (size_t i = 0; i < 16; ++i) {
538 params[i] = static_cast<GLint>(round(modelview_matrix[i]));
541 return true;
542 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
543 *num_written = 16;
544 if (params) {
545 for (size_t i = 0; i < 16; ++i) {
546 params[i] = static_cast<GLint>(round(projection_matrix[i]));
549 return true;
550 case GL_PACK_ALIGNMENT:
551 *num_written = 1;
552 if (params) {
553 params[0] = static_cast<GLint>(pack_alignment);
555 return true;
556 case GL_UNPACK_ALIGNMENT:
557 *num_written = 1;
558 if (params) {
559 params[0] = static_cast<GLint>(unpack_alignment);
561 return true;
562 case GL_POLYGON_OFFSET_FACTOR:
563 *num_written = 1;
564 if (params) {
565 params[0] = static_cast<GLint>(round(polygon_offset_factor));
567 return true;
568 case GL_POLYGON_OFFSET_UNITS:
569 *num_written = 1;
570 if (params) {
571 params[0] = static_cast<GLint>(round(polygon_offset_units));
573 return true;
574 case GL_SAMPLE_COVERAGE_VALUE:
575 *num_written = 1;
576 if (params) {
577 params[0] = static_cast<GLint>(sample_coverage_value);
579 return true;
580 case GL_SAMPLE_COVERAGE_INVERT:
581 *num_written = 1;
582 if (params) {
583 params[0] = static_cast<GLint>(sample_coverage_invert);
585 return true;
586 case GL_SCISSOR_BOX:
587 *num_written = 4;
588 if (params) {
589 params[0] = static_cast<GLint>(scissor_x);
590 params[1] = static_cast<GLint>(scissor_y);
591 params[2] = static_cast<GLint>(scissor_width);
592 params[3] = static_cast<GLint>(scissor_height);
594 return true;
595 case GL_STENCIL_FUNC:
596 *num_written = 1;
597 if (params) {
598 params[0] = static_cast<GLint>(stencil_front_func);
600 return true;
601 case GL_STENCIL_REF:
602 *num_written = 1;
603 if (params) {
604 params[0] = static_cast<GLint>(stencil_front_ref);
606 return true;
607 case GL_STENCIL_VALUE_MASK:
608 *num_written = 1;
609 if (params) {
610 params[0] = static_cast<GLint>(stencil_front_mask);
612 return true;
613 case GL_STENCIL_BACK_FUNC:
614 *num_written = 1;
615 if (params) {
616 params[0] = static_cast<GLint>(stencil_back_func);
618 return true;
619 case GL_STENCIL_BACK_REF:
620 *num_written = 1;
621 if (params) {
622 params[0] = static_cast<GLint>(stencil_back_ref);
624 return true;
625 case GL_STENCIL_BACK_VALUE_MASK:
626 *num_written = 1;
627 if (params) {
628 params[0] = static_cast<GLint>(stencil_back_mask);
630 return true;
631 case GL_STENCIL_WRITEMASK:
632 *num_written = 1;
633 if (params) {
634 params[0] = static_cast<GLint>(stencil_front_writemask);
636 return true;
637 case GL_STENCIL_BACK_WRITEMASK:
638 *num_written = 1;
639 if (params) {
640 params[0] = static_cast<GLint>(stencil_back_writemask);
642 return true;
643 case GL_STENCIL_FAIL:
644 *num_written = 1;
645 if (params) {
646 params[0] = static_cast<GLint>(stencil_front_fail_op);
648 return true;
649 case GL_STENCIL_PASS_DEPTH_FAIL:
650 *num_written = 1;
651 if (params) {
652 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
654 return true;
655 case GL_STENCIL_PASS_DEPTH_PASS:
656 *num_written = 1;
657 if (params) {
658 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
660 return true;
661 case GL_STENCIL_BACK_FAIL:
662 *num_written = 1;
663 if (params) {
664 params[0] = static_cast<GLint>(stencil_back_fail_op);
666 return true;
667 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
668 *num_written = 1;
669 if (params) {
670 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
672 return true;
673 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
674 *num_written = 1;
675 if (params) {
676 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
678 return true;
679 case GL_VIEWPORT:
680 *num_written = 4;
681 if (params) {
682 params[0] = static_cast<GLint>(viewport_x);
683 params[1] = static_cast<GLint>(viewport_y);
684 params[2] = static_cast<GLint>(viewport_width);
685 params[3] = static_cast<GLint>(viewport_height);
687 return true;
688 case GL_BLEND:
689 *num_written = 1;
690 if (params) {
691 params[0] = static_cast<GLint>(enable_flags.blend);
693 return true;
694 case GL_CULL_FACE:
695 *num_written = 1;
696 if (params) {
697 params[0] = static_cast<GLint>(enable_flags.cull_face);
699 return true;
700 case GL_DEPTH_TEST:
701 *num_written = 1;
702 if (params) {
703 params[0] = static_cast<GLint>(enable_flags.depth_test);
705 return true;
706 case GL_DITHER:
707 *num_written = 1;
708 if (params) {
709 params[0] = static_cast<GLint>(enable_flags.dither);
711 return true;
712 case GL_POLYGON_OFFSET_FILL:
713 *num_written = 1;
714 if (params) {
715 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
717 return true;
718 case GL_SAMPLE_ALPHA_TO_COVERAGE:
719 *num_written = 1;
720 if (params) {
721 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
723 return true;
724 case GL_SAMPLE_COVERAGE:
725 *num_written = 1;
726 if (params) {
727 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
729 return true;
730 case GL_SCISSOR_TEST:
731 *num_written = 1;
732 if (params) {
733 params[0] = static_cast<GLint>(enable_flags.scissor_test);
735 return true;
736 case GL_STENCIL_TEST:
737 *num_written = 1;
738 if (params) {
739 params[0] = static_cast<GLint>(enable_flags.stencil_test);
741 return true;
742 case GL_RASTERIZER_DISCARD:
743 *num_written = 1;
744 if (params) {
745 params[0] = static_cast<GLint>(enable_flags.rasterizer_discard);
747 return true;
748 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
749 *num_written = 1;
750 if (params) {
751 params[0] =
752 static_cast<GLint>(enable_flags.primitive_restart_fixed_index);
754 return true;
755 default:
756 return false;
760 bool ContextState::GetStateAsGLfloat(GLenum pname,
761 GLfloat* params,
762 GLsizei* num_written) const {
763 switch (pname) {
764 case GL_BLEND_COLOR:
765 *num_written = 4;
766 if (params) {
767 params[0] = static_cast<GLfloat>(blend_color_red);
768 params[1] = static_cast<GLfloat>(blend_color_green);
769 params[2] = static_cast<GLfloat>(blend_color_blue);
770 params[3] = static_cast<GLfloat>(blend_color_alpha);
772 return true;
773 case GL_BLEND_EQUATION_RGB:
774 *num_written = 1;
775 if (params) {
776 params[0] = static_cast<GLfloat>(blend_equation_rgb);
778 return true;
779 case GL_BLEND_EQUATION_ALPHA:
780 *num_written = 1;
781 if (params) {
782 params[0] = static_cast<GLfloat>(blend_equation_alpha);
784 return true;
785 case GL_BLEND_SRC_RGB:
786 *num_written = 1;
787 if (params) {
788 params[0] = static_cast<GLfloat>(blend_source_rgb);
790 return true;
791 case GL_BLEND_DST_RGB:
792 *num_written = 1;
793 if (params) {
794 params[0] = static_cast<GLfloat>(blend_dest_rgb);
796 return true;
797 case GL_BLEND_SRC_ALPHA:
798 *num_written = 1;
799 if (params) {
800 params[0] = static_cast<GLfloat>(blend_source_alpha);
802 return true;
803 case GL_BLEND_DST_ALPHA:
804 *num_written = 1;
805 if (params) {
806 params[0] = static_cast<GLfloat>(blend_dest_alpha);
808 return true;
809 case GL_COLOR_CLEAR_VALUE:
810 *num_written = 4;
811 if (params) {
812 params[0] = static_cast<GLfloat>(color_clear_red);
813 params[1] = static_cast<GLfloat>(color_clear_green);
814 params[2] = static_cast<GLfloat>(color_clear_blue);
815 params[3] = static_cast<GLfloat>(color_clear_alpha);
817 return true;
818 case GL_DEPTH_CLEAR_VALUE:
819 *num_written = 1;
820 if (params) {
821 params[0] = static_cast<GLfloat>(depth_clear);
823 return true;
824 case GL_STENCIL_CLEAR_VALUE:
825 *num_written = 1;
826 if (params) {
827 params[0] = static_cast<GLfloat>(stencil_clear);
829 return true;
830 case GL_COLOR_WRITEMASK:
831 *num_written = 4;
832 if (params) {
833 params[0] = static_cast<GLfloat>(color_mask_red);
834 params[1] = static_cast<GLfloat>(color_mask_green);
835 params[2] = static_cast<GLfloat>(color_mask_blue);
836 params[3] = static_cast<GLfloat>(color_mask_alpha);
838 return true;
839 case GL_CULL_FACE_MODE:
840 *num_written = 1;
841 if (params) {
842 params[0] = static_cast<GLfloat>(cull_mode);
844 return true;
845 case GL_DEPTH_FUNC:
846 *num_written = 1;
847 if (params) {
848 params[0] = static_cast<GLfloat>(depth_func);
850 return true;
851 case GL_DEPTH_WRITEMASK:
852 *num_written = 1;
853 if (params) {
854 params[0] = static_cast<GLfloat>(depth_mask);
856 return true;
857 case GL_DEPTH_RANGE:
858 *num_written = 2;
859 if (params) {
860 params[0] = static_cast<GLfloat>(z_near);
861 params[1] = static_cast<GLfloat>(z_far);
863 return true;
864 case GL_FRONT_FACE:
865 *num_written = 1;
866 if (params) {
867 params[0] = static_cast<GLfloat>(front_face);
869 return true;
870 case GL_GENERATE_MIPMAP_HINT:
871 *num_written = 1;
872 if (params) {
873 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
875 return true;
876 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
877 *num_written = 1;
878 if (params) {
879 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
881 return true;
882 case GL_LINE_WIDTH:
883 *num_written = 1;
884 if (params) {
885 params[0] = static_cast<GLfloat>(line_width);
887 return true;
888 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
889 *num_written = 16;
890 if (params) {
891 memcpy(params, modelview_matrix, sizeof(GLfloat) * 16);
893 return true;
894 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
895 *num_written = 16;
896 if (params) {
897 memcpy(params, projection_matrix, sizeof(GLfloat) * 16);
899 return true;
900 case GL_PACK_ALIGNMENT:
901 *num_written = 1;
902 if (params) {
903 params[0] = static_cast<GLfloat>(pack_alignment);
905 return true;
906 case GL_UNPACK_ALIGNMENT:
907 *num_written = 1;
908 if (params) {
909 params[0] = static_cast<GLfloat>(unpack_alignment);
911 return true;
912 case GL_POLYGON_OFFSET_FACTOR:
913 *num_written = 1;
914 if (params) {
915 params[0] = static_cast<GLfloat>(polygon_offset_factor);
917 return true;
918 case GL_POLYGON_OFFSET_UNITS:
919 *num_written = 1;
920 if (params) {
921 params[0] = static_cast<GLfloat>(polygon_offset_units);
923 return true;
924 case GL_SAMPLE_COVERAGE_VALUE:
925 *num_written = 1;
926 if (params) {
927 params[0] = static_cast<GLfloat>(sample_coverage_value);
929 return true;
930 case GL_SAMPLE_COVERAGE_INVERT:
931 *num_written = 1;
932 if (params) {
933 params[0] = static_cast<GLfloat>(sample_coverage_invert);
935 return true;
936 case GL_SCISSOR_BOX:
937 *num_written = 4;
938 if (params) {
939 params[0] = static_cast<GLfloat>(scissor_x);
940 params[1] = static_cast<GLfloat>(scissor_y);
941 params[2] = static_cast<GLfloat>(scissor_width);
942 params[3] = static_cast<GLfloat>(scissor_height);
944 return true;
945 case GL_STENCIL_FUNC:
946 *num_written = 1;
947 if (params) {
948 params[0] = static_cast<GLfloat>(stencil_front_func);
950 return true;
951 case GL_STENCIL_REF:
952 *num_written = 1;
953 if (params) {
954 params[0] = static_cast<GLfloat>(stencil_front_ref);
956 return true;
957 case GL_STENCIL_VALUE_MASK:
958 *num_written = 1;
959 if (params) {
960 params[0] = static_cast<GLfloat>(stencil_front_mask);
962 return true;
963 case GL_STENCIL_BACK_FUNC:
964 *num_written = 1;
965 if (params) {
966 params[0] = static_cast<GLfloat>(stencil_back_func);
968 return true;
969 case GL_STENCIL_BACK_REF:
970 *num_written = 1;
971 if (params) {
972 params[0] = static_cast<GLfloat>(stencil_back_ref);
974 return true;
975 case GL_STENCIL_BACK_VALUE_MASK:
976 *num_written = 1;
977 if (params) {
978 params[0] = static_cast<GLfloat>(stencil_back_mask);
980 return true;
981 case GL_STENCIL_WRITEMASK:
982 *num_written = 1;
983 if (params) {
984 params[0] = static_cast<GLfloat>(stencil_front_writemask);
986 return true;
987 case GL_STENCIL_BACK_WRITEMASK:
988 *num_written = 1;
989 if (params) {
990 params[0] = static_cast<GLfloat>(stencil_back_writemask);
992 return true;
993 case GL_STENCIL_FAIL:
994 *num_written = 1;
995 if (params) {
996 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
998 return true;
999 case GL_STENCIL_PASS_DEPTH_FAIL:
1000 *num_written = 1;
1001 if (params) {
1002 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
1004 return true;
1005 case GL_STENCIL_PASS_DEPTH_PASS:
1006 *num_written = 1;
1007 if (params) {
1008 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
1010 return true;
1011 case GL_STENCIL_BACK_FAIL:
1012 *num_written = 1;
1013 if (params) {
1014 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
1016 return true;
1017 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1018 *num_written = 1;
1019 if (params) {
1020 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
1022 return true;
1023 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1024 *num_written = 1;
1025 if (params) {
1026 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
1028 return true;
1029 case GL_VIEWPORT:
1030 *num_written = 4;
1031 if (params) {
1032 params[0] = static_cast<GLfloat>(viewport_x);
1033 params[1] = static_cast<GLfloat>(viewport_y);
1034 params[2] = static_cast<GLfloat>(viewport_width);
1035 params[3] = static_cast<GLfloat>(viewport_height);
1037 return true;
1038 case GL_BLEND:
1039 *num_written = 1;
1040 if (params) {
1041 params[0] = static_cast<GLfloat>(enable_flags.blend);
1043 return true;
1044 case GL_CULL_FACE:
1045 *num_written = 1;
1046 if (params) {
1047 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
1049 return true;
1050 case GL_DEPTH_TEST:
1051 *num_written = 1;
1052 if (params) {
1053 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
1055 return true;
1056 case GL_DITHER:
1057 *num_written = 1;
1058 if (params) {
1059 params[0] = static_cast<GLfloat>(enable_flags.dither);
1061 return true;
1062 case GL_POLYGON_OFFSET_FILL:
1063 *num_written = 1;
1064 if (params) {
1065 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
1067 return true;
1068 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1069 *num_written = 1;
1070 if (params) {
1071 params[0] = static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
1073 return true;
1074 case GL_SAMPLE_COVERAGE:
1075 *num_written = 1;
1076 if (params) {
1077 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
1079 return true;
1080 case GL_SCISSOR_TEST:
1081 *num_written = 1;
1082 if (params) {
1083 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
1085 return true;
1086 case GL_STENCIL_TEST:
1087 *num_written = 1;
1088 if (params) {
1089 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
1091 return true;
1092 case GL_RASTERIZER_DISCARD:
1093 *num_written = 1;
1094 if (params) {
1095 params[0] = static_cast<GLfloat>(enable_flags.rasterizer_discard);
1097 return true;
1098 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
1099 *num_written = 1;
1100 if (params) {
1101 params[0] =
1102 static_cast<GLfloat>(enable_flags.primitive_restart_fixed_index);
1104 return true;
1105 default:
1106 return false;
1109 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_