OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 // does not overflow the uniform. | 964 // does not overflow the uniform. |
965 bool PrepForSetUniformByLocation( | 965 bool PrepForSetUniformByLocation( |
966 GLint fake_location, const char* function_name, | 966 GLint fake_location, const char* function_name, |
967 GLint* real_location, GLenum* type, GLsizei* count); | 967 GLint* real_location, GLenum* type, GLsizei* count); |
968 | 968 |
969 // Gets the service id for any simulated backbuffer fbo. | 969 // Gets the service id for any simulated backbuffer fbo. |
970 GLuint GetBackbufferServiceId(); | 970 GLuint GetBackbufferServiceId(); |
971 | 971 |
972 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv | 972 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv |
973 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); | 973 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); |
| 974 // Same as GetHelper except for auto-generated state. |
| 975 bool GetState(GLenum pname, GLint* params, GLsizei* num_written); |
974 | 976 |
975 // Wrapper for glCreateProgram | 977 // Wrapper for glCreateProgram |
976 bool CreateProgramHelper(GLuint client_id); | 978 bool CreateProgramHelper(GLuint client_id); |
977 | 979 |
978 // Wrapper for glCreateShader | 980 // Wrapper for glCreateShader |
979 bool CreateShaderHelper(GLenum type, GLuint client_id); | 981 bool CreateShaderHelper(GLenum type, GLuint client_id); |
980 | 982 |
981 // Wrapper for glActiveTexture | 983 // Wrapper for glActiveTexture |
982 void DoActiveTexture(GLenum texture_unit); | 984 void DoActiveTexture(GLenum texture_unit); |
983 | 985 |
(...skipping 29 matching lines...) Expand all Loading... |
1013 // Wrapper for glBufferSubData. | 1015 // Wrapper for glBufferSubData. |
1014 void DoBufferSubData( | 1016 void DoBufferSubData( |
1015 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); | 1017 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); |
1016 | 1018 |
1017 // Wrapper for glCheckFramebufferStatus | 1019 // Wrapper for glCheckFramebufferStatus |
1018 GLenum DoCheckFramebufferStatus(GLenum target); | 1020 GLenum DoCheckFramebufferStatus(GLenum target); |
1019 | 1021 |
1020 // Wrapper for glClear | 1022 // Wrapper for glClear |
1021 error::Error DoClear(GLbitfield mask); | 1023 error::Error DoClear(GLbitfield mask); |
1022 | 1024 |
1023 // Wrappers for clear and mask settings functions. | |
1024 void DoStencilMask(GLuint mask); | |
1025 void DoStencilMaskSeparate(GLenum face, GLuint mask); | |
1026 void DoStencilFunc(GLenum func, GLint ref, GLuint mask); | |
1027 void DoStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); | |
1028 void DoStencilOp(GLenum fail, GLenum zfail, GLenum zpass); | |
1029 void DoStencilOpSeparate( | |
1030 GLenum face, GLenum fail, GLenum zfail, GLenum zpass); | |
1031 | |
1032 // Wrappers for various state. | 1025 // Wrappers for various state. |
1033 void DoBlendEquation(GLenum mode); | |
1034 void DoBlendFunc(GLenum sfactor, GLenum dfactor); | |
1035 void DoDepthRangef(GLclampf znear, GLclampf zfar); | 1026 void DoDepthRangef(GLclampf znear, GLclampf zfar); |
1036 void DoHint(GLenum target, GLenum mode); | 1027 void DoHint(GLenum target, GLenum mode); |
1037 void DoSampleCoverage (GLclampf value, GLboolean invert); | 1028 void DoSampleCoverage (GLclampf value, GLboolean invert); |
1038 | 1029 |
1039 // Wrapper for glCompileShader. | 1030 // Wrapper for glCompileShader. |
1040 void DoCompileShader(GLuint shader); | 1031 void DoCompileShader(GLuint shader); |
1041 | 1032 |
1042 // Helper for DeleteSharedIdsCHROMIUM commands. | 1033 // Helper for DeleteSharedIdsCHROMIUM commands. |
1043 void DoDeleteSharedIdsCHROMIUM( | 1034 void DoDeleteSharedIdsCHROMIUM( |
1044 GLuint namespace_id, GLsizei n, const GLuint* ids); | 1035 GLuint namespace_id, GLsizei n, const GLuint* ids); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 } | 1664 } |
1674 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 1665 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
1675 } | 1666 } |
1676 | 1667 |
1677 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 1668 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
1678 if (!resolve_and_bind_) | 1669 if (!resolve_and_bind_) |
1679 return; | 1670 return; |
1680 | 1671 |
1681 ScopedGLErrorSuppressor suppressor(decoder_); | 1672 ScopedGLErrorSuppressor suppressor(decoder_); |
1682 decoder_->RestoreCurrentFramebufferBindings(); | 1673 decoder_->RestoreCurrentFramebufferBindings(); |
1683 if (decoder_->state_.enable_scissor_test) { | 1674 if (decoder_->state_.enable_flags.scissor_test) { |
1684 glEnable(GL_SCISSOR_TEST); | 1675 glEnable(GL_SCISSOR_TEST); |
1685 } | 1676 } |
1686 } | 1677 } |
1687 | 1678 |
1688 ScopedTextureUploadTimer::ScopedTextureUploadTimer(GLES2DecoderImpl* decoder) | 1679 ScopedTextureUploadTimer::ScopedTextureUploadTimer(GLES2DecoderImpl* decoder) |
1689 : decoder_(decoder), | 1680 : decoder_(decoder), |
1690 begin_time_(base::TimeTicks::HighResNow()) { | 1681 begin_time_(base::TimeTicks::HighResNow()) { |
1691 } | 1682 } |
1692 | 1683 |
1693 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1684 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 has_robustness_extension_ = | 2224 has_robustness_extension_ = |
2234 context->HasExtension("GL_ARB_robustness") || | 2225 context->HasExtension("GL_ARB_robustness") || |
2235 context->HasExtension("GL_EXT_robustness"); | 2226 context->HasExtension("GL_EXT_robustness"); |
2236 | 2227 |
2237 if (!InitializeShaderTranslator()) { | 2228 if (!InitializeShaderTranslator()) { |
2238 return false; | 2229 return false; |
2239 } | 2230 } |
2240 | 2231 |
2241 state_.viewport_width = size.width(); | 2232 state_.viewport_width = size.width(); |
2242 state_.viewport_height = size.height(); | 2233 state_.viewport_height = size.height(); |
2243 glViewport( | |
2244 state_.viewport_x, state_.viewport_y, | |
2245 state_.viewport_width, state_.viewport_height); | |
2246 | 2234 |
2247 GLint viewport_params[4] = { 0 }; | 2235 GLint viewport_params[4] = { 0 }; |
2248 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | 2236 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
2249 state_.viewport_max_width = viewport_params[0]; | 2237 state_.viewport_max_width = viewport_params[0]; |
2250 state_.viewport_max_height = viewport_params[1]; | 2238 state_.viewport_max_height = viewport_params[1]; |
2251 | 2239 |
2252 state_.scissor_width = state_.viewport_width; | 2240 state_.scissor_width = state_.viewport_width; |
2253 state_.scissor_height = state_.viewport_height; | 2241 state_.scissor_height = state_.viewport_height; |
2254 | 2242 |
2255 // Set all the default state because some GL drivers get it wrong. | 2243 // Set all the default state because some GL drivers get it wrong. |
| 2244 state_.InitCapabilities(); |
| 2245 state_.InitState(); |
2256 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 2246 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
2257 EnableDisable(GL_BLEND, state_.enable_blend); | |
2258 glBlendColor( | |
2259 state_.blend_color_red, | |
2260 state_.blend_color_green, | |
2261 state_.blend_color_blue, | |
2262 state_.blend_color_alpha); | |
2263 glBlendFunc( | |
2264 state_.blend_source_rgb, | |
2265 state_.blend_dest_rgb); | |
2266 glBlendFuncSeparate( | |
2267 state_.blend_source_rgb, | |
2268 state_.blend_dest_rgb, | |
2269 state_.blend_source_alpha, | |
2270 state_.blend_dest_alpha); | |
2271 glBlendEquation( | |
2272 state_.blend_equation_rgb); | |
2273 glBlendEquationSeparate( | |
2274 state_.blend_equation_rgb, state_.blend_equation_alpha); | |
2275 glClearColor( | |
2276 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, | |
2277 state_.color_clear_alpha); | |
2278 glColorMask( | |
2279 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, | |
2280 state_.color_mask_alpha); | |
2281 EnableDisable(GL_CULL_FACE, state_.enable_cull_face); | |
2282 glCullFace(state_.cull_mode); | |
2283 glClearDepth(state_.depth_clear); | |
2284 glDepthFunc(state_.depth_func); | |
2285 glDepthRange(state_.z_near, state_.z_far); | |
2286 EnableDisable(GL_DEPTH_TEST, state_.enable_depth_test); | |
2287 EnableDisable(GL_DITHER, state_.enable_dither); | |
2288 glFrontFace(state_.front_face); | |
2289 glHint(GL_GENERATE_MIPMAP_HINT, state_.hint_generate_mipmap); | 2247 glHint(GL_GENERATE_MIPMAP_HINT, state_.hint_generate_mipmap); |
2290 glLineWidth(state_.line_width); | |
2291 glPixelStorei(GL_PACK_ALIGNMENT, state_.pack_alignment); | 2248 glPixelStorei(GL_PACK_ALIGNMENT, state_.pack_alignment); |
2292 glPolygonOffset(state_.polygon_offset_factor, state_.polygon_offset_units); | |
2293 EnableDisable(GL_POLYGON_OFFSET_FILL, state_.enable_polygon_offset_fill); | |
2294 EnableDisable( | |
2295 GL_SAMPLE_ALPHA_TO_COVERAGE, state_.enable_sample_alpha_to_coverage); | |
2296 EnableDisable(GL_SAMPLE_COVERAGE, state_.enable_sample_coverage); | |
2297 glSampleCoverage(state_.sample_coverage_value, state_.sample_coverage_invert); | |
2298 glScissor( | |
2299 state_.scissor_x, state_.scissor_y, | |
2300 state_.scissor_width, state_.scissor_height); | |
2301 EnableDisable(GL_SCISSOR_TEST, state_.enable_scissor_test); | |
2302 EnableDisable(GL_STENCIL_TEST, state_.enable_stencil_test); | |
2303 glClearStencil(state_.stencil_clear); | |
2304 glStencilFuncSeparate( | |
2305 GL_FRONT, | |
2306 state_.stencil_front_func, | |
2307 state_.stencil_front_ref, | |
2308 state_.stencil_front_mask); | |
2309 glStencilFuncSeparate( | |
2310 GL_BACK, | |
2311 state_.stencil_back_func, | |
2312 state_.stencil_back_ref, | |
2313 state_.stencil_back_mask); | |
2314 glStencilOpSeparate( | |
2315 GL_FRONT, | |
2316 state_.stencil_front_fail_op, | |
2317 state_.stencil_front_z_fail_op, | |
2318 state_.stencil_front_z_pass_op); | |
2319 glStencilOpSeparate( | |
2320 GL_BACK, | |
2321 state_.stencil_back_fail_op, | |
2322 state_.stencil_back_z_fail_op, | |
2323 state_.stencil_back_z_pass_op); | |
2324 glStencilMaskSeparate(GL_FRONT, state_.stencil_front_writemask); | |
2325 glStencilMaskSeparate(GL_BACK, state_.stencil_back_writemask); | |
2326 glPixelStorei(GL_UNPACK_ALIGNMENT, state_.unpack_alignment); | 2249 glPixelStorei(GL_UNPACK_ALIGNMENT, state_.unpack_alignment); |
2327 | 2250 |
2328 DoBindBuffer(GL_ARRAY_BUFFER, 0); | 2251 DoBindBuffer(GL_ARRAY_BUFFER, 0); |
2329 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 2252 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
2330 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 2253 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
2331 DoBindRenderbuffer(GL_RENDERBUFFER, 0); | 2254 DoBindRenderbuffer(GL_RENDERBUFFER, 0); |
2332 | 2255 |
2333 // AMD and Intel drivers on Mac OS apparently get gl_PointCoord | 2256 // AMD and Intel drivers on Mac OS apparently get gl_PointCoord |
2334 // backward from the spec and this setting makes them work | 2257 // backward from the spec and this setting makes them work |
2335 // correctly. rdar://problem/11883495 | 2258 // correctly. rdar://problem/11883495 |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 } | 3316 } |
3394 | 3317 |
3395 void GLES2DecoderImpl::ApplyDirtyState() { | 3318 void GLES2DecoderImpl::ApplyDirtyState() { |
3396 if (clear_state_dirty_) { | 3319 if (clear_state_dirty_) { |
3397 glColorMask( | 3320 glColorMask( |
3398 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, | 3321 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, |
3399 state_.color_mask_alpha && | 3322 state_.color_mask_alpha && |
3400 BoundFramebufferHasColorAttachmentWithAlpha()); | 3323 BoundFramebufferHasColorAttachmentWithAlpha()); |
3401 bool have_depth = BoundFramebufferHasDepthAttachment(); | 3324 bool have_depth = BoundFramebufferHasDepthAttachment(); |
3402 glDepthMask(state_.depth_mask && have_depth); | 3325 glDepthMask(state_.depth_mask && have_depth); |
3403 EnableDisable(GL_DEPTH_TEST, state_.enable_depth_test && have_depth); | 3326 EnableDisable(GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); |
3404 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3327 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3405 glStencilMaskSeparate( | 3328 glStencilMaskSeparate( |
3406 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); | 3329 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); |
3407 glStencilMaskSeparate( | 3330 glStencilMaskSeparate( |
3408 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); | 3331 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); |
3409 EnableDisable(GL_STENCIL_TEST, state_.enable_stencil_test && have_stencil); | 3332 EnableDisable( |
3410 EnableDisable(GL_CULL_FACE, state_.enable_cull_face); | 3333 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); |
3411 EnableDisable(GL_SCISSOR_TEST, state_.enable_scissor_test); | 3334 EnableDisable(GL_CULL_FACE, state_.enable_flags.cull_face); |
3412 EnableDisable(GL_BLEND, state_.enable_blend); | 3335 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| 3336 EnableDisable(GL_BLEND, state_.enable_flags.blend); |
3413 clear_state_dirty_ = false; | 3337 clear_state_dirty_ = false; |
3414 } | 3338 } |
3415 } | 3339 } |
3416 | 3340 |
3417 void GLES2DecoderImpl::BindAndApplyTextureParameters( | 3341 void GLES2DecoderImpl::BindAndApplyTextureParameters( |
3418 TextureManager::TextureInfo* info) { | 3342 TextureManager::TextureInfo* info) { |
3419 glBindTexture(info->target(), info->service_id()); | 3343 glBindTexture(info->target(), info->service_id()); |
3420 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); | 3344 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); |
3421 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); | 3345 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); |
3422 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); | 3346 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3656 } | 3580 } |
3657 return true; | 3581 return true; |
3658 case GL_MAX_VERTEX_UNIFORM_VECTORS: | 3582 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
3659 *num_written = 1; | 3583 *num_written = 1; |
3660 if (params) { | 3584 if (params) { |
3661 *params = group_->max_vertex_uniform_vectors(); | 3585 *params = group_->max_vertex_uniform_vectors(); |
3662 } | 3586 } |
3663 return true; | 3587 return true; |
3664 } | 3588 } |
3665 } | 3589 } |
| 3590 if (GetState(pname, params, num_written)) { |
| 3591 return true; |
| 3592 } |
3666 switch (pname) { | 3593 switch (pname) { |
3667 case GL_MAX_VIEWPORT_DIMS: | 3594 case GL_MAX_VIEWPORT_DIMS: |
3668 if (offscreen_target_frame_buffer_.get()) { | 3595 if (offscreen_target_frame_buffer_.get()) { |
3669 *num_written = 2; | 3596 *num_written = 2; |
3670 if (params) { | 3597 if (params) { |
3671 params[0] = renderbuffer_manager()->max_renderbuffer_size(); | 3598 params[0] = renderbuffer_manager()->max_renderbuffer_size(); |
3672 params[1] = renderbuffer_manager()->max_renderbuffer_size(); | 3599 params[1] = renderbuffer_manager()->max_renderbuffer_size(); |
3673 } | 3600 } |
3674 return true; | 3601 return true; |
3675 } | 3602 } |
(...skipping 15 matching lines...) Expand all Loading... |
3691 if (params) { | 3618 if (params) { |
3692 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); | 3619 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); |
3693 } | 3620 } |
3694 return true; | 3621 return true; |
3695 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 3622 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
3696 *num_written = 1; | 3623 *num_written = 1; |
3697 if (params) { | 3624 if (params) { |
3698 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); | 3625 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); |
3699 } | 3626 } |
3700 return true; | 3627 return true; |
3701 case GL_COLOR_WRITEMASK: | |
3702 *num_written = 4; | |
3703 if (params) { | |
3704 params[0] = state_.color_mask_red; | |
3705 params[1] = state_.color_mask_green; | |
3706 params[2] = state_.color_mask_blue; | |
3707 params[3] = state_.color_mask_alpha; | |
3708 } | |
3709 return true; | |
3710 case GL_DEPTH_WRITEMASK: | |
3711 *num_written = 1; | |
3712 if (params) { | |
3713 params[0] = state_.depth_mask; | |
3714 } | |
3715 return true; | |
3716 case GL_STENCIL_BACK_WRITEMASK: | |
3717 *num_written = 1; | |
3718 if (params) { | |
3719 params[0] = state_.stencil_back_writemask; | |
3720 } | |
3721 return true; | |
3722 case GL_STENCIL_WRITEMASK: | |
3723 *num_written = 1; | |
3724 if (params) { | |
3725 params[0] = state_.stencil_front_writemask; | |
3726 } | |
3727 return true; | |
3728 case GL_DEPTH_TEST: | |
3729 *num_written = 1; | |
3730 if (params) { | |
3731 params[0] = state_.enable_depth_test; | |
3732 } | |
3733 return true; | |
3734 case GL_STENCIL_TEST: | |
3735 *num_written = 1; | |
3736 if (params) { | |
3737 params[0] = state_.enable_stencil_test; | |
3738 } | |
3739 return true; | |
3740 case GL_ALPHA_BITS: | 3628 case GL_ALPHA_BITS: |
3741 *num_written = 1; | 3629 *num_written = 1; |
3742 if (params) { | 3630 if (params) { |
3743 GLint v = 0; | 3631 GLint v = 0; |
3744 glGetIntegerv(GL_ALPHA_BITS, &v); | 3632 glGetIntegerv(GL_ALPHA_BITS, &v); |
3745 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; | 3633 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; |
3746 } | 3634 } |
3747 return true; | 3635 return true; |
3748 case GL_DEPTH_BITS: | 3636 case GL_DEPTH_BITS: |
3749 *num_written = 1; | 3637 *num_written = 1; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4341 target, attachment, renderbuffertarget, service_id); | 4229 target, attachment, renderbuffertarget, service_id); |
4342 GLenum error = PeekGLError(); | 4230 GLenum error = PeekGLError(); |
4343 if (error == GL_NO_ERROR) { | 4231 if (error == GL_NO_ERROR) { |
4344 framebuffer_info->AttachRenderbuffer(attachment, info); | 4232 framebuffer_info->AttachRenderbuffer(attachment, info); |
4345 } | 4233 } |
4346 if (framebuffer_info == state_.bound_draw_framebuffer) { | 4234 if (framebuffer_info == state_.bound_draw_framebuffer) { |
4347 clear_state_dirty_ = true; | 4235 clear_state_dirty_ = true; |
4348 } | 4236 } |
4349 } | 4237 } |
4350 | 4238 |
4351 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { | |
4352 switch (cap) { | |
4353 case GL_BLEND: | |
4354 state_.enable_blend = enabled; | |
4355 return true; | |
4356 case GL_CULL_FACE: | |
4357 state_.enable_cull_face = enabled; | |
4358 return true; | |
4359 case GL_SCISSOR_TEST: | |
4360 state_.enable_scissor_test = enabled; | |
4361 return true; | |
4362 case GL_DEPTH_TEST: { | |
4363 if (state_.enable_depth_test != enabled) { | |
4364 state_.enable_depth_test = enabled; | |
4365 clear_state_dirty_ = true; | |
4366 } | |
4367 return false; | |
4368 } | |
4369 case GL_STENCIL_TEST: | |
4370 if (state_.enable_stencil_test != enabled) { | |
4371 state_.enable_stencil_test = enabled; | |
4372 clear_state_dirty_ = true; | |
4373 } | |
4374 return false; | |
4375 case GL_POLYGON_OFFSET_FILL: | |
4376 state_.enable_polygon_offset_fill = enabled; | |
4377 case GL_DITHER: | |
4378 state_.enable_dither = enabled; | |
4379 case GL_SAMPLE_ALPHA_TO_COVERAGE: | |
4380 state_.enable_sample_alpha_to_coverage = enabled; | |
4381 case GL_SAMPLE_COVERAGE: | |
4382 state_.enable_sample_coverage = enabled; | |
4383 default: | |
4384 return true; | |
4385 } | |
4386 } | |
4387 | |
4388 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 4239 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
4389 if (SetCapabilityState(cap, false)) { | 4240 if (SetCapabilityState(cap, false)) { |
4390 glDisable(cap); | 4241 glDisable(cap); |
4391 } | 4242 } |
4392 } | 4243 } |
4393 | 4244 |
4394 void GLES2DecoderImpl::DoEnable(GLenum cap) { | 4245 void GLES2DecoderImpl::DoEnable(GLenum cap) { |
4395 if (SetCapabilityState(cap, true)) { | 4246 if (SetCapabilityState(cap, true)) { |
4396 glEnable(cap); | 4247 glEnable(cap); |
4397 } | 4248 } |
4398 } | 4249 } |
4399 | 4250 |
4400 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { | |
4401 switch (cap) { | |
4402 case GL_BLEND: | |
4403 return state_.enable_blend; | |
4404 case GL_CULL_FACE: | |
4405 return state_.enable_cull_face; | |
4406 case GL_SCISSOR_TEST: | |
4407 return state_.enable_scissor_test; | |
4408 case GL_DEPTH_TEST: | |
4409 return state_.enable_depth_test; | |
4410 case GL_STENCIL_TEST: | |
4411 return state_.enable_stencil_test; | |
4412 case GL_POLYGON_OFFSET_FILL: | |
4413 return state_.enable_polygon_offset_fill; | |
4414 case GL_DITHER: | |
4415 return state_.enable_dither; | |
4416 case GL_SAMPLE_ALPHA_TO_COVERAGE: | |
4417 return state_.enable_sample_alpha_to_coverage; | |
4418 case GL_SAMPLE_COVERAGE: | |
4419 return state_.enable_sample_coverage; | |
4420 default: | |
4421 return glIsEnabled(cap) != 0; | |
4422 } | |
4423 } | |
4424 | |
4425 void GLES2DecoderImpl::DoDepthRangef(GLclampf znear, GLclampf zfar) { | 4251 void GLES2DecoderImpl::DoDepthRangef(GLclampf znear, GLclampf zfar) { |
4426 state_.z_near = std::min(1.0f, std::max(0.0f, znear)); | 4252 state_.z_near = std::min(1.0f, std::max(0.0f, znear)); |
4427 state_.z_far = std::min(1.0f, std::max(0.0f, zfar)); | 4253 state_.z_far = std::min(1.0f, std::max(0.0f, zfar)); |
4428 glDepthRange(znear, zfar); | 4254 glDepthRange(znear, zfar); |
4429 } | 4255 } |
4430 | 4256 |
4431 void GLES2DecoderImpl::DoStencilMask(GLuint mask) { | |
4432 state_.stencil_front_writemask = mask; | |
4433 state_.stencil_back_writemask = mask; | |
4434 clear_state_dirty_ = true; | |
4435 } | |
4436 | |
4437 void GLES2DecoderImpl::DoStencilMaskSeparate(GLenum face, GLuint mask) { | |
4438 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) { | |
4439 state_.stencil_front_writemask = mask; | |
4440 } | |
4441 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { | |
4442 state_.stencil_back_writemask = mask; | |
4443 } | |
4444 clear_state_dirty_ = true; | |
4445 } | |
4446 | |
4447 void GLES2DecoderImpl::DoStencilFunc(GLenum func, GLint ref, GLuint mask) { | |
4448 state_.stencil_front_func = func; | |
4449 state_.stencil_front_ref = ref; | |
4450 state_.stencil_front_mask = mask; | |
4451 state_.stencil_back_func = func; | |
4452 state_.stencil_back_ref = ref; | |
4453 state_.stencil_back_mask = mask; | |
4454 glStencilFunc(func, ref, mask); | |
4455 } | |
4456 | |
4457 void GLES2DecoderImpl::DoStencilFuncSeparate( | |
4458 GLenum face, GLenum func, GLint ref, GLuint mask) { | |
4459 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) { | |
4460 state_.stencil_front_func = func; | |
4461 state_.stencil_front_ref = ref; | |
4462 state_.stencil_front_mask = mask; | |
4463 } | |
4464 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { | |
4465 state_.stencil_back_func = func; | |
4466 state_.stencil_back_ref = ref; | |
4467 state_.stencil_back_mask = mask; | |
4468 } | |
4469 glStencilFuncSeparate(face, func, ref, mask); | |
4470 } | |
4471 | |
4472 void GLES2DecoderImpl::DoStencilOp( | |
4473 GLenum fail, GLenum zfail, GLenum zpass) { | |
4474 state_.stencil_front_fail_op = fail; | |
4475 state_.stencil_front_z_fail_op = zfail; | |
4476 state_.stencil_front_z_pass_op = zpass; | |
4477 state_.stencil_back_fail_op = fail; | |
4478 state_.stencil_back_z_fail_op = zfail; | |
4479 state_.stencil_back_z_pass_op = zpass; | |
4480 glStencilOp(fail, zfail, zpass); | |
4481 } | |
4482 | |
4483 void GLES2DecoderImpl::DoStencilOpSeparate( | |
4484 GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { | |
4485 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) { | |
4486 state_.stencil_front_fail_op = fail; | |
4487 state_.stencil_front_z_fail_op = zfail; | |
4488 state_.stencil_front_z_pass_op = zpass; | |
4489 } | |
4490 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { | |
4491 state_.stencil_back_fail_op = fail; | |
4492 state_.stencil_back_z_fail_op = zfail; | |
4493 state_.stencil_back_z_pass_op = zpass; | |
4494 } | |
4495 glStencilOpSeparate(face, fail, zfail, zpass); | |
4496 } | |
4497 | |
4498 void GLES2DecoderImpl::DoBlendEquation(GLenum mode) { | |
4499 state_.blend_equation_rgb = mode; | |
4500 state_.blend_equation_alpha = mode; | |
4501 glBlendEquation(mode); | |
4502 } | |
4503 | |
4504 void GLES2DecoderImpl::DoBlendFunc(GLenum sfactor, GLenum dfactor) { | |
4505 state_.blend_source_rgb = sfactor; | |
4506 state_.blend_dest_rgb = dfactor; | |
4507 state_.blend_source_alpha = sfactor; | |
4508 state_.blend_dest_alpha = dfactor; | |
4509 glBlendFunc(sfactor, dfactor); | |
4510 } | |
4511 | |
4512 void GLES2DecoderImpl::DoHint(GLenum target, GLenum mode) { | 4257 void GLES2DecoderImpl::DoHint(GLenum target, GLenum mode) { |
4513 switch (target) { | 4258 switch (target) { |
4514 case GL_GENERATE_MIPMAP_HINT: | 4259 case GL_GENERATE_MIPMAP_HINT: |
4515 state_.hint_generate_mipmap = mode; | 4260 state_.hint_generate_mipmap = mode; |
4516 break; | 4261 break; |
4517 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: | 4262 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
4518 state_.hint_fragment_shader_derivative = mode; | 4263 state_.hint_fragment_shader_derivative = mode; |
4519 break; | 4264 break; |
4520 default: | 4265 default: |
4521 NOTREACHED(); | 4266 NOTREACHED(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4582 } | 4327 } |
4583 } | 4328 } |
4584 | 4329 |
4585 void GLES2DecoderImpl::RestoreClearState() { | 4330 void GLES2DecoderImpl::RestoreClearState() { |
4586 clear_state_dirty_ = true; | 4331 clear_state_dirty_ = true; |
4587 glClearColor( | 4332 glClearColor( |
4588 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, | 4333 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
4589 state_.color_clear_alpha); | 4334 state_.color_clear_alpha); |
4590 glClearStencil(state_.stencil_clear); | 4335 glClearStencil(state_.stencil_clear); |
4591 glClearDepth(state_.depth_clear); | 4336 glClearDepth(state_.depth_clear); |
4592 if (state_.enable_scissor_test) { | 4337 if (state_.enable_flags.scissor_test) { |
4593 glEnable(GL_SCISSOR_TEST); | 4338 glEnable(GL_SCISSOR_TEST); |
4594 } | 4339 } |
4595 } | 4340 } |
4596 | 4341 |
4597 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { | 4342 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { |
4598 FramebufferManager::FramebufferInfo* framebuffer = | 4343 FramebufferManager::FramebufferInfo* framebuffer = |
4599 GetFramebufferInfoForTarget(target); | 4344 GetFramebufferInfoForTarget(target); |
4600 if (!framebuffer) { | 4345 if (!framebuffer) { |
4601 return GL_FRAMEBUFFER_COMPLETE; | 4346 return GL_FRAMEBUFFER_COMPLETE; |
4602 } | 4347 } |
(...skipping 4935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9538 GL_RGBA, GL_UNSIGNED_BYTE, false); | 9283 GL_RGBA, GL_UNSIGNED_BYTE, false); |
9539 } | 9284 } |
9540 | 9285 |
9541 // Include the auto-generated part of this file. We split this because it means | 9286 // Include the auto-generated part of this file. We split this because it means |
9542 // we can easily edit the non-auto generated parts right here in this file | 9287 // we can easily edit the non-auto generated parts right here in this file |
9543 // instead of having to edit some template or the code generator. | 9288 // instead of having to edit some template or the code generator. |
9544 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9289 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9545 | 9290 |
9546 } // namespace gles2 | 9291 } // namespace gles2 |
9547 } // namespace gpu | 9292 } // namespace gpu |
OLD | NEW |