Chromium Code Reviews| Index: gpu/command_buffer/service/context_state.cc |
| diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc |
| index e8912cfe1625b769dc0047b935c2f098aed31da3..68f3fd31a26dbecb740bdf43953a1a2f6b7086fb 100644 |
| --- a/gpu/command_buffer/service/context_state.cc |
| +++ b/gpu/command_buffer/service/context_state.cc |
| @@ -40,6 +40,7 @@ ContextState::ContextState(FeatureInfo* feature_info, Logger* logger) |
| pack_reverse_row_order(false), |
| fbo_binding_for_scissor_workaround_dirty_(false), |
| feature_info_(feature_info), |
| + max_active_texture_unit_(0), |
| error_state_(ErrorState::Create(logger)) { |
| Initialize(); |
| } |
| @@ -101,9 +102,17 @@ void ContextState::RestoreActiveTexture() const { |
| glActiveTexture(GL_TEXTURE0 + active_texture_unit); |
| } |
| -void ContextState::RestoreAllTextureUnitBindings() const { |
| +void ContextState::RestoreAllTextureUnitBindings( |
| + const ContextState* prev_state) const { |
| + size_t units_to_restore = texture_units.size(); |
|
boliu
2013/12/18 19:55:11
Should this be max_active_texture_unit_?
|
| + if (prev_state) { |
| + // Only restore units that have been modified by both contexts. |
| + units_to_restore = std::max(prev_state->max_active_texture_unit_, |
| + max_active_texture_unit_) + 1; |
|
no sievers
2013/12/18 19:36:20
Do we really need |max_active_texture_unit_| which
kaanb
2013/12/18 19:43:56
Having max_active_texture_unit_ is useful as it re
boliu
2013/12/18 19:55:11
Just diffing against prev_state would be great for
Ken Russell (switch to Gerrit)
2013/12/18 20:09:44
Reducing the number of loop iterations is a premat
|
| + } |
| + |
| // Restore Texture state. |
| - for (size_t ii = 0; ii < texture_units.size(); ++ii) { |
| + for (size_t ii = 0; ii < units_to_restore; ++ii) { |
| RestoreTextureUnitBindings(ii); |
| } |
| RestoreActiveTexture(); |
| @@ -139,8 +148,8 @@ void ContextState::RestoreGlobalState() const { |
| InitState(); |
| } |
| -void ContextState::RestoreState() const { |
| - RestoreAllTextureUnitBindings(); |
| +void ContextState::RestoreState(const ContextState* prev_state) const { |
| + RestoreAllTextureUnitBindings(prev_state); |
| // Restore Attrib State |
| // TODO: This if should not be needed. RestoreState is getting called |