blob: ae69fcbc53f58698bc458fb3eeb549edab72af52 [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",
34 base::FEATURE_DISABLED_BY_DEFAULT};
35
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",
40 base::FEATURE_DISABLED_BY_DEFAULT};
41#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.
Khushal Sagar4ea644402019-06-13 17:27:3858#if defined(OS_ANDROID)
59const base::Feature kDefaultEnableOopRasterization{
60 "DefaultEnableOopRasterization", base::FEATURE_ENABLED_BY_DEFAULT};
61#else
Adrienne Walkerc87477e2018-06-06 22:28:2162const base::Feature kDefaultEnableOopRasterization{
63 "DefaultEnableOopRasterization", base::FEATURE_DISABLED_BY_DEFAULT};
Khushal Sagar4ea644402019-06-13 17:27:3864#endif
Adrienne Walkerc87477e2018-06-06 22:28:2165
Maggie Chen132c38e52019-02-04 22:18:4766// Allow putting a video swapchain underneath the main swapchain, so overlays
67// can be used even if there are controls on top of the video. It can be
68// enabled only when overlay is supported.
69const base::Feature kDirectCompositionUnderlays{
Maggie Chen78bcd4912019-04-02 00:59:0870 "DirectCompositionUnderlays", base::FEATURE_ENABLED_BY_DEFAULT};
Maggie Chen132c38e52019-02-04 22:18:4771
Sunny Sachanandani35c727c2019-07-09 13:12:5272#if defined(OS_WIN)
73// Use a high priority for GPU process on Windows.
74const base::Feature kGpuProcessHighPriorityWin{
75 "GpuProcessHighPriorityWin", base::FEATURE_DISABLED_BY_DEFAULT};
76#endif
77
Sunny Sachanandani5cd10e962019-06-13 22:55:3278// Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads.
Michael Spang6f14d0052019-07-02 21:03:4979#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
Sunny Sachanandani5cd10e962019-06-13 22:55:3280const base::Feature kGpuUseDisplayThreadPriority{
81 "GpuUseDisplayThreadPriority", base::FEATURE_ENABLED_BY_DEFAULT};
82#else
83const base::Feature kGpuUseDisplayThreadPriority{
84 "GpuUseDisplayThreadPriority", base::FEATURE_DISABLED_BY_DEFAULT};
85#endif
86
Zhenyao Mocc6ea772019-04-25 22:33:5187// Allow GPU watchdog to keep waiting for ackowledgement if one is already
88// issued from the monitored thread.
89const base::Feature kGpuWatchdogNoTerminationAwaitingAcknowledge{
90 "GpuWatchdogNoTerminationAwaitingAcknowledge",
91 base::FEATURE_DISABLED_BY_DEFAULT};
92
Maggie Chen3590ec22019-06-14 00:28:0993// Gpu watchdog V2 to simplify the logic and reduce GPU hangs
94const base::Feature kGpuWatchdogV2{"GpuWatchdogV2",
95 base::FEATURE_DISABLED_BY_DEFAULT};
96
Christopher Cameron4f7ce362019-04-26 02:21:3797#if defined(OS_MACOSX)
98// Enable use of Metal for OOP rasterization.
99const base::Feature kMetal{"Metal", base::FEATURE_DISABLED_BY_DEFAULT};
100#endif
101
Maggie Chen1ecb0742018-11-28 07:27:37102// Causes us to use the SharedImageManager, removing support for the old
103// mailbox system. Any consumers of the GPU process using the old mailbox
104// system will experience undefined results.
105const base::Feature kSharedImageManager{"SharedImageManager",
106 base::FEATURE_DISABLED_BY_DEFAULT};
107
108// For Windows only. Use overlay swapchain to present software protected videos
109// for all GPUs
110const base::Feature kUseDCOverlaysForSoftwareProtectedVideo{
111 "UseDCOverlaysForSoftwareProtectedVideo",
112 base::FEATURE_DISABLED_BY_DEFAULT};
113
Andres Calderon Jaramillo605253d2018-09-05 15:46:35114// Controls the decode acceleration of JPEG images (as opposed to camera
115// captures) in Chrome OS using the VA-API.
116// TODO(andrescj): remove or enable by default in Chrome OS once
117// https://crbug.com/868400 is resolved.
118const base::Feature kVaapiJpegImageDecodeAcceleration{
119 "VaapiJpegImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT};
120
Khushalb39ecde2019-03-06 00:28:56121#if defined(OS_ANDROID)
122bool IsAndroidSurfaceControlEnabled() {
Khushalcc93a502019-04-04 22:12:57123 if (!gl::SurfaceControl::IsSupported())
124 return false;
125
126 if (!base::FeatureList::IsEnabled(kAndroidSurfaceControl))
127 return false;
128
129 if (FieldIsInBlacklist(base::android::BuildInfo::GetInstance()->model(),
130 base::GetFieldTrialParamValueByFeature(
131 kAndroidSurfaceControl, "blacklisted_models"))) {
132 return false;
133 }
134
135 if (FieldIsInBlacklist(
136 base::android::BuildInfo::GetInstance()->android_build_id(),
137 base::GetFieldTrialParamValueByFeature(kAndroidSurfaceControl,
138 "blacklisted_build_ids"))) {
139 return false;
140 }
141
142 return true;
Khushalb39ecde2019-03-06 00:28:56143}
144#endif
145
ericrk41a1579e2017-02-10 20:56:28146} // namespace features