| 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 framebuffer_srgb_(FRAMEBUFFER_SRGB_DISABLED), |
| 225 feature_info_(feature_info), | 225 feature_info_(feature_info), |
| 226 error_state_(ErrorState::Create(error_state_client, logger)) { | 226 error_state_(ErrorState::Create(error_state_client, logger)) { |
| 227 Initialize(); | 227 Initialize(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 ContextState::~ContextState() { | 230 ContextState::~ContextState() { |
| 231 } | 231 } |
| 232 | 232 |
| 233 void ContextState::RestoreTextureUnitBindings( | 233 void ContextState::RestoreTextureUnitBindings( |
| 234 GLuint unit, const ContextState* prev_state) const { | 234 GLuint unit, const ContextState* prev_state) const { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 488 |
| 489 void ContextState::RestoreState(const ContextState* prev_state) { | 489 void ContextState::RestoreState(const ContextState* prev_state) { |
| 490 RestoreAllTextureUnitBindings(prev_state); | 490 RestoreAllTextureUnitBindings(prev_state); |
| 491 RestoreVertexAttribs(); | 491 RestoreVertexAttribs(); |
| 492 RestoreBufferBindings(); | 492 RestoreBufferBindings(); |
| 493 RestoreRenderbufferBindings(); | 493 RestoreRenderbufferBindings(); |
| 494 RestoreProgramSettings(prev_state, true); | 494 RestoreProgramSettings(prev_state, true); |
| 495 RestoreIndexedUniformBufferBindings(prev_state); | 495 RestoreIndexedUniformBufferBindings(prev_state); |
| 496 RestoreGlobalState(prev_state); | 496 RestoreGlobalState(prev_state); |
| 497 | 497 |
| 498 if (prev_state && framebuffer_srgb_ != prev_state->framebuffer_srgb_) { | 498 if (!prev_state) { |
| 499 framebuffer_srgb_ = FRAMEBUFFER_SRGB_UNDEFINED; |
| 500 } else if (framebuffer_srgb_ != prev_state->framebuffer_srgb_) { |
| 499 // FRAMEBUFFER_SRGB will be restored lazily at render time. | 501 // FRAMEBUFFER_SRGB will be restored lazily at render time. |
| 500 framebuffer_srgb_ = prev_state->framebuffer_srgb_; | 502 framebuffer_srgb_ = prev_state->framebuffer_srgb_; |
| 501 } | 503 } |
| 502 } | 504 } |
| 503 | 505 |
| 504 ErrorState* ContextState::GetErrorState() { | 506 ErrorState* ContextState::GetErrorState() { |
| 505 return error_state_.get(); | 507 return error_state_.get(); |
| 506 } | 508 } |
| 507 | 509 |
| 508 void ContextState::EnableDisable(GLenum pname, bool enable) const { | 510 void ContextState::EnableDisable(GLenum pname, bool enable) const { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 DCHECK_EQ(0, unpack_skip_images); | 682 DCHECK_EQ(0, unpack_skip_images); |
| 681 PixelStoreParams params; | 683 PixelStoreParams params; |
| 682 params.alignment = unpack_alignment; | 684 params.alignment = unpack_alignment; |
| 683 params.row_length = unpack_row_length; | 685 params.row_length = unpack_row_length; |
| 684 if (dimension == k3D) { | 686 if (dimension == k3D) { |
| 685 params.image_height = unpack_image_height; | 687 params.image_height = unpack_image_height; |
| 686 } | 688 } |
| 687 return params; | 689 return params; |
| 688 } | 690 } |
| 689 | 691 |
| 690 void ContextState::EnableDisableFramebufferSRGB(bool enable) { | 692 void ContextState::EnableDisableFramebufferSRGB(FramebufferSRGBState enable) { |
| 691 if (framebuffer_srgb_ == enable) | 693 if (framebuffer_srgb_ == enable) |
| 692 return; | 694 return; |
| 693 EnableDisable(GL_FRAMEBUFFER_SRGB, enable); | 695 EnableDisable(GL_FRAMEBUFFER_SRGB, |
| 696 enable == FRAMEBUFFER_SRGB_ENABLED ? true : false); |
| 694 framebuffer_srgb_ = enable; | 697 framebuffer_srgb_ = enable; |
| 695 } | 698 } |
| 696 | 699 |
| 697 void ContextState::InitStateManual(const ContextState*) const { | 700 void ContextState::InitStateManual(const ContextState*) const { |
| 698 // Here we always reset the states whether it's different from previous ones. | 701 // Here we always reset the states whether it's different from previous ones. |
| 699 // We have very limited states here; also, once we switch to MANGLE, MANGLE | 702 // We have very limited states here; also, once we switch to MANGLE, MANGLE |
| 700 // will opmitize this. | 703 // will opmitize this. |
| 701 UpdatePackParameters(); | 704 UpdatePackParameters(); |
| 702 UpdateUnpackParameters(); | 705 UpdateUnpackParameters(); |
| 703 } | 706 } |
| 704 | 707 |
| 705 // Include the auto-generated part of this file. We split this because it means | 708 // Include the auto-generated part of this file. We split this because it means |
| 706 // we can easily edit the non-auto generated parts right here in this file | 709 // we can easily edit the non-auto generated parts right here in this file |
| 707 // instead of having to edit some template or the code generator. | 710 // instead of having to edit some template or the code generator. |
| 708 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 711 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 709 | 712 |
| 710 } // namespace gles2 | 713 } // namespace gles2 |
| 711 } // namespace gpu | 714 } // namespace gpu |
| OLD | NEW |