| 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/context_state.h" | 5 #include "gpu/command_buffer/service/context_state.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 214 } |
| 215 | 215 |
| 216 ContextState::ContextState(FeatureInfo* feature_info, | 216 ContextState::ContextState(FeatureInfo* feature_info, |
| 217 ErrorStateClient* error_state_client, | 217 ErrorStateClient* error_state_client, |
| 218 Logger* logger) | 218 Logger* logger) |
| 219 : active_texture_unit(0), | 219 : active_texture_unit(0), |
| 220 bound_renderbuffer_valid(false), | 220 bound_renderbuffer_valid(false), |
| 221 pack_reverse_row_order(false), | 221 pack_reverse_row_order(false), |
| 222 ignore_cached_state(false), | 222 ignore_cached_state(false), |
| 223 fbo_binding_for_scissor_workaround_dirty(false), | 223 fbo_binding_for_scissor_workaround_dirty(false), |
| 224 framebuffer_srgb_(false), |
| 224 feature_info_(feature_info), | 225 feature_info_(feature_info), |
| 225 error_state_(ErrorState::Create(error_state_client, logger)) { | 226 error_state_(ErrorState::Create(error_state_client, logger)) { |
| 226 Initialize(); | 227 Initialize(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 ContextState::~ContextState() { | 230 ContextState::~ContextState() { |
| 230 } | 231 } |
| 231 | 232 |
| 232 void ContextState::SetLineWidthBounds(GLfloat min, GLfloat max) { | 233 void ContextState::SetLineWidthBounds(GLfloat min, GLfloat max) { |
| 233 line_width_min_ = min; | 234 line_width_min_ = min; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 498 |
| 498 void ContextState::RestoreState(const ContextState* prev_state) { | 499 void ContextState::RestoreState(const ContextState* prev_state) { |
| 499 RestoreAllTextureUnitBindings(prev_state); | 500 RestoreAllTextureUnitBindings(prev_state); |
| 500 RestoreVertexAttribs(); | 501 RestoreVertexAttribs(); |
| 501 RestoreBufferBindings(); | 502 RestoreBufferBindings(); |
| 502 RestoreRenderbufferBindings(); | 503 RestoreRenderbufferBindings(); |
| 503 RestoreProgramSettings(prev_state, true); | 504 RestoreProgramSettings(prev_state, true); |
| 504 RestoreIndexedUniformBufferBindings(prev_state); | 505 RestoreIndexedUniformBufferBindings(prev_state); |
| 505 RestoreGlobalState(prev_state); | 506 RestoreGlobalState(prev_state); |
| 506 | 507 |
| 507 // FRAMEBUFFER_SRGB will be restored lazily at render time. | 508 if (!prev_state) { |
| 508 framebuffer_srgb_valid_ = false; | 509 if (feature_info_->feature_flags().desktop_srgb_support) { |
| 510 framebuffer_srgb_ = false; |
| 511 glDisable(GL_FRAMEBUFFER_SRGB); |
| 512 } |
| 513 } else if (framebuffer_srgb_ != prev_state->framebuffer_srgb_) { |
| 514 // FRAMEBUFFER_SRGB will be restored lazily at render time. |
| 515 framebuffer_srgb_ = prev_state->framebuffer_srgb_; |
| 516 } |
| 509 } | 517 } |
| 510 | 518 |
| 511 ErrorState* ContextState::GetErrorState() { | 519 ErrorState* ContextState::GetErrorState() { |
| 512 return error_state_.get(); | 520 return error_state_.get(); |
| 513 } | 521 } |
| 514 | 522 |
| 515 void ContextState::EnableDisable(GLenum pname, bool enable) const { | 523 void ContextState::EnableDisable(GLenum pname, bool enable) const { |
| 516 if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX && | 524 if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
| 517 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { | 525 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
| 518 // GLES2DecoderImpl::DoDrawElements can handle this situation | 526 // GLES2DecoderImpl::DoDrawElements can handle this situation |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 PixelStoreParams params; | 699 PixelStoreParams params; |
| 692 params.alignment = unpack_alignment; | 700 params.alignment = unpack_alignment; |
| 693 params.row_length = unpack_row_length; | 701 params.row_length = unpack_row_length; |
| 694 if (dimension == k3D) { | 702 if (dimension == k3D) { |
| 695 params.image_height = unpack_image_height; | 703 params.image_height = unpack_image_height; |
| 696 } | 704 } |
| 697 return params; | 705 return params; |
| 698 } | 706 } |
| 699 | 707 |
| 700 void ContextState::EnableDisableFramebufferSRGB(bool enable) { | 708 void ContextState::EnableDisableFramebufferSRGB(bool enable) { |
| 701 if (framebuffer_srgb_valid_ && framebuffer_srgb_ == enable) | 709 if (framebuffer_srgb_ == enable) |
| 702 return; | 710 return; |
| 703 EnableDisable(GL_FRAMEBUFFER_SRGB, enable); | 711 EnableDisable(GL_FRAMEBUFFER_SRGB, enable); |
| 704 framebuffer_srgb_ = enable; | 712 framebuffer_srgb_ = enable; |
| 705 framebuffer_srgb_valid_ = true; | |
| 706 } | 713 } |
| 707 | 714 |
| 708 void ContextState::InitStateManual(const ContextState*) const { | 715 void ContextState::InitStateManual(const ContextState*) const { |
| 709 // Here we always reset the states whether it's different from previous ones. | 716 // Here we always reset the states whether it's different from previous ones. |
| 710 // We have very limited states here; also, once we switch to MANGLE, MANGLE | 717 // We have very limited states here; also, once we switch to MANGLE, MANGLE |
| 711 // will opmitize this. | 718 // will opmitize this. |
| 712 UpdatePackParameters(); | 719 UpdatePackParameters(); |
| 713 UpdateUnpackParameters(); | 720 UpdateUnpackParameters(); |
| 714 } | 721 } |
| 715 | 722 |
| 716 // Include the auto-generated part of this file. We split this because it means | 723 // Include the auto-generated part of this file. We split this because it means |
| 717 // we can easily edit the non-auto generated parts right here in this file | 724 // we can easily edit the non-auto generated parts right here in this file |
| 718 // instead of having to edit some template or the code generator. | 725 // instead of having to edit some template or the code generator. |
| 719 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 726 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 720 | 727 |
| 721 } // namespace gles2 | 728 } // namespace gles2 |
| 722 } // namespace gpu | 729 } // namespace gpu |
| OLD | NEW |