Guard VaapiVideoDecoder behind more correct flags

Vulkan on linux also needs the features kVulkanFromANGLE and
kDefaultANGLEVulkan to function properly.

Additinoally, Vaapi on GL needs to be guarded behind a flag.

(cherry picked from commit f8f456983cf238d0429ab63466d75357d79a32da)

Bug: 1236697
Bug: 1394888
Bug: 1381114
Bug: 1383140
Change-Id: Ifb9da84b95e71fa39c1559455f25e7efcdc083f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4088731
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1081118}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4098377
Auto-Submit: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Cr-Commit-Position: refs/branch-heads/5414@{#698}
Cr-Branched-From: 4417ee59d7bf6df7a9c9ea28f7722d2ee6203413-refs/heads/main@{#1070088}
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index 92484de..fc450431 100644
--- a/media/base/media_switches.cc
+++ b/media/base/media_switches.cc
@@ -586,6 +586,10 @@
              "VaapiVideoDecoder",
              base::FEATURE_ENABLED_BY_DEFAULT);
 
+BASE_FEATURE(kVaapiVideoDecodeLinuxGL,
+             "VaapiVideoDecodeLinuxGL",
+             base::FEATURE_DISABLED_BY_DEFAULT);
+
 BASE_FEATURE(kVaapiVideoEncodeLinux,
              "VaapiVideoEncoder",
              base::FEATURE_DISABLED_BY_DEFAULT);
diff --git a/media/base/media_switches.h b/media/base/media_switches.h
index 78e148e..5a5bfa3 100644
--- a/media/base/media_switches.h
+++ b/media/base/media_switches.h
@@ -219,6 +219,7 @@
 MEDIA_EXPORT BASE_DECLARE_FEATURE(kUseR16Texture);
 #if BUILDFLAG(IS_LINUX)
 MEDIA_EXPORT BASE_DECLARE_FEATURE(kVaapiVideoDecodeLinux);
+MEDIA_EXPORT BASE_DECLARE_FEATURE(kVaapiVideoDecodeLinuxGL);
 MEDIA_EXPORT BASE_DECLARE_FEATURE(kVaapiVideoEncodeLinux);
 MEDIA_EXPORT BASE_DECLARE_FEATURE(kVaapiIgnoreDriverChecks);
 #endif  // BUILDFLAG(IS_LINUX)
diff --git a/media/mojo/services/gpu_mojo_media_client_cros.cc b/media/mojo/services/gpu_mojo_media_client_cros.cc
index 72aa1af6..f1d7c63 100644
--- a/media/mojo/services/gpu_mojo_media_client_cros.cc
+++ b/media/mojo/services/gpu_mojo_media_client_cros.cc
@@ -78,11 +78,20 @@
     }
     case VideoDecoderType::kVaapi: {
       // Allow VaapiVideoDecoder on GL.
-      if (gpu_preferences.gr_context_type == gpu::GrContextType::kGL)
-        return VideoDecoderType::kVaapi;
+      if (gpu_preferences.gr_context_type == gpu::GrContextType::kGL) {
+        if (base::FeatureList::IsEnabled(kVaapiVideoDecodeLinuxGL)) {
+          return VideoDecoderType::kVaapi;
+        } else {
+          return VideoDecoderType::kUnknown;
+        }
+      }
 #if BUILDFLAG(ENABLE_VULKAN)
       if (gpu_preferences.gr_context_type != gpu::GrContextType::kVulkan)
         return VideoDecoderType::kUnknown;
+      if (!base::FeatureList::IsEnabled(features::kVulkanFromANGLE))
+        return VideoDecoderType::kUnknown;
+      if (!base::FeatureList::IsEnabled(features::kDefaultANGLEVulkan))
+        return VideoDecoderType::kUnknown;
       // If Vulkan is active, check Vulkan info if VaapiVideoDecoder is allowed.
       if (!gpu_info.vulkan_info.has_value())
         return VideoDecoderType::kUnknown;