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