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