1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #include "gpu/config/gpu_finch_features.h"
5 
6 #if defined(OS_ANDROID)
7 #include "base/android/build_info.h"
8 #include "base/metrics/field_trial_params.h"
9 #include "base/strings/string_split.h"
10 #include "ui/gl/android/android_surface_control_compat.h"
11 #endif
12 
13 namespace features {
14 
15 #if defined(OS_ANDROID)
16 // Used only by webview to disable SurfaceControl.
17 const base::Feature kDisableSurfaceControlForWebview{
18     "DisableSurfaceControlForWebview", base::FEATURE_DISABLED_BY_DEFAULT};
19 #endif
20 
21 // Enable GPU Rasterization by default. This can still be overridden by
22 // --force-gpu-rasterization or --disable-gpu-rasterization.
23 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_CHROMEOS) || \
24     defined(OS_ANDROID) || defined(OS_FUCHSIA)
25 // DefaultEnableGpuRasterization has launched on Mac, Windows, ChromeOS, and
26 // Android.
27 const base::Feature kDefaultEnableGpuRasterization{
28     "DefaultEnableGpuRasterization", base::FEATURE_ENABLED_BY_DEFAULT};
29 #else
30 const base::Feature kDefaultEnableGpuRasterization{
31     "DefaultEnableGpuRasterization", base::FEATURE_DISABLED_BY_DEFAULT};
32 #endif
33 
34 // Enable out of process rasterization by default.  This can still be overridden
35 // by --enable-oop-rasterization or --disable-oop-rasterization.
36 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
37 const base::Feature kDefaultEnableOopRasterization{
38     "DefaultEnableOopRasterization", base::FEATURE_ENABLED_BY_DEFAULT};
39 #else
40 const base::Feature kDefaultEnableOopRasterization{
41     "DefaultEnableOopRasterization", base::FEATURE_DISABLED_BY_DEFAULT};
42 #endif
43 
44 // Allow putting a video swapchain underneath the main swapchain, so overlays
45 // can be used even if there are controls on top of the video. It can be
46 // enabled only when overlay is supported.
47 const base::Feature kDirectCompositionUnderlays{
48     "DirectCompositionUnderlays", base::FEATURE_ENABLED_BY_DEFAULT};
49 
50 #if defined(OS_WIN)
51 // Use a high priority for GPU process on Windows.
52 const base::Feature kGpuProcessHighPriorityWin{
53     "GpuProcessHighPriorityWin", base::FEATURE_ENABLED_BY_DEFAULT};
54 #endif
55 
56 // Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads.
57 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_WIN)
58 const base::Feature kGpuUseDisplayThreadPriority{
59     "GpuUseDisplayThreadPriority", base::FEATURE_ENABLED_BY_DEFAULT};
60 #else
61 const base::Feature kGpuUseDisplayThreadPriority{
62     "GpuUseDisplayThreadPriority", base::FEATURE_DISABLED_BY_DEFAULT};
63 #endif
64 
65 // Gpu watchdog V2 to simplify the logic and reduce GPU hangs
66 const base::Feature kGpuWatchdogV2{"GpuWatchdogV2",
67                                    base::FEATURE_ENABLED_BY_DEFAULT};
68 
69 // Use a different set of watchdog timeouts on V1
70 const base::Feature kGpuWatchdogV1NewTimeout{"GpuWatchdogV1NewTimeout",
71                                              base::FEATURE_ENABLED_BY_DEFAULT};
72 
73 // Use a different set of watchdog timeouts on V2
74 const base::Feature kGpuWatchdogV2NewTimeout{"GpuWatchdogV2NewTimeout",
75                                              base::FEATURE_DISABLED_BY_DEFAULT};
76 
77 #if defined(OS_MACOSX)
78 // Enable use of Metal for OOP rasterization.
79 const base::Feature kMetal{"Metal", base::FEATURE_DISABLED_BY_DEFAULT};
80 #endif
81 
82 // Causes us to use the SharedImageManager, removing support for the old
83 // mailbox system. Any consumers of the GPU process using the old mailbox
84 // system will experience undefined results.
85 const base::Feature kSharedImageManager{"SharedImageManager",
86                                         base::FEATURE_DISABLED_BY_DEFAULT};
87 
88 // For Windows only. Use overlay swapchain to present software protected videos
89 // for all GPUs
90 const base::Feature kUseDCOverlaysForSoftwareProtectedVideo{
91     "UseDCOverlaysForSoftwareProtectedVideo",
92     base::FEATURE_DISABLED_BY_DEFAULT};
93 
94 // Controls the decode acceleration of JPEG images (as opposed to camera
95 // captures) in Chrome OS using the VA-API.
96 // TODO(andrescj): remove or enable by default in Chrome OS once
97 // https://crbug.com/868400 is resolved.
98 const base::Feature kVaapiJpegImageDecodeAcceleration{
99     "VaapiJpegImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
100 
101 // Controls the decode acceleration of WebP images in Chrome OS using the
102 // VA-API.
103 // TODO(gildekel): remove or enable by default in Chrome OS once
104 // https://crbug.com/877694 is resolved.
105 const base::Feature kVaapiWebPImageDecodeAcceleration{
106     "VaapiWebPImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
107 
108 // Enable Vulkan graphics backend for compositing and rasterization. Defaults to
109 // native implementation if --use-vulkan flag is not used. Otherwise
110 // --use-vulkan will be followed.
111 const base::Feature kVulkan{"Vulkan", base::FEATURE_DISABLED_BY_DEFAULT};
112 
113 // Enable SkiaRenderer Dawn graphics backend. On Windows this will use D3D12,
114 // and on Linux this will use Vulkan.
115 const base::Feature kSkiaDawn{"SkiaDawn", base::FEATURE_DISABLED_BY_DEFAULT};
116 
117 // Used to enable shared image mailbox and disable legacy texture mailbox on
118 // webview.
119 const base::Feature kEnableSharedImageForWebview{
120     "EnableSharedImageForWebview", base::FEATURE_DISABLED_BY_DEFAULT};
121 
122 #if defined(OS_ANDROID)
IsAndroidSurfaceControlEnabled()123 bool IsAndroidSurfaceControlEnabled() {
124   if (base::FeatureList::IsEnabled(kDisableSurfaceControlForWebview))
125     return false;
126 
127   return gl::SurfaceControl::IsSupported();
128 }
129 #endif
130 
131 }  // namespace features
132