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..654c1d4137948aee967cac727639e238bb8e05fb 100644 |
--- a/gpu/command_buffer/service/context_state.cc |
+++ b/gpu/command_buffer/service/context_state.cc |
@@ -10,6 +10,7 @@ |
#include "gpu/command_buffer/service/framebuffer_manager.h" |
#include "gpu/command_buffer/service/program_manager.h" |
#include "gpu/command_buffer/service/renderbuffer_manager.h" |
+#include "ui/gl/dirty_texture_state.h" |
#include "ui/gl/gl_bindings.h" |
#include "ui/gl/gl_implementation.h" |
@@ -47,30 +48,44 @@ ContextState::ContextState(FeatureInfo* feature_info, Logger* logger) |
ContextState::~ContextState() { |
} |
-void ContextState::RestoreTextureUnitBindings(GLuint unit) const { |
+void ContextState::RestoreTextureUnitBindings( |
+ GLuint unit, const gfx::DirtyTextureState* dirty_texture_state) const { |
DCHECK_LT(unit, texture_units.size()); |
const TextureUnit& texture_unit = texture_units[unit]; |
glActiveTexture(GL_TEXTURE0 + unit); |
- GLuint service_id = texture_unit.bound_texture_2d.get() |
- ? texture_unit.bound_texture_2d->service_id() |
- : 0; |
- glBindTexture(GL_TEXTURE_2D, service_id); |
- service_id = texture_unit.bound_texture_cube_map.get() |
- ? texture_unit.bound_texture_cube_map->service_id() |
- : 0; |
- glBindTexture(GL_TEXTURE_CUBE_MAP, service_id); |
- |
- if (feature_info_->feature_flags().oes_egl_image_external) { |
- service_id = texture_unit.bound_texture_external_oes.get() |
- ? texture_unit.bound_texture_external_oes->service_id() |
- : 0; |
+ if (!dirty_texture_state || |
+ dirty_texture_state->IsBinding2DDirtyForUnit(unit)) { |
+ GLuint service_id = texture_unit.bound_texture_2d.get() |
+ ? texture_unit.bound_texture_2d->service_id() |
+ : 0; |
+ glBindTexture(GL_TEXTURE_2D, service_id); |
+ } |
+ |
+ if (!dirty_texture_state || |
+ dirty_texture_state->IsBindingCubeMapDirtyForUnit(unit)) { |
+ GLuint service_id = texture_unit.bound_texture_cube_map.get() |
+ ? texture_unit.bound_texture_cube_map->service_id() |
+ : 0; |
+ glBindTexture(GL_TEXTURE_CUBE_MAP, service_id); |
+ } |
+ |
+ if (feature_info_->feature_flags().oes_egl_image_external && |
+ (!dirty_texture_state || |
+ dirty_texture_state->IsBindingExternalOesDirtyForUnit(unit))) { |
+ GLuint service_id = |
+ texture_unit.bound_texture_external_oes.get() |
+ ? texture_unit.bound_texture_external_oes->service_id() |
+ : 0; |
glBindTexture(GL_TEXTURE_EXTERNAL_OES, service_id); |
} |
- if (feature_info_->feature_flags().arb_texture_rectangle) { |
- service_id = texture_unit.bound_texture_rectangle_arb.get() |
- ? texture_unit.bound_texture_rectangle_arb->service_id() |
- : 0; |
+ if (feature_info_->feature_flags().arb_texture_rectangle && |
+ (!dirty_texture_state || |
+ dirty_texture_state->IsBindingRectangleArbDirtyForUnit(unit))) { |
+ GLuint service_id = |
+ texture_unit.bound_texture_rectangle_arb.get() |
+ ? texture_unit.bound_texture_rectangle_arb->service_id() |
+ : 0; |
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, service_id); |
} |
} |
@@ -101,10 +116,15 @@ void ContextState::RestoreActiveTexture() const { |
glActiveTexture(GL_TEXTURE0 + active_texture_unit); |
} |
-void ContextState::RestoreAllTextureUnitBindings() const { |
+void ContextState::RestoreAllTextureUnitBindings( |
+ const gfx::DirtyTextureState* dirty_texture_state) const { |
+ size_t texture_units_to_restore = |
+ dirty_texture_state ? |
+ dirty_texture_state->GetMaxTextureUnitIndex() + 1 |
+ : texture_units.size(); |
// Restore Texture state. |
- for (size_t ii = 0; ii < texture_units.size(); ++ii) { |
- RestoreTextureUnitBindings(ii); |
+ for (size_t ii = 0; ii < texture_units_to_restore; ++ii) { |
+ RestoreTextureUnitBindings(ii, dirty_texture_state); |
} |
RestoreActiveTexture(); |
} |
@@ -139,8 +159,9 @@ void ContextState::RestoreGlobalState() const { |
InitState(); |
} |
-void ContextState::RestoreState() const { |
- RestoreAllTextureUnitBindings(); |
+void ContextState::RestoreState( |
+ const gfx::DirtyTextureState* dirty_texture_state) const { |
+ RestoreAllTextureUnitBindings(dirty_texture_state); |
// Restore Attrib State |
// TODO: This if should not be needed. RestoreState is getting called |