Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / context_state_impl_autogen.h
blobe6c63a60545bcdff1bcdb6550c78805225bb6fce
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) {
38 void ContextState::Initialize() {
39 blend_color_red = 0.0f;
40 blend_color_green = 0.0f;
41 blend_color_blue = 0.0f;
42 blend_color_alpha = 0.0f;
43 blend_equation_rgb = GL_FUNC_ADD;
44 blend_equation_alpha = GL_FUNC_ADD;
45 blend_source_rgb = GL_ONE;
46 blend_dest_rgb = GL_ZERO;
47 blend_source_alpha = GL_ONE;
48 blend_dest_alpha = GL_ZERO;
49 color_clear_red = 0.0f;
50 color_clear_green = 0.0f;
51 color_clear_blue = 0.0f;
52 color_clear_alpha = 0.0f;
53 depth_clear = 1.0f;
54 stencil_clear = 0;
55 color_mask_red = true;
56 cached_color_mask_red = true;
57 color_mask_green = true;
58 cached_color_mask_green = true;
59 color_mask_blue = true;
60 cached_color_mask_blue = true;
61 color_mask_alpha = true;
62 cached_color_mask_alpha = true;
63 cull_mode = GL_BACK;
64 depth_func = GL_LESS;
65 depth_mask = true;
66 cached_depth_mask = true;
67 z_near = 0.0f;
68 z_far = 1.0f;
69 front_face = GL_CCW;
70 hint_generate_mipmap = GL_DONT_CARE;
71 hint_fragment_shader_derivative = GL_DONT_CARE;
72 line_width = 1.0f;
73 modelview_matrix[0] = 1.0f;
74 modelview_matrix[1] = 0.0f;
75 modelview_matrix[2] = 0.0f;
76 modelview_matrix[3] = 0.0f;
77 modelview_matrix[4] = 0.0f;
78 modelview_matrix[5] = 1.0f;
79 modelview_matrix[6] = 0.0f;
80 modelview_matrix[7] = 0.0f;
81 modelview_matrix[8] = 0.0f;
82 modelview_matrix[9] = 0.0f;
83 modelview_matrix[10] = 1.0f;
84 modelview_matrix[11] = 0.0f;
85 modelview_matrix[12] = 0.0f;
86 modelview_matrix[13] = 0.0f;
87 modelview_matrix[14] = 0.0f;
88 modelview_matrix[15] = 1.0f;
89 projection_matrix[0] = 1.0f;
90 projection_matrix[1] = 0.0f;
91 projection_matrix[2] = 0.0f;
92 projection_matrix[3] = 0.0f;
93 projection_matrix[4] = 0.0f;
94 projection_matrix[5] = 1.0f;
95 projection_matrix[6] = 0.0f;
96 projection_matrix[7] = 0.0f;
97 projection_matrix[8] = 0.0f;
98 projection_matrix[9] = 0.0f;
99 projection_matrix[10] = 1.0f;
100 projection_matrix[11] = 0.0f;
101 projection_matrix[12] = 0.0f;
102 projection_matrix[13] = 0.0f;
103 projection_matrix[14] = 0.0f;
104 projection_matrix[15] = 1.0f;
105 pack_alignment = 4;
106 unpack_alignment = 4;
107 polygon_offset_factor = 0.0f;
108 polygon_offset_units = 0.0f;
109 sample_coverage_value = 1.0f;
110 sample_coverage_invert = false;
111 scissor_x = 0;
112 scissor_y = 0;
113 scissor_width = 1;
114 scissor_height = 1;
115 stencil_front_func = GL_ALWAYS;
116 stencil_front_ref = 0;
117 stencil_front_mask = 0xFFFFFFFFU;
118 stencil_back_func = GL_ALWAYS;
119 stencil_back_ref = 0;
120 stencil_back_mask = 0xFFFFFFFFU;
121 stencil_front_writemask = 0xFFFFFFFFU;
122 cached_stencil_front_writemask = 0xFFFFFFFFU;
123 stencil_back_writemask = 0xFFFFFFFFU;
124 cached_stencil_back_writemask = 0xFFFFFFFFU;
125 stencil_front_fail_op = GL_KEEP;
126 stencil_front_z_fail_op = GL_KEEP;
127 stencil_front_z_pass_op = GL_KEEP;
128 stencil_back_fail_op = GL_KEEP;
129 stencil_back_z_fail_op = GL_KEEP;
130 stencil_back_z_pass_op = GL_KEEP;
131 viewport_x = 0;
132 viewport_y = 0;
133 viewport_width = 1;
134 viewport_height = 1;
137 void ContextState::InitCapabilities(const ContextState* prev_state) const {
138 if (prev_state) {
139 if (prev_state->enable_flags.cached_blend != enable_flags.cached_blend) {
140 EnableDisable(GL_BLEND, enable_flags.cached_blend);
142 if (prev_state->enable_flags.cached_cull_face !=
143 enable_flags.cached_cull_face) {
144 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
146 if (prev_state->enable_flags.cached_depth_test !=
147 enable_flags.cached_depth_test) {
148 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
150 if (prev_state->enable_flags.cached_dither != enable_flags.cached_dither) {
151 EnableDisable(GL_DITHER, enable_flags.cached_dither);
153 if (prev_state->enable_flags.cached_polygon_offset_fill !=
154 enable_flags.cached_polygon_offset_fill) {
155 EnableDisable(GL_POLYGON_OFFSET_FILL,
156 enable_flags.cached_polygon_offset_fill);
158 if (prev_state->enable_flags.cached_sample_alpha_to_coverage !=
159 enable_flags.cached_sample_alpha_to_coverage) {
160 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
161 enable_flags.cached_sample_alpha_to_coverage);
163 if (prev_state->enable_flags.cached_sample_coverage !=
164 enable_flags.cached_sample_coverage) {
165 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
167 if (prev_state->enable_flags.cached_scissor_test !=
168 enable_flags.cached_scissor_test) {
169 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
171 if (prev_state->enable_flags.cached_stencil_test !=
172 enable_flags.cached_stencil_test) {
173 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
175 if (feature_info_->IsES3Capable()) {
176 if (prev_state->enable_flags.cached_rasterizer_discard !=
177 enable_flags.cached_rasterizer_discard) {
178 EnableDisable(GL_RASTERIZER_DISCARD,
179 enable_flags.cached_rasterizer_discard);
182 } else {
183 EnableDisable(GL_BLEND, enable_flags.cached_blend);
184 EnableDisable(GL_CULL_FACE, enable_flags.cached_cull_face);
185 EnableDisable(GL_DEPTH_TEST, enable_flags.cached_depth_test);
186 EnableDisable(GL_DITHER, enable_flags.cached_dither);
187 EnableDisable(GL_POLYGON_OFFSET_FILL,
188 enable_flags.cached_polygon_offset_fill);
189 EnableDisable(GL_SAMPLE_ALPHA_TO_COVERAGE,
190 enable_flags.cached_sample_alpha_to_coverage);
191 EnableDisable(GL_SAMPLE_COVERAGE, enable_flags.cached_sample_coverage);
192 EnableDisable(GL_SCISSOR_TEST, enable_flags.cached_scissor_test);
193 EnableDisable(GL_STENCIL_TEST, enable_flags.cached_stencil_test);
194 if (feature_info_->IsES3Capable()) {
195 EnableDisable(GL_RASTERIZER_DISCARD,
196 enable_flags.cached_rasterizer_discard);
201 void ContextState::InitState(const ContextState* prev_state) const {
202 if (prev_state) {
203 if ((blend_color_red != prev_state->blend_color_red) ||
204 (blend_color_green != prev_state->blend_color_green) ||
205 (blend_color_blue != prev_state->blend_color_blue) ||
206 (blend_color_alpha != prev_state->blend_color_alpha))
207 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
208 blend_color_alpha);
209 if ((blend_equation_rgb != prev_state->blend_equation_rgb) ||
210 (blend_equation_alpha != prev_state->blend_equation_alpha))
211 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
212 if ((blend_source_rgb != prev_state->blend_source_rgb) ||
213 (blend_dest_rgb != prev_state->blend_dest_rgb) ||
214 (blend_source_alpha != prev_state->blend_source_alpha) ||
215 (blend_dest_alpha != prev_state->blend_dest_alpha))
216 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
217 blend_dest_alpha);
218 if ((color_clear_red != prev_state->color_clear_red) ||
219 (color_clear_green != prev_state->color_clear_green) ||
220 (color_clear_blue != prev_state->color_clear_blue) ||
221 (color_clear_alpha != prev_state->color_clear_alpha))
222 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
223 color_clear_alpha);
224 if ((depth_clear != prev_state->depth_clear))
225 glClearDepth(depth_clear);
226 if ((stencil_clear != prev_state->stencil_clear))
227 glClearStencil(stencil_clear);
228 if ((cached_color_mask_red != prev_state->cached_color_mask_red) ||
229 (cached_color_mask_green != prev_state->cached_color_mask_green) ||
230 (cached_color_mask_blue != prev_state->cached_color_mask_blue) ||
231 (cached_color_mask_alpha != prev_state->cached_color_mask_alpha))
232 glColorMask(cached_color_mask_red, cached_color_mask_green,
233 cached_color_mask_blue, cached_color_mask_alpha);
234 if ((cull_mode != prev_state->cull_mode))
235 glCullFace(cull_mode);
236 if ((depth_func != prev_state->depth_func))
237 glDepthFunc(depth_func);
238 if ((cached_depth_mask != prev_state->cached_depth_mask))
239 glDepthMask(cached_depth_mask);
240 if ((z_near != prev_state->z_near) || (z_far != prev_state->z_far))
241 glDepthRange(z_near, z_far);
242 if ((front_face != prev_state->front_face))
243 glFrontFace(front_face);
244 if (prev_state->hint_generate_mipmap != hint_generate_mipmap) {
245 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
246 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
249 if (feature_info_->feature_flags().oes_standard_derivatives) {
250 if (prev_state->hint_fragment_shader_derivative !=
251 hint_fragment_shader_derivative) {
252 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
253 hint_fragment_shader_derivative);
256 if ((line_width != prev_state->line_width))
257 glLineWidth(line_width);
258 if (feature_info_->feature_flags().chromium_path_rendering) {
259 if (memcmp(prev_state->modelview_matrix, modelview_matrix,
260 sizeof(GLfloat) * 16)) {
261 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
264 if (feature_info_->feature_flags().chromium_path_rendering) {
265 if (memcmp(prev_state->projection_matrix, projection_matrix,
266 sizeof(GLfloat) * 16)) {
267 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
270 if (prev_state->pack_alignment != pack_alignment) {
271 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
273 if (prev_state->unpack_alignment != unpack_alignment) {
274 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
276 if ((polygon_offset_factor != prev_state->polygon_offset_factor) ||
277 (polygon_offset_units != prev_state->polygon_offset_units))
278 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
279 if ((sample_coverage_value != prev_state->sample_coverage_value) ||
280 (sample_coverage_invert != prev_state->sample_coverage_invert))
281 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
282 if ((scissor_x != prev_state->scissor_x) ||
283 (scissor_y != prev_state->scissor_y) ||
284 (scissor_width != prev_state->scissor_width) ||
285 (scissor_height != prev_state->scissor_height))
286 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
287 if ((stencil_front_func != prev_state->stencil_front_func) ||
288 (stencil_front_ref != prev_state->stencil_front_ref) ||
289 (stencil_front_mask != prev_state->stencil_front_mask))
290 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
291 stencil_front_mask);
292 if ((stencil_back_func != prev_state->stencil_back_func) ||
293 (stencil_back_ref != prev_state->stencil_back_ref) ||
294 (stencil_back_mask != prev_state->stencil_back_mask))
295 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
296 stencil_back_mask);
297 if ((cached_stencil_front_writemask !=
298 prev_state->cached_stencil_front_writemask))
299 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
300 if ((cached_stencil_back_writemask !=
301 prev_state->cached_stencil_back_writemask))
302 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
303 if ((stencil_front_fail_op != prev_state->stencil_front_fail_op) ||
304 (stencil_front_z_fail_op != prev_state->stencil_front_z_fail_op) ||
305 (stencil_front_z_pass_op != prev_state->stencil_front_z_pass_op))
306 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
307 stencil_front_z_fail_op, stencil_front_z_pass_op);
308 if ((stencil_back_fail_op != prev_state->stencil_back_fail_op) ||
309 (stencil_back_z_fail_op != prev_state->stencil_back_z_fail_op) ||
310 (stencil_back_z_pass_op != prev_state->stencil_back_z_pass_op))
311 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
312 stencil_back_z_pass_op);
313 if ((viewport_x != prev_state->viewport_x) ||
314 (viewport_y != prev_state->viewport_y) ||
315 (viewport_width != prev_state->viewport_width) ||
316 (viewport_height != prev_state->viewport_height))
317 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
318 } else {
319 glBlendColor(blend_color_red, blend_color_green, blend_color_blue,
320 blend_color_alpha);
321 glBlendEquationSeparate(blend_equation_rgb, blend_equation_alpha);
322 glBlendFuncSeparate(blend_source_rgb, blend_dest_rgb, blend_source_alpha,
323 blend_dest_alpha);
324 glClearColor(color_clear_red, color_clear_green, color_clear_blue,
325 color_clear_alpha);
326 glClearDepth(depth_clear);
327 glClearStencil(stencil_clear);
328 glColorMask(cached_color_mask_red, cached_color_mask_green,
329 cached_color_mask_blue, cached_color_mask_alpha);
330 glCullFace(cull_mode);
331 glDepthFunc(depth_func);
332 glDepthMask(cached_depth_mask);
333 glDepthRange(z_near, z_far);
334 glFrontFace(front_face);
335 if (!feature_info_->gl_version_info().is_desktop_core_profile) {
336 glHint(GL_GENERATE_MIPMAP_HINT, hint_generate_mipmap);
338 if (feature_info_->feature_flags().oes_standard_derivatives) {
339 glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
340 hint_fragment_shader_derivative);
342 glLineWidth(line_width);
343 if (feature_info_->feature_flags().chromium_path_rendering) {
344 glMatrixLoadfEXT(GL_PATH_MODELVIEW_CHROMIUM, modelview_matrix);
346 if (feature_info_->feature_flags().chromium_path_rendering) {
347 glMatrixLoadfEXT(GL_PATH_PROJECTION_CHROMIUM, projection_matrix);
349 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
350 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment);
351 glPolygonOffset(polygon_offset_factor, polygon_offset_units);
352 glSampleCoverage(sample_coverage_value, sample_coverage_invert);
353 glScissor(scissor_x, scissor_y, scissor_width, scissor_height);
354 glStencilFuncSeparate(GL_FRONT, stencil_front_func, stencil_front_ref,
355 stencil_front_mask);
356 glStencilFuncSeparate(GL_BACK, stencil_back_func, stencil_back_ref,
357 stencil_back_mask);
358 glStencilMaskSeparate(GL_FRONT, cached_stencil_front_writemask);
359 glStencilMaskSeparate(GL_BACK, cached_stencil_back_writemask);
360 glStencilOpSeparate(GL_FRONT, stencil_front_fail_op,
361 stencil_front_z_fail_op, stencil_front_z_pass_op);
362 glStencilOpSeparate(GL_BACK, stencil_back_fail_op, stencil_back_z_fail_op,
363 stencil_back_z_pass_op);
364 glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
367 bool ContextState::GetEnabled(GLenum cap) const {
368 switch (cap) {
369 case GL_BLEND:
370 return enable_flags.blend;
371 case GL_CULL_FACE:
372 return enable_flags.cull_face;
373 case GL_DEPTH_TEST:
374 return enable_flags.depth_test;
375 case GL_DITHER:
376 return enable_flags.dither;
377 case GL_POLYGON_OFFSET_FILL:
378 return enable_flags.polygon_offset_fill;
379 case GL_SAMPLE_ALPHA_TO_COVERAGE:
380 return enable_flags.sample_alpha_to_coverage;
381 case GL_SAMPLE_COVERAGE:
382 return enable_flags.sample_coverage;
383 case GL_SCISSOR_TEST:
384 return enable_flags.scissor_test;
385 case GL_STENCIL_TEST:
386 return enable_flags.stencil_test;
387 case GL_RASTERIZER_DISCARD:
388 return enable_flags.rasterizer_discard;
389 default:
390 NOTREACHED();
391 return false;
395 bool ContextState::GetStateAsGLint(GLenum pname,
396 GLint* params,
397 GLsizei* num_written) const {
398 switch (pname) {
399 case GL_BLEND_COLOR:
400 *num_written = 4;
401 if (params) {
402 params[0] = static_cast<GLint>(blend_color_red);
403 params[1] = static_cast<GLint>(blend_color_green);
404 params[2] = static_cast<GLint>(blend_color_blue);
405 params[3] = static_cast<GLint>(blend_color_alpha);
407 return true;
408 case GL_BLEND_EQUATION_RGB:
409 *num_written = 1;
410 if (params) {
411 params[0] = static_cast<GLint>(blend_equation_rgb);
413 return true;
414 case GL_BLEND_EQUATION_ALPHA:
415 *num_written = 1;
416 if (params) {
417 params[0] = static_cast<GLint>(blend_equation_alpha);
419 return true;
420 case GL_BLEND_SRC_RGB:
421 *num_written = 1;
422 if (params) {
423 params[0] = static_cast<GLint>(blend_source_rgb);
425 return true;
426 case GL_BLEND_DST_RGB:
427 *num_written = 1;
428 if (params) {
429 params[0] = static_cast<GLint>(blend_dest_rgb);
431 return true;
432 case GL_BLEND_SRC_ALPHA:
433 *num_written = 1;
434 if (params) {
435 params[0] = static_cast<GLint>(blend_source_alpha);
437 return true;
438 case GL_BLEND_DST_ALPHA:
439 *num_written = 1;
440 if (params) {
441 params[0] = static_cast<GLint>(blend_dest_alpha);
443 return true;
444 case GL_COLOR_CLEAR_VALUE:
445 *num_written = 4;
446 if (params) {
447 params[0] = static_cast<GLint>(color_clear_red);
448 params[1] = static_cast<GLint>(color_clear_green);
449 params[2] = static_cast<GLint>(color_clear_blue);
450 params[3] = static_cast<GLint>(color_clear_alpha);
452 return true;
453 case GL_DEPTH_CLEAR_VALUE:
454 *num_written = 1;
455 if (params) {
456 params[0] = static_cast<GLint>(depth_clear);
458 return true;
459 case GL_STENCIL_CLEAR_VALUE:
460 *num_written = 1;
461 if (params) {
462 params[0] = static_cast<GLint>(stencil_clear);
464 return true;
465 case GL_COLOR_WRITEMASK:
466 *num_written = 4;
467 if (params) {
468 params[0] = static_cast<GLint>(color_mask_red);
469 params[1] = static_cast<GLint>(color_mask_green);
470 params[2] = static_cast<GLint>(color_mask_blue);
471 params[3] = static_cast<GLint>(color_mask_alpha);
473 return true;
474 case GL_CULL_FACE_MODE:
475 *num_written = 1;
476 if (params) {
477 params[0] = static_cast<GLint>(cull_mode);
479 return true;
480 case GL_DEPTH_FUNC:
481 *num_written = 1;
482 if (params) {
483 params[0] = static_cast<GLint>(depth_func);
485 return true;
486 case GL_DEPTH_WRITEMASK:
487 *num_written = 1;
488 if (params) {
489 params[0] = static_cast<GLint>(depth_mask);
491 return true;
492 case GL_DEPTH_RANGE:
493 *num_written = 2;
494 if (params) {
495 params[0] = static_cast<GLint>(z_near);
496 params[1] = static_cast<GLint>(z_far);
498 return true;
499 case GL_FRONT_FACE:
500 *num_written = 1;
501 if (params) {
502 params[0] = static_cast<GLint>(front_face);
504 return true;
505 case GL_GENERATE_MIPMAP_HINT:
506 *num_written = 1;
507 if (params) {
508 params[0] = static_cast<GLint>(hint_generate_mipmap);
510 return true;
511 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
512 *num_written = 1;
513 if (params) {
514 params[0] = static_cast<GLint>(hint_fragment_shader_derivative);
516 return true;
517 case GL_LINE_WIDTH:
518 *num_written = 1;
519 if (params) {
520 params[0] = static_cast<GLint>(line_width);
522 return true;
523 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
524 *num_written = 16;
525 if (params) {
526 for (size_t i = 0; i < 16; ++i) {
527 params[i] = static_cast<GLint>(round(modelview_matrix[i]));
530 return true;
531 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
532 *num_written = 16;
533 if (params) {
534 for (size_t i = 0; i < 16; ++i) {
535 params[i] = static_cast<GLint>(round(projection_matrix[i]));
538 return true;
539 case GL_PACK_ALIGNMENT:
540 *num_written = 1;
541 if (params) {
542 params[0] = static_cast<GLint>(pack_alignment);
544 return true;
545 case GL_UNPACK_ALIGNMENT:
546 *num_written = 1;
547 if (params) {
548 params[0] = static_cast<GLint>(unpack_alignment);
550 return true;
551 case GL_POLYGON_OFFSET_FACTOR:
552 *num_written = 1;
553 if (params) {
554 params[0] = static_cast<GLint>(round(polygon_offset_factor));
556 return true;
557 case GL_POLYGON_OFFSET_UNITS:
558 *num_written = 1;
559 if (params) {
560 params[0] = static_cast<GLint>(round(polygon_offset_units));
562 return true;
563 case GL_SAMPLE_COVERAGE_VALUE:
564 *num_written = 1;
565 if (params) {
566 params[0] = static_cast<GLint>(sample_coverage_value);
568 return true;
569 case GL_SAMPLE_COVERAGE_INVERT:
570 *num_written = 1;
571 if (params) {
572 params[0] = static_cast<GLint>(sample_coverage_invert);
574 return true;
575 case GL_SCISSOR_BOX:
576 *num_written = 4;
577 if (params) {
578 params[0] = static_cast<GLint>(scissor_x);
579 params[1] = static_cast<GLint>(scissor_y);
580 params[2] = static_cast<GLint>(scissor_width);
581 params[3] = static_cast<GLint>(scissor_height);
583 return true;
584 case GL_STENCIL_FUNC:
585 *num_written = 1;
586 if (params) {
587 params[0] = static_cast<GLint>(stencil_front_func);
589 return true;
590 case GL_STENCIL_REF:
591 *num_written = 1;
592 if (params) {
593 params[0] = static_cast<GLint>(stencil_front_ref);
595 return true;
596 case GL_STENCIL_VALUE_MASK:
597 *num_written = 1;
598 if (params) {
599 params[0] = static_cast<GLint>(stencil_front_mask);
601 return true;
602 case GL_STENCIL_BACK_FUNC:
603 *num_written = 1;
604 if (params) {
605 params[0] = static_cast<GLint>(stencil_back_func);
607 return true;
608 case GL_STENCIL_BACK_REF:
609 *num_written = 1;
610 if (params) {
611 params[0] = static_cast<GLint>(stencil_back_ref);
613 return true;
614 case GL_STENCIL_BACK_VALUE_MASK:
615 *num_written = 1;
616 if (params) {
617 params[0] = static_cast<GLint>(stencil_back_mask);
619 return true;
620 case GL_STENCIL_WRITEMASK:
621 *num_written = 1;
622 if (params) {
623 params[0] = static_cast<GLint>(stencil_front_writemask);
625 return true;
626 case GL_STENCIL_BACK_WRITEMASK:
627 *num_written = 1;
628 if (params) {
629 params[0] = static_cast<GLint>(stencil_back_writemask);
631 return true;
632 case GL_STENCIL_FAIL:
633 *num_written = 1;
634 if (params) {
635 params[0] = static_cast<GLint>(stencil_front_fail_op);
637 return true;
638 case GL_STENCIL_PASS_DEPTH_FAIL:
639 *num_written = 1;
640 if (params) {
641 params[0] = static_cast<GLint>(stencil_front_z_fail_op);
643 return true;
644 case GL_STENCIL_PASS_DEPTH_PASS:
645 *num_written = 1;
646 if (params) {
647 params[0] = static_cast<GLint>(stencil_front_z_pass_op);
649 return true;
650 case GL_STENCIL_BACK_FAIL:
651 *num_written = 1;
652 if (params) {
653 params[0] = static_cast<GLint>(stencil_back_fail_op);
655 return true;
656 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
657 *num_written = 1;
658 if (params) {
659 params[0] = static_cast<GLint>(stencil_back_z_fail_op);
661 return true;
662 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
663 *num_written = 1;
664 if (params) {
665 params[0] = static_cast<GLint>(stencil_back_z_pass_op);
667 return true;
668 case GL_VIEWPORT:
669 *num_written = 4;
670 if (params) {
671 params[0] = static_cast<GLint>(viewport_x);
672 params[1] = static_cast<GLint>(viewport_y);
673 params[2] = static_cast<GLint>(viewport_width);
674 params[3] = static_cast<GLint>(viewport_height);
676 return true;
677 case GL_BLEND:
678 *num_written = 1;
679 if (params) {
680 params[0] = static_cast<GLint>(enable_flags.blend);
682 return true;
683 case GL_CULL_FACE:
684 *num_written = 1;
685 if (params) {
686 params[0] = static_cast<GLint>(enable_flags.cull_face);
688 return true;
689 case GL_DEPTH_TEST:
690 *num_written = 1;
691 if (params) {
692 params[0] = static_cast<GLint>(enable_flags.depth_test);
694 return true;
695 case GL_DITHER:
696 *num_written = 1;
697 if (params) {
698 params[0] = static_cast<GLint>(enable_flags.dither);
700 return true;
701 case GL_POLYGON_OFFSET_FILL:
702 *num_written = 1;
703 if (params) {
704 params[0] = static_cast<GLint>(enable_flags.polygon_offset_fill);
706 return true;
707 case GL_SAMPLE_ALPHA_TO_COVERAGE:
708 *num_written = 1;
709 if (params) {
710 params[0] = static_cast<GLint>(enable_flags.sample_alpha_to_coverage);
712 return true;
713 case GL_SAMPLE_COVERAGE:
714 *num_written = 1;
715 if (params) {
716 params[0] = static_cast<GLint>(enable_flags.sample_coverage);
718 return true;
719 case GL_SCISSOR_TEST:
720 *num_written = 1;
721 if (params) {
722 params[0] = static_cast<GLint>(enable_flags.scissor_test);
724 return true;
725 case GL_STENCIL_TEST:
726 *num_written = 1;
727 if (params) {
728 params[0] = static_cast<GLint>(enable_flags.stencil_test);
730 return true;
731 case GL_RASTERIZER_DISCARD:
732 *num_written = 1;
733 if (params) {
734 params[0] = static_cast<GLint>(enable_flags.rasterizer_discard);
736 return true;
737 default:
738 return false;
742 bool ContextState::GetStateAsGLfloat(GLenum pname,
743 GLfloat* params,
744 GLsizei* num_written) const {
745 switch (pname) {
746 case GL_BLEND_COLOR:
747 *num_written = 4;
748 if (params) {
749 params[0] = static_cast<GLfloat>(blend_color_red);
750 params[1] = static_cast<GLfloat>(blend_color_green);
751 params[2] = static_cast<GLfloat>(blend_color_blue);
752 params[3] = static_cast<GLfloat>(blend_color_alpha);
754 return true;
755 case GL_BLEND_EQUATION_RGB:
756 *num_written = 1;
757 if (params) {
758 params[0] = static_cast<GLfloat>(blend_equation_rgb);
760 return true;
761 case GL_BLEND_EQUATION_ALPHA:
762 *num_written = 1;
763 if (params) {
764 params[0] = static_cast<GLfloat>(blend_equation_alpha);
766 return true;
767 case GL_BLEND_SRC_RGB:
768 *num_written = 1;
769 if (params) {
770 params[0] = static_cast<GLfloat>(blend_source_rgb);
772 return true;
773 case GL_BLEND_DST_RGB:
774 *num_written = 1;
775 if (params) {
776 params[0] = static_cast<GLfloat>(blend_dest_rgb);
778 return true;
779 case GL_BLEND_SRC_ALPHA:
780 *num_written = 1;
781 if (params) {
782 params[0] = static_cast<GLfloat>(blend_source_alpha);
784 return true;
785 case GL_BLEND_DST_ALPHA:
786 *num_written = 1;
787 if (params) {
788 params[0] = static_cast<GLfloat>(blend_dest_alpha);
790 return true;
791 case GL_COLOR_CLEAR_VALUE:
792 *num_written = 4;
793 if (params) {
794 params[0] = static_cast<GLfloat>(color_clear_red);
795 params[1] = static_cast<GLfloat>(color_clear_green);
796 params[2] = static_cast<GLfloat>(color_clear_blue);
797 params[3] = static_cast<GLfloat>(color_clear_alpha);
799 return true;
800 case GL_DEPTH_CLEAR_VALUE:
801 *num_written = 1;
802 if (params) {
803 params[0] = static_cast<GLfloat>(depth_clear);
805 return true;
806 case GL_STENCIL_CLEAR_VALUE:
807 *num_written = 1;
808 if (params) {
809 params[0] = static_cast<GLfloat>(stencil_clear);
811 return true;
812 case GL_COLOR_WRITEMASK:
813 *num_written = 4;
814 if (params) {
815 params[0] = static_cast<GLfloat>(color_mask_red);
816 params[1] = static_cast<GLfloat>(color_mask_green);
817 params[2] = static_cast<GLfloat>(color_mask_blue);
818 params[3] = static_cast<GLfloat>(color_mask_alpha);
820 return true;
821 case GL_CULL_FACE_MODE:
822 *num_written = 1;
823 if (params) {
824 params[0] = static_cast<GLfloat>(cull_mode);
826 return true;
827 case GL_DEPTH_FUNC:
828 *num_written = 1;
829 if (params) {
830 params[0] = static_cast<GLfloat>(depth_func);
832 return true;
833 case GL_DEPTH_WRITEMASK:
834 *num_written = 1;
835 if (params) {
836 params[0] = static_cast<GLfloat>(depth_mask);
838 return true;
839 case GL_DEPTH_RANGE:
840 *num_written = 2;
841 if (params) {
842 params[0] = static_cast<GLfloat>(z_near);
843 params[1] = static_cast<GLfloat>(z_far);
845 return true;
846 case GL_FRONT_FACE:
847 *num_written = 1;
848 if (params) {
849 params[0] = static_cast<GLfloat>(front_face);
851 return true;
852 case GL_GENERATE_MIPMAP_HINT:
853 *num_written = 1;
854 if (params) {
855 params[0] = static_cast<GLfloat>(hint_generate_mipmap);
857 return true;
858 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
859 *num_written = 1;
860 if (params) {
861 params[0] = static_cast<GLfloat>(hint_fragment_shader_derivative);
863 return true;
864 case GL_LINE_WIDTH:
865 *num_written = 1;
866 if (params) {
867 params[0] = static_cast<GLfloat>(line_width);
869 return true;
870 case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
871 *num_written = 16;
872 if (params) {
873 memcpy(params, modelview_matrix, sizeof(GLfloat) * 16);
875 return true;
876 case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
877 *num_written = 16;
878 if (params) {
879 memcpy(params, projection_matrix, sizeof(GLfloat) * 16);
881 return true;
882 case GL_PACK_ALIGNMENT:
883 *num_written = 1;
884 if (params) {
885 params[0] = static_cast<GLfloat>(pack_alignment);
887 return true;
888 case GL_UNPACK_ALIGNMENT:
889 *num_written = 1;
890 if (params) {
891 params[0] = static_cast<GLfloat>(unpack_alignment);
893 return true;
894 case GL_POLYGON_OFFSET_FACTOR:
895 *num_written = 1;
896 if (params) {
897 params[0] = static_cast<GLfloat>(polygon_offset_factor);
899 return true;
900 case GL_POLYGON_OFFSET_UNITS:
901 *num_written = 1;
902 if (params) {
903 params[0] = static_cast<GLfloat>(polygon_offset_units);
905 return true;
906 case GL_SAMPLE_COVERAGE_VALUE:
907 *num_written = 1;
908 if (params) {
909 params[0] = static_cast<GLfloat>(sample_coverage_value);
911 return true;
912 case GL_SAMPLE_COVERAGE_INVERT:
913 *num_written = 1;
914 if (params) {
915 params[0] = static_cast<GLfloat>(sample_coverage_invert);
917 return true;
918 case GL_SCISSOR_BOX:
919 *num_written = 4;
920 if (params) {
921 params[0] = static_cast<GLfloat>(scissor_x);
922 params[1] = static_cast<GLfloat>(scissor_y);
923 params[2] = static_cast<GLfloat>(scissor_width);
924 params[3] = static_cast<GLfloat>(scissor_height);
926 return true;
927 case GL_STENCIL_FUNC:
928 *num_written = 1;
929 if (params) {
930 params[0] = static_cast<GLfloat>(stencil_front_func);
932 return true;
933 case GL_STENCIL_REF:
934 *num_written = 1;
935 if (params) {
936 params[0] = static_cast<GLfloat>(stencil_front_ref);
938 return true;
939 case GL_STENCIL_VALUE_MASK:
940 *num_written = 1;
941 if (params) {
942 params[0] = static_cast<GLfloat>(stencil_front_mask);
944 return true;
945 case GL_STENCIL_BACK_FUNC:
946 *num_written = 1;
947 if (params) {
948 params[0] = static_cast<GLfloat>(stencil_back_func);
950 return true;
951 case GL_STENCIL_BACK_REF:
952 *num_written = 1;
953 if (params) {
954 params[0] = static_cast<GLfloat>(stencil_back_ref);
956 return true;
957 case GL_STENCIL_BACK_VALUE_MASK:
958 *num_written = 1;
959 if (params) {
960 params[0] = static_cast<GLfloat>(stencil_back_mask);
962 return true;
963 case GL_STENCIL_WRITEMASK:
964 *num_written = 1;
965 if (params) {
966 params[0] = static_cast<GLfloat>(stencil_front_writemask);
968 return true;
969 case GL_STENCIL_BACK_WRITEMASK:
970 *num_written = 1;
971 if (params) {
972 params[0] = static_cast<GLfloat>(stencil_back_writemask);
974 return true;
975 case GL_STENCIL_FAIL:
976 *num_written = 1;
977 if (params) {
978 params[0] = static_cast<GLfloat>(stencil_front_fail_op);
980 return true;
981 case GL_STENCIL_PASS_DEPTH_FAIL:
982 *num_written = 1;
983 if (params) {
984 params[0] = static_cast<GLfloat>(stencil_front_z_fail_op);
986 return true;
987 case GL_STENCIL_PASS_DEPTH_PASS:
988 *num_written = 1;
989 if (params) {
990 params[0] = static_cast<GLfloat>(stencil_front_z_pass_op);
992 return true;
993 case GL_STENCIL_BACK_FAIL:
994 *num_written = 1;
995 if (params) {
996 params[0] = static_cast<GLfloat>(stencil_back_fail_op);
998 return true;
999 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1000 *num_written = 1;
1001 if (params) {
1002 params[0] = static_cast<GLfloat>(stencil_back_z_fail_op);
1004 return true;
1005 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1006 *num_written = 1;
1007 if (params) {
1008 params[0] = static_cast<GLfloat>(stencil_back_z_pass_op);
1010 return true;
1011 case GL_VIEWPORT:
1012 *num_written = 4;
1013 if (params) {
1014 params[0] = static_cast<GLfloat>(viewport_x);
1015 params[1] = static_cast<GLfloat>(viewport_y);
1016 params[2] = static_cast<GLfloat>(viewport_width);
1017 params[3] = static_cast<GLfloat>(viewport_height);
1019 return true;
1020 case GL_BLEND:
1021 *num_written = 1;
1022 if (params) {
1023 params[0] = static_cast<GLfloat>(enable_flags.blend);
1025 return true;
1026 case GL_CULL_FACE:
1027 *num_written = 1;
1028 if (params) {
1029 params[0] = static_cast<GLfloat>(enable_flags.cull_face);
1031 return true;
1032 case GL_DEPTH_TEST:
1033 *num_written = 1;
1034 if (params) {
1035 params[0] = static_cast<GLfloat>(enable_flags.depth_test);
1037 return true;
1038 case GL_DITHER:
1039 *num_written = 1;
1040 if (params) {
1041 params[0] = static_cast<GLfloat>(enable_flags.dither);
1043 return true;
1044 case GL_POLYGON_OFFSET_FILL:
1045 *num_written = 1;
1046 if (params) {
1047 params[0] = static_cast<GLfloat>(enable_flags.polygon_offset_fill);
1049 return true;
1050 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1051 *num_written = 1;
1052 if (params) {
1053 params[0] = static_cast<GLfloat>(enable_flags.sample_alpha_to_coverage);
1055 return true;
1056 case GL_SAMPLE_COVERAGE:
1057 *num_written = 1;
1058 if (params) {
1059 params[0] = static_cast<GLfloat>(enable_flags.sample_coverage);
1061 return true;
1062 case GL_SCISSOR_TEST:
1063 *num_written = 1;
1064 if (params) {
1065 params[0] = static_cast<GLfloat>(enable_flags.scissor_test);
1067 return true;
1068 case GL_STENCIL_TEST:
1069 *num_written = 1;
1070 if (params) {
1071 params[0] = static_cast<GLfloat>(enable_flags.stencil_test);
1073 return true;
1074 case GL_RASTERIZER_DISCARD:
1075 *num_written = 1;
1076 if (params) {
1077 params[0] = static_cast<GLfloat>(enable_flags.rasterizer_discard);
1079 return true;
1080 default:
1081 return false;
1084 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_IMPL_AUTOGEN_H_