1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/config/gpu_finch_features.h"
#include "base/command_line.h"
#include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_switches.h"
#if defined(OS_ANDROID)
#include "base/android/android_image_reader_compat.h"
#include "base/android/build_info.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "ui/gfx/android/android_surface_control_compat.h"
#endif
namespace features {
namespace {
#if defined(OS_ANDROID)
bool FieldIsInBlocklist(const char* current_value, std::string blocklist_str) {
std::vector<std::string> blocklist = base::SplitString(
blocklist_str, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
for (const std::string& blocklisted_value : blocklist) {
if (base::StartsWith(current_value, blocklisted_value,
base::CompareCase::INSENSITIVE_ASCII)) {
return true;
}
}
return false;
}
#endif
} // namespace
#if defined(OS_ANDROID)
// Used to limit GL version to 2.0 for skia raster on Android.
const base::Feature kUseGles2ForOopR{"UseGles2ForOopR",
base::FEATURE_ENABLED_BY_DEFAULT};
// Use android SurfaceControl API for managing display compositor's buffer queue
// and using overlays on Android. Also used by webview to disable surface
// SurfaceControl.
const base::Feature kAndroidSurfaceControl{"AndroidSurfaceControl",
base::FEATURE_ENABLED_BY_DEFAULT};
// https://crbug.com/1176185 List of devices on which SurfaceControl should be
// disabled.
const base::FeatureParam<std::string> kAndroidSurfaceControlBlocklist{
&kAndroidSurfaceControl, "AndroidSurfaceControlBlocklist", "capri|caprip"};
// Use AImageReader for MediaCodec and MediaPlyer on android.
const base::Feature kAImageReader{"AImageReader",
base::FEATURE_ENABLED_BY_DEFAULT};
// If webview-draw-functor-uses-vulkan is set, use vulkan for composite and
// raster.
const base::Feature kWebViewVulkan{"WebViewVulkan",
base::FEATURE_ENABLED_BY_DEFAULT};
// Used to enable/disable zero copy video path on webview for MCVD.
const base::Feature kWebViewZeroCopyVideo{"WebViewZeroCopyVideo",
base::FEATURE_DISABLED_BY_DEFAULT};
// List of devices on which WebViewZeroCopyVideo should be disabled.
const base::FeatureParam<std::string> kWebViewZeroCopyVideoBlocklist{
&kWebViewZeroCopyVideo, "WebViewZeroCopyVideoBlocklist", ""};
// Used to limit AImageReader max queue size to 1 since many devices especially
// android Tv devices do not support more than 1 images.
const base::Feature kLimitAImageReaderMaxSizeToOne{
"LimitAImageReaderMaxSizeToOne", base::FEATURE_ENABLED_BY_DEFAULT};
// List of devices on which to limit AImageReader max queue size to 1.
const base::FeatureParam<std::string> kLimitAImageReaderMaxSizeToOneBlocklist{
&kLimitAImageReaderMaxSizeToOne, "LimitAImageReaderMaxSizeToOneBlocklist",
"MIBOX"};
#endif
// Enable GPU Rasterization by default. This can still be overridden by
// --enable-gpu-rasterization or --disable-gpu-rasterization.
// DefaultEnableGpuRasterization has launched on Mac, Windows, ChromeOS, and
// Android.
const base::Feature kDefaultEnableGpuRasterization{
"DefaultEnableGpuRasterization",
#if defined(OS_MAC) || defined(OS_WIN) || BUILDFLAG(IS_ASH) || \
defined(OS_ANDROID) || defined(OS_FUCHSIA)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
// Enable out of process rasterization by default. This can still be overridden
// by --disable-oop-rasterization.
const base::Feature kDefaultEnableOopRasterization{
"DefaultEnableOopRasterization", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_WIN)
// Use a high priority for GPU process on Windows.
const base::Feature kGpuProcessHighPriorityWin{
"GpuProcessHighPriorityWin", base::FEATURE_ENABLED_BY_DEFAULT};
// Compute the root damage rect from the surface damage list for overlays on
// Windows.
const base::Feature kDirectCompositionUseOverlayDamageList{
"DirectCompositionUseOverlayDamageList", base::FEATURE_ENABLED_BY_DEFAULT};
#endif
// Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads.
const base::Feature kGpuUseDisplayThreadPriority{
"GpuUseDisplayThreadPriority",
#if defined(OS_ANDROID) || BUILDFLAG(IS_ASH) || defined(OS_WIN)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
// Use a different set of watchdog timeouts on V2
const base::Feature kGpuWatchdogV2NewTimeout{"GpuWatchdogV2NewTimeout",
base::FEATURE_DISABLED_BY_DEFAULT};
#if defined(OS_MAC)
// Enable use of Metal for OOP rasterization.
const base::Feature kMetal{"Metal", base::FEATURE_DISABLED_BY_DEFAULT};
#endif
// Turns on skia deferred display list for out of process raster.
const base::Feature kOopRasterizationDDL{"OopRasterizationDDL",
base::FEATURE_DISABLED_BY_DEFAULT};
// Causes us to use the SharedImageManager, removing support for the old
// mailbox system. Any consumers of the GPU process using the old mailbox
// system will experience undefined results.
const base::Feature kSharedImageManager{"SharedImageManager",
base::FEATURE_DISABLED_BY_DEFAULT};
// Controls the decode acceleration of JPEG images (as opposed to camera
// captures) in Chrome OS using the VA-API.
// TODO(andrescj): remove or enable by default in Chrome OS once
// https://crbug.com/868400 is resolved.
const base::Feature kVaapiJpegImageDecodeAcceleration{
"VaapiJpegImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls the decode acceleration of WebP images in Chrome OS using the
// VA-API.
// TODO(gildekel): remove or enable by default in Chrome OS once
// https://crbug.com/877694 is resolved.
const base::Feature kVaapiWebPImageDecodeAcceleration{
"VaapiWebPImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable Vulkan graphics backend for compositing and rasterization. Defaults to
// native implementation if --use-vulkan flag is not used. Otherwise
// --use-vulkan will be followed.
// Note Android WebView uses kWebViewVulkan instead of this.
const base::Feature kVulkan{"Vulkan", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable SkiaRenderer Dawn graphics backend. On Windows this will use D3D12,
// and on Linux this will use Vulkan.
const base::Feature kSkiaDawn{"SkiaDawn", base::FEATURE_DISABLED_BY_DEFAULT};
// Used to enable shared image mailbox and disable legacy texture mailbox on
// webview.
const base::Feature kEnableSharedImageForWebview{
"EnableSharedImageForWebview", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable GrShaderCache to use with Vulkan backend.
const base::Feature kEnableGrShaderCacheForVulkan{
"EnableGrShaderCacheForVulkan", base::FEATURE_ENABLED_BY_DEFAULT};
bool IsUsingVulkan() {
bool enable = base::FeatureList::IsEnabled(kVulkan);
#if defined(OS_ANDROID)
enable = enable || (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWebViewDrawFunctorUsesVulkan) &&
base::FeatureList::IsEnabled(kWebViewVulkan));
#endif
return enable;
}
#if defined(OS_ANDROID)
bool IsAImageReaderEnabled() {
return base::FeatureList::IsEnabled(kAImageReader) &&
base::android::AndroidImageReader::GetInstance().IsSupported();
}
bool IsAndroidSurfaceControlEnabled() {
const auto* build_info = base::android::BuildInfo::GetInstance();
auto disable_patterns =
base::SplitString(kAndroidSurfaceControlBlocklist.Get(), "|",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const auto& disable_pattern : disable_patterns) {
if (base::MatchPattern(build_info->device(), disable_pattern))
return false;
}
return IsAImageReaderEnabled() &&
base::FeatureList::IsEnabled(kAndroidSurfaceControl) &&
gfx::SurfaceControl::IsSupported();
}
// Many devices do not support more than 1 image to be acquired from the
// AImageReader.(crbug.com/1051705). This method returns true for those
// devices. Currently the list of device model names are sent from server side
// via a finch config file. There is a known device MIBOX for which max size
// should be 1 irrespecticve of the feature LimitAImageReaderMaxSizeToOne
// enabled or not. Get() returns default value even if the feature is disabled.
bool LimitAImageReaderMaxSizeToOne() {
return (FieldIsInBlocklist(base::android::BuildInfo::GetInstance()->model(),
kLimitAImageReaderMaxSizeToOneBlocklist.Get()));
}
// Zero copy is disabled if device can not support 3 max images.
bool IsWebViewZeroCopyVideoEnabled() {
const bool limit_max_size_to_one = LimitAImageReaderMaxSizeToOne();
if (!IsAImageReaderEnabled() || limit_max_size_to_one)
return false;
if (!base::FeatureList::IsEnabled(kWebViewZeroCopyVideo))
return false;
return !(FieldIsInBlocklist(base::android::BuildInfo::GetInstance()->model(),
kWebViewZeroCopyVideoBlocklist.Get()));
}
#endif
} // namespace features
|