Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1142)

Unified Diff: gpu/command_buffer/service/feature_info.cc

Issue 1716813002: Use GpuPreferences to avoid directly accessing switches in gpu related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/feature_info.cc
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index fd237c32013bfbac0d0621e0d7cee849319f37b0..8056c158917cd0db577820b65f9556e2ef9f3af3 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -13,7 +13,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
-#include "gpu/command_buffer/service/gpu_switches.h"
+#include "gpu/command_buffer/service/gpu_preferences.h"
#include "gpu/command_buffer/service/texture_definition.h"
#include "gpu/config/gpu_switches.h"
#include "ui/gl/gl_bindings.h"
@@ -83,14 +83,10 @@ class StringSet {
// Process a string of wordaround type IDs (seperated by ',') and set up
// the corresponding Workaround flags.
void StringToWorkarounds(
- const std::string& types, FeatureInfo::Workarounds* workarounds) {
+ const std::set<int>& workaround_set,
+ FeatureInfo::Workarounds* workarounds) {
DCHECK(workarounds);
- for (const base::StringPiece& piece :
- base::SplitStringPiece(
- types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
- int number = 0;
- bool succeed = base::StringToInt(piece, &number);
- DCHECK(succeed);
+ for (auto number : workaround_set) {
switch (number) {
#define GPU_OP(type, name) \
case gpu::type: \
@@ -206,33 +202,29 @@ void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) {
if (!command_line)
return;
- if (command_line->HasSwitch(switches::kGpuDriverBugWorkarounds)) {
- std::string types = command_line->GetSwitchValueASCII(
- switches::kGpuDriverBugWorkarounds);
- StringToWorkarounds(types, &workarounds_);
- }
+ const GpuPreferences* gpu_preferences = GpuPreferences::GetInstance();
+
+ StringToWorkarounds(gpu_preferences->gpu_driver_bug_workarounds,
+ &workarounds_);
feature_flags_.enable_shader_name_hashing =
- !command_line->HasSwitch(switches::kDisableShaderNameHashing);
+ !gpu_preferences->disable_shader_name_hashing;
feature_flags_.is_swiftshader =
(command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader");
feature_flags_.enable_subscribe_uniform =
- command_line->HasSwitch(switches::kEnableSubscribeUniformExtension);
+ gpu_preferences->enable_subscribe_uniform_extension;
- enable_unsafe_es3_apis_switch_ =
- command_line->HasSwitch(switches::kEnableUnsafeES3APIs);
+ enable_unsafe_es3_apis_switch_ = gpu_preferences->enable_unsafe_es3_apis;
- enable_gl_path_rendering_switch_ =
- command_line->HasSwitch(switches::kEnableGLPathRendering);
+ enable_gl_path_rendering_switch_ = gpu_preferences->enable_gl_path_rendering;
// The shader translator is needed to translate from WebGL-conformant GLES SL
// to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to
// target context GLSL, implement emulation of OpenGL ES features on OpenGL,
// etc.
// The flag here is for testing only.
- disable_shader_translator_ =
- command_line->HasSwitch(switches::kDisableGLSLTranslator);
+ disable_shader_translator_ = gpu_preferences->disable_glsl_translator;
unsafe_es3_apis_enabled_ = false;

Powered by Google App Engine
This is Rietveld 408576698