Plumbing for HDR10 color space surfaces

Add support for setting GLSurface color space to HDR10 which is BT 2020
primaries with SMPTE ST 2084 (PQ) transfer function.  Cleanup color
space conversion between gfx::ColorSpace and GL / GLSurface enums.

This CL doesn't change any behavior.  It's intended to pave the way for
using RGB10A2 surfaces with HDR10 color space in an upcoming CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1565631/

Bug: 937108
Change-Id: I4fbc31c7e8ff322427013ab7572afc4e8fa9e5b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1573172
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: ccameron <ccameron@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#652247}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: e36d10c6d21fa795d30ed0e38f3d681c0b785a25
diff --git a/GLES2/extensions/CHROMIUM/CHROMIUM_resize.txt b/GLES2/extensions/CHROMIUM/CHROMIUM_resize.txt
index 18ec563..0b7daa4 100644
--- a/GLES2/extensions/CHROMIUM/CHROMIUM_resize.txt
+++ b/GLES2/extensions/CHROMIUM/CHROMIUM_resize.txt
@@ -30,6 +30,7 @@
     GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM              0x8AF2
     GL_COLOR_SPACE_SRGB_CHROMIUM                      0x8AF3
     GL_COLOR_SPACE_DISPLAY_P3_CHROMIUM                0x8AF4
+    GL_COLOR_SPACE_HDR10_CHROMIUM                     0x8AF5
 
 New Procedures and Functions
 
@@ -53,7 +54,7 @@
         GL_COLOR_SPACE_SRGB_CHROMIUM: Indicates that the display system should
         interpret output colors as being sRGB values. On EGL-based systems this
         corresponds to using the default value, EGL_GL_COLORSPACE_LINEAR_KHR,
-        for the EGL_GL_COLORSPACE_KHR property in EGL_KHR_gl_colorspace. 
+        for the EGL_GL_COLORSPACE_KHR property in EGL_KHR_gl_colorspace.
         GL_COLOR_SPACE_DISPLAY_P3_CHROMIUM: Indicates that the display system
         should interpret output colors as being in P3 D65 color space. As above,
         this corresponds to the EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT value
diff --git a/GLES2/extensions/CHROMIUM/CHROMIUM_shared_image.txt b/GLES2/extensions/CHROMIUM/CHROMIUM_shared_image.txt
index 35cfcb9..def75e9 100644
--- a/GLES2/extensions/CHROMIUM/CHROMIUM_shared_image.txt
+++ b/GLES2/extensions/CHROMIUM/CHROMIUM_shared_image.txt
@@ -110,8 +110,8 @@
 New Tokens
 
     Accepted by the <mode> parameter of BeginSharedImageAccessCHROMIUM:
-    SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM        0x8AF5
-    SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM   0x8AF6
+    SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM        0x8AF6
+    SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM   0x8AF7
 
 Errors
 
diff --git a/GLES2/gl2extchromium.h b/GLES2/gl2extchromium.h
index bf112ff..ad7e3d0 100644
--- a/GLES2/gl2extchromium.h
+++ b/GLES2/gl2extchromium.h
@@ -635,6 +635,10 @@
 #define GL_COLOR_SPACE_DISPLAY_P3_CHROMIUM 0x8AF4
 #endif
 
+#ifndef GL_COLOR_SPACE_HDR10_CHROMIUM
+#define GL_COLOR_SPACE_HDR10_CHROMIUM 0x8AF5
+#endif
+
 #endif  /* GL_CHROMIUM_resize */
 
 /* GL_CHROMIUM_get_multiple */
@@ -1279,8 +1283,8 @@
 /* GL_CHROMIUM_shared_image */
 #ifndef GL_CHROMIUM_shared_image
 #define GL_CHROMIUM_shared_image 1
-#define GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM 0x8AF5
-#define GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM 0x8AF6
+#define GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM 0x8AF6
+#define GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM 0x8AF7
 #endif /* GL_CHROMIUM_shared_image */
 
 #ifdef __cplusplus
diff --git a/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
index fc9ba06..4d57dce 100644
--- a/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
+++ b/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
@@ -2694,10 +2694,14 @@
     },
     {
         0x8AF5,
-        "GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM",
+        "GL_COLOR_SPACE_HDR10_CHROMIUM",
     },
     {
         0x8AF6,
+        "GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM",
+    },
+    {
+        0x8AF7,
         "GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM",
     },
     {
diff --git a/command_buffer/service/gles2_cmd_decoder.cc b/command_buffer/service/gles2_cmd_decoder.cc
index 881c4d0..71ae06b 100644
--- a/command_buffer/service/gles2_cmd_decoder.cc
+++ b/command_buffer/service/gles2_cmd_decoder.cc
@@ -5821,6 +5821,9 @@
     case GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM:
       surface_color_space = gl::GLSurface::ColorSpace::SCRGB_LINEAR;
       break;
+    case GL_COLOR_SPACE_HDR10_CHROMIUM:
+      surface_color_space = gl::GLSurface::ColorSpace::HDR10;
+      break;
     case GL_COLOR_SPACE_SRGB_CHROMIUM:
       surface_color_space = gl::GLSurface::ColorSpace::SRGB;
       break;
diff --git a/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
index 6c2d585..643e0a1 100644
--- a/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
+++ b/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
@@ -3726,6 +3726,9 @@
       case GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM:
         surface_color_space = gl::GLSurface::ColorSpace::SCRGB_LINEAR;
         break;
+      case GL_COLOR_SPACE_HDR10_CHROMIUM:
+        surface_color_space = gl::GLSurface::ColorSpace::HDR10;
+        break;
       case GL_COLOR_SPACE_SRGB_CHROMIUM:
         surface_color_space = gl::GLSurface::ColorSpace::SRGB;
         break;