#include "ui/gl/gl_features.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "ui/gl/gl_switches.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(IS_ANDROID)
#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 "ui/gfx/android/achoreographer_compat.h"
#include "ui/gfx/android/android_surface_control_compat.h"
#endif
namespace features {
namespace {
#if BUILDFLAG(IS_ANDROID)
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByBrand{
&kDefaultPassthroughCommandDecoder, "BlockListByBrand", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByDevice{
&kDefaultPassthroughCommandDecoder, "BlockListByDevice", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByAndroidBuildId{
&kDefaultPassthroughCommandDecoder, "BlockListByAndroidBuildId", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByManufacturer{
&kDefaultPassthroughCommandDecoder, "BlockListByManufacturer", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByModel{
&kDefaultPassthroughCommandDecoder, "BlockListByModel", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByBoard{
&kDefaultPassthroughCommandDecoder, "BlockListByBoard", ""};
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByAndroidBuildFP{
&kDefaultPassthroughCommandDecoder, "BlockListByAndroidBuildFP", ""};
bool IsDeviceBlocked(const char* field, const std::string& block_list) {
auto disable_patterns = base::SplitString(
block_list, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const auto& disable_pattern : disable_patterns) {
if (base::MatchPattern(field, disable_pattern))
return true;
}
return false;
}
#endif
BASE_FEATURE(…);
const base::FeatureParam<std::string> kForcedANGLEEnabledFeaturesFP{ … };
const base::FeatureParam<std::string> kForcedANGLEDisabledFeaturesFP{ … };
void SplitAndAppendANGLEFeatureList(const std::string& list,
std::vector<std::string>& out_features) { … }
}
#if BUILDFLAG(IS_APPLE)
BASE_FEATURE(kGpuVsync, "GpuVsync", base::FEATURE_DISABLED_BY_DEFAULT);
#else
BASE_FEATURE(…);
#endif
#if BUILDFLAG(ENABLE_VALIDATING_COMMAND_DECODER)
BASE_FEATURE(kDefaultPassthroughCommandDecoder,
"DefaultPassthroughCommandDecoder",
base::FEATURE_ENABLED_BY_DEFAULT
);
#endif
#if BUILDFLAG(IS_MAC)
BASE_FEATURE(kWriteMetalShaderCacheToDisk,
"WriteMetalShaderCacheToDisk",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kUseBuiltInMetalShaderCache,
"UseBuiltInMetalShaderCache",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
#if BUILDFLAG(IS_WIN)
BASE_FEATURE(kUsePrimaryMonitorVSyncIntervalOnSV3,
"UsePrimaryMonitorVSyncIntervalOnSV3",
base::FEATURE_ENABLED_BY_DEFAULT);
#endif
bool UseGpuVsync() { … }
bool IsAndroidFrameDeadlineEnabled() { … }
bool UsePassthroughCommandDecoder() { … }
#if DCHECK_IS_ON()
bool IsANGLEValidationEnabled() { … }
#else
BASE_FEATURE(kDefaultEnableANGLEValidation,
"DefaultEnableANGLEValidation",
base::FEATURE_DISABLED_BY_DEFAULT);
bool IsANGLEValidationEnabled() {
return base::FeatureList::IsEnabled(kDefaultEnableANGLEValidation) &&
UsePassthroughCommandDecoder();
}
#endif
void GetANGLEFeaturesFromCommandLineAndFinch(
const base::CommandLine* command_line,
std::vector<std::string>& enabled_angle_features,
std::vector<std::string>& disabled_angle_features) { … }
}