Remove texture and sampler related code in RasterDecoder.

RasterDecoder uses skia to do rendering, and skia can restore texure
and sampler bindings by itself. So we don't need use ContextState to
do it.

Bug: 902904
Change-Id: I5ce2510b4616aab9087cd61bfbfb88368c6e34ab
Reviewed-on: https://chromium-review.googlesource.com/c/1338159
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611396}
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 60efd73..4afd27fa 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -63,6 +63,12 @@
   // glBindTexture
   scoped_refptr<TextureRef> bound_texture_2d_array;
 
+  bool AnyTargetBound() const {
+    return bound_texture_2d || bound_texture_cube_map ||
+           bound_texture_external_oes || bound_texture_rectangle_arb ||
+           bound_texture_3d || bound_texture_2d_array;
+  }
+
   TextureRef* GetInfoForSamplerType(GLenum type) {
     switch (type) {
       case GL_SAMPLER_2D:
@@ -156,9 +162,7 @@
   template <typename T>
   void SetValues(const T* values);
 
-  ShaderVariableBaseType type() const {
-    return type_;
-  }
+  ShaderVariableBaseType type() const { return type_; }
 
   bool Equal(const Vec4& other) const;
 
@@ -188,14 +192,12 @@
 GPU_GLES2_EXPORT void Vec4::SetValues<GLuint>(const GLuint* values);
 
 struct GPU_GLES2_EXPORT ContextState {
-  enum Dimension {
-    k2D,
-    k3D
-  };
+  enum Dimension { k2D, k3D };
 
   ContextState(FeatureInfo* feature_info,
                ErrorStateClient* error_state_client,
-               Logger* logger);
+               Logger* logger,
+               bool track_texture_and_sampler_units = true);
   ~ContextState();
 
   void set_api(gl::GLApi* api) { api_ = api; }
@@ -229,8 +231,8 @@
                               bool restore_transform_feedback_bindings) const;
   void RestoreRenderbufferBindings();
   void RestoreIndexedUniformBufferBindings(const ContextState* prev_state);
-  void RestoreTextureUnitBindings(
-      GLuint unit, const ContextState* prev_state) const;
+  void RestoreTextureUnitBindings(GLuint unit,
+                                  const ContextState* prev_state) const;
   void RestoreSamplerBinding(GLuint unit, const ContextState* prev_state) const;
 
   void PushTextureUnpackState() const;
@@ -238,10 +240,10 @@
   void DoLineWidth(GLfloat width) const;
 
   // Helper for getting cached state.
-  bool GetStateAsGLint(
-      GLenum pname, GLint* params, GLsizei* num_written) const;
-  bool GetStateAsGLfloat(
-      GLenum pname, GLfloat* params, GLsizei* num_written) const;
+  bool GetStateAsGLint(GLenum pname, GLint* params, GLsizei* num_written) const;
+  bool GetStateAsGLfloat(GLenum pname,
+                         GLfloat* params,
+                         GLsizei* num_written) const;
   bool GetEnabled(GLenum cap) const;
 
   inline void SetDeviceColorMask(GLboolean red,
@@ -339,14 +341,18 @@
 
   void EnableDisableFramebufferSRGB(bool enable);
 
-  #include "gpu/command_buffer/service/context_state_autogen.h"
+#include "gpu/command_buffer/service/context_state_autogen.h"
+
+  // if false, we will not track individual texture and sampler units, instead
+  // we only track if all units are in ground state or not.
+  const bool track_texture_and_sampler_units;
 
   EnableFlags enable_flags;
 
   // Current active texture by 0 - n index.
   // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would
   // be 2.
-  GLuint active_texture_unit;
+  GLuint active_texture_unit = 0u;
 
   // The currently bound array buffer. If this is 0 it is illegal to call
   // glVertexAttribPointer.
@@ -361,9 +367,11 @@
 
   // Which textures are bound to texture units through glActiveTexture.
   std::vector<TextureUnit> texture_units;
+  mutable bool texture_units_in_ground_state = true;
 
   // Which samplers are bound to each texture unit;
   std::vector<scoped_refptr<Sampler>> sampler_units;
+  mutable bool sampler_units_in_ground_state = true;
 
   // We create a transform feedback as the default one per ES3 enabled context
   // instead of using GL's default one to make context switching easier.
@@ -387,12 +395,12 @@
 
   // The currently bound renderbuffer
   scoped_refptr<Renderbuffer> bound_renderbuffer;
-  bool bound_renderbuffer_valid;
+  bool bound_renderbuffer_valid = false;
 
-  bool pack_reverse_row_order;
-  bool ignore_cached_state;
+  bool pack_reverse_row_order = false;
+  bool ignore_cached_state = false;
 
-  mutable bool fbo_binding_for_scissor_workaround_dirty;
+  mutable bool fbo_binding_for_scissor_workaround_dirty = false;
   mutable bool stencil_state_changed_since_validation = true;
 
   GLuint current_draw_framebuffer_client_id = 0;