blob: ddb2ed78da45f3006c164bb460785b67ec973d37 [file] [log] [blame]
ericrk41a1579e2017-02-10 20:56:281// 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
Khushalb39ecde2019-03-06 00:28:566#if defined(OS_ANDROID)
Khushalcc93a502019-04-04 22:12:577#include "base/android/build_info.h"
8#include "base/metrics/field_trial_params.h"
9#include "base/strings/string_split.h"
Khushalb39ecde2019-03-06 00:28:5610#include "ui/gl/android/android_surface_control_compat.h"
11#endif
12
ericrk41a1579e2017-02-10 20:56:2813namespace features {
Khushalcc93a502019-04-04 22:12:5714namespace {
15
16#if defined(OS_ANDROID)
17bool FieldIsInBlacklist(const char* current_value, std::string blacklist_str) {
18 std::vector<std::string> blacklist = base::SplitString(
19 blacklist_str, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
20 for (const std::string& value : blacklist) {
21 if (value == current_value)
22 return true;
23 }
24
25 return false;
26}
27#endif
28
29} // namespace
30
Maggie Chen1ecb0742018-11-28 07:27:3731#if defined(OS_ANDROID)
32// Use android AImageReader when playing videos with MediaPlayer.
33const base::Feature kAImageReaderMediaPlayer{"AImageReaderMediaPlayer",
vikassoni81d7d8e2019-09-09 18:15:2134 base::FEATURE_ENABLED_BY_DEFAULT};
Maggie Chen1ecb0742018-11-28 07:27:3735
36// Use android SurfaceControl API for managing display compositor's buffer queue
37// and using overlays on Android.
38// Note that the feature only works with VizDisplayCompositor enabled.
39const base::Feature kAndroidSurfaceControl{"AndroidSurfaceControl",
Khushal Sagarc2716c72019-09-25 19:32:3240 base::FEATURE_ENABLED_BY_DEFAULT};
Maggie Chen1ecb0742018-11-28 07:27:3741#endif
ericrk41a1579e2017-02-10 20:56:2842
43// Enable GPU Rasterization by default. This can still be overridden by
44// --force-gpu-rasterization or --disable-gpu-rasterization.
Eric Karlba990bf2018-01-03 00:19:3545#if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_CHROMEOS) || \
Sergey Ulanov54c279422019-05-14 01:08:0446 defined(OS_ANDROID) || defined(OS_FUCHSIA)
Eric Karlba990bf2018-01-03 00:19:3547// DefaultEnableGpuRasterization has launched on Mac, Windows, ChromeOS, and
48// Android.
ericrk41a1579e2017-02-10 20:56:2849const base::Feature kDefaultEnableGpuRasterization{
50 "DefaultEnableGpuRasterization", base::FEATURE_ENABLED_BY_DEFAULT};
51#else
52const base::Feature kDefaultEnableGpuRasterization{
53 "DefaultEnableGpuRasterization", base::FEATURE_DISABLED_BY_DEFAULT};
54#endif
55
Adrienne Walkerc87477e2018-06-06 22:28:2156// Enable out of process rasterization by default. This can still be overridden
57// by --enable-oop-rasterization or --disable-oop-rasterization.
58const base::Feature kDefaultEnableOopRasterization{
59 "DefaultEnableOopRasterization", base::FEATURE_DISABLED_BY_DEFAULT};
60
Maggie Chen132c38e52019-02-04 22:18:4761// Allow putting a video swapchain underneath the main swapchain, so overlays
62// can be used even if there are controls on top of the video. It can be
63// enabled only when overlay is supported.
64const base::Feature kDirectCompositionUnderlays{
Maggie Chen78bcd4912019-04-02 00:59:0865 "DirectCompositionUnderlays", base::FEATURE_ENABLED_BY_DEFAULT};
Maggie Chen132c38e52019-02-04 22:18:4766
Sunny Sachanandani35c727c2019-07-09 13:12:5267#if defined(OS_WIN)
68// Use a high priority for GPU process on Windows.
69const base::Feature kGpuProcessHighPriorityWin{
70 "GpuProcessHighPriorityWin", base::FEATURE_DISABLED_BY_DEFAULT};
71#endif
72
Sunny Sachanandani5cd10e962019-06-13 22:55:3273// Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads.
Michael Spang6f14d0052019-07-02 21:03:4974#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
Sunny Sachanandani5cd10e962019-06-13 22:55:3275const base::Feature kGpuUseDisplayThreadPriority{
76 "GpuUseDisplayThreadPriority", base::FEATURE_ENABLED_BY_DEFAULT};
77#else
78const base::Feature kGpuUseDisplayThreadPriority{
79 "GpuUseDisplayThreadPriority", base::FEATURE_DISABLED_BY_DEFAULT};
80#endif
81
Zhenyao Mocc6ea772019-04-25 22:33:5182// Allow GPU watchdog to keep waiting for ackowledgement if one is already
83// issued from the monitored thread.
84const base::Feature kGpuWatchdogNoTerminationAwaitingAcknowledge{
85 "GpuWatchdogNoTerminationAwaitingAcknowledge",
86 base::FEATURE_DISABLED_BY_DEFAULT};
87
Maggie Chen3590ec22019-06-14 00:28:0988// Gpu watchdog V2 to simplify the logic and reduce GPU hangs
89const base::Feature kGpuWatchdogV2{"GpuWatchdogV2",
90 base::FEATURE_DISABLED_BY_DEFAULT};
91
Christopher Cameron4f7ce362019-04-26 02:21:3792#if defined(OS_MACOSX)
93// Enable use of Metal for OOP rasterization.
94const base::Feature kMetal{"Metal", base::FEATURE_DISABLED_BY_DEFAULT};
95#endif
96
Maggie Chen1ecb0742018-11-28 07:27:3797// Causes us to use the SharedImageManager, removing support for the old
98// mailbox system. Any consumers of the GPU process using the old mailbox
99// system will experience undefined results.
100const base::Feature kSharedImageManager{"SharedImageManager",
101 base::FEATURE_DISABLED_BY_DEFAULT};
102
103// For Windows only. Use overlay swapchain to present software protected videos
104// for all GPUs
105const base::Feature kUseDCOverlaysForSoftwareProtectedVideo{
106 "UseDCOverlaysForSoftwareProtectedVideo",
107 base::FEATURE_DISABLED_BY_DEFAULT};
108
Andres Calderon Jaramillo605253d2018-09-05 15:46:35109// Controls the decode acceleration of JPEG images (as opposed to camera
110// captures) in Chrome OS using the VA-API.
111// TODO(andrescj): remove or enable by default in Chrome OS once
112// https://crbug.com/868400 is resolved.
113const base::Feature kVaapiJpegImageDecodeAcceleration{
114 "VaapiJpegImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
115
Gil Dekel8f4b5642019-07-27 05:27:40116// Controls the decode acceleration of WebP images in Chrome OS using the
117// VA-API.
118// TODO(gildekel): remove or enable by default in Chrome OS once
119// https://crbug.com/877694 is resolved.
120const base::Feature kVaapiWebPImageDecodeAcceleration{
121 "VaapiWebPImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
122
Peng Huangdc3c68f42019-09-15 02:27:22123// Enable Vulkan graphics backend if --use-vulkan flag is not used. Otherwise
124// --use-vulkan will be followed.
125const base::Feature kVulkan{"Vulkan", base::FEATURE_DISABLED_BY_DEFAULT};
126
Khushalb39ecde2019-03-06 00:28:56127#if defined(OS_ANDROID)
128bool IsAndroidSurfaceControlEnabled() {
Khushalcc93a502019-04-04 22:12:57129 if (!gl::SurfaceControl::IsSupported())
130 return false;
131
132 if (!base::FeatureList::IsEnabled(kAndroidSurfaceControl))
133 return false;
134
135 if (FieldIsInBlacklist(base::android::BuildInfo::GetInstance()->model(),
136 base::GetFieldTrialParamValueByFeature(
137 kAndroidSurfaceControl, "blacklisted_models"))) {
138 return false;
139 }
140
141 if (FieldIsInBlacklist(
142 base::android::BuildInfo::GetInstance()->android_build_id(),
143 base::GetFieldTrialParamValueByFeature(kAndroidSurfaceControl,
144 "blacklisted_build_ids"))) {
145 return false;
146 }
147
148 return true;
Khushalb39ecde2019-03-06 00:28:56149}
150#endif
151
ericrk41a1579e2017-02-10 20:56:28152} // namespace features