Implement EXT_window_rectangles in command buffer

Spec: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_window_rectangles.txt

Bug: 644265
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I3c4bae9cae8cf839fcf20103db1976e24e148000
Reviewed-on: https://chromium-review.googlesource.com/741866
Commit-Queue: Kai Ninomiya <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Cr-Commit-Position: refs/heads/master@{#513884}
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h
index 3a817ee..940068a 100644
--- a/gpu/command_buffer/service/context_state.h
+++ b/gpu/command_buffer/service/context_state.h
@@ -321,6 +321,20 @@
   // parameters user values; otherwise, set them to 0.
   void UpdateUnpackParameters() const;
 
+  void SetMaxWindowRectangles(size_t max);
+  size_t GetMaxWindowRectangles() const;
+  void SetWindowRectangles(GLenum mode,
+                           size_t count,
+                           const volatile GLint* box);
+  template <typename T>
+  void GetWindowRectangle(GLuint index, T* box) {
+    for (size_t i = 0; i < 4; ++i) {
+      box[i] = window_rectangles_[4 * index + i];
+    }
+  }
+  void UpdateWindowRectangles() const;
+  void UpdateWindowRectanglesForBoundDrawFramebufferClientID(GLuint client_id);
+
   void EnableDisableFramebufferSRGB(bool enable);
 
   #include "gpu/command_buffer/service/context_state_autogen.h"
@@ -378,6 +392,8 @@
 
   mutable bool fbo_binding_for_scissor_workaround_dirty;
 
+  GLuint current_draw_framebuffer_client_id = 0;
+
  private:
   void EnableDisable(GLenum pname, bool enable) const;
 
@@ -397,6 +413,10 @@
   GLfloat line_width_min_ = 0.0f;
   GLfloat line_width_max_ = 1.0f;
 
+  // Stores the list of N window rectangles as N*4 GLints, like
+  // vector<[x,y,w,h]>. Always has space for MAX_WINDOW_RECTANGLES rectangles.
+  std::vector<GLint> window_rectangles_;
+
   gl::GLApi* api_ = nullptr;
   FeatureInfo* feature_info_;
   std::unique_ptr<ErrorState> error_state_;