canvas: Refactor canvas resource provider single buffering mode

Do not use single buffered canvas resource provider without GMB or swap
chain support.  This CL makes the following changes to implement this:

1) GMB images are not used for low latency 2d canvas unless the
   corresponding finch flag is also enabled.  This is only enabled by
   default on ChromeOS.
2) Software (unaccelerated) composited low latency mode is removed since
   it behaved functionally equivalent to regular software composited
   mode. GMBs are still used in this mode, but single buffering is not.
3) Shared bitmap resource provider does not advertise support for single
   buffering.  This was only used in tests, and those tests have been
   fixed to mock the necessary GPU capabilities and finch flags to match
   the configuration used in production code.
4) Tests are added for both GMB and swap chain based single buffering.
   Moreover there are tests that check that single buffering is not
   used unless GMBs or swap chains are enabled.
5) kDirect3DGpuMemoryBuffer and kDirect3DSwapChain resource provider
   types have been merged into kPassThrough and the 2D suffix is removed
   from some of the other types.

Bug: 1011588
Change-Id: Idef5fd9bd699afd3a3008fd487dca63a8cf6b601
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1870052
Reviewed-by: Miguel Casas <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Kenneth Russell <[email protected]>
Reviewed-by: Khushal <[email protected]>
Commit-Queue: Sunny Sachanandani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#722207}
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index 3bbce168..9ada2d6 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -438,5 +438,25 @@
 const base::Feature kDispatchBeforeUnloadOnFreeze{
     "DispatchBeforeUnloadOnFreeze", base::FEATURE_ENABLED_BY_DEFAULT};
 
+// Enables the use of GpuMemoryBuffer images for low latency 2d canvas.
+// TODO(khushalsagar): Enable this if we're using SurfaceControl and GMBs allow
+// us to overlay these resources.
+const base::Feature kLowLatencyCanvas2dImageChromium {
+  "LowLatencyCanvas2dImageChromium",
+#if defined(OS_CHROMEOS)
+      base::FEATURE_ENABLED_BY_DEFAULT
+#else
+      base::FEATURE_DISABLED_BY_DEFAULT
+#endif  // OS_CHROMEOS
+};
+
+// Enables the use of shared image swap chains for low latency 2d canvas.
+const base::Feature kLowLatencyCanvas2dSwapChain{
+    "LowLatencyCanvas2dSwapChain", base::FEATURE_DISABLED_BY_DEFAULT};
+
+// Enables the use of shared image swap chains for low latency webgl canvas.
+const base::Feature kLowLatencyWebGLSwapChain{
+    "LowLatencyWebGLSwapChain", base::FEATURE_DISABLED_BY_DEFAULT};
+
 }  // namespace features
 }  // namespace blink